Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
@RichardBronosky
RichardBronosky / README.md
Last active July 22, 2022 13:50
Aliases for Terragrunt/Terraform to simplify using Terraform modules separately from terraform.tfvars

Installation

  1. Add aliases file to ~/.terraform.d
mkdir -p ~/.terraform.d

## Either: (a) Use a snapshot/copy of the current aliases
curl -sLo ~/.terraform.d/aliases https://gist.github.com/RichardBronosky/ae0e564f37f97f12586d6c828b8fa8ed/raw/48cfc248e74118a1c155fc321967d81c5fe70772/aliases
@RichardBronosky
RichardBronosky / slack_notify_ec2_launch.sh
Created August 5, 2019 16:53
Send EC2 launch notification to Slack webhook complete with connection command
# This functionality uses https://slack.com/apps/A0F7XDUAZ-incoming-webhooks?next_id=0
# Replace the 3 hashes in the next line with those from your webhook
slack(){ curl -d 'payload={"text": "'"$@"'"}' https://hooks.slack.com/services/HASH/HASH/HASH; }
msg_string='Instance \\"hack\\" came online. To connect:\n`%s`\nor:\n`%s`\n'
key="$(curl -s http://169.254.169.254/latest/meta-data/public-keys/ | awk -F '=' 'NR=1{print $2}')"
user="$(id -nu 1000)"
con_string="ssh -i ~/.ssh/$key.pem $user@%s"
private_host="$(hostname -f)"
public_host="$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)"
@RichardBronosky
RichardBronosky / redir_test.sh
Last active August 17, 2023 15:39
A oneliner for testing redirects
#!/bin/bash
# The following line defines a bash function and is designed to be copy-pasta-ed into your terminal and used as shown on the last line of this file. I'm only putting it in a script to get it on gist
redir_test(){ curl -svLo /tmp/redir_test.out "$@" 2>&1 | grep -E '^(> Host|> GET|< HTTP|< location|[<>]\s*$)'; }
# BONUS: One super-useful use of this is to test your readiness to respond to future DNS changes. That can be done like so:
# redir_test -H 'Host: www.example.com' https://192.168.0.101/
# This assumes that your server at 192.168.0.101 is set up to serve www.example.com and this simulates what `curl https://www.example.com/` would do if DNS returned 192.168.0.101 when doing a lookup on www.example.com
redir_test "$@"
@RichardBronosky
RichardBronosky / aws
Last active May 23, 2019 02:24
A pattern for syncing a dir to AWS S3 using using only Docker
#!/bin/bash -eu
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-PUT_DEFAULT_KEY_HERE}
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-PUT_DEFAULT_SECRET_HERE}
args=" -e \"AWS_DEFAULT_REGION=us-east-1\" ${DOCKER_ARGS:-} "
for v in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AWS_SECURITY_TOKEN; do
if [[ -n ${!v:-} ]]; then
args=" -e ${v}=${!v} ${args}"
fi
done
@RichardBronosky
RichardBronosky / .tmux.conf
Last active October 26, 2021 17:40
TMUX cheat sheet
# Use vi default bind-keys
setw -g mode-keys vi
# Use zsh inside tmux panes
tmux set-option default-command "/usr/bin/env zsh"
# Make @ do the opposite of !
bind-key @ list-windows; command-prompt -p "create pane from:" "join-pane -s ':%%'"
@RichardBronosky
RichardBronosky / vscode_cheat_sheet.md
Last active August 17, 2023 15:45
Visual Studio code - VSCode Cheat Sheet - Keyboard Shortcuts

VSCode Cheat Sheet

Keyboard Shortcuts

Jump to closing bracket

Cmd+Shift+\

Though I suggest changing it as follows:

editor.action.jumpToBracket Ctrl+]

@RichardBronosky
RichardBronosky / docker_build.sh
Last active April 10, 2019 12:30
My basic "build docker image from any directory" script. I have retyped this basic build script so many times that I basically didn't need to create this gist. Until I go a few weeks without doing Docker.
#!/bin/bash -eux
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$script_dir"
docker build -t $(basename $PWD) .
@RichardBronosky
RichardBronosky / dnsmasq.conf
Last active March 12, 2019 15:11
Tools for masking/spoofing/proxying DNS
#dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf
#log all dns queries
log-queries
#dont use host's hosts file
no-hosts
addn-hosts=./etc/hosts
@RichardBronosky
RichardBronosky / nginx.conf
Created March 1, 2019 17:02
An A/B testing work-in-progress
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
@RichardBronosky
RichardBronosky / similarities.sh
Created February 8, 2019 07:47
Identify how similar a file is to each file in a group of others.
#!/bin/bash
fileA="$1"
shift
for fileB in "$@"; do
(
# diff once grep twice with the help of tee and stderr
diff $fileA $fileB | \
tee >(grep -cE '^< ' >&2) | \
grep -cE '^> ' >&2