Skip to content

Instantly share code, notes, and snippets.

View samaaron's full-sized avatar

Sam Aaron samaaron

View GitHub Profile
@samaaron
samaaron / sun-flare-thingy.clj
Created June 7, 2012 19:21 — forked from quephird/sun-flare-thingy.clj
Quil: sun-flare-thingy
(ns sun-flare-thingy
(:import [processing.core PApplet PConstants])
(:use quil.core))
(def screen-w 1920)
(def screen-h 1080)
(defn- compute-stroke-color [x1 c1 x2 c2 x]
(map #(/ (+ %1 %2) (- x2 x1)) (map #(* (- x2 x) %) c1) (map #(* (- x x1) %) c2)))
@samaaron
samaaron / gist:2885344
Created June 6, 2012 22:56
Dancer draft
(ns rotating-spheres
(:use [quil.core]))
(defn setup []
(background 20)
(smooth))
(defn rand-circle-coords []
(let [max-x (* 2 (width))
max-y (* 2 (height))
@samaaron
samaaron / gist:2720148
Created May 17, 2012 16:49
Emacs Live description

"Energy starts surging through your fingertips. Sparks fly, making the shadows grow and flicker ominously around you."

This talk will introduce Emacs Live a pack-oriented structure for managing your .emacs.d. Emacs Live ships with a number of optional packs which add extra joy to your Emacs experience:

  • Foundation Pack
  • Colour Pack
  • Clojure Pack
  • Lang Pack
  • Power Pack
@samaaron
samaaron / spiragraph.clj
Created May 14, 2012 20:44
Quil Animated Spiragraph Experiments
(ns spiragraph
(:use [quil.core]
[quil.helpers.drawing :only [line-join-points]]
[quil.helpers.seqs :only [range-incl]]))
(defn setup []
(background 255)
(stroke-weight 5)
(smooth))
@samaaron
samaaron / vanishing-point-circles.clj
Created May 9, 2012 19:28
Vanishing Point circles
;;requires:
;; * Quil 1.4.1
;; * Clojure 1.4
;;
;; This is a modified version of @quephird's original code:
;; https://gist.github.com/2647426
(ns vanishing-point-circles
(:use quil.core))
@samaaron
samaaron / gist:2231226
Created March 28, 2012 22:43
binary file slurping and spitting
(ns slurper
(:import [java.io FileInputStream FileOutputStream File]))
(defn slurp-binary
[f-name]
(let [f (File. f-name)
fis (FileInputStream. f)
len (.length f)
ba (byte-array len)]
@samaaron
samaaron / gist:1726148
Created February 2, 2012 22:17
Clojure: swap-returning-prev! switch!
(defn switch!
"Sets the value of atom to new-val. Returns the previous value."
[atom new-val]
(let [old-val @atom
success? (compare-and-set! atom old-val new-val)]
(if success?
old-val
(recur atom new-val))))
(defn swap-returning-prev!
@samaaron
samaaron / gist:1494980
Created December 19, 2011 00:54
Clojure: mk-callable-map macro
(defmacro mk-callable-map []
(letfn [(arg-names [n]
(map #(symbol (str "v" (inc %))) (range n)))
(invoke-n [n]
(list 'invoke (vec (cons 'this (arg-names n)))
(list* 'callable-map-fn-impl (arg-names n))))
(invoke-n-with-apply [n]
(list 'invoke (vec (cons 'this (arg-names n)))
(list* 'apply 'callable-map-fn-impl (arg-names n))))]
`(~'defrecord ~'CallableMap [~'callable-map-fn-impl]
@samaaron
samaaron / gist:1494730
Created December 18, 2011 22:53
Clojure: infoke overloading
(defrecord Foo [fn-impl]
clojure.lang.IFn
(invoke [this] (fn-impl))
(invoke [this a] (fn-impl a))
(invoke [this a b] (fn-impl a b))
(invoke [this a b c] (fn-impl a b c))
(invoke [this a b c d] (fn-impl a b c d))
(invoke [this a b c d e] (fn-imple a b c d e))
(invoke [this a b c d e f (fn-impl a b c d e f)])
(invoke [this a b c d e f g (fn-impl a b c d e f g)])
@samaaron
samaaron / bells.clj
Created December 12, 2011 15:20 — forked from jennifersmith/bells.clj
Cheesy Holiday Music and bell synthesis example
(ns overtone-xmas.bells
(:use [overtone.live]))
;;tested in Overtone 0.6-dev
;;add [overtone.sc.machinery.defcgen] to ns :use clause for 0.5.0
;;http://computermusicresource.com/Simple.bell.tutorial.html
(def dull-partials
[
0.56