Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [opacity-ch (async/chan (async/dropping-buffer 1))] | |
(async/go-loop [last-set (:opacity @app-state) | |
last-received nil] | |
(let [t (async/timeout 100) | |
[ch val] (async/alts! [t opacity-ch]) | |
[new-set new-received] (cond | |
(= ch opacity-ch) | |
[last-set val] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[scad-clj.scad :refer :all] | |
'[scad-clj.model :refer :all]) | |
(defn degrees [d] | |
(-> d (/ 180.0) (* Math/PI))) | |
(def x-axis [1 0 0]) | |
(def y-axis [0 1 0]) | |
(def z-axis [0 0 1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.async :as async]) | |
(let [l (Object.)] | |
(defn log | |
[fmt & args] | |
(locking l | |
(apply printf fmt args) | |
(flush)))) | |
(let [req (async/chan 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example usage: | |
# | |
# lein-play '[org.craigandera/dynne "0.2.0"] [incanter/incanter-core "1.5.1"]' | |
LIBS=$* | |
PROJECT_DIR=/tmp/lein-play-`date +%Y%m%d%H%M%S` | |
mkdir $PROJECT_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:i1-channels (plumbing/fnk ^long [] 1) | |
:i1-duration (plumbing/fnk ^double [] 60.0) | |
:i1-amplitude (plumbing/fnk ^double [^double t] (Math/sin (p/* t 440 2.0 Math/PI))) | |
:i2-channels (plumbing/fnk ^long [] 1) | |
:i2-duration (plumbing/fnk ^double [] 60.0) | |
:i2-amplitude (plumbing/fnk [^double t] (let [x (-> t (p/* 440 2.0) long)] | |
(if (even? x) 1.0 -1.0))) | |
:m1-channels (plumbing/fnk ^long [^long i1-channels] i1-channels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn ->op | |
"Create an operation that just samples that sound | |
without additional processing." | |
[s] | |
(let [s* (gensym "sound")] | |
`{:bindings {~s* ~s} | |
:duration (.duration ~s*) | |
:channels (.channels ~s*) | |
:amplitude (.amplitude ~s* ~'t ~'c)})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sets up transparent encryption of files in /config/private as per | |
# https://gist.github.com/873637. You will need to edit the password | |
# in ~/.gitencrypt/password to match everyone else's if you want to | |
# share this repo. | |
# Note: due to me being in a hurry, only files in /config/private/ and | |
# its subdirectories DOWN TO FOUR LEVELS are encrypted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def eventcount (atom 0)) | |
(def i khordr.ApplicationServicesLibrary/INSTANCE) | |
(def eventTap (.CGEventTapCreate | |
i | |
khordr.ApplicationServicesLibrary$CGEventTapLocation/kCGSessionEventTap | |
khordr.ApplicationServicesLibrary$CGEventTapPlacement/kCGHeadInsertEventTap | |
0 | |
khordr.ApplicationServicesLibrary$CGEventType/kCGEventKeyDown | |
(reify khordr.ApplicationServicesLibrary$CGEventTapCallback | |
(onevent [this _ _ event _] (swap! eventcount inc) nil)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn update [state event-name] | |
;; current state id | event-name | action | |
;; | |
(match [(:status state) event-name] | |
[:waiting :prepare] #(assoc state :foo f3) | |
[:ready :delete] #(assoc state :bar 19) | |
[_ _] (throw (ex-info "Boom: roasted" {:reason :invalid-transition :event-name event-name})) | |
)) |