Skip to content

Instantly share code, notes, and snippets.

View wilhelm-murdoch's full-sized avatar
💀
Busy being spoopy.

Wilhelm Murdoch wilhelm-murdoch

💀
Busy being spoopy.
View GitHub Profile
@wilhelm-murdoch
wilhelm-murdoch / JSONCountries.json
Created December 6, 2010 02:45
Here is a JSON object which contains a list of all countries and their associated abbreviations. Thought others might find this useful.
[
{"US":"United States"},
{"CA":"Canada"},
{"AF":"Afghanistan"},
{"AL":"Albania"},
{"DZ":"Algeria"},
{"DS":"American Samoa"},
{"AD":"Andorra"},
{"AO":"Angola"},
{"AI":"Anguilla"},
@wilhelm-murdoch
wilhelm-murdoch / cidr.py
Last active October 22, 2021 13:08
Ensure given VPC subnets have zero overlap.
#!/usr/bin/env python
import ipaddr
accounts = {
'flood-beta': {
'public': [
'10.1.32.0/20',
'10.1.96.0/20',
'10.1.160.0/20'
@wilhelm-murdoch
wilhelm-murdoch / list.sh
Last active October 22, 2021 13:07
List all unused security groups in all AWS regions ...
#!/usr/bin/env bash
set -eo pipefail
[[ -n "${VERBOSE}" ]] && set -x
for region in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName'); do
for sg in $(aws ec2 describe-security-groups --region="${region}" | jq -r '.SecurityGroups[].GroupId'); do
if [[ $(aws ec2 describe-network-interfaces --region="${region}" --filters Name=group-id,Values="${sg}" | jq -r '.NetworkInterfaces | length') -eq 0 ]]; then
echo "${sg} in ${region}"
@wilhelm-murdoch
wilhelm-murdoch / keybase.md
Created November 7, 2020 03:41
keybase.md

Keybase proof

I hereby claim:

  • I am wilhelm-murdoch on github.
  • I am wilhelm (https://keybase.io/wilhelm) on keybase.
  • I have a public key ASBZm_maWfr3d882kURWC8C-i0iQFkBeuNWDtW2xi6sPxgo

To claim this, I am signing this object:

@wilhelm-murdoch
wilhelm-murdoch / spongebob
Last active October 22, 2021 13:07
Convert text to "spongebob' format from your command line ...
#!/usr/bin/env bash
set -eo pipefail
[[ -n "${VERBOSE}" ]] && set -x
read text
while [[ $index -lt "${#text}" ]]; do
swap=$(( $RANDOM % 10 ))
@wilhelm-murdoch
wilhelm-murdoch / aws.sh
Created July 7, 2020 06:53
Docker-based AWS CLI
#!/usr/bin/env bash
set -eo pipefail
[[ -n "${VERBOSE}" ]] && set -x
metadata() {
curl -s --connect-timeout 2 --fail "http://169.254.169.254/latest/meta-data/$*"
}
@wilhelm-murdoch
wilhelm-murdoch / K8s-DigitalOcean-CoreOS.md
Created March 23, 2018 07:42 — forked from kevashcraft/K8s-DigitalOcean-CoreOS.md
How to Setup Kubernetes on DigitalOcean with CoreOS

Kubernetes on DigitalOcean with CoreOS

Let's look at an example of how to launch a Kubernetes cluster from scratch on DigitalOcean, including kubeadm, an Nginx Ingress controller, and Letsencrypt certificates.

Overview

Environment

We'll be creating a four-node cluster (k8s-master, k8s-000...k8s-002), load balancer, and ssl certificates.

Table of Contents

  1. Install Kubernetes
@wilhelm-murdoch
wilhelm-murdoch / ngNumber.js
Created September 10, 2013 04:19
A better variation of AngularJS' ngNumber filter ...
/**
* Number Filter
* @Param input The number to format
* @Param fractionSize Nubmer of decimal places to round to; defaults to 2
* @Param groupSep Number group separator; defaults to a single space ' '
* @Param decimalSep Decimal place separator; defaults to single period
* @return string, ex: 1 234 345
*/
var DECIMAL_SEP = '.' // change to override default
var GROUP_SEP = ' ' // change to override default
@wilhelm-murdoch
wilhelm-murdoch / arthur.itermcolors
Last active September 30, 2016 21:29
My personal fish shell setup for iTerm 2 ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.16470588743686676</real>
<key>Green Component</key>
<real>0.20784313976764679</real>
@wilhelm-murdoch
wilhelm-murdoch / aggregation_test.py
Created August 18, 2013 07:52
Testing MongoDB aggregation problem. Creates 10 posters and randomly assigns them to 100 posts. Aggregation query returns mapping of poster to latest post sorted by creation date in descending order.
from pymongo import MongoClient
import datetime
import bunch
from faker import Faker
from random import choice
client = MongoClient(host="localhost", port=27017)
faker = Faker()
posters = []