Caolan
Multiple Set-Cookie headers in node.js
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:
Writing for node and the browser
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.
Asynchronous code in node.js
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.
Deploying node.js with Upstart
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:
Erlang map/reduce in CouchDB
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...
Notifications Update
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.
Ubuntu Notifications in Javascript
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.
Erlmpd - An Erlang library for MPD
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.
Flatten for Python
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:
Erlang syntax highlighting
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.