ミームの死骸を待ちながら

We are built as gene machines and cultured as meme machines, but we have the power to turn against our creators. We, alone on earth, can rebel against the tyranny of the selfish replicators. - Richard Dawkins "Selfish Gene"

We are built as gene machines and cultured as meme machines, but we have the power to turn against our creators.
We, alone on earth, can rebel against the tyranny of the selfish replicators.
- Richard Dawkins "Selfish Gene"

乱雑メモ/ RubyでCGI

sth.rhtmlは空っぽで、sth.rbでopen("../sth.rhtml", "w")して{|io|〜〜:、と書き込んでいく。printでHTML表記(ヒアドキュメント使う)途中でEOLしてMySQLを予備、処理して結果(s)を。最後に、生成したsth.(r)htmlに飛ぶ。

print cgi.header( { 'Status' => '302 moved', 'Location' => '../bbs/index.html' } )

MySQLは小文字つかう。取得したidは配列→.firstでとるが、まだ文字列→.to_iで数字に。パーミッション変えないと(755)、データベースの処理が反映されない。ていうか.rbも.rhtmlもパーミッションうるさすぎ。
what*1「input type="hidden"」
gets による入力は改行つきの文字列なので数を入力するためには明示的な型変換 to_i または to_f が必要

"Rhythm & Blues".sub(/(\w+) & (\w+)/, '\2 & \1')

ループが何重になるか分からないようなプログラムを書く一つのテクニックに, 関数の再帰呼び出しを用いる方法がある

*1:what検索で調べるもの抜き出せるように(個人的都合)