Skip to content

Instantly share code, notes, and snippets.

Avatar

Anubhav Sinha anubhavsinha

View GitHub Profile
View paramiko_example.py
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 Aug 29, 2015
install just the mongodb client: mongo
View mongodb-client-install.sh
# 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
View gist:abee1a8d3e0807580204
export AWS_ACCESS_KEY_ID=your_access_key_id
export AWS_SECRET_ACCESS_KEY=your_secret_access_key
View chromedriver.sh
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 Aug 29, 2015
Adding an alias to save us from typing long git clone commands.
View git_clone.sh
#########################################################
# 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 Jul 31, 2014
wraps around the words
View wrapword.css
.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 Aug 8, 2014
remove bad file names - names with white space in them.
View detox.sh
find . -depth -name '* *' \
| while IFS= read -r f ; do mv -i "$f" "$(dirname "$f")/$(basename "$f"|tr ' ' _)" ; done
@anubhavsinha
anubhavsinha / git_deploy_docker.py
Last active Aug 29, 2015
A flask script to listen for POST hooks for the production branch.
View git_deploy_docker.py
###################################################################
# TODO:
# add logging and ses email alerts for deployment failed and passed.
# Also pipe in the log file to logstash etc.
# Also write test cases
# Make all of the deployment task async and return to the POST request immediately.
# Already uses auto-reload - flask debug=True provides auto-reload out of t
# You will need to
# cd ~
@anubhavsinha
anubhavsinha / docker_remove_all.sh
Created Aug 14, 2014
alias for stop and rm all docker containers
View docker_remove_all.sh
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
View Dockerfile
# docker build -t="rails" .
FROM ubuntu:12.04
RUN apt-get update
## MYSQL
RUN apt-get install -y -q mysql-client libmysqlclient-dev
## RUBY