Skip to content

Instantly share code, notes, and snippets.

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 F782 0ED3 7BE8 3639 1130 3C76 EB31 8EE6 4426 0178

To claim this, I am signing this object:

@devn
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])
(:require
[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
@devn
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]
end
end
Do.dont :worry, :about, :grouping, :any, :arguments
=> [:worry, :about, :grouping, :arguments]
(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.
Example:
@devn
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 '[clojure.zip :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))
@devn
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
devn / quick-pr-str.clj
Created December 1, 2022 22:03
race car go vroom
(defn quick-pr-str
([data]
(let [acc (StringBuilder.)]
(quick-pr-str acc data)
(.toString acc)))
([^StringBuilder acc data]
(cond
(string? data)
(do
(.append acc \")