Skip to content

Instantly share code, notes, and snippets.

View austinhaas's full-sized avatar

Austin Haas austinhaas

View GitHub Profile
@austinhaas
austinhaas / gist:9279237
Created February 28, 2014 20:32
How to catch errors and display a stacktrace from within a core.async thread.
(let [out *out*]
(thread
(binding [*out* out
*err* out]
(try
(your-code-here)
(catch Throwable e (clojure.repl/pst e))))))
@austinhaas
austinhaas / findall.clj
Created May 9, 2013 04:54
core.logic findall sketch
(ns pettomato.findall
(:refer-clojure :exclude [==])
(:use
[clojure.core.logic.protocols])
(:require
[clojure.core.logic :refer :all]))
(defn findall
"A goal that unifies l with a lazy sequence containing all possible
instantiations of v that could be generated by applying the goal g
(ns test
(:refer-clojure :exclude [==])
(:require
[clojure.core.logic :refer :all]))
(defn foo [in out]
(matcha
[in out]
([('and a b . ()) ('and x y . ())] (foo a x) (foo b y))
([a ('bar ('baz a . ()) . ())])))
(ns replo
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]))
(defn replo
"A relation between two sequences in and out, such that out is the
same as in, except that all occurences of k have been replaced with
@austinhaas
austinhaas / core.clj
Created September 4, 2012 23:53
Using virtual hosts with Clojure and Jetty
;;; This is my first pass at setting up virtual hosts; it works, but there is room for improvement.
;;; dependencies
;;[ring "1.1.5"]
;;[javax.servlet/servlet-api "2.5"]
;;[org.eclipse.jetty/jetty-server "7.6.1.v20120215"]
;;[org.eclipse.jetty/jetty-servlet "7.6.1.v20120215"]
(ns app.core
(:require [ring.util.servlet :refer (servlet)]