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
(deftest test-store-if-not-modified | |
(let [bucket-name "clojurewerkz.welle.kv" | |
key "none-modified-key" | |
_ (kv/store bucket-name key "value1") | |
res (kv/fetch-one bucket-name key) | |
tstamp (:last-modified res) | |
_ (kv/store bucket-name key "value2") | |
_ (kv/store bucket-name key "value3" | |
:last-modified (.getTime tstamp) | |
:if-not-modified true) |
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
(require '[com.mefesto.wabbitmq :as mq] | |
'[com.mefesto.wabbitmq.content-type :as ct]) | |
(def broker | |
{:host "localhost" | |
:username "guest" | |
:password "guest" | |
:virtual-host "/"}) | |
(def queue (mq/publish-queue)) |
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
(let [name "test" num 5] | |
(cond | |
(and (= "test" name) (= num 5)) | |
(do-this) | |
(or (= "that" name) (full-moon?) (wednesday?)) | |
(do-that) | |
:else | |
(do-other))) |
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- wrap-log [handler] | |
(fn [req] | |
(log "uri: " (:uri request)) | |
(handler req))) |
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
(ns myapp.middleware) | |
(defn wrap-content-type [handler content-type] | |
(fn [req] | |
(let [res (handler req)] | |
(if-not (contains? (:headers req) "Content-Type") | |
(assoc-in res [:headers "Content-Type"] content-type) | |
res)))) |
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
(import [org.apache.commons.dbcp BasicDataSource]) | |
(require '[clojure.java.jdbc :as sql]) | |
(def ds | |
(doto (BasicDataSource.) | |
(.setDriverClassName "oracle.jdbc.driver.OracleDriver") | |
(.setUrl "jdbc:oracle:thin:@localhost:1521:sstest") | |
(.setUsername "testuser") | |
(.setPassword "testpass"))) |
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
$ JVM_OPTS="-server -Xms512m -Xmx512m" lein run |
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
(deftype MyType [x] | |
clojure.lang.IFn | |
(invoke [this y] | |
(+ x y))) | |
user> (def z (MyType. 2)) | |
#'user/z | |
user> (z 3) | |
5 |
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 wrap-codepage [handler] | |
(fn [request] | |
(handler (assoc-in request [:headers :content-type] "text/html; charset=utf-8")))) |
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
(let [method (.getMethod Long "parseLong" (into-array Class [String Integer/TYPE]))] | |
(.invoke method Long (into-array Object ["101" 2]))) |
NewerOlder