Home Intro Section

HTML5 Web Sockets Experiment

Posted by Matt Seward, 21 March 2011

We have been getting a bit giddy about HTML5 Web Sockets. If you didn't know, HTML5 Web Sockets allow browsers to establish an "always on" (full-duplex) connection to a web server, which is a big deal for anyone using or creating real-time data, event-driven applications.

Until now, if we wanted to update a screen with some new information, without requiring our users to click somewhere to trigger a full page reload, we had to use Javascript to communicate with the server in the background (AJAX). This simply creates content requests on behalf of the user which still involves waiting for the niceties of an http transaction to be performed.

The always-on, nature of HTML5 Web Sockets makes for a better (faster) User Experience (UX), creates all sorts of possibilities for some really nice User Interface (UI) elements and it also reduces network load.

We agree with the industry commentators who reckon that this is a big deal. Even though at this moment in time HTML5 Web Sockets is not perfectly implemented across all modern browsers we wanted to play around a bit to see what we could do with it, so we came up with the Twitter Happiness Meter.

The Twitter Happiness Meter

A moving gauge displaying the collective happiness of Tweets in real-time.

Twitter Happiness Gauge
How Happy Is Twitter? (Currently requires a Webkit browser, Chrome or Safari).

The Twitter Streaming API allows us to obtain public tweets in near-realtime, based on criteria that we define. In our case we are filtering status messages to only obtain those containing emoticons, e.g. :) :( :D ;) :-)

Using Node.js we can create a simple TCP Server which listens on a specified port for the stream of tweets. We then perform some very simple post-processing of the data received in order to generate a 'happiness' rating which we can then use with The Google Visualization API to display the Gauge.


  • The filtering we are doing is very very lo-fi, plus there exists more positive emoticons than negative which will effect the results. We'd like to process the data in ways that can produce a more meaningful assessment of 'mood'. We haven't even began to look at this but if anyone could point us to some useful resources we'd appreciate it.
  • Overall the Gauge hovers around the 'fine' (50%) mark, which is to be expected as overall the good and bad should even each other out. This renders this particular visualization fairly dull.
  • We wanted to experiment with other sources of large amounts of data (replacing the Twitter data) but struggled to find good sources of streaming data. Please comment below if you can suggest any.

Finally we'd be really interested in any ideas you might have for projects, gadgets, user interface elements that could really benefit from being hooked up to real-time data sources.

Further Reading

HTML5 Web Sockets: A Quantum Leap in Scalability for the Web


Twitter Streaming API

Google Visualization API

The Gauge can be found in the gallery


7 (Toddler) habits of highly effective programmers

Posted by Matt Seward, 21 January 2009

I often wonder how much better a developer/programmer/innovator I could be if I could just emulate some of the natural tendencies of my toddlers. I'm talking about habitual behaviours such as:

  1. Aptitude for languages - admittedly this is an obvious one, I'm just getting it out of the way early.
  2. Curiosity - they take total joy in the process of learning (at least when there is no pain involved) and move effortlessly from one thing to another.
  3. Willingness to make mistakes and...
  4. Ability to learn from mistakes. Toddlers are naturally free thinking because they're not bound by concerns about what is expected from them or what others think of them. Or, as we'd say in Yorkshire, they "say what they like and like what they bloody well say"!
  5. Determination - I love their tenacious approach to problem solving, the willingness to repeat and adjust their efforts until success is achieved, or at least until Ben 10 comes on the telly.
  6. Enthusiasm - an infectious sense of fun and ability to engage and involve the people around them.
  7. Keeping things simple - ability to filter out unnecessary information in a flash to reach an understanding of complex problems. The other day my Daughter was asking me why Daddies pee standing up. After an endless stream of 'why?'s and a lot of squirming from me we reached the conclusion that its because Daddies can. What struck me though was the speed at which the fact that men can also pee sitting down was shelved as unnecessary surplus data. Mummies sit down, Daddies stand up, simple.

Of course, if you spoke to my work mates they would probably tell you all about the toddler habits that they'd rather I didn't exemplify at work. The tantrums when things don't go my way, needing an afternoon nap. But that's a whole different blog post!