I am Hack Sparrow
Captain of the Internets.

Archive for December, 2012

Loading JavaScript Modules in the Browser with Component.js

Is there a way to enable the module loading capability of Node.js in the browser? How wonderful it would be if you could write JavaScript modules the Node.js way and load them in the browser. There have been many attempts at doing this. Notable among them are RequireJS and Browserify. Both got things done one or the other way, but are unnecessarily complicated and a pain to use. If you type "browserify" or "requirejs" ...

Scripting a Node.js App

What in the world could "Scripting a Node.js App" mean? Well, we are talking about the ability to write scripts for your Node.js apps. Wouldn't it be cool to be able to write independent JS scripts and execute them on the fly, in your app? This post is about that ability. When I first encountered the Node.js vm (Virtual Machine) module, I thought, "Hmmm, this thing looks like eval(). How different is it from ev ...

vhost in Express.js

Wondering how to replicate the Apache , it allows a web server to listen on a single port and serve different web apps depending on the domain name or the subdomain. Implementing such a feature in Express.js is very easy. Before we can see how is implemented in Express.js, we would need to play a little trick on our PC: [code] $ sudo vi /etc/hosts [/code] Append these entr ...

How to write Node.js Modules

So you have come to the stage where you feel the need to write Node.js modules of your own, or maybe you are just ... curious? Whatever be your reason, in this tutorial, I will show you how to create Node.js modules. Node.js modules are CommonJS-compliant modules, and are pretty straightforward to implement. You would have created a few modules by the end of this tutorial, trust me. First let's see how a Node module installed via NPM ...

Node.js Tutorial

Hello there! I see you wanna learn about Node.js and are looking for a tutorial to help you get productive in it immediately. Great news: you have come to the absolute right place. There exist many tutorials already on Node.js, written by knowledgeable and skilled people, on many websites. So what’s the point of writing another one? Well, those tutorials, even though informative, do not teach the basics of what Node.js is and the stuff that make it up. Instead of focussing on how to create ...