View server.js
var http = require('http'), //http server
urlparser = require('url'), //url parser & builder
host = 'sandbox',
port = 1337;
http.createServer(function (req, res) {
var response = 'Hello, World!\n',
url = urlparser.parse(req.url, true).pathname;
switch (url) {
case('/hello'): //check for path, alternatively strip the front slash
response = 'World!\n';
View server.js
var http = require('http'), //http server
urlparser = require('url'), //url parser & builder
host = 'sandbox',
port = 1337;
http.createServer(function (req, res) {
var response = 'Hello, World!\n',
url = urlparser.parse(req.url, true).pathname;
switch (url) {
case('/hello'): //check for path, alternatively strip the front slash
response = 'World!\n';
View bashrc
command_exists () {
type "$1" &> /dev/null ;
}
# grep always with color and line number
alias grep='grep -n --color=always'
# git
if command_exists git ; then
alias gitco='git checkout'
View niginx.conf
server {
listen 80;
server_name helloworld;
location / {
rewrite ^/(.*)$ /$1 break;
proxy_set_header X-Real-IP $remote_addr;
View virtual-host
<VirtualHost *:80>
#webmaster's email address
ServerAdmin webmaster@localhost
ServerName my-virtual-host
DocumentRoot /var/www/my-virtual-host/document/root/
<Directory />
Options FollowSymLinks
#Comment following to enable oveririding through .htaccess, e.g. mod_rewrite
AllowOverride None
</Directory>
View flexi-list.html
<html>
<head>
<title>Flexi list</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<style>
#container{
padding: 3px;
color: #000;
font-family: sans-serif;
View find-non-secure-assest.js
var request = require('request');
var cheerio = require('cheerio');
var url = require('url');
var httpsurl = 'https://www.yahoo.com/';
var assets = {
img: {src:'src'},
link: {src:'href'},
script: {src:'src'}
};
View mobile-phones-india.js
var re = /[789]\d{9}$/;
re.test(9876543210);
re.test(8765432109);
re.test(7654321098);
re.test(6543210987);
re.test(5432109876);
View basic vimrc
syntax enable " enable syntax processing
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab
set expandtab " tabs are space
set number " show line numbers
set showcmd " show command in bottom bar
set cursorline " highlight current line
filetype indent on " load filetype-specific indent files
set wildmenu " visual autocomplete for command menu
set showmatch " highlight matching [{()}]
View timer-setimeout.html
<html>
<head>
<title>timer using setTimeout</title>
</head>
<body>
<script>
var timer = function () {
var i = 0;
return function () {
i = i + 1;