Skip to content

Instantly share code, notes, and snippets.

Matthew Chadwick Hendekagon

Block or report user

Report or block Hendekagon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Hendekagon
Hendekagon / 206
Created Sep 28, 2017
add 206 partial content in Aleph
View 206
; ---- the following fns copied from ring.util.response because they were
; useful but private ----
(defn canonical-path [^File file]
(str (.getCanonicalPath file)
(if (.isDirectory file) File/separatorChar)))
(defn safe-path? [^String root ^String path]
(.startsWith (canonical-path (File. root path))
(canonical-path (File. root))))
View gist:d3877ae82f9418d687c7ecfec09fe881
(use 'criterium.core)
=> nil
(defprotocol p1 (pt [this]))
=> p1
(extend-type Number p1 (pt [this] (list this)))
=> nil
(extend-type clojure.lang.PersistentList p1 (pt [this] this))
=> nil
(defn pf [x] (if (list? x) x (list x)))
=> #'user/pf
View gist:ce7b654a92485847cbcce5884cf55b28
dev:cljs.user=> (-> (a/coll-zip [3 {:x 5} 7 [4 {:y 17}] 9]) z/down z/right z/down z/down z/right (z/edit inc) z/next z/prev (z/edit inc) a/fip)
[3 ([:x 7]) 7 [4 {:y 17}] 9]
dev:cljs.user=> (-> (a/coll-zip [3 {:x 5} 7 [4 {:y 17}] 9]) z/down z/right z/down z/down z/right (z/edit inc) (z/edit inc) a/fip)
[3 {:x 7} 7 [4 {:y 17}] 9]
@Hendekagon
Hendekagon / programmer_jargon
Created Jun 9, 2017
A list of programmer jargon
View programmer_jargon
modulo - 'except' as in "modulo means an equivalence relation modulo its use by programmers"
orthogonal - 'unrelated' as in "the use of 'orthogonal' by programmers is orthogonal to its use by mathematicians"
land, landed - when a new feature is added to a library, it isn't mearly 'added', it 'lands' -- as if from the heavens, like a magical bird or an expensive jet
cut - when a new version of library is released it isn't mearly 'released' it is 'cut' -- like a sparkling diamond
curated - if you release a list that wasn't created by an algorithm, then say it's 'curated' as in "A curated list of programmer jargon"
@Hendekagon
Hendekagon / gist:833c6d5605c8ccca50dd15cee996a370
Created May 24, 2017
Comparing performance of Clojure's protocols, records and maps for fn dispatch
View gist:833c6d5605c8ccca50dd15cee996a370
(deftype Qp [] Q (q [this x] x))
=> user.Qp
(def Qm {:q (fn [x] x)})
=> #'user/Qm
(def Qp1 (Qp.))
=> #'user/Qp1
(c/quick-bench (q Qp1 7))
Evaluation count : 150426264 in 6 samples of 25071044 calls.
Execution time mean : 2.073561 ns
Execution time std-deviation : 0.274594 ns
View copy2clip
(defn copy2clip [x]
(let [w (StringWriter.)]
(pprint x w)
(.. Toolkit getDefaultToolkit getSystemClipboard
(setContents (StringSelection. (.toString w)) nil))))
@Hendekagon
Hendekagon / F.st
Last active May 1, 2017
bit pattern symmetry layout for Roassal
View F.st
'From Pharo3.0 of 18 March 2013 [Latest update: #30846] on 1 May 2017 at 5:58:40.759228 pm'!
Object subclass: #F
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'fredkin'!
!F commentStamp: 'mjc 3/26/2015 10:19' prior: 0!
bits
!
@Hendekagon
Hendekagon / gta
Last active Apr 16, 2017
Cyclic tag system in Clojure
View gta
; t a list of productions, a an initial sequence
; note this halts with a NPE - it should really
; check for (empty? a) and reduced
(defn g [t a]
(reductions
(fn [[g & t] a]
(if (== 1 g) (concat t a) t))
a (cycle t)))
View gist:7fed4483e90ce398e772bc494b5730e2
(use 'criterium.core)
=> nil
(def v1 (vec (range 1000000)))
=> #'user/v1
(def m1 (into {} (map vector (range 1000000) (range 1000000))))
=> #'user/m1
(quick-bench (get m1 71))
Evaluation count : 9861456 in 6 samples of 1643576 calls.
Execution time mean : 60.482667 ns
Execution time std-deviation : 1.681717 ns
View gist:b9dfef3253b6e0f50785d705137e9080
# https://query.wikidata.org/#PREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20p%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2F%3E%0APREFIX%20ps%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fstatement%2F%3E%0APREFIX%20pq%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fqualifier%2F%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX%20bd%3A%20%3Chttp%3A%2F%2Fwww.bigdata.com%2Frdf%23%3E%0A%0ASELECT%20%3Fitem%20%3FitemLabel%20%3Fcountry2Label%20%3FlinkTo%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP47%20%3Fcountry2.%0A%20%20%09%3Fcountry2%20wdt%3AP31%20wd%3AQ6256.%0A%20%20%09%3Fitem%20wdt%3AP47%20%3FlinkTo.%0A%20%20%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFI
You can’t perform that action at this time.