Current location: Brighton, UK

What I've been upto lately

Posted on Wednesday, June 17, 2009 @ 17:21 CET

So hi there. It sure has been a while. For some reason I've been neglecting this blog in favour of Twitter, I suppose the main reason is probably how damn simple it is to use. So if you're into Twitter, come follow along :)

My admin tool for this blog was written back in the Flash MX 2004 days and uses AMF::Perl of all things to talk to my custom back-end. Geeky as all hell and there was a point in time when I was actually quite proud of it - it has been running pretty much flawlessly for the past 5 years after all. But apart from the technical merit its pretty useless (missing features, extensibility, etc) so I think a migration to Wordpress is in order soon. It really is just "yet another CMS" which I can't be bothered to update since the only person using it is... Well me.

Anywho, you don't care about that. So the past few months I've mostly been doing iPhone development with some ActionScript here and there so the rust doesn't set in. And Perl. Holy crap, THAT had been a long time indeed and like a long lost lover there still are some feelings lingering around there. But like a good friend I know its there when I need it, for example when you have to emancipate data - a term I'm quite fond of.

Last month I held a talk at Flash User Group Norway titled "Mashup My Bike". You can get the slides in PDF form here or the Keynote presentation here. Basically went through deconstructing the Oslo Bysykkel web service and talking about the current web-only version, which is... special.

However we can learn alot by looking at the source and inspecting the traffic back and forth using Charles, which not only is the first Google result for "charles", well done!) but also a fantastic web debugging proxy. With this info in hand I showed a simple Flash-based client along with a quick peek to an iPhone client I wrote.

There is a MUCH better Google Maps-based mashup available as well as a Windows Mobile client. But onto the iPhone version!

Bysykkel app

Bysykkel is an iPhone app that came to be after talking with my buddy Snorre who was explaining to me the wonders of the Oslo city bikes over a few pints at the Dub. My main problem was that I didn't know where the stands are and although you can check availability online a) I don't carry my laptop with me at all times, and b) its not like there's WiFi everywhere either. And so Bysykkel was born.

The app simply shows you which bike stands have bikes or locks available. You can switch modes depending on which you're looking for and use the built-in GPS function to find stands in your area. There's a video of the app in action here.

It requires iPhone OS 3.0 since it uses both MapKit (in order to use Google Maps within the app) and CoreLocation (GPS functionality) both of which are part of OS 3.0, but this will be released to the public today so you're in luck! Right now we're simply waiting for Apple to green-light the app so it ends up in the iTunes App Store. Here's to hoping it won't be much longer...

You can follow app updates on Twitter or Facebook if you're into that sort of thing :)

Technical details

The following might be a little hairy for non-techies. Just a warning. Anyways, the existing bysykkel service basically pings an ASP.NET service with a stand ID. It gets back some XML with the details and you have to do this for every single stand - there's 99 of them at last count. Each response is about 900 bytes of data and takes on average around 90 ms over WiFi - 3G is obviously slower. So that's about 99KB to check the current status of all the stands. This is too much over 3G in my opinion, so what can we do?

Well we can cache it on the server. By checking every now and then and storing the result to a file, as well as simplifying the XML structure it ends up being around 16KB! Much better. Get rid of the whitespace and its 15KB. And for the coup de grace GZIP that sucka and it whittles down to a mere 4KB. That's 4KB to get the current status of all the bike stands in the city! Not too shabby if I do say so myself :)

The best part is that the compression is done automatically on both the server and client sides when you instruct them to. In an Apache .htaccess file, to compress both XML and JSON data its as simple as:

AddType application/xml xml
AddType application/json json
AddOutputFilterByType DEFLATE application/xml application/json

And then in Objective C, you say:

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://mysite.com/myData.xml"]];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];

Smoove as butter as the kids say.

Other stuff

Apart from all this geekery my mom came to visit for 10 days and I turned 28.

On the peeps front, BG started blogging, Perk had a great talk at the last FUGN showing off his BasicFLAR class, Taylor started giving away some cool free shit, Paul joined us over at Tarantell:Hybrid and Chris posted something on his blog (holy crap!).

I'd feed you an empty promise about blogging more often and that but we'll just have to see. Nice shirt by the way :)

- paulo

Post a comment:

You must have Flash and JavaScript enabled to post a comment.