Skip to content

Instantly share code, notes, and snippets.

@cemerick
cemerick / wordnik-links.user.js
Last active March 12, 2016 00:07
greasemonkey script that links all words in wordnik definitions to their corresponding wordnik page
@cemerick
cemerick / scratch.clj
Last active November 11, 2015 17:32 — forked from anonymous/scratch.clj
user=> (require 'cemerick.splice.rank)
nil
user=> (in-ns 'cemerick.splice.rank)
#<Namespace cemerick.splice.rank>
cemerick.splice.rank=> low
#cemerick.splice.rank.Rank[0]
cemerick.splice.rank=> high
#cemerick.splice.rank.Rank[2047]
cemerick.splice.rank=> (between low high)
#cemerick.splice.rank.Rank[1023]
@cemerick
cemerick / gist:59c1d2ed6067fe2be9cb
Created July 13, 2015 18:31
ls /etc/fonts/conf.d/
chas@t440p:~$ ls /etc/fonts/conf.d/
10-antialias.conf 58-dejavu-lgc-sans-mono.conf 70-no-bitmaps.conf
10-hinting.conf 58-dejavu-lgc-serif.conf 80-delicious.conf
10-hinting-slight.conf 60-latin.conf 89-tlwg-garuda-synthetic.conf
10-scale-bitmap-fonts.conf 64-01-tlwg-kinnari.conf 89-tlwg-kinnari-synthetic.conf
11-lcdfilter-default.conf 64-02-tlwg-norasi.conf 89-tlwg-loma-synthetic.conf
20-unhint-small-dejavu-lgc-sans.conf 64-11-tlwg-waree.conf 89-tlwg-umpush-synthetic.conf
20-unhint-small-dejavu-lgc-sans-mono.conf 64-12-tlwg-loma.conf 89-tlwg-waree-synthetic.conf
20-unhint-small-dejavu-lgc-serif.conf 64-13-tlwg-garuda.conf 90-fonts-nanum.conf
20-unhint-small-dejavu-sans.conf 64-14-tlwg-umpush.conf 90-fonts-unfonts-core.conf
; compilers are cool
(when-let [missing-methods (->> possible-dispatch-values
(map #(when-not (get-method multimethod %) %))
(filter identity)
seq)]
(throw (ex-info "Missing methods for `multimethod`" {:dispatch-vals missing-methods})))
@cemerick
cemerick / user.clj
Last active August 29, 2015 14:21
user.clj to recover pre-1.7.0 printing of Objects and Throwables in the REPL
; add to your user.clj to recover pre-1.7.0 printing of Objects and Throwables in the REPL
; https://github.com/clojure/clojure/blob/master/changes.md#17-printing-as-data
(in-ns 'clojure.core)
; from 1242c48
(defn- print-object [o, ^Writer w]
(when (instance? clojure.lang.IMeta o)
(print-meta o w))
(.write w "#<")
@cemerick
cemerick / repl_interaction.txt
Created April 26, 2015 01:12
using cljs.jar + nREPL + piggieback
chas@t440p:~/Downloads$ java -cp cljs.jar:/home/chas/.m2/repository/org/clojure/tools.nrepl/0.2.10/tools.nrepl-0.2.10.jar:/home/chas/.m2/repository/com/cemerick/piggieback/0.2.1/piggieback-0.2.1.jar clojure.main nrepl_piggieback.clj &
nREPL server running on port 7888
# using Leiningen here _only_ to connect to the running nREPL server
# any nREPL client will do
chas@t440p:~/Downloads$ lein repl :connect 7888
Connecting to nREPL at 127.0.0.1:7888
REPL-y 0.3.5, nREPL 0.2.10
Clojure 1.7.0-beta1
foo=> (defn x [y] (+ 5 y))
"(defn x [y] (+ 5 y))"
"ns-form?" false
Type Error (/tmp/form-init580281525933880320.clj) Static method clojure.lang.Numbers/add could not be applied to arguments:
Domains:
java.lang.Long java.lang.Long
java.lang.Double java.lang.Double
clojure.core.typed/AnyInteger clojure.core.typed/AnyInteger
@cemerick
cemerick / gist:0556998b37ec4ab07c1d
Created March 17, 2015 09:41
newly-refactored ClojureScript (0.0-3058+) REPLs work well over nREPL in a terminal environment
$ lein repl
nREPL server started on port 50811 on host 127.0.0.1 - nrepl://127.0.0.1:50811
REPL-y 0.3.2, nREPL 0.2.3
Clojure 1.6.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_40-b25
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
@cemerick
cemerick / gist:6cc2a276f34177ebf52b
Created March 9, 2015 17:46
quartz scheduling job name / key leak
; CIDER 0.6.0alpha (package: 0.5.0) (Clojure 1.6.0, nREPL 0.2.3)
=> (schedule #(println "foo"))
=> (schedule #(println "foo"))
=> (schedule #(println "foo"))
...
=> (def s (immutant.scheduling.internal/scheduler {}))
#<Var@5f67764a:
#<QuartzScheduling org.projectodd.wunderboss.scheduling.QuartzScheduling@450109d4>>
; scheduled job names (and thus their JobKeys) are retained, even if they're not repeating
(define-pass optimize-direct-call L0 [x] L0
[]
{Expr
[[((fn [x*] e*) e1*)
(== (count x*) (count e1*))
`(let [~@(interleave x* e1*)] ~@e*)]]}
(Expr x))
lang> (optimize-direct-call '((fn [a b] _) 1 2))
(clojure.core/let [a 1 b 2] _)