Tuesday, May 10, 2016

Tutorials: NodeJS and Express (Tutorial 1)

Tutorials: NodeJS and Express

While learning about Express  and and how to use, here is my small effort to document my learning in tutorial form. Express  has become an integral part in web applications developed in NodeJS.

Tutorial 1: NodeJS: An Asynchronous World
Tutorial 2: Express: Middleware or more...
Tutorial 3: Understanding Routing in Express
Tutorial 4: Develop a Static File Server
Tutorial 5: Using HTTPS with Express
Tutorial 6: Develop an JSON API server
Tutorial 7: Use Templates and Views with Express
Tutorial 8: Integrating MongoDB
Tutorial 9: Testing Express Applications
Tutorial 10: Securing Express

Tutorial 1: NodeJS: An Asynchronous World

For so many years, Javascript has been a defacto standard to do front end scripting in browsers. In 2009, another incarnation of JS (V8 JS engine from Chrome) as node.js came out which made it server side scripting language also. NodeJS came up with a bouqet of many features like:
  • Its execution is fast (V8 JS engine being compined in C++)
  • Promotes asynchronous coding style
  • Same coding paradigm for front and back end.
Its event-driven, non-blocking I/O model make it popular among developers community. NodeJS has assemblage of libraries and frameworks helping developer community. Express JS or Express is also one of the framework available for NodeJS helps in developing web based applications.

Installing NodeJS

The simplest way is go to NodeJS website and click on the installer link. The site also provides other download options (binary download or installers for Mac and Linux flavours). For Windows make sure your machine has latest OS updates otherwise windows installer may have trouble in installing.

Tutorials: NodeJS and Express (Tutorial 1)

For Linux, nodeJS package manager (eg apt-get) is also available. The installer also installs node package manager (npm). Once installed you can check node version and npm version by typing node -v and npm -v respectively at the command prompt or shell.

First NodeJS Program

You can try your first the most famous "Hello World" program in nodeJS. Type the following script in notepad or any text editor and save the file as helloworld.js

Program 1: helloworld.js

console.log("Hello World");

To run this code type node helloworld.js at the shell prompt. If everything works well, you would see the output of the program similar to what is shown in the figure.
Tutorials: NodeJS and Express (Tutorial 1) - Hello World

console.log() api is part of console built-in module in nodeJS. There are many inbuilt modules (or libraries) and globals defined in nodeJS. Apart from using builtin modules, you can use external modules.

Node Package Manager or npm helps you installing or managing node modules. The site www.npmjs.com lists the most starred packages used among NodeJS community.

Let us try to install and use colors module. The colors module gives color style to your console output. Type npm install colors will download colors module from npm repository and installs it. You can see a directory named 'node_modules' gets created where npm installs any package.

Tutorials: NodeJS and Express (Tutorial 1) - install color module
npm install color

See the following snippet showing how to use 'colors' node module:

Program 2: ex2.js

var colors = require("colors");
console.log('This is red'.red);
console.log('This looks green'.green);
console.log('this rainbow text'.rainbow);

The statement require("colors")in the above snippet will load the "colors" exported JavaScript API and returns the JS object. Once colors Javascript Object is loaded, you can call its exported functions and members in your program code. The output of the above snippet will look like the Figure

Tutorials: NodeJS and Express (Tutorial 1) - using color

Asynchronous Programming Approach

Friday, April 8, 2016

Six Sites Provide You Legal Free Images

Six Sites Provide You Legal Free Images

No doubt to enhance your presentation or blog post, images play a crucial role. Following are few sources that provide legally free good quality images.


Pixabay.com - Cat

Pixabay has collection of more than 6 million images which are available under creative commons CC0. If you wish you can modify, distribute and use them royalty free even for commercial purposes.


Six Sites Provide You Legal Free Images - MorgueFile.com

Morguefile has a stock of high resoulution photos which are available completely free. Do read about "Why this site is called MorgueFile?". The site provides categories to serach images for your needs.

Tuesday, February 16, 2016

How to control caching of your web server to avoid file suits?

How to control caching of your web server 

to avoid file suits?

How to control caching of your web server to avoid file suits?

While working for a world’s top most product company, one day a Product Manager working there approached to me. He had a legal letter served by one of our client. The legal notice says that our company has to bear a cost of  25,000 Australian dollars as bandwidth cost incurred to our client. Interestingly the legal notice did have technical explanation for excessive bandwidth consumption. The client used 100+ licenses of my employer’s products. Each installed product has an updater client to download updates. The client uses squid like cache server to optimise bandwidth.  Unfortunately update server switched off caching flag for a 1 GB sized update, due to which the cache server starts downloading for every time it gets a proxy request from the updater client on different machines. Anyway the matter get sorted by enabling the flags and offering extensions to the license products. But it was a great learning and caching procedures were added in product manager’s and testing team check list for future updates releases.    

Caching control helps in many ways such as

Monday, December 28, 2015

Start Your Online Book Keeping Services

Start Your Online Book Keeping Services

Start Your Online Book Keeping Services

Book Keeping and accountant services are something required by every business operation. A good book keeper can earn between 25,000 to 2 Lacs per month. The objective is to show your potential customer how you can help them in financial matters. Better managed accounting books help your customer in managing their financial matters. Most of the book keepers work through networking. Generally they work co-ordinate with Chartered Accountants who refer potential customers to book keepers. Unfortunately there is cut throat competition and you need to show that your book keeping services are much better. Making business online can help you offer better services and bring more customers.

How Can I become Certified Book keeper?

There are institutions like IIFCA , polytechnices like Delhi Government Polytechnic  offer Computer Accounting Certificate courses. They teach you computer basics, accounting basics, taxation, VAT and accounting software. For domestic clients learn TALLY or BUSY accounting software. For international clients, learn about Quicken or Quick books.

What do I need to start basic book keeping services?

  1. A computer or a laptop and licensed copy of TALLY or BUSY Accounting Software, 
  2. A flat bed scanner and small laser printer. 
  3. Office area, furniture, calculator etc. 
  4. Telephone and internet connection (email account).

What services can I offer from my Website?

Saturday, October 10, 2015

How to Start Your Astrology Portal?

How to Start Your Astrology Portal?

Ganesha - Lord of Beginnings

Prediction business has existed since Satyuga (for thousands of years). Hardly there existed any civilization in past which did not have oracles or astrologers. In this modern world when we have gone hi-tec, astrology has adapted the latest technology and is flourishing. Many consider (including me) it a fool’s science. In India, matrimonial alliances are still made after consulting astrologers. Astrologers are considered here as spiritual gurus and they mint money for the predictions made by them. If these predictions go true, it’s Balle-Balle (बल्ले-बल्ले) for the them. If predictions go wrong (generally it happens), who cares! Nobody approaches to the astrologer complaining against false prediction. Ironically, if a MBBS doctor fails to treat his patient, often the patient's relatives will beat him. Those believe in astrology of mention that Indian astrology is one of the important auxiliary of Vedantic Literature.

Anyway my purpose of the post is quite different. A person, a friend of my relative (let us call him Sanyam), approached me.  He wanted to start his website on Vedic Astrology and asked me guide him. Sanyam used to be a good salesman in a Nokia showroom at Connaught Place in Delhi. He sold Nokia phones for a good number of years and never realized that one day Nokia would run out of business and he would be jobless. He tried to approach other showrooms selling smartphones of other brands but couldn’t get a decent opportunity. Being in 40s he faced mid-life crisis, he failed to compete against much younger salesmen who knew Android and iOS lingos very well. Luckily his hobby helped him survive. Sanyam joined a part time course on Vedic Astrology at Bhartiya Vidya Bhawan when he was working at Nokia showroom. This course helped his salesmanship connect people, who used to visit him for astrological advice and might become his customers in future. During his bad phase, he planned to pursue his career as an astrologer and soon it started bearing fruits. He started appearing in TV shows and built up his brand. Being a salesman he understands the power of Internet or Social Media. He wants to offer his services online.

Here are the steps you would like to start as online astrology services:

Thursday, August 20, 2015

CSS Tricks: Giving a Blue Jeans Stitched Appearance

 Giving a Blue Jeans Stitched Appearance

CSS Tricks: Giving a Blue Jeans Stitched Appearance

Playing with CSS and CSS3 has always been fun playing. I am still learning the various aspects of style sheets and my learning has been part of the problem solving. While reviewing fashion related web content, one of the web designer wants to give a Blue Jeans stitched appearance to a div panel. Here is a simple style that evolved quickly:

  .BlueJeans {
    border: 2px dashed #fff;
    padding: 25px;
    background: #4e6590;
    color: #fff;
    margin: 10px;
    box-shadow: 0 0 0 4px #4e6590, 2px 1px 6px 4px RGB(78, 101, 144);
    border-radius: 10px;

Friday, August 14, 2015

Want To Send Self Destruct Mails... use DMail

Want To Send Self Destruct Mails... use DMail 

DMail Chrome Plugin to Self Destruct Message

Occasionally you want to send a mail and wish it should vanish within ten minutes or hours. Most common scenario is that you share some sensitive information with your friend and do not want that the mail should persist forever in your friend’s InBox. For GMail users the chrome plugin ‘DMail’ gives the solution.

Still available as free beta release, once you install the Chrome Extension it will allow you send self-destructing encrypted emails. You can set the self-destruct timer to an hour,a day or a week.

Other important feature it allows you to encrypt your messages and revoke access at your command. Once revoked the recipient would see the garbled message.