memoryless sources

無記憶情報源。

0リアクション &

Creating a RAM disk on Mac OS X

diskutilhdiutil を使う。

$ diskutil eraseDisk HFS+ RAMDISK `hdiutil attach -nomount ram://524288`

出力はこんなの。

Started erase on disk2
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk2s1 as Mac OS Extended with name RAMDISK
Initialized /dev/rdisk2s1 as a 256 MB HFS Plus volume
Mounting disk
Finished erase on disk2

http://builder.japan.zdnet.com/os-admin/os-x-lion11/35014217/ このページのコメントから。

登録カテゴリ: mac memory disk

0リアクション &

Linux のシェルスクリプトでサブシェルのプロセス ID を取得するには、ビルトインの read コマンドを使って、

(
    read pid _ < /proc/self/stat
    echo $pid > $pidfile
    exec $*
)

みたいに書く。( ... ) 内で $$ を参照しても、親シェルのプロセス ID が返ってきてしまうので。Bash なら $BASHPID でもよい。

cf. bash - $$ in a script vs $$ in a subshell - Stack Overflow

登録カテゴリ: sh shellscript pid linux

0リアクション &

Dropbox 用に 100GB のパーティションを切って、そこにホームフォルダを移動した。

ファイルの移動にはここを参考にして、tar コマンドを使った。 http://www.linuxdevcenter.com/pub/a/linux/lpt/18_16.html

その後、システム環境設定でホームディレクトリのパスを変更して出来上がり。

従来の /Users/ のパスでも参照できるように、シンボリックリンクも作った。

cd /Users/
sudo ln -s /Volumes/Dropbox/Dropbox/Home ./toru
sudo chown toru:staff toru

[EDIT] このままだと、ホームフォルダにある .dropbox というフォルダまで Dropbox が同期しようとするが、この中には Dropbox 自身が使っているメタデータが入っているため、このままでは同期が永久に終わらない。そこで、Dropbox の設定を変更して、このフォルダを同期しないようにした。

[EDIT 2] Dropbox のフォーラムで聞いてみたところ、どうやらホームディレクトリを Dropbox に入れるのはよくないらしいことがわかった。代わりにここで紹介されていた MacDropAny を試してみようと思います。

登録カテゴリ: mac tar dropbox

0リアクション &

Xcode についてくる gcc 4.2 でコンパイルした CppUnit を、g++ 4.8 で書いたテストとリンクすると、こんなエラーがでる。

BigramTest::test_searchtest-bi(92745) malloc: *** error for object 0x7fff79526570: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

CppUnit を g++ 4.8 でコンパイルしてインストールするとなおる。

登録カテゴリ: gcc c++ testing cppunit programming