Skip to content

Instantly share code, notes, and snippets.

View malcolmsparks's full-sized avatar

Malcolm Sparks malcolmsparks

View GitHub Profile
(ns foo.core
(:require [compojure.core :refer :all]
[ring.mock.request :refer [request]]))
(defn foo []
"I don't do a whole lot."
(context "/api" []
(context "/users" []
(context "/:user-id" [user-id]
(context "/contacts" []
(ns foo.core
(:require [compojure.core :refer :all]
[ring.mock.request :refer [request]]))
(defn foo []
"I don't do a whole lot."
(context "/api" []
(context "/users" []
(context "/:user-id" [user-id]
(context "/contacts" []
#=(eval
(-> (clojure.core/read-string (slurp "/home/malcolm/src/azondi/config.clj"))
((partial clojure.walk/postwalk
(fn [x] (if-let [path (and (string? x) (second (re-matches #"\.\./azondi(.*)" x)))]
(str "/home/malcolm/src/azondi" path)
x))))
;; Comment these 3
#_(update-in [:jig/components] dissoc
@malcolmsparks
malcolmsparks / gist:11109616
Created April 20, 2014 09:25
Autowire dependenices in component
(defn autowire-dependencies-satisfying
"Return a dependency map, adding dependencies between the given
key (of the dependant) and any components in the given system map that
satisfy the given protocol."
[dependency-map system-map dependant-key proto]
(merge-with merge dependency-map (normalize-dependency-map {dependant-key (vec (keep (fn [[k v]] (when (satisfies? proto v) k)) (seq system-map)))})))
### Keybase proof
I hereby claim:
* I am malcolmsparks on github.
* I am malcolmsparks (https://keybase.io/malcolmsparks) on keybase.
* I have a public key whose fingerprint is D7EA C082 D28B C792 3327 9A32 06CE E45E C93B 3AF9
To claim this, I am signing this object:
@malcolmsparks
malcolmsparks / gist:1c26adba3a55cefa057a
Created December 11, 2014 09:34
perf testing with http-kit and core.match
(ns perf.test
(:require
[org.httpkit.client :refer (request) :rename {request http-request}]
[clojure.core.async :refer (chan >! <! go go-loop)]
[clojure.core.match :refer (match)]
[ring.mock.request :refer (request) :rename {request mock-request}]))
(defn with-profiling [p & {:keys [callback]}]
(let [start (System/nanoTime)
dur (atom nil)]
@malcolmsparks
malcolmsparks / gist:473ece4b4905dadb0dc4
Created December 22, 2014 14:40
aleph seems to hang
(defproject alephplay "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.7.0-alpha4"]
[aleph "0.4.0-alpha9" :exclusions [org.clojure/clojure]]])
(ns alephplay.core
(ns alephplay.core
(:require
[aleph.http :as http]
[manifold.deferred :as d]))
(defn index [req]
(d/let-flow [status (future 200)]
{:status status :body "Hello World!"}))
[malcolm@nessa eep]$ lein deps :tree
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
warn
[cider/cider-nrepl "0.8.2-20141208.173909-2"]
[cljs-tooling "0.1.3" :exclusions [[org.clojure/clojure]]]
[compliment "0.2.0" :exclusions [[org.clojure/clojure]]]
[org.clojure/java.classpath "0.2.0" :exclusions [[org.clojure/clojure]]]
[org.clojure/tools.namespace "0.2.5" :exclusions [[org.clojure/clojure]]]
[org.clojure/tools.trace "0.7.8" :exclusions [[org.clojure/clojure]]]
[org.tcrawley/dynapath "0.2.3" :exclusions [[org.clojure/clojure]]]
@malcolmsparks
malcolmsparks / gist:1fa4fa6ff11387f795ef
Created January 9, 2015 12:19
test failures on eep
[malcolm@nessa eep]$ lein test
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
lein test clojurewerkz.eep.emitter-test
Exception occured while processing :failure-is-expected-here : java.lang.String cannot be cast to java.lang.Number
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number