yahoo pipes declared officially neato

The life of a fresh-out-of-college non-homeowner continues. It’s quite disruptive to have to transfer the entirety of one’s belongings from one physical location to another, but a new place is usually a welcomed, fresh change. It’s a chance to fall in love with a new place before living there is disrupted by the crappy DJ next door, talented-but-loud musician upstairs, or asshole downstairs blasting his stereo at 2AM. (Seriously – I’m five-for-six for truly-amazingly-loud neighbors in the last places I’ve lived.)

In a few months I’ll begin the dreadful process of searching for an apartment. I’d be happy to stay where I am, but the new management is dreadfully greedy and has decided to raise our rent by almost a third. When I asked a friend for his apartment-hunting script he replied, “Sure, but you could use Yahoo! Pipes.” I’m glad that I took his suggestion.

Yahoo! Pipes is a fancy interface to take lists of data – mostly RSS feeds – and transform it into other lists. I’ll face the risk of sounding like a PhD in saying that it’s a GUI for a functional language. One of its most-useful features is the ability to geolocate items, which can be combined with Google Maps for the ultimate tool in apartment hunting.

pipe editor

I’m in awe at the pipe-drawing part of the interface. This isn’t a Flash application – the pipes are rendered immediately. It might be JavaScript generating the images or it might be calling out to a Flash applet – I haven’t figured it out yet, but I need to.

debugging output

What interested me the most was how this application could be represented as a function mini-language. Let’s write a very-procedural Perl version of this processor – the Ruby folks will drool at the though of a functional Ruby metalanguage, so I’ll leave that to them.

# Prompt for $query, $bedrooms, $max and $keyword
# ...

Pipe->new(
    sub {
        my $url = URLBuilder(
            query => {
                format   => 'rss',
                query    => $query,
                bedrooms => $bedrooms,
                maxAsk   => $max
            }
        );

        my $rss = FeedFetcher($url);

        my $filtered = Filter(
            $rss,
            disposition => PERMIT,
            match       => ALL,
            rules       => [ [ 'description', CONTAINS, $keyword ] ]
        );

        my $loc = GeoLocate($filtered);

        my $sorted = Sort( $loc, order => ASCENDING, by => 'nearby.Distance' );

        return $sorted;
    }
)->run;

google maps plots it

Once the Pipe is run, Yahoo! Pipes lets you grab the output in whatever format you’d like, including RSS and JSON. I was working on my own Google Maps mashup with the JSON output until I was told that you could simply paste the RSS URL into maps.google.com. Holy crap! My work is done!

description displayed inline

The next step? Input data from ApartmentRatings.com and plot that on the map, too. Coming soon.

© Ian Langworth