Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Dewar mikedewar

View GitHub Profile
@mikedewar
mikedewar / matplotlibrc
Created Oct 17, 2011 — forked from huyng/matplotlibrc
my default matplotlib settings
View matplotlibrc
### 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 Dec 16, 2011
A little script to convert a pandas data frame to a JSON object. Is there a better way?
View df2json.py
"""
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 Feb 17, 2013
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.
View instapaper_xauth
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)
View nsq-Dockerfile
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 Aug 29, 2015
a stream processing library in go, where every function only accepts channels as inputs and only returns channels as outputs
View streamgo.go
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 Aug 29, 2015
streamtools pattern to parse the FCC "Comments on Protecting and Promoting the Open Internet" XML files.
View fcc_open_internet.json
{
"Connections": [
{
"ToRoute": "in",
"ToId": "1",
"FromId": "4",
"Id": "5"
},
{
"ToRoute": "in",
View .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)\]"
View keybase.md

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 Sep 16, 2015
A PeekAndShift block for st-core
View peekAndShift.json
{"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 Oct 9, 2015
a moving average block for st-core
View movingAverage.json
{"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":"
You can’t perform that action at this time.