Fighting with WebSockets

April 18th, 2011

Overview

A long, rambly and very geeky post without a proper ending about some of the challenges I recently had getting WebSockets to work with mobile Safari on the iPhone/iPad.

Background

I wrote last week about a recent project of mine – a proof-of-concept using a custom WebSockets server implementation to push messages to web apps.

A target platform for one of the demos that I wrote to go with this was the iPhone. But it wasn’t as straightforward as I’d hoped. And I’ve ranted enough about it to friends and colleagues and on twitter. About time that I did a bit of moaning here 😉

Read the rest of this entry »

How to make a battery

April 17th, 2011

Overview

DSC01488A bit of science fun for Grace. We made a battery out of zinc washers and copper coins.


Read the rest of this entry »

The cost of volunteering

April 17th, 2011

I keep hearing volunteers referred to as free labour – normally in the context of the “Big Society” being a way to replace paid employees with volunteers because they’re free. But at a time when policymakers talk about wanting to encourage big increases in levels of volunteering, some volunteering charities are struggling to find funding.

A point that doesn’t seem to be well recognised in mainstream media coverage of the Big Society is that volunteers are not free. In fact, they can be very expensive.

Volunteers need to be supported. (Obviously, I’m talking in the context of Solent Youth Action – a charity that focuses on enabling young people to volunteer. But still…)

Someone needs to look out for and help to create opportunities for people to volunteer.

Someone needs to check that a volunteering opportunity is safe, that the role is appropriate, and that the volunteer will be adequately supported.

Someone needs to identify any training or preparation required for a volunteering role, and help the volunteer to find the training they need – whether it’s getting a food hygiene certficate for volunteering in a community kitchen, or getting training to help prepare them for working with people with special physical or learning needs.

Someone needs to encourage the volunteer to review and reflect on what they’ve done, and what they got out of it.

I could go on, but you get the idea. The point is that to do volunteering properly (where a volunteer is supported in carrying out a well-defined and appropriate role for which they are properly prepared) takes work. And that work has a cost.

Read the rest of this entry »

MQTT over WebSockets

April 10th, 2011

Overview

Extending WebSphere MQ to include support for WebSockets, allowing messaging to web browsers, including mobile browsers, without any additional client software

Background

I’ve talked about MQTT before – a lightweight messaging protocol that I’ve used both on personal projects and my day job.

From mqtt.org:

It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.

I’ve used it in CurrentCost projects, mobile apps and with small and embedded computers like my Slug.

But in all cases, I’ve needed MQTT client software to talk to the messaging server. Whether writing in C, C#, Java or Python, I’ve needed a client library to get me started, something that knows the sequence of packets that make up the MQTT protocol.

It’d be useful to have a zero-install MQTT client: an MQTT client app delivered over the web, without the user needing to install any additional client libraries, or resort to Java applets.

What this does

One possible way to do this could be WebSockets. Part of HTML5, this is a protocol that describes how to do two-way messaging between web servers and web browsers. And I mean proper two-way communication, including push-notification from the server to the browser, without resorting to hacks or kludges like long polling or hidden iframes.

It’s an emerging protocol, still in draft form, but there are a few implementations around so there are already a few browsers that know how to manage WebSockets.

We’ve been exploring recently how this could work with MQTT – the aim was to build in support for WebSockets into an MQTT messaging server: IBM WebSphere MQ (WMQ).

I’ve mentioned WebSphere MQ before, as back in the dim-and-distant past (well, five or six years ago) I used to be a developer of it.

It’s one of the server implementations that support the MQTT protocol.

By adding support for WebSockets to it, it means that WMQ could send and receive messages to web browsers. It means a web app could be a fully-fledged MQTT client.

Read the rest of this entry »

Prototype web app for recording your time

February 4th, 2011

Something I was working on before Christmas: a web app for recording what you spend your time working on, using a painting metaphor – with your projects as a palette of different paint colours.

The video is quite high resolution, so it’s best viewed in full-screen in the highest resolution supported.

Using MQTT in Android mobile applications

February 1st, 2011

Overview

How to receive push notifications using MQTT in an Android mobile application

Background

I’ve written before about MQTT as a technology for doing push notifications to mobile. When I wrote that, I gave an example Android project. However, it was the first time I’d ever done Android development, and while it was an okay Java MQTT sample, it was a poor Android sample – I didn’t know anything about how Android works as a platform.

I’ve since written other Android MQTT apps, such as a hackday app for pushing updates from websites to your phone and learnt a lot about how to do it properly. Well… if not properly, at least a little better.

But Google is still directing people to my old, and probably unhelpful, sample. So it’s about time that I share something more useful.

I’ve put the full source for a sample implementation below. (Note that I’m using the Java J2EE client library from ibm.com). Hopefully the comments in it are clear enough, but here are a few of the key points.

Read the rest of this entry »

An API for twitter hashtags for TV programmes

December 31st, 2010

Overview
Hacking together an API that returns commonly-used hashtags for the programme you’re watching on the TV

Background
tweets on TVLast April, I wrote a quick-and-dirty Python script that displays tweets for a given hashtag on my TV screen so that I could follow the twitter backchannel about a programme that I watched.

Considering that it was a random idea that was hacked together in a few minutes, I’ve used it a lot since then: it’s made watching a bunch of programmes much more entertaining – Eurovision is probably the best example (the commentary on twitter is hysterical), but there are many others.

But I never made any changes to the script since I first wrote it. If I’m watching something on TV that I know has a hashtag, I ssh to my set-top box and run my hashtags script, giving it the hashtag to filter on in the command.

I was thinking – it’d be much better if it was all automatic. It’d be better if my set-top box automatically showed tweets with the hashtag for whatever programme I’m watching.

To do this, I needed some way of knowing what was the right hashtag for the programme currently on a given TV channel. I could’ve hacked this into my existing script, but I thought it might be a feature that people might find other uses for, so instead I’ve made a stand-alone thing, available as a web-service.

What it does
I’ve made a web feed that returns a blob of either JSON or XML. You can get either:

  • the commonly-used hashtag for the programme currently on a specified channel (e.g. “what is the hashtag for the programme that’s on BBC 1 now?”)
  • the next programme on TV that has a commonly-used hashtag (e.g. “what are the next five programmes on TV that have hashtags?”)

Read the rest of this entry »

Programmatically identifying DVDs by their barcodes from Android

December 30th, 2010

Overview

A few Android code snipperts for how to identify a DVD by it’s barcode

Background

In November, I wrote a simple Android app that lets me add films to my LOVEFiLM list by taking a photo of a movie poster.

It also works by taking a photo of the front of a DVD case, as the DVD covers are essentially mini-posters. But a few people pointed out that using image recognition for the front of a DVD case is overkill, when DVD cases have a machine-readable barcode printed on them.

So I spent an evening adding the ability to scan barcodes to the app – and now you can add to your LOVEFiLM list either by photos of posters or barcodes.

I thought I’d quickly share how I did it, in case it’s useful to anyone else.

Read the rest of this entry »