Skip to content

Instantly share code, notes, and snippets.

View gordonmurray's full-sized avatar
🍺

Gordon Murray gordonmurray

🍺
View GitHub Profile
#!/usr/bin/env bash
# white list all public IPs from an AWS region in to a security group
security_group="sg-xxxxxx"
region="eu-west-1"
port="3306"
# list the public IPs from the instances in region
public_ips=`aws ec2 describe-instances --query "Reservations[*].Instances[*].PublicIpAddress" --output=text --region=${region} | xargs`
@gordonmurray
gordonmurray / split.sh
Created April 16, 2017 18:29
A small script to take a larger text based file and break it down to several smaller files
#!/usr/bin/env bash
# A small script to take a larger text based file and break it down to several smaller files
# of 500 lines each for easier processing, keeping the headings at the top of each file
FILENAME=${1}
if [ -z ${FILENAME} ]; then
echo "Please provide a filename, for example: bash split.sh /path/to/data.csv";
else
@gordonmurray
gordonmurray / handy_aws_cli_commands.txt
Last active April 15, 2016 11:14
Handy CLI Commands
# Sync 2 S3 buckets
aws s3 sync s3://{source} s3://{destination}
# Determine size of an S3 bucket
aws s3api list-objects --bucket {s3_bucket_name} --output json --query "[sum(Contents[].Size), length(Contents[])]"
# dump large mysql DB > tested on 200gb DBs
mysqldump -h {HOST} -u {USER} -p {TABLE} --single-transaction --default-character-set=utf8 --quick --extended-insert > {FILENAME}.sql