Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am minimal on github.
  • I am chrismcdevitt (https://keybase.io/chrismcdevitt) on keybase.
  • I have a public key whose fingerprint is 9FF4 31C9 6AF3 1739 5300 2F71 03E4 4C93 6251 7D7B

To claim this, I am signing this object:

View fpx2015.org

property tests

how to choose properties

different paths, same destination

  • commutativity
  • associativity
  • map
  • monad & functor laws

there and back again

  • serialization/deserialization
View pi.txt
┌─────────────────┬─────────────────────┐ ┌─────────────────┐
│*****************│*********************│ │*****************│
│*****************│**************
View test_flow.py
def strategy(*args, **kwargs):
return ss.StrategyTable().strategy(*args, **kwargs)
PagesTuple = namedtuple("PagesTuple", ("url", "url_hash", "description",
"title", "classified"))
def make_pages(tuples):
pages = pages_pb2.Pages()
for tup in tuples:
View core.clj
(ns transducers-exp.core
(:require [criterium.core :as cr])
(:gen-class))
(def xform (comp (map inc)
(filter even?)
(dedupe)
(mapcat range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
View times.csv
nfuncs thread transducers
17 28000 548
6 3700 199
2 21 50
View *cider-repl transducers-exp*.txt
transducers-exp.core> (cr/with-progress-reporting (cr/bench (sequence xform-small data)))
Warming up for JIT optimisations 10000000000 ...
compilation occured before 934629 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
View *cider-repl transducers-exp*.txt
transducers-exp.core> (cr/bench (sequence xform data))
WARNING: Final GC required 3.920999473301486 % of runtime
Evaluation count : 119337840 in 60 samples of 1988964 calls.
Execution time mean : 548.637437 ns
Execution time std-deviation : 85.741031 ns
Execution time lower quantile : 474.085845 ns ( 2.5%)
Execution time upper quantile : 732.818167 ns (97.5%)
Overhead used : 2.067067 ns
Found 5 outliers in 60 samples (8.3333 %)
@minimal
minimal / core_test.clj
Last active Nov 27, 2018
testing monoids with test.check
View core_test.clj
(defn passes-monoid-props
[f id a b c]
(and (= (f (f a b) c) (f a (f b c))) ;; associativity
(= (f a id) a) ;; identity element
(= (f id a) a)))
(defspec plus-zero-are-monoid 100
(prop/for-all [[a b c] (gen/vector gen/int 3)]
(passes-monoid-props + 0 a b c)))
View util.clj
(defn flip-map
"Map of vals to keys"
[col]
(persistent! (reduce-kv (fn [m k v] (assoc! m v k))
(transient {}) col)))