Skip to content

Instantly share code, notes, and snippets.

@timbirk
timbirk / ghperms.rb
Last active August 9, 2018 13:23
Checks and optionally sets a Github user or teams permission on matching repos in an org
#!/usr/bin/env ruby
require 'octokit'
require 'optparse'
require 'terminal-table'
require 'io/console'
def yesno
case $stdin.getch.downcase
when "Y".downcase then true
@timbirk
timbirk / isholiday
Created July 20, 2018 13:15
Python script to detect if it's a UK bank holiday. Requires "holidays" pip package.
#!/usr/bin/env python
import sys
import holidays
from datetime import date
sys.exit(date.today() not in holidays.England())
@timbirk
timbirk / why.sh
Created July 2, 2018 09:49 — forked from xiongchiamiov/why.sh
Use this when Amazon gives you an "Encoded authorization failure message" and you need to turn it into something readable. If you only get a request id... you're out of luck.
function decode-authorization-failure-message {
if [ $# -ne 1 ] || [ "$1" = -h ] || [ "$1" = --help ]; then
cat <<'EOT'
Usage: decode-authorization-failure-message <message>
Use this when Amazon gives you an "Encoded authorization failure message" and
you need to turn it into something readable.
EOT
return 1
fi
@timbirk
timbirk / gist:1fe37567dd331bb887b4c28754b0f222
Created June 27, 2018 14:50
Simple VCL Puppet template with caching
# This file is managed by Puppet. Manual changes will be destroyed.
# A naively simple config to cache items for <%= @cache_ttl %> and serve stale objects
# for up to <%= @grace_ttl %> on backend outage (data reload)
vcl 4.0;
# Default backend definition.
backend default {
.host = "127.0.0.1";
@timbirk
timbirk / .ssh_config
Created June 22, 2018 19:54
SSH config for accepting / ignoring host certs on RFC1700 / RFC1918 addresses.
Match exec "ping -q -c 1 -t 1 %n | grep ' (127\.\| (10\.\| (172\.16\.\| (172\.17\.\| (172\.18\.\| (172\.19\.\| (172\.20\.\| (172\.21\.\| (172\.22\.\| (172\.23\.\| (172\.24\.\| (172\.25\.\| (172\.26\.\| (172\.27\.\| (172\.28\.\| (172\.29\.\| (172\.30\.\| (172\.31\.\| (192\.168\.'"
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
@timbirk
timbirk / lp2itv.rb
Last active June 21, 2018 13:32
Generate repo / forge modules for itv.yaml file from existing Puppetfile.lock (captures all deps)
#!/usr/bin/env ruby
require 'librarian/puppet'
lockfile = Librarian::Puppet::Lockfile.new(
Librarian::Puppet::Environment.new, 'Puppetfile.lock'
)
puppet_modules = {}
@timbirk
timbirk / Colour-less.sh
Last active June 20, 2018 09:40
Following sets everything up to colorise less output.
# Pre-requisite
pip install pygments
cat << EOF > ~/.lessfilter
#!/bin/sh
case "$1" in
*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
*.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
*.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
*.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass)
#!/bin/bash
set -e
echo "Started running at: $(date '+%Y-%m-%d %H:%M:%S %:z')"
if [[ ! `bundle show puppet | grep "puppet-5"` ]]; then
export PUPPET_VERSION=5.3.3
fi
source ~/.github
@timbirk
timbirk / Random Passwords
Created June 18, 2018 09:55
Quick gist for generating 64 random characters on the command line
# It's been proven that password length is more important than complexity.
# For humans aLongPhraseLikeThis1 is more secure than an 8 character password.
# Generating a 64 character random character string on command line:
cat /dev/urandom | tr -dc 'a-zA-Z0-9._~()!*:@,;+?-' | fold -w 64 | head -n 1
# Because we probably use eyaml to encrypt the value, we don't ever need to know it:
eyaml encrypt --string=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9._~()!*:@,;+?-' | fold -w 64 | head -n 1)
@timbirk
timbirk / who-oncall.sh
Last active August 16, 2018 08:15
Add this to your ~/.bash_profile to see who's currently on-call on PagerDuty
#!/usr/bin/env bash
scheduleid=XXXXXX
apikey=XXXXXXXXXXXXXXXXXX
# No need to edit below
touch ~/.on_call
blue=`tput setaf 4`
reset=`tput sgr0`
today=$(date +'%Y-%m-%d')T09:00:00Z