Skip to content

Instantly share code, notes, and snippets.

View mikedewar's full-sized avatar

Mike Dewar mikedewar

View GitHub Profile
@mikedewar
mikedewar / matplotlibrc
Created October 17, 2011 10:27 — forked from huyng/matplotlibrc
my default matplotlib settings
### MATPLOTLIBRC FORMAT
### This is a custom config based on huyng's gist: https://gist.github.com/816622
#### CONFIGURATION BEGINS HERE
# the default backend; one of GTK GTKAgg GTKCairo CocoaAgg FltkAgg
# MacOSX QtAgg Qt4Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG Template
# You can also deploy your own backend outside of matplotlib by
@mikedewar
mikedewar / df2json.py
Created December 16, 2011 13:17
A little script to convert a pandas data frame to a JSON object. Is there a better way?
"""
tiny script to convert a pandas data frame into a JSON object
"""
import ujson as json
import pandas
import numpy as np
df = pandas.DataFrame({
"time" : [1,2,3,4,5],
@mikedewar
mikedewar / instapaper_xauth
Created February 17, 2013 01:44
This is an example script to get the list of articles on your instapaper account. You need to ask Instapaper for xauth access and you (or your user) need to be an instapaper subscriber ($3 a month) to be able to see the API.
from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth1
key = "key"
secret ="secret"
oauth = OAuth1(key, secret)
FROM google/golang
RUN go get github.com/tools/godep
RUN go get github.com/bmizerany/assert
ADD . /gopath/src/github.com/bitly/nsq
RUN godep get github.com/bitly/nsq/...
RUN cd /gopath/src/github.com/bitly/nsq && godep restore
@mikedewar
mikedewar / streamgo.go
Last active August 29, 2015 14:04
a stream processing library in go, where every function only accepts channels as inputs and only returns channels as outputs
package main
// merge takes two streams and turns them into one stream
func merge(a, b chan interface{}) chan interface{} {
o := make(chan interface{})
go func() {
for {
select {
case m := <-a:
o <- m
@mikedewar
mikedewar / fcc_open_internet.json
Last active August 29, 2015 14:04
streamtools pattern to parse the FCC "Comments on Protecting and Promoting the Open Internet" XML files.
{
"Connections": [
{
"ToRoute": "in",
"ToId": "1",
"FromId": "4",
"Id": "5"
},
{
"ToRoute": "in",
@mikedewar
mikedewar / .bash_profile
Created September 3, 2014 12:13
bash profile
export EDITOR=/usr/bin/vim
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
source ~/.git-prompt.sh
export PS1="\w\[$(tput setaf 7)\]\$(__git_ps1) \[$(tput setaf 6)\]⚡︎ \[$(tput sgr0)\]"

Keybase proof

I hereby claim:

  • I am mikedewar on github.
  • I am michaeldewar (https://keybase.io/michaeldewar) on keybase.
  • I have a public key whose fingerprint is 56BA A8AE 353F 9427 FB1E E971 06F8 7191 F6D5 A479

To claim this, I am signing this object:

@mikedewar
mikedewar / peekAndShift.json
Created September 16, 2015 20:02
A PeekAndShift block for st-core
{"blocks":[{"label":"","type":"pqPeek","id":27,"inputs":[{"name":"trigger","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"},{"name":"priority","type":"number"}],"source":"priority-queue","position":{"x":958,"y":72}},{"label":"","type":"delay","id":29,"inputs":[{"name":"in","value":{"data":1},"type":"any"},{"name":"duration","value":null,"type":"string"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":581,"y":286}},{"label":"","type":"latch","id":30,"inputs":[{"name":"in","value":null,"type":"any"},{"name":"ctrl","value":null,"type":"boolean"}],"outputs":[{"name":"true","type":"any"},{"name":"false","type":"any"}],"source":null,"position":{"x":1316,"y":134}},{"label":"","type":"sink","id":32,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[],"source":null,"position":{"x":1177,"y":59}},{"label":"1ms delay","type":"gate","id":33,"inputs":[{"name":"in","value":{"data":1},"type":"any"},{"name":"ctrl","value":null,"type":"any"}],"outputs":[{"name":"out","type":"
@mikedewar
mikedewar / movingAverage.json
Last active October 9, 2015 14:18
a moving average block for st-core
{"blocks":[{"label":"","type":"pqPeek","id":22,"inputs":[{"name":"trigger","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"},{"name":"priority","type":"number"}],"source":"priority-queue","position":{"x":958,"y":72}},{"label":"","type":"delay","id":23,"inputs":[{"name":"in","value":{"data":1},"type":"any"},{"name":"duration","value":null,"type":"string"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":581,"y":286}},{"label":"","type":"latch","id":24,"inputs":[{"name":"in","value":null,"type":"any"},{"name":"ctrl","value":null,"type":"boolean"}],"outputs":[{"name":"true","type":"any"},{"name":"false","type":"any"}],"source":null,"position":{"x":1314,"y":143}},{"label":"","type":"sink","id":25,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[],"source":null,"position":{"x":1170,"y":30}},{"label":"1ms delay","type":"gate","id":26,"inputs":[{"name":"in","value":{"data":1},"type":"any"},{"name":"ctrl","value":null,"type":"any"}],"outputs":[{"name":"out","type":"