Skip to content

Instantly share code, notes, and snippets.

Get Our images
aws ec2 describe-images --region ap-southeast-2 --owners 627242648017 | grep SnapshotId | awk -F'[":]' '{print $5}' | sort | uniq > snaps_in_use_by_images
Get Our volumes
aws ec2 describe-volumes | awk -F'[":]' /snap-/'{print $5}' | sort | uniq > snaps_in_use_by_ec2_volumes
All Snapshot IDs
aws ec2 describe-snapshots --owner-ids 627242648017 | grep SnapshotId | awk -F'[":]' '{print $5}' | sort | uniq > all_snaps
cat snaps_in_use_by_ec2_volumes snaps_in_use_by_images |sort | uniq > all_snaps_in_use
comm -23 all_snaps all_snaps_in_use > snaps_not_inuse
@BigAl
BigAl / gist:3c376b680c64c3b8fad042808056bad9
Created September 15, 2016 00:29
List and Tag instances in an VPC
VPCID=vpc-f4b2ba96
aws ec2 describe-instances --filters Name=vpc-id,Values=${VPCID} --query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`environment`].Value|[0],State.Name,PrivateIpAddress,PublicIpAddress]' --output text | column -t
aws ec2 describe-instances --filters Name=vpc-id,Values=${VPCID} --query 'Reservations[*].Instances[*].[InstanceId]' --output text > instances
aws ec2 create-tags --resources `echo $(cat instances)` --tags Key=environment,Value=test
rm instances
OSX 10.11.6 packages
curl http://osxapps.itunes.apple.com/apple-assets-us-std-000001/Purple20/v4/dc/94/05/dc940501-f06f-2a91-555e-3dc272653af5/izt4803713449411067066.pkg
curl http://osxapps.itunes.apple.com/apple-assets-us-std-000001/Purple60/v4/45/df/86/45df865d-d24d-01d6-2b2c-c003317293ac/signed.dcr.6112397842917719871.pfpkg
Install command line MAS tool becuase I had problems with the GUI
brew install mas
cd Desktop
mkdir osxapps_local
cd osxapps_local
Put the pkg file here
@BigAl
BigAl / Find deleted files
Created June 30, 2016 10:45
Handy one liners
Checking for Deleted Files Held Open in UFS File Systems
To 'find' the particular offending process(es) with open but deleted files you can use
find /proc/*/fd -type f -links 0 -exec ls -l {} \;
which looks for files with zero links, i.e. that have been deleted but a running process still has the file open.
Using the PID from the /proc/<PID>/fd/xxxxx names returned you can determine if the process can be restarted without a server reboot.
sudo xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install virtualbox
brew install packer terraform libdvdcss awscli bash-completion
brew install iterm2
brew install visual-studio-code vlc firefox
brew install google-drive-file-stream google-chrome
brew cask install --appdir="/Applications" jbidwatcher
--
:backends:
- yaml
:hierarchy:
- defaults
- "%{clientcert}"
- "%{environment}"
- global
:yaml:
@BigAl
BigAl / disk_attach.sh
Last active September 23, 2015 23:38
Create new lvm , mount and transfer data
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
fdisk /dev/sdb
pvcreate /dev/sdb1
vgcreate vgsyslog /dev/sdb1
lvcreate -n lvsyslog-data -l 100%FREE vgsyslog
@BigAl
BigAl / gist:53f500babf1d6d391dd5
Last active August 29, 2015 14:24
Mac brew packer vargrant vb install
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew tap caskroom/cask
$ brew install caskroom/cask/brew-cask
$ brew cask install virtualbox
$ brew cask install vagrant
$ brew cask install packer
@BigAl
BigAl / update_pattterndb.sh
Created June 28, 2015 11:27
Update patterndb
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sysconfdir=@sysconfdir@
localstatedir=@localstatedir@
${bindir}/pdbtool merge -D ${sysconfdir}/patterndb.d -p ${localstatedir}/patterndb.xml
@BigAl
BigAl / gist:45111c0e1f02f64d4911
Created November 25, 2014 20:44
sensuapp vagrant
git clone https://github.com/bsnape/vagrant-sensu.git sensu
git clone https://github.com/sensu/sensu-puppet.git sensu
git clone https://github.com/puppetlabs/puppetlabs-rabbitmq.git rabbitmq
git clone https://github.com/thomasvandoren/puppet-redis.git redis
git clone https://github.com/garethr/garethr-erlang.git erlang
git clone https://github.com/puppetlabs/puppetlabs-stdlib.git stdlib
git clone https://github.com/stahnma/puppet-module-epel.git epel
git clone https://github.com/maestrodev/puppet-wget.git wget
git clone https://github.com/puppetlabs/puppetlabs-gcc.git gcc