Home > Uncategorized > Inadvertently following the Unix Way

Inadvertently following the Unix Way

I was able to rewrite Robert Berry’s B-Movie Title Generator today in ruby (thanks to the quasi-magical Sinatra web framework) because he, almost certainly unwittingly, followed the Unix Way. By way of a definition, Ted Dziuba recently gave a pretty good summary of the Unix Way in a recent, inflammatory, and otherwise unrelated essay:

A long time ago, the original neckbeards decided that it was a good idea to chain together small programs that each performed a specific task, and that the universal interface between them should be text.

If you develop on a Unix platform and you abide by this principle, the operating system will reward you with simplicity and prosperity. As an example, when web applications first began, the web application was just a program that printed text to standard output. The web server was responsible for taking incoming requests, executing this program, and returning the result to the requester. We called this CGI, and it was a good way to do business until the micro-optimizers sank their grubby meathooks into it.

In practice, the Unix Way looks something like this: you might use wget to fetch a webpage as it’s HTML source, pipe that to grep to use regexes to pull out the bits you care about, and then pipe that to cut to select only certain columns and pretty-print the data. Wget, grep, and cut are three separate, single-purpose programs that communicate by way of the universal language of streams of text.

So how did Bob accidentally flex his neckbeard and abide by the founding principles of our unix ancestors? Backing the Title Generator is a database that has one table that lists all the different types of creatures that the generator can spit out, and another table for all the places, and tags, and so on. You can actually get a full dump of the database as sweet, sweet plaintext.

I am positive that this page is a vestige, a sandbox test that was never removed. But because it stumbled on to the Path of Unix by making an easy export of the database available, anybody with half an hour and a decent grasp of regular expressions can extract the data from it and use it to fuel their own implementation of the B-Movie Title Generator. Which is exactly what I was able to do today. The source is also up on GitHub (check out bmovie.rb for all the magic).

Advertisements
Categories: Uncategorized
  1. Bartholomew Xerxes Ogilvie, Jr.
    October 4, 2011 at 10:05 am

    You’re right that I didn’t implement the dump script as a means of exporting the database for other purposes, but it’s not exactly a vestige either. I use it myself when adding phrases to the database, as a low-tech way of checking for duplication. I’m sure I could get a similar view of the data through phpMyAdmin, but this is quick and easy and easy to search with Ctrl+F.

    Of course, most of the implementation decisions I made while writing the B-movie Title Generator were motivated by laziness, and this is one of them. I always intended to create a proper admin interface for the Generator, which would consist of a form for adding or removing phrases (with the intelligence to detect duplicates). But I never got around to it.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: