Skip to content

Instantly share code, notes, and snippets.

@bakins
bakins / coreos-image.sh
Last active August 29, 2015 14:19
Get CoreOS AMI for an AWS region
function cores-image {
REGION=$1
CHANNEL=${2:-alpha}
EXPRESSION=`printf '.amis|map(select(.name == "%s"))[0]["hvm"]' "$REGION"`
curl --fail -s -L http://$CHANNEL.release.core-os.net/amd64-usr/current/coreos_production_ami_all.json | jq -r "$EXPRESSION"
}
ZONE=us-east-1
AWS_IMAGE=$(curl -s -L http://alpha.release.core-os.net/amd64-usr/current/coreos_production_ami_all.json | python -c "import json,sys;obj=json.load(sys.stdin);print filter(lambda t: t['name']=='${ZONE}', obj['amis'])[0]['hvm']")
@bakins
bakins / stoker.go
Last active August 29, 2015 14:14
stoker parser - very rough
// https://www.rocksbarbque.com - the stoker
// when you connect to telnet port, it is streaming updates about
// once per second. I was able to figure out which field was temperature
// and how to tell food and pit probes apart.
// Plan is to dump data to statsd(?) and/or into something like Circonus.
package main
import (
"bufio"

Keybase proof

I hereby claim:

  • I am bakins on github.
  • I am bakins (https://keybase.io/bakins) on keybase.
  • I have a public key whose fingerprint is D8DF B5B1 00D5 DA8F 88CD 2FC5 877A 72F8 7C59 9ABB

To claim this, I am signing this object:

@bakins
bakins / gist:bda46eff346c85aa3a17
Last active August 29, 2015 14:01
Horrible ohai workaround
# I need to support a few versions of chef and some custom ohai plugins
# our ohai 6 plugins didn't work in ohai 7, so here's a horrible hack to have a node
# sync/load the plugins based on ohai version if using the ohai cookbook
# this is in my cookbook "base". put ohai-6 plugins in files/default/ohai-6, and
# ohai-7 ones in files/default/ohai-7
node.default['ohai']['plugins']['base'] = 'ohai-' + (Ohai::VERSION.split('.')[0])
=====
===== LOGGING STARTED Sat May 3 13:53:24 UTC 2014
=====
13:53:25.353 [error] You've tried to set max_parallel_uploads, but there is no setting with that name.
13:53:25.353 [error] Did you mean one of these?
13:53:25.357 [error] max_paralell_uploads
13:53:25.357 [error] parallel_uploads
13:53:25.357 [error] max_paralell_downloads
13:53:25.361 [error] Error generating configuration in phase transform_datatypes
13:53:25.361 [error] Conf file attempted to set unknown variable: max_parallel_uploads
@bakins
bakins / gist:e62e9713ffa7c13b86da
Last active August 29, 2015 14:00
simple "synapse" type thing for consul
already do healthchecks in consul - we even need haproxy?
No way to get metadata into service - maybe insert into k/v? ie, healthcheck url.
if used haproxy - maybe just port check? or use a healthcheck grabbed from kv. wrapper go program that uses a text/template and writes haproxy config
simple go program:
"watch" service endpoint like: http://localhost:8500/v1/health/service/web?wait=120s&index=66 then add "passing" nodes to a pool then hand out connections - use httputil.reverseproxy to start
@bakins
bakins / gist:9695834
Created March 21, 2014 20:37
riak top
$ riak-admin top
===============================================================================================================================
'riak@10.165.23.16' 20:36:46
Load: cpu 692 Memory: total 301938 binary 17238
procs 9238 processes 53167 code 11491
runq 0 atom 1015 ets 167663
Pid Name or Initial Func Time Reds Memory MsgQ Current Function
-------------------------------------------------------------------------------------------------------------------------------
#!/bin/bash
VERSION=""
NAME=""
DIR=""
while getopts "v:n" opt; do
case $opt in
v)
VERSION=$OPTARG
@bakins
bakins / worker.go
Created January 6, 2014 18:15
Silly worker to create a push queue for each chef role and add each node in that role as a subscriber. Just learning golang and Iron.IO
package main
import (
"fmt"
"github.com/bakins/chef-golang"
"github.com/bakins/iron_go/mq"
"github.com/iron-io/iron_go/config"
"os"
"encoding/json"
"io/ioutil"