Skip to content

Instantly share code, notes, and snippets.

View daveyarwood's full-sized avatar

Dave Yarwood daveyarwood

View GitHub Profile
@daveyarwood
daveyarwood / gist:28f135b0241f29826fd6
Created March 26, 2015 20:41
clj-image2ascii.core rules
$ boot -d clj-image2ascii repl
boot.user=> (require '[clj-image2ascii.core :refer :all])
nil
boot.user=> (convert-image
#_=> (get-image-by-url (java.net.URL. "http://evansheline.com/wp-content/uploads/2011/06/cute-cat.jpg (40KB) "))
#_=> 60 false)
{:width 60, :height 58, :color? false, :image <long-ass string here>}
@daveyarwood
daveyarwood / alda-repl-session
Created November 14, 2016 13:18
alda voice continuation example
$ alda repl
Nov 14, 2016 8:12:00 AM com.jsyn.engine.SynthesisEngine start
INFO: Pure Java JSyn from www.softsynth.com, rate = 44100, RT, V16.7.3 (build 457, 2014-12-25)
Preparing MIDI system... done.
█████╗ ██╗ ██████╗ █████╗
██╔══██╗██║ ██╔══██╗██╔══██╗
███████║██║ ██║ ██║███████║
██╔══██║██║ ██║ ██║██╔══██║
██║ ██║███████╗██████╔╝██║ ██║
#!/usr/bin/env ruby
template = <<~HEREDOC
{{plural noun}} are {{color}},
{{plural noun}} are {{color}},
{{food}} is {{adjective}},
and so are you.
HEREDOC
def prompt(type)
@daveyarwood
daveyarwood / random-bongos.alda
Created April 24, 2017 00:30
randomly generated bongos
(defn random-bongos
[ticks vol-min vol-max]
[(octave 4)
(set-duration 0.25) ; 16th notes
(let [notes (-> #{[:c] [:c :sharp] [:d] [:d :sharp] [:e]}
(->> (map #(note (apply pitch %))))
(conj (pause)))
rand-note #(rand-nth notes)
rand-vol #(vol (+ vol-min (rand-int (- vol-max vol-min))))
tick #(vector (rand-vol) (rand-note))]
@daveyarwood
daveyarwood / wpgtr-ch3.clj
Created January 27, 2014 00:37
why's (poignant) guide to ruby in clojure - chapter 3
; ex. 1:
(repeat 5 "Odelay!")
; ex. 2:
(when-not (re-find #"aura" "restaurant") (System/exit 0))
; ex. 3:
(map clojure.string/capitalize ["toast" "cheese" "wine"])
; ex. 4:
@daveyarwood
daveyarwood / .bashrc
Created May 10, 2018 00:20
Taskwarrior "task ready count" in Bash prompt
tasks_ready() {
which task >/dev/null || return
tasks_ready=$(task ready 2>/dev/null | grep -E '[0-9]+ tasks?')
if [[ -n "$tasks_ready" ]]; then
echo " ($tasks_ready ready)"
fi
}
PS1='\u@\h:\w$(tasks_ready) \$ '
@daveyarwood
daveyarwood / keybase.md
Created April 12, 2019 13:19
Keybase proof

Keybase proof

I hereby claim:

  • I am daveyarwood on github.
  • I am daveyarwood (https://keybase.io/daveyarwood) on keybase.
  • I have a public key ASB6ddX1Ndj1kkDK0O_jMhphWldMoERIjUmxh0uz6Bch0go

To claim this, I am signing this object:

@daveyarwood
daveyarwood / debugging-alda-up-issues.md
Created April 13, 2019 00:46
Debugging `alda up` issues (hanging waiting on workers, etc.)
  1. Start a server in the foreground:
$ ALDA_DISABLE_SUPERVISOR=yes alda -v -p 27714 -w 0 server

You should see output like the following:

19-04-13 00:32:31 moondog INFO [alda.server:243] - Binding frontend socket on port 27714...
@daveyarwood
daveyarwood / thousand.alda
Created June 29, 2019 02:02
a thousand-year-long polymetric drum pattern
# 12tone: "I Wrote a Thousand-Year-Long Song By Accident"
# https://www.youtube.com/watch?v=h7RCRLHcOlE
#
# Transcribed by Dave Yarwood 2019-06-28
#
# In this piece, each percussion instrument is played at a regular interval
# based on a prime number: the hi-hat is played every 2 16th notes, the kick
# every 3 16th notes, the snare every 5 16th notes, and so on. Because we're
# dealing with prime numbers, it takes an exceptionally long time for all of the
# instruments to eventually line up: over 1000 years, apparently!
@daveyarwood
daveyarwood / 00-conjure.edn
Last active November 21, 2019 03:03
Dave's setup for starting a prepl server in Boot projects
;; ~/.config/conjure/conjure.edn
{:conns
;; My `prepl-server` task spits out a `.socket-port` file when it starts a
;; prepl server. This configuration allows Conjure to find the prepl server
;; without needing to specify the port explicitly.
{:cwd {:port #slurp-edn ".socket-port"}}}