Skip to content

Instantly share code, notes, and snippets.

@timbirk
timbirk / keybase.md
Created July 11, 2017 09:00
keybase.md

Keybase proof

I hereby claim:

  • I am timbirk on github.
  • I am timbirk (https://keybase.io/timbirk) on keybase.
  • I have a public key ASAtnfXQtwKGD3RJTDl-riZHx937drGQ3Mtv_fN82Gkiywo

To claim this, I am signing this object:

@timbirk
timbirk / prcli
Created December 9, 2017 11:20
A tool for listing PRs and setting statuses.
#!/usr/bin/env ruby
require 'octokit'
require 'json'
def printhelp()
STDERR.puts 'ghlist - list things in Github'
STDERR.puts 'Usage examples:'
STDERR.puts ' * prcli status ITV/tp-infra 1423 pending jenkins "http://ci.infradev.tp.com/build/001" "Jenkins Build"'
STDERR.puts ' * prcli status ITV/tp-infra 1423 success'
@timbirk
timbirk / karma.conf.ci.js
Created January 2, 2018 17:55
Selenium Chrome / Docker / Karma
module.exports = function (config) {
// Get local IP for selenium runner
var address,
ifaces = require('os').networkInterfaces();
for (var dev in ifaces) {
ifaces[dev].filter((details) => details.family === 'IPv4' && details.internal === false ? address = details.address: undefined);
}
var webdriverConfig = {
@timbirk
timbirk / rdsstartstop
Last active May 24, 2021 08:54
A script used as a shell step in Jenkins jobs to start / stop RDS instances.
#!/usr/bin/env bash
set +x
ACTION="start"
ERR_RETRIES=3
STEP_SLEEP=60
MACHINE_TIMEOUT=3600
RDS_INSTANCE={envname}-mysql-rds
REGION=eu-west-1
@timbirk
timbirk / aws_subnet.rb
Last active February 20, 2018 15:18
This is an example of code to split a specified VPC / network CIDR into 3 public and 3 private subnets and spits out YAML style keys. Great for consistent subnet'ing across all AWS environments.
require 'netaddr'
vpc_subnet = '10.204.120.0/22'
subnet_cidr = 25
vpc_cidr = NetAddr::IPv4Net.parse(vpc_subnet)
@public_subnets = []
@private_subnets = []
@timbirk
timbirk / lp2r10k.rb
Last active August 14, 2018 14:55
A ruby script to generate a complete R10k ready Puppetfile from a librarian puppet style file.
#!/usr/bin/env ruby
require 'librarian/puppet'
lockfile = Librarian::Puppet::Lockfile.new(
Librarian::Puppet::Environment.new, 'Puppetfile.lock'
)
puppet_modules = {}
@timbirk
timbirk / GmailBliss.gs
Last active May 8, 2018 13:46
Script to setup regular email archiving and tagging of last week / this week.
/**
* Create the labels we’ll need for snoozing and attach Gmail account if needed
*/
function GmailLabelSetup() {
var CLEANUP_LABELS = ["1 - This Week", "2 - Last week"];
for (var i in CLEANUP_LABELS) {
GmailApp.createLabel(CLEANUP_LABELS[i]);
}
CleanInboxIsHappyInbox();
@timbirk
timbirk / private_repos.rb
Last active April 20, 2018 11:46
Lists forks of all private repos in your org. Relies on .netrc setup.
#!/usr/bin/env ruby
require 'octokit'
if ARGV[0]
@client = Octokit::Client.new(:netrc => true, :per_page => 100,
:auto_traversal => true, :auto_paginate => true)
@client.login
@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
@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)