PIYO - Tech & Life -

Tips

Yosemiteで日本語入力が遅い問題が解決

昨年末にMacbook Pro 15inchに買い替えてからOS X Yosemiteで日本語入力が遅い問題にずっと困っていたのを、さっきおこなった対策で直せた気がするのでメモしておく。 まず、以前試していて少し改

RailsのDBマイグレーションでカラムを変更する

あとからデフォルト値を変えたり、Nullableをやめたりってときのやりかたを忘れがちなのでメモ。 class MigrationName < ActiveRecord::Migration def change change_column :models, :column_name, :integer, null:false, default:0 end end こんな感じです。 change_column :モデル複数形, :属性, :型, {オプション}

iOS、Androidの空き容量をコードで調べる

iOS NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error:nil]; if (dictionary) { int GiB = 1024*1024*1024; float free = [[dictionary objectForKey: NSFileSystemFreeSize] floatValue]/GiB; float total = [[dictionary objectForKey: NSFileSystemSize] floatValue]/GiB; NSLog(@"Space: %.3f", free); NSLog(@"Total: %.3f", total); } Android ディレクトリのパスはいくつかとれますが、デバイスによって使われ方がどうも違うっぽい感じがしました。 写真のデータ置