Skip to content

Instantly share code, notes, and snippets.

View willscripted's full-sized avatar

Will O'Brien willscripted

View GitHub Profile
@willscripted
willscripted / bootstrap-cluster.sh
Created March 11, 2016 14:26
Bootstrap consul on top of etcd
#!/usr/bin/env bash
source /etc/environment
# If I am able to contact etcd2
/usr/bin/etcdctl mkdir /consul/leader
if [[ $? -eq 0 ]]; then
echo "Master lock created, bootstrapping"
/bin/bash -c "/usr/bin/docker run \
@willscripted
willscripted / mkcert
Last active November 25, 2015 12:38
One-liner for making self-signed certs. `mkcert <domain-name>`. Just add this script to your $PATH
#!/usr/bin/env bash
mkdir -p /tmp/mkcert
openssl genrsa -des3 -passout pass:x -out /tmp/mkcert/server.pass.key 2048
openssl rsa -passin pass:x -in /tmp/mkcert/server.pass.key -out /tmp/mkcert/server.key
rm /tmp/mkcert/server.pass.key
openssl req -new -key /tmp/mkcert/server.key -out /tmp/mkcert/server.csr \
-subj "/C=US/ST=Massachusettes/L=Boston/O=Me/OU=Department of Departments/CN=$1"
openssl x509 -req -days 365 -in /tmp/mkcert/server.csr -signkey /tmp/mkcert/server.key -out /tmp/mkcert/server.crt
mv /tmp/mkcert/* `pwd`
@willscripted
willscripted / gist:68670640648d0bae8574
Created September 2, 2015 19:00
docker upstart example
[Unit]
Description=Documentation for my app
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Environment="PROJECT_API_URL=https://path.to.place.com"
ExecStartPre=-/usr/bin/docker kill myapp
ExecStartPre=-/usr/bin/docker rm myapp
@willscripted
willscripted / deploy-geoff.sh
Created August 27, 2015 20:19
Deploy all Geoffs
#!/usr/bin/env bash
curl -H "Content-type: application/json" -X POST \
-d '{
"service_key": "--------YOURKEYHERE-------",
"event_type": "trigger",
"description": "A developer is in trouble!",
"client": "Geoff deployment cli",
"client_url": "http://butt.holdings",
"details": {
@willscripted
willscripted / index.js
Last active August 29, 2015 14:25
compare json via named pipe
expect = require('chai').expect
diff = require('diff')
require('colors').enabled = true;
process.stdin.setEncoding('utf8');
process.stdin.on('readable', function(){
var chunk = process.stdin.read();
if (chunk !== null) {
try {
json = JSON.parse(chunk);
@willscripted
willscripted / .tmux.conf
Last active August 29, 2015 14:24
tmux-me
set -g default-terminal "screen-256color"
# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
@willscripted
willscripted / kafka.sh
Created July 8, 2015 14:20
install kafka
#!/usr/bin/env bash
# Just for editor highlighting
### Kafka configuration
version=0.8.2.1
scala_version=2.11
install_dir=/usr/local/share
sudo -E su - --command "cd /tmp && wget http://archive.apache.org/dist/kafka/$version/kafka_$scala_version-$version.tgz"
CREATE OR REPLACE FUNCTION update_modified_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
ALTER TABLE consumer_offsets ADD COLUMN updated_at timestamp default current_timestamp;
CREATE TRIGGER update_consumer_offsets_modtime BEFORE UPDATE ON consumer_offsets FOR EACH ROW EXECUTE PROCEDURE update_modified_column();
@willscripted
willscripted / bootstrap-consul.sh
Last active August 29, 2015 14:20
Bootstrap Consul on Docker via Cloudconfig
#!/bin/bash
# Inspired by Brandon Philips' consul bootstrap script
# https://gist.github.com/philips/56fa3f5dae9060fbd100
source /etc/environment
num_expected_nodes=$1
do_join() {

test gist!

Things & Stuff

^ I need this to test '&' in headers