Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am djk29a on github.
  • I am djk29a (https://keybase.io/djk29a) on keybase.
  • I have a public key ASCQLM9VXCy9BpHeqxj2zEb_VtmPOBbFS3lMYT-D1wgQdwo

To claim this, I am signing this object:

@djk29a
djk29a / gittricks.sh
Last active March 3, 2017 17:39
git tricks
# get all files modified in a branch
git diff --name-only <notMainDev> $(git merge-base <notMainDev> <mainDev>)
# shorter alternative for git versions... ?+
git whatchanged --name-only --pretty="" origin..HEAD
@djk29a
djk29a / gist:4888b852aea250d2ae836e939a19064f
Last active February 22, 2017 03:13 — forked from hummus/gist:8592113
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq || sudo apt-get -y --force-yes install jq || sudo yum install -y jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \
@djk29a
djk29a / deconsolidate.rb
Last active September 30, 2016 18:38
Remove duplicate files in iTunes as a result of Consolidate Files
require 'find'
root = '/Volumes/music' # pick your path
Find.find(root) do |path|
if FileTest.directory? path and File.basename(path)[0] == '.'
Find.prune
else
d, f = File.split path
if f =~ /^(\d+(\-\d+)?.+)(\s\d+)\.(mp3)$/i
orig_file = File.join(d, $1 + '.' + $4) # check for existence of original file name including extension case
if File.readable? orig_file
@djk29a
djk29a / useradd.bash
Created March 31, 2016 20:53
Add users in a list
for u in username1 username2; do
# Ok, the groups are probably off but you get the point
useradd -p $(openssl passwd -1 ABC123def) -G primarygroup -g additionalgroups ${u}
end
@djk29a
djk29a / prune-chef-nodes.sh
Created March 22, 2016 00:30
Delete stale / not checking in Chef nodes
for node in $(knife search node "ohai_time:[* TO $(date +%s -d '5hours ago')]" -i); do
knife client delete -y $node
knife node delete -y $node
done
@djk29a
djk29a / zscaler-status.py
Last active March 22, 2016 00:28
Parse zScaler client info page; suitable for Sensu/Nagios/Check_MK monitoring checks
from HTMLParser import HTMLParser
import sys
"""
ZScaler IP Page Parser
$ curl -sL http://ip.zscaler.com/cgi-bin/index.cgi | python zscaler-status.py
{"proxycloud": "zscalertwo.net",
"proxyhost":"zs2-*redacted*",
"ip": "*redacted_ip*"}
@djk29a
djk29a / mtr_mpls.sh
Created October 9, 2015 16:04
Usage of mtr to get mpls label info
sudo mtr --port 443 --show-ips -T $1 -4 --no-dns --mpls # not sure why I needed both --show-ips and --no-dns, hmm
@djk29a
djk29a / bookshelf-du.rb
Last active October 9, 2015 15:47
[Chef] Get Bookshelf Usage by-org
# Retrieve the size of Chef cookbooks used by different organizations on the Chef server it runs on
# Should run as root normally since we use su to hop across to another user
full_org_list=''
full_file_list=''
orgs={}
# Getting orgs can take a while, let's hold onto the results for repeat invocations
if not File.exist?('.orgs-cached')
# NOTE: this produces 2 header lines and a footer line that has the rowcount
@djk29a
djk29a / export-chef-roles.sh
Last active October 9, 2015 15:48
Download Chef roles in all environments to JSON files
mkdir environments
for env in $(knife environment list); do
knife environment show "${env}" --format=json > "environments/${env}.json"
done