Skip to content

Instantly share code, notes, and snippets.

View philandstuff's full-sized avatar

Philip Potter philandstuff

View GitHub Profile
@philandstuff
philandstuff / data-model.org
Created June 1, 2015 11:09
data modelling for registers

data model

needs

  • fetch a particular version of a record (permalink)
  • fetch the latest version of a record
  • view all (current) records
  • export whole register inc history
  • export last N versions of history
    • update my local copy of register with changes (streaming)
(function() {
var jQuery = window.$;
var OpenRegister = function(endpoint) {
this.endpoint = endpoint;
};
OpenRegister.prototype.buildURL = function(path) {
return this.endpoint + path + ".json";
};
@philandstuff
philandstuff / standalone-mapit.org
Last active August 29, 2015 14:23
standalone mapit experience
@philandstuff
philandstuff / lists-of-countries.md
Created September 1, 2015 11:20
Lists of countries and geographical locations
@philandstuff
philandstuff / tarai.clj
Created December 7, 2011 07:16 — forked from kawabata/tarai.clj
tarai mawashi in overtone
(ns tarai.core
(:use [overtone.live])
(:use [clojure.algo.monads :only [state-t cont-m run-cont domonad]]))
(def m (metronome 400))
;; basic.clj より
(defsynth foo [freq 200 dur 0.5]
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)])
low (sin-osc (/ freq 2))
@philandstuff
philandstuff / gist:1579825
Created January 8, 2012 21:48 — forked from samaaron/gist:1309367
Simple coordinated ping mechanism - only plays the ping if two buttons are pressed at the "same" time
(ns examples.coordination
(:use [overtone.live]
[overtone.inst.synth])
(:require [polynome.core :as poly]))
;;ping
(def m (poly/init "/dev/tty.usbserial-m64-0790"))
(poly/on-press m (fn [x y s]
@philandstuff
philandstuff / gist:1579755
Created January 8, 2012 21:25 — forked from samaaron/gist:1377020
Mostly Lazy Satie Bumper
(ns polynome-satie.core
(:use [clojure.core.match :only [match]]
[polynome core launchpad]
[overtone.live]
[overtone.inst sampled-piano]))
;;Erik Satie Gnossienne No. 1
(def phrase1a [:v :vii :vi# :v :v :iv# :v :iv#])
(def phrase1b [:v :vii :vi# :v :vii# :i+ :vii# :i+])
(def phrase1c [:v :vii :vi# :v :v :iv# :iii :ii :i :ii :i :ii :iii :ii :ii :i])
@philandstuff
philandstuff / definst_star.clj
Created February 14, 2012 07:28
Composable insts
(ns definst2.core
(:use [overtone.core]))
(defmacro definst* [name params & form]
(let [cgen-name (symbol (str name "-cgen"))
param-list (partition 2 params)
cgen-params (vec (mapcat (fn [[name default-val]] [name {:default default-val :doc ""}]) param-list))]
`(do
(definst ~name ~params ~@form)
(defcgen ~cgen-name ~cgen-params
@philandstuff
philandstuff / neo_loading.rb
Created June 10, 2012 12:51 — forked from mneedham/neo_loading.rb
Loading stuff into neo via the batch API
# So the problem is inserting data into neo using the batch API. So we have a bunch of people and we want to put them into the graph and also
# add to to the index so that we can search for them.
# The way the batch API works is that you can refer to previous commands by referencing their index in the list of commands (zero indexed)
# e.g. if I want to reference the person added in the first command I would reference that node as {0}
# You should be able to see how that works in the code below.
neo_people_to_load = Set.new
neo_people_to_load << { :name => "Mark Needham", :id => 1 }
neo_people_to_load << { :name => "Jenn Smith", :id => 2 }
neo_people_to_load << { :name => "Chris Ford", :id => 3 }
@philandstuff
philandstuff / haproxy-statsd.rb
Created October 8, 2012 09:34
script to pump haproxy stats into statsd
#!/usr/bin/ruby
require 'socket'
HOSTNAME = `facter hostname`.chomp
SOCKET = UDPSocket.new
IO.popen(["curl","http://localhost:8000/haproxy;csv"]) do |haproxy_csv|
header_line = haproxy_csv.gets
header_line.gsub!(/# /,'')
HEADERS = header_line.split(/,/)[0..-2]