Running Open Wound locally using WampServer and Strawberry Perl

TL;DR: I'm hosting it here now, too.

 

I posted to a poetry group I follow on Facebook (which I would link to but you need to be logged into facebook to see, which sort of defeats the purpose) about Leonard Richardson's Olipy library, seeing as there are several people in the group who enjoy work from generated text.

The resulting discussion turned to Matt Butler's project, Open Wound, and the potential for getting it to run locally using something like XAMPP, since the site's version of it is broken.

Anyway. To cut a long story really short, this is how you do it on Windows:

Download and install Strawberry Perl.  Where you install it isn't super important, but you'll need to remember it later. I just installed it to the default, c:\strawberry.

From the start menu, select Strawberry Perl > Tools > CPAN Client.

A Command-line window will appear.  Enter the following command:

    install Lingua::EN::Tagger

It'll need to install a bunch of dependencies from a server, so give it some time. With any luck, it won't shout any errors at you. Eventually, it'll dump you back at the command prompt - type "bye" to quit.

Next, download Wampserver and install it using default everything. The version I used was this one - 2.4, 32bit, PHP 5.4 - but I doubt it matters.  At the end of the installation when it asks you if you want to run it, uncheck the box.

Go to c:\wamp (assuming that's where you installed it) and create a new folder called cgi-bin. Go to this new folder and drop the index.pl from your Open Wound download. 

Open index.pl up in Notepad and change the first line from

    #!/usr/bin/perl

to

    #!"\strawberry\perl\bin\perl.exe"

 (assuming you installed perl to c:\strawberry).

Save the file.

Go to the start menu and run Wampserver. Check for the system tray icon (it should be a little green W).

Visit http://127.0.0.1/cgi-bin/index.pl

When you're done, remember to close to close wamp from the system tray menu (left-click it and select "Stop All Services" and/or right-click and select "exit").

Overbearing and OAuth

So I built another stupid widget because I wanted to try to use the Twitter API - but I ended up being pretty disappointed by the result.

My goals at the outset were:

  • A single page widget that, given a specific Twitter user, returns the distribution of users responsible for the posts in their timeline
  • Preferably just in HTML if that's possible, because hosting a sinatra application or whatever is beyond the scope of my interest in this project

But I was immediately stifled by the 1.1 API.

  • Every request needs to be magically OAuth signed by your application
  • (somewhat less surprisingly) the home timeline requires user authentication

So what I had naïvely envisaged as a single page with some requests to the API had blown out into something that required an OAuth library. At this point I should have stopped, taken a long hard look at what I was trying to achieve, chosen a library in a technology I was comfortable with, and built something that could handle the OAuth user handshake robustly.

Instead,  I found a PHP library that would let me do it on one page, without worrying about any additional infrastructure. At the time I just wanted data, but retrospectively this was a mistake (mostly because I haven't touched PHP in three years).

The sole benefit was that I could put my twitter application keys in what was otherwise an HTML page and not worry about exposing them to the outside world; the downside is that the code isn't particularly attractive because a) I was just hacking on examples, and b) more than half of the code on the page is boilerplate for handling OAuth authentication. It's hardly something I'd be proud to release the source for (which, really, was most of the point of the exercise),

Even after making all these technological compromises in order to get data, the data I got didn't turn out to be very helpful. The Twitter API only lets you read the first 200 tweets of a timeline at a time, and the rate limit is particularly aggressive (15 calls / 15 minutes, compared to 180 for something like a lookup of a user's tweets)

This snapshot doesn't do a great job of illustrating the stated point of the exercise - prove one of your friends tweets too much - because it can only look at your most recent 200 tweets. When your feed is active, this snapshot can be for a time period of less than an hour; if someone is tweeting more aggressively than the rest, it's going to be pretty obvious.

Anyway, the moral of the story is that sometimes you have a great idea and then it turns out that to actually get anything out of it requires more data than you can get in one go.

I called it "Overbearing".