Skip to content

Instantly share code, notes, and snippets.

@derpston
derpston / riakcollector.py
Last active Dec 28, 2015
Plugin for diamond, collects stats from riak over http locally and submits to Graphite.
View riakcollector.py
# 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
derpston / button.py
Created May 24, 2012
Python libusb interface for getting key up/down events from USB HIDs like keyboards.
View button.py
import sys
import time
import usb
class Button:
def __init__(self, vendor_id, device_id):
"""
Find and open a USB HID device.
"""
@derpston
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");
metricfire.init("your-api-key");
setInterval(function(){
memusage = process.memoryUsage();
metricfire.send("memoryusage.rss", memusage.rss);
metricfire.send("memoryusage.heaptotal", memusage.heapTotal);
metricfire.send("memoryusage.heapused", memusage.heapUsed);
@derpston
derpston / cursestest.py
Created Apr 11, 2012
Python curses example
View cursestest.py
# Scatters dots randomly on your terminal as a quick demo of curses.
import curses
import random
import time
window = curses.initscr()
try:
(h, w) = window.getmaxyx()
@derpston
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
derpston / crontab
Created Mar 8, 2012
Quick and dirty implementation of a smokeping-like tool on top of Metricfire
View crontab
* * * * * curl -s https://your-api-key@api.metricfire.com/v1/metric/smokecheap/tog-dot-ie --data-binary "[$(ping -c 20 tog.ie | awk '/bytes from/{print $8}' | cut -b6-10 | xargs | tr ' ' ',')]"
@derpston
derpston / mf_benchmark.py
Created Mar 7, 2012
Metricfire Python benchmarking
View mf_benchmark.py
import metricfire
import time
# Send to a nonexistant Metricfire aggregation server on this machine.
metricfire.init("deadbeef-dead-beef-dead-deadcafebabe", server = "127.0.0.1:6334")
before = time.time()
for index in xrange(100000):
pass
after = time.time()
@derpston
derpston / sparkfun-freeday-metricfire.py
Created Jan 12, 2012
SparkFun Free Day / Pachube / Metricfire data scraper
View sparkfun-freeday-metricfire.py
import urllib
import time
import metricfire
from BeautifulSoup import BeautifulSoup
metricfire.init("[API key redacted]")
previous_values = None
while True:
@derpston
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
BIFFBOOT> ?
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.