Skip to content

Instantly share code, notes, and snippets.

View puredanger's full-sized avatar
😀
Clojure is life

Alex Miller puredanger

😀
Clojure is life
View GitHub Profile
{:paths ["."]
:deps {org.clojure/data.json {:mvn/version "2.4.0"}}}
@puredanger
puredanger / # clojure - 2020-01-30_14-27-00.txt
Created February 21, 2020 14:56
clojure on macOS 10.15.2 - Homebrew build logs
Homebrew build logs for clojure on macOS 10.15.2
Build date: 2020-01-30 14:27:00
@puredanger
puredanger / # clojure - 2020-01-30_14-27-00.txt
Created February 21, 2020 14:52
clojure on macOS 10.15.2 - Homebrew build logs
Homebrew build logs for clojure on macOS 10.15.2
Build date: 2020-01-30 14:27:00
@puredanger
puredanger / responses.csv
Created December 2, 2013 05:37
Categorized responses from the Clojure/ClojureScript survey
Respondent ID Text Category Sub
61448432 Local Adoption. The community is very much concentrated in the US, with the exception of London. In the rest of Europe, not so much. In Belgium we hardly get 6 to 10 people joining a meetup. You see it in conferences too: Clojure presence is much higher at US conferences. adoption
61454845 Needs enterprise uptake and buy-in. adoption
61455773 It's a fairly insular community. adoption
61463826 In Japan... * Very little developer use with clojure. * it is too hard to find clojure developer. * it is too hard to find clojure documents for **non-lisp** programmer (I was non-lisp programmer before use clojure, but I am joyful **lisp style** programming with Clojure). adoption
61506717 Not mature enough language yet to be mainstream in corporate datacenters who think .NET is all you need. adoption
@puredanger
puredanger / dump.clj
Last active November 20, 2017 07:36
Dumping a var meta table
;; 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} %))
clojure.pprint/print-table))
(pr-vars 'clojure.string)
;; | :added | :macro | :deprecated | :name | :line |
@puredanger
puredanger / ex.clj
Last active June 22, 2017 15:57
fspec missing gen
(require '[clojure.spec.alpha :as s] '[clojure.spec.test.alpha :as stest])
(s/def ::cb (s/fspec :args (s/cat :e #(instance? Throwable %))))
(s/fdef foo :args (s/cat :e ::cb))
(defn foo [e])
(stest/instrument `foo)
(foo (fn [e] e))
ExceptionInfo Unable to construct gen at: [:e] for: (instance? java.lang.Throwable %) clojure.core/ex-info (core.clj:4727)
;; for the use case where same key is transformed through stage
(s/def :st1/a int?)
(s/def :st2/a string?)
(defn validate-map [stage m]
(every? (fn [[k v]] (s/valid? (keyword stage (name k)) v)) m))
(validate-map "st1" {:a 100}) ;; true
(validate-map "st2" {:a "abc"}) ;; true
@puredanger
puredanger / rps.clj
Created July 10, 2013 12:29
Rock Paper Scissors with core.async
(require 'clojure.core.async :refer :all)
(def MOVES [:rock :paper :scissors])
(def BEATS {:rock :scissors, :paper :rock, :scissors :paper})
(defn rand-player
"Create a named player and return a channel to report moves."
[name]
(let [out (chan)]
(go (while true (>! out [name (rand-nth MOVES)])))
(def v0 [])
(def v10 (vec (range 10)))
(def v100 (vec (range 100)))
(def v1000 (vec (range 1000)))
(quick-bench (reduce + v0)) ;; 2 ns
(quick-bench (apply + v0)) ;; 29 ns
(quick-bench (reduce + v10)) ;; 216 ns
(quick-bench (apply + v10)) ;; 392 ns
(quick-bench (reduce + v100)) ;; 2.13 µs