#Anubhav Sinha ####Bangalore, India
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
#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) |
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
# following Python packages needs to be installed | |
# xlrd, xlsxrd, unidecode, MySQLdb | |
import xlrd | |
import xlsxrd | |
import MySQLdb as mdb | |
import re | |
import unidecode |
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
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 ) |
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
# 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 |
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
export AWS_ACCESS_KEY_ID=your_access_key_id | |
export AWS_SECRET_ACCESS_KEY=your_secret_access_key |
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
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/; |
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
######################################################### | |
# 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. |
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
.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; | |
} |
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
find . -depth -name '* *' \ | |
| while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done |
OlderNewer