memo

Middlemanの入れ子レイアウトでエラー undefined method `safe_concat' for "":String

slimでwrap_layout使おうとしてエラーった。- を = に。 wrap_layout doesn't work with slim 参考: wrap_layout doesn't work with slim on ~> 3.3.2 #1269

gulpfileをCoffeeScriptで書く

メモ。 //gulpfile.js require('coffee-script/register'); require('./gulpfile.coffee'); //gulpfile.coffee gulp = require('gulp') gulp.task 'default', () -> console.log('gulp!') 参考。 http://efcl.info/2014/0123/res3625/ http://safx-dev.blogs…

node-webkitでコールバックで書いた非同期処理をPromise使用に書き換えてみた

node-webkitで作ったアプリで、データロード処理と保存処理部分をそれぞれ書き換えてみた。 PromiseのライブラリはBluebirdを使ってみた。 あと、cheerioをDOMのパースに使用。 FTPは、jsftpを使用。 データロード処理の流れ(load) 1. FTPでデータ取得 2. FT…

node-webkitでTypeScriptを使ってはまるケース

node-webkitのJavaScript Contextでのrequireでのパス解決でハマる場合がある。 例えばこんなファイル構成で index.html js index.js(index.ts) fileUploader.js 各ファイルがこんな感じ。 <html> <head > <meta charset="utf-8" /> ................. <script src="js/index.js"></script> </body> </html> //js/index.js ........…

requireしてnewして使用するnpmのパッケージにTypeScript用の型定義ファイルを書く

こういうの。 ///<reference path='./typing/node.d.ts' /> ///<reference path='./typing/jsftp.d.ts' /> import JSFtp = require('jsftp'); .......................... var Ftp = new JSFtp({ host: connect.host, port: connect.port, user: connect.account, pass: connect.password }); .......................... jsftp用に…</reference></reference>

node-webkitでNode contextからGUIのAPIを使う

メニュー出したりとかデスクトップアプリ特有のネイティブのアレをNode側から使いたい。 1.require時に引数として渡す //index.js var gui = require('nw.gui'); //↓コレ var fileUploader = require('fileUploader')(gui); 例なので全部渡しちゃってるけど…

grunt-slim

メモ Gruntfile.coffee ...................................... slim: pretty: options: pretty: true files: [ expand: true cwd: 'src' src: ['{,*/}*.slim'] dest: 'app' ext: '.html' ] ...................................... grunt.loadNpmTasks('gr…

bower_componentsをディレクトリ別の場所に

.bowerrcに記述 { "directory": "app/bower_components" }

gruntで任意の場所でnpm i --productionする

node-webkitで作成したアプリのパッケージングはappディレクトリを対象として実行してて、npmをcd app してからnpm i --productionと手動で処理していたので、Gruntに登録した。 Gruntfile.coffeeの該当箇所 ...... exec: npm_i_production: cwd: 'app' cmd:…

node-webkitでWindows向けアプリケーションのアイコンを変更する

Icons に書いてある。 Resource Hackerで書き換える。 これだとWindowsのパッケージングが自動化出来ないのでアレ。

node-webkitで作ったアプリをWindows向けにパッケージングする

grunt-node-webkit-builder使う。 使う人の環境がWindowsだけど、一応Macも作っとく。 Gruntfile.coffeeはこんな感じ。appディレクトリに集めたファイルをパッケージング。 module.exports = (grunt) -> pkg = grunt.file.readJSON 'package.json' .........…

node-webkit特有の問題にはまった

node-webkitでアプリを開発していて、node-webkitの環境ならでは?の問題にはまったのでメモ。 前提 % bower install eonasdan-bootstrap-datetimepicker --save nodeのcontextではなくJavaScriptのcontextでの話。 アプリでbootstrap 3対応のdatetimepicker…

WebStormでnode-webkitをデバッグする

WebStorm 8.0.1以上、package.json等作成済みとして話を進める。 メニューのRunからEdit Configurations…を選択 node-webkitを追加 アプリの場所を指定。グローバルに入れたnode-webkitではなく、npmでプロジェクト下に入れたnode-webkitを指定する場合はint…

Node.jsの管理をhomebrewからnodebrewに変更

npmでglobalにインストールしたtypescriptとbowerを削除。 % npm uninstall -g bower % npm uninstall -g typescript npmを削除 % npm uninstall -g npm Node.jsを削除 brew uninstall node nodebrewをインストール % curl -L git.io/nodebrew | perl - setu…

VPSからAmazon S3とGoogle Apps for Businessに移行しました

さくらのVPSで運用していたkatahirado.jp(VALUE DOMAINで取得)を、WebサイトはAmazon S3に、メールはGoogle Apps for Businessにそれぞれ移行しました。 Webサイト、メールサーバの他に、redmine、git、Railsのデモアプリが動いていましたが、 git,redmineは…

WebViewに動的にJSを読み込みした後の評価(実行)タイミングではまった

11/20日追記:SafariとChromeでも試して見たところ、JSでbodyに複数appendChildすると順番は一定しない事を確認。そうだったのか。 http://blog.setunai.net/20120317/javascript%E3%81%AE%E5%AE%9F%E8%A1%8C%E9%A0%86%E5%BA%8F%E3%81%AB%E3%81%A4%E3%81%84%E…

ファイルのアイコンを取得する

一つ前のエントリーでは端折っていたが、ファイルのアイコンを取得するのが目的で、pathをあれこれやってあれってなったのであんなエントリーを残した。せっかくなのでアイコン取得もメモ。 pathをStringでアイコン取得する場合。 //_fullPath はこんなのが…

file://localhost/directory/といったURL文字列にstringByAppendingPathComponent:を使うと・・・

やっちゃ駄目って書いてあるからやるほうが悪いんですが・・ stringByAppendingPathComponent:のリファレンスには下記のように書いてあります。 Note that this method only works with file paths (not, for example, string representations of URLs). fil…

WebViewでsetFrameをアニメーションさせようとしたら記述量が多かった

NSAnimatablePropertyContainer プロトコルのanimatorを使えば下記のような感じに書ける↓ https://developer.apple.com/library/mac/#samplecode/BasicCocoaAnimations/Listings/MainWindowController_m.html しかしWebViewでanimatorメソッドを使ってみたら…

jQuery の複数バージョンを同時使用する

http://stacktrace.jp/jquery/with_other_lib.html#other_version noConflictの引数にtrue渡せばいいと。 <html> <head> <script type="text/javascript" src="jquery-1.2.6.js"></script> <script type="text/javascript" src="jquery-1.4.2.js"></script> <script type="text/javascript"> // $ 関数および jQuery関数の上書きを元に戻します。 var $j =…</head></html>

ARC時のBridged Cast

忘れるので。http://blog.natsuapps.com/2011/11/ios5-arc-autorelease-bridge-xcode.html

CoreDataのレコードをJSONに変換する

一つ前のエントリーとは逆に、Objective-CのオブジェクトをJSONへ、のパターン。 素直なNSArrayとかNSDictionaryを処理する場合には特に注意する点はなし*1。 SQLiteがストアのCoreDataで,FetchしたResultのNSArrayをJSONとして渡したい場合等は注意が必要。…

JavaScriptからObjective-CへJSONで渡す

複雑な構造のはJSON使って渡せばよかったんじゃないかorz WebViewのJavaScriptとObjective-Cでのやり取りでもそりゃJSON使えるか。 JSON使うのはWebのAPI叩くときみたいな固定観念が。頭固い。 OS X 10.7から標準でNSJSONSerializationが使える。iOSは5から…

JavaScriptからObjective-Cに渡したArrayでの注意その2

11/7追記:WebKit DOM Programming TopicsのCalling Objective-C Methods From JavaScriptに書いてあった。WebKit側の資料しか見てなかったから気づかなかったorz Other JavaScript objects are wrapped as WebScriptObject instances. As an exception, Java…

JavaScriptからObjective-Cに変換されたNSArrayで配列の要素にアクセスする際の注意

11/7追記:WebKit DOM Programming TopicsのCalling Objective-C Methods From JavaScriptに書いてあった。WebKit側の資料しか見てなかったから気づかなかったorz Other JavaScript objects are wrapped as WebScriptObject instances. As an exception, Java…

NSWebViewでWeb Inspectorを有効にする

OS Xの。 UIWebViewは別。 "WebKitDeveloperExtras"と。 http://qiita.com/items/7c737f8f135199cc82b1 調べたついで。iOSのUIWebViewをOS XのSafariのWeb Inspector使ってリモートデバッグ http://j-apps.sakura.ne.jp/prototype/2011/12/10/uiwebview%E3%8…

WebViewのJavaScriptからObjective-Cのメソッドを呼ぶ時の命名規則

WebScripting Protocol Reference の webScriptNameForSelector: に書いてあった。 It is your responsibility to ensure that the returned name is unique to the script invoking this method. If this method returns nil or you do not implement it, t…

iframeのseamless属性

メモ。 http://www.tohoho-web.com/html/iframe.htm http://hyper-text.org/archives/2012/05/iframe_seamless_attribute.shtml

libxmlでのHTML Parserを調べている過程で見つけたライブラリ

XPathなやつ。Macアプリだと、NSXMLDocumentがあるから不要かな。iPhoneiOSだと、NSXMLDocument使えないのですね。 http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html libxmlのHTMLParserをObjective-Cでラップしたライブラリ。AR…

libxmlのHTMLparserはHTML5をサポートしていない

"interface for an HTML 4.0 non-verifying parser"ってどどんと書いてあるので自明ではあるのですが。 http://xmlsoft.org/html/libxml-HTMLparser.html うーん https://bugzilla.gnome.org/show_bug.cgi?id=655218 HTMLのパースをしたくて色々調べたのです…