Skip to content

Instantly share code, notes, and snippets.

View dwallraff's full-sized avatar

Dave Wallraff dwallraff

View GitHub Profile
@dwallraff
dwallraff / funtions.sh
Last active May 24, 2023 03:25
Bash funtions
#! /usr/bin/env bash
# Check for requirements
function check_command {
if [ ! "$(command -v "$1")" ];
then
echo "command $1 was not found"
return 1
fi
@dwallraff
dwallraff / to_wtf.sh
Created March 31, 2020 15:53
loop to upload flat text files to wtf
#!/usr/bin/env bash
for i in *.yml; do
WORD=$(head -n 1 "$i")
ENCODED_WORD=$(echo -ne "$WORD" | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
DEF=$(tail -n+2 "$i" | awk '{printf "%s\\n", $0}')
echo "Posting $WORD..."
curl -s -X POST \
-H "Content-Type: application/json" \
-d '{"def" : "'"$DEF"'"}' \
@dwallraff
dwallraff / precreated_client-mulitple_contexts.sh
Last active March 12, 2020 17:55
get your 'precreated-client' bearer token from uaa when you have multiple contexts
cat ~/.uaac.yml | ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' | jq -r '.[].contexts[] | select(.client_id =="precreated-client") | .access_token'
@dwallraff
dwallraff / minikube-bootstrap.sh
Created March 12, 2020 02:02 — forked from minrk/minikube-bootstrap.sh
bootstrap single node kubernetes with minikube (no vm)
set -x
wget -O /usr/local/bin/rmate https://raw.github.com/aurora/rmate/master/rmate
chmod a+x /usr/local/bin/rmate
apt -y update
apt -y dist-upgrade
apt -y install docker.io
which minikube || (curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && mv minikube /usr/local/bin/)
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
# Forked from the original to do the opposite: Switch ssh repo urls to https
# Original here: https://gist.github.com/m14t/3056747
# Thanks to @m14t
#origin or upstream
REMOTE=${1-origin}
REPO_URL=`git remote -v | grep -m1 "^$REMOTE" | sed -Ene's#.*([email protected]:[^[:space:]]*).*#\1#p'`
@dwallraff
dwallraff / creds.sh
Last active January 11, 2024 01:52
Creds from an opsman install
# BOSH Director credentials
cat installationSettings.json | jq 'del(.products[] | select(.identifier == "p-bosh") | .jobs[] | select(.identifier == "director") | .properties[] | select(.identifier == "director_credentials"))' > installationSettings.json.tmp && mv installationSettings.json.tmp installationSettings.json
# BOSH UAA admin user creds
cat installationSettings.json | jq 'del(.products[] | select(.identifier == "p-bosh") | .uaa_admin_user_credentials)' > installationSettings.json.tmp && mv installationSettings.json.tmp installationSettings.json
# BOSH UAA admin client creds
cat installationSettings.json | jq 'del(.products[] | select(.identifier == "p-bosh") | .uaa_admin_client_credentials)' > installationSettings.json.tmp && mv installationSettings.json.tmp installationSettings.json
# BOSH VM creds
@dwallraff
dwallraff / no_powerchime.sh
Created February 11, 2020 16:33
Turn off PowerChime in OSX
defaults write com.apple.PowerChime ChimeOnNoHardware -bool true
killall PowerChime
@dwallraff
dwallraff / remove_nsx.md
Last active January 11, 2024 17:27
Remove NSX after a failed uninstall
  1. Put your ESXi hosts into maintenance mode

  2. Log into your ESXi host

  3. Check to see what got left behind

# Check for vmknic's
esxcfg-vmknic -l 
@dwallraff
dwallraff / set_colors.ps1
Created February 3, 2020 15:35
Set colors for pwsh
Set-PSReadlineOption -Colors @{member = "Cyan"}
Set-PSReadlineOption -Colors @{number = "Cyan"}
Set-PSReadlineOption -Colors @{type = "Cyan"}
Set-PSReadlineOption -Colors @{default = "Cyan"}
Set-PSReadlineOption -Colors @{continuationprompt = "Cyan"}