Monthly Archives: April 2009

5K App competition tie up

I didn’t win the 5K App competition, Seb did with a very impressive 3D Moon Lander game in Flash (write up), which has since been featured on Wired’s Geekdad blog.

There’s a video up which is mainly my presentation of the three apps I made. Hopefully more video will be appearing on the £5 App blog showing Seb’s Lander, Dougie from Future Platform’s Location SMS app, and a chap Armandas from Sussex University who had an electronics toolbox cataloging system made in Python.

I really enjoyed the competition and it re-invigorated some of my coding muscles, so I’d like to say a big thanks to John for organising it all.

[Updated with some better links and Armandas’ name]

5K App: Article Suggester

For my third and final 5K app for the £5 App competition I built a cut-down version of something I’ve been meaning to build for ages, which is part of the reason for having the 5K limit in the first place – it forces you to concentrate on the main point of a script or programme and leave out everything else.

At heart, the Article Suggester is a very simple application: you give it a bunch of text (for instance an article or blog post that you’re writing) and it will suggest a list of articles from the Guardian website.

Behind the scenes, things are slightly more complicated. When the form containing the text is submitted it’s first run through the Yahoo Term Extraction tool, which gives back a list of words and phrases it thinks are important from the text. The script then runs this list through the Guardian’s Open Platform content API and gets back a couple of articles related to each phrase, offering them up as links next to the submitted text to help with further research.

Try out the Article Suggester.

Both the Yahoo API and Guardian API have limits on their use, so if this gets popular it may not work. I’ll post up the source code soon so people can get their own API keys and extend it any way they want.

The code is written in PHP and uses SimpleXML to work through the data coming back from the APIs. Currently it’s only 2,292 bytes, so there’s loads of space left in the 5K, I just don’t have any time to add new bits before the competition presentation and judging on Monday.

If you’re interested in seeing the competition presentations, it’s happening at the Skiff from 8pm on Monday 20th April.

5K App: Portal Me

I enjoyed building my first 5K App, the Twitter Biorhythm bot, so much I started building another app. In fact, I started building the second app. before I’d even finished the bot because it was so easy to put together.

This app. was inspired by Jeremy Keith’s talk at the £5 App meet in February about HuffDuffer, his podcast creation service. Within HuffDuffer Jeremy uses Google’s ‘Social Graph‘ API to help broaden the usefulness of the site without bothering the person using it. For instance, if you give it your Twitter name it will use your Twitter icon as your icon on Huffduffer, and it will also offer links to other popular services that it’s found you on using the Social Graph. You can see this at work on the ‘Elsewhere’ section of a profile, the links are created by looking up where else you have profiles via the Social Graph API.

In the past I have thought it would be useful to be able to put someone’s name in to a web page, and get back a set of their posted information from various sites. This is a bit cyber-stalking like, but it’s helpful to be able to get a quick picture of someone’s online life, especially if you’ve just met them as a potential client or through networking.

The Social Graph information would give me a simple way of looking up at least some information about someone. After a poke around in the documentation I found I could easily build a URL that included the URL of a page about someone that could be included in the graph, e.g. their blog or Twitter page. Giving this to the API and asking for ‘otherme’ information meant it would give me back a bunch of XML which includes profile pages on sites registered to that person, including the URL of RSS/Atom feeds from  those pages. I could take those feed URLs and make a page of posts from the person from various sites.

As this was to be a 5K App, I started knocking the code up in ColdFusion, which only needs a very small amount of code for parsing RSS and Atom feeds using the CFFEED function, and it’s XML parsing is pretty short too.

I got a prototype working and it only needed a couple of K’s worth of code. As I had so much spare, I decided to add some basic caching so it wouldn’t request the RSS feeds every time the page was refreshed.

The caching first checks a directory where feeds are saved. If it can’t find a feed, or the saved one is over an hour old, it goes on to request the feed and save it in to the cache directory. Then it reads the feed out of the cache.

Finally, a bit of styling, giving away the fact that I’m not a designer, and it was finished. The code is 4041 bytes, and you can try it out for yourself here: Portal Me.

It works best with people who have several sites which are registered in the Social Graph, and it only works for sites which are tied to the person by using the ‘rel=”me”‘ microformat code on the link (places like Flickr and Twitter do this automatically for you.)

Here’s a Portal for Jeremy Keith from his website address, and one for my friend Josh Russell based on his Twitter account.

One problem with Portal Me is that the Social Graph isn’t perfect, and if you haven’t tied your accounts together properly it shows some odd effects. For instance, if you make a portal for me based on my Twitter account you get less results than if you look me up via my main website address. I’ve only recently started making sure all of my various profiles link to the same site, and also that the site links back to tie them all together, so it may be sorted out over time.

I’ll put some coments in the code and put it up for downloading soon.

Try Portal Me for yourself.

5K Twitter Biorhythm Bot: Byobot

John and Ian, the nice chaps behind the Five Pound App meetings are holding a competition to build the best application or website you can in 5K of code. The prize? £51.20, which is 5K (5120 bytes) in pennies.

I was initially dubious that I’d have time to make any apps, partly because I have a lot of client work on, and partly because I couldn’t think of anything to make. 5K is small and making something useful in it is a tricky. However, I was inspired by John’s demo applications to at least do something. Recently I was fed up with the work I was doing and went for a walk down to the sea and finally, inspiration!

My first app, and oddly the last one completed, uses Twitter. I wanted to build something relatively useful to an audience, and that would run itself. I built a Twitter joke poster a while ago at the Farm Hack Day event I organised, and the problem with it is I haven’t had time to compile jokes for it for ages (although it’s still on my to-do list, which is unfortunately just a little longer than my arm right now, and I have very long arms.)

I started thinking about information that updates often, and that the non-geeks who are joining Twitter now might like to have. I thought of horoscopes, but quickly realised it would be difficult to compress these down to 140 characters without needing human intervention (and have since discovered a couple of people doing the same thing.) I then remembered biorhythms. These are supposed cycles of Physical, Intellectual and Emotional states that you go through, related to when you were born.

Biorhythms were popular in the mid-’80s, when my sister had a biorhythm calculator on her BBC Micro, and they’ve drifted in and out of fashion since then, and probably way before. This means they’re likely to be in fashion for some people, or will be at some point. Another major plus is that they’re quite small pieces of information, which means they can be crammed in to a tweet without too much trouble.

So, my first 5K app (finished today) is…

The 5K Twitter Biorhythm Bot

Twittering as @byobot if you send a message to the bot in the format @byobot yyyy-m-d (e.g. “@byobot 1942-1-8″ if you were Stephen Hawking) then it will reply back with your biorhythm for today.

There’s not a lot of error checking, so if you don’t get the date in the right format, you just get a friendly error message sent back to you.

The code is written in PHP and uses a greatly cut down version of the biorhythm class by Iztok Strzinar for the main calculation. Twitter is handled by a combination of Curl and SimpleXML.

Once I’d found the class, the main things I had to work on was compiling the message so it was short enough to go in a tweet (including leaving space for the @ reply to the person wanting the biorhythm.) And also a way of storing the last tweet read, so the bot wouldn’t keep replying to messages it had replied to before. By using the XML version of the ‘mentions’ stream from the Twitter API I was able to store ID of the last tweet replied to and use the ’since_id=’ variable in the URL when getting the stream so it receives the 20 tweets after the last tweet that the bot read.

The code, plus a file to store the last tweet ID in, is 4,605 bytes. I managed to make a very light logo for Twitter by reducing the colours used in the GIF down a long way – this was a little problematic as Twitter wouldn’t accept a GIF with only 16 colours, I had to go to 32. Altogether, code and image come to 5,036 bytes, which means I have 84 bytes left to play with.

I can think of various things to do with the Biorhythm Bot, the first one to be adding direct messaging to it can give private results to people, but that’s outside the scope of a 5K project and won’t happen for a while anyway as I have too many other client and personal projects on the boil.

Give byobot a go

Why ‘byobot’? When I first started thinking about this project, I wanted to use ‘biorhythm’ as the account name on Twitter, but both that and ‘biorhythms’ are already in use. I had thought of using ‘bior’, but that got registered while I was messing around with the code. Let this be a lesson to you: if you’re going to do a project, register the damn account / domain name while you still can!

[Update] I’ll be talking a little about the biorhythm bot at the next Five Pound App meet up on 20th April at the Skiff