2007-08-31

Vim のシンタックスカラー調整

  • まず TERMxterm-256color にする.
  • putty の Cursor Color を 128 128 128 (or 255 135 0) にする.
  • Vim で :colorscheme desert256 とする(desert256.vim は vim.org からとってくる).

見やすい色設定

  • ctermfg=117 [desert256 の Comment; うすい水色]
  • ctermfg=217 [desert256 の Constant; あかるいピンク]
  • ctermfg=224 [murphy の Comment; ピンク]
  • ctermfg=39 [inkpot の Statement; 青]
  • ctermfg=215 [inkpot の Constant; 明るいオレンジ]
  • ctermfg=203 [inkpot の Number; 濃いオレンジ]
  • ctermfg=35 [inkpot の PreProc; 目立たない緑]
  • ctermfg=207 [inkpot の Type; どぎついマゼンタ]

terminal における 256 色

2007-08-27

sshfs

FUSEを利用したssh経由でのリモートディレクトリのマウント.

% sshfs host.example.com: dir
% fusermount -u dir

2007-08-24

Perl の YAML.pm と Unicode

  • YAML::DumpFile で utf8 フラグが立った文字列をダンプすると 'Wide character ...' と警告が出る(どうやって防ぐ?)
  • use utf8;
    use YAML;
    $a = '漢字';
    YAML::DumpFile('a.yaml', $a);
    
  • 上のコードで a.yaml は utf-8 で出力される.次に読み込んでみる.
  • use utf8;
    use YAML;
    $a = YAML::LoadFile('a.yaml');
    print $a;
    
  • 一見うまくいっているように見える.しかし次のようにすると失敗する.
  • use utf8;
    use YAML;
    binmode STDOUT, ':utf8';
    $a = YAML::LoadFile('a.yaml');
    print $a;
    
  • これは,$a がバイト列(中身はたしかに「漢字」の utf-8 表現)として扱われているから(utf8::is_utf8($a) が false).この場合には以下のようにしなければならない.
  • use utf8;
    use YAML;
    binmode STDOUT, ':utf8';
    $a = YAML::LoadFile('a.yaml');
    utf8::decode($a);
    print $a;
    
  • これでは巨大なデータを読んだとき面倒なので,以下のようなハックがある.
  • use utf8;
    use YAML;
    binmode STDOUT, ':utf8';
    $a = YAML::LoadFile('a.yaml');
    $yaml = YAML::Dump($a);
    utf8::decode($yaml);
    $a = YAML::Load($yaml);
    print $a;
    
  • 参考

2007-08-02

Python でのスクリプトファイルのインクルード

f = open('../../../pylib/common.py')
if (f):
    exec(f)
    f.close()

う~む...

あった.

execfile('../../../pylib/common.py')