Monthly Archives: January 2009

TwtrCtr – Tracking Twitter followers with an iPhone

twtrctr logo I’ve already mentioned this on Twitter, but so far I haven’t had a chance to write about the culmination of my first “proper” efforts to create a mashup: TwtrCtr.

For those not obsessed with Twitter or their follower numbers, there’s an application you probably haven’t heard of called TwitterCounter. The site provides tools, graphs and APIs for charting the growth of a user’s Twitter followers. It’s interesting, and if you’re slightly obsessive about figures and have a belief that such things “matter”, then you might already spend time checking it and looking at the pretty graphs. It also provides an element of “prediction” based on historical growth trends, and does cool things like allowing users to compare themselves to others and watch the graphs intersect or overlap.

twittercounter website There’s just one issue – although it looks great on the desktop, the site isn’t laid out very well for mobile browsers like Mobile Safari on the iPhone. It also uses a Flash component to display the graph, and since there’s currently no Flash on the iPhone, you get a big blank box in the middle of the screen.

The nice part is that TwitterCounter has a simple REST API which enables a developer to get the raw data about a user’s follower numbers. If you use Twitter clients like Tweetdeck, then you’ll see this in action.

Based on my previous experience of using the iWebkit framework to build an iPhone-optimised web wrapper for the data from my Current Cost meter, I thought it might be interesting to play around with using iWebkit to display the TwitterCounter stats.

iWebkit is a simple HTML framework which provides a set of CSS classes to make your web pages look like native iPhone apps. There are other frameworks out there like iUI and, but they depend a lot more on knowledge of AJAX and some more advanced / dynamic coding, whereas iWebkit is all about simplicity – if you know your HTML basics, it is pretty straightforward. As it happens, you can extend it very easily as well – in my case, I combined it with some PHP functions which call out to TwitterCounter and echo the numbers into a table on a web page.

Although I worked with PHP a lot a few years ago, I hadn’t really done much with the language recently. The first thing I did was to create a simple piece of code to call the TwitterCounter API and get back the data for a specific user; and then I displayed it in a web page. Once I’d done that, it was pretty easy to get the whole thing wrapped into two pages of iWebkit template code, and style it all appropriately.

twtrctr mark 1

Revision one of the interface and app ran off my home server, and didn’t look fantastic. My initial thought for a name was “TwitterCounter nano”, but I changed it after realising that it didn’t fit so well as a name on the iPhone home screen 🙂

In the screenshot on the left, you’ll also see that the first form I came up with was far from “iPhone native-looking”… the current version of iWebkit didn’t have form CSS classes, so I had to tweak things a little. I also found it was worth digging into the Apple Web Development Guidelines for the iPhone, which gave some hints about how to make some iPhone-specific tweaks like turning off auto-capitalisation for the text entry box (since most usernames are all in lowercase), and how to add a text hint, for example.

twtrctr mark 2 So, the second iteration of the UI looks a lot nicer. It’s also possible to hit the bookmark button in Safari and add the app as a shortcut on the iPhone home screen… (see the icon at the top of the post)… if you do that, and launch TwtrCtr from there, it will act as a full-screen iPhone app with no Safari controls, giving a much more native experience. The user can then navigate by using the controls in the header bar rather than the forward and back buttons provided by the browser.

I added an FAQ page, too, so if you want to know more about the app you can check that out directly on the site. In these days of heightened concern about Twitter security I also thought it would be a good idea to add a note on the front screen to point out that it doesn’t ask for anything more than a username, and it doesn’t log that anywhere, it just passes it on to the TwitterCounter API.

twtrctr display OK, that was a rather long explanation of the evolution of the first page! The important part is actually how the data is displayed. Once you’ve entered a valid Twitter username and hit “Get User Stats”, you get a single-page representation  of the TwitterCounter data for the given user.

The top 2 or three rows are links which will open the user’s profile page, homepage/URL (if one is set… otherwise that row doesn’t display), or display a simple graph / chart which is generated by the Google Chart API. The latter is something high on my list of enhancements, because it looks a little dull at the moment; also, I’m generating the Google Charts URL myself rather than using one of the PHP wrappers to the API, which would probably be a lot simpler.

Don’t look too closely for the rough edges… right now, it doesn’t actually make any effort deal with cases where a user doesn’t exist, or TwitterCounter or Twitter is down…. I know about those small issues 🙂

In a nutshell, then – that’s all it is. A mashup which allowed me to explore a bit more iPhone-specific web development, some PHP / REST / XML coding, and a bit of Google Charts stuff as well. I have to say that the TwitterCounter folks (Boris and Arjen in particular) have been brilliant and very helpful and supportive, despite their app having an issue with the Twitter API while I was in the middle of developing this mashup on top of their API! iWebkit is a lot of fun to play with, and very simple as well – I know the developers are working hard to add new features into that framework whilst keeping it simple and aiming it at “non-techies”.

Oh, and incidentally, although the stylesheets make it look like an iPhone app, it should work perfectly well in any desktop or mobile browser – it’s plain old HTML.

I’m not making any claims about how this might develop in the future, but I’ve got a couple of ideas for tweaks that I might make. In the meantime, if you’re an iPhone (or other mobile device) Twitter user, do take a look at and see how it works for you. Let me know what you think, or any ideas for additions you might find useful! Feel free to follow me on Twitter and @ your suggestions and comments to me, too.

Update: TwtrCtr is now linked directly from the TwitterCounter home page! Follow the iPhone link in the page footer! 🙂


The great iTunes library migration of 2009

Last week, I finally got fed up with the constant pain of bumping up against the disk size of my MacBook Pro. The largest chunk of space on the 120Gb drive was the ~35Gb taken up by my iTunes library. It was time to move it.

Moving out, making space

I’d previously thought about moving all of my music to the network and serving it out of daap-server on Ubuntu. The issue is that I sync my iPhone with the MBP and therefore I want my music library available locally, rather than streamed. I have a smart playlist which randomly selects about 7Gb of stuff from my library, leaving room for my apps, podcasts, and photos in the rest of the 16Gb space on the iPhone.

The thought of moving my iTunes library has just been such a painful one that I’d been putting it off for ages. I finally found a really good guide to the subject that reassured me, though – I could move the bulk of the library to another drive, and iTunes would still “work” (in the sense of enabling me to rip more, or download new podcasts) even when it was disconnected. I’m not going to go into the steps in detail here, read the iLounge guide to Transferring your iTunes Library – but it was basically a case of attaching a big external disk, changing the location of the iTunes library in the preferences, and Consolidating it; then deleting the local files on the internal drive.

Once all ~35Gb of music, video and podcasts was safely relocated, I decided to try something else. I unplugged the external USB drive, and attached it to my Airport Extreme base station. It appeared as an Airport Disk (with the same name as it had as a local disk) on my desktop. I started iTunes, and… hey presto, It Just Worked. So I now have my main iTunes library on my home network, visible to the iTunes application when the MacBook is on the same network, and can sync my iPhone when I’m there.

Time to rip

Once I’d finally made space, and also got the library into a location with room to breathe, I decided to make a start on something I should have done a long time ago. Up until now, I’d ripped CDs randomly according to when I wanted to hear particular albums or tracks… now, it was time to systematically get the whole collection into digital format.  Plus, I don’t actually own a stereo / hifi with a CD player anymore, so the only way I’m consuming music is through the computer. There are about 500 CDs to rip, so this is an ongoing project.

A few people asked on Twitter what format I’m going for. Purely on the basis of convenience and accessibility of format, I’ve decided to go with high quality MP3 rather than OGG, AAC or FLAC. I know MP3s will pretty much play anywhere I might choose to put them. Sorry to the audio aficionados.

Bumps in the road

There are just a few things which continue to mildly bother me:

  • If I’m not on the home network, iTunes reverts to a temporary/default (local) library location. I tend to Sleep the Mac rather than shutting apps down, so if I go home and reconnect to the network, I have to remember to close and restart iTunes for it to pick up the “proper” library location… otherwise it continues to point itself at the internal location. Selecting “Consolidate Library” by accident when the library preference points to the local disk can have bad consequences (it tries to copy everything back from the external disk to the internal one!)
  • iTunes has a weird relationship with album art. It can find some, but not others… does it depend on what is in the iTunes store? I’m partway through the D section of my CD library right now, and in general the rippage has been fine, but none of the Beatles or (oddly) Def Leppard albums have album art that iTunes can find. (and, sometimes, my scanner) to the rescue!
  • There’s another, smaller iTunes library on a Thinkpad that I’d like to be able to merge in. I’ve seen some third-party tools which can apparently do merges and retain play counts and ratings, and also do duplicate checking… I need to look into those.

Generally though – really happy with how this has worked out, and I wish that the solution to my full disk problem had been more obvious some time ago. Now I have some disk space to play around with iMovie 09 🙂

Building a mainframe with nodes and wires

Last Friday, I built a mainframe. It looks like this:

message flow

Well OK. That’s a very, very big exaggeration. Let me explain. I’m doing some work at the moment that involves using some Enterprise Service Bus logic with CICS and various other systems. In one particular case I needed to be able to invoke a CICS transaction across the CICS/MQ bridge. This is actually incredibly straightforward, but at the last minute I couldn’t get my queue manager connected to the host thanks to some firewall issues, so I decided to create a stub version instead.

My own “ESB of choice” is WebSphere Message Broker, and coincidentally that was what I was using to develop logic late last week. I’ve been using the product for about seven years now, on and off. The development environment for WMB enables the user to create message flows that receive data over various input protocols, and wire together various operations which transform, route or otherwise make use of the data.

All this “mainframe emulator” flow does is receive a message with a COBOL copybook formatted body; map the values into a response message (there’s some conditional logic in the map which decides whether to return an error of some kind based on the specific account number in the incoming message, to emulate different conditions); and then just reply to the ReplyToQueue specified in the input message.

Total time – about 3 minutes (OK… a bit more, as I was fiddling with the return conditions and a little bit of XPath in the mapping node). Obviously it’s not a real CICS system, but it served the purpose I needed. Since the interface to the actual CICS/MQ bridge is well-defined, it would be a simple matter of redirecting the message traffic to the real system if it was required for some other degree of testing.

How to make a MOO Mosaic Frame

For Christmas this year I decided to make a couple of MOO Mosaic Frames for family members. The frames hold 20 MiniCards in a variety of orientations – you can switch them around to suit your design. I made a short clip in iMovie 08 to demonstrate the process, which you can see on my YouTube or Viddler channels.

Trying out iBlogger

image1835434027.jpgA friend pointed out that iBlogger, the iPhone blogging client based on the ecto codebase, is on sale – only £0.59 in the UK app store right now. I’ve previously used the free WordPress app, but since I contribute to blogs on various platforms this seems like a good alternative… and it has nice support for images (test example embedded) and links. Worth a look. Ironically I’ve recently switched from ecto to MarsEdit for my desktop blogging client, but iBlogger seems very nice indeed.

Update: hmm… so it doesn’t pad the images very nicely and I’ve had to edit in the browser subsequently… but otherwise it works well. Need to try with some blogs. Also it doesn’t appear to have applied any tags, which is annoying.