Skip to content

Instantly share code, notes, and snippets.

View cam8001's full-sized avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Amazon Web Services
  • Wellington, New Zealand
  • 09:54 (UTC +12:00)
View GitHub Profile
@cam8001
cam8001 / all_apple_ips.txt
Created January 26, 2019 07:21
All Apple IP address ranges. Useful for firewall rules.
# Generated by:
# ASN=AS714; whois -h whois.radb.net -- "-i origin $ASN" | awk '/^route:/ {print $2;}' | sort | uniq
# @see https://ipinfo.io/AS714
#
# ASN=AS6185; whois -h whois.radb.net -- "-i origin $ASN" | awk '/^route:/ {print $2;}' | sort | uniq
# @see https://ipinfo.io/AS6185
144.178.0.0/18
144.178.0.0/19
144.178.48.0/21
144.178.56.0/21
@cam8001
cam8001 / shell-setup.sh
Last active January 9, 2024 20:49
Customise AWS cloudshell or Amazon Linux 2 with nice utilities
# Note for Cloudshell, only stuff in your home directory is saved.
# But, Cloudshell already has git and zsh available. So we just install custom binaries to ~/bin and update our path.
# you can whoami == cloudshell-user or $AWS_EXECUTION_ENV==CloudShell to detect cloudshell
# Start zsh on startup. No chsh :(
[[ $AWS_EXECUTION_ENV == "CloudShell" ]] && echo "In CloudShell, no need to install git/zsh" || sudo yum -y install git zsh && echo zsh >> ~/.bashrc
echo 'alias l="ls -lash"' >> ~/.zshrc
@cam8001
cam8001 / service-regions.sh
Last active December 20, 2023 19:41
One liner to get list of services keyed to AWS region
#!/bin/bash
curl -s 'https://api.regional-table.region-services.aws.a2z.com/index.json' \
| jq '.prices[] | .attributes | .["aws:region"], .["aws:serviceName"]' \
| sed '$!N;s/\n/,/'
@cam8001
cam8001 / yum-debug-variables.py
Created July 17, 2018 01:04
Show yum variables as referenced in the files in /etc/yum.repos.d/
python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
@cam8001
cam8001 / dapply
Last active December 20, 2023 19:40
Apply a patch directly from a URL without downloading it first.
#!/bin/bash
# Downloads and applies a patch from Drupal.org.
if [ -z "$1" ]
then
echo "You need to supply a URL to a patch file."
exit
fi
URL=$1;
@cam8001
cam8001 / git-diff-highlight
Last active December 20, 2023 19:40
Use nice word-level highlighting in git.
#!/bin/bash
# See https://github.com/git/git/tree/master/contrib/diff-highlight
export PATH=$PATH:$(brew --cellar git)'/'$(git --version | sed 's/git version //')/share/git-core/contrib/diff-highlight
# Add this to your gitconfig.
[pager]
log = diff-highlight | less
show = diff-highlight | less
@cam8001
cam8001 / jq-aws.bash
Created February 18, 2021 01:26
AWS ip-ranges.json parsing with JQ examples
# Use jq to parse the published AWS IP ranges.
# Use the file from here: https://ip-ranges.amazonaws.com/ip-ranges.json
# Select all Cloudfront nodes homed to Sydney
jq .prefixes[] | select(.service == "CLOUDFRONT") | select(.network_border_group=="ap-southeast-2")
# Find s3 endpoints in Oregon
jq -r '.prefixes[] | select(.region=="us-east-2") | select(.service=="S3") | .ip_prefix' < ip-ranges.json
@cam8001
cam8001 / goonsay.sh
Created September 7, 2023 02:17
goonsay.sh
echo " ___________ $@"
echo " (--)[ .]-[ .] /"
echo " (________O__)"
@cam8001
cam8001 / vort3x.md
Last active September 1, 2023 18:31
Vortex / IKBC Pok3r keyboard guide for Mac OS
@cam8001
cam8001 / role-instructions.md
Last active May 22, 2023 22:50
`Failed to delete stack: Role <role> is invalid or cannot be assumed` Assume this role from the cli if your cloudformation stack can't delete

Create a role with a trust policy that can be assumed by Cloudformation. Trust policy looks like this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
 "Effect": "Allow",