Skip to content

Instantly share code, notes, and snippets.

@steve-jansen
steve-jansen / demo.sh
Created November 18, 2016 20:13
Parse Terraform state file for AWS security group rules
jq '.modules[].resources | to_entries[] | select(.value.type == "aws_security_group_rule" or .value.type == "aws_security_group")' test.json
@steve-jansen
steve-jansen / git-diff-add
Last active September 19, 2018 21:37
A custom script for git to interactively run "git difftool" against each modified and untracked file, then prompt to stage (add) the change, undo (checkout) the change, or ignore (skip) the change.
#!/bin/bash
# query the root of the repo because git status prints
# relative paths within the repo
if ! pushd "`git rev-parse --show-toplevel`" >/dev/null
then
echo "git rev-parse --show-toplevel failed to return the root dir of the repo"
exit 1
else
gitroot=`pwd`
@steve-jansen
steve-jansen / main.sh
Created February 14, 2017 21:24
Bulk invite Slack users to a channel
for u in $(jq --raw-output ". | .[]" < members.json); do
clear;
echo Inviting user ${u};
curl -i -X GET "https://slack.com/api/channels.invite?token=${API_TOKEN}&channel=${CHANNEL}&user=${u}" | head -n 20;
sleep 1;
done;
@steve-jansen
steve-jansen / mirror-docker-registries.sh
Last active February 11, 2021 10:44
Mirror a Docker Trusted Registry (DTR) to another registry
#!/bin/bash
read -p "Registry to clone from: " pull_registry
read -p "Username for $pull_registry: " user
read -s -p "Password for $pull_registry: " password
echo
read -p "Registry to clone onto: " push_registry
echo Querying $pull_registry...
@steve-jansen
steve-jansen / MsDepSvc.Port.cmd
Created February 28, 2013 21:37
Windows batch script to modify the TCP/IP port binding for the Microsoft Web Deployment Agent Service
:: Name: MsDepSvc.Port.cmd
:: Purpose: Modifies the TCP/IP port that the Web Deployment Agent Service
:: (MsDepSvc) listens on. Tested on Win7 Enterprise 32-bit.
:: Author: stevejansen_github@icloud.com
:: Revision: January 2013
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
@steve-jansen
steve-jansen / export-zone.sh
Created December 15, 2014 19:11
Export DNS records from Rackspace Cloud DNS to zone files on disk
#!/bin/bash
# exports DNS records from Rackspace Cloud DNS to text files
# Depends on https://github.com/wichert/clouddns/blob/master/src/clouddns.py
set -e
me=export-zone
base_domain=
rackspace_region=
rackspace_rate_limit_delay=3
@steve-jansen
steve-jansen / Startup.Windows.cmd
Created March 8, 2013 17:18
A Windows batch file designed to run at logon from the Start / Programs / Startup to do the following: SUBST drive letters, wipe the %TEMP% folder, and run the disk defragmenter
:: Name: Windows Startup.cmd
:: Purpose: A logon script to SUBST drive letters, wipe %TEMP%, and run defrag
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL
:: map local folders to drive letters
CALL :MAPDRIVE P: "%USERPROFILE%\Documents\Visual Studio 2010\Projects"
@steve-jansen
steve-jansen / Startup.Cmd.cmd
Created March 8, 2013 17:22
A Command Prompt auto-run script to injet DOSKEY macros into the shell from a text file, change the initial working directory to a SUBST'd drive letter, update the PATH to include SysInternal utilities, and log all Command Prompt launches to a history file
:: Name: Startup.Cmd.cmd
:: Purpose: Initializes a Windows command prompt shell
:: Author: stevejansen_github@mac.com
:: Revision: April 2012
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
:: self-install this script, but, don't force an overwrite if an auto run script is already configured
IF /I "%~1"=="/install" (
@steve-jansen
steve-jansen / .vault
Last active November 11, 2022 05:24
HashiCorp Vault Token Helper using the OS X Keychain
token_helper = "/Users/me/.vault-helper"
@steve-jansen
steve-jansen / git-update
Created March 8, 2013 16:29
A custom script for git to stash any working changes, checkout master, pull origin master, checkout your working branch, rebase master, and unstash your working changes
#!/bin/bash
stash() {
# check if we have uncommited changes to stash
git status --porcelain | grep "^." >/dev/null;
if [ $? -eq 0 ]
then
if git stash save -u "git-update on `date`";
then