2008年5月アーカイブ

たとえば、

class Member < ActiveRecord::Base
end

というモデルがあり、membersテーブルにはnameカラムがあるとする。
すると、

members = Member.find(:all)
member_names = members.map(&:name)

というようにmap(またはcollect)が使える。
これは、以下のようにActiveSuppoprtにSymbol#to_procが定義されているからだ。

class Symbol
  def to_proc
    Proc.new { |obj, *args| obj.send(self, *args) }
  end
end

Symbol#to_procのおかげで、上記のmapのコードは、下記と同じことになる。

members = Member.find(:all)
member_names = members.map { |member| member.name }

カテゴリー:

使用できるエンコーディングをリストする
$ iconv -l
エンコーディング変換例
$ iconv -f SJIS -t EUC-JP sjis.txt > euc.txt
ディレクトリ内の複数ファイルのエンコーディングを変換する例
$ for f in *.txt; do iconv -f euc-jp -t utf-8 "$f" >"$f.utf8"; done

blog.yosy.jp::iconvの使い方

カテゴリー:

TextMate -- The Missing Editor for Mac OS X

TextMate - JotSpot Wiki (ytesaki)

TextMate stuff - hetima.com
日本語入力・表示プラグイン

[TxMt] How to add encodings to "Re-open with encoding" menu
任意のエンコードのファイルを読み込む方法
[TxMt] How to open an encoded file with TextMate?
任意のエンコードのファイルを読み込む方法...こっちはうまくいかなかった。

TextMate Manual Japanese Translation Project | Samurai Coder
TextMateマニュアル日本語訳プロジェクト

TextMate Manual
TextMateマニュアル日本語訳


カテゴリー: