Add start function

Add start function

--- src/overtone_workspace/grunbles.clj
+++ src/overtone_workspace/grunbles.clj
@@ -179,14 +179,29 @@
           (schedule-pattern beat-t beat-sep-t sound beat-info)
           (at beat-t (when beat-info (apply sound (flatten1 beat-info)))))))))

+(def live-sequencer-states {})
+(def *live-sequencer-states (atom live-sequencer-states))
+
 (defn live-sequencer
+  [curr-t pat-dur live-patterns uid]
+  (let [running (@*live-sequencer-states uid)]
+    (when running
+      (doseq [[sound pattern] @live-patterns]
+        (schedule-pattern curr-t pat-dur sound pattern))
+      (let [new-t (+ curr-t pat-dur)]
+        (apply-by new-t #'live-sequencer [new-t pat-dur live-patterns uid]))
+      )))
+
+(defn start-live-sequencer
   [curr-t pat-dur live-patterns]
-  (doseq [[sound pattern] @live-patterns]
-    (schedule-pattern curr-t pat-dur sound pattern))
-  (let [new-t (+ curr-t pat-dur)]
-    (apply-by new-t #'live-sequencer [new-t pat-dur live-patterns])))
+  (let [uid (trig-id)]
+    (swap! *live-sequencer-states assoc uid true)
+    (live-sequencer curr-t pat-dur live-patterns uid)
+    uid
+    ))

 (def a {:rate 2 :amp 0.1 :time-scale-max 5})
+(def a {:rate 10 :amp 0.1 :time-scale-max 10})
 (def a {:rate 100 :amp 0.4 :time-scale-max 5})
 (def b {:pan -1 :freq 1000})
 (def c {:freq 25000 :amp 0.2})
@@ -233,14 +248,14 @@
   (let [ms-per-pattern (* 1000 dur-per-pattern)]
     ;;(live-sequencer (now) ms-per-pattern *beats)
     ;; (live-sequencer (metro (inc (metro))) ms-per-pattern *beats))
-    (live-sequencer (metro (next-beat (metro) 0 beat-per-pattern)) ms-per-pattern *beats))
+    (start-live-sequencer (metro (next-beat (metro) 0 beat-per-pattern)) ms-per-pattern *beats))
   (init-latchbell-mod (:rate @latchbell-arg))
   (apply-by (metro (- (next-beat (metro) 0 (* 8 beat-per-pattern)) 1/16))
             #'swap! [*beats assoc laserbeam [d _ _ [_ d d] (vec (repeat 64 0.5)) _ _ d _ _ d _ b _ _ [d d d]]])

-  (apply-by (metro (- (next-beat (metro) 0 (* 4 beat-per-pattern)) 1/16))
+  (apply-by (metro (- (next-beat (metro) 0 (* 8 beat-per-pattern)) 1/16))
             #'init-latchbell-mod [(:rate @latchbell-arg)])
-  (apply-by (metro (- (next-beat (metro) 0 (* 4 beat-per-pattern)) 1/16))
+  (apply-by (metro (- (next-beat (metro) 0 (* 8 beat-per-pattern)) 1/16))
             #'swap! [*beats assoc latchbell (vec (repeat 24 a))])

   (swap! *beats assoc laserbeam [d _ _ [d d] (vec (repeat 64 0.8)) _ _ d _ _ d _ b _ _ [d d d]])
@@ -280,6 +295,12 @@
     ;;(live-sequencer (now) ms-per-pattern *beats)
     ;; (live-sequencer (metro (inc (metro))) ms-per-pattern *beats))
     (live-sequencer (metro (next-beat (metro) 0 beat-per-pattern)) (* 16 ms-per-pattern) *beats16))
+  (let [ms-per-pattern (* 1000 dur-per-pattern)]
+    ;;(live-sequencer (now) ms-per-pattern *beats)
+    ;; (live-sequencer (metro (inc (metro))) ms-per-pattern *beats))
+    (start-live-sequencer (metro (next-beat (metro) 0 beat-per-pattern)) (* 16 ms-per-pattern) *beats16))
+  (print @*live-sequencer-states)
+  (swap! *live-sequencer-states assoc 3 false)
   (reset! *beats16 beats16))

@@ -292,4 +313,8 @@
   (odoc apply-by)
   (odoc apply-at)
   (odoc at-at)
+  (odoc trig-id)
+  (odoc on-trigger)
+  (odoc on-sync-trigger)
+  (odoc on-latest-trigger)
   )


hellhound-system macro added

hellhound-system macro added

--- src/clj/hellhound/system.clj
+++ src/clj/hellhound/system.clj
@@ -39,3 +39,11 @@
   `(defn ~system-name []
      (-> hellhound.component.core/default-system-structure
          ~@body)))
+
+(defmacro hellhound-system
+  "Define a system map with some pre defined components."
+  [system-name & body]
+  `(-> hellhound.core/default-system-structure
+       ;; TODO: Pass the options from config file
+       (hellhound.component.websocket/make-websocket-component {})
+       (hellhound.component.pedestal/make-pedestal-component {})))


Fix bad expressions.

Fix bad expressions.

--- src/cljam/util/intervals.clj
+++ src/cljam/util/intervals.clj
@@ -17,12 +17,11 @@
        (into (sorted-map))
        (->SortedMapIntervals)))

-(defn- find-nclist-overlap-intervals [^clojure.lang.Sorted nclist start end]
+(defn- find-nclist-overlap-intervals [nclist start end]
   (when-let [target-intervals
-             (and nclist
-                  (->> (subseq nclist  >= start)
-                       (map second)
-                       (take-while #(<= (:start (first %)) end))))]
+             (->> (subseq nclist  >= start)
+                  (map second)
+                  (take-while #(<= (:start (first %)) end)))]
     (mapcat #(cons (first %)
                    (find-nclist-overlap-intervals (second %)
                                                   start end))
@@ -33,24 +32,18 @@
   (find-overlap-intervals* [this start end]
     (find-nclist-overlap-intervals nclist start end)))

-(defn- compare-nclist [a b]
-  (let [res (Long/signum (- (:start a) (:start b)))]
-    (if (zero? res)
-      (Long/signum (- (:end b) (:end a)))
-      res)))
 (declare make-nclist*)

 (defn- make-nested-intervals [intervals]
-  (when (seq intervals)
-    (let [head (first intervals)
-          [nested-intervals rests]
-          (split-with #(<= (:start  head) (:start %) (:end %) (:end head))
+  (when-first [{:keys [start end] :as head} intervals]
+    (let [[nested-intervals rests]
+          (split-with #(<= start (:start %) (:end %) end)
                       (next intervals))]
-      (cons [(:end head) [head (make-nclist* nested-intervals)]]
+      (cons [end [head (make-nclist* nested-intervals)]]
             (lazy-seq (make-nested-intervals rests))))))

 (defn- make-nclist* [intervals]
-  (let [sorted-intervals (sort compare-nclist intervals)]
+  (let [sorted-intervals (sort-by (juxt :start (comp - :end)) intervals)]
     (into (sorted-map) (make-nested-intervals sorted-intervals))))

 (defn- make-nclist [intervals]
@@ -58,14 +51,16 @@

 (defn index-intervals
   "Make indexes for intervals to find overlaps."
-  [intervals {:keys [structure] :or {structure :sorted-map}}]
-  (->> intervals
-       (group-by :chr)
-       (into {} (map (fn [[k vs]]
-                       [k
-                        (case structure
-                          :sorted-map (make-sorted-map-intervals vs)
-                          :nclist (make-nclist vs))])))))
+  ([intervals]
+   (index-intervals intervals {}))
+  ([intervals {:keys [structure] :or {structure :sorted-map}}]
+   (->> intervals
+        (group-by :chr)
+        (into {} (map (fn [[k vs]]
+                        [k
+                         (case structure
+                           :sorted-map (make-sorted-map-intervals vs)
+                           :nclist (make-nclist vs))]))))))

 (defn find-overlap-intervals
   "Find intervals that are on the given `chr` and overlap the given interval


Improve input handling, and start fleshing out command stream behavior.

Input handling now matches a global input map, that can be updated, and returns those input maps.
`process-input` changed from loop to recursion, and works on a command-stream (currently a vector).

`update-world` now folds over this stream to update the target (hardcoded as the mesh, simply testing purposed.
-- I am trying to have this be something an actor will consume, updating it's FSM and other state as consumed, before advancing the world by timestep.

--- src/cljs/cljs_game/core.cljs
+++ src/cljs/cljs_game/core.cljs
@@ -5,40 +5,53 @@

 (def world (atom {}))

-(def command-queue (atom cljs.core/PersistentQueue.EMPTY))
+(def input-queue (atom cljs.core/PersistentQueue.EMPTY))
+
+(def input-mapping (atom
+                    { "w" {:type :input :action :up :target :player}
+                     "a" {:type :input :action :left :target :player}
+                     "s" {:type :input :action :down :target :player}
+                     "d" {:type :input :action :right :target :player}
+                     "i" {:type :input
+                          :action :info
+                          :target :none
+                          :execute (fn [] (println @world))}
+                     "p" {:type :input
+                          :action :pause
+                          :target :world
+                          :execute (fn [] (swap! world assoc :running
+                                                (not (@world :running))))}}))

 (defn handle-input [event]
   (let [key (.-key event)]
-    (swap! command-queue conj
-           (case key
-             "w" {:type :input :key :up}
-             "a" {:type :input :key :left}
-             "s" {:type :input :key :down}
-             "d" {:type :input :key :right}
-             "p" {:type :input :key :pause}))
-    (when (not (.-repeat event))
-      (print (.-repeat event)))))
+    (when (not (.-repeat event)))
+    (swap! input-queue conj (@input-mapping key))))

-(defn process-input []
-  (loop [attempts 10]
-    (let [command (peek @command-queue)]
-      (if command
-        ;; change? What if somethign else pops between above and below
-        ;; have function check if peek and item are same item, yay! then do pop
-        ;; else, recur w/o doing anything to try again.
-        (do (swap! command-queue pop)
-            (print command)
-            (when (and (= (command :type) :input)
-                       (= (command :key) :pause))
-              (swap! world assoc :running
-                     (not (@world :running))))
-            (recur (dec attempts)))))))
+(defn process-input [player-commands attempts]
+  (let [command (peek @input-queue)]
+    (if (and command (> attempts 0))
+      (do (swap! input-queue pop)
+          (process-input
+           (let [result
+                 (if (= :player (command :target))
+                   (conj player-commands command)
+                   (do ((command :execute))
+                       nil))]
+             (if result result player-commands))
+           (dec attempts)))
+      player-commands)))

 (defn update-world
   [delta-time]
-  (let [mesh (@world :mesh)]
-    (set! (.-x (.-rotation mesh)) (+ 0.01 (.-x (.-rotation mesh))))
-    (set! (.-y (.-rotation mesh)) (+ 0.02 (.-y (.-rotation mesh))))
+  (let [mesh (reduce (fn [mesh command]
+                       (cond
+                         (= :left (command :action)) (set! (.-x (.-rotation mesh)) (- (.-x (.-rotation mesh)) 0.01 ))
+                         (= :right (command :action)) (set! (.-x (.-rotation mesh)) (+ 0.01 (.-x (.-rotation mesh))))
+                         (= :up (command :action)) (set! (.-y (.-rotation mesh)) (- (.-y (.-rotation mesh)) 0.01))
+                         (= :down (command :action)) (set! (.-y (.-rotation mesh)) (+ 0.01 (.-y (.-rotation mesh)))))
+                       mesh)
+                     (@world :mesh) (@world :player-stream))]
+    (swap! world assoc :player-stream [])
     (swap! world assoc :mesh mesh)))

 (defn game-loop
@@ -47,7 +60,9 @@
         leftover-time (@world :accum-time)
         time-step 16.666666666666668]
     (swap! world assoc :prev-time now)
-    (process-input)
+    (let [player-stream (process-input nil 10)]
+      (swap! world assoc :player-stream (vec (concat (@world :player-stream)
+                                                     player-stream))))
     (when (@world :running)
       (swap! world assoc :leftover-time
              (loop [accumulated (+ leftover-time (- now prev))]
@@ -75,8 +90,10 @@
     (.setSize renderer js/window.innerWidth js/window.innerHeight)
     (js/document.body.appendChild (.-domElement renderer))
     (js/document.addEventListener "keydown" handle-input)
-    (swap! world assoc :prev js/Performance.now)
+    (swap! world assoc :prev-time js/Performance.now)
     (swap! world assoc :accum-time 0.0)
+    (swap! world assoc :player-stream [])
+    (swap! world assoc :running true)
     (let [animate (fn animate [current-time]
                     (js/requestAnimationFrame animate)
                     (game-loop current-time)


Pointless tidying

Pointless tidying

--- src/cljs/cloj/web/utils.cljs
+++ src/cljs/cloj/web/utils.cljs
@@ -5,6 +5,10 @@
     [dommy.core             :as dommy :include-macros true]  ))

 (defn id-ize   [v] (str "#" v))
-(defn by-id    [v] (-> (id-ize v) (dommy/sel1)))
+(defn by-id
+  ( [v] (-> (id-ize v) (dommy/sel1)) )
+  ( [v b] (->> (id-ize v) (dommy/sel1 b)) )
+
+  )
 (defn get-dims [e] (mapv e [:width :height]))
 (defn log-js   [v] (.log js/console v))


Get some sections started

Get some sections started

--- src/cljs/uberblick/core.cljs
+++ src/cljs/uberblick/core.cljs
@@ -76,6 +76,7 @@

 (defn PersonCard [user]
   [:div.z-depth-1 {:style {:max-width 100
+                          :margin 5
                            :text-align :center}}
    [:div {:style {:width 100
                   :height 100
@@ -84,8 +85,21 @@
                    :font-size 16}}
     (:FirstName user)]])

+(defn Floor [title users]
+  [:div
+   [:h3 title]
+   [:hr]
+   [:div {:style {:display :flex
+                  :flex-direction :row
+                  :flex-wrap :wrap}}
+    (for [u users]
+      [PersonCard  u])
+    [:br]]])
+
 (defn home-page []
-  [PersonCard Max])
+  [:div
+   [Floor "North 4th" [Max Max Max]]
+   [Floor "3rd Floor" (repeat 10 Max)]])

 (defn About
 "Take the readme, render it to HTML, and set it as the element!"


Updated async-post request call to new API.

--- src/cmr/http/kit/request.clj
+++ src/cmr/http/kit/request.clj
@@ -82,7 +82,7 @@
   ([url req options]
     (async-post url req options nil))
   ([url req options callback]
-    (request :post url req callback)))
+    (request :post url req options callback)))

 (defn get
   [& args]


fix #1804 - duplicated status in discover tab

--- src/status_im/ui/screens/accounts/events.cljs
+++ src/status_im/ui/screens/accounts/events.cljs
@@ -128,7 +128,7 @@

 (register-handler-fx
   :check-status-change
-  (fn [{:accounts/keys [accounts current-account-id]} [_ status]]
+  (fn [{{:accounts/keys [accounts current-account-id]} :db} [_ status]]
     (let [{old-status :status} (get accounts current-account-id)
           status-updated? (and (not= status nil)
                                (not= status old-status))]
@@ -150,9 +150,9 @@
       {:db                        (assoc-in db [:accounts/accounts current-account-id] new-account)
        ::save-account             new-account
        ::broadcast-account-update (merge
-                                    (select-keys db [:current-public-key :web3])
-                                    (select-keys new-account [:name :photo-path :status
-                                                              :updates-public-key :updates-private-key]))})))
+                                   (select-keys db [:current-public-key :web3])
+                                   (select-keys new-account [:name :photo-path :status
+                                                             :updates-public-key :updates-private-key]))})))

 (register-handler-fx
   :account-update-keys
@@ -166,9 +166,9 @@
       {:db                (assoc-in db [:accounts/accounts current-account-id] new-account)
        ::save-account     new-account
        ::send-keys-update (merge
-                            (select-keys db [:web3 :current-public-key :contacts])
-                            (select-keys new-account [:updates-public-key
-                                                      :updates-private-key]))})))
+                           (select-keys db [:web3 :current-public-key :contacts])
+                           (select-keys new-account [:updates-public-key
+                                                     :updates-private-key]))})))

 (register-handler-fx
   :send-account-update-if-needed
@@ -184,5 +184,6 @@
   :set-current-account
   (fn [{:accounts/keys [accounts] :as db} [_ address]]
     (let [key (:public-key (accounts address))]
-      (assoc db :accounts/current-account-id address
-                :current-public-key key))))+      (assoc db
+             :accounts/current-account-id address
+             :current-public-key key))))


Optimize the code for cleaners

Optimize the code for cleaners

--- src/cyanite_fetcher/core.clj
+++ src/cyanite_fetcher/core.clj
@@ -33,20 +33,11 @@
     "path = ? AND tenant = ? AND rollup = ? AND period = ? "
     "AND time >= ? AND time <= ? ORDER BY time ASC;")))

-(defn remove-cleaner
-  "Remove cleaner."
-  [data]
-  (println "Cleaning data with remove cleaner...")
-  (let [cdata (time (doall (remove nil? data)))]
-    (println "Number of rows:" (count cdata))
-    (println)
-    cdata))
-
-(defn rremove-cleaner
-  "R/remove cleaner."
-  [data]
-  (println "Cleaning data with r/remove cleaner...")
-  (let [cdata (time (doall (into [] (r/remove nil? data))))]
+(defn cleaner
+  "Cleaner."
+  [data f name]
+  (println (format "Cleaning data with %s..." name))
+  (let [cdata (time (doall (f data)))]
     (println "Number of rows:" (count cdata))
     (println)
     cdata))
@@ -236,8 +227,8 @@
           rreduce-fdata (flatter data (fn [data] (r/reduce into [] data)) "r/reduce")
           flatten-fdata (flatter data (fn [data] (flatten data)) "flatten")
           rflatten-fdata (flatter data (fn [data] (into [] (r/flatten data))) "r/flatten")
-          remove-cdata (remove-cleaner reduce-fdata)
-          rremove-cdata (rremove-cleaner reduce-fdata)]))
+          remove-cdata (cleaner (fn [data] (remove nil? data)) reduce-fdata "remove")
+          rremove-cdata (cleaner (fn [data] (r/remove nil? data)) reduce-fdata)]) "r/remove")
   (println "Finish time:" (tl/format-local-time (tl/local-now) :rfc822)))

 ;;------------------------------------------------------------------------------


Fix #27 - Add tags task

Fix #27 - Add tags task

--- src/io/perun.clj
+++ src/io/perun.clj
@@ -715,6 +715,43 @@
         grouper #(-> {p {:entries %}})]
     (assortment-impl "collection" :io.perun/collection grouper options)))

+(def ^:private +tags-defaults+
+  {:out-dir "public"
+   :filterer :has-content
+   :sortby (fn [file] (:date-published file))
+   :comparator (fn [i1 i2] (compare i2 i1))})
+
+(deftask tags
+  "Render multiple collections based on the `:tags` metadata key
+   The symbol supplied as `renderer` should resolve to a function
+   which will be called with a map containing the following keys:
+    - `:meta`, global perun metadata
+    - `:entry`, the metadata for this collection
+    - `:entries`, all entries
+
+   Entries can optionally be filtered by supplying a function
+   to the `filterer` option.
+
+   The `sortby` function can be used for ordering entries before rendering."
+  [o out-dir    OUTDIR     str  "the output directory"
+   r renderer   RENDERER   sym  "page renderer (fully qualified symbol resolving to a function)"
+   _ filterer   FILTER     code "predicate to use for selecting entries (default: `:has-content`)"
+   s sortby     SORTBY     code "sort entries by function"
+   c comparator COMPARATOR code "sort by comparator function"
+   m meta       META       edn  "metadata to set on each collection entry"]
+  (let [options (merge +tags-defaults+ *opts*)
+        grouper (fn [entries]
+                  (->> entries
+                       (mapcat (fn [entry]
+                                 (map #(-> [% entry]) (:tags entry))))
+                       (reduce (fn [result [tag entry]]
+                                 (let [path (str tag ".html")]
+                                   (-> result
+                                       (update-in [path :entries] conj entry)
+                                       (assoc-in [path :group-meta :tag] tag))))
+                               {})))]
+    (assortment-impl "tags" :io.perun/tags grouper options)))
+
 (deftask inject-scripts
   "Inject JavaScript scripts into html files.
    Use either filter to include only files matching or remove to


revert some validations

revert some validations

--- src/io/perun.clj
+++ src/io/perun.clj
@@ -224,8 +224,6 @@
   (let [pods    (wrap-pool (pod/pod-pool (boot/get-env)))
         tmp     (boot/tmp-dir!)
         options (merge +render-defaults+ *opts*)]
-  (if (not (test/function? renderer))
-    (u/fail "render task :renderer option should resolve to the function\n")
     (boot/with-pre-wrap fileset
       (let [pod   (pods fileset)
             files (vals (get-perun-meta fileset))]
@@ -237,7 +235,7 @@
                                     (str (:filename file) ".html")))]
             (perun/create-file tmp page-filepath html)))
         (u/info "Render all pages\n")
-        (commit fileset tmp))))))
+        (commit fileset tmp)))))

 (def ^:private +collection-defaults+
   {:out-dir "public"
@@ -253,25 +251,23 @@
    s sortby     SORTBY     code "Sort by function"
    c comparator COMPARATOR code "Sort by comparator function"
    p page       PAGE       str  "Collection result page path"]
-  (if (not (test/function? renderer))
-    (u/fail "collection task :renderer option should resolve to the function\n")
-    (let [pods      (wrap-pool (pod/pod-pool (boot/get-env)))
-          tmp       (boot/tmp-dir!)
-          options   (merge +collection-defaults+ *opts*)]
-      (cond (not (test/function? (:comparator options)))
-                (u/fail "collection task :comparator option should be a function\n")
-            (not (test/function? (:filterer options)))
-                (u/fail "collection task :filterer option should be a function\n")
-            (not (test/function? (:sortby options)))
-                (u/fail "collection task :sortby option should be a function\n")
-            :else
-              (boot/with-pre-wrap fileset
-                (let [pod            (pods fileset)
-                      files          (vals (get-perun-meta fileset))
-                      filtered-files (filter (:filterer options) files)
-                      sorted-files   (vec (sort-by (:sortby options) (:comparator options) filtered-files))
-                      html           (render-in-pod pod renderer sorted-files)
-                      page-filepath  (perun/create-filepath (:out-dir options) page)]
-                  (perun/create-file tmp page-filepath html)
-                  (u/info (str "Render collection " page "\n"))
-                  (commit fileset tmp)))))))
+  (let [pods      (wrap-pool (pod/pod-pool (boot/get-env)))
+        tmp       (boot/tmp-dir!)
+        options   (merge +collection-defaults+ *opts*)]
+    (cond (not (test/function? (:comparator options)))
+              (u/fail "collection task :comparator option should be a function\n")
+          (not (test/function? (:filterer options)))
+              (u/fail "collection task :filterer option should be a function\n")
+          (not (test/function? (:sortby options)))
+              (u/fail "collection task :sortby option should be a function\n")
+          :else
+            (boot/with-pre-wrap fileset
+              (let [pod            (pods fileset)
+                    files          (vals (get-perun-meta fileset))
+                    filtered-files (filter (:filterer options) files)
+                    sorted-files   (vec (sort-by (:sortby options) (:comparator options) filtered-files))
+                    html           (render-in-pod pod renderer sorted-files)
+                    page-filepath  (perun/create-filepath (:out-dir options) page)]
+                (perun/create-file tmp page-filepath html)
+                (u/info (str "Render collection " page "\n"))
+                (commit fileset tmp))))))


Fix bug in delete output

Fix bug in delete output

--- src/backloggery/data/backloggery.clj
+++ src/backloggery/data/backloggery.clj
@@ -142,7 +142,7 @@
   (let [user (:bl-name *opts*)
         params {"user" user "delete2" "Stealth Delete"}
         body (map (fn [[k v]] {:name k :content v}) params)]
-    (printf "Deleting '%s' from backloggery:" (:progress game) (:name game))
+    (printf "Deleting '%s' from backloggery:" (:name game))
     (let [response (http/post "http://backloggery.com/update.php"
                               {:cookies cookies
                                ;:debug true :debug-body true


read 11.3

read 11.3

--- src/joy/ch11.clj
+++ src/joy/ch11.clj
@@ -152,3 +152,27 @@

 (ten/dothreads!
  #(do (println "hume is" @hume) (deliver kant :fork)))
+
+;; 11.3 parallel operations
+(pvalues 1 2 (+ 1 2))
+
+(defn sleeper [s thing] (Thread/sleep (* 1000 s)) thing)
+(defn pvs [] (pvalues
+              (sleeper 2 :1st)
+              (sleeper 3 :2nd)
+              (keyword "3rd")))
+
+(-> (pvs) first time)
+(-> (pvs) last time)
+
+(->> [1 2 3]
+     (pmap (comp inc (partial sleeper 2)))
+     doall
+     time)
+
+(-> (pcalls
+     #(sleeper 2 :1st)
+     #(sleeper 3 :2nd)
+     #(keyword "3rd"))
+    doall
+    time)


Need to convert rest output back to vec.

--- src/cbfg/net.cljs
+++ src/cbfg/net.cljs
@@ -115,7 +115,7 @@
                           results)))
                :else ; Test if it's a completed deliverable (recv-ch aput'ed).
                (if-let [stream (first (filter #(= (:recv-ch %) ch) (vals streams)))]
-                 (let [stream2 (update-in stream [:msgs] rest)]
+                 (let [stream2 (update-in stream [:msgs] #(vec (rest %)))]
                    (if (and (:send-closed stream2)
                             (empty? (:msgs stream2)))
                      (do (aclose net (:recv-ch stream2))


More destructuring bind.

More destructuring bind.

--- src/cbfg/vis.cljs
+++ src/cbfg/vis.cljs
@@ -296,8 +296,7 @@
                    :gen-id gen-id})
         render-ch (chan)]
     (go-loop [num-events 0]  ; Process events from world / simulation.
-      (let [[actx event] (<! event-ch)
-            [verb step & args] event
+      (let [[actx [verb step & args]] (<! event-ch)
             deltas ((get (get vis-event-handlers verb) step) vis actx args)
             event-str (str num-events ": " (last actx) " " verb " " step " " args)]
         (when (and (not (zero? @event-delay)) (some #(not (:after %)) deltas))


CMR-2562: Testing ingesting new data after rebalancing collection has started goes into both the small collections and separate index.

--- system-int-test/test/cmr/system_int_test/bootstrap/rebalance_collections_test.clj
+++ system-int-test/test/cmr/system_int_test/bootstrap/rebalance_collections_test.clj
@@ -62,6 +62,19 @@
   (is (= (assoc expected-counts :status 200)
          (bootstrap/get-rebalance-status (:concept-id collection)))))

+(defn ingest-granule-for-coll
+  [coll n]
+  (let [granule-ur (str (:entry-title coll) "_gran_" n)]
+    (d/ingest (:provider-id coll) (dg/granule coll {:granule-ur granule-ur}))))
+
+(defn inc-provider-holdings-for-coll
+  "Updates the number of granules expected for a collection in the expected provider holdings"
+  [expected-provider-holdings coll num]
+  (for [coll-holding expected-provider-holdings]
+    (if (= (:concept-id coll-holding) (:concept-id coll))
+      (update coll-holding :granule-count + num)
+      coll-holding)))
+
 (deftest rebalance-collection-test
   (s/only-with-real-database
    (let [coll1 (d/ingest "PROV1" (dc/collection {:entry-title "coll1"}))
@@ -69,13 +82,13 @@
          coll3 (d/ingest "PROV2" (dc/collection {:entry-title "coll3"}))
          coll4 (d/ingest "PROV2" (dc/collection {:entry-title "coll4"}))
          granules (doall (for [coll [coll1 coll2 coll3 coll4]
-                               n (range 4)
-                               :let [granule-ur (str (:entry-title coll) "_gran_" n)]]
-                          (d/ingest (:provider-id coll) (dg/granule coll {:granule-ur granule-ur}))))
+                               n (range 4)]
+                           (ingest-granule-for-coll coll n)))
+
          expected-provider-holdings (for [coll [coll1 coll2 coll3 coll4]]
-                                     (-> coll
-                                         (select-keys [:provider-id :concept-id :entry-title])
-                                         (assoc :granule-count 4)))]
+                                      (-> coll
+                                          (select-keys [:provider-id :concept-id :entry-title])
+                                          (assoc :granule-count 4)))]
      (index/wait-until-indexed)

      (assert-rebalance-status {:small-collections 4} coll1)
@@ -85,13 +98,28 @@
      (bootstrap/start-rebalance-collection (:concept-id coll1))
      (index/wait-until-indexed)

+     ;; After rebalancing 4 granules are in small collections and in the new index.
      (assert-rebalance-status {:small-collections 4 :separate-index 4} coll1)
      ;; Clear the search cache so it will get the last index set
      (search/clear-caches)
-     (verify-provider-holdings expected-provider-holdings))))
+     (verify-provider-holdings expected-provider-holdings)

-    ;; TODO index data and make sure that counts are correct
-    ;; use verify to get the counts
+     ;; Index new data. It should go into both indexes
+     (ingest-granule-for-coll coll1 4)
+     (ingest-granule-for-coll coll1 5)
+     (index/wait-until-indexed)
+     (assert-rebalance-status {:small-collections 6 :separate-index 6} coll1)
+
+     (let [expected-provider-holdings (inc-provider-holdings-for-coll
+                                       expected-provider-holdings coll1 2)]
+       (verify-provider-holdings expected-provider-holdings)))))
+
+
+    ;; TODO finalize the rebalancing
+    ;; TODO verify counts
+    ;; TODO verify indexing new data goes into the right indexes
+
+    ;; TODO continue to rebalance other collections and check on status. (Do multiple at the same time.)

 ;; rebalance one and then test results. Make sure data when indexed goes to the right place.


Fixed test case bug

Fixed test case bug

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -536,6 +536,6 @@
             :description "Given a vector of integers, find the longest consecutive sub-sequence of increasing numbers. If two sub-sequences have the same length, use the one that occurs first."
             :tags ["medium" "seqs"]
             :tests ["(= (__ [1 0 1 2 3 0 4 5]) [0 1 2 3])"
-		    "(= (__ [5 6 1 2 6 7]) [5 6])"
+		    "(= (__ [5 6 1 3 2 7]) [5 6])"
 		    "(= (__ [2 3 3 4 5]) [3 4 5])"
-		    "(= (__ [7 6 5 4]) [])"]})))+		    "(= (__ [7 6 5 4]) [])"]})))


Drop every Nth item problem added

Drop every Nth item problem added

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -406,4 +406,14 @@
             :tags ["easy" "seqs" "core-functions"]
             :tests ["(= (__ 0 [1 2 3]) [1 0 2 0 3])"
 		    "(= (apply str (__ \", \" [\"one\" \"two\" \"three\"])) \"one, two, three\")"]
-	    :secret-tests ["(= (__ :z [:a :b :c :d]) [:a :z :b :z :c :z :d])"]})))+	    :secret-tests ["(= (__ :z [:a :b :c :d]) [:a :z :b :z :c :z :d])"]})
+
+    (insert! :problems
+           {:_id 41
+            :title "Drop Every Nth Item"
+            :times-solved 0
+            :description "Write a function which drops every Nth item from a sequence."
+            :tags ["easy" "seqs"]
+            :tests ["(= (__ [1 2 3 4 5 6 7 8] 3) [1 2 4 5 7 8])"
+		    "(= (__ [:a :b :c :d :e :f] 2) [:a :c :e])"]
+	    :secret-tests ["(= (__ [1 2 3 4 5 6] 4) [1 2 3 5 6])"]})))


Refactor `update-ModulesSelected-for-affected-days!`

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -721,21 +721,15 @@
    lessons, update the individual entries in the `ModulesSelected` global."
   [affectedDaysSet]
   (doseq [day affectedDaysSet]
-    (let [ttDay (timetable-get-day day)]
-      (doseq [[rowIdx ttRow] (map vector (range (count ttDay)) ttDay)]
-        (doseq [[ttLessonInfo _] ttRow]
-          (let [moduleCode  (:moduleCode ttLessonInfo)
-                lessonType  (:lessonType ttLessonInfo)
-                lessonGroup (:lessonGroup ttLessonInfo)
-                startTime   (:startTime ttLessonInfo)
-                endTime     (:endTime ttLessonInfo)]
-            (set! ModulesSelected
-                  (update-in
-                    ModulesSelected
-                    [moduleCode lessonType :info]
-                    (fn [modSelLessonInfoSeq]
-                      (conj
-                        (filter (fn [modSelLessonInfo]
+    (doseq [[rowIdx ttRow] (timetable-enumerate-rows-in-day day)]
+      (doseq [[{:keys [moduleCode lessonType lessonGroup
+                       startTime endTime]} _] ttRow]
+        (set! ModulesSelected
+              (update-in
+                ModulesSelected
+                [moduleCode lessonType :info]
+                (fn [modSelLessonInfoSeq]
+                  (conj (filter (fn [modSelLessonInfo]
                                   (or (not= (:day modSelLessonInfo) day)
                                       (not= (:startTime modSelLessonInfo)
                                             startTime)
@@ -745,7 +739,7 @@
                         {:day day,
                          :rowNum rowIdx,
                          :startTime startTime,
-                         :endTime endTime}))))))))))
+                         :endTime endTime}))))))))

 (defn- create-lesson-div
   "Creates a <div> element for a new lesson using jQuery"


Not used anymore

Not used anymore

--- src/cljs/gc_api_browser/request.cljs
+++ src/cljs/gc_api_browser/request.cljs
@@ -47,13 +47,11 @@
   (reify
     om/IInitState
     (init-state [_]
-      {:submit-chan (async/chan)
-       :response-chan (async/chan)})
+      {:submit-chan (async/chan)})

     om/IWillMount
     (will-mount [_]
-      (let [submit-chan (om/get-state owner :submit-chan)
-            response-chan (om/get-state owner :response-chan)]
+      (let [submit-chan (om/get-state owner :submit-chan)]
         (go (loop []
               (when-let [req (async/<! submit-chan)]
                 (let [resp (async/<! (http/request req))]


Added metadata to all vector stack instructions

--- src/clojush/instructions/vectors.clj
+++ src/clojush/instructions/vectors.clj
@@ -1,66 +1,64 @@
 (ns clojush.instructions.vectors
   (:use [clojush pushstate globals]
         clojush.instructions.common))
-;      [clojure.string :only [split trim]])
-;(:require [clojure.string :as string]))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; stack instructions for vectors

-(define-registered vector_integer_pop (popper :vector_integer))
-(define-registered vector_float_pop (popper :vector_float))
-(define-registered vector_boolean_pop (popper :vector_boolean))
-(define-registered vector_string_pop (popper :vector_string))
-
-(define-registered vector_integer_dup (duper :vector_integer))
-(define-registered vector_float_dup (duper :vector_float))
-(define-registered vector_boolean_dup (duper :vector_boolean))
-(define-registered vector_string_dup (duper :vector_string))
-
-(define-registered vector_integer_swap (swapper :vector_integer))
-(define-registered vector_float_swap (swapper :vector_float))
-(define-registered vector_boolean_swap (swapper :vector_boolean))
-(define-registered vector_string_swap (swapper :vector_string))
-
-(define-registered vector_integer_rot (rotter :vector_integer))
-(define-registered vector_float_rot (rotter :vector_float))
-(define-registered vector_boolean_rot (rotter :vector_boolean))
-(define-registered vector_string_rot (rotter :vector_string))
-
-(define-registered vector_integer_flush (flusher :vector_integer))
-(define-registered vector_float_flush (flusher :vector_float))
-(define-registered vector_boolean_flush (flusher :vector_boolean))
-(define-registered vector_string_flush (flusher :vector_string))
-
-(define-registered vector_integer_eq (eqer :vector_integer))
-(define-registered vector_float_eq (eqer :vector_float))
-(define-registered vector_boolean_eq (eqer :vector_boolean))
-(define-registered vector_string_eq (eqer :vector_string))
-
-(define-registered vector_integer_stackdepth (stackdepther :vector_integer))
-(define-registered vector_float_stackdepth (stackdepther :vector_float))
-(define-registered vector_boolean_stackdepth (stackdepther :vector_boolean))
-(define-registered vector_string_stackdepth (stackdepther :vector_string))
-
-(define-registered vector_integer_yank (yanker :vector_integer))
-(define-registered vector_float_yank (yanker :vector_float))
-(define-registered vector_boolean_yank (yanker :vector_boolean))
-(define-registered vector_string_yank (yanker :vector_string))
-
-(define-registered vector_integer_yankdup (yankduper :vector_integer))
-(define-registered vector_float_yankdup (yankduper :vector_float))
-(define-registered vector_boolean_yankdup (yankduper :vector_boolean))
-(define-registered vector_string_yankdup (yankduper :vector_string))
-
-(define-registered vector_integer_shove (shover :vector_integer))
-(define-registered vector_float_shove (shover :vector_float))
-(define-registered vector_boolean_shove (shover :vector_boolean))
-(define-registered vector_string_shove (shover :vector_string))
-
-(define-registered vector_integer_empty (emptyer :vector_integer))
-(define-registered vector_float_empty (emptyer :vector_float))
-(define-registered vector_boolean_empty (emptyer :vector_boolean))
-(define-registered vector_string_empty (emptyer :vector_string))
+(define-registered vector_integer_pop (with-meta (popper :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_pop (with-meta (popper :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_pop (with-meta (popper :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_pop (with-meta (popper :vector_string) {:stack-types [:vector_string]}))
+
+(define-registered vector_integer_dup (with-meta (duper :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_dup (with-meta (duper :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_dup (with-meta (duper :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_dup (with-meta (duper :vector_string) {:stack-types [:vector_string]}))
+
+(define-registered vector_integer_swap (with-meta (swapper :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_swap (with-meta (swapper :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_swap (with-meta (swapper :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_swap (with-meta (swapper :vector_string) {:stack-types [:vector_string]}))
+
+(define-registered vector_integer_rot (with-meta (rotter :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_rot (with-meta (rotter :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_rot (with-meta (rotter :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_rot (with-meta (rotter :vector_string) {:stack-types [:vector_string]}))
+
+(define-registered vector_integer_flush (with-meta (flusher :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_flush (with-meta (flusher :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_flush (with-meta (flusher :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_flush (with-meta (flusher :vector_string) {:stack-types [:vector_string]}))
+
+(define-registered vector_integer_eq (with-meta (eqer :vector_integer) {:stack-types [:vector_integer :boolean]}))
+(define-registered vector_float_eq (with-meta (eqer :vector_float) {:stack-types [:vector_float :boolean]}))
+(define-registered vector_boolean_eq (with-meta (eqer :vector_boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_eq (with-meta (eqer :vector_string) {:stack-types [:vector_string :boolean]}))
+
+(define-registered vector_integer_stackdepth (with-meta (stackdepther :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_stackdepth (with-meta (stackdepther :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_stackdepth (with-meta (stackdepther :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_stackdepth (with-meta (stackdepther :vector_string) {:stack-types [:vector_string :integer]}))
+
+(define-registered vector_integer_yank (with-meta (yanker :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_yank (with-meta (yanker :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_yank (with-meta (yanker :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_yank (with-meta (yanker :vector_string) {:stack-types [:vector_string :integer]}))
+
+(define-registered vector_integer_yankdup (with-meta (yankduper :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_yankdup (with-meta (yankduper :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_yankdup (with-meta (yankduper :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_yankdup (with-meta (yankduper :vector_string) {:stack-types [:vector_string :integer]}))
+
+(define-registered vector_integer_shove (with-meta (shover :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_shove (with-meta (shover :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_shove (with-meta (shover :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_shove (with-meta (shover :vector_string) {:stack-types [:vector_string :integer]}))
+
+(define-registered vector_integer_empty (with-meta (emptyer :vector_integer) {:stack-types [:vector_integer :boolean]}))
+(define-registered vector_float_empty (with-meta (emptyer :vector_float) {:stack-types [:vector_float :boolean]}))
+(define-registered vector_boolean_empty (with-meta (emptyer :vector_boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_empty (with-meta (emptyer :vector_string) {:stack-types [:vector_string :boolean]}))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; common instructions for vectors
@@ -80,10 +78,10 @@
           state))
       state)))

-(define-registered vector_integer_concat (concater :vector_integer))
-(define-registered vector_float_concat (concater :vector_float))
-(define-registered vector_boolean_concat (concater :vector_boolean))
-(define-registered vector_string_concat (concater :vector_string))
+(define-registered vector_integer_concat (with-meta (concater :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_concat (with-meta (concater :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_concat (with-meta (concater :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_concat (with-meta (concater :vector_string) {:stack-types [:vector_string]}))

 (defn conjer
   "Returns a function that takes a state and conj's an item onto the type stack."
@@ -99,10 +97,10 @@
           state))
       state)))

-(define-registered vector_integer_conj (conjer :vector_integer :integer))
-(define-registered vector_float_conj (conjer :vector_float :float))
-(define-registered vector_boolean_conj (conjer :vector_boolean :boolean))
-(define-registered vector_string_conj (conjer :vector_string :string))
+(define-registered vector_integer_conj (with-meta (conjer :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_conj (with-meta (conjer :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_conj (with-meta (conjer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_conj (with-meta (conjer :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn taker
   "Returns a function that takes a state and takes the first N items from the type
@@ -117,10 +115,10 @@
                  (pop-item type (pop-item :integer state)))
       state)))

-(define-registered vector_integer_take (taker :vector_integer))
-(define-registered vector_float_take (taker :vector_float))
-(define-registered vector_boolean_take (taker :vector_boolean))
-(define-registered vector_string_take (taker :vector_string))
+(define-registered vector_integer_take (with-meta (taker :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_take (with-meta (taker :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_take (with-meta (taker :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_take (with-meta (taker :vector_string) {:stack-types [:vector_string :integer]}))

 (defn subvecer
   "Returns a function that takes a state and takes the subvec of the top item
@@ -137,10 +135,10 @@
                    (pop-item type (pop-item :integer (pop-item :integer state)))))
       state)))

-(define-registered vector_integer_subvec (subvecer :vector_integer))
-(define-registered vector_float_subvec (subvecer :vector_float))
-(define-registered vector_boolean_subvec (subvecer :vector_boolean))
-(define-registered vector_string_subvec (subvecer :vector_string))
+(define-registered vector_integer_subvec (with-meta (subvecer :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_subvec (with-meta (subvecer :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_subvec (with-meta (subvecer :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_subvec (with-meta (subvecer :vector_string) {:stack-types [:vector_string :integer]}))

 (defn firster
   "Returns a function that takes a state and gets the first item from the type stack."
@@ -153,10 +151,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_first (firster :vector_integer :integer))
-(define-registered vector_float_first (firster :vector_float :float))
-(define-registered vector_boolean_first (firster :vector_boolean :boolean))
-(define-registered vector_string_first (firster :vector_string :string))
+(define-registered vector_integer_first (with-meta (firster :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_first (with-meta (firster :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_first (with-meta (firster :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_first (with-meta (firster :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn laster
   "Returns a function that takes a state and gets the last item from the type stack."
@@ -169,10 +167,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_last (laster :vector_integer :integer))
-(define-registered vector_float_last (laster :vector_float :float))
-(define-registered vector_boolean_last (laster :vector_boolean :boolean))
-(define-registered vector_string_last (laster :vector_string :string))
+(define-registered vector_integer_last (with-meta (laster :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_last (with-meta (laster :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_last (with-meta (laster :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_last (with-meta (laster :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn nther
   "Returns a function that takes a state and gets the nth item from the type stack."
@@ -188,10 +186,10 @@
                    (pop-item :integer (pop-item type state))))
       state)))

-(define-registered vector_integer_nth (nther :vector_integer :integer))
-(define-registered vector_float_nth (nther :vector_float :float))
-(define-registered vector_boolean_nth (nther :vector_boolean :boolean))
-(define-registered vector_string_nth (nther :vector_string :string))
+(define-registered vector_integer_nth (with-meta (nther :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_nth (with-meta (nther :vector_float :float) {:stack-types [:vector_float :float :integer]}))
+(define-registered vector_boolean_nth (with-meta (nther :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean :integer]}))
+(define-registered vector_string_nth (with-meta (nther :vector_string :string) {:stack-types [:vector_string :string :integer]}))

 (defn rester
   "Returns a function that takes a state and takes the rest of the top item
@@ -204,10 +202,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_rest (rester :vector_integer))
-(define-registered vector_float_rest (rester :vector_float))
-(define-registered vector_boolean_rest (rester :vector_boolean))
-(define-registered vector_string_rest (rester :vector_string))
+(define-registered vector_integer_rest (with-meta (rester :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_rest (with-meta (rester :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_rest (with-meta (rester :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_rest (with-meta (rester :vector_string) {:stack-types [:vector_string]}))

 (defn butlaster
   "Returns a function that takes a state and takes the butlast of the top item
@@ -220,10 +218,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_butlast (butlaster :vector_integer))
-(define-registered vector_float_butlast (butlaster :vector_float))
-(define-registered vector_boolean_butlast (butlaster :vector_boolean))
-(define-registered vector_string_butlast (butlaster :vector_string))
+(define-registered vector_integer_butlast (with-meta (butlaster :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_butlast (with-meta (butlaster :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_butlast (with-meta (butlaster :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_butlast (with-meta (butlaster :vector_string) {:stack-types [:vector_string]}))

 (defn lengther
   "Returns a function that takes a state and takes the length of the top item
@@ -236,10 +234,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_length (lengther :vector_integer))
-(define-registered vector_float_length (lengther :vector_float))
-(define-registered vector_boolean_length (lengther :vector_boolean))
-(define-registered vector_string_length (lengther :vector_string))
+(define-registered vector_integer_length (with-meta (lengther :vector_integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_length (with-meta (lengther :vector_float) {:stack-types [:vector_float :integer]}))
+(define-registered vector_boolean_length (with-meta (lengther :vector_boolean) {:stack-types [:vector_boolean :integer]}))
+(define-registered vector_string_length (with-meta (lengther :vector_string) {:stack-types [:vector_string :integer]}))

 (defn reverser
   "Returns a function that takes a state and takes the reverse of the top item
@@ -252,10 +250,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_reverse (reverser :vector_integer))
-(define-registered vector_float_reverse (reverser :vector_float))
-(define-registered vector_boolean_reverse (reverser :vector_boolean))
-(define-registered vector_string_reverse (reverser :vector_string))
+(define-registered vector_integer_reverse (with-meta (reverser :vector_integer) {:stack-types [:vector_integer]}))
+(define-registered vector_float_reverse (with-meta (reverser :vector_float) {:stack-types [:vector_float]}))
+(define-registered vector_boolean_reverse (with-meta (reverser :vector_boolean) {:stack-types [:vector_boolean]}))
+(define-registered vector_string_reverse (with-meta (reverser :vector_string) {:stack-types [:vector_string]}))

 (defn pushaller
   "Returns a function that takes a state and pushes every item from the first
@@ -271,10 +269,10 @@
           (recur (rest lit-list)
                  (push-item (first lit-list) lit-type loop-state)))))))

-(define-registered vector_integer_pushall (pushaller :vector_integer :integer))
-(define-registered vector_float_pushall (pushaller :vector_float :float))
-(define-registered vector_boolean_pushall (pushaller :vector_boolean :boolean))
-(define-registered vector_string_pushall (pushaller :vector_string :string))
+(define-registered vector_integer_pushall (with-meta (pushaller :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_pushall (with-meta (pushaller :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_pushall (with-meta (pushaller :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_pushall (with-meta (pushaller :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn emptyvectorer
   "Returns a function that takes a state and pushes a boolean of whether the top
@@ -287,10 +285,10 @@
                  (pop-item type state))
       state)))

-(define-registered vector_integer_emptyvector (emptyvectorer :vector_integer))
-(define-registered vector_float_emptyvector (emptyvectorer :vector_float))
-(define-registered vector_boolean_emptyvector (emptyvectorer :vector_boolean))
-(define-registered vector_string_emptyvector (emptyvectorer :vector_string))
+(define-registered vector_integer_emptyvector (with-meta (emptyvectorer :vector_integer) {:stack-types [:vector_integer :boolean]}))
+(define-registered vector_float_emptyvector (with-meta (emptyvectorer :vector_float) {:stack-types [:vector_float :boolean]}))
+(define-registered vector_boolean_emptyvector (with-meta (emptyvectorer :vector_boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_emptyvector (with-meta (emptyvectorer :vector_string) {:stack-types [:vector_string :boolean]}))

 (defn containser
   "Returns a function that takes a state and tells whether the top lit-type item
@@ -307,10 +305,10 @@
                    :boolean
                    (pop-item lit-type (pop-item type state)))))))

-(define-registered vector_integer_contains (containser :vector_integer :integer))
-(define-registered vector_float_contains (containser :vector_float :float))
-(define-registered vector_boolean_contains (containser :vector_boolean :boolean))
-(define-registered vector_string_contains (containser :vector_string :string))
+(define-registered vector_integer_contains (with-meta (containser :vector_integer :integer) {:stack-types [:vector_integer :integer :boolean]}))
+(define-registered vector_float_contains (with-meta (containser :vector_float :float) {:stack-types [:vector_float :float :boolean]}))
+(define-registered vector_boolean_contains (with-meta (containser :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_contains (with-meta (containser :vector_string :string) {:stack-types [:vector_string :string :boolean]}))

 (defn indexofer
   "Returns a function that takes a state and finds the index of the top lit-type
@@ -327,10 +325,10 @@
                    :integer
                    (pop-item lit-type (pop-item type state)))))))

-(define-registered vector_integer_indexof (indexofer :vector_integer :integer))
-(define-registered vector_float_indexof (indexofer :vector_float :float))
-(define-registered vector_boolean_indexof (indexofer :vector_boolean :boolean))
-(define-registered vector_string_indexof (indexofer :vector_string :string))
+(define-registered vector_integer_indexof (with-meta (indexofer :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_indexof (with-meta (indexofer :vector_float :float) {:stack-types [:vector_float :float :integer]}))
+(define-registered vector_boolean_indexof (with-meta (indexofer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean :integer]}))
+(define-registered vector_string_indexof (with-meta (indexofer :vector_string :string) {:stack-types [:vector_string :string :integer]}))

 (defn occurrencesofer
   "Returns a function that takes a state and counts the occurrences of the top lit-type
@@ -347,10 +345,10 @@
                    :integer
                    (pop-item lit-type (pop-item type state)))))))

-(define-registered vector_integer_occurrencesof (occurrencesofer :vector_integer :integer))
-(define-registered vector_float_occurrencesof (occurrencesofer :vector_float :float))
-(define-registered vector_boolean_occurrencesof (occurrencesofer :vector_boolean :boolean))
-(define-registered vector_string_occurrencesof (occurrencesofer :vector_string :string))
+(define-registered vector_integer_occurrencesof (with-meta (occurrencesofer :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_occurrencesof (with-meta (occurrencesofer :vector_float :float) {:stack-types [:vector_float :float :integer]}))
+(define-registered vector_boolean_occurrencesof (with-meta (occurrencesofer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean :integer]}))
+(define-registered vector_string_occurrencesof (with-meta (occurrencesofer :vector_string :string) {:stack-types [:vector_string :string :integer]}))

 (defn replaceer
   "Returns a function that takes a state and replaces all occurrences of the second lit-type item
@@ -366,10 +364,10 @@
                    type
                    (pop-item lit-type (pop-item lit-type (pop-item type state))))))))

-(define-registered vector_integer_replace (replaceer :vector_integer :integer))
-(define-registered vector_float_replace (replaceer :vector_float :float))
-(define-registered vector_boolean_replace (replaceer :vector_boolean :boolean))
-(define-registered vector_string_replace (replaceer :vector_string :string))
+(define-registered vector_integer_replace (with-meta (replaceer :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_replace (with-meta (replaceer :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_replace (with-meta (replaceer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_replace (with-meta (replaceer :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn replacefirster
   "Returns a function that takes a state and replaces the first occurrence of the second lit-type item
@@ -387,10 +385,10 @@
                    type
                    (pop-item lit-type (pop-item lit-type (pop-item type state))))))))

-(define-registered vector_integer_replacefirst (replacefirster :vector_integer :integer))
-(define-registered vector_float_replacefirst (replacefirster :vector_float :float))
-(define-registered vector_boolean_replacefirst (replacefirster :vector_boolean :boolean))
-(define-registered vector_string_replacefirst (replacefirster :vector_string :string))
+(define-registered vector_integer_replacefirst (with-meta (replacefirster :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_replacefirst (with-meta (replacefirster :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_replacefirst (with-meta (replacefirster :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_replacefirst (with-meta (replacefirster :vector_string :string) {:stack-types [:vector_string :string]}))

 (defn removeer
   "Returns a function that takes a state and removes all occurrences of the first lit-type item
@@ -406,7 +404,7 @@
                    type
                    (pop-item lit-type (pop-item type state)))))))

-(define-registered vector_integer_remove (removeer :vector_integer :integer))
-(define-registered vector_float_remove (removeer :vector_float :float))
-(define-registered vector_boolean_remove (removeer :vector_boolean :boolean))
-(define-registered vector_string_remove (removeer :vector_string :string))
+(define-registered vector_integer_remove (with-meta (removeer :vector_integer :integer) {:stack-types [:vector_integer :integer]}))
+(define-registered vector_float_remove (with-meta (removeer :vector_float :float) {:stack-types [:vector_float :float]}))
+(define-registered vector_boolean_remove (with-meta (removeer :vector_boolean :boolean) {:stack-types [:vector_boolean :boolean]}))
+(define-registered vector_string_remove (with-meta (removeer :vector_string :string) {:stack-types [:vector_string :string]}))


Correctly log slow queries when no statement is available

--- src/com/puppetlabs/jdbc/internal.clj
+++ src/com/puppetlabs/jdbc/internal.clj
@@ -51,7 +51,7 @@
                              (query-params->str log-statements? params))
                         query-execution-limit
                         (/ time-elapsed 1000000000.0)
-                        stmt)))))
+                        sql)))))

 (defn limit-exception
   "Helper method; simply throws an exception with a message explaining


image primitives

image primitives

--- src/video_feed_transformer/transform_feed.clj
+++ src/video_feed_transformer/transform_feed.clj
@@ -8,8 +8,18 @@
             [clojure.string :as str]
             [mikera.image.core :as imgz]))

-(defn- load-image [path] ""
+(defn- load-image [path]
+  "loads an image from path"
   (imgz/load-image path))
+
+(defn- get-image-data [img]
+  "get pixels from image"
+  (imgz/get-pixels img))
+
+(defn- get-grid-boxes [width height rows cols]
+  "for a given width, height, num rows and num cols,
+  return a map of [ {:x1 0 :x2 10 :y1 0 :y2 10} ...]"
+  nil)

 (defn- move-file [src-file dest-dir] ""
   (fs/copy+ src-file dest-dir))


Remove a race between the control channel and the response channel

--- src/io/aviso/rook/server.clj
+++ src/io/aviso/rook/server.clj
@@ -207,7 +207,12 @@
                                         (or response
                                             (do
                                               (l/debugf "Handler for %s closed response channel." (utils/summarize-request request))
-                                              not-found-response))))))))))
+                                              not-found-response)))
+
+                           ;; In testing at least, the close of the control channel and returning nil (closing
+                           ;; the response channel) can happen close enough together that the handler-ch
+                           ;; wins over the timeout-control-ch, resulting in a 404 response not a 504.
+                           :priority true)))))))

 (defn wrap-debug-response
   "Used with synchronous handlers to log the response sent back to the client at debug level.  [[wrap-with-timeout]]


Greedy drop algorithm.

Greedy drop algorithm.

--- src/onyx/log/commands/submit_job.clj
+++ src/onyx/log/commands/submit_job.clj
@@ -16,6 +16,23 @@
 (defmethod extensions/replica-diff :submit-job
   [{:keys [args]} old new]
   {:job (:id args)})
+
+(defmulti drop-peers
+  (fn [replica job n]
+    (:job-scheduler replica)))
+
+(defmethod drop-peers :onyx.job-scheduler/greedy
+  [replica job n]
+  (let [tasks (get (:allocations replica) job)]
+    (take-last n (apply concat (vals tasks)))))
+
+(defmethod drop-peers :onyx.job-scheduler/round-robin
+  [replica job n])
+
+(defmethod drop-peers :default
+  [replica job n]
+  (throw (ex-info (format "Job scheduler %s not recognized" (:job-scheduler replica))
+                  {:replica replica})))

 (defn job->n-peers [replica]
   (let [j (count (:jobs replica))
@@ -49,7 +66,7 @@
         (= (:job-scheduler old) :onyx.job-scheduler/round-robin)
         (if-let [allocation (peer->allocated-job (:allocations new) (:id peer-args))]
           (let [peer-counts (job->n-peers new)]
-            (prn "~>" peer-counts)
+            (prn (get peer-counts (:job allocation)))
             [{:fn :volunteer-for-task :args {:id (:id peer-args)}}])
           [{:fn :volunteer-for-task :args {:id (:id peer-args)}}])))


average attende now isplayed properly

average attende now isplayed properly

--- src/cljs/conference_rating/conference_detail_page/aggregated_ratings.cljs
+++ src/cljs/conference_rating/conference_detail_page/aggregated_ratings.cljs
@@ -7,47 +7,112 @@
 (defn badge [label classes]
   [:span {:class (str "badge " classes)} label])

-(defn conference-badges-row [& badges]
-  [:div {:class "badge-row"} badges ])
+(defn conference-badges-row [badges]
+  [:div {:class "badge-row"} badges])

-;;TODO show sentence for experience level, too
-(defn average-attendee []
+(defn top-2 [collection]
+  (->> collection
+       (sort-by #(second %))
+       (reverse)
+       (take 2)
+       (map first)))
+
+(def roles->sentence-fragment {:dev        "a developer"
+                               :devops     "a devops aka admin :)"
+                               :ux         "a user experience designer"
+                               :qa         "a quality analyst"
+                               :ba         "a business analyst"
+                               :pm         "a project manager"
+                               :sales      "a sales person"
+                               :other      "a random person"
+                               :recruiting "a recruiter"})
+
+(def roles->badge-label {:dev        "DEV"
+                         :devops     "DEVOPS"
+                         :ux         "UX"
+                         :qa         "QA"
+                         :ba         "BA"
+                         :pm         "PM"
+                         :sales      "Sales"
+                         :other      "Other"
+                         :recruiting "Recruiting"})
+
+(def experience->sentence-fragment {:rookie       "a rookie"
+                               :beginner     "a beginner"
+                               :intermediate "intermediate"
+                               :advanced     "advanced"
+                               :expert       "an expert"})
+
+(def experience->badge-label {:rookie       "Rookie"
+                              :beginner     "Beginner"
+                              :intermediate "Intermediate"
+                              :advanced     "Advanced"
+                              :expert       "Expert"})
+
+(def tags->sentence-fragment {:inspiring    "I am looking for inspiring talks to get awesome ideas for new projects."
+                              :entertaining "I want to get entertained. And have fun at an awesome after party."
+                              :informative  "I am here to learn a lot and watch as many talks as possible."
+                              :hires        "I want to met potential future collegues and extend my network."
+                              :clients      "I am on the hunt for potential clients that have a booth at this confernece."})
+
+(def tags->badge-label {:inspiring    "Inspiring"
+                        :entertaining "Entertaining"
+                        :informative  "Informative"
+                        :hires        "Potential Hires"
+                        :clients      "Potential Clients"})
+
+(defn get-role-sentence [roles]
+  (let [top-2-roles (->> roles
+                         (top-2)
+                         (map roles->sentence-fragment))]
+    (str "I am " (first top-2-roles) " or " (second top-2-roles))))
+
+(defn get-experience-sentence [experiences]
+  (let [top-2-experience (->> experiences
+                              (top-2)
+                              (map experience->sentence-fragment))]
+    (str "I am " (first top-2-experience) " or " (second top-2-experience) " in my field.")))
+
+(defn get-tags-sentence [tags]
+  (let [top-2-tags (->> tags
+                        (top-2)
+                        (map tags->sentence-fragment))]
+    [:div
+     [:p (first top-2-tags)]
+     [:p (second top-2-tags)]]))
+
+(defn average-attendee [aggregated-ratings]
   [:div
-   [:p "I am a Dev or QA"]
-   [:p "I am looking for entertainment and fun"]
-   [:p "I want to learn a lot"]
-   [:p "I want to eatch out for potential clients"]
-   [:p "I want to watch out for potential hires"]])
+   [:p (get-role-sentence (:roles aggregated-ratings))]
+   [:p (get-experience-sentence (:experience aggregated-ratings))]
+   [:p (get-tags-sentence (:tags aggregated-ratings))]])

-(defn- selection-of-role-elements [aggregated-ratings role label]
-  (let [count (role aggregated-ratings)]
-    (if (> count 0) [badge (str label " " count) "badge-light-blue"])))
+(defn- conference-badge [lookup-table]
+  (fn [[key count]]
+    (let [label (lookup-table key)]
+      [badge (str label " (" count ")") "badge-light-blue"])))
+
+(defn badges [coll lookup-table]
+  (->> coll
+       (filter #(not= 0 (second %)))
+       (sort-by #(second %))
+       (reverse)
+       (map (conference-badge lookup-table))))

 (defn conference-badges [aggregated-ratings]
   [:div
-   (conference-badges-row (selection-of-role-elements aggregated-ratings :dev "DEV")
-                          (selection-of-role-elements aggregated-ratings :devops "DEVOPS")
-                          (selection-of-role-elements aggregated-ratings :ux "UX")
-                          (selection-of-role-elements aggregated-ratings :qa "QA")
-                          (selection-of-role-elements aggregated-ratings :ba "BA")
-                          (selection-of-role-elements aggregated-ratings :pm "PM")
-                          (selection-of-role-elements aggregated-ratings :sales "Sales")
-                          (selection-of-role-elements aggregated-ratings :recruting "Recruting")
-                          (selection-of-role-elements aggregated-ratings :other "Others"))
-   (conference-badges-row (badge "Inspiring" "badge-light-primary")
-                          (badge "learnings" "badge-light-primary")
-                          (badge "Network" "badge-light-primary")
-                          (badge "Hires" "badge-light-primary")
-                          (badge "Clients" "badge-light-primary"))])
+   (conference-badges-row (badges (:roles aggregated-ratings) roles->badge-label))
+   (conference-badges-row (badges (:experience aggregated-ratings) experience->badge-label))
+   (conference-badges-row (badges (:tags aggregated-ratings) tags->badge-label))])

 (defn conference-average-attendee [aggregated-ratings]
   [:div
-   (panel/info-panel "glyphicon-user" "I am your average attende" (average-attendee) (conference-badges aggregated-ratings))])
+   (panel/info-panel "glyphicon-user" "I am your average attende" (average-attendee aggregated-ratings) (conference-badges aggregated-ratings))])

 (defn display-aggregated-ratings [aggregated-ratings]
-  (let  [overall-avg (get-in aggregated-ratings [:overall :avg])
+  (let [overall-avg (get-in aggregated-ratings [:overall :avg])
         overall-avg-percentage (* (/ overall-avg 4) 100)
         overall-ratings-str (str (get-in aggregated-ratings [:overall :count]) " ratings")
         talks-avg (get-in aggregated-ratings [:talks :avg])
@@ -59,15 +124,15 @@
         networking-avg (get-in aggregated-ratings [:community :avg])
         networking-avg-percentage (* (/ networking-avg 4) 100)
         networking-ratings-str (str (get-in aggregated-ratings [:community :count]) " ratings")]
-  [:div
-   (conference-recommendations (:recommendations aggregated-ratings))
-   [:div {:class "row"}
-    [:div {:class "col-lg-6 col-md-6 col-sm-6"}
-     (panel/range-panel overall-avg-percentage overall-avg "Overall" overall-ratings-str "bg-mint" "glyphicon-thumbs-up")
-     (panel/range-panel talks-avg-percentage talks-avg "Talks" talks-ratings-str "bg-purple" "glyphicon-user")]
-    [:div {:class "col-lg-6 col-md-6 col-sm-6"}
-     (panel/range-panel venue-avg-percentage venue-avg "Venue" venue-ratings-str "bg-pink" "glyphicon-home")
-     (panel/range-panel networking-avg-percentage networking-avg "Networking" networking-ratings-str "bg-green" "glyphicon-glass")]]
-   (conference-average-attendee aggregated-ratings)]))
+    [:div
+     (conference-recommendations (:recommendations aggregated-ratings))
+     [:div {:class "row"}
+      [:div {:class "col-lg-6 col-md-6 col-sm-6"}
+       (panel/range-panel overall-avg-percentage overall-avg "Overall" overall-ratings-str "bg-mint" "glyphicon-thumbs-up")
+       (panel/range-panel talks-avg-percentage talks-avg "Talks" talks-ratings-str "bg-purple" "glyphicon-user")]
+      [:div {:class "col-lg-6 col-md-6 col-sm-6"}
+       (panel/range-panel venue-avg-percentage venue-avg "Venue" venue-ratings-str "bg-pink" "glyphicon-home")
+       (panel/range-panel networking-avg-percentage networking-avg "Networking" networking-ratings-str "bg-green" "glyphicon-glass")]]
+     (conference-average-attendee aggregated-ratings)]))


fix normalize bug

fix normalize bug

--- src/main/compassus/core.cljs
+++ src/main/compassus/core.cljs
@@ -131,10 +131,13 @@
         state (if normalize?
                 (atom (merge (om/tree->db merged-query state true)
                              route-info))
-                (swap! state merge route-info))]
+                (doto state
+                  (swap! merge route-info)))]
     (merge reconciler-opts
            {:state state
-            :parser (make-parser parser)})))
+            :parser (make-parser parser)}
+           (when normalize?
+             {:normalize true}))))

 ;; TODO:
 ;; - should routes be idents or just keywords?


don't `get-method` twice

don't `get-method` twice

--- src/main/compassus/core.cljs
+++ src/main/compassus/core.cljs
@@ -111,9 +111,8 @@
 (defmethod read :default
   [{:keys [target] :as env} key params]
   (let [dispatch  [:default key]
-        submethod (get-method read dispatch)
-        this      (get-method read :default)]
-    (if (and submethod (not= submethod this))
+        submethod (get (methods read) dispatch)]
+    (if submethod
       (do
         (-add-method read dispatch submethod)
         (submethod env key params))


[Issue #82] clarifying renames

[Issue #82] clarifying renames

--- src/midje/ideas/formulas.clj
+++ src/midje/ideas/formulas.clj
@@ -62,22 +62,22 @@
   how many facts are generated per formula."
   {:arglists '([docstring? opts-map? bindings & body])}
   [& args]
-  (valid-let [[docstring? opts bindings body] (validate &form)
+  (valid-let [[docstring? opts-map bindings body] (validate &form)
               fact (formula-fact docstring? body)
               conclusion-signal `(midje.sweet/fact
                                    :always-pass midje.sweet/=> :always-pass
                                    :formula :formula-conclude )]

     `(try
-       (loop [cnt-down# (or (:num-trials ~opts) midje.ideas.formulas/*num-trials*)]
-         (when (pos? cnt-down#)
-           (let [snd-bindings# ~(vec (take-nth 2 (rest bindings)))
-                 ~(vec (take-nth 2 bindings)) snd-bindings#]
+       (loop [num-trials-left# (or (:num-trials ~opts-map) midje.ideas.formulas/*num-trials*)]
+         (when (pos? num-trials-left#)
+           (let [bindings-rhss# ~(vec (take-nth 2 (rest bindings)))
+                 ~(vec (take-nth 2 bindings)) bindings-rhss#]
              (if ~fact
-               (recur (dec cnt-down#))
+               (recur (dec num-trials-left#))
                (shrink-failure-case ~docstring?
                                     ~(vec (take-nth 2 bindings))
-                                    snd-bindings#
+                                    bindings-rhss#
                                     ~body)))))
        (finally
          ~conclusion-signal))))
@@ -92,8 +92,8 @@
     form))

 (defmethod validate "formula" [[_formula_ & args :as form]]
-  (let [[docstring? opt-map bindings body] (deconstruct-formula-args args)
-        invalid-keys (remove (partial = :num-trials) (keys opt-map))]
+  (let [[docstring? opts-map bindings body] (deconstruct-formula-args args)
+        invalid-keys (remove (partial = :num-trials) (keys opts-map))]
     (cond (not (leaves-contain-arrow? (check-part-of args)))
           (simple-report-validation-error form "There is no expection in your formula form:")

@@ -111,9 +111,9 @@
           (not (empty? invalid-keys))
           (simple-report-validation-error form (format "Invalid keys (%s) in formula's options map. Valid keys are: :num-trials" (join ", " invalid-keys)))

-          (and (:num-trials opt-map)
-               (not (pos? (:num-trials opt-map))))
-          (simple-report-validation-error form (str ":num-trials must be an integer 1 or greater. You tried to set it to: " (:num-trials opt-map)))
+          (and (:num-trials opts-map)
+               (not (pos? (:num-trials opts-map))))
+          (simple-report-validation-error form (str ":num-trials must be an integer 1 or greater. You tried to set it to: " (:num-trials opts-map)))

           :else
-          [docstring? opt-map bindings body])))+          [docstring? opts-map bindings body])))


Handle ref-objects

Handle ref-objects

--- src/discuss/integration.cljs
+++ src/discuss/integration.cljs
@@ -84,11 +84,12 @@
 (defn convert-reference
   "Find parent of reference, split it into parts and wrap the original reference for highlighting and interaction."
   [ref]
-  (let [doms-raw  (.getElementsByTagName js/document "*")
+  (let [ref-text  (:text ref)
+        doms-raw  (.getElementsByTagName js/document "*")
         doms      (minify-doms doms-raw)
-        parent    (get-parent doms ref)
-        dom-parts (string/split (.-innerHTML parent) (re-pattern ref))
-        dom-ref   (str "" ref "")
+        parent    (get-parent doms ref-text)
+        dom-parts (string/split (.-innerHTML parent) (re-pattern ref-text))
+        dom-ref   (str "" ref-text "")
         new-dom   (str (first dom-parts) dom-ref (last dom-parts))]
     (when parent
       (set! (.-innerHTML parent) new-dom))))
@@ -98,4 +99,4 @@
   [refs]
   (doall (map #(convert-reference %) refs))
   (let [arguments (.getElementsByClassName js/document "arguments-toggle")]
-    (register-arguments arguments)))
+    (register-arguments arguments)))


STORM-205. Add REST API to Storm UI. undid the complete-latencies fix with last commit added back

--- storm-core/src/clj/backtype/storm/ui/core.clj
+++ storm-core/src/clj/backtype/storm/ui/core.clj
@@ -284,11 +284,11 @@
     (merge-with
      (fn [s1 s2]
        (merge-with + s1 s2))
-     (select-keys agg-bolt-stats [:emitted :transferred :acked :failed])
-     (select-keys agg-spout-stats [:emitted :transferred :acked :failed])
+     (select-keys agg-bolt-stats [:emitted :transferred :acked :failed :complete-latencies])
+     (select-keys agg-spout-stats [:emitted :transferred :acked :failed :complete-latencies])
      )))

-(defn stats-times [stats-map]
+(Defn stats-times [stats-map]
   (sort-by #(Integer/parseInt %)
            (-> stats-map
                clojurify-structure


Killing the rotation thread explicitly

Killing the rotation thread explicitly

otherwise it may still run in the background.

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/draw/lattices.clj
+++ src/conexp/contrib/draw/lattices.clj
@@ -337,7 +337,9 @@
       (update-layout-of-scene scn (layout (get-value))))
     (with-action-on rotate
       (if-not (nil? @rotate-thread)
-        (reset! rotate-thread nil)
+        (do
+          (.stop @rotate-thread)
+          (reset! rotate-thread nil))
         (do
           (update-layout-of-scene scn (layout (get-value)))
           (fit-scene-to-layout scn)


Remove blank line.

Remove blank line.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -104,7 +104,6 @@
 ;;;
 ;;; Tests for other input data types.
 ;;;
-
 (deftest clojure-vector-to-java-map-with-additional-operation-and-two-data-values-test
   (let [expected {"quotient" 2}
         input-data [1 8 1 1 1 4 1 1]


Logical badge naming

Logical badge naming

--- src/golden_kestrel/core.cljs
+++ src/golden_kestrel/core.cljs
@@ -7,6 +7,14 @@
     [om.dom :as dom :include-macros true]))

 (enable-console-print!)
+
+(def badge-types
+  [["4" "Small badge"]
+   ["2" "Medium badge"]
+   ["1" "Large badge"]
+   ["donut" "Small donut"]
+   ["medium-donut" "Medium donut"]
+   ["large-donut" "Large donut"]])

 (def app-state
   (atom {:badge-type "medium-donut",
@@ -72,17 +80,14 @@
       (dom/fieldset
         nil
         (dom/label #js {:htmlFor "kestrel-badge-type"} "Badge type")
-        (dom/select #js {:ref "badgeType"
-                         :id "kestrel-badge-type"
-                         :value (:badge-type data)
-                         :defaultValue (:badge-type data)
-                         :onChange (partial change-data :badge-type)}
-                    (dom/option #js {:value ""} "Default")
-                    (dom/option #js {:value "1"} "1")
-                    (dom/option #js {:value "4"} "4")
-                    (dom/option #js {:value "donut"} "Donut")
-                    (dom/option #js {:value "medium-donut"} "Medium donut")
-                    (dom/option #js {:value "large-donut"} "Large donut"))
+        (apply dom/select
+               #js {:ref "badgeType"
+                    :id "kestrel-badge-type"
+                    :value (:badge-type data)
+                    :defaultValue (:badge-type data)
+                    :onChange (partial change-data :badge-type)}
+               (for [[value text] badge-types]
+                 (dom/option #js {:value value} text)))
         (dom/label #js {:htmlFor "kestrel-popover"} "Popover")
         (dom/select #js {:ref "popover"
                          :id "kestrel-popover"


Cleanup aeron dirs on exit.

Cleanup aeron dirs on exit.

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -11,7 +11,7 @@
              [uk.co.real_logic.aeron Aeron$Context]
              [uk.co.real_logic.agrona.concurrent UnsafeBuffer]
              [uk.co.real_logic.agrona CloseHelper]
-             [uk.co.real_logic.aeron.driver MediaDriver]
+             [uk.co.real_logic.aeron.driver MediaDriver MediaDriver$Context]
              [uk.co.real_logic.aeron.common.concurrent.logbuffer DataHandler]
              [uk.co.real_logic.agrona.concurrent IdleStrategy BackoffIdleStrategy]
              [java.util.function Consumer]
@@ -21,7 +21,9 @@
   component/Lifecycle
   (start [component]
     (taoensso.timbre/info "Starting Aeron Peer Group")
-    (let [media-driver (MediaDriver/launch)]
+    (let [ctx (MediaDriver$Context.)
+          _ (.dirsDeleteOnExit ctx true)
+          media-driver (MediaDriver/launch ctx)]
       (assoc component :media-driver media-driver)))

   (stop [{:keys [media-driver] :as component}]


Update cljdev

Update cljdev

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1,5 +1,5 @@
 {:user
- {:dependencies [[cljdev "0.6.3-SNAPSHOT"]]
+ {:dependencies [[cljdev "0.6.7-SNAPSHOT"]]
   :injections   [(require 'nu)]
   :repositories [["nu-maven" {:url "s3p://nu-maven/releases/"
                               :username [:gpg :env/artifacts_aws_access_key_id]


Formatting

Formatting

--- lein/profiles.clj
+++ lein/profiles.clj
@@ -1,14 +1,14 @@
 {
- :user {
-        :plugins [
-                  [lein-ancient "0.5.5"]
-                  ]
-        }
- :dev {
-        :dependencies [[clj-stacktrace "0.2.8"]]
-        :injections [(require 'clj-stacktrace.repl)]
-        :repl-options {
-                       :caught clj-stacktrace.repl/pst+
-                       }
-        }
- }
+  :user {
+    :plugins [
+      [lein-ancient "0.5.5"]
+    ]
+  }
+  :dev {
+    :dependencies [[clj-stacktrace "0.2.8"]]
+    :injections [(require 'clj-stacktrace.repl)]
+    :repl-options {
+      :caught clj-stacktrace.repl/pst+
+    }
+  }
+}


Prettier save file

Prettier save file


add test for upgrading with metadata.

add test for upgrading with metadata.

--- test/leiningen/ancient/artifact/zip_test.clj
+++ test/leiningen/ancient/artifact/zip_test.clj
@@ -33,6 +33,27 @@
   [:dependencies 0]

   (str "(defproject project-x \"0.1.1-SNAPSHOT\"\n"
+       "  :dependencies #^:replace [[xyz \"0.2.0\"]\n"
+       "                            %s\n"
+       "                            [abc \"0.3.0\"]])")
+  read-project-zipper!
+  [:dependencies 1]
+
+  (str "(defproject project-x \"0.1.1-SNAPSHOT\"\n"
+       "  :dependencies ^:replace [[xyz \"0.2.0\"]\n"
+       "                           %s\n"
+       "                           [abc \"0.3.0\"]])")
+  read-project-zipper!
+  [:dependencies 1]
+
+  (str "(defproject project-x \"0.1.1-SNAPSHOT\"\n"
+       "  :dependencies [[xyz \"0.2.0\"]\n"
+       "                 ^:some-meta %s\n"
+       "                 [abc \"0.3.0\"]])")
+  read-project-zipper!
+  [:dependencies 1]
+
+  (str "(defproject project-x \"0.1.1-SNAPSHOT\"\n"
        "  :dependencies [#_[ignore] %s])")
   read-project-zipper!
   [:dependencies 0]


Save workspace working, still needs some validations and dynamic filenames, check comments in code

--- webui/src/webui/routes/api.clj
+++ webui/src/webui/routes/api.clj
@@ -32,10 +32,16 @@
    :headers {"Content-Type" "application/json; charset=utf-8"}
    :body (json/generate-string data)})

+(defn yaml-response [data & [status]]
+  {:status (or status 200)
+   :headers {"Content-Type" "text/plain; charset=utf-8"}
+   :body data})
+
 (defn save-workspace [workspace]
   ; TODO handle nil or invalid data for spit
-  (spit (str savedir "/workspace.sav")  ; TODO dynamic filename
-        (yaml/generate-string (json/parse-string workspace))))
+  (def yaml-workspace (yaml/generate-string (json/parse-string workspace)))
+  (spit (str savedir "/workspace.sav") yaml-workspace); TODO dynamic filename
+  (yaml-response yaml-workspace))

 (defn load-workspace []
   (json-response "hola"))


set project environment

set project environment

--- rest-media-demo/project.clj
+++ rest-media-demo/project.clj
@@ -1,12 +1,14 @@
 (defproject rest-media-demo "0.1.0-SNAPSHOT"
-  :description "FIXME: write description"
-  :url "http://example.com/FIXME"
   :min-lein-version "2.0.0"
   :dependencies [[org.clojure/clojure "1.7.0"]
                  [compojure "1.4.0"]
-                 [ring/ring-defaults "0.1.5"]]
+                 [ring/ring-defaults "0.1.5"]
+                 [liberator "0.13"]
+                 [org.clojure/data.json "0.2.6"]]
   :plugins [[lein-ring "0.9.7"]]
-  :ring {:handler rest-media-demo.handler/app}
+  :ring {:handler rest-media-demo.handler/app
+         :auto-reload? true
+         :auto-refresh? true}
   :profiles
   {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                         [ring/ring-mock "0.3.0"]]}})


CMR-4283: Updated docstring.

CMR-4283: Updated docstring.

--- transmit-lib/src/cmr/transmit/association.clj
+++ transmit-lib/src/cmr/transmit/association.clj
@@ -16,8 +16,7 @@
           concept-id))

 (defmulti associations-url
-  "Returns the url to associate a variable based on the association type.
-  Valid association types are :query and :concept-ids."
+  "Returns the url to associate a concept with the given concept id to collections."
   (fn [context concept-id]
     (:concept-type (concepts/parse-concept-id concept-id))))


Pick a slightly better name

Pick a slightly better name

--- test/vip/data_processor/db/translations/v5_1/contact_information_test.clj
+++ test/vip/data_processor/db/translations/v5_1/contact_information_test.clj
@@ -25,9 +25,9 @@
       (is (empty? (set (transform-fn idx-fn parent-path row)))))

     (testing "at least one field builds a ContactInformation child"
-      (let [funky-row (assoc row :ci_address_line_1 "123 Lonely Ln")]
+      (let [minimal-row (assoc row :ci_address_line_1 "123 Lonely Ln")]
         (is (contains?
-             (set (transform-fn idx-fn parent-path funky-row))
+             (set (transform-fn idx-fn parent-path minimal-row))
              {:path "VipObject.0.Person.100.ContactInformation.27.AddressLine.0"
               :value "123 Lonely Ln"
               :simple_path "VipObject.Person.ContactInformation.AddressLine"


reserve OPTIONS if cors-origin is configured

--- src/io/sarnowski/swagger1st/core.clj
+++ src/io/sarnowski/swagger1st/core.clj
@@ -200,8 +200,16 @@
       (assoc response :body (serializer (:body response)))
       response)))

+(defn- add-cors-headers [response cors-origin]
+  (-> response
+      (r/header "Access-Control-Allow-Origin" cors-origin)
+      (r/header "Access-Control-Max-Age" "3600")
+      (r/header "Access-Control-Allow-Methods" "GET, POST, DELETE, PUT, PATCH, OPTIONS")
+      (r/header "Access-Control-Allow-Headers" "*")))
+
 (defn swagger-mapper
-  "A ring middleware that uses a swagger definition for mapping a request to the specification."
+  "A ring middleware that uses a swagger definition for mapping a request to the specification.
+   Hint: if you set cors-origin, all OPTIONS requests will be ignored and used solely for CORS."
   [chain-handler swagger-definition-type swagger-definition & {:keys [surpress-favicon cors-origin]
                                                                :or   {surpress-favicon true}}]
   (let [definition (schema/validate swagger-2-0/root-object
@@ -210,9 +218,17 @@
     (log/debug "swagger-definition" definition)

     (fn [request]
-      (if (and surpress-favicon (= (:uri request) "/favicon.ico"))
+      (cond
+        (and surpress-favicon (= "/favicon.ico" (:uri request)))
         (-> (r/response "No favicon available.")
             (r/status 404))
+
+        (and cors-origin (= :options (:request-method request)))
+        (-> (r/response nil)
+            (r/status 200)
+            (add-cors-headers cors-origin))
+
+        :else
         (let [[request-key swagger-request] (lookup-swagger-request request)]
           (log/debug "swagger-request:" swagger-request)
           (let [response (chain-handler (-> request
@@ -221,11 +237,7 @@
                                             (assoc :swagger-request-key request-key)))]
             (let [response (serialize-response request response)]
               (if cors-origin
-                (-> response
-                    (r/header "Access-Control-Allow-Origin" cors-origin)
-                    (r/header "Access-Control-Max-Age" "3600")
-                    (r/header "Access-Control-Allow-Methods" "GET, POST, DELETE, PUT, PATCH, OPTIONS")
-                    (r/header "Access-Control-Allow-Headers" "*"))
+                (add-cors-headers response cors-origin)
                 response))))))))

 (defn- swaggerui-template


clojure-programming:: finished chap6:: data-types and protocols

--- src/clojure_learning/clj_programming_data_types_and_protocols.clj
+++ src/clojure_learning/clj_programming_data_types_and_protocols.clj
@@ -237,6 +237,8 @@
 ;; accessor methods: set! or use inside the body by simply referencing them.

 ;; to expose some methods on the defrecord animal -> we can create a protocol to mutate-access the Animal defrecord
+
+;; here's a version of augmenting an existing protocol to a new TYpe via inline implementation:
 (defprotocol AnimalMutation
   "A simple protocol to allow access to Animal mutable members"
   (get-specie [this])
@@ -252,8 +254,120 @@
 (set-specie! wolf "cat")
 (get-specie wolf)     ;; "cat"

-
-;; the only way to access the mutation capabilities on clojure deftypes mutable fields is TO EXPOSE
-;; behavior for such operations, ONLY when the TYPE is declared/defined!!!
-
-
+;; there are ONLY TWO ways to augment a given type with a protocol:
+;;;;;;;;;;
+;; NOTE: these 2 forms are ONLY for public-final fields!!! and not for private mutable fields
+;;;;;;;;;;
+;; 1. augmenting a type when the type is defined, via inline implementation for the protocol
+;; 2. augmenting an already existing type, with a new created protocol via extend-protocol
+
+;; let's start from scratch by defining a new type (this should be the existig type in historical time)
+(deftype HumanBeing [^:unsynchronized-mutable who ^:unsynchronized-mutable age])
+
+;; then define a new protocol that we're gonna use to augment the existing mutable type
+(defprotocol HumanMutation
+  (getName [this] (.who this))
+  (setName! [this new-name] (set! (. this who) new-name)))
+
+;; then extend the new-protocol to the existing type
+(extend-protocol HumanMutation
+  HumanBeing
+  (getName [this] (. this who))
+  (setName! [this new-name] (set! (. this who) new-name)))
+
+(def cclaudiu (->HumanBeing "cclaudiu" 34))
+(.getName cclaudiu)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(deftype Languages [lang-code paradigm])
+
+(defprotocol LanguageServiceProtocol
+  (get-lang-code [this])
+  (get-lang-paradigm [this]))
+
+(extend-protocol LanguageServiceProtocol
+  Languages
+  (get-lang-code [this] (.lang-code this))
+  (get-lang-paradigm [this] (.paradigm this)))
+
+(def clojure-lang (->Languages "CLJ" "FP"))
+(get-lang-code clojure-lang)   ;; CLJ
+;; ---> WORKS NICEEEEEEE because the fields for deftype are public and can be accessed AFTER THE TYPE is DECLARED.
+
+;; ONE IMPORTANT THING TO NOTE HERE:
+;; defrecord participating in the MAP Collection Abstraction -> it's keys/fields can be used
+;; as accessor-functions to lookup values bound to the fields,
+;; on the other side deftype is NOT participating in the Map-Collection-Abstraction and therefore
+;; deftype will work ONLY using java interoperabilty, to access values bound to fields.
+(.member DEF-TYPE)
+(:member DEF-RECORD)
+;; this is valid only for public static final members, to be accessible AFTER THE TYPE is declared!
+
+;;;;;;;;;;;;
+;; Types Inline Implementation
+;;;;;;;;;;;;
+;; generally inline implementation provides better performance, since protocol polymorphic methods
+;; can have DIRECT access to fields defined in declared Types + will be as fast as calling
+;; java interfaces methods.
+;; JVM optimizes method calls to extremme!
+;; inline implementation raises the potential for duplicate-method-signature exception to be thrown,
+;; if ONE Type defines implementation for 2 protocols which have methods with the same signatures.
+;; this is true also for any attempt to implement a protocol, for a type, which type already implements
+;; some of the java.util.Map interface.
+
+;; guideliness in clojure:: always use inline implementation for performance optimizations! not as a
+;; first idea!
+;; inline implementation are the only to provide implementation for java interfaces!!! Just as with
+;; protocols there's NOT mandatory to implement all the methods that the interface defines ->
+;; an exception is triggered on the first attempt to use an-unimplemented method!
+
+;; there's YET another way to declare a new type. this is more likely behaving as the anonymous inner classes
+;; that java provides. this is realizable using "REIFY". which has the declaration rules as the deftype
+;; or defrecord, but without the Type NAME. using [reify] one can opt to provide implementation ONLY
+;; for SOME of the methods that protocol defines (and not all).
+
+(def clojure-reified
+      (reify LanguageServiceProtocol
+        (get-lang-code [this]
+          (.lang-code (->Languages "clojure" nil)))))
+
+(get-lang-code clojure-lang-code)  ;; clojure
+
+;; reify is a powerfull inliner tool, that behaves more like lambda-expressions. We can reify on the fly
+;; a protocol for an anonymous type, providing some "hardcoded/concrete" types in the body of the
+;; protocol/method we implement. This whole thing returns a reified object back. from this on
+;; since our object-reified implemented the protocol, we can apply the functions which were implemented on it.
+
+;; another example/usage of reify::
+(def reified
+  (reify
+    LanguageServiceProtocol
+    (get-lang-paradigm [this] (.paradigm (->Languages "clojure" "functional-programming")))))
+
+(get-lang-paradigm reified) ;; functional-programming
+
+;; Clojure drops the support for Type based inheritance in the favour of "programming to interfaces/protocols".
+;; Types can ONLY satisfy protocols or implement interfaces!
+;; theefore clojure enforces the idea to prefer composition over type-based-inheritance reusable entities.
+
+;; [extend] is a function, it takes the context of protocol to implement as func-keys inside a map;
+;; [extend] is a function, while [extend-type] [extend-protocol] are both macros;
+;; [extend] taking the context-implementation in a map, this map can be augmented with other implementations
+;; simulating the mechanism of mixins or traits.
+
+;; to simulate inheritance, this gate is opened by the [extend] function:
+;; 1. declare a abstract-parent-object
+(def abstract-vov
+  {:cols (fn [this] (apply map vector this))
+   :rows (fn [this] (count this))})
+(extend clojure.lang.IPersistentVector
+  Matrix
+  (assoc abstract-vov
+     :lookup (fn [this i j] (get-in this [i j]))
+     :dims (fn [this] [(count this) (count (first this))])
+     :update (fn [this i j new-val] (update-in this [i j] (fn [old-val] new-val)))))
+
+(dims [[1 2 3] [3 4 5]])
+(update [[1 2] [3 4]] 0 0 24) ;; [[24 2] [3 4]]
+(cols [[1 2] [3 4]]) ;; [[1 3] [2 4]] --> cols in "mixed-in" with the abstraction
+


whoops

whoops

--- src/huon/log.cljs
+++ src/huon/log.cljs
@@ -23,13 +23,16 @@
    :warn  Level/WARNING
    :error Level/SEVERE})

+(defn- get-logger [name]
+  (LogManager/getLogger name))
+
 (defn set-level!
   "Set a per-namespace logging level. This overrides the level defined by
   (set-root-level!)."
   [logger-or-name level]
   {:pre [(contains? levels level)]}
   (let [logger (if (string? logger-or-name)
-                 (LogManager/getLogger logger-or-name)
+                 (get-logger logger-or-name)
                  logger-or-name)]
     (.setLevel logger (levels level))))


Local hostname option now :localhost

Local hostname option now :localhost

--- src/riemann/jvm_profiler.clj
+++ src/riemann/jvm_profiler.clj
@@ -49,7 +49,7 @@
   :port       Riemann HTTP port.
   :prefix     Service prefix for distinguishing this telemetry from other apps
               (default \"\")
-  :host       Override the hostname (default: nil; calls (localhost))
+  :localhost  Override the hostname (default: nil; calls (localhost))
   :dt         How often to send telemetry events to Riemann, in seconds
               (default 5)
   :load       Target fraction of one core's CPU time to use for profiling
@@ -63,7 +63,7 @@
                  dt
                  (partial report client
                           dt
-                          (:host opts)
+                          (:localhost opts)
                           (or (:prefix opts) "")))))

 (defn stop!