This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn without-results | |
"Stop the query returning results." | |
[query] | |
(dissoc query :results)) | |
; Example | |
(insert log without-results (values [{:foo 1 :bar 2}])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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" |