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
java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String | |
AFunction.java:39 clojure.lang.AFunction.compare | |
Arrays.java:1270 java.util.Arrays.mergeSort | |
Arrays.java:1210 java.util.Arrays.sort | |
core.clj:2339 clojure.core/sort | |
core.clj:2335 clojure.core/sort | |
debugging.clj:62 apij.debugging/report-log-status | |
debugging.clj:98 apij.debugging/show-logging | |
response.clj:29 compojure.response/eval5394[fn] | |
response.clj:7 compojure.response/eval5363[fn] |
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 http-agent | |
(:import | |
(java.net URL | |
HttpURLConnection) | |
(java.io InputStreamReader | |
BufferedReader | |
InputStream))) | |
(defn GET | |
[{:keys [url on-success on-fail]}] |
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 [res (atom nil) | |
response-future (medusa/medusa-future | |
;; logging the result of client/post shows the correct value | |
(swap! res (fn [_] | |
(client/post config/rtd-url | |
{:headers default-headers | |
:body xml })))] | |
;; this yields nil | |
(.get response-future 3000 java.util.concurrent.TimeUnit/MILLISECONDS) |
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 [candidates [{:udicode 1} {:udicode 2} {:udicode 3} {:udicode 4} {:udicode 1} {:udicode 9} {:udicode 20}] | |
result (atom #{}) | |
filters [#(not (@result %)) | |
#(< (:udicode %) 10)] | |
include? (fn [h] | |
(if (every? #(% h) filters) | |
(swap! result conj h)))] | |
(take 7 (filter include? candidates))) | |
;; using juxt and reduce for applying the filters: |
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
;; Provides the ability to use :pre and :or options to defrecord via a constructor function. | |
;; The constructor function is named new-X, where X is the name passed into (defrecord+ X ...) | |
(defmacro defrecord+ | |
[name fields & etc] | |
(let [[[{:as opts}] etc] | |
(if (map? (first etc)) | |
(split-at 1 etc) | |
[nil etc]) |
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 l-split-with [i pred] | |
(lazy-seq (loop [in i out []] | |
(if-let [f (first in)] | |
(if (pred f) | |
(list out in) | |
(recur (rest in) (conj out f))))))) | |
(l-split-with [1 2 3 4 :true true] keyword?) | |
; => | |
'([1 2 3 4] (:true 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
(defn divisions [n t] | |
(loop [nn n nt t z []] | |
(let [q (quot nn nt) nz (concat z [q])] | |
(if (> nt 1) | |
(recur (- nn q) (dec nt) nz) | |
nz)))) | |
(divisions 10 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
(defn de2 [x n] | |
(concat | |
(map (constantly (int (quot x n))) (range (- n 1))) | |
[(int (java.lang.Math/ceil (/ x n)))])) | |
(de2 7 2) | |
(de2 10 2) | |
(de2 10 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 de [x n] | |
(loop [x x nr (vec (range 1 (+ n 1))) z []] | |
(let [q (quot x (last nr))] | |
(if-let [xx (not-empty (subvec nr 0 (- (count nr) 1)))] | |
(recur (- x q) xx (concat z [q])) | |
(concat z [q]))))) | |
(de 8 2) | |
(de 7 3) | |
(de 7 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
(facts "/locations/:id/rates should limit the rate response count by the :limit param" | |
(let [limit 3 | |
params [:check_in (gen-check-in) | |
:check_out (gen-check-out) | |
:guests 1 | |
:rooms 1 | |
:limit limit]] | |
(apply location-rate-request (:tid location-one) params) => truthy | |
(provided | |
(apij.models.hotel-search/search |