天泣記

2010-04-10 (Sat)

#1

timer_settime は async-signal-safe なのか。これはいいかもしれない。

2010-04-18 (Sun)

#1

かねてからの懸案だった、chkbuild で fork メソッドを使っているのをやめた。

Ruby 1.9 では Unix でも fork メソッドが動かないことがあるし。

2010-04-24 (Sat)

#1

「ハーバード白熱教室」を視た。なるほどおもしろい。

#2

第42回 Ruby/Rails勉強会@関西」で「IO クラスについて」という発表があったようだ。

発表資料を眺めようと思ったが、

Error

undefined method `[]' for nil:NilClass
/home/wiki/hiki/hiki/image_size.rb:126:in `check_type'
/home/wiki/hiki/hiki/image_size.rb:69:in `initialize'
/home/wiki/hiki/plugin.available/attach.rb:101:in `new'
/home/wiki/hiki/plugin.available/attach.rb:101:in `attach_download'
/home/wiki/hiki/plugin.available/attach.rb:100:in `open'
/home/wiki/hiki/plugin.available/attach.rb:100:in `attach_download'
/home/wiki/hiki/hiki/plugin.rb:232:in `__send__'
/home/wiki/hiki/hiki/plugin.rb:232:in `send'
/home/wiki/hiki/hiki/command.rb:570:in `cmd_plugin'
/home/wiki/hiki/hiki/command.rb:119:in `send'
/home/wiki/hiki/hiki/command.rb:119:in `dispatch'
/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
/home/wiki/hiki/hiki/command.rb:89:in `dispatch'
/home/wiki/hiki/hiki.cgi:38
/home/wiki/hiki/hiki/storage.rb:14:in `open_db'
/home/wiki/hiki/hiki.cgi:36
/home/wiki/html/RubyNoKai/index.rb:5:in `load'
/home/wiki/html/RubyNoKai/index.rb:5

というエラーになってしまう。

2010-04-25 (Sun)

#1

また試したら、今度はちゃんと「IO クラスについて」の資料を見れた。

ustream のも視てみたが、これは解像度が低くて読めない。

PDF の資料を見ながら ustream のを聞くのが現実的だろうか。

それだと (事前に資料を提供していないと) 中継を視るのは微妙そうだが。

それはそれとして中身は、とりあえず基本的なところは押さえてあったのではないかと思う。

2010-04-27 (Tue)

#1

rationalize ってどういう動作なんだっけ?

図示してみよう。

有理数の分子を x, 分母を y として平面に割り当てれば、rationalize は平面の中の矢印として表現できるはずだ。

% ./ruby -e '
puts "unset arrow"
1.upto(20) {|n|
  1.upto(20) {|d|
    r = Rational(n,d)
    r2 = r.rationalize("0.05".to_r)
    puts "set arrow from #{r.numerator},#{r.denominator} to #{r2.numerator},#{r2.denominator}"
  }
}
puts "plot [0:20][0:20] x"
'         
unset arrow
set arrow from 1,1 to 1,1
set arrow from 1,2 to 1,2
set arrow from 1,3 to 1,3
...
set arrow from 10,9 to 8,7
set arrow from 20,19 to 11,10
set arrow from 1,1 to 1,1
plot [0:20][0:20] x

rationalize.png

rationalize.gp:

unset arrow
set arrow from 1,1 to 1,1
set arrow from 1,2 to 1,2
set arrow from 1,3 to 1,3
set arrow from 1,4 to 1,4
set arrow from 1,5 to 1,4
set arrow from 1,6 to 1,5
set arrow from 1,7 to 1,6
set arrow from 1,8 to 1,6
set arrow from 1,9 to 1,7
set arrow from 1,10 to 1,7
set arrow from 1,11 to 1,8
set arrow from 1,12 to 1,8
set arrow from 1,13 to 1,8
set arrow from 1,14 to 1,9
set arrow from 1,15 to 1,9
set arrow from 1,16 to 1,9
set arrow from 1,17 to 1,10
set arrow from 1,18 to 1,10
set arrow from 1,19 to 1,10
set arrow from 1,20 to 0,1
set arrow from 2,1 to 2,1
set arrow from 1,1 to 1,1
set arrow from 2,3 to 2,3
set arrow from 1,2 to 1,2
set arrow from 2,5 to 2,5
set arrow from 1,3 to 1,3
set arrow from 2,7 to 1,3
set arrow from 1,4 to 1,4
set arrow from 2,9 to 1,4
set arrow from 1,5 to 1,4
set arrow from 2,11 to 1,5
set arrow from 1,6 to 1,5
set arrow from 2,13 to 1,5
set arrow from 1,7 to 1,6
set arrow from 2,15 to 1,6
set arrow from 1,8 to 1,6
set arrow from 2,17 to 1,6
set arrow from 1,9 to 1,7
set arrow from 2,19 to 1,7
set arrow from 1,10 to 1,7
set arrow from 3,1 to 3,1
set arrow from 3,2 to 3,2
set arrow from 1,1 to 1,1
set arrow from 3,4 to 3,4
set arrow from 3,5 to 3,5
set arrow from 1,2 to 1,2
set arrow from 3,7 to 2,5
set arrow from 3,8 to 1,3
set arrow from 1,3 to 1,3
set arrow from 3,10 to 1,3
set arrow from 3,11 to 1,4
set arrow from 1,4 to 1,4
set arrow from 3,13 to 1,4
set arrow from 3,14 to 1,4
set arrow from 1,5 to 1,4
set arrow from 3,16 to 1,5
set arrow from 3,17 to 1,5
set arrow from 1,6 to 1,5
set arrow from 3,19 to 1,5
set arrow from 3,20 to 1,5
set arrow from 4,1 to 4,1
set arrow from 2,1 to 2,1
set arrow from 4,3 to 4,3
set arrow from 1,1 to 1,1
set arrow from 4,5 to 3,4
set arrow from 2,3 to 2,3
set arrow from 4,7 to 3,5
set arrow from 1,2 to 1,2
set arrow from 4,9 to 2,5
set arrow from 2,5 to 2,5
set arrow from 4,11 to 1,3
set arrow from 1,3 to 1,3
set arrow from 4,13 to 1,3
set arrow from 2,7 to 1,3
set arrow from 4,15 to 1,4
set arrow from 1,4 to 1,4
set arrow from 4,17 to 1,4
set arrow from 2,9 to 1,4
set arrow from 4,19 to 1,4
set arrow from 1,5 to 1,4
set arrow from 5,1 to 5,1
set arrow from 5,2 to 5,2
set arrow from 5,3 to 5,3
set arrow from 5,4 to 5,4
set arrow from 1,1 to 1,1
set arrow from 5,6 to 4,5
set arrow from 5,7 to 2,3
set arrow from 5,8 to 2,3
set arrow from 5,9 to 3,5
set arrow from 1,2 to 1,2
set arrow from 5,11 to 1,2
set arrow from 5,12 to 2,5
set arrow from 5,13 to 2,5
set arrow from 5,14 to 1,3
set arrow from 1,3 to 1,3
set arrow from 5,16 to 1,3
set arrow from 5,17 to 1,3
set arrow from 5,18 to 1,4
set arrow from 5,19 to 1,4
set arrow from 1,4 to 1,4
set arrow from 6,1 to 6,1
set arrow from 3,1 to 3,1
set arrow from 2,1 to 2,1
set arrow from 3,2 to 3,2
set arrow from 6,5 to 5,4
set arrow from 1,1 to 1,1
set arrow from 6,7 to 5,6
set arrow from 3,4 to 3,4
set arrow from 2,3 to 2,3
set arrow from 3,5 to 3,5
set arrow from 6,11 to 1,2
set arrow from 1,2 to 1,2
set arrow from 6,13 to 1,2
set arrow from 3,7 to 2,5
set arrow from 2,5 to 2,5
set arrow from 3,8 to 1,3
set arrow from 6,17 to 1,3
set arrow from 1,3 to 1,3
set arrow from 6,19 to 1,3
set arrow from 3,10 to 1,3
set arrow from 7,1 to 7,1
set arrow from 7,2 to 7,2
set arrow from 7,3 to 7,3
set arrow from 7,4 to 7,4
set arrow from 7,5 to 7,5
set arrow from 7,6 to 6,5
set arrow from 1,1 to 1,1
set arrow from 7,8 to 5,6
set arrow from 7,9 to 3,4
set arrow from 7,10 to 2,3
set arrow from 7,11 to 2,3
set arrow from 7,12 to 3,5
set arrow from 7,13 to 1,2
set arrow from 1,2 to 1,2
set arrow from 7,15 to 1,2
set arrow from 7,16 to 2,5
set arrow from 7,17 to 2,5
set arrow from 7,18 to 2,5
set arrow from 7,19 to 1,3
set arrow from 7,20 to 1,3
set arrow from 8,1 to 8,1
set arrow from 4,1 to 4,1
set arrow from 8,3 to 8,3
set arrow from 2,1 to 2,1
set arrow from 8,5 to 8,5
set arrow from 4,3 to 4,3
set arrow from 8,7 to 7,6
set arrow from 1,1 to 1,1
set arrow from 8,9 to 6,7
set arrow from 4,5 to 3,4
set arrow from 8,11 to 3,4
set arrow from 2,3 to 2,3
set arrow from 8,13 to 3,5
set arrow from 4,7 to 3,5
set arrow from 8,15 to 1,2
set arrow from 1,2 to 1,2
set arrow from 8,17 to 1,2
set arrow from 4,9 to 2,5
set arrow from 8,19 to 2,5
set arrow from 2,5 to 2,5
set arrow from 9,1 to 9,1
set arrow from 9,2 to 9,2
set arrow from 3,1 to 3,1
set arrow from 9,4 to 9,4
set arrow from 9,5 to 7,4
set arrow from 3,2 to 3,2
set arrow from 9,7 to 4,3
set arrow from 9,8 to 7,6
set arrow from 1,1 to 1,1
set arrow from 9,10 to 6,7
set arrow from 9,11 to 4,5
set arrow from 3,4 to 3,4
set arrow from 9,13 to 2,3
set arrow from 9,14 to 2,3
set arrow from 3,5 to 3,5
set arrow from 9,16 to 3,5
set arrow from 9,17 to 1,2
set arrow from 1,2 to 1,2
set arrow from 9,19 to 1,2
set arrow from 9,20 to 1,2
set arrow from 10,1 to 10,1
set arrow from 5,1 to 5,1
set arrow from 10,3 to 10,3
set arrow from 5,2 to 5,2
set arrow from 2,1 to 2,1
set arrow from 5,3 to 5,3
set arrow from 10,7 to 7,5
set arrow from 5,4 to 5,4
set arrow from 10,9 to 8,7
set arrow from 1,1 to 1,1
set arrow from 10,11 to 7,8
set arrow from 5,6 to 4,5
set arrow from 10,13 to 3,4
set arrow from 5,7 to 2,3
set arrow from 2,3 to 2,3
set arrow from 5,8 to 2,3
set arrow from 10,17 to 3,5
set arrow from 5,9 to 3,5
set arrow from 10,19 to 1,2
set arrow from 1,2 to 1,2
set arrow from 11,1 to 11,1
set arrow from 11,2 to 11,2
set arrow from 11,3 to 11,3
set arrow from 11,4 to 11,4
set arrow from 11,5 to 9,4
set arrow from 11,6 to 9,5
set arrow from 11,7 to 8,5
set arrow from 11,8 to 4,3
set arrow from 11,9 to 5,4
set arrow from 11,10 to 8,7
set arrow from 1,1 to 1,1
set arrow from 11,12 to 7,8
set arrow from 11,13 to 4,5
set arrow from 11,14 to 3,4
set arrow from 11,15 to 3,4
set arrow from 11,16 to 2,3
set arrow from 11,17 to 2,3
set arrow from 11,18 to 3,5
set arrow from 11,19 to 3,5
set arrow from 11,20 to 1,2
set arrow from 12,1 to 12,1
set arrow from 6,1 to 6,1
set arrow from 4,1 to 4,1
set arrow from 3,1 to 3,1
set arrow from 12,5 to 12,5
set arrow from 2,1 to 2,1
set arrow from 12,7 to 5,3
set arrow from 3,2 to 3,2
set arrow from 4,3 to 4,3
set arrow from 6,5 to 5,4
set arrow from 12,11 to 9,8
set arrow from 1,1 to 1,1
set arrow from 12,13 to 7,8
set arrow from 6,7 to 5,6
set arrow from 4,5 to 3,4
set arrow from 3,4 to 3,4
set arrow from 12,17 to 2,3
set arrow from 2,3 to 2,3
set arrow from 12,19 to 2,3
set arrow from 3,5 to 3,5
set arrow from 13,1 to 13,1
set arrow from 13,2 to 13,2
set arrow from 13,3 to 13,3
set arrow from 13,4 to 13,4
set arrow from 13,5 to 13,5
set arrow from 13,6 to 11,5
set arrow from 13,7 to 11,6
set arrow from 13,8 to 5,3
set arrow from 13,9 to 7,5
set arrow from 13,10 to 4,3
set arrow from 13,11 to 6,5
set arrow from 13,12 to 9,8
set arrow from 1,1 to 1,1
set arrow from 13,14 to 8,9
set arrow from 13,15 to 5,6
set arrow from 13,16 to 4,5
set arrow from 13,17 to 3,4
set arrow from 13,18 to 3,4
set arrow from 13,19 to 2,3
set arrow from 13,20 to 2,3
set arrow from 14,1 to 14,1
set arrow from 7,1 to 7,1
set arrow from 14,3 to 14,3
set arrow from 7,2 to 7,2
set arrow from 14,5 to 11,4
set arrow from 7,3 to 7,3
set arrow from 2,1 to 2,1
set arrow from 7,4 to 7,4
set arrow from 14,9 to 8,5
set arrow from 7,5 to 7,5
set arrow from 14,11 to 5,4
set arrow from 7,6 to 6,5
set arrow from 14,13 to 9,8
set arrow from 1,1 to 1,1
set arrow from 14,15 to 8,9
set arrow from 7,8 to 5,6
set arrow from 14,17 to 4,5
set arrow from 7,9 to 3,4
set arrow from 14,19 to 3,4
set arrow from 7,10 to 2,3
set arrow from 15,1 to 15,1
set arrow from 15,2 to 15,2
set arrow from 5,1 to 5,1
set arrow from 15,4 to 15,4
set arrow from 3,1 to 3,1
set arrow from 5,2 to 5,2
set arrow from 15,7 to 13,6
set arrow from 15,8 to 11,6
set arrow from 5,3 to 5,3
set arrow from 3,2 to 3,2
set arrow from 15,11 to 4,3
set arrow from 5,4 to 5,4
set arrow from 15,13 to 6,5
set arrow from 15,14 to 10,9
set arrow from 1,1 to 1,1
set arrow from 15,16 to 8,9
set arrow from 15,17 to 5,6
set arrow from 5,6 to 4,5
set arrow from 15,19 to 3,4
set arrow from 3,4 to 3,4
set arrow from 16,1 to 16,1
set arrow from 8,1 to 8,1
set arrow from 16,3 to 16,3
set arrow from 4,1 to 4,1
set arrow from 16,5 to 13,4
set arrow from 8,3 to 8,3
set arrow from 16,7 to 7,3
set arrow from 2,1 to 2,1
set arrow from 16,9 to 7,4
set arrow from 8,5 to 8,5
set arrow from 16,11 to 3,2
set arrow from 4,3 to 4,3
set arrow from 16,13 to 5,4
set arrow from 8,7 to 7,6
set arrow from 16,15 to 10,9
set arrow from 1,1 to 1,1
set arrow from 16,17 to 9,10
set arrow from 8,9 to 6,7
set arrow from 16,19 to 4,5
set arrow from 4,5 to 3,4
set arrow from 17,1 to 17,1
set arrow from 17,2 to 17,2
set arrow from 17,3 to 17,3
set arrow from 17,4 to 17,4
set arrow from 17,5 to 17,5
set arrow from 17,6 to 14,5
set arrow from 17,7 to 12,5
set arrow from 17,8 to 13,6
set arrow from 17,9 to 13,7
set arrow from 17,10 to 5,3
set arrow from 17,11 to 3,2
set arrow from 17,12 to 7,5
set arrow from 17,13 to 4,3
set arrow from 17,14 to 5,4
set arrow from 17,15 to 7,6
set arrow from 17,16 to 10,9
set arrow from 1,1 to 1,1
set arrow from 17,18 to 9,10
set arrow from 17,19 to 6,7
set arrow from 17,20 to 4,5
set arrow from 18,1 to 18,1
set arrow from 9,1 to 9,1
set arrow from 6,1 to 6,1
set arrow from 9,2 to 9,2
set arrow from 18,5 to 18,5
set arrow from 3,1 to 3,1
set arrow from 18,7 to 13,5
set arrow from 9,4 to 9,4
set arrow from 2,1 to 2,1
set arrow from 9,5 to 7,4
set arrow from 18,11 to 5,3
set arrow from 3,2 to 3,2
set arrow from 18,13 to 7,5
set arrow from 9,7 to 4,3
set arrow from 6,5 to 5,4
set arrow from 9,8 to 7,6
set arrow from 18,17 to 11,10
set arrow from 1,1 to 1,1
set arrow from 18,19 to 9,10
set arrow from 9,10 to 6,7
set arrow from 19,1 to 19,1
set arrow from 19,2 to 19,2
set arrow from 19,3 to 19,3
set arrow from 19,4 to 19,4
set arrow from 19,5 to 15,4
set arrow from 19,6 to 16,5
set arrow from 19,7 to 8,3
set arrow from 19,8 to 7,3
set arrow from 19,9 to 15,7
set arrow from 19,10 to 13,7
set arrow from 19,11 to 7,4
set arrow from 19,12 to 8,5
set arrow from 19,13 to 3,2
set arrow from 19,14 to 4,3
set arrow from 19,15 to 5,4
set arrow from 19,16 to 6,5
set arrow from 19,17 to 7,6
set arrow from 19,18 to 11,10
set arrow from 1,1 to 1,1
set arrow from 19,20 to 1,1
set arrow from 20,1 to 20,1
set arrow from 10,1 to 10,1
set arrow from 20,3 to 20,3
set arrow from 5,1 to 5,1
set arrow from 4,1 to 4,1
set arrow from 10,3 to 10,3
set arrow from 20,7 to 17,6
set arrow from 5,2 to 5,2
set arrow from 20,9 to 9,4
set arrow from 2,1 to 2,1
set arrow from 20,11 to 9,5
set arrow from 5,3 to 5,3
set arrow from 20,13 to 3,2
set arrow from 10,7 to 7,5
set arrow from 4,3 to 4,3
set arrow from 5,4 to 5,4
set arrow from 20,17 to 6,5
set arrow from 10,9 to 8,7
set arrow from 20,19 to 11,10
set arrow from 1,1 to 1,1
plot [0:20][0:20] x

うぅむ。矢印だけ描くのってどうやったらいいんだっけ?


[latest]


田中哲