Skip to content

Instantly share code, notes, and snippets.

View bitprophet's full-sized avatar
🎯
Focusing

Jeff Forcier bitprophet

🎯
Focusing
View GitHub Profile
@bitprophet
bitprophet / gist:5493982
Last active December 16, 2015 20:39
Descartes and external data sources

Cluster graphing

  • It's frequently useful to graph a metric over a cluster of hosts, e.g. "show me the number of requests/s being handled by all of my load balancers".
  • Doing this in vanilla Graphite is easy - it honors both glob expressions (lb*) and brace expressions ({a,b,c,d}).
  • But how do we generate these for clusters whose hostnames don't glob well, and/or whose members change over time?

Descartes

  • Generally flippin' awesome.
  • Has a database of Metrics, Graphs composing 1+ Metrics, and Dashboards composing 1+ Graphs.

The setup:

  • Some top level tasks
  • A 'docs' submodule
  • docs.build is configured to be the default task for 'docs'
  • So, 'invoke docs' == 'invoke docs.build'. Either is allowed.

The question is, how should this setup display in --list? Our options:

  1. Fab 1.x style: display both, no indication of what maps to what:
from fabric.api import parallel, execute, sudo
@parallel
def uptime():
sudo('uptime')
def do_my_stuff():
execute(uptime, hosts=['web1', 'web2'])
# Bad
foo \
bar
# Good
foo \
bar
@bitprophet
bitprophet / bad.py
Created April 17, 2012 05:26 — forked from idan/gist:2403662
Parameter Usage Style
>>> def init(headers={}):
... print "headers before: %r" % headers
... headers['foo'] = 'bar'
... print "headers after: %r" % headers
...
...
>>> init()
headers before: {}
headers after: {'foo': 'bar'}
>>> init()
@bitprophet
bitprophet / gist:1503116
Created December 20, 2011 20:25 — forked from blech75/gist:1503089
markdown and lists

i want to be able to do this:


# grocery list

* apples
* bananas
* strawberries
import csv
import json
import os
import sys
from collections import defaultdict
from dateutil.parser import parse as dateparse
import requests
import csv
import json
import sys
from collections import defaultdict
from dateutil.parser import parse as dateparse
count = int(sys.argv[2]) if len(sys.argv) > 2 else None
seconds = defaultdict(int)
# Output of https://github.com/bitprophet/seven/blob/master/2-io/day1/answers.io
# at 6a42e4c454eb6eb6499bc1264efa34fc22d3fa15
-- Type strength --
Strongly typed
Still strongly typed
-- Truthiness --
0 is true
empty string is true
@bitprophet
bitprophet / gist:1189894
Created September 2, 2011 20:56
Partial Cony settings file
def github(query, url):
url = "https://github.com/%s/issues" % url
# Direct to issue number
try:
redirect("%s/%s" % (url, int(query)))
except ValueError:
# New ticket
if query == "new":
redirect("%s/new" % url)
# Issue list