Feeds:
Posts
Comments

Archive for the ‘Personal Projects’ Category

Toys. With each generation, the number of toys per infantile capita is surely increasing. My nephews have so many toys they can barely keep track of them all. I was a relative toy pauper by comparison, but next to my dad, I was as rich as Croesus. In Dad’s childhood, money was scarce and toys were a luxury beyond his reach. But little boys want toys, so human innovation filled the gap – they made their own.

King of the home-made toys was the cotton reel tank, a wind-up automotive device made from a candle, a cotton reel, an elastic band, and two used matchsticks. Once the craft had been passed down from father to son, I too found joy in building and performance tweaking these little beauties. I’d discovered the pleasure of making something, however primitive, with my own hands.

cotton reel tank

In the spirit of the cotton reel tank, I sometimes have a hankering to knock up a little digital toy as a fun micro project. Something of little or no practical use. How about a Magic 8-Ball Twitter bot? A search revealed a handful of such bots already existed, but not one was still functional. Some tweeted their last in August 2010, no doubt victims of the Twitter OAuth Apocalypse. Another unfortunate example replied repeatedly every two minutes to any question, the only way to stop it being to delete the original tweet. A disappointing 8-Ball fail.

Having taken into account all of this prior art, I defined the requirements of my bot thus – it should:

The open source Twitter4J Java library supports OAuth, so no problems there. To ensure the bot only replies once meant persisting the ID of the most recent tweet replied to, for which I used Prevayler. I pass this persisted tweet ID as a parameter when querying the Twitter API (via Twitter4J) for new mentions, so the bot only “sees” each question once.

The maximum wait for a reply is determined by cron config. I scheduled the bot app to run every two minutes, which seems like a reasonable worst-case time to wait for the omniscient wisdom of the 8-Ball gods, plus I’m mindful of Twitter API rate limiting. Responses are read in at runtime from a simple text file populated with the standard 20 8-Ball responses, one of which is selected at random when creating a reply.

wise8ball-tree-falls-in-forest

And that’s about it – a crude toy that was probably more fun to make than it is to play with, although I still get a kick out of asking it stuff once in a while. Take my cotton reel tank for a spin yourself by tweeting a yes/no question to @Wise8Ball; you may be surprised by how profound it can appear.

Read Full Post »

I have this tiny app on an Ec2 micro instance. It uses the Twitter API, via the Twitter4J Java client library, to record the number of followers for a given list of Twitter handles. I’ve cronned it to run once a day, so for each of the Twitter accounts I’m interested in, for example my bots, I have a CSV file that tracks the number of followers over time. Simple, crude, and good enough.

A friend asked me if I would do the same for his Twitter account. “No problem”, I said, because, you know, I’m generous like that. Add it to the list, CSV file magically appears the next day, and Bob’s yer uncle. Every once in a while I would email him an up-to-date copy of that file, that analytical masterpiece, that source of valuable “Business Information”, and he’d plot it as a graph in Excel, or whatever it is he does with it.

Keegan's wisdom

This arrangement was fine for a couple of weeks, but it soon became clear it would be better for both of us if he had direct access to his data so we could do away with this bothersome emailing business altogether. So, how to do that? Call me skittish, but I’m not mad keen on granting SSH access to any old Tom, Dick or Harry, personal friend or no. And in any case, I’m sure he’d find SCP a little bit of a faff. How about good old HTTP?

(more…)

Read Full Post »

Recently I’ve been tinkering with Clocktwerk, a very small personal project. It got me thinking about personal projects in general. Like most developers, I enjoy creating software away from the day job from time to time, and what I look for in these little hobby projects is:

  1. something that seems like fun
  2. the chance to create software that will be useful, even if only to me
  3. the opportunity to learn something – a new tool, framework, API or technique

Over the years, I found that some of the projects I started were fruitful, whereas others fell by the wayside, doomed to an eternal state of half-finished nothingness.

Unfinished

(more…)

Read Full Post »