Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

devn / quick-pr-str.clj
Created December 1, 2022 22:03
race car go vroom
(defn quick-pr-str
(let [acc (StringBuilder.)]
(quick-pr-str acc data)
(.toString acc)))
([^StringBuilder acc data]
(string? data)
(.append acc \")
devn / day05.clj
Created December 6, 2020 01:52
Day 5, Advent of Code 2020
(ns day05
(:require [clojure.string :as str]
[clojure.set :as set]))
(def boarding-passes "...")
(defn find-pos [ops size lower-op upper-op]
(loop [ops ops
xs (range 0 (inc size))]
(if (seq ops)
devn / clojure_zippers.clj
Last active September 11, 2019 18:51
clojure zippers, returning a path that can be used with update-in or get-in, has alternate versions of update-in and assoc-in which work with clojure sets
(require '[ :as z])
(defn update-in*
"Like update-in, but also works with nested sets."
[m ks f & args]
(let [up (fn up [m ks f args]
(let [[k & ks] ks]
(if ks
(if (set? m)
(conj (disj m k) (up (get m k) ks f args))
(ns coinstar
(:import [java.time LocalDate]))
(def working? (constantly false))
(defn go
"Provided a `who` and `when`, returns the state of
a coinstar `when` the `who` goes to it.
devn / todo.exs
Last active December 1, 2017 22:38
do todo
defmodule Do do
def dont think, about, it, but, please do
[think, about, it, please]
Do.dont :worry, :about, :grouping, :any, :arguments
=> [:worry, :about, :grouping, :arguments]
devn / strum.clj
Created December 24, 2016 14:30 — forked from noprompt/strum.clj
Macro for defining instrumented functions which verify their arguments and return values against specs.
(ns strum.core
(:refer-clojure :exclude [defn])
[clojure.spec :as spec]
[clojure.spec.test :as spec.test]))
;; ---------------------------------------------------------------------
;; Prelude
;; HACK: Currently, as of Clojure 1.9.0-alpha14, there is a bug with

Keybase proof

I hereby claim:

  • I am devn on github.
  • I am devn ( on keybase.
  • I have a public key whose fingerprint is F782 0ED3 7BE8 3639 1130 3C76 EB31 8EE6 4426 0178

To claim this, I am signing this object:

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)
devn / midijam.clj
Created September 4, 2015 23:47
playing midi notes from overtone to ableton, reason, etc. using 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 []))
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]