Nodejs Sqlite Module Issue

I have been trying on setting up with nodejs sqlite module (Node-Sqlite) and i am facing an issue as follow when i try to build

node-waf build

it throws me following error

Waf: Entering directory /home/anand/Downloads/node-sqlite/build'
[1/2] cxx: -> build/Release/sqlite3_bindings_1.o
../ fatal error: node_events.h: No such file or directory
compilation terminated.
Waf: Leaving directory/home/anand/Downloads/node-sqlite/build'
Build failed: -> task failed (err #1): 
{task: cxx -> sqlite3_bindings_1.o}

My platform was ubuntu v11.04 and node v0.6.15

i found an another module to over come this issue node-sqlite3

installation can be done pretty simple with npm registry

npm install sqlite3

Static Website With node.JS

I am really addicted to nodejs stuffs and modules, not just because of javascript; but also because of a few videos and blogs that I read, made me spend time with learning nodejs. I am at the beginning stage of learning and exploring nodejs. Hence, I am putting everything I have experienced here.

My previous article “Introduction to Nodejs” helps you install and start programming on node platform. This time, I am going to help you create a simple static website on top of nodejs and how to use node modules. This static site can be done with simple HTML and CSS. However, in my opinion, learning in practical manner will add more value in lesser time than reading lots of theories. The following article helps in your Node learning curve rather than a real world problem solver.

Let me take a simple use-case before getting started. I want a simple Shopping cart app built on top of nodejs I will be using this use-case throughout my series of articles.

Why Nodejs?

  • I want my application to serve concurrent requests at same time
  • I want my application to run on distribute environment
  • Javascript is my favourite language and Nodejs is much similar to Javascript

Lets first install Pre-Requisites!

Node Package Manager(npm) is a package manager for node. You can use it to install and publish your node programs. It manages dependencies automatically and can be lot more useful. To install npm, use the following command:

curl | sh

To verify the installation, type the following command:

npm –v

This will print the version of npm installed. As of now, npm is supported only in Linux. We can make use of the npm to install node modules that we need. There are a bunch of node modules we will be using for our site

  • Express, a web framework
  • EJS, a template module
  • LessJS, a styling module

Lets me explain those modules in detail in my upcoming articles. Now, we can just install them by using the Node Package Manager(npm).

npm install express
npm install ejs
npm install less

Getting started

We need a simple page which should display “Coming Soon!” message. The URL for the site will be http://localhost:3000

First we need to run a webserver that will be reached at http://localhost:3000

I just created a folder named “Node_Shop” to place all my code for this project. Create a file server.js, where we can start a server with express and made it to listen on port 3000.

var express = require(‘express’); //This will include expressjs module that we have installed.
var server = express.createServer(); //creating express server
res.set(“hello world”);
server.listen(3000); //will make server listen at port 3000
console.log(“Running at http://localhost:3000”);

The server.js can be executed as:

node server.js

When we hit the url http://localhost:3000 in browser, we will end up with a hello world display!

Now, create a folder “views” under Node_Shop, where all our layout files get stored. After creating the folder, edit server.js and set the path for our template and specify the template engine(in this case, it’s ejs).

server.set(‘views’, __dirname + ‘/views’); //specifying template path
server.set(‘view engine’, ‘ejs’); //specifying template engine

Lets add our view files layout.ejs,and index.ejs. The ejs extention is nothing but a template page. There are many template modules in nodejs, like Jade, haml, etc., that can be used with express. The layout.ejs contain common layout that all pages have. A simple layout.ejs for our site is given below:

< head>
<title>Node Shop</title>
<%- body %>

In this, is where the content from other view pages will fit. To create a “coming soon” page as the default index page, edit the index.ejs and add the content given below:

<h1>Coming soon</h1>

Lets reset our get response to render the index.ejs by using the render function.


The template engine(ejs) will smartly render the index.ejs by combining both the index.ejs and layout.ejs as a single template. After running the server, in the browser, do a right click and view the source. We can see the combined template page.

<title>Node Shop</title>
<h1>Coming soon</h1>

In this article, I am not going to compile lessjs via express server. I am going to do it via normal include of file less.js on head.

Create another folder “static” under Node_Shop where we can store all the static files such as style sheets, images and javascript files. Place a “main.less” file with your desired style within the folder. Finally, we shall style the page with lessjs by including *.less files within the head tag.

server.use({ src: __dirname + ‘/static’ });
server.use(express.static(__dirname + ‘/static’));

and the fully rendered HTML page

<title>Node Shop</title>
<link rel=”stylesheet/less” href=”/static/main.less”>
<script src=”/js/less-1.1.3.min.js”></script>
<h1>Comming soon</h1>

Lessjs is something to add greatness to the styling. We can either include the *.less files within the head tag or we can compile the files via express server itself. I will explain lessjs briefly in the later part of this series.

The complete code can be found on my git-hub repository

Thanks and I hope this article might help some one new to nodejs

Introducing node.JS

In general node.JS is a bunch of sugar on top of very complex virtual machine (V8) written by Google (V8 is a JavaScript engine inside of chrome) .It is a beast, it’s a huge, high performance virtual machine written by smart people .That’s not what node is.Its a set of libraries written on top of V8 that uses its greatness to do networking.

Installing node.JS

Just follow these steps for Unix-like platform.

$ wget
$ tar xzvf node-latest.tar.gz
$ cd node-v0.4.7
$ ./configure
$ make
$ sudo make install.

This in general is enough. After all that you can write the node command in your terminal. However if there are some problems while compiling it, you may refer to Git and the Node community for more help. Don’t forget that V8 can work only on x86, x64 and ARM architectures.

Interactive node.JS shell

If everything worked, you should be able to invoke the interactive node.JS shell ,you type node without arguments you get this prompt just as python and you could type real JavaScript in that

$ node
> 2+4

Node has a rebuild and you could type functions

> function add(a,b) { return a + b }
> add(5,4)

Now let’s just write a simple hello world program on node, that’s where we all start. Obviously you open up your text editor, I use vim.

$vim hello_world.js

e.g. helloworld.js

setTimeout(function() {
}, 2000)

What this code does is…. let’s try, It prints hello and then waits for 2 seconds and then prints world. And then it exits.

Here what does setTimeout do?

SetTimeout has two arguments, First is call-back, and then a number of milli seconds you want it to wait.

Something that I need to say is,node should be somewhat familiar for JavaScript people.People who are familiar with browser side JavaScript should feel comfortable, not just for javascriptness but for the same pattern of coding.

The same helloworld.js can also be written in PHP as follows:-

e.g. helloworld.php


What is the difference between code in helloworld.js and helloworld.php?

In helloworld.js the hello happens immediately as it happened right through in helloworld.php we kind of stopped on the sleep.That is the fundamental difference.In node you never ever sleep, never have you fetched a URL from website and wait for it to come back.

You don’t have the ability to sleep on node and there is no possibility of halting executions, you can set Timeout to be ideal. In helloworld.js,it is not that CPU is spinning in busy loop,the CPU goes to zero and ideal and the OS unschedule’s it and schedules it back after timeout.Node is good at idling and it doesn’t sleep though.

Let’s improve on this example

What if i change setTimeout to setInterval?

e.g. helloworld2.js

setInterval(function() {
}, 2000)

It prints

>and so on ..

This brings a important property of node:-it exits when there is nothing left to do. It has a natural ability to reference count the callback or intervals, it knows there is something to do, so it doesn’t dropout or once all gets done, it dropsout automatically.

These are some basic concepts of node.JS.


Hybridfox – Elastic Load Balancer

Demo on Hybridfox with support for Amazon AWS Elastic Load Balancer

* Create Load balancer
* Deregister/Register Instances
* Enable/Disable Availability zones
* Configure Health check
* Enable/Disable Application stickiness and Load balancer Stickiness
* Delete Loadbalancer

Download Hybridfox with ELB Support :…

If any Issues post it on

Fast Powerful Web Applications With FUEL PHP5 Framework

Fuel is a simple, flexible, community driven PHP 5 web framework. It was born out of the frustrations people have with the current available frameworks and developed with support from a community of developers. Fuel is extremely portable, works on almost any server and prides itself on clean syntax.







Requirements: PHP 5.3+ & Apache / IIS / Nginx
License: MIT

Flexible Font Sizes with FitText

Imagine, how your design layout would appear to users on a nifty handheld device and to the person viewing it on a hi-res wide screen. With so many browsing options (iPad, Tablets, Mobile Phones, Wide Screen Monitors etc.), you can limit your design to pre-defined scales. It has to be fluid and scalable – not just the layout but the entire text in your website/web application so users can read contents easily. Challenging? Not actually, at least not with FitText.

FitText is a jQuery plugin to make font-sizes flexible. Use this plugin on your fluid or responsive layout to achieve scalable headlines that fill the width of a parent element. FitText is a perfect choice while developing cross-platform websites (scalable for all those nifty devices and displays).


License: Free to use

Game on with Firefox Addon

Firefox addon, it was pretty hard for me at the time when interviewer was given a choice for me either to take a session on 960gs or build a simple firefox addon. I have to go on with 960gs since i am familiar with css and i did it and got selected.

Then the game starts , i was asked to work on with firefox add-on and now there is no choice . It was not as big task because there are lot of supports online i fond easy to learn and work on it . Here is that tutorial

Firefox addon development requires only few basics on HTML and CSS , JavaScript but new markup language XUL (ZOOL) Xml User interface language should be hands on and its more powerful