Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Lindsay progrium

View GitHub Profile
View gist:93c6a98a8af9a548a099
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]
View gist:e6a5dd31811befd989a6
++ 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
View gist:8b23c938cac6cb74861b
#!/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)
View gist:6a24ae8d7ab93bc65579
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"
View 0.noattributes
#include
https://cloud-init.gliderlabs.com/docker-cluster
View gist:219576c6a33cc0757292
#!/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 Feb 17, 2015
Comparing natural brevity and concise expressiveness between Go and shell/Bash for certain tasks using each tool's "standard" library.
View bash.sh
curl -s "$url" | tar -zxC "$dest"
View gist:9e1d085d9e978d32e99a
package main
import (
"bytes"
"fmt"
"math/rand"
"time"
)
// Field represents a two-dimensional field of cells.
View gist:8b20dd6314f3b164244a
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 Aug 29, 2015
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.
View gist:a6d8f4b72fc16891bd15
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