Archive for the ‘node.js’ Category

Yet another must have node.js module – underscore-cli

September 12, 2012 Leave a comment

If you love underscore.js and happen to be a CLI nut, you should not miss out underscore-cli, see

for details, or simply install via (assuming you are already using node.js)

sudo npm install -g underscore-cli

Test Drive:
curl|underscore print --color

Categories: javascript, node.js

Install node.js on Raspberry PI in two simple steps

July 24, 2012 13 comments

[ Updated Jan 20, 2013 ] Check out my git repository if you are interested in putting newer version of node to raspberry pi (tested with 0.8.14, os runs raspbian)

1) Install the newest wheezy image onto the sd card (currently from


sudo apt-get install nodejs npm

, press y, Enter when prompted, you will get node.js (v0.6.19) and npm (1.1.4) installed in a few minutes, which should be the easiest way to get node.js and npm up and running on RP.

Note: If you want newer version of node.js you might want to check this out:, I have tested the method described in this post in the previous release of wheezy ( and I assume it should work with the current image as well.

Categories: node.js, raspberry pi

A simple password generator written in node.js

Probably not a very advanced password generator but should be adequate for general purpose, see for details.

Sheevaplug + Debian 6 (Squeez) + node.js 0.6.13

March 21, 2012 Leave a comment

1) Preparation

apt-get install build-essential libssl-dev curl
cd /tmp
tar xzf node-v0.6.13.tar.gz
cd node-v0.6.13

2) Edit file deps/v8/SConstruct as follows:

//line #80
  'gcc': {
    'all': {
      'CCFLAGS':      ['$DIALECTFLAGS', '$WARNINGFLAGS', '-march=armv5t', '-mfloat-abi=soft'],
      'CXXFLAGS':     ['-fno-rtti', '-fno-exceptions'],

//line #1081
  'armeabi': {
    'values': ['hard', 'softfp', 'soft'],
    'default': 'soft',
    'help': 'generate calling conventiont according to selected ARM EABI variant'

3) Compile & Install

make && make install

Step 3) will take about 40 minutes. If installation is successful, command node -v should print v0.6.13.

4) Download and install npm

curl | sh
npm list -g
ln -s /usr/local/lib/node_modules ~/.node_modules

The ln command is optional but it’ll make require statements much easier.

Categories: Debian, node.js, sheevaplug

Example: sorted set functions with node.js + redis

February 28, 2012 2 comments

Have been playing with node.js module redis (and a bit of underscore) almost all day and I could not find any examples using zrange (or zrevrange) so I decided to write one as a practice:

var rc=require('redis').createClient();
var _=require('underscore');

rc.zincrby('myset', 1, 'usera');
rc.zincrby('myset', 5, 'userb');
rc.zincrby('myset', 3, 'userc');
rc.zrevrange('myset', 0, -1, 'withscores', function(err, members) {
        // the resulting members would be something like
        // ['userb', '5', 'userc', '3', 'usera', '1']
        // use the following trick to convert to
        // [ [ 'userb', '5' ], [ 'userc', '3' ], [ 'usera', '1' ] ]
        // learned the trick from
	var lists=_.groupBy(members, function(a,b) {
		return Math.floor(b/2);
	console.log( _.toArray(lists) );

Have fun.

Categories: node.js, redis, underscore

System load monitoring with

February 12, 2012 Leave a comment

I am a big fan of node.js, and a long list of other node modules, as you might have known through my News Board app. While working on a html5 charting project a few years back I discovered flot which I also became a fan of. I started a few weeks ago working on a real-time charting app with the technologies I just mentioned, by plotting some randomly generated numbers (streamed through with flot. Today I just changed the app by using real data – system average loads. Check out the project at github if you are interested in. My next goal is to use Redis to handle the data captured.[update] A new branch using Redis as data store has also been implemented.


Categories: flot, node.js,

A real-time app made with node.js,, express …

January 19, 2012 2 comments

This past weekend I decided to work on a pet project – build a real-time app using node.js.

Modules used:, express, jade, sqlite3.

Still screenshot:

News Board still image

News Board 3 clients on the left, admin UI on the right

Checkout the source codes at:

Video demo is available here (audio-less).

Have fun.

Categories: node.js,