Skip to content

Instantly share code, notes, and snippets.

Justin Clayton justinclayton

  • Seattle
Block or report user

Report or block justinclayton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@justinclayton
justinclayton / add-dns-record.sh
Created Jul 15, 2015
CLI to add DNS Records in Route53
View add-dns-record.sh
#!/bin/bash -eo pipefail
## Allows for creation of "Basic" DNS records in a Route53 hosted zone
function main() {
record_name=$1
record_value=$2
[[ -z $record_name ]] && echo "record_name is: $record_name" && exit 1
[[ -z $record_value ]] && echo "record_value is: $record_value" && exit 1
@justinclayton
justinclayton / taint_module.sh
Created Jan 19, 2016
Terraform: taint all resources from one module
View taint_module.sh
#!/bin/bash
module=$1
for resource in `terraform show -module-depth=1 | grep module.${module} | tr -d ':' | sed -e 's/module.${module}.//'`; do
terraform taint -module ${module} ${resource}
done
@justinclayton
justinclayton / asg_to_ips.sh
Created Aug 29, 2017
Get private IPs of instances in an AWS autoscaling group
View asg_to_ips.sh
asg_to_ips() {
local asg=$1
local instances=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names ${asg} \
| jq '[.AutoScalingGroups[].Instances[].InstanceId]')
aws ec2 describe-instances --instance-ids ${instances} | jq -r '.Reservations[].Instances[].PrivateIpAddress'
}
View custom.itermcolors
<?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>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.20784313976764679</real>
@justinclayton
justinclayton / hack.tf
Created May 1, 2018
Terraform: conditionally reference a data source that may or may not exist
View hack.tf
variable "yes" { default = true }
data "template_file" "maybe" {
count = "${ var.yes == false ? 0 : 1 }"
template = "YES"
}
output "maybe" {
value = "${ var.yes == false ? "" : element(concat(data.template_file.maybe.*.rendered, list("")), 0) }" # <-- :_(
}
View percentiles.awk
# nearest-rank percentile, assumes sorted array
function ceil(valor)
{
return (valor == int(valor)) ? valor : int(valor)+1
}
function p(k, values) {
return values[ceil((k / 100) * length(values))]
}
View batt.py
#!/usr/bin/env python
# coding=UTF-8
import math, subprocess, re, sys
p = subprocess.Popen(['pmset', '-g', 'batt'], stdout=subprocess.PIPE)
output = p.communicate()[0]
# sample output
# "Now drawing from 'AC Power'\n -InternalBattery-0 (id=4522083)\t47%; charging; 2:00 remaining present: true\n"
View atelic.itermcolors
<?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>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.20784313976764679</real>
View dottmux.conf
# Map prefix to Ctrl-a
unbind C-b
set -g prefix C-a
bind C-a send-prefix
bind r source-file ~/.tmux.conf
# Rename your terminals
#set -g set-titles on
View keybase.md

Keybase proof

I hereby claim:

  • I am justinclayton on github.
  • I am justinclayton (https://keybase.io/justinclayton) on keybase.
  • I have a public key ASBhfnoIncfKAYyzMnFfzxG_bBFuwKvwtaHLIjyhUvrC7Qo

To claim this, I am signing this object:

You can’t perform that action at this time.