Skip to content

Instantly share code, notes, and snippets.

View acsrujan's full-sized avatar
🏠

Srujan acsrujan

🏠
View GitHub Profile
@acsrujan
acsrujan / scheduled_ami.sh
Last active March 30, 2016 08:35
Schedule AMI creation and delete 3 days older images.
#!/bin/bash
#---The following is to create AMI of server daily---#
echo "instance-`date +%d%b%y`" > /tmp/ami-name.txt
INSTANCE_ID=$1 #Pass instance id as arguement or change hardcode it here.
aws ec2 create-image --instance-id $INSTANCE_ID --name "`cat /tmp/ami-name.txt`" --description "This is daily auto AMI by Cron" --no-reboot | grep -i ami | awk '{print $2}' > /tmp/ami-id.txt
#---The following is to remove AMIs older than 3 days---#
echo "instance-`date +%d%b%y --date '3 days ago'`" > /tmp/ami-delete.txt
aws ec2 describe-images --filters "Name=name,Values=`cat /tmp/ami-delete.txt`" | grep -i imageid | awk '{ print $2 }' > /tmp/image-id.txt
@acsrujan
acsrujan / git_find_big.sh
Created January 21, 2016 07:42
Bash script to find large files in your github.
#!/bin/bash
#set -x
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
IFS=$'\n';
# list all objects including their size, sort by size, take top 10
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`
echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
@acsrujan
acsrujan / install_postgres.sh
Last active December 10, 2015 10:05
Installs postgres 9.3
sudo touch /etc/apt/sources.list.d/pgdg.list
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-9.3 libpq-dev postgresql-contrib-9.3
sudo apt-get autoremove
sudo pg_dropcluster --stop 9.3 main
sudo pg_createcluster --start -e UTF-8 9.3 main
@acsrujan
acsrujan / acsrujan_resume.py
Last active November 27, 2015 07:08
Resume of Srujan Akumarthi (Myself). Python program readable by layman, and also, executable through command line.
'''
If you're viewing it from pdf, original program can be found at: https://gist.github.com/acsrujan/15e211400258871f538a
To run download the file as it is.
Make sure you've python installed. (run python --version in terminal)
python filename.py -h will show the help line. (Make sure to change the file name.)
python filename.py -c will show contacts. and so on.
'''