Simple Example of Event Emitters in Node.js

Very similar to the pub-sub or observer/listener pattern where events are triggered upon a particular action.


var fs = require('fs'); // get the fs module
var EventEmitterVar = require('events').EventEmitter, util = require('util');

var exampleEventEmitterClass= function () {
    console.log("emitter constructor");
util.inherits(exampleEventEmitterClass, EventEmitterVar);  //register class as emitter

exampleEventEmitterClass.prototype.emitMethod1 = function () {
} ;

exampleEventEmitterClass.prototype.emitMethod2 = function () {
}  ;

//register events
var evtEmitInstance = new exampleEventEmitterClass();
    .on('emittedevent1', function () {
    console.log('Executing Event Emitter 1');
    .on('emittedevent2', function () {
        console.log('Executing Event Emitter 2');

for (var i = 0; i < 3; i++) {

for (var i = 0; i < 3; i++) {

Setting up Yoeman (Compass and Sass)

Yoeman is a scaffolding and workflow platform for developing modern (HTML5) webapps. In a rough sense, it is to Node.js what Rails is to Ruby. When setting this up on my ubuntu based workstation, I ran into a few conflicts installing Compass and Sass (possibly because of conflicts between the “apt” and “gem” environments. Eventually, I backed out my ruby, compass, and sass installs and re-installed them via the following commands. Post install, “grunt serve” and “grunt test” worked without complaining about compass not being in the path etc.

sudo apt-get install ruby-full rubygems1.8

sudo gem install sass

sudo gem install compass


Decent dark theme (light text on dark background) finally available for eclipse.

I’ve been using intellij for a while now and usually cringe a bit whenever I need to use eclipse. One of my big issues with eclipse has been their atrocious support for dark themes (helpful to those of us who value our eyesight). I’ve tried various plugins in the past and have usually come away dis-satisfied (bad colour schemes, file navigator refuses to comply to the theme etc).

However, I’ve come across one plugin that seems to work okay (at least on my mac). It looks to be a clone of the intellij “darcula” theme and can be found at¬† .

Note that this plugin merely affects the eclipse ui framework windows (the file navigator etc). To change the color themes for the actual code windows, you will need another plugin such as

Big thank you to the author.

Testing for Equality using reflection

This utility tests for equality using reflection. Saves you from getting carpal tunnel by  writing multiple lines of the form

assertThat(result.getFoo(), is(equalTo(item.getFoo())));

Here’s the source. Modify as needed

public class MappingTestUtility {

public static void assertEquals(Object input, Object result) throws IllegalAccessException {
 assertThat(result, is(equalTo(input)));
 final Field[] fields = input.getClass().getDeclaredFields();
 for (final Field field : fields) {
 assertThat(field.get(input), is(equalTo(field.get(result))));