Skip to content

Instantly share code, notes, and snippets.

View progrium's full-sized avatar

Jeff Lindsay progrium

View GitHub Profile
def healthy_nodes():
nodes = requests.get("http://localhost:8500/v1/health/nodes").json()
passing = requests.get("http://localhost:8500/v1/health/state/passing").json()
passing = [c["Node"] for c in passing if c["CheckID"] == "serfHealth"]
return [n for n in nodes if n["Node"] in passing]
++ export FLEETCTL_TUNNEL=54.68.57.250
++ FLEETCTL_TUNNEL=54.68.57.250
++ case "$cmd" in
++ fleetctl --debug=true --strict-host-key-checking=false list-units
I0918 03:22:13.988410 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/machines?consistent=true&recursive=true&sorted=true
I0918 03:22:14.271524 12217 client.go:360] etcd: recv response from GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/machines?consistent=true&recursive=true&sorted=true: 200 OK
I0918 03:22:14.271917 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/state?consistent=true&recursive=true&sorted=false
I0918 03:22:14.331921 12217 client.go:360] etcd: recv response from GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/state?consistent=true&recursive=true&sorted=false: 200 OK
I0918 03:22:14.332321 12217 client.go:353] etcd: sending HTTP request GET http://127.0.0.1:4001/v2/keys/_coreos.com/fleet/states?consistent=true&recursive=true&so
#!/usr/local/bin/bash
#nl2spc() {
# sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'
#}
#set -x
fn-args() {
local argline=$(type $1 | grep declare | grep -v "declare desc" | head -1)
export PS1="\[\033[01;31m\]\$(status=\$?; [[ \$status -ne 0 ]] && echo \"[\$status] \")\[\033[01;32m\]\u@\h \[\033[01;34m\]\w\n\$ \[\033[00m\]"
alias reload="curl -s https://gist.githubusercontent.com/progrium/6a24ae8d7ab93bc65579/raw/gistfile1.txt > ~/.profile.me; source ~/.profile"
alias g="git"
alias gpr="git pull --rebase origin"
alias gprr="git pull --rebase"
alias gpu="git push origin"
alias gpuu="git push"
alias gs="git status"
#include
https://cloud-init.gliderlabs.com/docker-cluster
#!/bin/sh
tail -n +6 $0 | tar -zx "$(uname -sm)"
mv "$(uname -sm)" $0
exec $0 $@
exit
( gzip data with different binaries named after output of uname -sm )
@progrium
progrium / bash.sh
Created February 17, 2015 14:19
Comparing natural brevity and concise expressiveness between Go and shell/Bash for certain tasks using each tool's "standard" library.
curl -s "$url" | tar -zxC "$dest"
package main
import (
"bytes"
"fmt"
"math/rand"
"time"
)
// Field represents a two-dimensional field of cells.
render-template() {
declare filename="$1"; shift
local script k v
for var in "$@"; do
IFS='=' read k v <<< "$var"
script="s/\$\$$k/${var##${k}=}/;$script"
done
cat "$filename" | sed "$script"
}
@progrium
progrium / gist:a6d8f4b72fc16891bd15
Last active August 29, 2015 14:25
Found some notes sketching possible Docker commands before we (well, Solomon) settled on most of what exists today. Some made it, some didn't. Explicit layer management idea was dropped entirely.
docker run -L layer://buildlayer -L file:///tmp/appsrc.tgz build.sh
docker run --layer buildlayer --layer appsrc.tgz --export build.sh > output.tgz
docker run --layer buildlayer --layer appsrc.tgz --export-file myfile build.sh > myfile
docker start foobar "run.sh web"
docker stop foobar
docker restart foobar
docker info foobar
docker logs foobar
docker destroy foobar