Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Run the AWS cli on an ec2 instance with the security credentials of that instance
set -e
export IAM_ROLE=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)
export AWS_ACCESS_KEY_ID=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .SecretAccessKey)
export AWS_SECURITY_TOKEN=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${IAM_ROLE} |/usr/bin/jq -r .Token)
export AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/[a-z]$//')
# cat <<EOF
# IAM_ROLE $IAM_ROLE
@bhyde
bhyde / install-s6.sh
Last active April 2, 2017 01:12
Install script for the s6 supervision suite.
#!/bin/bash
# Based on https://raw.githubusercontent.com/cburki/docker-s6builder/master/scripts/build.sh
# hence GNU GENERAL PUBLIC LICENSE Version 3
set -o errexit
trap 'echo ERROR: exiting on error' ERR
SRC_DIR=/tmp/$(basename $0)-$$
trap 'rm -rf $SRCDIR' EXIT
mkdir -p ${SRC_DIR}
@bhyde
bhyde / keybase.md
Created February 9, 2017 15:24
Link to Github <-> Keybase

Keybase proof

I hereby claim:

  • I am bhyde on github.
  • I am bhyde (https://keybase.io/bhyde) on keybase.
  • I have a public key ASB6SG9PWyOBE1e1WA21mCNHl-7FixKCgJLi0f1vKZMn0Qo

To claim this, I am signing this object:

@bhyde
bhyde / jpsearch.py
Created August 10, 2015 21:55
A python implementation of https://github.com/jmespath/jp
#!/bin/env python
"""
USAGE: jpsearch [--unquoted|-u] [-f|--filename <json-file>] <JMESPath>
Reads json from standard input, or the file
if given. Then searches that as instructed
by the JMESPath; and prints the result. If
the result is a string and --unquoted is given
the string is printed without quotation. See
also http://jmespath.org/
"""
;;; package --- autoname remote shell buffers
;;; Commentary:
;; Adjustments to comint's shell mode.
;;; Code:
;; This is based on my-shell in http://www.emacswiki.org/emacs/ShellMode
@bhyde
bhyde / transcript
Last active August 29, 2015 14:10
pylint install failure, syntax errors?! under pyenv//2.6.9
$ pyenv versions
system
2.6.9
* 2.7.8 (set by /home/bhyde/.../.python-version)
$ ls ~/.pyenv/versions/
2.6.9 2.7.8
$ rm -rf ~/.pyenv/versions/2.6.9
$ pyenv install 2.6.9
Downloading Python-2.6.9.tgz...
-> https://yyuu.github.io/pythons/7277b1285d8a82f374ef6ebaac85b003266f7939b3f2a24a3af52f9523ac94db
@bhyde
bhyde / bad_indent.sh
Created November 18, 2014 18:31
A clever scheme to indent shell output, which doesn't work :(
#!/bin/bash
function indent(){
exec 6>&1
exec > >(sed 's/^/ /')
}
function end_indent(){
exec 1>&6 6>&-
}
@bhyde
bhyde / start-droplet-setup-ssh
Created July 30, 2014 21:44
Create droplet using tugboat, and wait for it. Wait till we can ssh_keyscan can get it's host key. Update my known_hosts. Plus, a paranoid check that ssh is working reliability.
#!/bin/bash
# Usage: start-droplet-setup-ssh <name> london docker
NAME="$1"
REGION="$2"
IMAGE="$3"
function LOG() { echo "LOG: $*" ; }
function ERROR() { echo "ERROR: $*" ; exit 1 ;}
#!/bin/bash
# get-docker-socket-from-remote <name> <user>@<host>
# Create a unix socket at /tmp/<name>-docker.sock which, when
# used will ssh to <user>@<host> and connect to the docker
# socket at <host>:///var/run/docker.sock
# Note:
# 1. This forks a subjob that manages the local socket.
# Rmember to kill that when your finished
@bhyde
bhyde / quickload_system_test
Created July 8, 2014 17:18
Assuming you have a working docker setup 'quickload_system_test foo' will (ql:load "foo") in a container and leave a of that in runs/foo/foo.log
#!/bin/bash
cd $(dirname $0)
set -o nounset -o errexit
function LOG(){ echo "LOG: $*" ; }
function ERROR(){ echo "ERROR: $*" ; }
function cleanup(){ echo '' ; }
trap "cleanup; ERROR in $0; exit 1" ERR
if [[ 0 == $# ]] ; then ERROR "missing system name arg."; exit 1; fi
QL_SYSTEM="$1"
DIR="runs/$QL_SYSTEM"