Skip to content

Instantly share code, notes, and snippets.

View abhiomkar's full-sized avatar

Abhinay Omkar abhiomkar

View GitHub Profile
@abhiomkar
abhiomkar / query_param_parse.js
Created July 7, 2011 17:43
URL Query Parameter Parser in Javascript
// Author: Abhinay Omkar
// Input: "red=123&green=456&blue=789"
// Output: [{key: 'red', value: 123}, {key: 'green', value: 456}, ...
var dict = [], i = 0; qparams.split('&').map(function(s) { dict[i] = {}; kv = s.split('='); dict[i].key = kv[0]; dict[i].value = kv[1]; i = i + 1; })
@abhiomkar
abhiomkar / url_regex
Created July 11, 2011 14:39
Regex for URL Match
((http://)?|https://|ftp://|rtsp://|mms://|shttp://|tv://)([-\w\.]+)+(:\d+)?(/[^\s]+)?
@abhiomkar
abhiomkar / wget_urls.sh
Created August 29, 2011 11:43
Recursively Fetch all the possible URLs
wget -R.jpg,.jpeg,.gif,.png,.css,.js -c -r http://www.example.com/ -o urllog.txt
grep ' http' urllog.txt | awk '{print $3}'
mkdir heroku-django
cd heroku-django
virtualenv --no-site-packages .
source bin/activate
bin/pip install django
@abhiomkar
abhiomkar / cookies.js
Created November 14, 2011 10:02
JavaScript cookies - cookies.js
/**
* Read the JavaScript cookies tutorial at:
* http://www.netspade.com/articles/javascript/cookies.xml
*/
/**
* Sets a Cookie with the given name and value.
*
* name Name of the cookie
* value Value of the cookie
@abhiomkar
abhiomkar / sqlite_quick_ref.sql
Created January 13, 2012 11:52
SQLite Queries - Quick Reference
.
@abhiomkar
abhiomkar / is_prime.py
Created February 18, 2012 10:03
is Prime Number
def is_prime(x):
""" Return True if 'x' is prime number, otherwise, return False """
# positive numbers
x = abs(int(x))
# 0, 1 are not prime
if x < 2:
return False
@abhiomkar
abhiomkar / convert.sh
Created March 29, 2012 08:08
Imagemagick Convert Quick Commands
# Resize Image
find . -maxdepth 1 -iname '*jpg' -exec convert -resize 800x500\> -quality 85 {} low/{} \;
@abhiomkar
abhiomkar / net_dreceived.sh
Created June 26, 2012 13:40
One Liner to get Network Data Received
# One Liner to get Network Data Received in GB
echo "`netstat -bi | grep -v Ibytes | grep -v "-" | grep "^en" | awk '{ x += $7 } END { print x / (1024 * 1024 * 1024) }'` + `netstat -bi | grep -v Ibytes | grep -v "-" | grep "^lo" | awk '{ x += $6 } END { print x / (1024 * 1024 * 1024) }'`" | bc
@abhiomkar
abhiomkar / httperf_ngnix_vs_cherokee.txt
Created July 25, 2012 13:37
Website Benchmark: Ngnix vs Cherokee using httperf
# Benchmark - ngnix vs Cherokee
# Django + Cherokee
127.0.0.1 ➜ ~ httperf --client=0/1 --server=abhiomkar.in --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=10 --num-calls=10
httperf --client=0/1 --server=abhiomkar.in --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=10 --num-calls=10
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
Total: connections 10 requests 100 replies 100 test-duration 70.575 s