年が開けた

このブログ見てる人いないと思いますが、今年もよろしくお願いします。

Homebrewでscreenを256色を有効にしてビルドする

/usr/local/Library/Formula/screen256.rb参考 https://gist.github.com/1287202 require 'formula' class Screen256

そろそろ2011年のクリスマスについて一言いっておくか

ぷぎえもんとけいおん!の映画を観に行く夢をみたような気がした。

年開ける前にブログをリニューアルすることにした

がむしゃらにコード以外を書き続けるブログってタイトルにして分けようかと思ったんだけど、 分けると更新手順が別になってやらなくなりそうなのでやめた。 今回からコード以外の話題も取り扱っていきます。

auto-save-buffers.elとguardの相性が悪い件について

auto-save-buffers-enhanced.elでspecファイルを自動保存しないようにした。 (require 'auto-save-buffers-enhanced) (auto-save-buffers-enhanced t) (setq auto-save-buffers-enhanced-include-regexps '(".+")) (setq auto-save-buffers-enhanced-exclude…

git pre commit hookでテストに失敗したらコミットしないようにする。

gitでコミットする前にrspecとjasmine-headless-webkitを実行する。.git/hooks/pre-commit #!/bin/sh if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then # First try to load from a user install source "$HOME/.rvm/scripts/rvm" elif [[ -s "/usr/local/rvm/s…

KeyRemap4MacBookのキーリピートの設定

OS X入れ直す時に前にいくつに設定したか忘れるのでメモ Key Repeatのタブの [Key Repeat] Initial Waitを500から150msに [Key Repeat] Waitを83から15msに

Amazon EC2でnginxをインストールするとき注意すること

--with-file-aioが有効になっていると動かない。 参考 nginx 0.8.25 on an Xen VPS - Ubuntu. eventfd() failed

Googleのトップにリンク追加するGreasemonkeyスクリプト

前に書いてたのを久しぶりに修正した。var listのnameとurlにタイトルとurlを指定して使う。 // ==UserScript== // @name menu // @namespace f96q // @include http://www.google.co.jp/ // ==/UserScript== var list = [ {name: 'Backpack', url: 'http://…

iPhone3G、iPhone4、iPad用のアイコンをまとめて作成

自動でリサイズして名前を付けるシェルスクリプト書いた。 ImageMagic必須。icon.sh #!/bin/sh convert -resize 57x57 $1 Icon.png convert -resize 72x72 $1 Icon-72.png convert -resize 114x114 $1 Icon@2x.png convert -resize 29x29 $1 Icon-Small.png …

UINavigationControllerでナビゲーションバーの高さを取得する

CGFloat height = self.navigationController.navigationBar.frame.size.height;

動的にメソッド実行する

if ([delegate respondsToSelector:selector]) { [delegate performSelector:selector withObject:eventList]; }

速度を測る

NSDate *begin = [NSDate new]; /* なんかの処理。 */ NSLog(@"%f", [[NSDate new] timeIntervalSinceDate:begin]);

メインスレッドか判別する。

if ([[NSThread currentThread] isMainThread]) { NSLog(@"main"); } else { NSLog(@"not main"); }

GNU Screenの設定

256色にする。 ./configure --enable-colors256

現在のリファレンスカウントの参照数を表示する

NSLog(@"%d", [object retainCount]);

非同期にデータを受信したあとコールバック関数で処理する

NetConnection.h #import <Foundation/Foundation.h> @interface NetConnection : NSObject { NSURLConnection *connection; NSMutableData *data; id object; SEL selector; } - (void)initWithURL:(NSString *)url object:(id)object_ selector:(SEL)selector_; @end NetConnection.</foundation/foundation.h>…

ファイル名と行と関数名をいっしょにログ出力する。

#define LogPrintf(fmt, ...) NSLog(@"%s: %d: %s" fmt, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) 最近はこうしてる。

動的にメソッドを書き換える

#import <objc/runtime.h> id length(id self, SEL _cmd, ...) { return 0; } int main(int argc, char *argv[]) { NSString *str = @"abcdefg"; NSLog(@"%d", [str length]);// => 7 Method method = class_getInstanceMethod([str class], @selector(length)); method->met</objc/runtime.h>…

コアの部分のデータ構造

Class struct objc_class { struct objc_class *isa; struct objc_class *super_class; const char *name; long version; long info; long instance_size; struct objc_ivar_list *ivars; struct objc_method_list **methodLists; struct objc_cache *cache;…

YouTubeの動画を組み込む

メソッド - (void)embedYouTube:(NSString*)url frame:(CGRect)frame { NSString* embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ </body></html>

Foundation Classの定義を調べる

class-dumpをパスが通ってる場所に置く。 class-dump /System/Library/Frameworks/Foundation.framework/Foundation > ~/out.h

livedoorReaderを広くして使う

Chromeで使うのに修正した。 function fullWindow() { var style = document.createElement('style') style.type = 'text/css'; style.innerHTML = '#header, #menu, #control, #ads_bottom {display: none;}'; document.body.appendChild(style); } functio…

ChromeでAutoPagerizeでSITEINFOを書く

リロードautopagerize.user.jsにwedataに登録する前にテストする時に書き換えてブラウザをリロードしても反映されないので、 ソースコードが全部入ってるディレクトリを直接読み込んで拡張機能の再読込を使ってリロードした。FirefoxのGreasemonkey版にあっ…

ふぁぼったーのを見れるようにするChromeExtension

Chrome版を作りました。ダウンロードページ

ふぁぼったーのを見れるようにするGreasemonkeyスクリプト(AutoPagerize対応)

インストール // ==UserScript== // @name show censored // @namespace http://d.hatena.ne.jp/f96q/ // @include http://favotter.net/* // ==/UserScript== function $X(xpath, context) { context = context || document; var result = document.evaluat…

debug.js

Chromeでwindow.onerror使えなかった。 window.onerror = function(error, name, line) { alert(name + ':' + line + ':' + error); } function alert(v) { var div =document.createElement('div'); div.innerHTML = v; document.body.appendChild(div); } …

Chrome Extensionsの開発について

Google Chromeの5.0.342.3devで確認。ファイルにアクセスpopup.htmlにアクセスする場合。 IDはchrome://extensions/の拡張機能を読み込んだ時表示されるID。 chrome-extension://[ID]/popup.htmlソースコードの反映FirefoxでGreasemonkey書いてた時みたいに…

WindowsXPのプロファイルディレクトリ

Firefox C:\Documents and Settings\[user]\Application Data\Mozilla\Firefox\ProfilesChrome C:\Documents and Settings\[user]\Local Settings\Application Data\Google\Chrome\User Data

テキスト処理

テキストの置換とか加工するのに使うひな形。 #!/usr/bin/env ruby in = open("in.txt") res = in.read; res = res.gsub(/ /, " ") out = open("out.txt", "w") out.puts res