Skip to content

Instantly share code, notes, and snippets.

@termie
termie / .vimrc
Created January 14, 2016 20:57
patch to allow vim-go to use new vendor feature in go imports
let g:go_fmt_command = "goimports"
let g:go_fmt_options = "-f " . expand("%:p")
@termie
termie / glide.yaml
Last active January 12, 2016 23:01
ls vendor/github.com
ls vendor/github.com [master] 14:55:03
AdRoll bitly deckarep go-ini jinzhu mattn pmezard shurcooL vbatts
Azure bmizerany denverdino go-sql-driver jmespath matttproud prometheus spf13 vdemeester
BurntSushi boltdb dgryski godbus joho miekg rakyll stathat vishvananda
DataDog bradfitz docker gogo jonboulle mitchellh rcrowley stevvooe wercker
Sirupsen bugsnag dotcloud golang julienschmidt ncw revel stretchr xordataexchange
agl cbroglie dvsekhvalnov google jwilder noahdesu robfig syndtr yvasiyarov
agtorre chuckpreslar feyeleanor gorilla kimor79 olekukonko
@termie
termie / restore_fixtures.sh.diff
Last active November 10, 2015 11:03
WTF: the case of the missing N
--- a/restore_fixtures.sh
+++ b/restore_fixtures.sh
@@ -65,7 +65,8 @@ restore_to_mongo() {
local etcd_key="/services/mongodb"
echo "etcd key: $etcd_key"
- local host="$(sudo etcdctl ls --recursive $etcd_key | cut -d/ -f4)"
+ local host=$(sudo etcdctl ls --recursive "$etcd_key" | cut -d/ -f4)
local dump="$work_dir/dump/wercker"
@termie
termie / termieville.txt
Created October 26, 2015 10:56
my schedule between sunday afternoon and thursday afternoon
Time Estimates:
plane - 10h Complete
office - 4h In Progress
meeting - 1h
meeting - 1h
dead - 12h
office - 4h
meeting - 2h
dead - 2h
plane - 2h
@termie
termie / killprocess.go
Created July 14, 2015 20:43
kill stuff in a container
// killProcesses sends a signal to all the processes on the machine except
// for PID 1, somewhat naive but seems to work
func (s *WatchStep) killProcesses(containerID string, signal string) error {
client, err := NewDockerClient(s.options.DockerOptions)
if err != nil {
return err
}
cmd := []string{`/bin/sh`, `-c`, fmt.Sprintf(`ps | grep -v PID | awk "{if (\$1 != 1) print \$1}" | xargs -n 1 kill -s %s`, signal)}
err = client.ExecOne(containerID, cmd, os.Stdout)
if err != nil {
@termie
termie / trigger_build.sh
Created June 5, 2015 19:56
triggering a build on wercker
#!/bin/bash
APP_ID=<from wercker>
API_TOKEN=<from https://app.wercker.com/#profile/tokens>
GIT_BRANCH=master
#URL=https://app.wercker.com/api/project/${APP_ID}/build?token=${TOKEN}
RESULT=`curl --data-urlencode "branch=$GIT_BRANCH" https://app.wercker.com/api/project/${APP_ID}/build\?token\=$API_TOKEN`
echo $RESULT
@termie
termie / awk
Last active August 29, 2015 14:20
usage examples
termie@champs-3:/usr/local/bin % awk --help [master] 15:07:57
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options: GNU long options: (standard)
-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val
Short options: GNU long options: (extensions)
-b --characters-as-bytes
-c --traditional
@termie
termie / gist:216ccdfd87c54bd39aa6
Created January 20, 2015 09:52
auto-color based on directory
# add this to your .zshrc and then add
# $(__prompt_color) to your PROMPT
function __prompt_color()
{
local RGB CONVERTED RH GH BH RD GD BD
RGB=$(echo $(pwd) | md5 | cut -c 1-6)
RH=$(echo ${RGB} | cut -c 1-2)
GH=$(echo ${RGB} | cut -c 3-4)
@termie
termie / background.js
Last active August 29, 2015 14:10
quick dream chrome extension: shorten tab names in busy windows
// Also probably need a background page with tab permissions: https://developer.chrome.com/extensions/tabs
// listening for onCreated, onUpdated and do a
chrome.tabs.onCreated.addListener(tabCreated);
function tabCreated(tab) {
chrome.tabs.query({"windowId": tab.windowId}, function (tabList) {
tablist.forEach(function (aTab) {
aTab.sendMessage({"numTabs": tabList.size()});
})
})
# Ensure that etcd is starting fresh
config.vm.provision :shell, :inline => "systemctl stop etcd"
config.vm.provision :shell, :inline => "rm -rf /var/lib/etcd/*", :privileged => true
$script = <<SCRIPT
for x in $(cat /etc/environment); do
export $x
done
coreos-cloudinit --from-file /var/lib/coreos-vagrant/vagrantfile-user-data
SCRIPT