The 140 character webapp challenge!
February 13, 2009
How many interesting webapps can you code in one Twitter message? I have one — a micro-twitter. I want to see many!
Back at Twitter I read this message on 222 character Wikis, by Arun Shroff. I thought — why not — and replied with a challenge: Make a 140 chars webapp in 2 weeks! Whatever language, library or module included, as long as it’s standard. I made an example micro-twitter, described later in the post. If you think you can do better — I dare you. You’ve got 2 weeks again. Post your webapp here in the comments! (complete code, link or anything such that we can see it at its best)
Now, to my micro-twitter app. It’s written in Perl, using just the CGI module. The one-line code has 140 characters, although in the source code file you can find a further minimized version with just 123 characters, but less features.
What the micro-twitter basically does, is let you update your status and show it. Don’t expect any social candy, there’s no room for that, but it works, and you can (no longer) test it here — the PIN is 1234, and this version is a bit more secure, for obvious reasons. To post a message, type the PIN number, a space, and then your message.
I’ve worked about 2 hours refining the code. That’s around 51 seconds per character, funny how such a short piece takes so much time. And here it is:
use CGI’:all’;print header.’<form>’.submit.textfield 0,’’,99;open F,’<0';print $f=(param 0)=~/1234 (.*)/?hr.$1.<F>:<F>;open F,’>0';print F$f
The extent to which I bended the common practices of Perl are quite bizarre to me, but on the other hand this code is completely valid in my IDE of choice — Komodo Edit. First of all, I include all the fancy stuff from CGI, but in fact I am using just the :standard, :form and :html extensions. I’m printing the heading, otherwise the browser will spit an Internal Server Error. Next, I’m starting the form, no html, head or body rubbish. I’m printing the submit button and a textfield using the mentioned :form extension.
After that, I handle the possible message. I’m using a regular expression to analyze it, looking for the PIN. If found, I append the message at the beginning of the file, adding a hrizontal line to make it look readable. At the same time, I push all the file contents to a $f variable. I use it then to overwrite the database file, so the messages don’t get lost. And that’s it.
Now, again — I dare you, make something better, shorter, fancier! The rules are simple: whatever language you choose, whatever module or library you include, as long as it’s standard, it’s good. But share your webapp in the comments, even if they bend the rules — it will be interesting. The challenge is on. So are you skilled enough for this? Bring it on! And follow me.
Originally published at web.archive.org.