Ilya Grigorik —Last night I wrote a quick database explorer for an HCI project at U of Waterloo (screenshot above). I had a database of lead stories for BBC, Yahoo News and NY Times over a period spanning Sept. 2004 to Aug. 2005 and I wanted to juxtapose and visualize different queries. The concept is simple, given two words (ex: war / peace), I wanted to see some aggregate calculations over the available document corpus.
At first, I wanted to write about a great Ruby graphing library (Scruffy) I found, but later realized that I could nail three different concepts at once: writing a simple threaded web-server, interfacing with a database, and generating live graphs (SVG/XML). It’s a nice trifecta and I learned a few nice tricks along the way, hopefully you’ll pick up something as well. Let’s get to it!
Building a threaded web-server in Ruby
This is a neat one, we’re going to build a light-weight threaded web server! Why threaded? Well, primarily for reliability reasons in this case - if a thread crashes, our server is still operational because our parent thread is still listening, and in a development environment that could very helpful. (My code is not perfect,in fact, I know it will crash on some edge cases!)
Continue reading full post....