Skip to content

Instantly share code, notes, and snippets.

View mathew-hall's full-sized avatar

Mathew Hall mathew-hall

View GitHub Profile
@mathew-hall
mathew-hall / GraphView.java
Created July 3, 2012 14:03
Prefuse basic graph
/*
* Code from http://stackoverflow.com/questions/7233956/creating-data-in-prefuse
*/
package ui.mainview;
import prefuse.Constants;
import prefuse.Display;
import prefuse.Visualization;
import prefuse.action.ActionList;
@mathew-hall
mathew-hall / PLS2Spotify.py
Created February 7, 2013 17:32
Searches Spotify via spotimeta for each track name in a list.
#!/usr/bin/python
import sys
import re
import spotimeta
import time
import codecs
from glob import glob
@mathew-hall
mathew-hall / client.R
Created March 2, 2014 11:20
R Vircurex API wrapper
library(rjson)
library(RCurl)
#Magic: this function chooses the endpoint type based on the name
# of the caller.
# Arguments are a list of values which are matched
# with their named defaults.
request <- function(added_args, named_args){
#Matching nameless arguments to named arguments in declaration:
@mathew-hall
mathew-hall / bibtex.csl
Created April 10, 2014 15:52
CSL file to produce BibTeX records with Papers.app cite keys. Based on Zotero stylesheet by Markus Schaffner and Richard Karnesky.
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
<info>
<title>BibTeX generic citation style with Papers.app CiteKeys</title>
<id>http://www.zotero.org/styles/bibtex</id>
<link href="http://www.zotero.org/styles/bibtex" rel="self"/>
<link href="http://www.bibtex.org/" rel="documentation"/>
<author>
<name>Markus Schaffner</name>
</author>
@mathew-hall
mathew-hall / kalman
Created July 6, 2014 19:03
Kalman Filter example in R
#Example of a Kalman filter for estimating a fixed value with
#measurement error from the Welch and Bishop's "An Introduction
#to the Kalman Filter" University of North Carolina at Chapel Hill,
#Department of Computer Science TR 95-041
#Code ported from: Andrew D. Straw's implementation
# at: wiki.scipy.org/Cookbook/KalmanFiltering
@mathew-hall
mathew-hall / efergy_ltspice_dc.asc
Last active August 29, 2015 14:12
Efergy current monitor simulation (download as raw)

Version 4 SHEET 1 1260 680 WIRE -224 -208 -448 -208 WIRE -48 -208 -224 -208 WIRE 208 -208 -48 -208 WIRE 320 -208 320 -240 WIRE 320 -208 208 -208 WIRE 944 -208 320 -208 WIRE -48 -192 -48 -208 WIRE -448 -176 -448 -208

#!/usr/bin/env python
import socket
import json
import datetime
import sys
import MySQLdb
import os
# create database sensors:
#
for host in 10.0.0.100 10.0.0.101 10.0.0.102 10.0.0.103; do
for sensor in DS18B20 DHT11; do
filename="$host-$sensor.rrd"
if [ ! -f $filename ]; then
rrdtool create $filename --step 15 \
--start 1415577600 \
DS:humidity:GAUGE:600:10:80 \
DS:temperature:GAUGE:600:5:40 \
RRA:AVERAGE:0.5:1:40320 \
colours=('#dd0000' '#00dd00' '#0000dd')
colours=('#e41a1c' '#377eb8' '#4daf4a' '#984ea3')
for type in humidity temperature; do
i=0
for host in 10.0.0.100 10.0.0.101 10.0.0.102 10.0.0.103; do
for sensor in DS18B20 DHT11; do
rrdtool graph temperature/$host-$sensor-$type-1d.png \
@mathew-hall
mathew-hall / hex_hist.sh
Created February 16, 2015 11:03
Generate a histogram of all hex bytes for a file
xxd -c 1 $1 | cut -d " " -f 2,3,4 | sort | uniq -c | perl -p -e 's/^\s+//; $_ =~ /(\d+)\s+([a-f\d]{2})\s+(.+)/; $_="$2 $3"."*"x$1."$1\n";'