FizzBuzz with Sather like loop

Posted by: Shugo Maeda Fri, 24 Aug 2007 23:06:00 GMT

num = (1..100).each
fizz = ([""] * 2 + ["Fizz"]).cycle
buzz = ([""] * 4 + ["Buzz"]).cycle
loop do
  n = num.next
  puts (fizz.next + buzz.next).sub(/\A\z/) { n }
end

Posted in Ruby | no comments | no trackbacks

Graceful Restart with mod_fcgid

Posted by: Shugo Maeda Fri, 24 Aug 2007 15:39:00 GMT

I tried to restart Rails application gracefully (apachectl graceful) with mod_fcgid, but I couldn't get a response on graceful restart.

The problems are:

  • mod_fcgid sends SIGTERM to FastCGI processes on graceful restart, but Rails FastCGI processes exit as soon as it's received SIGTERM (Rails FastCGI processes stop gracefully on SIGUSR1, not SIGTERM).
  • Apache child processes exit on SIGUSR1 with mod_fcgid, as soon as it's received a signal.

I created a patch to fix these problems, but I'm not sure....

Posted in Apache, mod_fcgid, Rails | no comments | no trackbacks

Sather like loop

Posted by: Shugo Maeda Fri, 24 Aug 2007 13:15:00 GMT

Sather like loop is available in the SVN head.

e1 = [1,2,3,4,5].each
e2 = ["a","b","c","d","e"].each

loop do
  p [e1.next, e2.next]
end

It's cool, isn't it?

Posted in Ruby | no comments | no trackbacks