Skip to content

Instantly share code, notes, and snippets.

View BradGunnerSGT's full-sized avatar

Mark McCoy BradGunnerSGT

View GitHub Profile
@BradGunnerSGT
BradGunnerSGT / gen-passwd
Last active July 7, 2017 14:41
Create a long random password on the Linux command line
#!/bin/bash
TMPFILE=`/usr/bin/env mktemp`
dd count=1 bs=10M if=/dev/urandom of=$TMPFILE > /dev/null 2>&1 && md5sum $TMPFILE | awk '{print $1 }'
rm -f $TMPFILE
@BradGunnerSGT
BradGunnerSGT / gist:5ee3039ba28efba38dcb
Created August 28, 2014 22:04
list items in powershell older/newer than a certain date
# ls is an alias for get-childitem. get-childitem also take a -recurse and other
# useful params, used to include or exclude file types, etc...
ls file*.txt | Where-Object { $_.LastWriteTime -lt (get-date).AddDays(-3)}
@BradGunnerSGT
BradGunnerSGT / main-prod inventory
Last active January 11, 2020 22:57
Ansible instance-environment example:
In order to minimize slip-ups, we have a different inventory file for
each instance-environment pair, and each inventory uses a different
group name as well. Then there are group-vars files for each
instance-environment pair that set a variable so the proper playbooks
get run.
For example, here is how we have the project laid out:
site.yml
inventory/
main-prod
@BradGunnerSGT
BradGunnerSGT / script-runner.sh
Created May 1, 2014 21:37
script runner to run logstash conf files
#!/bin/bash
BASEDIR=`dirname $0`/..
SCRIPT=`basename $0 .sh`
cd $BASEDIR
CMD=lib/logstash/bin/logstash
if [ -f conf/$SCRIPT ]; then
exec $CMD -f conf/$SCRIPT
fi