John Leach

Category: Ruby on Rails

News Sniffer, Ferret and Rails

Created · Last updated · Ruby on Rails

I've been working on my News Sniffer project for the last few days, finishing up a two month experiment with using the Ruby Lucene implementation, Ferret, to index news articles and comments.  More info on the News Sniffer blog.  The project spanned two months due to some instability in the newer versions of Ferret, but the author responded to the bug reports and managed to fix all the problems so I decided to deploy.

Ferret offers huge improvements over the original MySQL full-text search method, and I'm looking forward to adding some fancy keyword statistics graphs in the future - perhaps showing censorship patterns in bbc comments with certain keywords.

Because News Sniffer is distributed across a number of servers, I used DRb (distributed Ruby) to allow them all to update one central Ferret index.  DRb seems to work very well generally, and is amazingly simple to use, but I ran into a few problems with recycled objects and invalid references whilst using Ferret across it, apparently due to the garbage collector on the service side collecting things still in use on the client side.  I think I eliminated most of them but they still crop up once in a while - I'll be looking into this further.

Continue reading “News Sniffer, Ferret and Rails” →

Daemontools and Ruby on Rails

Created · Last updated · GNU/Linux, Ruby on Rails, Tech · 5 comments

Dan J Bernstein's (djb) daemontools is a set of programs to help you manage unix services. It provides a flexible, secure and convenient way of starting, stopping and sending signals to background processes. Combined with his ucspi-tcp tools, it can be used as an awesome replacement to inetd (it's most often used in this way to run qmail, a secure and high-performance mta). It can be fiddly to set up and has a bit of a steep learning curve but I already use daemontools for various other stuff, so it was just natural for me to use it for Ruby on Rails deployment.

Continue reading “Daemontools and Ruby on Rails” →

Active Resource not in Rails 1.2!

Created · Ruby on Rails · 1 comment

Whilst planning some changes to my News Sniffer project, I thought I'd have a play with Active Resource.

Currently, all the forum and news article downloading and scraping happens on a different machine to the web server. It has a VPN connection to the database and memcache servers, but I'd like to integrate the Ferret text indexing system for better searching capabilities. To centralise Ferret, I have a three options:

Continue reading “Active Resource not in Rails 1.2!” →

Bruce Schneier whistles white noise

Created · Last updated · Personal, Ruby on Rails, Tech

The new ELER strip is about Bruce Schneier and links to a Chuck Norris style Bruce Schneier Facts Database system I wrote. It got linked from Boingboing, Metafilter, Reddit and even Bruce Schneier's own blog!

As you might imagine, it's getting trabigillions of hits right now. Lucky I wrote it in Ruby on Rails with its built in page caching which (after first render) serves as fast as the webserver can serve. And since I'm using Lighttpd too, that is very fast.

Can I Compost This?

Created · Last updated · Personal, Ruby on Rails · 2 comments

Louisa and I am announcing our latest project: Compost This. It's a directory of items with information about it's compostability.

For example Tea and Flour can be put on the compost heap, but Bindweed and Walnuts cannot. And it's not always a good idea to put Orange peel on there either.

For geeks: I wrote Compost This using Ruby on Rails, which is one of the best web frameworks I've used, and I'm really starting to love the Ruby language too. I'll release the code soon as an example.

Lighttpd and Ruby on Rails: Secure and Fast Downloading

Created · Last updated · Ruby on Rails, Tech · 3 comments

When controlling access to files on a webserver developers often use the web application itself as a file server. The request comes in, the script checks for some session authentication variable or something, then streams the file from disk (hopefully from outside the webroot) to the browser.

The problem with this from a performance standpoint is that a thread/process of the web application has to be running for the entire duration of the download. With a busy webserver serving many concurrent downloads, this is an immense overhead. The web server itself should be orders of magnitude faster at serving files directly than via a web application, but you can't just stick the files in a different directory and hope nobody finds the secret urls. The new web server on the block, Lighttpd, has some clever solutions for this problem.

Continue reading “Lighttpd and Ruby on Rails: Secure and Fast Downloading” →

I changed his life through webdev

Created · Last updated · Ruby on Rails, Tech · 4 comments

A couple of months ago I was having an IM conversation with an old web developer work friend and asked him if he'd played with Ruby on Rails yet. He told me not and I enquired as to whether he'd been living in a mud hut within a rain forest for the last year. He told me not. I pointed him in the right direction and he said he'd take a look sometime.

Continue reading “I changed his life through webdev” →