Skip to content

Instantly share code, notes, and snippets.

@coxchen
coxchen / gist:b6e7ca706a0f37a53031
Last active August 29, 2015 14:02
Adopt Graph (Plumbing) for complex task definition in RestBot
(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)
@coxchen
coxchen / gist:611e5ec176d53b01e18e
Last active August 29, 2015 14:03
refactor API definition
(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
coxchen / restbot-elasticsearch-ttl.clj
Last active August 29, 2015 14:15
testing ElasticSearch _ttl using restbot
;;;;;;;;;;;;;;;;;;;;
;; MAPPINGs
;;;;;;;;;;;;;;;;;;;;
(def mapping-log
{:log {:_ttl {:enabled true
:default "2h"}
:_timestamp {:enabled true
:path "log_time"}
:properties {:log_time {:type "date"}
;; gorilla-repl.fileformat = 1
;; **
;;; # Clojure for Brave and True
;;;
;;; ## CH5 Exercises
;; **
;; @@
(ns braveclojure-ch5)
;; gorilla-repl.fileformat = 1
;; **
;;; # Play Data
;; **
;; @@
(ns play-data
(:require [gorilla-plot.core :as plot]
[gorilla-repl.table :refer [table-view]]
(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!)