2011-08-11
■homebrew on MacOS10.7(lion)でemacsがinstallできない
いろいろ探したけど、本家のpatchもおかしいので通るように強引のFormula書換。
時間あったらpull request送るけどそんな時間は1ミリもない予感。。。
diff --git a/Library/Formula/emacs.rb b/Library/Formula/emacs.rb
index 33affb7..f88f63f 100644
--- a/Library/Formula/emacs.rb
+++ b/Library/Formula/emacs.rb
if ARGV.include? "--use-git-head"
head 'git://repo.or.cz/emacs.git'
@@ -29,6 +29,8 @@ class Emacs < Formula
# Fix for building with Xcode 4; harmless on Xcode 3.x.
unless ARGV.build_head?
p << "http://repo.or.cz/w/emacs.git/commitdiff_plain/c8bba48c5889c4773c62
+ p << "https://raw.github.com/gist/1098107"
+ p << "https://raw.github.com/gist/1102744"
end
if ARGV.include? "--cocoa"
2011-04-19
■EC2でUbuntuのS3 AMIを作ると起動しない
Commniuty Imageからカスタマイズすると起動しない!!とおもったらgrubとfstabの設定を変えないとダメ。なんでこんな仕様になってるんだw
64bit版の場合。
/boot/grub/menu.lst title Ubuntu 10.10, kernel 2.6.35-24-virtual root (hd0) kernel /boot/vmlinuz-2.6.35-24-virtual root=/dev/sda1 ro console=hvc0 initrd /boot/initrd.img-2.6.35-24-virtual
rootを/dev/sda1に変更。
/etc/fstab # /etc/fstab: static file system information. # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 /dev/sda1 / ext4 defaults 0 0 /dev/sdb /mnt auto defaults,nobootwait,comment=cloudconfig 0 2
/のmount pointを/dev/sda1に変更。
これで起動します。
これで半日つかったよ!!111
2011-04-13
■passenger-nginx-moudle-installでwith-http_ssl_moduleを使えるようにする
rvm+rails+nginxをEC2で使うときに、realipがとるためにnginxのコンパイルオプションを加えないと行けません。
そのためのquickhack
.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.6/bin/passenger-install-nginx-module
393c393
< command = "sh ./configure --prefix='#{prefix}' --with-http_ssl_module "
---
> command = "sh ./configure --prefix='#{prefix}' --with-http_ssl_module --with-http_realip_module "
すればOK。ここがConfigure Optionみたいですね。
2011-02-01
■PythonのPILをMacOS Xでつかったときに怒られる。
先日Pycon mini JPにいった時に、blockdiagというナイスなソフトを知りました。
ので使ってみようと思い、pipからインストールすると怒られます。
reki$:pip install blockdiag
(略)
reki$: blockdiag -o test.png test.diag
Traceback (most recent call last):
File "/usr/local/bin/blockdiag", line 8, in <module>
load_entry_point('blockdiag==0.6.6', 'console_scripts', 'blockdiag')()
File "/Library/Python/2.6/site-packages/blockdiag/blockdiag.py", line 421, in main
draw.draw()
File "/Library/Python/2.6/site-packages/blockdiag/DiagramDraw.py", line 96, in draw
self.node(node, **kwargs)
File "/Library/Python/2.6/site-packages/blockdiag/DiagramDraw.py", line 204, in node
font=self.font, badgeFill=self.badgeFill)
File "/Library/Python/2.6/site-packages/blockdiag/noderenderer/box.py", line 24, in render_node
lineSpacing=metrix.lineSpacing)
File "/Library/Python/2.6/site-packages/blockdiag/ImageDrawEx.py", line 264, in textarea
lines = TextFolder(box, string, scale=self.scale_ratio, **kwargs)
File "/Library/Python/2.6/site-packages/blockdiag/utils/PILTextFolder.py", line 14, in __init__
self.ttfont = ImageFont.truetype(font, fontsize)
File "/Library/Python/2.6/site-packages/PIL/ImageFont.py", line 218, in truetype
return FreeTypeFont(filename, size, index, encoding)
File "/Library/Python/2.6/site-packages/PIL/ImageFont.py", line 134, in __init__
self.font = core.getfont(file, size, index, encoding)
File "/Library/Python/2.6/site-packages/PIL/ImageFont.py", line 34, in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed
しらべると、PIL(Python Image Library)の1.1.6をいれるといいらしいのでいれてみる
reki:$pip uninstall pil reki:$pip install pil==1.1.6 Could not find a version that satisfies the requirement pil==1.1.6 (from versions: ) No distributions matching the version for pil==1.1.6 Storing complete log in /Users/marth/.pip/pip.log
ないっていわれたのでこまった。
Windowsだとバイナリーエディターとか荒技つかうんだけど、Macなので情報なし。
でもいっかいPILをいれてみると……
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
FREETYPE2がサポートされていない!!これが原因だ!!!
というわけでhomebrewでいれてみると(MacPorts嫌い)
reki$brew install freetype2 Error: No available formula for freetype2
ないっていわれたよ(´Д`;)
でしょうがないのでつくったw
https://github.com/yuuna/homebrew/blob/freetype/Library/Formula/freetype2.rb
require 'formula' class Freetype2 <Formula url 'http://sourceforge.net/projects/freetype/files/freetype2/2.4.4/freetype-2.4.4.tar.gz/download' homepage 'http://freetype.sourceforge.net/index2.html' md5 '9273efacffb683483e58a9e113efae9f' version '2.4.4' # depends_on 'cmake' def install system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}" # system "cmake . #{std_cmake_parameters}" system "make install" end end
これを/usr/local/Library/Formula/にいれてFreetypeをいれてpipから再度インストール(pullリクエストおくってるのでそのうちmergeされるかも)
reki:$ sudo brew install freetype2 ==> Downloading http://sourceforge.net/projects/freetype/files/freetype2/2.4.4/freetype-2.4.4.tar.gz/download ######################################################################## 100.0% ==> ./configure --disable-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/freetype2/2.4.4 ==> make install /usr/local/Cellar/freetype2/2.4.4: 54 files, 2.5M, built in 16 seconds reki:$ pip install pil
さすがMacProはやいっ、じゃなくて。
ログの最後をみると
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
無事サポートされたみたい。
というわけで無事うごきました。
よくみるとjpegもサポートされていなかったのでlibjpegをいれて再度いれなおしました。
やっぱりhomebrewだね、homebrewヽ(´ー`)ノ
2010-12-21
■Rubyアドベントカレンダー:rubyでmongodbと戦うときにしっていったほうがいいいくつかのこと(未完了)
Ruby Adventカレンダー参加です。
体調を崩してしまい、熱がでるなら出て寝込みたいのですが、ただひたすら怠いだけで熱もでない状態なので大変辛いです。最近流行てしまっているmongoDBをrubyで使うときに決行大変な思いをしたのでそのへんをまとめて記しておきたいと思います。
病院いったら口内ヘルペスが大量発生してやんごとなき状況になりつつあるので書きかけのまま投稿します。。。
ruby用のmongoDBドライバーの種類
mongo/mongoMapper/mongoid
大きく分けてこの3種類がある
"mongo"はO/R Mapperなどの機能はなくmongoへのinterface、後ろ2個はO/R Mapperの機能を提供している。
インストールは簡単
もうruby1.9.2ならgem installで入ります。終わり。
ないならrvmでもつかってください。
問題が使い方
ふつーRailsで使おうとおもうので、mongoidを使ってみます。
今回の案件では、そもそもCSVデーターのフォーマットがきまっていなかったために、カラムフリーかつ、複数レコード1documentにしたかったのでmongoを選択しました。
……でふたを開けてみたらびっくり。
mongoidをつかうと、事前にmongoidのクラスを定義してcolletionの定義をしないといけないのです。
こんなの全然Document指向のmongoと相反していて使い物になりません。
で、どうするか……。
しょうがないので定義をymlで書いた
今回は1Documentにある方法で識別可能なn個のレコードを格納するので設計はmongoidでいうhas_many関係で記述できます。
とりあえずymlに定義をかいて、rubyのclassにclass_evalをつかって記述方法や、evalでやる方法でクラスを動的に作る方向にしました。ただ、実行時のオーバーヘッドが高いので最終的に初回起動時にファイルに書き出してincludeする方法にしました。
でもyml更新するのめんどい
エンドユーザーに試しに使ってもらったらymlのインデントをタブで書いたりして運用ができないとうことなので、困った私は、csvの1行目を定義につかうことで動的にmongoのDocumentクラスをつかう運用に変更。
でも奴らは日本語を使う
やっぱり動かないのでどうしたのかとおもったら、1行目のカラム名が日本語になっていてなにもできない。こればっかりはどうしょうもないので、ここでmongoidを使うのを放棄。
