Skip to content

Instantly share code, notes, and snippets.

View alexclifford's full-sized avatar

Alex Clifford alexclifford

  • Melbourne, Australia
View GitHub Profile
@alexclifford
alexclifford / git_reset_hard.sh
Created May 28, 2015 03:47
If you really need to reset your local git repo to what is upstream to remove any unwanted changes
git reset origin/<branch> --hard
@alexclifford
alexclifford / get_all_private_aws_ip_addresses.sh
Created March 12, 2015 23:24
Get all private IP addresses currently assigned
aws ec2 describe-instances --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4
# or
aws ec2 describe-instances --query 'Reservations[*].Instances[*]' --output text | less
@alexclifford
alexclifford / get_ssl_arn_details.sh
Created March 12, 2015 23:23
Get the ARN details for an SSL certificate created for an ELB
aws iam get-server-certificate --server-certificate-name wildcard.example.com
@alexclifford
alexclifford / apache_process_size.sh
Created February 10, 2015 05:13
List average Apache process size
ps -ylC httpd --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
@alexclifford
alexclifford / check_public_private_key_pair.sh
Created November 14, 2014 05:40
Compare checksum of pubic and private keys for matching modulus
openssl x509 -noout -modulus -in /etc/pki/tls/certs/www.example.com.crt | openssl md5
openssl rsa -noout -modulus -in /etc/pki/tls/private/www.example.com.key | openssl md5
@alexclifford
alexclifford / most_used_commands.sh
Created September 24, 2014 22:38
Read history and count most used commands
history | awk '{CMD[$4]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
@alexclifford
alexclifford / sendmail_test.sh
Created September 2, 2014 04:05
sendmail test
sendmail -v user@example.com < test.txt
@alexclifford
alexclifford / change_default_editor.sh
Last active August 29, 2015 14:05
Change default editor to vim in Ubuntu
sudo update-alternatives --set editor /usr/bin/vim.basic
@alexclifford
alexclifford / postgres_debug.sh
Created August 26, 2014 03:43
Start postgresql on Ubuntu 12.04 with debugging enabled
sudo -u postgres -H /usr/lib/postgresql/9.1/bin/postgres -d 3 -D /var/lib/postgresql/9.1/main/ -c config_file=/etc/postgresql/9.1/main/postgresql.conf
@alexclifford
alexclifford / get_mysql_db_sizes.sql
Last active August 29, 2015 14:05
MySQL query to get all database sizes in MB
SELECT table_schema "Database Name",
sum( data_length + index_length ) / 1024 / 1024 "Database Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema;