Skip to content

Instantly share code, notes, and snippets.

@devn
devn / local.clj
Created January 27, 2014 22:20
example caribou local.clj environment for heroku
{:database {:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:database "YOURUNIQUESTRING"
:host "ec2-123-456-789.compute-1.amazonaws.com"
:port 5432
:user "postgres_username"
:ssl true
:sslfactory "org.postgresql.ssl.NonValidatingFactory"
:password "postgres_password"}}
@devn
devn / winamp.clj
Created January 28, 2014 06:46
winamp skins for clojure
(ns defjam.core)
(defn __verb [__noun __noun_place]
(filter #{__noun} __noun_place))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ns defjam.dude
(:require [clojure.java.io :as io]
[clojure.string :as str]
@devn
devn / memo.md
Created February 19, 2014 19:52 — forked from yokolet/memo.md
(defn write-file [filename file]
(with-open [w (clojure.java.io/output-stream filename)]
(.write w (:body file))))
(let [base-uri "http://google.com"
img-path (-> (get-page base-uri)
(first-by-xpath "//img[@alt='Google']")
(comp :src attrs))
img-url (str base-uri img-path)]
(->> (clj-http.client/get img-uri {:as :byte-array
@devn
devn / keybase.md
Created March 24, 2014 17:36
keybase.md

Keybase proof

I hereby claim:

  • I am devn on github.
  • I am devn (https://keybase.io/devn) on keybase.
  • I have a public key whose fingerprint is C1FC 786D C713 AFC5 CE9F 41E8 8233 12B2 4DA1 AA3D

To claim this, I am signing this object:

;;
;; paths
;;
(setq system-uses-terminfo nil)
(add-to-list 'exec-path (expand-file-name "~/bin"))
(add-to-list 'exec-path (expand-file-name "/usr/local/bin"))
(setenv "PATH" (concat (expand-file-name "~/bin")
":/usr/local/bin:"
@devn
devn / autotune.clj
Created July 15, 2014 17:48
autotune/autocorrect pitch overtone
(defsynth pitch-follow-1 []
(let [in (mix [(sound-in)])
amp (amplitude:kr in 0.05 0.05)
[freq has-freq] (pitch:kr in
:amp-threshold 0.02
:median 7)
out-1 (mix [(var-saw:ar (mul-add:ar 0.5 1 2)
0
(lf-noise1:kr (mul-add:kr 0.3 0.1 0.1)))])
out-2 (loop [n 6
@devn
devn / cheating.clj
Created September 5, 2014 21:40
Implementing IFn
(defn gen-nonvariadic-invokes [f]
(for [arity (range 1 21),
:let [args (repeatedly arity gensym)]]
`(~'invoke [~@args] (~f ~@args))))
(defn gen-variadic-invoke [f]
(let [args (repeatedly 22 gensym)]
`(~'invoke [~@args] (apply ~f ~@args))))
(defn gen-apply-to [f]
@devn
devn / midijam.clj
Created September 4, 2015 23:47
playing midi notes from overtone to ableton, reason, etc. using MIDI Patchbay
;; http://notahat.com/midi_patchbay/
;; Create a virtual input and virtual output in MIDI patchbay
;; input name: "Overtone"
;; output name: "yourchoice"
;; In Reason, Ableton, etc. select "yourchoice"
;; as the midi input for a channel.
(ns jam.core
(:use [overtone.live]))
@devn
devn / recursive-transient-persistent-transform.clj
Last active December 5, 2022 15:02
Recursively transform a nested map into transients, and then back to persistents
(require '[clojure.walk :as walk])
;; => nil
(defn transient? [x]
(instance? clojure.lang.ITransientCollection x))
;; => #'user/transient?
(let [transients (walk/postwalk (fn [x]
(if (map? x)
(transient x)