Skip to content

Instantly share code, notes, and snippets.

View MageMasher's full-sized avatar

Joe Lane MageMasher

View GitHub Profile
@grodtron
grodtron / quine.clj
Created May 7, 2012 01:53
A Clojure Quine
(fn [] (let [s "(fn [] (let [s %s] (format s (pr-str s))))"] (format s (pr-str s))))
@ohpauleez
ohpauleez / interceptor.clj
Last active June 19, 2018 01:35
An example of how to make conditional interceptors that enqueue new interceptors
;; Let's start with a simple conditional interceptor that works with functions...
(defn conditional-context
"Given a keyword name and any variable predicate and terminator function pairs,
return an interceptor that will apply the terminator function paired to the first
truthy predicate. Predicates and terminators are both given the context as
the only argument.
If all predicates fail, the original context is returned."
[name-kw & pred-terms]
@thheller
thheller / web-component-v1.cljs
Created November 20, 2016 09:19
create web-component v1 in cljs without class
(defn component []
(js/Reflect.construct js/HTMLElement #js [] component))
(set! (.-prototype component)
(js/Object.create (.-prototype js/HTMLElement)
#js {:connectedCallback
#js {:configurable true
:value
(fn []
(this-as this
@mfikes
mfikes / README.md
Last active May 24, 2018 12:20
add-lib ClojureScript
clj -Sdeps '{:deps {github-mfikes/a69c72e65330e92625bfa81d5501dad4 {:git/url "https://gist.github.com/mfikes/a69c72e65330e92625bfa81d5501dad4" :sha "700c681f61eae580be3f52181e15c221fa23b77c"}}}' -m cljs.main -re node -r

This sets you up to use Alex Miller's new add-lib capability, hacked into a revision of ClojureScript.

Once the REPL is running, call add-lib to dynamically require a Git Dep library (or a :mvn/version, or a :local/root dep):

cljs.user=> (require '[cljs.repl :refer [add-lib]])
@bmaddy
bmaddy / deps.edn
Last active December 26, 2018 20:54
Playing around with caching
{:deps
{org.clojure/clojure {:mvn/version "1.10.0-RC5"}
#_#_org.clojure/spec.alpha {:mvn/version "0.2.176"}
#_#_org.clojure/test.check {:mvn/version "0.10.0-alpha3"}
org.clojure/core.cache {:mvn/version "0.7.1"}
org.clojure/core.memoize {:mvn/version "0.7.1"}
}}