Skip to content

Instantly share code, notes, and snippets.

View seancorfield's full-sized avatar

Sean Corfield seancorfield

View GitHub Profile
(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"))
@seancorfield
seancorfield / gist:1064231
Created July 5, 2011 03:57
find-by-keys, built on clojure.java.jdbc
(def q
"Convert keyword to MySQL quoted entity name."
(partial sql/as-quoted-identifier \`))
(def qi
"Naming strategy for MySQL quoting and no lowercasing in results."
{ :entity (partial sql/as-quoted-str \`) :keyword identity })
(defn find-by-keys
"Given a table name (string) and a map of key/value pairs,
@seancorfield
seancorfield / adam.clj
Created March 24, 2017 17:28
Example of closures in Clojure
(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 / stacktrace.txt
Created July 19, 2018 23:47
Stacktrace from Boot pod failure with Clojure 1.10.0-alpha6
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 / stacktrace.txt
Created September 13, 2018 22:38
Stacktrace from Boot pod -- clearly dynapath does NOT have a syntax error!
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 / deps.edn
Last active June 10, 2020 20:33
Debugging Reflection Warnings
;; 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 / sean.clj
Last active August 25, 2021 17:00
Polylith dependency checker
(ns sean
"Placeholder for any dev-specific code I want to write."
(:require [clojure.java.io :as io]
[clojure.set :as set]
[clojure.string :as str]
[clojure.tools.deps.alpha :as t]))
(set! *warn-on-reflection* true)
(defn- libs-from-deps
@seancorfield
seancorfield / README.md
Last active October 28, 2022 04:11
map-vals and map-keys

NOTE: Clojure 1.11 Alpha 2 added update-keys and update-vals which provide similar functionality directly in clojure.core, but with the hash map first and the function second.

Running this code:

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

That starts a REPL: