Skip to content

Instantly share code, notes, and snippets.

View abhiomkar's full-sized avatar

Abhinay Omkar abhiomkar

View GitHub Profile
@abhiomkar
abhiomkar / window_location_param.js
Created July 16, 2013 07:12
read query parameter values from current URL in JavaScript
window.location.param = function(key) {
var value;
window.location.search.slice(1).split('&').map(function(e) {
e = decodeURIComponent(e);
if (e.indexOf(key + '=') === 0) {
value = e.slice(key.length + 1);
return false;
}
});
return value;
@abhiomkar
abhiomkar / play-when-coding.txt
Created July 1, 2013 08:08
Programmer's Background Score
World War Z - Isolated System by Muse
Inception - Time by Hans Zimmer
Man of Steel - Ideal of Hope by Hans Zimmer
X-Men: First Class - First Class by Henry Jackman
Bourne Ultimatum - Extreme Ways by Mobi
Tron: Legacy - The Son of Flynn by Daft Punk
Tron: Legacy - Flynn Lives by Daft Punk
@abhiomkar
abhiomkar / most_used_cmds.sh
Created May 22, 2013 10:59
Most used commands in ZSH
# Top 20 most used commands in your ZSH shell
cat ~/.zsh_history | cut -d ';' -f 2- | awk {'print $1'} | sort | uniq -c | sort -r | head -20
@abhiomkar
abhiomkar / zip-tar-cheatsheet.sh
Last active January 2, 2018 23:35
zip tar cheatsheet
# Compress file
zip compressed.zip file_name.txt
# Compress Folder
zip -r compressed.zip folder_name/
# Uncompress zipped file to current directory
unzip compressed.zip
# Uncompress zipped to current directory to specific location
@abhiomkar
abhiomkar / thehindu.py
Created April 30, 2013 09:52
The Hindu Quick Scraper
#!/usr/bin/python
# Abhinay Omkar
from urllib2 import urlopen
import simplejson as json
from lxml import etree
root = etree.fromstring(urlopen("http://www.thehindu.com/?service=rss").read())
items = root[0].findall('item')
output = []
@abhiomkar
abhiomkar / getopt.py
Created August 30, 2012 10:50
Python Script Input
def usage():
""" Script Usage """
print "Usage: python main.py OPTIONS INPUT_FILE [OUTPUT_FILE] "
print "OPTIONS:"
print " --help, --usage, -h: Show this help message"
print " --meta=, -m: Meta File"
print "ARGS:"
print " INPUT_FILE: input file name or path"
print " OUTPUT_FILE: output file path"
print ""
@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
@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 / 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 / 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