Some code for working with processes using ruby.
# get status from child process before daemonizing
rd, wr = IO.pipe
fork do
rd.close
fork do
wr.write "hello"
wr.close
sleep 10
end
wr.close
end
wr.close
puts rd.read
# run a command and get exit status and command output
rd, wr = IO.pipe
pid = fork do
$stdout.reopen wr
$stderr.reopen wr
$stdin.reopen rd
exec '/opt/local/bin/ls -l'
end
wr.close
pid, status = Process.wait2(pid)
puts rd.read
puts status.inspect
Pretty easy in ruby.
Software
Ruby
We just finished up our first virtual conference website. It’s a kind of mix of event signup and confernce registration as well as related content. The content is provided by the company hosting the conference, SAE. I think I most enjoyed puting together the Dynamic Lead with the rotating images on the landing page. I used Prototype UI’s carousel widget.

Read more…
Software
Anerian, blueprint, Consulting, Javascript, Prototype UI, Ruby, SAE
Git has really made it much easier to share code. ~23 days after posting curb to github, it now has a fork that’s added direct methods for making a PUT and DELETE request.
Software
Curb, Git, Ruby
A question came up recently and I had to think twice. It was how do I run a different app server for my merb application? Knowing merb relies on rack, I initially thought to look in the config/rack.rb. Then I started to grep through merb-core/ and finally came to:
Merb::Config.use do|config|
config[:adapter] = :mongrel
end
Read more…
Software
Ebb, Merb, mongrel, Rack, Rack Adapter, Ruby, Thin
Ruby threads require care when writing an extension - especially when the extension does anything over a network. In the case of curb, it’s often used as a replacement to the built in ruby net/http library.
Read more…
Software
concurrency, Curb, Ruby
I added a new callback hook to curb on_success and on_failure. They work as advertised and are esspecially useful when using the Curl::Multi interface from my last patch.
gc = Curl::Easy.new("http://www.google.com/")
gc.on_success{|curl| puts curl.body_str }
yc = Curl::Easy.new("http://www.yahoo.com/")
yc.on_success{|curl| puts curl.body_str }
mc = Curl::Multi.new
mc.add(gc)
mc.add(yc)
mc.perform
Read more…
Software
Curb, libcurl, Ruby
Vendoring gems definitely makes deployment easier for both rails and merb. For merb, the solution is to create a local gem repository within your project.
gem install -i gems/ --no-ri --no-rdoc #{gem_to_install}
This works great, once you update your merb/config/init.rb to include the new gem repository.
Gem.clear_paths
Gem.path.unshift(Merb.root / "gems")
Read more…
Software
gems, Merb, Ruby
Recent Comments