Trac にある python 2.4 よりも前のバージョンとの互換性のためのコード

Trac にある python 2.4 よりも前のバージョンとの互換性のためのコード: http://trac.edgewall.org/browser/trunk/trac/util/compat.py にある。via #1796 (sorted() requires Python2.4) - Trac Hacks - Plugins Macros etc. - Tracよく見ると http://trac…

Trac でニコニコカレンダー - インストールで躓いた

NikoCaleMacro にある手順でインストールしてみると ↓ な感じでエラーが…。 2007-07-12 23:52:48,984 Trac[main] ERROR: global name 'sorted' is not defined Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/trac/web/main.py…

Trac でニコニコカレンダー

Trac でニコニコカレンダーを実現する - NikoCaleMacro - Trac Hacks - Plugins Macros etc. - Trac後でインストールしてみよう。

wsh/vbscript でネットワークアダプターの名前を変更する

「ローカル エリア接続 2」という名前のネットワークアダプターの名前を変更したくなったが、Power Users のアカウントだったので Explorer からでは変更できない。Windows 2000 だから administrator でログオンしなおすのも面倒で、↓ のようなスクリプトを…

CSS のルールを javascript から動的に追加する

display:none にしておいた div の innerHTML に '<span>&nbsp;</span><style type="text/css">' + css + '</style>' を代入する方法もありますが、それ以外の方法です。追加する場合。 function addStyle(css) { var style = document.getElementById("dynamic-style"); if (!style) { style = document.…

migration で blob の代わりに longblob を使わせる

migration で ↓ のように :binary を指定していたら、mysql では blob 型になっていた。 class Init < ActiveRecord::Migration def self.up create_table :articles do |t| t.column :data, :binary end end endblob じゃなくて longblob を使いたいんだけ…

YAML.load で symbol や object が指定されたらエラーにする

YAML.load で symbol や object が指定されたらエラーにするには、以下のように指定すれば可能のようです。 error_proc = Proc.new do |type,value| raise YAML::Error, "Invalid #{type.inspect}, #{value.inspect}" end YAML.add_domain_type('ruby.yaml.o…

Association extensions を block で指定して gettext updatepo を行うとエラーになる

↓ のようなテーブルがあるとします +---------+ +----------+ | authors | --------- | articles | +---------+ 1 N +----------+で ActiveRecord は ↓ のように Association extensions を使ったもの。 class Author < ActiveRecord::Base has_many :articl…

ActionController の verify と :xhr => true を指定したときの TestCase

ActionController には verify というクラスメソッドがあります。「request.method は :post か?」とか「params に :id が含まれているか?」といった検査を :only, :except に該当する action の実行前に行ってくれるものです。update_name という action で…

RELEASE: lighttpd 1.4.12

RELEASE: lighttpd 1.4.12 のようです。/tags/lighttpd-1.4.12 - lighttpd - Trac

rubygems をユーザディレクトリにインストールする

環境変数 GEM_HOME にインストール先を設定して、setup.rb config --prefix でユーザディレクトリを指定する。--prefix を使わないと gem コマンドなどを /usr/bin/gem あたりにインストールしようとするので注意。 $ GEM_HOME="$HOME/mygem"; export GEM_HO…

script/console で URL がどんな params に認識されるかを確かめる

まず config/routes.rb が次のような内容になっているものとします。 ActionController::Routing::Routes.draw do |map| map.connect 'date/:year/:month/:day', :controller => 'blog', :action => 'by_date', :month => nil, :day => nil map.connect ':co…

gettext/rails のロケール決定方法を変える

require 'gettext/rails' を使う場合、gettext のロケール情報は「ブラウザからのアクセスとCookieへの情報格納」にあるように params[:lang], cookies[:lang], HTTP_ACCEPT_LANGAUGE, "en" の順番に参照され決定されます。これを params[:lang], cookies[:l…

rake doc:app で生成される html の文字化けを解消させる

rake doc:app と実行すると app/**/*.rb に記述した RDoc 形式のコメントからドキュメントを生成してくれます。が、ここに日本語を書いて生成させると html が化けてしまいます。Rakefile に以下のコードを書き足して回避しました。ついでに public method …

インストールしている gem の最新バージョンでタグファイルを作成する

rubygems でインストールしている gem から最新バージョンのものだけを対象にして vim 用のタグファイルを作成する。ついでに ruby のライブラリに対してもタグファイルを作成。 こんなスクリプトを用意。これを実行したらそれぞれ ~/.tags-rubygems と ~/.t…

Debian sarge ruby1.8 1.8.2-7sarge4 で mongrel_rails を動かす

mongrel はインストールに ruby 1.8.4 を要求してきて sarge ではインストール出来ません。 $ sudo gem install -r mongrel ... ERROR: While executing gem ... (RuntimeError) mongrel requires Ruby version >= 1.8.4mongrel は 1.8.3 から利用可能になっ…

(new Template("")).constructor != Template になってはまる

prototype.js にある Template クラスを使って次のようなコードを書いてたら、ちっとも真にならなくてはまりました。 function showMessage(message, options) { if (message.constructor == Template) { message = message.evaluate(options); } alert(mess…

gettext/utils があると rake doc:app が失敗する

気づいたら rake doc:app が失敗するようになっていた。 $ rake doc:app rm -r doc/app rake aborted! uninitialized constant AlreadyDefinedToken (See full trace by running task with --trace)調べてみると lib/tasks/gettext.rake に gettext 用のタス…