Fork me on GitHub

Caolan McMahon

  • CouchDB is not a database

    Fri Jan 06 2012 Comments

    CouchDB and it's users have been in a state of flux all year, with declarations of the project's death by outsiders and the rest of community scrambling to fall in-line behind their chosen implementation.

    Read more...

  • Flexible callback arguments

    Wed Mar 23 2011 Comments

    Recently, I released a small library called Nimble, which is an experiment in unifying a synchronous and asynchronous API. Its early days yet, but I thought I'd share my approach so others can explore the viability of the technique too.

    Read more...

  • CommonJS modules in CouchDB

    Tue Jan 18 2011 Comments

    You may not realise that CouchDB actually supports CommonJS modules in design documents. This can be very useful when you want to share code across different list, show, update or validation functions.

    Read more...

  • Unit testing in node.js

    Mon Sep 20 2010 Comments

    Node.js provides a its own assert module with some really useful functions for creating basic tests. However, the reporting and running of these assertions can become complicated, especially with asynchronous code. How can you be sure that all assertions ran? Or that they ran in the correct order? This is where nodeunit comes in, a tool for defining and running unit tests in the simplest way possible.

    Read more...

  • On _designs undocumented

    Mon Sep 06 2010 Comments

    With the aim of understanding CouchDB as an application platform (and not just a database), I've been exploring some of the more recent features, as well as a few older ones that I'd previously neglected. I've found experimenting with these at turns both exciting and frustrating. CouchDB continues to lack thorough documentation, and although the reasons behind most API choices are blindingly obvious once you understand the context of their implementation, getting there is a steepening learning curve.

    Read more...

  • Async.js update and console utils

    Mon Aug 02 2010 Comments

    Since my last post on the async module its gained quite a few features, not least of which the ability to use it in the browser! However, one of the simplest additions is an async-friendly version of console.log and console.dir. Both of which are saving me quite a bit of typing when playing around in the node REPL. But before demonstrating these functions, a quick overview of the latest features:

    Read more...

  • Multiple Set-Cookie headers in node.js

    Sat Jul 31 2010 Comments

    Sometimes you want to send the same header twice in the same response, such as setting two cookies at once. But how can this be achieved when HTTP headers are passed to writeHead as an object and it's not possible to have the same key twice? The answer seems to be an undocumented feature of writeHead, that allows you to pass an array of headers instead. 'Use an array' is a little ambiguous, so let me provide an example:

    Read more...

  • Writing for node and the browser

    Thu Jul 01 2010 Comments

    Modules that can be used both on the server and the client-side are a useful way to reuse code. This is one way of writing a module that will work well with both systems, while allowing you to write code in the familiar node style.

    Read more...

  • Asynchronous code in node.js

    Tue Jun 01 2010 Comments

    Writing an async library has almost become a right of passage for node developers and I really don't want to add to this myriad of already great modules. Really. However (you saw that coming!), when I'm using node, I want to stay fairly close to the vanilla async implementation. When writing my own modules I try to follow the convention of using a single callback with an optional error as the first argument.

    Read more...

  • Deploying node.js with Upstart

    Tue May 25 2010 Comments

    Upstart seems like a really cool project to replace the old init.d scripts with an event-based system. However, I've found working with it to be pretty frustrating. Events that I expected to fire don't, and its difficult to debug. After a bit of digging around and plenty of trial and error I've managed to come up with a script that works on Lucid (and Karmic with a few tweaks). So, for my own reference, and in the hope that I save some lucky Googler the time I spent investigating, here is my process for deploying a node.js application with upstart:

    Read more...

  • Erlang map/reduce in CouchDB

    Thu Oct 15 2009 Comments

    After some initial confusion on my part, it appears that a native Erlang view server has made the 0.10.0 release of CouchDB. Unfortunately, at the time of writing, there is no documentation on enabling or using this feature. The only example currently available is in the test suite, so for anyone else wanting to play around with Erlang map/reduce functions, these are the steps I carried out on Ubuntu Jaunty...

    Read more...

  • Notifications Update

    Thu Oct 01 2009 Comments

    Just announcing a few bug fixes to the Ubuntu notifications plugin for jQuery. The plugin should now work on Firefox 2+, IE 6+, Safari and Opera. This mostly relied on removing the reliance on getBoundingClientRect() and introducing SVG-based rounded corners as a fall-back for Opera.

    Read more...

  • Ubuntu Notifications in Javascript

    Mon Sep 28 2009 Comments

    There are a whole bunch of growl-like plugins for jQuery, but I'm a real fan of the new Ubuntu notifications introduced in Jaunty (see: http://www.markshuttleworth.com/archives/253). So, I decided to create a plugin which imitates these instead.

    Read more...

  • Erlmpd - An Erlang library for MPD

    Sat Aug 22 2009 Comments

    Just a short notice to announce the uploading of erlmpd to Github. This module implements the MPD protocol in Erlang and was developed for a web-based MPD client I'm currently working on. Since I felt this module could potentially stand on its own two feet, I've released the source code here. I've also uploaded the docs for reference.

    Read more...

  • Flatten for Python

    Fri Jul 17 2009 Comments

    After making frequent use of lists:flatten/1 in Erlang, I found myself wanting to use this function in Python too. Somewhat surprisingly, Python doesn't have a builtin for flattening lists. If you're not familiar with flatten, its most easily explained through some quick examples:

    Read more...

  • Erlang syntax highlighting

    Sun Jul 12 2009 Comments

    For this site I wanted to use a simple syntax highlighter written in Javascript. Unfortunately, when I searched, none of the existing libraries seemed to support Erlang source code. So I descended like a vulture onto the vim syntax file and somehow mashed it into something that resembles a GNU Source-highlight language definition.

    Read more...