Skip to content

Instantly share code, notes, and snippets.

Avatar

Sean Corfield seancorfield

View GitHub Profile
@seancorfield
seancorfield / deps.edn
Last active Jun 10, 2020
Debugging Reflection Warnings
View deps.edn
;; I use Clojure CLI / deps.edn and I have these JVM options in an alias
;; that use when starting my REPL for testing:
:jvm-opts ["-Dclojure.core.async.go-checking=true"
"-XX:-OmitStackTraceInFastThrow"
"--illegal-access=warn"]
;; the last one is relevant to this particular piece of debugging so that
;; _all_ illegal reflective access warnings are shown, not just the last
;;
;; the stacktrace option ensures the JVM doesn't optimize away stack traces
;; for commonly thrown exceptions (such as NPE)
@seancorfield
seancorfield / stacktrace.txt
Created Sep 13, 2018
Stacktrace from Boot pod -- clearly dynapath does NOT have a syntax error!
View stacktrace.txt
Exception in thread "Thread-81" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at clojure.lang.RT.classForName(RT.java:2204)
at clojure.lang.RT.classForName(RT.java:2213)
at clojure.lang.RT.loadClassForName(RT.java:2232)
at clojure.lang.RT.load(RT.java:450)
at clojure.lang.RT.load(RT.java:426)
at clojure.core$load$fn__6653.invoke(core.clj:6071)
at clojure.core$load.invokeStatic(core.clj:6070)
@seancorfield
seancorfield / stacktrace.txt
Created Jul 19, 2018
Stacktrace from Boot pod failure with Clojure 1.10.0-alpha6
View stacktrace.txt
java.lang.Thread.run Thread.java: 745
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 617
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1142
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/binding-conveyor-fn/fn core.clj: 2022
boot.core/boot/fn core.clj: 1031
boot.core/run-tasks core.clj: 1021
boot.user$eval1637$fn__1638$fn__1647$fn__1648.invoke : 663
@seancorfield
seancorfield / README.md
Last active Jan 6, 2020
map-vals and map-keys
View README.md

Running this code:

clj -Sdeps '{:deps 
             {seancorfield/map-utils 
              {:git/url "https://gist.github.com/seancorfield/6e8dd10799e9cc7527da5510c739e52f"
               :sha "cfde3c2c83379e93ab1a49752611ae663008129f"}}}'

That starts a REPL:

user=> (require '[map-utils :refer [map-vals map-keys]])
@seancorfield
seancorfield / adam.clj
Created Mar 24, 2017
Example of closures in Clojure
View adam.clj
(defn do-it []
(let [a ["a" "b" "c"]
b ["x" "y" "z"]
counter (atom 0)]
(run! (fn [foo]
(reset! counter 0)
(run! (fn [bar]
(swap! counter inc)
(println {:counter @counter
:foo foo
@seancorfield
seancorfield / async_pmap.clj
Created Jul 14, 2016 — forked from drewolson/async_pmap.clj
pmap using core.async
View async_pmap.clj
(ns async-example.core
(:require [clojure.core.async :refer [chan go >! <!!]])
(:gen-class))
(defn my-pmap [f col]
(let [chans (repeatedly (count col) chan)]
(doseq [[c e] (map vector chans col)]
(go (>! c (f e))))
(map <!! chans)))
View gist:8f62615233244820c8db
(ns example
(:require [reagent.core :as r :refer [atom]]
[reagent.cursor :as c]))
(defn input [prompt val]
[:div
prompt
[:input {:value @val
:on-change #(reset! val (.-target.value %))}]])
@seancorfield
seancorfield / gist:8285619
Created Jan 6, 2014
replaceNoCase() failure example
View gist:8285619
<cfprocessingdirective pageencoding="utf-8">
<cfoutput>
#replaceNoCase("LİELİELİELİE....","E","a very long string to replace E","all")#
</cfoutput>
@seancorfield
seancorfield / gist:8232204
Created Jan 3, 2014
Testing CFML's isClosure() and isCustomFunction() decision functions with function expressions as arguments.
View gist:8232204
<cfscript>
writeOutput("closure? " & isClosure(function() { return "yes"; }));
writeOutput("function? " & isCustomFunction(function() { return "no"; }));
</cfscript>
View gist:3222856
(ns webdriver.expectations.arab-slideshow
(:require [clj-webdriver.taxi :refer :all]
[expectations.scenarios :refer [expect scenario]]))
(scenario
(set-driver! {:browser :firefox} "http://dv.arablounge.com/login/logout"))
(scenario
(to "http://dv.arablounge.com/login")
(expect "Arab Dating" (text ".footer p a"))