Filed in "code"

Using Elixir to visualise the Bitcoin futures curve

For the last couple of years my cryptocurrency trading has focused on doing a carry trade between the Bitcoin spot and derivatives markets. This has involved buying spot Bitcoin and selling short a corresponding quantity of perpetual swap contracts and/or futures contracts. The mathematics of this trade are described in this in-depth article . To trade futures I’ve been using Deribit as they now offer contracts that settle up to a year in the future which I’ve found useful for longer term planning, especially when I’m borrowing against my spot holdings to increase the size of my position.

RPC between Go and Ruby using Protocol Buffers

I’ve previously written some thoughts on service oriented architectures and since then I’ve wanted to explore beyond the currently accepted standard of sending and receiving JSON data over web APIs. Protocol Buffers With JSON there’s an overhead of transmitting plain-text over the wire coupled with parsing that text in your application once received. For many cases this is probably acceptable but for a large-scale distributed system this can represent a not insignificant cost in terms of bandwidth and computing resources.

A simple service oriented architecture using Ruby and Go

Some common pain points seem to keep cropping up time and time again as applications grow in size and complexity: tests get longer to run deployments become a much more involved process making a small fix to one area of code can often break something in another it can be much harder to reason about the system as a whole These large, monolithic applications are affectionately known as monorails in the Rails world and the common wisdom is to start splitting up the codebase into services: to extract areas of functionality out into self-contained, independent applications which work in unison to deliver the original capability.

Serving up a static site using Go

Like a lot of people in technology a portion of my time is spent wondering what will be the next programming language, framework or whatever to take off and become popular. Of greater personal importance is the matter of which one of them will get added to my toolboox next and press-ganged into productive use. For years now Ruby has been my goto for a lot things and I’ve been doing more and more OS X and iOS development but it had been some time since I last picked up something new and I had a hankering for some shinyness.

Decisions, decisions, decisions

I can be an awfully indecisive person at times. Often I’ve been in the grips of analysis paralysis unable to pick a course of action to take, crippled with choice. When I was a student I read The Dice Man and was sorely tempted to make all my decisions by rolling a die or tossing a coin. Needless to say this is maybe not the best way for a person to navigate through life.

An Introduction to WebSockets

Last week I gave a short talk at BelfastJS outlining WebSockets: what they are, how you use them, examples, warnings and alternatives. That should cover the basics I think. A few months ago I spoke at BelfastRuby and it was good again to be sharing some knowledge with a bunch of people enthusiastic about technology and the local community. Hopefully we can keep things going and help make Belfast a supportive environment for those involved in the knowledge economy.

An iOS client for my Coffee Tracker API

About 9 hours ago I dandered down the road to see what was happening at the FlackNite event being hosted in Farset Labs. When I finally got myself settled down with network access and a cup of coffee and said hello to everyone it seemed I was the only one without a project to work on. Nightmare. Decisions, Decisions I couldn’t think of what to focus on but Rob and Pete were sitting next to me and tinkering with some Objective-C and Cocoa.

An introduction to Sinatra

Tonight I gave an introductory talk about Sinatra at the second meetup of BelfastRuby. The Converser platform I’ve been building this last while uses a lot of Sinatra so when I was asked to give a talk about using Ruby to develop web apps without Rails it wasn’t hard to think of a subject. This was my first technical talk and apart from a touch of nerves and forgetting some of the jokes I had in mind I think things went well.

Tracking my coffee consumption with Redis, Sinatra and Cocoa

I’ve often joked about putting together an app to track my coffee consumption, such is my reputation for consuming the black goodness. Like a lot of my other personal projects, the idea had a prolonged gestation period and was finally born through a welcome spark of motivation. Crafting fine web APIs Over the past 6 months the bulk of what I’ve been doing day to day with Vigill has involved building web APIs for consumption by mobile clients.

A simple app to monitor Google Chrome on OS X

I was on-site with Vigill one day before Christmas and I mentioned to Oisin an idea I had for an app. I was sick of having endless tabs open in Chrome, hogging memory, each one some seeming important enough at the time that I read it but now just a contextless enigma. If I at least knew how many tabs I had open, it would be a step in the right direction I thought.

My also-ran Markdown Editor for OS X

Quite often I feel the need to learn something new for the sake of learning something new. Covey aficionados would know this as sharpening the saw. I usually struggle deciding upon something however as there are so many areas to choose from in the software world and it isn’t everyday I feel drawn enough to something to put time and effort into it on top of holding down a day job.

An iOS client for my UK inflation app

After last week’s great Xcake meet I felt a fresh surge to take on new challenges and bend some less-familiar pieces of technology to my will. Motivation The first product of this enthusiasm was a prototype web app built to get a bit more experience with Python and Google App Engine. A few days later it got an API. The resulting rapid feedback loop led me to pick up my copy of Beginning iPhone Development which had been sitting gathering dust for the last couple of years and get stuck back into following the examples.

Keeping an eye on UK inflation with Google App Engine

For a long time now whenever I’m on the search for something interesting to work on that could potentially be of value to myself and others my attention is brought to topics like machine learning, data mining and natural language processing. These are all areas within computer science which are not particularly easy and have a higher barrier of entry compared to building a typical web application for instance. Yet, if implemented correctly they can provide great insight and fame and fortune are bound to be near.

A minimal Rack app to lookup your external IP address

I think I first heard the term “Rack-app” when I started using Heroku to host a couple of projects. I didn’t know an awful lot about Rack but I did know that it helped a great deal when it came to getting my Rails and Sinatra apps off my workstation and onto the web. Tonight I thought I’d have another quick look at how it works, what it takes to build a Rack-app and what information about the request is available to the handler.

Backing up Delicious bookmarks to CouchDB

Last year I started researching how CouchDB could be used for the BodyGuard web-app QA platform. Unfortunately I had to put my tinkerings to one side when some extra freelance work came in; contracting during the day and freelancing in the evenings quickly put an end to any spare time and my fitness efforts took a hit but I was only self-employed for a short while and it seemed the thing to do.

Minder - a simple web-app monitoring tool written in Ruby

Background A few months ago I was tasked with migrating and maintaining a bunch of legacy Rails apps and a couple of them were misbehaving. Requests were hanging which was tying-up the front-end Apache child processes and resulting in all the web-apps on the server becoming unresponsive At the time I didn’t know what was causing the hanging requests, it wasn’t happening in a predictable manner and on the surface I had all the apps dependencies in place.

Is it raining in Belfast? Redux

Last year I created a nano-app which attempted to answer the question, is it raining in Belfast? I was never completely pleased with it but the objective was to get something done and get it done fast, which was achieved. This weekend I’ve been tinkering with another project and hit a bit of a stumbling block getting various pieces of software to co-exist. I decided a break from the problem would be beneficial but I still wanted to have some sense of achievement from the weekend and redeveloping this app seemed a good idea.

An experimental lifestream app

Some time ago DW and myself had an enthusiastic conversation about logging various aspects of our electronic lives: emails sent and received, RSS feeds read, incoming and outgoing phone calls, the list goes on. At that time I’d already started tinkering with apps to track my efforts in the gym and changes in my bodyweight, I’ve used notebooks for this for years and thought it’d be interesting to have this information in electronic form.

Rails 3 Hello World

The past while I’ve been busy providing technical consultancy to BT and haven’t had much drive to work on anything on my own time. The itch has returned the past couple of weeks though so I thought I’d see what I’ve been missing in the Rails world and in what better way than getting a basic Rails 3 app up and running. My environment was already setup for Rails 2.3.* and Yehuda Katz' post served as a guide to get me up to speed with the beta loveliness.

Home time revisited - redeveloping a CakePHP application with Sinatra

I’ve just released the latest iteration of, 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.

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.

A dummy datasource for CakePHP

I was recently developing a project at work which at the beginning didn’t need a database. However, Cake was still testing the database connection and issuing a warning as a result when it couldn’t connect. My solution was to create a dummy datasource which silenced the warnings and allowed me to get on with the rest of development in relative peace. The scope of the project changed and a database was required.

Mashing up Twitter Trends and Google Images

I recently released the latest entry in my series of nano-apps. As with my previous efforts, serves serves no real purpose other than as an act of deliberate practice: going through the process of coming up with an idea, writing code, registering domain names, setting up Cron jobs and configuring deployment systems to get it all up and running in a production environment. I questioned why I was even bothering with an app that was likely not going to see any traffic or be of use to people and when I hit a minor javascript problem the project was shelved for a few months.

Because everyone needs their own URL shortening service

At the moment I’m in between paid work and have been using my time to generally enjoy life but to also improve my skills. I’m all about the skills. As an act of deliberate practice to hone my skills with web-application development and to deepen my understanding of the Rails framework I’ve been adding to my collection of nano-apps. A while back I had an idea to develop a URL shortener just to see how little code would be required but decided the world really didn’t need another one.

Finally, after 2 and a half years, my Rails DVD catalogue is go

Well, it only took me 2 and a half years but I finally used Rails to develop a catalogue for my DVD collection. The catalogue loosely fits in with my series of nano-apps and is hosted on The code is publicly available on GitHub for anyone who’s interested. All’s left now is to actually use the system and fill in the details of my collection!

An experiment with Sinatra, HAML and Blueprint CSS

In my last post I considered transforming into a Sinatra app. Well, I did it, although I’m only mentioning it now. Not only was this my first experience with Sinatra but I also decided to try using HAML for the markup and Blueprint CSS to help with the styling. If I’m going to play with a new technology why not play with a few new technologies? I found Sinatra quite straight forward: you match up a HTTP verb (eg ‘GET’) and a url (eg ‘/') with a block of Ruby and the results can be sent directly to the browser or an optional view template can be rendered.

First production Rails app

I released my first production Rails application,, last night. I first started playing with Rails over 2 years ago and it has taken me until now to take an app through from conception to initial deployment. And an interesting journey it has been. When I first started investigating Rails I had never used a web framework before and the Ruby language really confused me, but there were a few things I liked.


Last month Giles Bowkett in the trawls of his hypergraphia wrote a post on Nano-Apps, quirky one page apps which serve up a piece of trivia or answer a question like is George W. Bush still president? Previously I had put together, a little AJAX-y app to let me know how much longer I had to go until I could leave work for the day and when a new nano-app reporting Belfast’s goodonpaper’s coffee drinking habits surfaced the bug bit me and I wanted to do something and do it quick.

Simple example of accessing the Twitter REST API with Ruby

To date, a lot of interesting applications have been built on top of the Twitter service with new apps being released almost daily, each one more ingenious than the last. In my spare time I’ve been tinkering with Ruby, my motivation being to learn something new and to see if Ruby lives up the hype that has been surrounding it in recent years. In conjunction with this I’ve also been experimenting with obtaining content from existing web sites and services, content being king after all.

Home time is a little closer

Before calling it a day last night I pushed out another release of my “toy” web-application, Thank you Capistrano! I mentioned last month that I was intending on following the “release early, release often” paradigm with this project, but as always, life had other plans and I found myself doing very little hacking outside of the 9-5. Regardless, I believe this release provides a great deal of extra functionality and I’m content to just have gotten the code out the door.

Is it home time yet?

I’ve just released the first iteration of which provides an answer to the important question of is it home time yet? My general dislike of working for a living inspired me to craft a python script during my tenure at $BIG_CORP and last week the creativity bug bit me and I decided to quickly develop a web-application and get it publicly available. Thanks CakePHP! I’m following the “release early, release often” philosophy and as such this iteration only has the most basic of functionality but I’ve some more interesting/useful things planned and will get them out as soon as possible.

What, no version control?

$WEB_CORP has taken on the maintenance contract of a particular site and the client has asked for some changes to be made along with fixing up some SQL injection vulnerabilities. My first step was to GET all the site’s scripts via FTP so I could create a local DEV instance of it and was surprised to see the following: $ ls -1 index*.asp index-old.asp index.11May2007.asp index.11Oct2006.asp index.13March2006.asp index.18aug2006.asp index.20Feb2007.asp index.20Jan2006.asp index.

$BIG_CORP rides the snake - my first Python script

In between support tasks at $BIG_CORP I’ve been slowly reading through O’Reilly’s Learning Python and trying a few things out with the command-line interpreter. The first script I’ve written that actually does something useful is #!/usr/bin/env python countdown to 5pm 2008 SJW import datetime now = home = datetime.datetime(now.year, now.month,, 17, 0, 0, 0) total_secs = (home - now).seconds hours = total_secs / (60 * 60) minutes = (total_secs - (hours * 60 * 60)) / 60 print hours, " hours and “, minutes, " minutes until 5pm”

Fun with Photoshop and cross-browser CSS

The consensus wasn’t to go live with the new site straight away after all but to create a better impression on the public by waiting on the final design and within no time at all Jordan had worked his graphical magic and delivered the goods. I was supplied with a .psd mockup and got busy with Photoshop. I hadn’t used this app in a while and it took some time to relearn how to use it but I managed to cut things up and proceeded to get stuck into the CSS.

Getting ready to launch

I’m preparing to push my code for the new Infurious site into production so we can start selling our first application, Rickshaw. The site’s not too pretty but It Works and our freshly recruited designer Jordan has some interesting ideas for the next iteration. All the important stuff is present: people can download Rickshaw, purchase a license and the license details will be generated and mailed out to them. I’ve just had a dry run of this scenario and it all looks good.

Infurious Update

Just a quick update on what I’ve been working on for Infurious recently. Since finishing up on configuring Jabber I’ve been developing our website with the specific aim of allowing customers to download our products and purchase licenses for them. For this I’ve returned to CakePHP and been tinkering with the PHP portion of the AquaticPrime framework which Aidan has implemented in our upcoming application, Rickshaw. Other highlights have been working with the PayPal Sandbox and writing a component which generates “Buy Now” buttons for our apps and then handles the Instant Payment Notification and Payment Data Transfer callbacks once the transaction has been completed.

MySQL upgrade

I finally got sick of not being able to use SQL subqueries and decided to upgrade my MySQL installation from 4.0.x to 5.0.x. I had wanted to do this previously but was afraid I’d end up breaking something and be left without a working development environment or a website either, for that matter, so I resorted to complicating my custom queries in CakePHP with JOIN statements :( I couldn’t find a 5.

CakePHP 1.2alpha - model validation

I thought I was out of the woods. I upgraded my development copy of MacServ to the alpha version of CakePHP so I could make use of it’s pagination features; I tweaked my views to replace calls to various deprecated html helper functions with the new ones in the form helper, made one or two minor changes and thought I was good to go… First thing this morning one of the engineers was having problems adding a new repair.

Patching CakePHP

I submitted a minor contribution to the CakePHP framework today, a patch to a patch, to be specific. It’s good to give back :)

Synchronising production and development code with subversion

Now that MacServ has been deployed keeping development and production copies of the code synchronised has become an issue. The app is still very much a work in progress, with daily requests for fixes & tweaks from the technicians using it and instead of keeping track of modified files and then manually updating them via scp, I decided to let laziness motivate me to utilise a less painful system. I spent a bit of time researching the use of rsync but decided that subversion would better suit my needs.

MacServ deployed

The initial version of my latest project, MacServ, has just been deployed. MacServ is intended to model the work-flow at Mac-Sys and to replace the existing paperwork. Deployment was scheduled for close-of-play yesterday and I thought I was home clear: I’d uploaded the scripts, configured the database and at a quick glance things appeared to be working. I was getting ready to leave the office and hit the gym only for one of the staff to discover that one of the apps controllers wasn’t operational…

PHP predefined variables on BSD

I’ve been getting ready for the deployment of and one of the final features to be into place was restricting access to the administrative back-end. I enabled admin routing in CakePHP and put all the back-end code into admin_* functions in my controller which are accessible via /admin/controller/action. I wanted to enable some form of access control but without utilising a full user management system which would have been overkill.

Ajax: first impressions

I’ve been working on a form in my app and was faced with a decision regarding one of the fields: I need the user to select an object from a (possibly large) number of existing objects. I reckoned I had 3 options: a simple drop-down list, which could prove to be impractical; a pop-up window; or, behind door number 3, I could investigate the use of Ajax, which would have the added effect of adding some web 2.

O frabjous day!

Yesterday, the project I’m working on turned into a full-time gig. I start Monday as a full-time developer and can finally sign-off after nearly 6 years on state benefits. It works if you work it!


I secured my first consultancy gig on Monday, developing a web-app for a local business; the end-product is to be deployed onto a standard *nix hosting account, so it’s going to be an adventure in PHP and MySQL from here on in. Since my first meeting with the client I started collating all the various bits and pieces of PHP I’ve written over the past couple of years with the intention of producing some form of crude framework which would allow me to develop sites quicker and easier.

UML For A Laugh

I’m just getting started in the development of my next application: a management system for the Agency’s various resources. The intention of this program is to allow members of staff to book laptops, projectors and so on and to see at a glance what is already booked, when for and by whom. Not since my days of 210CSC218 and the calamity that was my undergraduate dissertation have I done any serious planning or documentation for anything I’ve implemented to date, but for some reason the mood took me this morning and I found myself brushing up on UML and printing off a reference to remind me of the different symbols involved.

ClickOnce, yeah right

I’ve just committed vdaExtensions 1.1 to SVN: I had had enough of stressing out about minor aspects of the user interface and just went for it and published the application. Only to discover that ClickOnce wasn’t working on the target desktops, doh! The problem was with the assemblies for the ReportViewer class. I have SQL Server 2005 Express installed on my machine and so had no problems with the app getting access to the appropriate libraries at runtime, but it didn’t look like the .

WinForm Woes

I’ve been finishing off the next release of vdaExtensions seemingly forever and have had all the functionality sorted out for ages and without much in the way of trouble but I’ve been struggling with the user interface. The only contents of my main form are a MenuStrip and the meat of the app, a DataGridView. Throughout the use of the program the DataGridView can change dimensions: information can be added/changed/removed and I’ve also added the ability to show/hide the various columns of the control, with the constraint that at least one column must be visible at all times.

In Pursuit Of vdaExtensions 1.1

The past fortnight has proved fruitful: each weekday I have risen early, went to the gym and spent the rest of the day at the office plugging away in Visual Studio. It’s been good to get back into developing vdaExtensions: it’s first incarnation was completed in August and I asked a few members of staff to try it out and Phil was the only one to give me feedback, I don’t know if anyone else even used it!

Rip It Up And Start Again

I’ve just finished putting the changes I’ve been making to this site live. The front page is now an integration of my latest blog post, a random image from my gallery and a short bio of myself. Getting the latest post was explained well by this post and boils down to including the WordPress header file and calling query_posts() with the appropriate search criteria, from there it is a simple matter of making use of The Loop and Template Tags, just like when creating a theme.

Ruby On Rails

I decided last week to see what all the hype was about and have a look at Ruby On Rails. I’ve been meaning to catalogue my DVD collection on my site for a good while now but nothing ever materialised, so I’ve got something to work towards and if RoR delivers what it promises I should get something up and running quite quickly. The first thing to do was to track down some kind of reference material to learn from and this book seemed like the right place to start.

My Brain Hurts

I’ve just finished hacking new features into a web-app my colleague Kev developed. Yep, I was deep into M$ country but as always nothing beats the sense of satisfaction that problem solving brings (for me anyways.) Any time I’ve went back over my own code I usually ask myself “what was I thinking of here?” so over the past few days I’ve felt pretty much like that what with stepping into some one else’s work and trying to understand what is being done, how it is being done and getting acclimatised with a foreign coding style.

It's Alive!

I’ve just published the first release of a little application I wrote to manage the list of internal extension & direct dial numbers of staff here at the VDA. A few members of staff have been asked to give it a whirl and report back. Up until now it’s been the responsibility of one of the admin team to maintain a spreadsheet containing the info and distribute printed copies of it to everyone else.

Where Old Code goes to Die

Well, I’ve started a million different projects and finished none, so in an effort to quell the sense of dis-ease I’ve went back to whatever seemed nearest to completion before I abandoned it… …which has meant getting stuck back into Classic ASP and MS-SQL, not nice for a Linux-fanboy-wannabie like myself ;) Captain Beefheart’s Trout Mask Replica has been providing much needed mental stimulation while I at least try to make some progress on this thing.

And So The Legend Grows

Just put the development site live, fingers crossed!