Skip to content

Instantly share code, notes, and snippets.

Nick Rothwell cassiel

Block or report user

Report or block cassiel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# start coding here or load an example from the dropdown above!
lp.extrude({'e': 5, 'speed': 5})

Keybase proof

I hereby claim:

  • I am cassiel on github.
  • I am cassiel ( on keybase.
  • I have a public key whose fingerprint is 2A68 ADDC 2464 C81E D429 47B2 8CE5 D2B4 CEA5 0008

To claim this, I am signing this object:

cassiel / intersect.cljc
Created Aug 21, 2015
2D line intersection test
View intersect.cljc
(defn intersection-2D
"Intersection of two lines in 2D space. No checks for parallel or coincident lines."
[[[x1 y1] [x2 y2]]
[[x3 y3] [x4 y4]]]
(let [denom (- (* (- x1 x2) (- y3 y4))
(* (- y1 y2) (- x3 x4)))
x1y2-y1x2 (- (* x1 y2) (* y1 x2))
x3y4-y3x4 (- (* x3 y4) (* y3 x4))
px-num (- (* x1y2-y1x2 (- x3 x4))
(* (- x1 x2) x3y4-y3x4))
cassiel / forbidden-piano.rb
Created May 2, 2015
Forbidden Piano, for Sonic Pi.
View forbidden-piano.rb
theNotes = [:a2, :a3, :e3, :a4, :g4, :e4]
define :foo do |samp, n|
sample samp,
rate: pitch_ratio(note(n) - note(:a3)),
sustain: 0.05,
release: 0.1,
View cljs-puffdraw-2.cljs
(defn paint
"Paint does the work. Iterate through the circular queue of states, drawing
a fat line from each point to the next (if button down)."
(letfn [(iter [i last-x last-y]
((let [{:keys [button x y]} (nth points i)]
(.move_to g last-x last-y)
(.line_to g x y)
View cljs-puffdraw-1.cljs
(defn bucket-add
"Cycle a new button/x/y into the point stash and force redraw.
Unlike the original Javascript, we
add to the front and remove from the end.
[me state]
(let [old (.-point_stash me)]
(set! (.-point_stash me) (cons state (drop-last old)))
(stash me state)
(.redraw (.-mgraphics me))))
View gist:1864710
from java.util import Map, List
class Manifest:
def __init__(self, h=None, **kw):
for k in kw:
setattr(self, k, kw[k])
if h is not None:
for k in h.iterator():
n = k.getKey().getName()
View gist:1863592
(defn kick
[m_Configuration m_Geometry]
(u/hashify m_Configuration)
(u/hashify m_Geometry)]
(fn [t]
(let [v-fn (if DO_VORONOI
(voronoi-with (* CELL_COLS CELL_SIZE 1/2)
View gist:1863525
(ns oncotrees.util
(:import [org.python.core PyFloat PyInteger PyBoolean PyString
PyList PyInstance PyNone]
[java.util NoSuchElementException]))
(defn hashify [py-object]
(cond (instance? PyNone py-object) nil
(instance? PyInstance py-object)
(letfn [(retr [key] (.__getitem__ (.__dict__ py-object) key))
(de-iter [iter result]
View gist:1863409
class Manifest:
def __init__(self, **kw):
for k in kw:
setattr(self, k, kw[k])
You can’t perform that action at this time.