This file contains hidden or 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 [index (default :ttl 300 (update-index (index)))] | |
(streams | |
(where (tagged "nginx") | |
#(info "nginx" %) | |
(with {:metric 1.0 | |
:service "nginx.reqs.second"} | |
(by [:host] | |
(rate 5 index #(info "rate" %))))) |
This file contains hidden or 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
ContentTypes = ["text/html" => "html", | |
"text/html; charset=utf-8" => "html", | |
"image/png" => "image", | |
"image/jpeg" => "image", | |
"image/gif" => "image", | |
"text/css" => "css", | |
"application/x-javascript; charset=utf-8" => "js", | |
"-" => "unknown", | |
"application/json; charset=utf-8" => "js", | |
"application/font-woff" => "font", |
This file contains hidden or 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
(map (comp #(read-str % :key-fn keyword) #(String. %) :data #(data c (str "/brokers/ids/" %))) (children c "/brokers/ids")) |
This file contains hidden or 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 abs [x] | |
(if (neg? x) | |
(- x) | |
x)) | |
(defn session-id | |
([x] x) | |
([x y] (if (> (abs (- x y)) | |
*threshold*) | |
(max x y) |
This file contains hidden or 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
$ brew install unixodbc | |
$ brew tap pingles/homebrew-psqlodbc | |
$ brew install psqlodbc | |
# can now check the connection... | |
$ isql -v redshiftodbc | |
+---------------------------------------+ | |
| Connected! | |
This file contains hidden or 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(redshift) | |
conn <- redshift.connect("jdbc:postgresql://mycluster.redshift.amazonaws.com:5439/data", "user", "pass") | |
# we can retrieve a list of tables | |
tables <- redshift.tables(conn) | |
# and get some info about the columns in one of those tables | |
cols <- redshift.columns(conn, "weblog") |
This file contains hidden or 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 if-let-multi-bind.core) | |
(defmacro if-let* | |
([bindings then] | |
`(if-let* ~bindings ~then nil)) | |
([bindings then else & oldform] | |
(let [test (cons #'and (map last (partition 2 bindings)))] | |
`(if ~test | |
(let ~bindings | |
~then) |
This file contains hidden or 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 '[langohr.consumers :as lcm]) | |
(lcm/subscribe ch "images.resize" | |
(fn [ch metadata ^bytes payload] | |
(println (format "[consumer] %s received %s" | |
username | |
(String. payload "UTF-8")))) | |
:auto-ack true) |
This file contains hidden or 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 subscriber-seq | |
[ch qname] | |
(let [[message-seq put] (pipe)] | |
(letfn [(message-handler [ch msg-meta payload]) | |
(put {:ch ch :msg-meta msg-meta :payload payload})] | |
(lc/subscribe ch qname message-handler :auto-ack true)) | |
message-seq)) | |
(defn payload-str | |
[x] |
This file contains hidden or 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 json-payload | |
[_ _ payload] | |
(read-json (String. payload "UTF-8"))) | |
(defn subscriber-seq | |
[ch qname handler] | |
(let [[message-seq put] (pipe)] | |
(lc/subscribe ch qname (comp put handler) :auto-ack true) | |
message-seq)) |