Skip to content

Instantly share code, notes, and snippets.

View samaaron's full-sized avatar

Sam Aaron samaaron

View GitHub Profile
;;
;; MM""""""""`M
;; MM mmmmmmmM
;; M` MMMM 88d8b.d8b. .d8888b. .d8888b. .d8888b.
;; MM MMMMMMMM 88''88'`88 88' `88 88' `"" Y8ooooo.
;; MM MMMMMMMM 88 88 88 88. .88 88. ... 88
;; MM .M dP dP dP `88888P8 '88888P' '88888P'
;; MMMMMMMMMMMM
;;
;; M""MMMMMMMM M""M M""MMMMM""M MM""""""""`M
(ns native-path.fix
(:require [leiningen.core.eval :as lein-ev]))
(defonce __FIX-NATIVE-PATH__
(let [lib-path (System/getProperty "java.library.path")
native-dir (lein-ev/native-arch-path {:native-path "target/native"})
new-path (str lib-path ":" native-dir)]
(System/setProperty "java.library.path" new-path)))
@samaaron
samaaron / markov.clj
Created September 6, 2012 07:23 — forked from kelsey-sorrels/markov.clj
Overtone Internal Sequencer with Markov chains
(ns overtone.examples.internal-sequencer
(:use [overtone.live]))
;; A fully server-side sample sequencer.
;; =====================================
;; This example demonstrates some of the benefits of moving all synth
;; triggers inside the server itself. For example, it allows you to
;; modify the synthesis with *immediate* effect (rather than waiting for
;; the next bar/chunk to be scheduled) and you can use a global pulse to
@samaaron
samaaron / gist:3607725
Created September 3, 2012 07:51
Random circles with Raphael.js & ClojureScript
(ns hello-world.hello)
(defn- clj-map->js-map
"makes a javascript map from a clojure one"
[cljmap]
(let [out (js-obj)]
(doall (map #(aset out (name (first %)) (second %)) cljmap))
out))
(defn- attr [object attributes]
@samaaron
samaaron / pg.clj
Created August 23, 2012 10:22
How to suck an entire postgres db into Clojure datastructures in memory
(ns ormclj.pg
(:require [clojure.java.jdbc :as sql]))
(defn pg-db
[hostname port db-name user passwd]
{:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname (str "//" hostname ":" port "/" db-name)
:user user
:password passwd})
(ns mondrian-factory
(:use quil.core))
(def screen-w 1920)
(def screen-h 1080)
(defn- red-yellow-blue-or-white []
([[255 0 0] [255 255 0] [0 0 255] [255 255 255] [255 255 255] [255 255 255]] (int (random 6))))
(defn- generate-positions-and-widths [n]
@samaaron
samaaron / pleiades.clj
Created June 13, 2012 12:27 — forked from quephird/pleiades.clj
Quil: pleiades
(ns pleiades
(:import [processing.core PApplet PConstants])
(:use quil.core))
(def screen-w 1920)
(def screen-h 1080)
; TODO: Need to apply blur to entire background; stars look too fake here
(defn- generate-background-stars []
(doseq [_ (range 1000)]
(ns square-exploration
(:use quil.core))
; This is another blatant ripoff, this time of the images produced
; by Don Relyea here: http://algorithm.posterous.com/tag/algorithmicexplorationofsquares
; This code needs some serious refactoring, particularly the screen metrics.
; Stay tuned...
(def screen-w 1000)
@samaaron
samaaron / ejackson.txt
Created June 8, 2012 11:38
Emacs gist-mode FTW!
<ejackson> oh that is cool
<ejackson> i can see my gists
<samaaron> you can even edit them
<ejackson> and edit them
<ejackson> :)
<samaaron> and when you hit save it updates them on github
<ejackson> no way !
<samaaron> yes way! [12:38]
<ejackson> create a new one ?
<samaaron> i believe you can do that
@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)))