1. A RESTful interface for MD5 hashes

    Or not quite. I had a need to generate MD5 hashes inside a Google Spreadsheet, but Google does not include an MD5 function (and neither does OpenOffice.org). Google does, however, support a function to get XML data and process it with Xpath. So assuming someone had created an MD5 generator on the web that was accessible via XML, I set to work. It turns out, nobody has ever needed this before. But that’s okay, I am a Real Programmer.

    I installed Ruby on Rails and created a very simple controller for hashes:

    class HashController < ApplicationController
        def md5
        result = { }
        result['data'] = params[:id]
        result['md5'] = Digest::MD5.hexdigest(params[:id])
    
        respond_to do |format|
            format.json { render :json => result }
            format.xml { render :xml => result }
        end
    end
    

    Which is now accessible via http://api.jameshoward.us/hash/md5/foo.json or foo.xml as appropriate. In addition, there is an sha1 method available. It’s all running on a minimal instance with Heroku, so please use it to your heart’s content.

  2. Source Code for LX, a Link Shortener

    Last August, I began work on a link shortening service as a me-too kind of project.  In my case, I wanted to provide custom domains, so that, for instance, The Washington Post could be wp.ly.  However, I had been displeased in the user interface I had created and had not taken it live.

    On Monday, the jig was up when both Google and Facebook pushed their own link shorteners into the arena.  Additionally, bit.ly announced bit.ly Pro which will provide the custom domain I had been interested in.  Rather than being steamrolled by these behemoths, I will instead open source my code under a BSD License.  It is now available at GitHub.

    From the readme:

    lx is a URL-shortening application created in CakePHP. The Git repository is a top-skimming of the /app directory from CakePHP v1.2.4. Also included in /sql is a database template for PostgreSQL. It is important to note, this code does not work and will need significant revision before being functional. However, here is a partial list of partially implemented features:

    • URL addition
    • URL deletion
    • URL redirection
    • URL favoriting (through the “stars” concept)
    • User accounts
    • User verification
    • URL renaming (title, not target)
    • Some jQuery-based AJAX

    Please use this as the basis for your own work.  If you wish to contribute changes back, please do.