Category Archives: Code Snippets

Web Scraping through YQL and nodejs

Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites.

I used a node module call YQL(Yahoo Query Language) to achieve it. You may have many other ways to do the same.

1. npm install yql (this will download yql module for your node project)

2. app.js file.

3. node app.js

4. hit your url : http://localhost:3000/


Create your first Responsive Webpage

Responsive webpages are those which accommodate the screen size of various multimedia devices, like Tablet, Phone and Screen etc, copy this code and name it what you like it, like index.html and then try reducing the width of browser.

The interesting part here is


Creating Image Slider with HTML and CSS without any plugin

The main idea behind images slide is sliding the set of images through a visible container.
I had used Jquery for working with DOM.

Create you HTML first, say index.html

Now use the css file, say style.css for this particular example.

and now the main.js file

Extra files required are Image files, reset.css and jquery.js.
I hope you enjoy this example.


Public and Private

Here is the code for creating a object definition(class) which maintains the public and private scope of variable.


Concept of namespace

How many time you have seen this kind of line in your code.

var app = app || {};

This is the common way to create a namespace. What does it do. It search for the app object, if it exists return it and if it doesn’t returns empty object.

Let us understand this with example




So no matter how many javascript files you create, you just want to include all your objects in app namespace, do it like as it is done in model.js

but make sure you write this line as your first line of code in your javascript file.

var app = app || {};