Relaunching lunchomizer.com

Posted by chetan on February 12, 2011

I spent a bunch of time the last couple of days sprucing up a few of my personal projects. Today was mostly spent on the lunchomizer, which gives you random suggestions for lunch, based on your location. It still only works for Midtown Manhattan since the locations all come from Midtown Lunch and that’s also the neighborhood where I happen to work.

The biggest change today was fixing the HTML5 location support and a much better mobile experience via a separate Rails layout tailored for small screens. All in all, it was pretty easy, but one thing that surprised me was a noticeable lack of a de facto standard library for doing mobile, or really any, browser detection. I ended up using a gem called Nomadic and that worked well with the following controller code:

class LunchController < ApplicationController
    layout :choose_layout
    [...]
    private
 
    # use mobile layout for mobile clients (using browser detection)
    def choose_layout
        Nomadic.mobile?(request.env) ? "mobile" : "default"
    end
end

A fairly simplistic solution, but perfect for this app which has only a single controller and a single view :)

And for the curious, the full source is available on github. Fork away!


Launching srchmvn.com

Posted by chetan on March 30, 2010

Today I’m launching my latest personal project, srchmvn.com, to help Java developers find Maven artifacts. It’s also the first project I’ve finished* and released in a very long time.

The Problem

While Maven is, at it’s core, a build system, one of the most valuable features it offers is it’s centralized repository and transitive dependency management for your projects. You can simply include an artifact definition and Maven will, at build time, download and provide not only the selected artifact, but all it’s dependencies as well.

The problem is actually finding definitions for your artifacts, specifically when you already know the name of the library or project. You would think that a popular project like Spring would include this information somewhere on their download page, but for some odd reason they don’t and neither do most other opensource projects.

Existing attempts

As it turns out, I’m not the only one with this problem; I found at least 7 different sites that try to solve it. All of them appear to have taken a similar approach and yet offer wildly different results.

As a test, try searching for “struts” on each of them and see if you can locate the correct artifact id for the latest version.

Were you able to find Struts 2.1.8.1? I wasn’t.

My Solution

Enter srchmvn.com, my attempt at building a search engine for Maven artifacts. With srchmvn I offer two key improvements over existing solutions: a clean, speedy interface and an improved search algorithm. Specifically, rather than relying solely on a simple keyword search, I also take into account a given artifact’s “popularity” in much the same way that Google determines Page Rank. In this case, I’m using Maven’s own dependency system to determine which artifacts are referenced more often than others.

Now let’s try that search again, shall we?

Ah, much better. Exactly what I was looking for. The latest versions of both Struts 1.x and 2.x in the top 3 results, followed by several other popular artifacts.

Fun Bits

Other than scratching an itch I’ve had for the last couple projects I’ve worked on, building srchmvn gave me a chance to play with things I generally haven’t had a chance to use at work, like Rails 3 beta, nginx, Capistrano, and jquery.

I’ve had a love/hate relationship with Rails over the years and I was hoping to find out if any of the “hates” had been addressed in this latest version. I can’t say I’ve done much more than simply kick the tires on this thing, but so far I’m not blown away. The rails team has done a remarkable job in refactoring the monolithic codebase that rails had grown into, but my biggest complaint has always been the use of [generally] undocumented “magic” behaviors, and they’re still here, for better or worse.

Surprisingly, the area that gave me the most trouble, and where I spent the most time, was in trying to correctly parse the Maven project (POM) files. Of course, anyone who has ever had to write or maintain one will know exactly why that is… :-)

*Not Quite Finished

Ok, so it’s not quite finished. I have a few ideas on ways to improve various bits of the app, but more than anything, I’d appreciate some feedback. I’ve so far been able to quickly find every artifact I’ve thrown at it, but if you happen to find some cases where you get weird results, please let me know. I’ve got some ideas on improving the search as well, but unless I see a need to tinker with it, it probably won’t be changing for now.