Skip to content

Instantly share code, notes, and snippets.

Simulating an incomplete stream from S3:

(let [server
      (ring.adapter.jetty/run-jetty
       (GET "/" _
         {:body
          (let [in (java.io.PipedInputStream.)
                out (java.io.PipedOutputStream.)]
            (.connect in out)
@atw-gr
atw-gr / user.clj
Created February 12, 2019 23:11
Unexpected multi-spec behavior
(ns user
(:require [clojure.spec.alpha :as s]))
(clojure-version) ;; => "1.10.0"
(defmulti type-spec :type)
(defmethod type-spec "foo" [_] any?)
(s/explain (s/multi-spec type-spec :type) {:type "foo"})
;; val: {:type "foo"} fails at: ["foo"] predicate: type-spec
@atw-gr
atw-gr / puzzles.org
Last active September 14, 2018 13:55

Keyword applied to set

You know what ({:foo 1} :foo), (:foo {:foo 1}), and (#{:foo} :foo) evaluate to , but what about (:foo #{:foo})?

Answer:

Here a keyword is being used as a function. Is that legal?

(isa? (type :foo) clojure.lang.IFn)
### Keybase proof
I hereby claim:
* I am atw-gr on github.
* I am atwgr (https://keybase.io/atwgr) on keybase.
* I have a public key whose fingerprint is 95D6 1415 A7A9 D9EE 8D3A A554 F5F4 D9B0 C8C6 EB5C
To claim this, I am signing this object: