Skip to content

Instantly share code, notes, and snippets.

View har-specter.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Play Data
;; **
;; @@
(ns play-data
(:require [gorilla-plot.core :as plot]
[gorilla-repl.table :refer [table-view]]
View process-chrome-har-specter.clj
(defmacro collect-all [collections]
(into [] (concat ['ALL] (for [c collections]
(if (and (sequential? c) (keyword? (first c)))
`(~'collect-one ~@c)
`(~'collect-one ~c))))))
(defn process-har [requests & {:keys [view-with selection] :or {view-with count selection [ALL]}}]
(->> (select-one [:log :entries] requests)
(select [ALL (selected? :request :url sz-api?)])
(transform [ALL :request :url] sz-api!)
View braveclojure-ch5.clj
;; gorilla-repl.fileformat = 1
;; **
;;; # Clojure for Brave and True
;;; ## CH5 Exercises
;; **
;; @@
(ns braveclojure-ch5)
coxchen / restbot-elasticsearch-ttl.clj
Last active Aug 29, 2015
testing ElasticSearch _ttl using restbot
View restbot-elasticsearch-ttl.clj
(def mapping-log
{:log {:_ttl {:enabled true
:default "2h"}
:_timestamp {:enabled true
:path "log_time"}
:properties {:log_time {:type "date"}
coxchen / gist:611e5ec176d53b01e18e
Last active Aug 29, 2015
refactor API definition
View gist:611e5ec176d53b01e18e
(defprotocol ApiBuilder
(-req [this apiOpts]))
(defn- replace-with-param
[basestr param]
(clojure.string/replace basestr
(re-pattern (str "\\{" (name (first param)) "\\}"))
(str (second param))))
(defn apply-api-params
coxchen / gist:b6e7ca706a0f37a53031
Last active Aug 29, 2015
Adopt Graph (Plumbing) for complex task definition in RestBot
View gist:b6e7ca706a0f37a53031
(use 'plumbing.core)
(require '[plumbing.graph :as graph])
(use '[restbot core utils])
(defn- make-task-graph
[specs serverSym authSym]
(reduce merge
(for [[specKey specParam specBody] (partition 3 specs)]
{specKey (cons 'fnk
(list (conj specParam serverSym authSym)