Skip to content

Instantly share code, notes, and snippets.

View philandstuff's full-sized avatar

Philip Potter philandstuff

View GitHub Profile
require 'octokit'
client = Octokit::Client.new(access_token: "<TOKEN>")
repos = client.repos('gds-attic')
repos.take(10).each do |repo|
puts "archiving #{repo.url}..."
client.post(
"#{repo.url}/transfer",
(function() {
var jQuery = window.$;
var OpenRegister = function(endpoint) {
this.endpoint = endpoint;
};
OpenRegister.prototype.buildURL = function(path) {
return this.endpoint + path + ".json";
};
module FizzBuzz where
import Data.Foldable (fold)
whenDivisible :: Integral a => a -> b -> a -> Maybe b
whenDivisible d x n = if n `rem` d == 0 then Just x else Nothing
fizzbuzz :: (Show a, Integral a) => a -> String
fizzbuzz n = maybe (show n) id tagStr
where tagStr = fold [fizz n, buzz n]
fizz = whenDivisible 3 "Fizz"
module FizzBuzz where
import Data.Maybe
data FizzBuzz = Fizz | Buzz deriving Show
whenDivisible :: Integral a => a -> b -> a -> Maybe b
whenDivisible d x n = if n `rem` d == 0 then Just x else Nothing
fizzbuzz :: (Show a, Integral a) => a -> String
fizzbuzz n = if null tags then show n else concatMap show tags
@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 / 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 / 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))