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 / gist:2957594
Created Jun 20, 2012
lamina.core.graph.propagator: error in aleph.http.core/expand-writes
View gist:2957594
lamina.core.graph.propagator: error in aleph.http.core/expand-writes
java.lang.NullPointerException
at clojure.lang.RT.intCast(RT.java:1065)
at aleph.http.core$ring_map__GT_netty_response.invoke(core.clj:341)
at aleph.http.core$expand_writes$fn__822.invoke(core.clj:177)
at lamina.core.graph.propagator$bridge_join$fn__2582.invoke(propagator.clj:162)
at lamina.core.graph.propagator.BridgePropagator.propagate(propagator.clj:57)
at lamina.core.graph.node.Node.propagate(node.clj:273)
at lamina.core.channel.SplicedChannel.enqueue(channel.clj:102)
at lamina.core$enqueue.invoke(core.clj:101)
View gist:5505873
(defplan start-server []
(remote-file/remote-file "server-1.0-standalone.jar" :local-file "/Users/me/server/target/server-1.0-standalone.jar")
(upstart/job "start-server" {:respawn true :exec "java -jar /var/lib/pallet/admin-home/onto/server-1.0-standalone.jar"}
{:instance-id "my-server"})
)
(defn start-instances []
(pallet.core/converge
(pallet.core/group-spec "g0"
:extends [(pallet.crate.nginx/nginx (http-server-config))]
@Hendekagon
Hendekagon / gist:0369f5a0c5128159fc23
Created Jul 17, 2015
"composition" of multimethods in Clojure
View gist:0369f5a0c5128159fc23
(defmulti qwe (fn [{:keys [a b c]}] [a b c]))
(defmethod qwe :default [m] m)
(defmethod qwe [1 2 3] [m] (zipmap (keys m) (map str (vals m))))
(defmethod qwe ["1" "2" "3"] [m] (zipmap (keys m) (map (partial str "x") (vals m))))
(defmethod qwe ["x1" "x2" "x3"] [m] {:x 3 :y 2 :z [1 0]})
View gist:441c6ebc07bfd89fac42
(defn tranz
"
Return the given matrix mat transposed such that the dimension at index i
is the first or last (f) dimension.
e.g. if m is a matrix with shape [2 3 4 5], then (tranz m 2 last) has shape [5 2 3 4]
Don't like this, there must be a better way.
"
[mat i f]
(first
@Hendekagon
Hendekagon / rest
Created Jan 29, 2016
From REST to CQRS with Clojure, Kafka, & Datomic - Bobby Calderwood https://www.youtube.com/watch?v=qDNPQo9UmJA
View rest
0:00
thank you Alex and thank you
0:03
Elgin land and ever more complex and involved for a great love about this
0:07
event
0:07
this is my first bug big speak at the conference event I've done like little
0:12
you know I'm sessions and meet ups and stuff in the past and I have conjured
View cljsbuild
{
:id "dev"
:source-map true
:source-map-timestamp true
:source-map-path "public/js"
:output-to "public/js/main.js"
:output-dir "public/js"
:asset-path "js"
:foreign-libs [
{:file "http://ariutta.github.io/svg-pan-zoom/dist/svg-pan-zoom.min.js"
View gist:9ff9ee6d44a92e9066a5dd19b9bc7f31
(defmacro explanatory-cond->
"Adapted from Clojure's cond-> macro to keep a list of conditions and results"
[expr & clauses]
(assert (even? (count clauses)))
(let [g (gensym)
pstep
(fn [[test step]]
`(if ~test
[(-> (if (vector? (first ~g)) (ffirst ~g) (first ~g)) ~step)
(cons [(quote ~test) (quote ~step) (first ~g)] (second ~g))]
@Hendekagon
Hendekagon / cheese-hat
Last active May 23, 2016
Add a jaunty cheese-hat to any div
View cheese-hat
div::before {
width: 3em;
top: -2.6em;
height: 3em;
transform-origin: 50% 50%;
transform: rotate(-29deg);
position: relative;
z-index: 10000000;
margin-bottom: -3em;
content: url("data:image/svg+xml;utf8,<svg height='100%' viewBox='-8 -8 16 16' width='100%' xmlns='http://www.w3.org/2000/svg'><g><rect fill='white' height='5' stroke-width='0.25' stroke='black' transform='rotate(45) translate(8,8)' width='5' x='-10.5' y='-10.5'></rect><rect fill='white' height='5' stroke-width='0.25' stroke='black' width='15' x='-7.5' y='0'></rect><text font-family='monospace' font-size='2.5' x='-5' y='3.25'>CHEESE</text></g></svg>");
View gist:3d582703fbe50c1435b1c95cbf3aac05
(defn lca
"Last common ancestor"
[db name1 name2]
(d/q '[
:find [(pull ?anc [:db/id :name]) ...]
:in $ % ?name1 ?name2
:where
(?node1 :name ?name1)
(?node2 :name ?name2)
(anc ?anc1 ?node1)
@Hendekagon
Hendekagon / gist:bcbdbd2edc841b4c326d7060683897ac
Last active Aug 6, 2016
Clojure arity vs map destructure cost
View gist:bcbdbd2edc841b4c326d7060683897ac
(require '[criterium.core :as crit])
=> nil
(defn Q ([x y z] [x y z]) ([{:keys [x y z]}] [x y z]))
=> #'repl/Q
(crit/quick-bench (Q 4 5 6))
Evaluation count : 43141050 in 6 samples of 7190175 calls.
Execution time mean : 12.030810 ns
Execution time std-deviation : 0.313706 ns
Execution time lower quantile : 11.631011 ns ( 2.5%)
Execution time upper quantile : 12.336856 ns (97.5%)
You can’t perform that action at this time.