Caolan McMahon
-
CouchDB is not a database
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.
-
Flexible callback arguments
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.
-
CommonJS modules in CouchDB
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.
-
Unit testing in node.js
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.
-
On _designs undocumented
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.
-
Async.js update and console utils
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:
-
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.