This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((http://)?|https://|ftp://|rtsp://|mms://|shttp://|tv://)([-\w\.]+)+(:\d+)?(/[^\s]+)? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -R.jpg,.jpeg,.gif,.png,.css,.js -c -r http://www.example.com/ -o urllog.txt | |
grep ' http' urllog.txt | awk '{print $3}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir heroku-django | |
cd heroku-django | |
virtualenv --no-site-packages . | |
source bin/activate | |
bin/pip install django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resize Image | |
find . -maxdepth 1 -iname '*jpg' -exec convert -resize 800x500\> -quality 85 {} low/{} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |