Skip to content

Instantly share code, notes, and snippets.

View mathew-hall's full-sized avatar

Mathew Hall mathew-hall

View GitHub Profile
### Keybase proof
I hereby claim:
* I am mathew-hall on github.
* I am mat_h (https://keybase.io/mat_h) on keybase.
* I have a public key ASD6Rk7RQ-JiVEaOJv4g13dnsqH_5VLK3pVvz6vwkhdV1Ao
To claim this, I am signing this object:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mathew-hall
mathew-hall / import.sh
Created December 14, 2015 15:45
Wikipedia pagelinks postgres import; fixes up MySQL format problems that interfere with psql. Imports into the wiki database as `postgres`.
#!/usr/bin/env bash
pv enwiki-20151102-pagelinks.sql.gz | zcat | ./sql.pl | sudo -u postgres psql wiki >psql_err.log 2>&1
@mathew-hall
mathew-hall / printdeps.sh
Last active October 16, 2015 15:52
Angular Dependency Graphviz
#!/usr/bin/env bash
(echo "digraph g{"; grep -rh module js | grep -v '[\S+]' | sed 's/.*module(//;' | tr -d " (')[];" | tr , " " | awk '{if($1!="" && $1 != " "){for(i = 2; i <= NF; i++){ print "\"",$1,"\"","->", "\"",$i,"\""; }}}'; echo "}") > /tmp/deps.dot
dot -Tpdf /tmp/deps.dot -o/tmp/deps.pdf && open /tmp/deps.pdf
@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";'
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 \
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 \
#!/usr/bin/env python
import socket
import json
import datetime
import sys
import MySQLdb
import os
# create database sensors:
#
@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

@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