Skip to content

Instantly share code, notes, and snippets.

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
slime-one-line-ify(nil)
slime-insert-xrefs((("(No location)" nil)))
slime-show-xref-buffer((("(No location)" nil)) :calls "function1" "namespace1")
slime-show-xrefs((("(No location)" nil)) :calls "function1" "namespace1")
@senior
senior / gist:817497
Created February 8, 2011 23:07
Macro/AOT Issue
(defmacro match-record
([matches expr]
`(match-record ~matches ~expr nil))
([[record in] expr fail-expr]
(println "Multimethods "(methods record-matcher) " class " (class record))
(println "Record matcher " (record-matcher record) " class record " (class record))
`(if-match [~(record-matcher record) ~in] ~expr ~fail-expr)))
(match-record [(new-baz {:bar ?e} ) nil]
(some #(match-record [(new-baz {:bar false}) %] true) e))
@senior
senior / gist:843940
Created February 25, 2011 15:31
defroutes example
(defroutes admin-app
(GET "/sparql-ui" [query]
(if query
(let [result (dostuff)]
{:body (apply str (template query result))})
{:body (apply str (template nil nil))}))
(route/not-found "<h1>Page not found</h1>"))
@senior
senior / gist:4983149
Last active December 13, 2015 22:18
gmatche from Practical core.logic - ClojureWest 2012
(defn lvarify
"Using _ for don't care types of values works fine when using the matche and conde
macros directly, but not as well when other macros wrap it. This will walk a list,
looking for _ values and swapping them for new logic variables. This translates into
the same don't care values when using conde/matche directly."
[sym-list]
(vec (map #(if (= % '_)
`(lvar)
%)
sym-list)))
@senior
senior / dbg
Created February 23, 2013 15:31
(defmacro dbg (form)
(let ((res (make-symbol "res"))
(dbg-str (make-symbol "dbg-str")))
`(progn
(let ((,res ,form))
(let ((,dbg-str (concat
(prin1-to-string "Debugging--> ")
(prin1-to-string ',form)
(prin1-to-string "\n = ")
@senior
senior / lazy-dog
Last active December 14, 2015 11:59
lazy-dog
(defn lazy-dog
"Like concat or lazy-cat but does not realize the outer seq"
[coll]
(concat
(first coll)
(lazy-seq
(when-let [more (next coll)]
(lazy-dog more)))))
(defn make-lazy-seq [end]
@senior
senior / gist:6707884
Last active December 23, 2015 23:09 — forked from kbarber/gist:6703697
On the host system
-------------------
* Install the net-scp ruby gem: sudo gem install net-scp
* Install the json gem:
** The gem needs to build a native extension, tell it where Xcode Command Line Tools is: sudo xcode-select -switch /Library/Developer/
** Xcode CLT doesn't include xcrun, fake one with the script here: http://stackoverflow.com/questions/13041525/osx-10-8-xcrun-no-such-file-or-directory
** should be ready to build now: sudo gem install json
* sudo gem install systemu
* git clone git://github.com/puppetlabs/puppet-acceptance.git
* cd puppet-acceptance
@senior
senior / gist:6935402
Last active December 25, 2015 06:49
with-redefs is global
(defn inc-it [x] (+ x 1))
(let [hand-off-queue (java.util.concurrent.SynchronousQueue.)
f1 (future-call
(fn []
(with-redefs [inc-it (fn [x] (- x))]
(.put hand-off-queue "foo")
(inc-it 10))))
f2 (future-call
(fn []
-[ RECORD 1 ]--+------------------------------
datid | 17413
datname | puppetdb
numbackends | 13
xact_commit | 238
xact_rollback | 2
blks_read | 314
blks_hit | 30109
tup_returned | 68458
tup_fetched | 16072
@senior
senior / slingshot.clj
Last active October 8, 2017 19:03
Slingshot Basics
(ns com.puppetlabs.test.slingshot
(:require [slingshot.slingshot :refer [try+ throw+]]
[slingshot.support :refer [wrap]]
[slingshot.test]
[clojure.test :refer :all]
[clojure.pprint]
[clojure.stacktrace :as st]
[spyscope.core]))
(defn wrapped? [^Throwable t]