Skip to content

Instantly share code, notes, and snippets.


Steve Miner miner

View GitHub Profile
ericnormand / 00_script.clj
Last active Oct 25, 2020
Boilerplate for running Clojure as a shebang script
View 00_script.clj
#_DEPS is same format as deps.edn. Multiline is okay.
{:deps {clj-time {:mvn/version "0.14.2"}}}
#_You can put other options here
View gist:c17f378718cbd2fd82324002133ef678

So you’d like to contribute to Clojure, great! Let’s talk about what that involves.

The first thing you’ll want to make sure is that your idea is valid, and that you won’t spend a ton of time working on something that won’t make into master. To do this, you should create a JIRA ticket. For example, let’s say we want to improve how core.async handles channel closing propagation. It’s not a super complex problem, but there are some design questions about which of the various semantics currently in place should be the default, and if some semantics should be configurable.

So start by making a JIRA ticket and stating what the problem is you’re trying to solve, what the possible options for solving the problem. Now hit save and wait for the ticket to be triaged. Alex Miller will take a look when he can, and that can take a few days to a few weeks, depending on the time of the year (he has other responsibilities). Alex may out-right reject the idea if he knows Rich would never approve the ticket, but otherwise h

puredanger / dump.clj
Last active Nov 20, 2017
Dumping a var meta table
View dump.clj
;; Prints a table of vars in an ns with name/line/added/macro flag/deprecated flag
(defn pr-vars [ns-sym]
(->> (ns-publics ns-sym) vals (map meta) (sort-by :name)
(map #(select-keys % [:name :line :added :macro :deprecated]))
(map #(merge {:added nil :macro false :deprecated false} %))
(pr-vars 'clojure.string)
;; | :added | :macro | :deprecated | :name | :line |
stuarthalloway / missing_keys_specs.clj
Created Oct 14, 2017
I think it would be a mistake to introduce temporal coupling to prevent typos.
View missing_keys_specs.clj
;; I think it would be a mistake to introduce temporal coupling to prevent typos.
;; The example program below lets you identify "missing" keys specs at
;; the time and place of your choosing, and then handle them as you
;; deem appropriate, without imposing those decisions on other
;; users of spec.
(require '[clojure.spec.alpha :as s]
'[clojure.set :as set])
cgrand /
Last active May 31, 2017
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
# launch a clojure plain repl but with options and classpath matching project.clj
# Except when project.clj changes (and on first launch), lein is not called.
(let [p (leiningen.core.project/read)
args (@(var leiningen.core.eval/get-jvm-args) p)
cp (with-out-str (leiningen.classpath/classpath p))]
(print "ARGS=\"")
(apply print args)
reborg /
Last active Oct 20, 2020
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

cgrand / core.cljc
Last active Oct 14, 2020
Mixing macros and code in cljc and supporting clj, cljs and self-hosted cljs, see
View core.cljc
;; SEE:
;; macros and code in a single cljc working across clj, cljs and self-hosted cljs
;; require clojurescript from master
(ns foo.core
#?(:cljs (:require-macros
[net.cgrand.meta-macros :refer [macros no-macros]]
[foo.core :refer [add]])
:clj (:require
andymatuschak /
Last active Oct 14, 2020
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

bishboria /
Last active Oct 16, 2020
Springer made a bunch of books available for free, these were the direct links
You can’t perform that action at this time.