Skip to content

Instantly share code, notes, and snippets.

(send-message ^{:host "mail.isp.net"}
{:from "me@draines.com"
:to "foo@example.com"
:subject "Hi!"
:body [:related
{:type "text/html"
:content "<b>Test!</b>"}
;;;; supports both dispositions:
{:type :attachment
:content (java.io.File. "/tmp/foo.txt")}
(defrecord Fragment [t p1 p2])
(defprotocol FragmentProtocol
(t [fragment] "Return the type.")
(switch-type [fragment] "Switch type."))
(deftype TypeFragment [f-type p1 p2]
FragmentProtocol
(t [this] f-type)
(switch-type [this] (TypeFragment. (if (= f-type :type-a) :type-a :type-b) p1 p2)))
@kirasystems
kirasystems / gist:2946182
Created June 18, 2012 00:40
without-results function
(defn without-results
"Stop the query returning results."
[query]
(dissoc query :results))
; Example
(insert log without-results (values [{:foo 1 :bar 2}]))
(defn str-template
[s & args]
(fn [params]
(apply format s ((apply juxt args) params))))
user=> (def t1 (str-template "My name is %s, my id is %s" :firstname :ssn))
#'user/t1
user=> (t1 {:firstname "John" :lastname "Doe" :ssn "111111" })
"My name is John, my id is 111111"