Skip to content

Instantly share code, notes, and snippets.

joinr / ordering.clj
Created May 28, 2019
examples of composeable ordering functions
View ordering.clj
(ns ordering)
;;We want to pack some information along with
;;our functions so that when our interpreter picks them
;;up, we can determine if the function should be applied
;;directly as a comparator, or if we need to "lift"
;;it into the comparator domain.
(defn ordering? [x] (get (meta x) :ordering))
;;convenience macro to help us create functions with
;;ordering specified in meta
kachayev /
Last active Dec 23, 2021
A few thoughts on Aleph development

Aleph, Async, HTTP, Clojure

I've been working with Aleph rougly for last 5 years, actively contributing to the library for last 2 (or so). I also put some effort into spreading the word about it, including educational tech talks, like "Deep HTTP Dive Throught Aleph & Netty". But the more I talk to people the more confusion I find, mostly about how Aleph works and what can you expect when adding it to your stack. Clojurists Together has recently announced Aleph to get Q1 funding, I think it's a good time to share my priorities and thoughts on development plans that were mentioned in the blog post. Hope the community would find it interesting and helpful.

Aleph describes itself as "asynchronous communication for Clojure" library. And you should probably pay a good portion of your attention to the first word: "asynchronous".

mfikes /
Last active Feb 7, 2019
cljs command

If you wan't a cljs that acts like clj, but for ClojureScript, there are a few minor changes you can make:

First, add the following entry to ~/.clojure/deps.edn under the :deps key:

org.clojure/clojurescript {:mvn/version "1.10.439"}

Then make copies of clj and clojure named cljs and clojurescript, and put those copies on your path.

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

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])
reborg /
Last active Sep 28, 2022
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

semperos / bimap.clj
Created Oct 4, 2012
Bidirectional Map in Clojure (Christophe Grand)
View bimap.clj
;; Big thanks to Christophe Grand -
(defprotocol ReversibleMap
(rmap [m]))
(defn- rdissoc [d r v]
(if-let [[_ k] (find r v)] (dissoc d k) d))
(deftype Bimap [^clojure.lang.IPersistentMap direct reverse]
(hashCode [x]
semperos / clojure-deftype-scaffolding.clj
Created Oct 4, 2012
Clojure Scaffolding for deftype (Christophe Grand) - Show which methods a class implements and for which interfaces
View clojure-deftype-scaffolding.clj
;; Big thanks to Christophe Grand -
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]