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 / 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 / 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 / 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 / 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 / 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 / s3_set_object_public.sh
Created July 24, 2015 01:59
Make S3 object public and private via s3cmd command line
s3cmd setacl s3://bucket/path/to/file --acl-public
s3cmd info s3://bucket/path/to/file
s3cmd setacl s3://bucket/path/to/file --acl-private
@alexclifford
alexclifford / adhoc_php_debugging.php
Created August 6, 2015 01:14
Some (poor) adhoc PHP debug logging code
file_put_contents('/tmp/foo/bar.txt', print_r(, true), FILE_APPEND);
file_put_contents('/tmp/foo/bar.txt', "5:\n\n", FILE_APPEND);
@alexclifford
alexclifford / delete_graylog_index.sh
Created May 2, 2016 00:28
Delete a Graylog Elasticsearch index
curl -XDELETE 'http://localhost:9200/graylog2_0/'
@alexclifford
alexclifford / vim_auto_indent.instructions
Created May 2, 2016 00:29
Enable automatic HTML indenting in VIM
:filetype indent on
:set filetype=html
:set smartindent
gg=G
@alexclifford
alexclifford / cinnamon-dconf-backup-and-restore.sh
Created September 15, 2016 07:53
Backup Cinnamon settings with dconf
# Backup
dconf dump /org/cinnamon/ > cinnamon-dconf-settings.txt
# Reset Cinnamon
dconf reset -f /org/cinnamon/
# Restore
dconf load /org/cinnamon/ < cinnamon-dconf-settings.txt