Home time revisited – redeveloping a CakePHP application with Sinatra

I’ve just released the latest iteration of hometi.me, a little nano-app I’ve mentioned before.

Deliberate Practice

It’s only a trivial app but I’ve a bit of free time before the start of a contract so I thought it would be good practice to redevelop it, a task I’d been ignoring for a long time.

Goodbye CakePHP, Hello Sinatra

The original app was put together quickly with CakePHP, a PHP-based framework I’ve used since my first paid programming gig. Since then though my interest and proficiency with Ruby and it’s frameworks has come more to the forefront. By choosing Sinatra, the app was given access to the rich Ruby ecosystem, including the joyful HAML and SASS.

The interesting aspect of this release is that all the logic is now implemented on the client-side using Javascript. Originally the countdown was calculated on the server-side and passed to the client with an AJAX call, but the server is more-or-less just hosting the markup, stylesheets and Javascript files required to get the app up and running in the browser.


As this app doesn’t make use of a database or Cron jobs etc I thought I’d take the opportunity to move it from my own infrastructure and onto the awesomeness of Heroku whose free offering is a lot more performant than my little VPS. Heroku is a service I’ve been playing with for a while now and it makes deploying a Ruby web app into production a breeze, assuming your project can work within it’s limitations.

All that’s left now is for the DNS changes to propagate. I’d like to show a bit more love to this app in the future, the controls to specify your own home time could be more intuitive for instance, but for now I’m content with the improvements I’ve made to it and it’s new home.

Is it passed your home time yet?

node-shoutbox – a simple node.js demo

Last month, at the inaugural Super Happy Dev Castle, my buddy Dave Rice told me about a project he was working on involving node.js, an event-based I/O system for Javascript.

Javascript outside of the browser?

This concept seemed almost ridiculous to me at that time but I thought it was worth a look and cobbled together a quick “Hello World.” I was greatly amused by creating a command-line app with Javascript but did nothing more about it until last week. I’m currently starting out as an independant contractor & have a bit of spare bandwidth so I thought I’d put together something a bit meatier in order to learn more about this system & to also sharpen up my Javascript skills.

Dave had shown me node-comment and I also studied node_chat. From there I had just enough reference material to understand the mechanics of long-polling and to start piecing together a simple real-time commenting system.

What is node?

In and of itself, node is not a web development stack. It provides an I/O platform of which HTTP handling is a part. People are building blogging and wiki engines, FTP servers and command-line tools with this thing, anything I/O based is possible and thankfully micro-frameworks like (fab) can ease the pain of creating web apps.

Node is still very young software, which I have felt the pain of. To serve up static content I wanted to use paperboy as it can be used as middleware within (fab), however mere days after the last update to the project the API it was relying upon in node changed fundamentally. Despite being new to node development I was able to patch paperboy to work with node v0.1.31 and get on with my actual project. Another sticking point was the inability of (fab) to handle POSTed form variables, this functionality is planned for it’s next release though.


Ultimately, my app is of little practical use: it doesn’t make use of persistance or moderation and node’s suitability for the production environment may itself be questionable at this time, but it was quite a fun experience. From something I more-or-less despised a decade ago I’ve come to develop a real affection for coding Javascript over the past few years.

When I had the basics of the app laid-down I eagerly awaiting the moment when I could have it open in two browser windows and enter a comment into one and see it appear in the second. That moment came and it brought a smile to my face. I suggest you give it a go :)

Get the code

As a wise man once said, code speaks louder than words, so please be my guest and clone my demo on GitHub.