Skip to content

Instantly share code, notes, and snippets.

View colehocking's full-sized avatar

Cole Hocking colehocking

  • Colorado
View GitHub Profile
@colehocking
colehocking / .bash_profile
Last active October 5, 2018 17:54
Bash profile for OSX
# CCH - Bash Profile Settings #
# user@hostname:where<ex.~>$
export PS1="\e[1;33m\u@\h:\e[1;36m\w\e[0m\$ "
# colors
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias c='clear'
@colehocking
colehocking / .bash_aliases
Last active December 19, 2019 20:02
Some good bash aliases
alias c='clear'
alias f='thunar' #or applicable file manager
alias tlist='tmux list-sessions'
alias sbrc='source ~/.bashrc'
alias s='sudo'
@colehocking
colehocking / tuxwtf
Created December 10, 2017 13:52
Make a penguin say weird things
#!/bin/bash
# This tiny script outputs Github commit messages into the speech bubble of Tux ascii art
# The commit messages are curl'd from whatthecommit.com
# You need the cowsay application
# Check with: `which cowsay`
# Install with: `sudo apt-get install cowsay`
MSG=$(curl -s whatthecommit.com/index.txt)
#!/bin/bash
# Installation script to load homebrew
# -- Cole Hocking
# -----------------------------------------------------------------------------
# Verify Homebrew installation for package management
# Docs: https://brew.sh/
go_brew() {
echo "Checking for Homebrew package management tool..."
#######################
## Github Cheatsheet ##
#######################
# Git Global Setup #
git config --global user.name "Cole Hocking"
git config --global user.email "<my-email-addr>"
# Token Authentication #
( Settings --> <> Developer Settings --> Personal Access Tokens)
@colehocking
colehocking / dumpClean.py
Created July 11, 2018 15:51
dumpClean: the mighty nested JSON object expander!
def dumpClean(obj):
"""
Recursive function to clean the output of deeply nested dicts/lists
"""
if type(obj) == dict:
for k, v in obj.items():
# if the object has an iterable attribute; keep pulling it apart
if hasattr(v, '__iter__'):
print("%s : %s" % (k, dumpClean(v)))
else:
@colehocking
colehocking / getDomains.sh
Created October 4, 2018 16:54
Get AWS Domains
#!/bin/bash
# Gather AWS Domain info
declare -a domain_list=( $(aws route53domains list-domains | jq -r .Domains[].DomainName) )
for domain in "${domain_list[@]}"
do
echo ${domain}
echo "Admin Contact:"
@colehocking
colehocking / getExpDate.sh
Created October 4, 2018 16:56
Get AWS Domain Expiration Date
#!/bin/bash
declare -a domain_list=( $(aws route53domains list-domains | jq -r .Domains[].DomainName) )
for domain in "${domain_list[@]}"
do
# Returns date in unix timestamp
date_unix=$(aws route53domains get-domain-details --domain-name ${domain} | jq -r .ExpirationDate)
date -r ${date_unix}
done
@colehocking
colehocking / diffstr.sh
Created October 4, 2018 17:05
Compare strings in 2 files; output the difference to 3rd file
#!/bin/bash
# Find a list of strings in OG_LIST in OTHER LIST; export to FINAL_LIST
OG_LIST=$1
OTHER_LIST=$2
FINAL_LIST=$3
diff -iEwBay --strip-trailing-cr $OG_LIST $OTHER_LIST | grep -v "|" | grep -v "<" | grep -v ">" | awk '{print $1 " " $2}' > $FINAL_LIST
@colehocking
colehocking / netbiosx.sh
Created October 4, 2018 17:10
Use OSX smbutil to NetBIOS resolve a file full of IPs
#!/bin/bash
# Use the OSX smbutil to query a file of IPs
# use 'lookup' instead of 'status' to get IPs from Netbi names
file="$1"
while read -r line; do
smbutil status "$line"