Skip to content

Instantly share code, notes, and snippets.

View anubhavsinha's full-sized avatar

Anubhav Sinha anubhavsinha

View GitHub Profile
@anubhavsinha
anubhavsinha / remove_dupes.py
Created September 1, 2012 16:27
list vs set: Python
#function to remove duplicates from a Python list
#using append/add is O(1) for both list and set
#but using in/not in/remove in list is O(n) vs O(1) in case of set
def remove_dupes(some_list):
seen = set()
items = []
for each in some_list:
if each not in seen:
seen.add(each)
@anubhavsinha
anubhavsinha / cv-resume.md
Created September 16, 2012 22:40
A write-up of things I have done. This may be considered as my cv/resume for hiring/consultancy purpose.

#Anubhav Sinha ####Bangalore, India

@anubhavsinha
anubhavsinha / excel2mysql.py
Created September 29, 2012 00:29
simple excel to mysql in python
# following Python packages needs to be installed
# xlrd, xlsxrd, unidecode, MySQLdb
import xlrd
import xlsxrd
import MySQLdb as mdb
import re
import unidecode
import paramiko
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting"
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k )
print "connected"
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ]
for command in commands:
print "Executing {}".format( command )
@anubhavsinha
anubhavsinha / mongodb-client-install.sh
Last active August 29, 2015 14:03
install just the mongodb client: mongo
# useful when you want to debug a docker container running the mongodb server
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org-shell mongodb-org-tools
@anubhavsinha
anubhavsinha / gist:abee1a8d3e0807580204
Last active August 29, 2015 14:03
aws-cli-config.sh
export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
sudo apt-get install unzip;
wget -O /tmp/chromedriver.zip http://chromedriver.googlecode.com/files/chromedriver_linux64_19.0.1068.0.zip && sudo unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/;
@anubhavsinha
anubhavsinha / git_clone.sh
Last active August 29, 2015 14:04
Adding an alias to save us from typing long git clone commands.
#########################################################
# Save this file to your /usr/local/bin (Ubuntu 14.04LTS)
# then run chmod 755 git_clone.sh
# add the following line to your .bash_aliases file.
# alias clone='/usr/local/bin/git_clone.sh'
# Now you can use it like
# as@xps:~/works$ clone awsma-server
# instead of typing the long version
# git clone git@github.com:anubhavsinha/awsma-server.git
# You should also add your ssh key to github.
@anubhavsinha
anubhavsinha / wrapword.css
Created July 31, 2014 20:50
wraps around the words
.wrapword{
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* css-3 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
@anubhavsinha
anubhavsinha / detox.sh
Created August 8, 2014 19:14
remove bad file names - names with white space in them.
find . -depth -name '* *' \
| while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done