Skip to content

Instantly share code, notes, and snippets.

@mwinters0
mwinters0 / pr_clean.sh
Created May 1, 2017 20:19
Pull master and clean dead local branches after a PR
#!/bin/bash
echo "Switching to master and pulling ..."
git checkout master
if [[ ! $? -eq 0 ]]; then
echo
echo Unable to checkout master, aborting.
exit
fi
git pull
@mwinters0
mwinters0 / ec2_get_tag.sh
Created February 14, 2017 19:20
Bash to get Name tag on EC2 instances
# Gets any tag value, default 'Name'. Assumes that `aws` CLI is
# installed, and the IAM role has Describe-Tags permissions.
TAG=Name
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
TAG_VALUE=$(aws ec2 describe-tags --filters "Name=resource-id,Values=$INSTANCE_ID" "Name=key,Values=$TAG" --region=$REGION --output=text | cut -f5)
#!/bin/bash
# from http://stackoverflow.com/questions/3971822/yaml-syntax-validator
ruby -e "require 'yaml';puts YAML.load_file('$1')"
@mwinters0
mwinters0 / gist:c70d195c5c5670d1625f
Created November 10, 2014 19:43
Shell one-liner to parse apache access logs and extract a unique URL list with hit count, querystring excluded.
cat access.log | awk -F\" '{print $2}' | awk '{print $2}' | sed '/^$/d' | sed 's/\?.*//g' | sort | uniq -c | sort -rn > url_hits.txt
@mwinters0
mwinters0 / vshef.sh
Created October 5, 2012 18:37
Run shef in vagrant
shef -s -c /tmp/vagrant-chef-1/solo.rb -j /tmp/vagrant-chef-1/dna.json
@mwinters0
mwinters0 / ftpmon.php
Created August 21, 2012 22:17
QnD php cli ftp spy
<?php
//Super Q&D. Monitors a single FTP directory for new files.
//Modify the vars below and run as 'php ftpmon.php'.
//Notification is via growlnotify, which requires purchase of growl.
$host = "ftp.host.com";
$user = "ftpuser";
$pass = "secret";