Skip to content

Instantly share code, notes, and snippets.

derpston /
Last active Dec 28, 2015
Plugin for diamond, collects stats from riak over http locally and submits to Graphite.
# Plugin for the diamond to collect stats from Riak over HTTP.
# Copyright (c) 2013, Metricfire Ltd (Hosted Graphite)
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
derpston /
Created May 24, 2012
Python libusb interface for getting key up/down events from USB HIDs like keyboards.
import sys
import time
import usb
class Button:
def __init__(self, vendor_id, device_id):
Find and open a USB HID device.
derpston / gist:2772494
Created May 23, 2012
Node.js: sending memory usage data to Metricfire
View gist:2772494
// Send process memory usage to Metricfire every ten seconds.
var metricfire = require("metricfire");
memusage = process.memoryUsage();
metricfire.send("memoryusage.rss", memusage.rss);
metricfire.send("memoryusage.heaptotal", memusage.heapTotal);
metricfire.send("memoryusage.heapused", memusage.heapUsed);
derpston /
Created Apr 11, 2012
Python curses example
# Scatters dots randomly on your terminal as a quick demo of curses.
import curses
import random
import time
window = curses.initscr()
(h, w) = window.getmaxyx()
derpston / gist:2069716
Created Mar 18, 2012
Unpacking and repacking initramfs images
View gist:2069716
# Unpack
gzip -cd /boot/initramfs.example | cpio -i
# Repack
find . | cpio --dereference -o -H newc | gzip > /boot/initramfs.example
derpston / crontab
Created Mar 8, 2012
Quick and dirty implementation of a smokeping-like tool on top of Metricfire
View crontab
* * * * * curl -s --data-binary "[$(ping -c 20 | awk '/bytes from/{print $8}' | cut -b6-10 | xargs | tr ' ' ',')]"
derpston /
Created Mar 7, 2012
Metricfire Python benchmarking
import metricfire
import time
# Send to a nonexistant Metricfire aggregation server on this machine.
metricfire.init("deadbeef-dead-beef-dead-deadcafebabe", server = "")
before = time.time()
for index in xrange(100000):
after = time.time()
derpston /
Created Jan 12, 2012
SparkFun Free Day / Pachube / Metricfire data scraper
import urllib
import time
import metricfire
from BeautifulSoup import BeautifulSoup
metricfire.init("[API key redacted]")
previous_values = None
while True:
derpston / gist:1494015
Created Dec 18, 2011
Bifferboard BIFFROOT menu example
View gist:1494015
BIFFBOOT v3.3 00B3F600379E 32-bit Loader by bifferos (c) 2010
Redistribution prohibited, all rights reserved.
Press <ESC>
'help' or '?' for a list of commands
Available commands:
help Print this help
? Alias for 'help'
credits Print credits
analyser Run a simple logic analyser on JTAG/button GPIO
You can’t perform that action at this time.