Skip to content

Instantly share code, notes, and snippets.

View weavejester's full-sized avatar

James Reeves weavejester

View GitHub Profile
#!/bin/bash
#
# Bash script to automatically run a test suite every time a file is modified
# in the src or test directories. Plays a sound file to tell the user what's
# happening in an unobtrusive fashion.
PLAY="mplayer -really-quiet -nolirc"
while true; do
# Wait until a file has been changed
(ns flockr
(:use compojure))
(defn index []
(html
[:h1 "Flockr"]
[:h2 "Twitter Portal"]))
(defservlet home
(GET "/"
(ns flockr.template
(:use compojure))
(defn page
[title body]
(html
[:html
[:head
[:title title]]
[:body
(ns flockr
(:use compojure )
(:use flockr.template)) ; looks for flockr/template.clj
(defn twitter-status
[tweet]
[:p.tweet
[:div.tweet-text (tweet "text")]
[:div.tweet-user (get-in tweet ["user" "name"])]])
(ns compojure.openid
"Compojure OpenID wrapper around jopenid library."
(:use compojure.control)
(:use compojure.encodings)
(:use compojure.http)
(:use compojure.http.session)
(:import com.javaeedev.openid.OpenIdManager)
(:import javax.servlet.http.HttpServletRequest))
(defn- make-manager
(defn- lex-1
"Lex one symbol from a string, and return the symbol and trailing source."
[src clauses]
(some
(fn [[re action]]
(let [matcher (re-matcher re src)]
(if (.lookingAt matcher)
[(if (fn? action) (action matcher) action)
(.substring src (.end matcher))])))
(partition 2 clauses)))
(ns example
{:deps ("weavejester/hello-world/1.0"
"weavejester/compojure/0.3.1")}
(:use weavejester.hello-world))
(hello-world)
(ns #^{:deps "weavejester/compojure/0.3.1"}
example
(:use compojure))
(defmacro with-ns [ns & body]
`(binding [*ns* (the-ns ~ns)]
~@(map (fn [form] `(eval '~form)) body)))
(with-ns 'clojure.core
(def in-ns* in-ns)
(defn in-ns [name]
(doseq [dep (-> name meta :deps)]
(capra.package/install dep))
(in-ns* name)))