Skip to content

Instantly share code, notes, and snippets.

View jcorbin's full-sized avatar

Joshua T Corbin jcorbin

View GitHub Profile
@jcorbin
jcorbin / graphite_to_pandas.py
Created January 15, 2014 19:32
Simple functions for converting raw graphite data to pandas time series / frame. Reasonably fast too; my test set was a 16MiB 350 metric dump, timing on my machine to parse is ~400ms.
import numpy as np
import pandas as pd
from cStringIO import StringIO
def parse_raw_graphite_metric(line):
head, body = line.rstrip('\n').split('|', 1)
name, since, until, freq = head.replace('\n', '').split(',')
since = float(since) * 1e9
until = float(until) * 1e9
freq = '%ss' % int(freq)
@jcorbin
jcorbin / d3_nest_tags.coffee
Created November 19, 2012 04:20
First pass at some convenience for turning d3.nest into tags with less boilerplate...
basicGroupTag = (tag) ->
[name, klass] = tag.split('.')
(sel, data) ->
sel = sel.selectAll(tag).data(data)
enter = sel.enter().append(name)
enter.attr('class', klass) if klass?
sel.exit().remove()
sel
ensureTag = (tag) ->
@jcorbin
jcorbin / division_demo.py
Created January 30, 2012 23:51
Division Demo
#!/usr/bin/python
# Example usage:
# $ ./division_deom.py 1 7
# 0 1
# .
# 1 3
# 4 2
# 2 6
# 8 4