UITableView用のNSIndexPathの作り方
また忘れたのでメモ。
NSIndexPat
+ (NSIndexPat
h *)indexPathF orRow:(NSUInteger )row inSection: (NSUInteger )section
コードにこんな感じで:
1 NSIndexPath* indexPath = [NSIndexPat h indexPathF orRow:0 inSection: 0];
また忘れたのでメモ。
NSIndexPat
+ (NSIndexPat
h *)indexPathF orRow:(NSUInteger )row inSection: (NSUInteger )section
コードにこんな感じで:
1 NSIndexPath* indexPath = [NSIndexPat h indexPathF orRow:0 inSection: 0];
どこが違うのか気になったのでメモ。
Window-bas
※ Xcode 4.1で動作確認しています。
File - New - New FileでUIViewCont
MainWindow
View - Utilities - Show Object Library を開いて、
- View Controller
をDrag & Drop
View - Utilities - Show Identity Inspector を開いて、
- 先にDropしたView Controller
を選択 - Custom ClassのClassをRootViewCo
ntrollerに - (LabelをRoot View Controller
に)
View - Utilities - Show Attributes
- View Controller
のNIB NameをRootViewCo ntrollerに
View - Assistant Editor - Show Assistant Editor を開いて、
- AppDelegat
eクラス(h)を開く - IB上でoptionキーを押しながらRoot View Controller
を選択、(hファイル上まで)DragしてInsert Outlet Connection を追加(Name:viewContro ller)
下記のようにコード生成されます:
1 @interface RootViewControllerPr otoAppDele gate : NSObject <UIApplicat ionDelegat e> { 2 RootViewCo ntroller *_viewContr oller; 3 } 4 5 6 @property (nonatomic, retain) IBOutlet UIWindow *window; 7 @property (nonatomic, retain) IBOutlet RootViewCo ntroller *viewContro ller;
AppDelegat
1 @class RootViewController;
AppDelegat
1 #import "RootViewController.h " 2 3 - (BOOL)applicatio n:(UIApplicat ion *)applicatio n didFinishL aunchingWi thOptions: (NSDictiona ry *)launchOpti ons 4 { 5 // Override point for customizat ion after applicatio n launch. 6 self.window.rootViewCo ntroller = self.viewContro ller; 7 [self.window makeKeyAnd Visible]; 8 return YES; 9 }
厳密に言うと、View-based
作業をしてみてIB経由でクラスにViewContro
One of my websites had begun to use Amazon ELB for load balancing.
As long as I see the webmaster tools, the +1 audience has stopped its increase since that time.
In addition, the site has issues too on several Google's services such as Google Wireless Transcoder
In my observatio
The DNS of Amazon ELB has TLS of 60 seconds. Google's DNS caching should expire within that period.
See Also
Update
It's turned out that Google+ itself too causes this problem.
ブロック引数を1つとるブロックつき関数を呼び出すときに
1 create_table do |t| 2 t.string :foo 3 end
ブロック仮引数を省略した場合、暗黙のうちにブロック引数に対する instance_e
1 create_table do |t| 2 t.instance_e val do 3 string :foo 4 end 5 end
色々と綺麗にかけるようになる気がします。
1 create_table do 2 string :foo 3 end
ついでに、省略されたブロック引数に $
とかでアクセスできると
1 [1,2,3].map{to_s}.select{$>2}
みたいな事ができて楽しいかもです。 ついでに case の値もこんなふうに
1 case price # <= この値を $ で参照したい 2 when $ < 5; #... 3 when $ < 10; #... 4 end
参照できるといいな。
前回(uninitiali
1 % install_name_tool -change libmysqlcl ient.18.dy lib /usr/local /mysql/lib /libmysqlc lient.18.d ylib /path/to/r ubygems/ge ms/mysql-2 .8.1/lib/m ysql_api.b undle
See Also
EC2のSpotインスタンスの価格変動がどんなものか把握するのが面倒だったので、直近の相場をグラフで表示するwebサービスを作りました。
相場はリージョン、OS毎に違うので、適当な組み合わせを選択してみてください。 データはだいたい5分ごとに更新されています。
実は SpotHistor
ブラウザのタブを閉じるときは基本的に中ボタンクリックなので、閉じるボタンの存在は無駄なだけでなく、うっかり押してしまって必要なタブを閉じてしまうこともあって邪魔でした。
そんな場合には、about:conf
1 browser.tabs.closeBu ttons = 2
普段はPostgresql
ということで、homebrewを使ってインストールすることにしました。
Homebrewをインストール
以下を実行すればok
1 /usr/bin/ruby -e "$(curl -fsSL https://ra w.github.c om/gist/32 3731)"
あとは
1 brew install postgresql
でインストールし、以下でdbを初期化します。
1 initdb /usr/local/var/postg res
最後に、自動起動の設定を行います。
1 cp /usr/local/Cellar/po stgresql/9 .0.4/org.p ostgresql. postgres.p list ~/Library/ LaunchAgen ts/ 2 launchctl load -w ~/Library/ LaunchAgen ts/org.pos tgresql.po stgres.pli st
brewでインストールした場合、postgresユーザは作成されないようです。 $USERがスーパユーザとして作成されます。
以下のようにメソッド引数のデフォルト値を設定すれば、 呼び出す時に省略することができます。
1 def foo(a = nil) 2 a 3 end 4 5 foo #=> nil 6 foo("test") => "test"
では、引数が省略されたかどうか判別するにはどうすればいいでしょうか。 以下のようにすれば判別が可能です。
1 def foo(a = (a_default = true) && nil) 2 [a,a_default] 3 end 4 5 foo #=> [nil, true] 6 foo("test") #=> ["test", nil]
Rubyの引数のデフォルト値は、式を記述でき、省略された場合だけ評価されるのでそれを利用できます。
開発環境でしか使っていないので我慢してきたのですが、
どうも MacOS 10.6.8 における Socket.get
1 ruby-1.8.7-p302 :012 > Socket.get addrinfo("localhost", nil) 2 SocketErro r: getaddrinf o: nodename nor servname provided, or not known 3 from (irb):12:in `getaddrinf o' 4 from (irb):12 5 ruby-1.8.7 -p302 :013 > Socket.get addrinfo("localhost", nil) 6 => [["AF_INET", 0, "en.localho st", "127.0.0.1", 2, 2, 17], ["AF_INET", 0, "en.localho st", "127.0.0.1", 2, 1, 6], ["AF_INET6", 0, "localhost", "::1", 30, 2, 17], ["AF_INET6", 0, "localhost", "::1", 30, 1, 6]]
MacOS環境でのSocket.get
今回は全く同じ条件下で挙動が変わるというものなので、なかなか手ごわい感じです。