hashmap enacts implicit class-map functionality

--- src/show/dom.cljs
+++ src/show/dom.cljs
@@ -1,13 +1,13 @@
 (ns show.dom
-  ;; (:require [plug2.core :refer [pluggable?]])
+  (:require [show.core :refer [class-map]])
   (:refer-clojure :exclude [map meta time])
   (:require-macros [show.dom :as dom]))

-(defn process-opts [opts]
-  opts)
+(defn preprocess-opts [opts]
+  (cond-> opts
+    (and (:className opts) (map? (:className opts))) (update :className class-map)))

 (defn process-body [body]
-  ;; (if (pluggable? body) @body body)
   body)

 (defn array-map? [o]
@@ -19,9 +19,9 @@
         [opts body] (if (array-map? (first vs))
                       [(first vs) (rest vs)]
                       [nil        vs])
+        opts        (preprocess-opts opts)
         opts        (into {} (for [[k v] opts]
                                [k (if (array-map? v) (clj->js v) v)]))]
-    [(process-opts opts)
-     (clojure.core/map process-body body)]))
+    [opts (clojure.core/map process-body body)]))

 (dom/build-tags)


[network] Parameter count in table print. (#128)

--- src/cortex/nn/network.clj
+++ src/cortex/nn/network.clj
@@ -348,4 +348,5 @@
                           "output" (layer->output-str layer)}
                          (for [k parameter-keys]
                                    [k (layer->buffer-shape network layer k)])))))
-         (pprint/print-table (concat ["type" "input" "output"] parameter-keys)))))
+         (pprint/print-table (concat ["type" "input" "output"] parameter-keys)))
+    (println "Parameter count:" (graph/parameter-count (:compute-graph network)))))


Type support for LocalTime

Type support for LocalTime

--- src/tick/core.clj
+++ src/tick/core.clj
@@ -390,6 +390,14 @@
     ([from to step] (cond->> (iterate #(.plus % step) from)
                       to (take-while #(< % to))))))

+(extend-type LocalTime
+  ITimeArithmetic
+  (+ [t x] (.plus t x))
+  (- [t x] (.minus t x))
+  (maximum [x y] (if (neg? (compare x y)) y x))
+  (minimum [x y] (if (neg? (compare x y)) x y))
+  )
+
 (extend-type YearMonth
   ITimeArithmetic
   (+ [t x] (if (number? x) (.plusMonths t x) (.plus t x)))
@@ -486,8 +494,12 @@
   (end [i] (instant i))

   LocalDateTime
-  (beginning [time] time)
-  (end [end] end)
+  (beginning [x] x)
+  (end [x] x)
+
+  LocalTime
+  (beginning [x] x)
+  (end [x] x)

   nil
   (beginning [_] nil)


STORM-132 simplify code using sort-by function

--- storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
+++ storm-core/src/clj/backtype/storm/scheduler/EvenScheduler.clj
@@ -22,12 +22,7 @@
     :implements [backtype.storm.scheduler.IScheduler]))

 (defn sort-slots [all-slots]
-  (let [split-up
-         (map second
-           (reverse
-             (sort
-               (for [[host ports] (group-by first all-slots)]
-                 [(count ports) ports]))))]
+  (let [split-up (sort-by count (vals (group-by first all-slots)))]
     (apply interleave-all split-up)
     ))


Made HTML rendering more efficient

Made HTML rendering more efficient

--- src/hiccup.clj
+++ src/hiccup.clj
@@ -9,18 +9,17 @@
 (ns hiccup
   "Efficiently generate HTML from a Clojure data structure."
   (:use clojure.contrib.def)
-  (:use clojure.contrib.java-utils)
-  (:import clojure.lang.IPersistentVector)
-  (:import clojure.lang.ISeq))
+  (:use clojure.contrib.java-utils))

 (defn escape-html
   "Change special characters into HTML character entities."
-  [string]
-  (.. (as-str string)
-    (replace "&"  "&")
-    (replace "<"  "<")
-    (replace ">"  ">")
-    (replace "\"" """)))
+  [text]
+  (let [#^String string (as-str text)]
+    (.. string
+      (replace "&"  "&")
+      (replace "<"  "<")
+      (replace ">"  ">")
+      (replace "\"" """))))

 (def h escape-html)   ;; alias for escape-html

@@ -55,11 +54,10 @@
   [tag]
   (rest (re-matches re-tag (as-str tag))))

-(defmulti render-html
-  "Render a Clojure data structure to a string of HTML."
-  type)
+(declare render-html)

-(defmethod render-html IPersistentVector
+(defn render-tag
+  "Render a HTML tag represented as a vector."
   [[tag & content]]
   (let [[tag id class]  (parse-tag-name tag)
         tag-attrs       {:id id
@@ -74,12 +72,13 @@
            "</" tag ">")
       (str "<" tag (make-attrs attrs) " />"))))

-(defmethod render-html ISeq
-  [coll]
-  (apply str (map render-html coll)))
-
-(defmethod render-html :default [x]
-  (as-str x))
+(defn render-html
+  "Render a Clojure data structure to a string of HTML."
+  [data]
+  (cond
+    (vector? data) (render-tag data)
+    (seq? data)    (apply str (map render-html data))
+    :otherwise     (as-str data)))

 (defn html
   "Render Clojure data structures to HTML."


Improve user testing utilities.

Improve user testing utilities.

--- dev/user.clj
+++ dev/user.clj
@@ -62,7 +62,9 @@
 (defn sample-record-data
   "Generates a vector of `n` maps of record data using the given field keys."
   [field-keys n]
-  (rand-nth (gen/sample (gen/vector (mdgen/record-data field-keys) n))))
+  (rand-nth (gen/sample (gen/vector (gen/map (gen/elements field-keys)
+                                             gen/large-integer)
+                                    n))))

 (defn sample-subset
@@ -106,10 +108,17 @@
                         (sample-record-data
                           field-keys
                           (count extant-keys)))
+        pick-half (fn [xs]
+                    (let [half (int (/ (count xs) 2))]
+                      (condp > (rand)
+                        0.25 nil
+                        0.50 (take half xs)
+                        0.75 (drop half xs)
+                             xs)))
         changes (merge
-                  (let [ins-keys (sample-subset 0.25 record-keys)]
+                  (let [ins-keys (sample-subset 0.25 (pick-half record-keys))]
                     (zipmap ins-keys (sample-record-data field-keys (count ins-keys))))
-                  (let [del-keys (sample-subset 0.25 record-keys)]
+                  (let [del-keys (sample-subset 0.25 (pick-half record-keys))]
                     (zipmap del-keys (repeat ::patch/tombstone))))]
     {:families families
      :records records
@@ -123,8 +132,7 @@
         params {::record/families families
                 ::index/branching-factor branch-factor
                 ::part/limit part-limit}
-        parts (part/partition-records store params records)
-        root (index/build-tree store params parts)]
+        root (index/from-records store params records)]
     (try
       (let [root' (index/update-tree store params root changes)
             old-nodes (viz/find-nodes store {}


dont ignore decimals in calculations

dont ignore decimals in calculations

--- src/dataanalysis/core.clj
+++ src/dataanalysis/core.clj
@@ -23,29 +23,29 @@
   (int (Math/ceil v)))

 (defn calc-unemployment-ratio
-  ([lfprpop wrpop]  (rounded-value (* (/ (- lfprpop wrpop) lfprpop) 1000)))
-  ([lfprpop wrpop pop] (rounded-value (* (/ (- lfprpop wrpop) pop) 1000))))
+  ([lfprpop wrpop]  (* (/ (- lfprpop wrpop) lfprpop) 1000))
+  ([lfprpop wrpop pop] (* (/ (- lfprpop wrpop) pop) 1000)))

 (defn calc-state-pop [constant estpop statepop gender-constant gender]
-  (rounded-value (+ constant (* estpop statepop) (* gender-constant gender))))
+  (+ constant (* estpop statepop) (* gender-constant gender)))

 (defn calc-population [statepop constant
                        estpop gender-constant
                        gender]
-  (rounded-value (/ (* statepop
-                       (calc-state-pop constant estpop
-                                       statepop gender-constant
-                                       gender)) 1000)))
+  (/ (* statepop
+        (calc-state-pop constant estpop
+                        statepop gender-constant
+                        gender)) 1000))

 (defn calc-state-lfpr [constant estpop gender-constant gender spp]
   {:year (:year spp) :lfpr (cond (<= (:year spp) 2014) (:lfpr spp)
-                                 :else (calc-state-pop constant estpop
-                                                       (:population spp)
-                                                       gender-constant
-                                                       gender))
-   :lfprpop (calc-population (:population spp) constant
-                             estpop gender-constant
-                             gender)
+                                 :else (rounded-value (calc-state-pop constant estpop
+                                                                      (:population spp)
+                                                                      gender-constant
+                                                                      gender)))
+   :lfprpop (rounded-value (calc-population (:population spp) constant
+                                            estpop gender-constant
+                                            gender))
    :statepop (:population spp)
    :gender (:gender spp)})

@@ -53,11 +53,12 @@

 (defn calc-state-wpr [constant estpop gender-constant gender spp]
   {:year (:year spp) :wpr (cond (<= (:year spp) 2014) (:wpr spp)
-                                :else (calc-state-pop constant estpop (:population spp)
-                                                      gender-constant gender))
-   :wprpop (calc-population (:population spp) constant
-                             estpop gender-constant
-                             gender-constant)
+                                :else (rounded-value (calc-state-pop constant estpop
+                                                                     (:population spp)
+                                                                     gender-constant gender)))
+   :wprpop (rounded-value (calc-population (:population spp) constant
+                                           estpop gender-constant
+                                           gender))
    :statepop (:population spp)
    :gender (:gender spp)})

@@ -92,17 +93,15 @@
                       sspw (first (filter #(= (:rate %) "WPR") spe))
                       lfpr (get-unemp-pop sspl o)
                       wpr (get-unemp-pop sspw o)
-                      lfprpop (rounded-value
-                               (/ (* lfpr (:population o)) 1000))
-                      wprpop (rounded-value
-                              (/ (* wpr (:population o)) 1000))
+                      lfprpop (read-string (format "%.2f" (/ (* lfpr (:population o)) 1000)))
+                      wprpop (read-string (format "%.2f" (/ (* wpr (:population o)) 1000)))
                       upr  (calc-unemployment-ratio
                             lfprpop
                             wprpop)]

-                  {:upr upr
+                  {:upr (rounded-value upr)
                    :year (:year o)
-                   :statepop lfprpop
+                   :statepop (rounded-value  lfprpop)
                    :unemppersons (rounded-value
                                   (/ (* upr lfprpop) 1000))
                    :gender (:gender o)}))) sp))
@@ -111,23 +110,20 @@
   (map (fn [o] (if (<= (:year o) 2014)
                 {:year (:year o) :pur (:pur o)
                  :statepop (:population o)
-                 :unemppersons (rounded-value
-                                (/ (* (:pur o) (:population o))
-                                   1000))
+                 :unemppersons (rounded-value (/ (* (:pur o) (:population o))
+                                                 1000))
                  :gender (:gender o)
                  }
                 (let [sspl (first (filter #(= (:rate %) "LFPR") spe))
                       sspw (first (filter #(= (:rate %) "WPR") spe))
                       wpr (get-unemp-pop sspw o)
                       lfpr (get-unemp-pop sspl o)
-                      lfprpop (rounded-value
-                               (/ (* lfpr (:population o)) 1000))
-                      wprpop (rounded-value
-                              (/ (* wpr (:population o)) 1000))
+                      lfprpop (/ (* lfpr (:population o)) 1000)
+                      wprpop (/ (* wpr (:population o)) 1000)
                       pur (calc-unemployment-ratio lfprpop
                                                    wprpop
                                                    (:population o))]
-                  {:pur pur
+                  {:pur (rounded-value pur)
                    :year (:year o)
                    :statepop (:population o)
                    :unemppersons (rounded-value


- fix tuple-key-fn to return array in CLJ - revert 2 of the aget -> get CLJ conditionals; the rest appear to be necessary due to use of string keys

--- src/datascript/query.cljc
+++ src/datascript/query.cljc
@@ -338,7 +338,7 @@
     (let [getters (to-array getters)]
       (fn [tuple]
         (list* #?(:cljs (.map getters #(% tuple))
-                  :clj  (map #(% tuple) getters)))))))
+                  :clj  (dc/into-arr (map #(% tuple) getters))))))))

 (defn hash-attrs [key-fn tuples]
   (loop [tuples     tuples
@@ -430,7 +430,7 @@
 (defn- context-resolve-val [context sym]
   (when-let [rel (some #(when (contains? (:attrs %) sym) %) (:rels context))]
     (when-let [tuple (first (:tuples rel))]
-      (#?(:cljs aget :clj get) tuple ((:attrs rel) sym)))))
+      (aget tuple ((:attrs rel) sym)))))

 (defn- rel-contains-attrs? [rel attrs]
   (not (empty? (set/intersection (set attrs) (set (keys (:attrs rel)))))))
@@ -655,7 +655,7 @@
                          t2 (:tuples rel)]
                      (let [res (aclone t1)]
                        (dotimes [i len]
-                         (when-let [idx (#?(:cljs aget :clj get) copy-map i)]
+                         (when-let [idx (aget copy-map i)]
                            (aset res i (#?(:cljs aget :clj get) t2 idx))))
                        res))
                    (next rels)


Updating search results for transformer change.

--- src/cmr/search/api/search_results.clj
+++ src/cmr/search/api/search_results.clj
@@ -85,7 +85,7 @@
   "Converts search result references into the desired format"
   [context references format]
   (let [tuples (map #(vector (:concept-id %) (:revision-id %)) references)]
-    (t/get-formatted-concept-revisions context tuples format)))
+    (map :metadata (t/get-formatted-concept-revisions context tuples format))))

 (defmethod search-results->response :xml
   [context results result-type pretty]


Accept XML elements for XML document variables

Related to #9

--- src/uruk/core.clj
+++ src/uruk/core.clj
@@ -337,6 +337,16 @@
    ;; default:
    nil ValueType/XS_STRING})

+(defn ->xml-str
+  "Assumes that its input is valid XML in some format, returning that
+  XML in its String representation. Accepts String, hiccup-style
+  vectors, and clojure.data.xml.Element."
+  [xml]
+  (cond
+    (string? xml) xml
+    (vector? xml) (xml/emit-str (xml/sexp-as-element xml))
+    (instance? clojure.data.xml.Element xml) (xml/emit-str xml)))
+
 (defn wrap-val
   "Given a Clojure value, returns a value in a type appropriate for a
   MarkLogic XdmVariable."
@@ -348,7 +358,7 @@
                       ValueFactory/newBooleanNode)
     :attribute clj-val ;; doesn't seem to be implemented by ValueFactory: "java.lang.InternalError Unrecognized valueType: attribute()"
     :binary clj-val ;; TODO
-    :comment clj-val ;; TODO
+    :comment clj-val ;; TODO, also really :comment-node

     :cts-box (str clj-val) ;; 4-element sequence or String
     :cts-circle (let [[radius [latitude longitude]] clj-val]
@@ -367,11 +377,8 @@
                                                                  (str longitude)))
                                      vertices))))

-    :document clj-val ;; :document-node, really, but we're following ValueType
-    :element (cond
-               (string? clj-val) clj-val
-               (vector? clj-val) (xml/emit-str (xml/sexp-as-element clj-val))
-               (instance? clojure.data.xml.Element clj-val) (xml/emit-str clj-val))
+    :document (->xml-str clj-val) ;; :document-node, really, but we're following ValueType
+    :element (->xml-str clj-val)
     :js-array (ValueFactory/newJSArray (json/write-str clj-val))
     :js-object (ValueFactory/newJSObject (json/write-str clj-val))
     :node clj-val
@@ -380,7 +387,7 @@
     :object-node (ValueFactory/newObjectNode (json/write-str clj-val))
     :processing-instruction clj-val ;; TODO
     :sequence clj-val ;; XXX WONTFIX -- see GitHub issue #8: "com.marklogic.xcc.exceptions.UnimplementedFeatureException - Setting variables that are sequences is not supported"
-    :text clj-val ;; TODO
+    :text clj-val ;; TODO, also really :text-node

     :xs-any-uri clj-val ;; TODO
     :xs-base64-binary clj-val ;; TODO


update sente

update sente

--- Clojure-Websockets/project.clj
+++ Clojure-Websockets/project.clj
@@ -9,7 +9,8 @@
                  [twitter-streaming-client "0.3.2"]
                  [clojurewerkz/elastisch "2.1.0-beta6"]
                  [org.clojure/tools.logging "0.3.0"]
-                 [com.taoensso/sente "0.15.1" :exclusions [org.clojure/clojure]]
+                 [com.taoensso/sente "1.1.0" :exclusions [org.clojure/clojure]]
+                 [org.clojure/core.match "0.2.1"]
                  [http-kit "2.1.18"]
                  [compojure "1.1.8"]
                  [ring "1.3.1"]


comments sorted

comments sorted

--- iwaswhere-web/src/clj/iwaswhere_web/graph.clj
+++ iwaswhere-web/src/clj/iwaswhere_web/graph.clj
@@ -1,6 +1,5 @@
 (ns iwaswhere-web.graph
   (:require [ubergraph.core :as uber]
-            [clojure.pprint :as pp]
             [clj-time.coerce :as ctc]
             [clj-time.core :as ct]
             [clojure.string :as s]
@@ -36,8 +35,10 @@
                 (if (uber/has-node? g n)
                   (let [attrs (uber/attrs g n)
                         comment-edges (flatten (uber/find-edges g {:dest n :relationship :COMMENT}))
-                        comment-edges (remove :mirror? comment-edges)
-                        comments (map #(uber/attrs g (:src %)) comment-edges)
+                        comments (->> comment-edges
+                                      (remove :mirror?)
+                                      (map #(uber/attrs g (:src %)))
+                                      (sort-by :timestamp))
                         entry (merge attrs {:comments comments})]
                     entry)
                   (log/warn "Cannot find node: " n))))


Histogram shouldn't melt computer. Fixes #117.

Still looks a bit rubbish, but better than before.

--- src/gorilla_plot/core.clj
+++ src/gorilla_plot/core.clj
@@ -84,7 +84,10 @@
         points-in-range (util/count-in-range data range-min range-max)
         ;; if bins :automatic then use the Sturges rule (it's simple)
         num-bins (if (= bins :automatic) (Math/ceil (+ 1 (/ (Math/log points-in-range) (Math/log 2)))) bins)
-        bin-size (/ (- range-max range-min) (double num-bins))
+        bin-size-raw (/ (- range-max range-min) (double num-bins))
+        ;; this is a hack to catch the case when all of the points are identical.
+        ;; TODO: this could probably be done in a much nicer way.
+        bin-size (if (< bin-size-raw 1e-15) 1.0 bin-size-raw)
         cat-counts (util/bin-counts data range-min range-max bin-size)
         ;; optionally normalise to probability - note that the normalisation is wrt the whole dataset, not just the
         ;; plotted portion.


Redis ping

Redis ping

--- src/harland/messaging.clj
+++ src/harland/messaging.clj
@@ -26,6 +26,11 @@
       (car/set (str prefix ":error") err)
       (car/set (str prefix ":out") out))))

+(defn status
+  "Ping redis connection"
+  []
+  (wcar* (car/ping)))
+
 (defn poll-build-queue
   "Polls the build queue"
   []


Add needed namespaces to feedback.

Add needed namespaces to feedback.

--- src/haystack/feedback.clj
+++ src/haystack/feedback.clj
@@ -4,6 +4,7 @@
             [clojure.set :refer [rename-keys]]

             [clojurewerkz.elastisch.rest.index :as esi]
+            [clojurewerkz.elastisch.rest.document :as esd]

             [haystack.repo :as r]
             ;; [clj-http.client :as client]
@@ -25,5 +26,5 @@

 (defn get-feedback
   []
-  (esd/search repo "searchecommerce" "feedback" ""))
+  (esd/search r/repo "searchecommerce" "feedback" ""))


Similar failing case for join.cljs

Similar failing case for join.cljs

--- src/aurora/join.cljs
+++ src/aurora/join.cljs
@@ -365,6 +365,17 @@
     (time (all-join-results j))
   )

+  (let [tree (tree 10)
+        _ (dotimes [i 10]
+            (let [i (+ i 0)]
+              (.assoc! tree #js [i i] (* 2 i))))
+        j (time (join-iterator #js [(magic-iterator tree #js [0 nil nil nil nil 1])
+                                    (magic-iterator tree #js [nil 0 nil nil 1 nil])
+                                    (magic-iterator tree #js [nil nil 0 1 nil nil])]))
+        ]
+    (time (all-join-results j))
+  )
+
   (let [tree1 (tree 10)
         _ (doseq [x [#js [0 1 4]
                      #js [0 1 6]


Beefs up item hash to include more details.

--- src/az_wish/core.clj
+++ src/az_wish/core.clj
@@ -42,8 +42,12 @@
 (defn- item-comment [item]
   (html/text (first (html/select item [:span.g-comment-quote]))))

-(defn- item-pair [link]
-  {:link (item-link link) :title (item-title link)})
+(defn- item-hash [link]
+  {:title (item-title link)
+   :link (item-link link)
+   :price (item-price link)
+   :availability (item-availability link)
+   :comment (item-comment link)})

 (defn- next-link [dom]
   ; Single page wishlists will not have the element at all.
@@ -52,16 +56,18 @@
     (if-let [nxt (-> a-last :content first :attrs)]
       (az-link (:href nxt)))))

+(defn- get-links [links]
+  (map item-hash links))
+
 (defn wishlist [id]
-  (letfn [(get-links [links] (map item-pair links))]
-    (loop [url (list-url id)
-           coll '()]
-      (if (nil? url)
-        coll
-        (let [resource (fetch-url url)
-              links (items resource)]
-          (recur (next-link resource)
-                 (concat coll (get-links links))))))))
+  (loop [url (list-url id)
+         coll '()]
+    (if (nil? url)
+      coll
+      (let [resource (fetch-url url)
+            links (items resource)]
+        (recur (next-link resource)
+               (concat coll (get-links links)))))))

 (def cli-options
   [["-w" "--wishlist" "ID of the wishlist to grab data and links for."]])


Handling single-page lists.

Handling single-page lists.

Just swallowing the NPE until I can get a clean way around the next-link
issue.

--- src/az_wish/core.clj
+++ src/az_wish/core.clj
@@ -24,6 +24,8 @@

 (defn- next-link [dom]
   ; Written this way to avoid Util.java:221 RuntimeException for Unmatched delimiter: )
+  ; Will throw NPE for single-page wish lists.
+  ; Will throw CCE for last page of multi-page lists.
   (az-link (((first ((first (html/select dom [:#wishlistPagination :li.a-last])) :content)) :attrs) :href)))

 (defn wishlist [id]
@@ -34,5 +36,5 @@
         coll
         (let [resource (fetch-url url)
               links (items resource)]
-          (recur (try (next-link resource) (catch ClassCastException _ nil))
+          (recur (try (next-link resource) (catch ClassCastException _ nil) (catch NullPointerException _ nil))
                  (concat coll (get-links links))))))))


Improve docs.cljs console noise

Improve docs.cljs console noise

--- doc/src/edge/doc/doc.cljs
+++ doc/src/edge/doc/doc.cljs
@@ -53,7 +53,6 @@
             "GET" "/hello"
             (fn [ev req]
               (dom/removeChildren output)
-              (js/console.dir ev)
               (dom/append output (source-listing
                                    (str
                                      (.getAllResponseHeaders req)
@@ -72,9 +71,9 @@
 (set!
   (.-onload js/window)
   (fn [ev]
-    ;;(println "windows loaded")
+    (println "Edge: window loaded")
     (init)))

 (defn figwheel-reload []
-  (println "figwheel-reload!")
+  (println "Edge: figwheel-reload!")
   (init))


added show-insights? true to the test data for test_insights so it passes

--- test-cljs/frontend/components/test_insights.cljs
+++ test-cljs/frontend/components/test_insights.cljs
@@ -14,6 +14,7 @@
   [{:reponame "test repo"
     :username "foo user"
     :default_branch "master"
+    :show-insights? true
     :recent-builds [
                     {
                      :committer_name "Mr. M",
@@ -91,4 +92,4 @@
 ;;       (is (= "Passed"
 ;;              (utils/text (sel1 ".test-chart .legend.left")))))
 ;;     (testing "Renders correct number of bars."
-;;       (is (= 4 (.-length (sel "rect.bar")))))))+;;       (is (= 4 (.-length (sel "rect.bar")))))))


Fix wrong usage of as-> threading macro.

--- src/beicon/core.cljc
+++ src/beicon/core.cljc
@@ -887,12 +887,12 @@
                (cond
                  (every? observable? items)
                  (as-> items $
-                   (clojure.core/map as-observable items)
+                   (clojure.core/map as-observable $)
                    (Observable/zip ^Iterable $ (as-function #(apply selector (seq %)))))

                  (every? flowable? items)
                  (as-> items $
-                   (clojure.core/map as-flowable items)
+                   (clojure.core/map as-flowable $)
                    (Flowable/zip ^Iterable $ (as-function #(apply selector (seq %)))))

                  :else


fix typo, use == for numeric comparison

fix typo, use == for numeric comparison

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -258,7 +258,7 @@
     :else (match-int s (doto (.matcher int-pattern s) .matches))))

 (defn- parse-symbol [^String token]
-  (when (not (= "" token))
+  (when-not (= "" token)
     (let [ns-idx (.indexOf token "/")
           ns (if-not (== -1 ns-idx) (.substring token 0 ns-idx))]
       (if (nil? ns)
@@ -296,33 +296,33 @@
 (defn read-unicode-char
   ([^String token offset length base]
      (let [l (+ offset length)]
-       (when-not (= (.length token) l)
+       (when-not (== (.length token) l)
          (throw (IllegalArgumentException. (str "Invalid unicode character: \\" token))))
        (loop [uc 0 i offset]
-         (if (= i l)
+         (if (== i l)
            (char uc)
            (let [d (Character/digit (.charAt token i) ^int base)]
-             (if (= d -1)
+             (if (== d -1)
                (throw (IllegalArgumentException. (str "Invalid digit: " (.charAt token i))))
                (recur (long (* uc (+ base d))) (inc i))))))))

   ([rdr initch base length exact?]
      (let [uc (Character/digit ^char initch ^int base)]
-       (if (= uc -1)
+       (if (== uc -1)
          (throw (IllegalArgumentException. (str "Invalid digit: " initch))))
        (loop [i 1 uc uc]
-         (if-not (= i length)
+         (if-not (== i length)
            (let [ch (peek-char rdr)]
              (if (or (nil? ch)
                      (whitespace? ch)
                      (macros ch))
                (if exact?
                  (throw (IllegalArgumentException.
-                         (str "Invalid character lenght: " i ", should be: " length)))
+                         (str "Invalid character length: " i ", should be: " length)))
                  (char uc))
                (let [d (Character/digit ^char ch ^int base)]
                  (read-char rdr)
-                 (if (= d -1)
+                 (if (== d -1)
                    (throw (IllegalArgumentException. (str "Invalid digit: " (char ch))))
                    (recur (inc i) (long (* uc (+ base d))))))))
            (char uc))))))
@@ -334,7 +334,7 @@
       (let [token (read-token rdr ch)]
         (cond

-          (= 1 (.length token))  (Character/valueOf (.charAt token 0))
+          (== 1 (.length token))  (Character/valueOf (.charAt token 0))

           (= token "newline") \newline
           (= token "space") \space
@@ -479,7 +479,7 @@
 (defn read-keyword
   [reader initch]
   (let [ch (read-char reader)]
-    (if (not (whitespace? ch))
+    (if-not (whitespace? ch)
       (let [token (read-token reader ch)
             s (parse-symbol token)]
         (if (and s (== -1 (.indexOf token "::")))
@@ -615,7 +615,7 @@
         (let [n (read rdr true nil true)]
           (if (= n '&)
             (register-arg -1)
-            (if (not (instance? Number n))
+            (if-not (instance? Number n)
               (throw (IllegalStateException. "Arg literal must be %, %& or %integer"))
               (register-arg n))))))))


Uncomment tests and closes #91

Uncomment tests and closes #91

--- test/node/replumb/require_node_test.cljs
+++ test/node/replumb/require_node_test.cljs
@@ -478,79 +478,41 @@
       (reset-env! '[my.namespace foo.bar.core foo.bar.macros])))

   (deftest ns-macro-require-include-macros
-    ;; solved in 1.7.202 - see commented test below
-    ;; the issue in replumb is https://github.com/ScalaConsultants/replumb/issues/91
+    ;; Was https://github.com/ScalaConsultants/replumb/issues/91
     (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.baz :include-macros true]))")
                   (read-eval-call "(foo.bar.baz/mul-baz 6 6)"))
-          error (unwrap-result res)]
-      (is (not (success? res)) "(ns my.namespace (:require ... :include-macros ...)) and (foo.bar.baz/mul-baz 6 6) should not succeed")
-      (is (valid-eval-error? error) "(ns my.namespace (:require ...:include-macros...)) and (foo.bar.baz/mul-baz 6 6) should be an instance of jsError")
-      (is (re-find #"Cannot read property 'call' of undefined" (extract-message error)) "(ns my.namespace (:require ...:include-macros...)) and (foo.bar.baz/mul-baz 6 6) should have correct error message.")
+          out (unwrap-result res)]
+      (is (success? res) "(ns my.namespace (:require ... :include-macros ...)) and (f/mul-baz 6 6) should succeed")
+      (is (valid-eval-result? out) "(ns my.namespace (:require ...:include-macros...)) and (f/mul-baz 6 6) should be a valid result.")
+      (is (= "36" out) "(f/mul-baz 6 6) should be 36")
       (reset-env! '[my.namespace foo.bar.baz]))

-    ;; (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.baz :include-macros true]))")
-    ;;               (read-eval-call "(foo.bar.baz/mul-baz 6 6)"))
-    ;;       out (unwrap-result res)]
-    ;;   (is (success? res) "(ns my.namespace (:require ... :include-macros ...)) and (f/mul-baz 6 6) should succeed")
-    ;;   (is (valid-eval-result? out) "(ns my.namespace (:require ...:include-macros...)) and (f/mul-baz 6 6) should be a valid result.")
-    ;;   (is (= "36" out) "(f/mul-baz 6 6) should be 36")
-    ;;   (reset-env! '[my.namespace foo.bar.baz]))
-
-    ;; solved in 1.7.202 - see commented test below
     ;; note that the test outputs (* nil nil) but the correct result is 150
     (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.core :include-macros true]))")
                   (read-eval-call "(foo.bar.core/mul-core 30 5)"))
           out (unwrap-result res)]
       (is (success? res) "(ns my.namespace (:require...:include-macros...])) and (foo.bar.core/mul-core 30 5) should succeed")
       (is (valid-eval-result? out) "(ns my.namespace (:require...:as...])) and (foo.bar.core/mul-core 30 5) should be a valid result")
-      (is (= "(* nil nil)" out) "(foo.bar.core/mul-core 30 5) should be 150")
-      (reset-env! '[my.namespace foo.bar.core foo.bar.macros]))
-
-    ;; (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.core :include-macros true]))")
-    ;;               (read-eval-call "(foo.bar.core/mul-core 30 5)"))
-    ;;       out (unwrap-result res)]
-    ;;   (is (success? res) "(ns my.namespace (:require...:include-macros...])) and (foo.bar.core/mul-core 30 5) should succeed")
-    ;;   (is (valid-eval-result? out) "(ns my.namespace (:require...:as...])) and (foo.bar.core/mul-core 30 5) should be a valid result")
-    ;;   (is (= "150" out) "(foo.bar.core/mul-core 30 5) should be 150")
-    ;;   (reset-env! '[my.namespace foo.bar.core foo.bar.macros]))
-    )
+      (is (= "150" out) "(foo.bar.core/mul-core 30 5) should be 150")
+      (reset-env! '[my.namespace foo.bar.core foo.bar.macros])))

   (deftest ns-macro-require-refer-macros
-    ;; solved in 1.7.202 - see commented version below
-    ;; the issue in replumb is https://github.com/ScalaConsultants/replumb/issues/91
+    ;; Was https://github.com/ScalaConsultants/replumb/issues/91
     (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.baz :refer-macros [mul-baz]]))")
                   (read-eval-call "(mul-baz 10 12)"))
-          error (unwrap-result res)]
-      (is (not (success? res)) "(ns my.namespace (:require ...:refer-macros...)) and (mul-baz 10 12) should not succeed")
-      (is (valid-eval-error? error) "(ns my.namespace (:require ...:refer-macros..)) and (mul-baz 10 12) should be an instance of js/Error")
-      (is (re-find #"ERROR" (extract-message error)) "(ns my.namespace (:require ...:refer-macros...)) and (mul-baz 10 12) should have correct error message")
+          out (unwrap-result res)]
+      (is (success? res) "(ns my.namespace (:require ...:refer-macros...)) and (mul-baz 10 12) should succeed")
+      (is (valid-eval-result? out) "(ns my.namespace (:require ...:refer-macros)) and (mul-baz 10 12) should be a valid result")
+      (is (= "120" out) "(mul-baz 10 12) should be equal to 120")
       (reset-env! '[my.namespace foo.bar.baz]))
-
-    ;; (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.baz :refer-macros [mul-baz]]))")
-    ;;               (read-eval-call "(mul-baz 10 12)"))
-    ;;       out (unwrap-result res)]
-    ;;   (is (success? res) "(ns my.namespace (:require ...:refer-macros...)) and (mul-baz 10 12) should succeed")
-    ;;   (is (valid-eval-result? out) "(ns my.namespace (:require ...:refer-macros)) and (mul-baz 10 12) should be a valid result")
-    ;;   (is (= "120" out) "(mul-baz 10 12) should be equal to 120")
-    ;;   (reset-env! '[my.namespace foo.bar.baz]))

     (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.core :refer-macros [mul-core]]))")
                   (read-eval-call "(mul-core 10 20)"))
-          error (unwrap-result res)]
-      (is (not (success? res)) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should not succeed")
-      (is (valid-eval-error? error) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should be an instance of js/Error")
-      (is (re-find #"ERROR" (extract-message error))
-          "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should have correct error message")
-      (reset-env! '[my.namespace foo.bar.core foo.bar.macros]))
-
-    ;; (let [res (do (read-eval-call "(ns my.namespace (:require [foo.bar.core :refer-macros [mul-core]]))")
-    ;;               (read-eval-call "(mul-core 10 20)"))
-    ;;       out (unwrap-result res)]
-    ;;   (is (success? res) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should succeed")
-    ;;   (is (valid-eval-result? out) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should have a valid result")
-    ;;   (is (= "200" out ) "(mul-core 10 20) should produce 200")
-    ;;   (reset-env! '[my.namespace foo.bar.core foo.bar.macros]))
-    )
+          out (unwrap-result res)]
+      (is (success? res) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should succeed")
+      (is (valid-eval-result? out) "(ns my.namespace (:require ...:refer-macros...)) and (mul-core 10 20) should have a valid result")
+      (is (= "200" out ) "(mul-core 10 20) should produce 200")
+      (reset-env! '[my.namespace foo.bar.core foo.bar.macros])))

   (deftest ns-macro-self-requiring-namespace
     ;; see "loop" section here: http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html
@@ -566,6 +528,7 @@
     (let [alterable-core-path "dev-resources/private/test/src/cljs/alterable/core.cljs"
           pre-content "(ns alterable.core)\n\n(def b \"pre\")"
           post-content "(ns alterable.core)\n\n(def b \"post\")"]
+
       ;; Writing "pre" version of alterable.core
       (io/write-file! alterable-core-path pre-content)
       (let [res (do (read-eval-call "(require 'alterable.core)")
@@ -587,7 +550,6 @@
         (is (= 'cljs.user (repl/current-ns)) "(require 'alterable.core :reload) and alterable.core/b should not change namespace")
         (is (= "\"post\"" out) "(require 'alterable.core :reload) and alterable.core/b should return \"post\"")
         (reset-env! '[alterable.core]))
-
       (io/delete-file! alterable-core-path)))

   (deftest process-reload-all
@@ -635,6 +597,7 @@
       validated-echo-cb (partial repl/validated-call-back! target-opts echo-callback)
       reset-env! (partial repl/reset-env! target-opts)
       read-eval-call (partial repl/read-eval-call target-opts validated-echo-cb)]
+
   (deftest require-when-read-file-return-nil
     (let [res (do (read-eval-call "(require 'clojure.string)")
                   (read-eval-call "(source clojure.string/trim)"))


Define composed specs as named type (with deftype).

--- src/bytebuf/spec.clj
+++ src/bytebuf/spec.clj
@@ -14,6 +14,65 @@
   (write [_ buff start data] "Read all data from buffer."))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Composed Spec Types
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(deftype AssociativeSpec [data dict types]
+  clojure.lang.Counted
+  (count [_]
+    (count types))
+
+  IStaticSize
+  (size [_]
+    (reduce #(+ %1 (proto/size %2)) 0 types))
+
+  ISpec
+  (read [_ buff pos]
+    (loop [index pos result {} pairs data]
+      (if-let [[fieldname type] (first pairs)]
+        (let [[readedbytes readeddata] (read type buff index)]
+          (recur (+ index readedbytes)
+                 (assoc result fieldname readeddata)
+                 (rest pairs)))
+        [(- index pos) result])))
+
+  (write [_ buff pos data']
+    (let [written (reduce (fn [index [fieldname type]]
+                            (let [value (get data' fieldname nil)
+                                  written (write type buff index value)]
+                              (+ index written)))
+                          pos data)]
+      (- written pos))))
+
+(deftype IndexedSpec [types]
+  clojure.lang.Counted
+  (count [_]
+    (count types))
+
+  IStaticSize
+  (size [_]
+    (reduce #(+ %1 (proto/size %2)) 0 types))
+
+  ISpec
+  (read [_ buff pos]
+    (loop [index pos result [] types types]
+      (if-let [type (first types)]
+        (let [[readedbytes readeddata] (read type buff index)]
+          (recur (+ index readedbytes)
+                 (conj result readeddata)
+                 (rest types)))
+        [(- index pos) result])))
+
+  (write [_ buff pos data']
+    (let [indexedtypes (map-indexed vector types)
+          written (reduce (fn [pos [index type]]
+                            (let [value (nth data' index nil)
+                                  written (write type buff pos value)]
+                              (+ pos written)))
+                          pos indexedtypes)]
+      (- written pos))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Spec Constructors
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

@@ -47,75 +106,24 @@
   (fn [& params]
     (let [numparams (count params)]
       (cond
+        (every? #(satisfies? ISpec %) params)
+        :indexed
+
         (and (even? numparams)
              (keyword? (first params))
              (satisfies? ISpec (second params)))
-        :associative
-
-        (every? #(satisfies? ISpec %) params)
-        :indexed))))
+        :associative))))

 (defmethod spec :associative
   [& params]
   (let [data (mapv vec (partition 2 params))
         dict (into {} data)
         types (map second data)]
-    (reify
-      clojure.lang.Counted
-      (count [_]
-        (count types))
-
-      IStaticSize
-      (size [_]
-        (reduce #(+ %1 (proto/size %2)) 0 types))
-
-      ISpec
-      (read [_ buff pos]
-        (loop [index pos result {} pairs data]
-          (if-let [[fieldname type] (first pairs)]
-            (let [[readedbytes readeddata] (read type buff index)]
-              (recur (+ index readedbytes)
-                     (assoc result fieldname readeddata)
-                     (rest pairs)))
-            [(- index pos) result])))
-
-      (write [_ buff pos data']
-        (let [written (reduce (fn [index [fieldname type]]
-                                (let [value (get data' fieldname nil)
-                                      written (write type buff index value)]
-                                  (+ index written)))
-                              pos data)]
-          (- written pos))))))
+    (AssociativeSpec. data dict types)))

 (defmethod spec :indexed
   [& types]
-  (reify
-    clojure.lang.Counted
-    (count [_]
-      (count types))
-
-    IStaticSize
-    (size [_]
-      (reduce #(+ %1 (proto/size %2)) 0 types))
-
-    ISpec
-    (read [_ buff pos]
-      (loop [index pos result [] types types]
-        (if-let [type (first types)]
-          (let [[readedbytes readeddata] (read type buff index)]
-            (recur (+ index readedbytes)
-                   (conj result readeddata)
-                   (rest types)))
-          [(- index pos) result])))
-
-    (write [_ buff pos data']
-      (let [indexedtypes (map-indexed vector types)
-            written (reduce (fn [pos [index type]]
-                              (let [value (nth data' index nil)
-                                    written (write type buff pos value)]
-                                (+ pos written)))
-                            pos indexedtypes)]
-        (- written pos)))))
+  (IndexedSpec. types))

 (def ^{:doc "A semantic alias for spec constructor."}
   compose-type spec)
@@ -183,7 +191,6 @@
        (let [value (or value default)]
          (buffer/write-short buff pos value)
          (Short/BYTES))))))
-

 (defn int32
   "Integer type spec constructor."


Fix incorrecty formed jarname in uberjar.

--- src/leiningen/uberjar.clj
+++ src/leiningen/uberjar.clj
@@ -45,24 +45,23 @@
 may wish to clean first."
   [project]
   (jar project)
-  (with-open [out (-> (file (:root project)
-                            (str (:name project) "-" (:version project)
-                                 "-standalone.jar"))
-                      (FileOutputStream.) (ZipOutputStream.))]
-    ;; TODO: any way to make sure we skip dev dependencies?
-    (let [deps (->> (file-seq (file (:library-path project)))
-                    (filter #(.endsWith (.getName %) ".jar"))
-                    (cons (file (:root project) (str (:name project) ".jar"))))
-          [_ components] (reduce (partial include-dep out)
-                                 [#{"META-INF/plexus/components.xml"} nil]
-                                 deps)]
-      (when-not (empty? components)
-        (.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml"))
-        (binding [*out* (PrintWriter. out)]
-          (xml/emit {:tag :component-set
-                     :content
-                     [{:tag :components
+  (let [jarname-root  (str (:name project) \- (:version project))]
+    (with-open [out (-> (file (:root project) (str jarname-root "-standalone.jar"))
+                          (FileOutputStream.) (ZipOutputStream.))]
+      ;; TODO: any way to make sure we skip dev dependencies?
+      (let [deps (->> (file-seq (file (:library-path project)))
+                      (filter #(.endsWith (.getName %) ".jar"))
+                      (cons (file (:root project) (str jarname-root ".jar"))))
+            [_ components] (reduce (partial include-dep out)
+                                   [#{"META-INF/plexus/components.xml"} nil]
+                                   deps)]
+        (when-not (empty? components)
+          (.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml"))
+          (binding [*out* (PrintWriter. out)]
+            (xml/emit {:tag :component-set
                        :content
-                       components}]})
-          (.flush *out*))
-        (.closeEntry out)))))
+                       [{:tag :components
+                         :content
+                         components}]})
+            (.flush *out*))
+          (.closeEntry out))))))


replace tabs with spaces

replace tabs with spaces

--- src/client/game.cljs
+++ src/client/game.cljs
@@ -1,7 +1,7 @@
 (ns client.game
-	(:require-macros [hiccups.core :as hiccups])
-	(:require
-		hiccups.runtime
+  (:require-macros [hiccups.core :as hiccups])
+  (:require
+    hiccups.runtime
     [client.socket :refer [socket]]
     client.game.core
     ))
@@ -13,42 +13,42 @@
 ;;------------------------------------------------------------

 (hiccups/defhtml game-html []
-	[:div.player-view
-		[:div#theme-options
-			"Press keys 0-9 to change your theme."]
-		[:div#canvas-wrap
-			[:canvas#game-canvas]]
-		[:div.right-side
-			[:div#scoreboard
-				[:div.next-area
-					[:span.next-header "Next: "]
-					[:canvas#next-canvas]]
-				[:div.game-stats
-					[:div#score]
-					[:div#level]
-					[:div#lines]]]
-			[:div#theme "1984"]
-			[:div#theme-details "Electronika 60"]]
-		[:section#arena]])
+  [:div.player-view
+    [:div#theme-options
+      "Press keys 0-9 to change your theme."]
+    [:div#canvas-wrap
+      [:canvas#game-canvas]]
+    [:div.right-side
+      [:div#scoreboard
+        [:div.next-area
+          [:span.next-header "Next: "]
+          [:canvas#next-canvas]]
+        [:div.game-stats
+          [:div#score]
+          [:div#level]
+          [:div#lines]]]
+      [:div#theme "1984"]
+      [:div#theme-details "Electronika 60"]]
+    [:section#arena]])

-(hiccups/defhtml game-html []
-	[:div.player-view
-		[:div#theme-options
-			"Press keys 0-9 to change your theme."]
-		[:div#canvas-wrap
-			[:canvas#game-canvas]]
-		[:div.right-side
-			[:div#scoreboard
-				[:div.next-area
-					[:span.next-header "Next: "]
-					[:canvas#next-canvas]]
-				[:div.game-stats
-					[:div#score]
-					[:div#level]
-					[:div#lines]]]
-			[:div#theme "1984"]
-			[:div#theme-details "Electronika 60"]]
-		[:section#arena]])
+(hiccups/defhtml game-html2 []
+  [:div.player-view
+    [:div#theme-options
+      "Press keys 0-9 to change your theme."]
+    [:div#canvas-wrap
+      [:canvas#game-canvas]]
+    [:div.right-side
+      [:div#scoreboard
+        [:div.next-area
+          [:span.next-header "Next: "]
+          [:canvas#next-canvas]]
+        [:div.game-stats
+          [:div#score]
+          [:div#level]
+          [:div#lines]]]
+      [:div#theme "1984"]
+      [:div#theme-details "Electronika 60"]]
+    [:section#arena]])

 (hiccups/defhtml countdown-html []
   [:h1#countdown "Connecting..."])


refactor core a bit

refactor core a bit

--- src/cu/core.clj
+++ src/cu/core.clj
@@ -16,8 +16,10 @@
 (defn- sqs-client [credentials] (apply sqs/create-client credentials))
 (defn- sqs-queue [client queue-name] (sqs/create-queue client queue-name))

+(defn- path [& parts] (join "/" parts))
+
 (defn- workspace-dir [basedir url]
-  (join "/" [basedir (last (split url #"/")) "workspace"]))
+  (path basedir (last (split url #"/")) "workspace"))

 (defn process-push-message [client workspaces-path build-queue-name {payload :body}]
   (when-let [url (payload/clone-target-url payload)]
@@ -40,56 +42,56 @@
 (defn- read-body [message]
   (read-string (message :body)))

-(defn run-job-from-message
-  "Process a queue item from the worker queue. Runs script, stores output.
+(defn- read-body-keys [message & ks]
+  (-> (message :body)
+      read-string
+      (select-keys ks)))
+
+(defn message-job-runner
+  "Returns a fn that processes a message from the worker queue.
+  Runs script, stores output.
   Currently outputs to both a big log and separate job logs.
   TODO: Remove big log."
-  [workspaces-path big-log-key
-   credentials bucket ; TODO: make all these args a map
-   message]
+  [{:keys [workspaces-path log-key
+           aws-credentials bucket]}]
   (println "--------------------------------------")
-  (println "run-job-from-message")
-  (let [{uuid     :uuid
-         job-name :name
-         git-url  :repo
-         git-ref  :ref
-         script   :script}  (read-body message)
+  (println "message-job-runner")
+  (fn [message]
+    (let [job                 (read-body-keys message :uuid :name :repo :ref :script)

-        workspace-path      (join "/" [workspaces-path job-name "workspace"])
+          workspace-path      (path workspaces-path (job :name) "workspace")

-        existing-big-log    (io/get-key credentials bucket big-log-key)
+          existing-big-log    (io/get-key aws-credentials bucket log-key)

-        repo                (git/fresh-clone git-url workspace-path git-ref)
-        build               (runner/run! workspace-path script)
-        ]
+          repo                (git/fresh-clone (job :repo) workspace-path (job :ref))
+          build               (runner/run! workspace-path (job :script))
+          ]

-    (println "for" job-name)
-    (io/put credentials bucket
-            (results/log-key uuid job-name (build :exit))
-            (build :out))
-    (io/put credentials bucket
-            big-log-key
-            (str existing-big-log (build :out)))
-    (build :out)))
+      (println "for" (job :name))
+      (io/put aws-credentials bucket
+              (results/log-key (job :uuid) (job :name) (build :exit))
+              (build :out))
+      (io/put aws-credentials bucket
+              log-key
+              (str existing-big-log (build :out)))
+      (build :out))))

 (defn- no-pending-upstream-jobs?
   "Predicate used to filter out messages to leave in queue
   i.e. don't process and don't delete."
   [credentials bucket
    message]
-  (let [ls (partial io/ls
-                    credentials
-                    bucket)
-        {job-name             :name
-         uuid                 :uuid
-         upstream-job-names   :upstream} (read-body message)
-        all-results           (ls uuid)
+  (let [ls                    (partial io/ls
+                                       credentials
+                                       bucket)
+        job                   (read-body-keys message :name :uuid :upstream)
+        all-results           (ls (job :uuid))
         completed-job-names   (results/job-names all-results)]
     (println "--------------------------------------")
-    (println "no-pending-upstream-jobs? for" job-name)
+    (println "no-pending-upstream-jobs? for" (job :name))
     (println "raw list:" all-results)
-    (println "superset?" completed-job-names upstream-job-names)
-    (doto (superset? completed-job-names upstream-job-names) println)))
+    (println "superset?" completed-job-names (job :upstream))
+    (doto (superset? completed-job-names (job :upstream)) println)))

 (defn parser [config]
   (let [client (sqs-client (vals (config :aws-credentials)))
@@ -107,28 +109,23 @@
                                 :limit 10)))))

 (defn worker [config]
-  (let [credentials (config :aws-credentials)
-        client (sqs-client (vals credentials))
-        q (sqs-queue client (config :build-queue))
-        ls (partial io/ls credentials (config :bucket))
-        upstream-all-passed? (fn [message]
-                               (let [{job-name             :name
-                                      uuid                 :uuid
-                                      upstream-job-names   :upstream} (read-body message)
-                                     passed-job-names      (results/passed-job-names (ls uuid))]
-                                 (println "--------------------------------------")
-                                 (println "upstream-all-passed? for" job-name)
-                                 (doto (or (empty? upstream-job-names)
-                                           (superset? passed-job-names upstream-job-names)) println)))]
+  (let [credentials           (config :aws-credentials)
+        client                (sqs-client (vals credentials))
+        q                     (sqs-queue client (config :build-queue))
+        ls                    (partial io/ls credentials (config :bucket))
+        run-job-from-message  (message-job-runner config)
+        upstream-all-passed?  (fn [message]
+                                (let [job                (read-body-keys message :name :uuid :upstream)
+                                      passed-job-names   (results/passed-job-names (ls (job :uuid)))]
+                                  (println "--------------------------------------")
+                                  (println "upstream-all-passed? for" (job :name))
+                                  (doto (or (empty? (job :upstream))
+                                            (superset? passed-job-names (job :upstream))) println)))]
     (println "Starting worker")
     (dorun
       (map (sqs/deleting-consumer client
                                   (runner/decide-whether-to
-                                    (partial run-job-from-message
-                                             (config :workspaces-path)
-                                             (config :log-key)
-                                             (config :aws-credentials)
-                                             (config :bucket))
+                                    run-job-from-message
                                     upstream-all-passed?))
            (filter (partial no-pending-upstream-jobs?
                             (config :aws-credentials)


Added :iso as alias to :iso-mends.

Added :iso as alias to :iso-mends.

--- src/cmr/umm/core.clj
+++ src/cmr/umm/core.clj
@@ -25,6 +25,10 @@
   [concept]
   (dif-c/parse-collection (:metadata concept)))

+(defmethod parse-concept [:collection "application/iso+xml"]
+  [concept]
+  (iso-mends-c/parse-collection (:metadata concept)))
+
 (defmethod parse-concept [:collection "application/iso-mends+xml"]
   [concept]
   (iso-mends-c/parse-collection (:metadata concept)))
@@ -42,6 +46,10 @@
   [umm format]
   (dif/umm->dif-xml umm))

+(defmethod umm->xml :iso
+  [umm format]
+  (iso-mends/umm->iso-mends-xml umm))
+
 (defmethod umm->xml :iso-mends
   [umm format]
   (iso-mends/umm->iso-mends-xml umm))


Don't require my spec in test code This ensures that the tests will fail if I forget to require the specs in my application code.

--- test/time_tracker/timers/pubsub_test.clj
+++ test/time_tracker/timers/pubsub_test.clj
@@ -9,8 +9,7 @@
             [time-tracker.util :as util]
             [gniazdo.core :as ws]
             [cheshire.core :as json]
-            [clojure.spec :as s]
-            [time-tracker.timers.spec]))
+            [clojure.spec :as s]))

 (use-fixtures :once fixtures/init! fixtures/migrate-test-db fixtures/serve-app)
 (use-fixtures :each fixtures/isolate-db)


Need to make sure we reference the cache before scheduling

Otherwise, the active singleton won't have a chance to share its state
with the idle one before it dies.

--- src/demo/caching.clj
+++ src/demo/caching.clj
@@ -164,7 +164,7 @@

 (defn -main [& args]
   "Schedule a counter"
-  (let [f #(prn (-> (c/cache "counter")
-                  (c/swap! :count (fnil inc 0))))]
+  (let [c (c/cache "counter")
+        f #(prn (c/swap! c :count (fnil inc 0)))]
     (schedule f :id "counter" :every [3 :seconds])))


Improve performance of notification a bit

--- src/derive/core.cljs
+++ src/derive/core.cljs
@@ -280,10 +280,9 @@
 (defn notify-listeners [store deps]
   (let [listeners (.-listeners store)]
     #_(.log js/console "Update listeners " (pr-str listeners) (pr-str deps))
-    (->> (keys listeners)
-         (filter #(or (nil? %) (match-deps % deps))) ;; cheap consolidation
-         (map (fn [k] (doseq [l (get listeners k)] (l store deps))))
-         doall)))
+    (doseq [ldeps (keys listeners) :when (or (nil? ldeps) (match-deps ldeps deps))]
+      (doseq [l (get listeners ldeps)]
+        (l store deps)))))

 (defn derive-listener
   "Helper. Handle source listener events"


remove dead code

remove dead code

--- src/fat_jar/core.clj
+++ src/fat_jar/core.clj
@@ -48,9 +48,6 @@
                      slurp
                      edn/read-string)

-              selections (->> mappings
-                      (map :map))
-
                user-data (->> (config :input.data)
                      slurp
                      StringReader.


fix reflection errors

fix reflection errors

--- src/fileape/core.clj
+++ src/fileape/core.clj
@@ -35,7 +35,8 @@

   (defn ^File create-file [base-dir codec file-key]
     "Create and return a File object with the name based on the file key codec and base dir"
-       (File. base-dir (str file-key
+       (File. (clojure.java.io/file base-dir)
+              (str file-key
                             (codec-extension codec)
                             "_" (System/nanoTime))))

@@ -73,7 +74,7 @@
        (catch Exception e (do
                             (error e e)
                             (>!! error-ch e))))
-     (.set (:updated file-data) (System/currentTimeMillis)))
+     (.set ^AtomicReference (:updated file-data) (System/currentTimeMillis)))

   (defn write [{:keys [star error-ch] :as conn} file-key writer-f]
     "Writes the data in a thread safe manner to the file output stream based on the file-key
@@ -99,15 +100,15 @@
 	                                      (last s1)]))))

-  (defn close-and-roll [{:keys [file ^OutputStream out] :as file-data} i]
+  (defn close-and-roll [{:keys [^File file ^OutputStream out] :as file-data} i]
     "Close the output stream and rename the file by removing the last _[number] suffix"
     (try
       (do
         (.flush out)
         (.close out))
       (catch Exception e (error e e)))
-    (let [file2 (File. (.getParent file)
-                       (add-file-name-index
+    (let [file2 (File. ^File (.getParent file)
+                       ^String (add-file-name-index
                          (clj-str/join "" (interpose "_" (-> (.getName file) (clj-str/split #"_") drop-last)))
                          i))]
       (if (.exists file2)
@@ -189,9 +190,9 @@
 	               (do
                    (try
 		                  (doseq [f roll-callbacks]
-		                    (info "before roll") (f v) (info "after roll"))
+		                    (f v))

-		                (catch Exception e (.printStackTrace e)))
+		                (catch Exception e (error e e)))
                   (recur))))))

 	       (assoc conn :fix-delay-ch (fixdelay (:check-freq conn)


add error handler

add error handler

--- src/fileape/core.clj
+++ src/fileape/core.clj
@@ -90,9 +90,9 @@
 (defn ape
   "Entrypoint to the api, creates the resources for writing
    roll-callbacks - on each file roll all functions in this list are called, they are called with a map of keys [file codec file-key future-file-name ^AtomicLong record-count ^AtomicReference(long) updated]
-
+   error-handler a function that is called if any errors happen in the writer agens as (error-handler error fn)
    Returns a map with a key :env that can be updated using update-env!, and is used depending on the storage plugins"
-  [{:keys [codec base-dir rollover-size rollover-timeout rollover-abs-timeout check-freq roll-callbacks
+  [{:keys [codec base-dir rollover-size rollover-timeout rollover-abs-timeout check-freq roll-callbacks error-handler
            out-buffer-size use-buffer
            parallel-files
            env] :or {codec :gzip check-freq 10000 rollover-size 134217728 rollover-timeout 60000 parallel-files 2 rollover-abs-timeout Long/MAX_VALUE
@@ -119,13 +119,22 @@
         ctx (io/create-ctx conf env-ref roll-ch)]

     (info "start file check " check-freq " rollover-sise " rollover-size " rollover-timeout " rollover-timeout)
+    ;;if any error handlers
+    (when error-handler
+      (fun-utils/go-seq
+        (fn [v]
+          (try
+            (apply error-handler v)
+            (catch Exception e (error e e))))
+        error-ch))
+
     ;if any rollbacks
     (when (not-empty roll-callbacks)
       (fun-utils/go-seq
         (fn [v]
           (try
             (->> roll-callbacks (map #(% v)) doall)
-            (catch Exception e (prn e e))))
+            (catch Exception e (error e e))))
         roll-ch))

     {:ctx ctx


Improve/fix handle-command function.

Improve/fix handle-command function.

--- src/mvxcvi/vault/tool.clj
+++ src/mvxcvi/vault/tool.clj
@@ -93,30 +93,58 @@

 (defn- handle-command
   "Handles a sequence of arguments following a command tree structure."
-  [command opts args]
-  (let [subcommand-names (into #{} (cons "help" (keys (:commands command))))
+  ([cmd args]
+   (handle-command cmd [] {} args))

-        [command-args [subcommand & subcommand-args]]
-        (split-with (complement subcommand-names) args)
+  ([cmd branch opts args]
+   (if (some #{"help"} args)
+     (recur cmd branch
+            (assoc opts :help true)
+            (filter #(not= "help" %) args))
+     (let [branch (conj branch (:name cmd))
+           subcmds (:commands cmd)
+           subcmd-names (apply hash-set (map :name subcmds))
+           usage (str "Usage: " (string/join " " branch) " " (:usage cmd)
+                      "\n\n" (:desc cmd)
+                      (when (seq subcmds)
+                        (str "\n\n Subcommand   Description\n"
+                                 " ----------   -----------\n"
+                             (->> subcmds
+                                  (map #(format " %10s   %s" (:name %) (:desc %)))
+                                  (string/join "\n")))))

-        [command-opts remaining-args banner]
-        (apply cli command-args
-               (str "Usage: " (:usage command) "\n\n" (:desc command))
-               (:specs command))
+           [cmd-args [subcmd & subcmd-args]]
+           (split-with (complement subcmd-names) args)

-        new-opts (merge opts command-opts)
-        new-opts (delay (if-let [init (:init command)] (init new-opts) new-opts))]
-    (if subcommand
-      (if (= "help" subcommand)
-        (recur command
-               (assoc opts :help true)
-               (concat command-args subcommand-args))
-        (recur (get-in command [:commands subcommand])
-               @new-opts
-               subcommand-args)) ; NOTE: ignores unknown args before the subcommand
-      (cond (:help opts) (do (println banner) (System/exit 0))
-            (:action command) ((:action command) @new-opts command-args)
-            :else (do (println banner) (System/exit 1))))))
+           [cmd-opts action-args banner]
+           (if-let [specs (:specs cmd)]
+             (apply cli cmd-args usage (:specs cmd))
+             [opts cmd-args usage])
+
+           opts (merge opts cmd-opts (when (:help opts) {:help true}))
+           opts ((or (:init cmd) identity) opts)]
+
+       ;(clojure.pprint/pprint {:branch branch, :opts opts, :action-args action-args, :subcmd subcmd, :subcmd-args subcmd-args})
+
+       (if-let [subcmd (some #(and (= (:name %) subcmd) %) subcmds)]
+         (if-not (empty? action-args)
+           (throw (IllegalArgumentException.
+                    (str "Unparsed arguments before command: " action-args)))
+           (recur subcmd branch opts subcmd-args))
+
+         (cond (:help opts)
+               (do (println banner)
+                   (System/exit 0))
+
+               (:action cmd)
+               ((:action cmd) opts action-args)
+
+               :else
+               (do (when-not (empty? action-args)
+                     (println "Unrecognized arguments:"
+                              (string/join " " action-args) "\n"))
+                   (println banner)
+                   (System/exit 1))))))))

@@ -159,4 +187,4 @@

 (defn -main [& args]
-  (handle-command command-tree {} args))
+  (handle-command command-tree args))


#'file-exists? now in overtone.helpers.file

--- src/overtone/util/lib.clj
+++ src/overtone/util/lib.clj
@@ -112,9 +112,6 @@
       (applyTo    ([args] (apply fun args)))
       (toString   [] "Callable Map")))

-(defn file-exists? [path]
-  (.exists (java.io.File. path)))
-
 (defn- syms-to-keywords [coll]
   (map #(if (symbol? %)
           (keyword %)


Whitespace

Whitespace

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -214,6 +214,7 @@
 (defn read-notes
   "Returns a sequence of pairs [version note-text] for all notes on
   prior or equal versions of the given thing."
+
   [config thing]
   (let [thing  (ensure-thing thing)]
     (for [thing (thing->prior-versions config thing)


GHC: Implement MOD->

GHC: Implement MOD->

--- src/icfp2014/ghc.clj
+++ src/icfp2014/ghc.clj
@@ -102,7 +102,8 @@
               "GHOST-POS"
               "SQUARE-AT"
               "GHOST-STAT"
-              "MY-STAT"})
+              "MY-STAT"
+              "MOD->"})

 (defn macrolize
   [line]
@@ -176,7 +177,17 @@
                         "INT 6"
                         (format "MOV %s,A" dest-vit)
                         (format "MOV %s,B" dest-dir)])
-
+
+                     "MOD->"
+                     (let [[dest x y] args]
+                       [(format "MOV $TMP,%s" x)
+                        (format "DIV $TMP,%s" y)
+                        (format "MOV %s,%s" dest y)
+                        (format "MUL %s,$TMP" dest)
+                        (format "MOV $TMP,%s" dest)
+                        (format "MOV %s,%s" dest x)
+                        (format "SUB %s,$TMP" dest)])
+
                      "JMP"
                      (let [[dest] args]
                        [(format "JEQ %s,0,0" dest)]))


lines

lines

--- src/leech/parse.cljs
+++ src/leech/parse.cljs
@@ -68,6 +68,7 @@
       (aset raw-obj "slot" (get m 8))
       (aset raw-obj "ion_id" (parse-long (get m 9)))
       (aset raw-obj "cloud" (get m 10))
+      (aset raw-obj "line" l)
       (ObjMap. nil (js-keys raw-obj) raw-obj))))

 (def raw-re
@@ -80,7 +81,8 @@
      "host" (get m 2)
      "facility" (get m 3)
      "level" (get m 4)
-     "message" (get m 5)}))
+     "message" (get m 5)
+     "line" l}))

 (def nginx-access-re
      ;timestamp_src                              ;host      ;facility    ;level           ;slot        ;ion_id ;cloud           ;http_host                                                              ;http_method,_url,_version      ;http_status,_bytes,_referrer,_user_agent,_domain
@@ -105,7 +107,8 @@
      "http_bytes" (parse-long (get m 13))
      "http_referrer" (get m 14)
      "http_user_agent" (get m 15)
-     "http_domain" (get m 16)}))
+     "http_domain" (get m 16)
+     "line" l}))

 (def nginx-error-re
   #"^(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d-\d\d:00) ([0-9\.]+) ([a-z0-7]+)\.([a-z]+) nginx - ([a-z4-6]+)?\.(\d+)@([a-z.]+\.com) - .* \[error\] (.*)$")
@@ -121,7 +124,8 @@
      "slot" (get m 5)
      "ion_id" (parse-long (get m 6))
      "cloud" (get m 7)
-     "message" (get m 8)}))
+     "message" (get m 8)
+     "line" l}))

 (def varnish-access-re
   #"^(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d[\-+]\d\d:00) ([0-9\.]+) ([a-z0-7]+)\.([a-z]+) varnish\[(\d+)\] - ([a-z4-6\-]+)?\.(\d+)@([a-z.]+\.com) - [0-9\.]+ - - .*\" (\d\d\d) .*$")
@@ -138,7 +142,8 @@
      "slot" (get m 6)
      "ion_id" (parse-long (get m 7))
      "cloud" (get m 8)
-     "http_status" (parse-long (get m 9))}))
+     "http_status" (parse-long (get m 9))
+     "line" l}))

 (defn log [data]
   (util/log (merge {:ns "parse"} data)))


Use `file` to construct paths

Use `file` to construct paths

--- src/mdr2/archive.clj
+++ src/mdr2/archive.clj
@@ -53,21 +53,23 @@
 (defn container-id [production]
   (str "dam" (:id production)))

-(defn container-path
-  "Return the name of a archive spool directory for a given production"
-  [production]
-  (str spool-dir "/" (container-id production)))
-
-(defn container-rdf-path
-  "Return the name of an rdf file in the archive spool for a given production"
+(defn container-path
+  "Return the archive spool directory for a given production"
   [production]
   (let [id (container-id production)]
-    (str spool-dir "/" id "/" id ".rdf")))
+    (file spool-dir id)))
+
+(defn container-rdf-path
+  "Return an rdf file in the archive spool for a given production"
+  [production]
+  (let [id (container-id production)
+        rdf-name (str id ".rdf")]
+    (file spool-dir id rdf-name)))

 (defn add-to-db [production]
   (let [new-job
         {:id (container-id production)
-         :verzeichnis (container-path production)
+         :verzeichnis (.getPath (container-path production))
          ;; if there is a cdimage attached to this production then we
          ;; need to add some magic incantations to get this properly
          ;; archived
@@ -104,7 +106,7 @@
   [production]
   (let [path (:path production)
         iso-path (:iso-path production)
-        archive-path (file (container-path production))]
+        archive-path (container-path production)]
     ;; if the production has an iso archive that, otherwise just
     ;; archive the raw unencoded files
     (if iso-path


only change url when on a doc url

only change url when on a doc url

--- src-cljs/frontend/controllers/navigation.cljs
+++ src-cljs/frontend/controllers/navigation.cljs
@@ -156,7 +156,9 @@
                        urls/urlify-doc-name)]
     (when (seq new-url-name)
       (utils/set-page-title! (:document/name doc)))
-    (when (and (seq new-url-name) (not= current-url-name new-url-name))
+    (when (and (seq new-url-name)
+               (not= current-url-name new-url-name)
+               (zero? (.indexOf path "/document")))
       (let [[_ before-name after-name] (re-find #"^(/document/)[A-Za-z0-9_-]*?-{0,1}(\d+(/.*$|$))" path)
             new-path (str before-name new-url-name "-" after-name)]
         (put! (get-in current-state [:comms :nav]) [:navigate! {:replace-token? true


server-upgrades: moving defaults to constructor

--- src/main/untangled/components/server/image_library.clj
+++ src/main/untangled/components/server/image_library.clj
@@ -62,13 +62,13 @@
 (defn build-components [{:as opts
                          :keys [meta-deps blob-deps meta-fn blob-fn
                                 middleware-key middleware-deps]}]
-  {::storage/meta (build-switcher (or meta-deps [])
+  {::storage/meta (build-switcher meta-deps
                     (some-fn meta-fn
                              (fn [_] ["in-memory meta store" storage/map->InMemMetaStore])))
-   ::storage/blob (build-switcher (or blob-deps [])
+   ::storage/blob (build-switcher blob-deps
                     (some-fn blob-fn
                              (fn [_] ["file-system blob store" storage/map->FileStore])))
-   (or middleware-key ::middleware)
+   middleware-key
    (component/using
      (map->ImageLibraryMiddleware opts)
      (vec (into #{::storage/blob ::storage/meta} middleware-deps)))})
@@ -101,6 +101,9 @@
         {:auth-fn (fn [this im loc] :ok)
          :assets-root "/assets/"
          :middleware-deps []
+         :middleware-key ::middleware
          :meta-fn (constantly nil)
-         :blob-fn (constantly nil)}))
+         :meta-deps []
+         :blob-fn (constantly nil)
+         :blob-deps []}))
     [::storage/blob ::storage/meta]))


Success in calling init without breaking one.

--- src/app/cljs/one/sample/view.cljs
+++ src/app/cljs/one/sample/view.cljs
@@ -131,6 +131,21 @@

 (dispatch/react-to #{:state-change} (fn [_ m] (render m)))

+;; ------------- fnx -------------
+
+(defmulti render-fnx
+  "Accepts a map which represents the current state of the application
+  and renders a view based on the value of the `:state` key."
+  :state)
+
+(defmethod render-fnx :init [_]
+  (js/alert "this is a fucking test!"))
+
+(dispatch/react-to #{:state-change} (fn [_ m] (render-fnx m)))
+
+;; ------------- fnx -------------
+
+
 (defn- form-fields-status
   "Given a map of old and new form states, generate a map with `:id`,
   `:transition` and `:error` keys which can be passed to


working on passé composé

working on passé composé

--- src/babel/francais/morphology.clj
+++ src/babel/francais/morphology.clj
@@ -522,6 +522,16 @@
    looks up the hypothesized lexeme using lookup-fn."
   (cond

+   (= surface-form "allées")
+   (concat
+    (map (fn [lexeme]
+           (unifyc
+            lexeme
+            {:synsem {:subcat {:1 {:agr {:number :plur
+                                         :gender :fem}}}}}))
+         (get lexicon "aller"))
+    (get lexicon surface-form))
+
    (re-find #"e$" surface-form)
    (concat


comments

comments

--- src/babel/italiano/benchmark.cljc
+++ src/babel/italiano/benchmark.cljc
@@ -43,8 +43,8 @@
   (run-benchmark times))

 ;; lein run -m babel.italiano.benchmark/parse-mark 20 "i gatti neri hanno bevuto il vino rosso"
-;; (parsemark 100 "gli uomini alti hanno bevuto il vino rosso alla casa rossa")
-(defn parsemark [times expr]
+;; lein run -m babel.italiano.benchmark/parse-mark 20 "gli uomini alti hanno bevuto il vino rosso alla casa rossa"
+(defn parse-mark [times expr]
   (count (take (Integer. times)
                (repeatedly
                 #(println (with-out-str


CMR-669: Added test for paging depth validation.

--- test/cmr/system_int_test/search/paging_search_test.clj
+++ test/cmr/system_int_test/search/paging_search_test.clj
@@ -5,7 +5,8 @@
             [cmr.system-int-test.utils.search-util :as search]
             [cmr.system-int-test.utils.index-util :as index]
             [cmr.system-int-test.data2.collection :as dc]
-            [cmr.system-int-test.data2.core :as d2c]))
+            [cmr.system-int-test.data2.core :as d2c]
+            [cmr.common.config :as cfg]))

 (def prov1-collection-count 10)
 (def prov2-collection-count 15)
@@ -22,6 +23,20 @@
   (index/refresh-elastic-index))

 (use-fixtures :each (ingest/reset-fixture {"provguid1" "PROV1" "provguid2" "PROV2"}))
+
+(deftest search-with-page-size-and-page-num
+  (create-collections)
+  (testing "Exceeded page depth (page-num * page-size)"
+    (let [limit (cfg/config-value :paging-depth-limit 1000000)
+          page-size 10
+          page-num (int (+ (/ limit page-size) 1))]
+      (let [res (search/find-refs :collection
+                                  {:page_size page-size
+                                   :page-num page-num})
+            status (:status res)
+            errors (:errors res)]
+        (is (= 400 status))
+        (is (re-matches #"The paging depth \(page_num \* page_size\) of \[\d*?\] exceeds the limit of \d*?.*?" (first errors)))))))

 (deftest search-with-page-size
   (create-collections)
@@ -43,6 +58,7 @@
     (try
       (search/find-refs :collection {:page_size -1})
       (catch clojure.lang.ExceptionInfo e
+        (println "OK>..........")
         (let [status (get-in (ex-data e) [:object :status])
               body (get-in (ex-data e) [:object :body])]
           (is (= 400 status))
@@ -81,8 +97,8 @@
     (index/refresh-elastic-index)
     (testing "Search with page_num."
       (let [{:keys [refs]} (search/find-refs :collection {:provider "PROV1"
-                                                      :page_size 5
-                                                      :page_num 2})]
+                                                          :page_size 5
+                                                          :page_num 2})]
         (is (= (map :short-name [col5 col4 col3 col2 col1])
                (map :short-name refs)))))
     (testing "page_num less than one."


Specify `lang` attribute for `html` element

English, do you speak it?

--- src/clj/chili_dog_night/views.clj
+++ src/clj/chili_dog_night/views.clj
@@ -21,7 +21,7 @@
    [:p "© 2016 Chili Dog Night Productions"]])

 (defn common [title head body]
-  (h/html5
+  (h/html5 {:lang "en"}
    [:head
     [:meta {:charset "utf-8"}]
     [:meta {:http-equiv "X-UA-Compatible" :content "IE=edge,chrome=1"}]


update ecs namespace

update ecs namespace

--- src/clj/resonate2015/day1/ecs.clj
+++ src/clj/resonate2015/day1/ecs.clj
@@ -21,6 +21,13 @@
          :entities     {}
          :systems      {}}))

+(defn new-entity!
+  "Defines a new entity ID"
+  [app-state]
+  (-> app-state
+      (swap! update-in [:uuid-counter] inc)
+      (:uuid-counter)))
+
 (defn component
   "Defines a new component"
   [app-state entity-id name state]
@@ -34,18 +41,15 @@

 (defn add-components-for-eid!
   "Swaps a app state atom with new entity states."
-  [app-state entity-id states]
-  (swap! app-state
-         update-in [:entities entity-id]
-         merge states))
-
-
-(defn new-entity!
-  "Defines a new entity ID"
-  [app-state]
-  (-> app-state
-      (swap! update-in [:uuid-counter] inc)
-      (:uuid-counter)))
+  ([app-state entity-id states]
+   (swap! app-state
+          update-in [:entities entity-id]
+          merge states))
+  ([app-state states]
+    (add-components-for-eid!
+      app-state
+      (new-entity! app-state)
+      states)))

 (defn system
   "Defines a new system"


Some handy dev functions

Some handy dev functions

--- src/cljs/gc_api_browser/core.cljs
+++ src/cljs/gc_api_browser/core.cljs
@@ -10,26 +10,36 @@
                       "Accept"             "application/json"
                       "Content-Type"       "application/json"})

+(def init-app-state
+  {:history []
+   :request {:text              "Select a JSON schema..."
+             :selected-resource nil
+             :selected-action   nil
+             :url               nil
+             :method            "GET"
+             :body              nil
+             :headers           {}}})
+
 (defonce app-state
-         (atom {:history []
-                :request {:text              "Select a JSON schema..."
-                          :selected-resource nil
-                          :selected-action   nil
-                          :url               nil
-                          :method            "GET"
-                          :body              nil
-                          :headers           {}}}))
+  (atom init-app-state))

 (enable-console-print!)
+
+;; handy repl functions
+(comment
+  (keys @app-state)
+  (swap! app-state (fn [] init-app-state))
+  (do
+    (.removeItem js/localStorage "schema")
+    (.removeItem js/localStorage "headers"))
+  (swap! app-state (fn [x] (update-in x [:request] (fn [y] (dissoc y :schema))))))

 (defn handle-new-response [app resp]
   (om/transact! app (fn [m]
                       (-> m
                           (assoc :response resp)
                           (update :history #(conj % (select-keys m [:request :response])))))))
-
-;; (swap! app-state (fn [x] (update-in x [:request] (fn [y] (dissoc y :schema)))))

 (defn main []
   (om/root
@@ -64,4 +74,4 @@
                                 (om/build response/component resp)))
                      (dom/h1 nil "Select a JSON Schema" (schema-select/schema-file (:request app))))))))
     app-state
-    {:target (.getElementById js/document "app")}))+    {:target (.getElementById js/document "app")}))


GAWB 3740 update call to /me orch endpoint to call less expensive alternative (#1390)

* change call to /me to include parameter to use less expensive endpoint

* first effort at changing /me endpoint, breaks everything

* fixed brokenness

* remove unnecessary options call

--- src/cljs/main/broadfcui/auth.cljs
+++ src/cljs/main/broadfcui/auth.cljs
@@ -207,39 +207,39 @@
                                                (on-change signed-in? true))))}))))))})

 (react/defc UserStatus
-  {:render
-   (fn [{:keys [state]}]
-     [:div {:style {:padding "40px 0"}}
-      (case (:error @state)
-        nil (spinner "Loading user information...")
-        :not-active [:div {:style {:color (:exception-reds style/colors)}}
-                     "Thank you for registering. Your account is currently inactive."
-                     " You will be contacted via email when your account is activated."]
-        [:div {}
-         [:div {:style {:color (:state-exception style/colors) :paddingBottom "1rem"}}
-          "Error loading user information. Please try again later."]
-         [:table {:style {:color (:text-lighter style/colors)}}
-          [:tbody {:style {}}
-           [:tr {} [:td {:style {:fontStyle "italic" :textAlign "right" :paddingRight "0.3rem"}} "What went wrong:"] [:td {} (:message (:error @state))]]
-           [:tr {} [:td {:style {:fontStyle "italic" :textAlign "right" :paddingRight "0.3rem"}} "Status code:"] [:td {} (:statusCode (:error @state))]]]]])])
-   :component-did-mount
-   (fn [{:keys [props state]}]
-     (ajax/call-orch "/me"
-                     {:on-done (fn [{:keys [success? status-code get-parsed-response]}]
-                                 (if success?
-                                   ((:on-success props))
-                                   (case status-code
-                                     403 (swap! state assoc :error :not-active)
-                                     ;; 404 means "not yet registered"
-                                     404 ((:on-success props))
-                                     ;; Borked servers often return HTML pages instead of JSON, so suppress JSON parsing
-                                     ;; exceptions because they are useless ("Unexpected token T in JSON...")
-                                     (let [[error-json parsing-error] (get-parsed-response true false)]
-                                       (swap! state assoc :error (if parsing-error
-                                                                   {:message (str "Cannot reach the API server. The API server or one of its subsystems may be down.")
-                                                                    :statusCode status-code}
-                                                                   error-json))))))}
-                     :service-prefix ""))})
+            {:render
+             (fn [{:keys [state]}]
+               [:div {:style {:padding "40px 0"}}
+                (case (:error @state)
+                  nil (spinner "Loading user information...")
+                  :not-active [:div {:style {:color (:exception-reds style/colors)}}
+                               "Thank you for registering. Your account is currently inactive."
+                               " You will be contacted via email when your account is activated."]
+                  [:div {}
+                   [:div {:style {:color (:state-exception style/colors) :paddingBottom "1rem"}}
+                    "Error loading user information. Please try again later."]
+                   [:table {:style {:color (:text-lighter style/colors)}}
+                    [:tbody {:style {}}
+                     [:tr {} [:td {:style {:fontStyle "italic" :textAlign "right" :paddingRight "0.3rem"}} "What went wrong:"] [:td {} (:message (:error @state))]]
+                     [:tr {} [:td {:style {:fontStyle "italic" :textAlign "right" :paddingRight "0.3rem"}} "Status code:"] [:td {} (:statusCode (:error @state))]]]]])])
+             :component-did-mount
+             (fn [{:keys [props state]}]
+               (ajax/call-orch "/me?userDetailsOnly=true"
+                 {:on-done (fn [{:keys [success? status-code get-parsed-response]}]
+                              (if success?
+                                ((:on-success props))
+                                (case status-code
+                                  403 (swap! state assoc :error :not-active)
+                                  ;; 404 means "not yet registered"
+                                  404 ((:on-success props))
+                                  ;; Borked servers often return HTML pages instead of JSON, so suppress JSON parsing
+                                  ;; exceptions because they are useless ("Unexpected token T in JSON...")
+                                  (let [[error-json parsing-error] (get-parsed-response true false)]
+                                    (swap! state assoc :error (if parsing-error
+                                                                {:message    (str "Cannot reach the API server. The API server or one of its subsystems may be down.")
+                                                                 :statusCode status-code}
+                                                                error-json))))))}
+             :service-prefix ""))})

 (react/defc RefreshCredentials
   {:get-initial-state


move blocks initial

move blocks initial

--- src/cljs/salava/page/ui/edit.cljs
+++ src/cljs/salava/page/ui/edit.cljs
@@ -88,7 +88,7 @@
         format (:format @block-atom)]
     [:div.form-group
      [:div.col-xs-8
-      #_[:div.badge-select
+      [:div.badge-select
        [:select {:class "form-control"
                  :aria-label "select badge group"
                  :value badge-id
@@ -108,6 +108,25 @@
      [:div {:class "col-xs-4 badge-image"}
       (if image
         [:img {:src (str "/" image)}])]]))
+
+(defn badge-block [block-atom]
+  (let [badge-id (get-in @block-atom [:badge :id] (session/get-in! [:badge-block :badge :id] 0))
+        image (get-in @block-atom [:badge :image_file])
+        name (get-in @block-atom [:badge :name] "")
+        format (:format @block-atom)
+        description (get-in @block-atom [:badge :description])]
+    [:div.badge-select
+     [:div.row.flip
+      [:div.col-md-3.badge-image
+       [:img.badge-image {:src (str "/" image)}]
+       ]
+      [:div.col-md-9
+       [:h4.media-heading name]
+
+       [:div description]]]]
+
+    )
+  )

 (defn edit-block-badge-groups [block-atom tags badges]
   (let [tag (get-in @block-atom [:tag] "")
@@ -333,11 +352,12 @@
          #_[block-type block-atom]]
         [:div {:class "col-xs-4 field-remove"
                :on-click #(f/remove-field blocks index)}
+         [:span.move-block  [:i.fa.fa-arrows]]
          [:span {:class "remove-button" :title (t :page/Delete)}
           [:i {:class "fa fa-trash"}]]]]
        (case type
          ("heading" "sub-heading") [edit-block-text block-atom]
-         ("badge") [edit-block-badges block-atom badges]
+         ("badge") [badge-block block-atom]#_[edit-block-badges block-atom badges]
          ("tag") [edit-block-badge-groups block-atom tags badges]
          ("file") [edit-block-files block-atom files]
          ("html") [edit-block-html block-atom]


Get rid of unused function

Get rid of unused function

--- src/clojure/nightcode/dialogs.clj
+++ src/clojure/nightcode/dialogs.clj
@@ -107,6 +107,3 @@
                                                   % (finish))])])
         s/pack!
         s/show!)))
-
-(defn show-sdk-dialog
-  [path])


Improve the behavior of the Find text box

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -167,15 +167,21 @@
 (defn find-text
   [e]
   (when-let [editor (get-selected-editor)]
-    (let [is-enter-key? (= (.getKeyCode e) 10)
+    (let [key-code (.getKeyCode e)
+          is-enter-key? (= key-code 10)
           find-text (s/text e)
+          is-printable-char? (-> editor .getFont (.canDisplay key-code))
+          is-valid-search? (and (> (count find-text) 0)
+                                is-printable-char?
+                                (not @shortcuts/is-down?))
           context (SearchContext. find-text)]
-      (.setRegularExpression context true)
-      (when (and (not is-enter-key?) (> (count find-text) 0))
-        (.setCaretPosition editor 0))
-      (when (and is-enter-key? (.isShiftDown e))
-        (.setSearchForward context false))
-      (if (and (> (count find-text) 0)
+      (when is-valid-search?
+        (.setRegularExpression context true)
+        (when-not is-enter-key?
+          (.setCaretPosition editor 0))
+        (when (.isShiftDown e)
+          (.setSearchForward context false)))
+      (if (and is-valid-search?
                (not (try (SearchEngine/find editor context)
                       (catch Exception e false))))
         (s/config! e :background (color/color :red))
@@ -184,7 +190,8 @@
 (defn replace-text
   [e]
   (when-let [editor (get-selected-editor)]
-    (let [is-enter-key? (= (.getKeyCode e) 10)
+    (let [key-code (.getKeyCode e)
+          is-enter-key? (= key-code 10)
           pane (get-selected-editor-pane)
           find-text (s/text (s/select pane [:#find-field]))
           replace-text (s/text e)


make sure all stages have stopped before we run autofocus

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@9336 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -588,6 +588,7 @@
           #(when-let [wait-time-ms (:wait-time-ms event)]
              (acq-sleep wait-time-ms))
           #(when (get event :autofocus)
+             (wait-for-pending-devices)
              (run-autofocus))
           #(when check-z-ref
              (store-z-reference current-position)


got rid of tree functions I never needed

--- src/duffel/tree/core.clj
+++ src/duffel/tree/core.clj
@@ -64,39 +64,6 @@
   [dir]
   (-> dir create-dir-tree explode-tree))

-(defn tree-dir-mapreduce
-  "Given a duffel tree, runs f on each dir map (the first item in each list).
-  The first argument to f is the dir map itself. The second is an accumulator.
-  The third is the list of file maps for that dir map. f returns a vector of the
-  new dir map and new accumulator which will be given to all child calls from
-  that dir. If the new dir map is nil then that dir is removed and its children
-  are not processed. The file map list is unaffected"
-  [f acc dtree]
-  (let [dir-map (first dtree)
-        file-maps (rest dtree)
-        [new-dir-map new-acc] (f dir-map acc file-maps)]
-    (when-not (nil? new-dir-map)
-      (cons new-dir-map
-        (remove nil?
-          (map
-            #(if (sequential? %) (tree-dir-mapreduce f new-acc %) %)
-            file-maps))))))
-
-(defn tree-file-map
-  "Given a duffel tree, runs f on each file map (any map that's not the first
-  item in a list). The first argument to f is the dir map for the file, the
-  second is the file map currently being looked at. f returns the new file map
-  to be put in place. If f returns nil then the file map will be ommitted from
-  the returned tree"
-  [f dtree]
-  (let [dir-map (first dtree)
-        file-maps (rest dtree)]
-    (cons dir-map
-      (remove nil?
-        (map
-          #(if (sequential? %) (tree-file-map f %) (f dir-map %))
-          file-maps)))))
-
 (defn tree-map
   "Given a duffel tree, run f on that duffel tree. Look through the returned
   duffel tree for more duffel trees, and call f on them. Recurse."
@@ -113,7 +80,6 @@
   (cons (first dtree)
     (map f (rest dtree))))

-
 (defn tree-get
   "Given some item from a duffel tree, either a file or another tree, returns
   the value of a key in it"
@@ -128,24 +94,3 @@
   (if (sequential? el)
     (cons (apply assoc (first el) kvs) (rest el))
     (apply assoc el kvs)))
-
-(comment
-  (require '[clojure.pprint :refer [pprint]])
-
-  (pprint
-    (tree-dir-mapreduce
-      (fn [dir acc files]
-        (if (= (dir :real-name) "wat1") [nil acc]
-          [(assoc dir :len-files (count files) :path acc)
-           (str acc "/" (dir :real-name))]))
-      ""
-      (dir->tree "my-duffel")))
-
-  (pprint
-    (tree-file-map
-      (fn [dir file]
-        (when-not (= (file :real-name) "b.txt")
-          (assoc file :dir-name (dir :real-name))))
-      (dir->tree "my-duffel")))
-
-)


Allow PATCH handler to have body

Allow PATCH handler to have body

Don't throw an error when compiling a handler for PATCH request that uses :body

--- src/fnhouse/handlers.clj
+++ src/fnhouse/handlers.clj
@@ -167,7 +167,7 @@
        (empty? undeclared-args)
        "Undeclared args %s in %s" (vec undeclared-args) (source-map->str source-map))
       (fnk-schema/assert-iae
-       (or (not (boolean body)) (boolean (#{:post :put} method)))
+       (or (not (boolean body)) (boolean (#{:post :put :patch} method)))
        "Body only allowed in post or put method in %s" (source-map->str source-map))
       (fnk-schema/assert-iae
        (every? #{:resources :request s/Keyword} (keys (pfnk/input-schema @var)))


Don't hardcode api-url request type

Don't hardcode api-url request type

--- src/grimoire/api/web.clj
+++ src/grimoire/api/web.clj
@@ -8,6 +8,17 @@
   [host])

 (def api-base-str "/api/v2/")
+
+(def normalize-type
+  {:json              "json"
+   "json"             "json"
+   :application/json  "json"
+   "application/json" "json"
+
+   :edn               "edn"
+   "edn"              "edn"
+   :application/edn   "edn"
+   "application/edn"  "edn"})

 (defn make-api-url
   "λ [Cfg, Thing, Op] → String
@@ -21,7 +32,10 @@
   (str (:host config)
        api-base-str
        (when thing (t/thing->url-path thing))
-       "?op=" op "&type=edn"))
+       "?op=" op
+       (when-let [type (:type config :edn)]
+         (when-let [t' (normalize-type type)]
+           (str "&type=" t')))))

 (def store-base-str "/store/v1/")


fix formatting issue

fix formatting issue

--- src/hatti/ona/forms.cljs
+++ src/hatti/ona/forms.cljs
@@ -203,10 +203,10 @@
       (label (-> label keys sort first)))))

 (defn uses-search-expression?
-    "Checks if the appearance-value has the search expression"
-    [appearance-value]
-    (and (string? appearance-value)
-         (re-matches #"^search\(.*\)$" appearance-value)))
+  "Checks if the appearance-value has the search expression"
+  [appearance-value]
+  (and (string? appearance-value)
+       (re-matches #"^search\(.*\)$" appearance-value)))

 (defn format-answer
   "String representation for a particular field datapoint (answer).
@@ -224,7 +224,7 @@
     (select-all? field) (let [names (set (string/split answer #" "))
                               appearance-value (-> field :control :appearance)
                               has-search-expression? (uses-search-expression?
-                                                       appearance-value)
+                                                      appearance-value)
                               multiple-select-values
                               (if has-search-expression?
                                 (map #(identity {:name %}) names)


add contact

add contact

--- src/om_tut/core.cljs
+++ src/om_tut/core.cljs
@@ -2,13 +2,10 @@
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
-            [cljs.core.async :refer [put! chan <!]]))
+            [cljs.core.async :refer [put! chan <!]]
+            [clojure.string :as string]))

 (enable-console-print!)
-
-(println "Edits to this text should show up in your developer console.")
-
-;; define your app data so that it doesn't get over-written on reload

 (defonce app-state (atom
     {:contacts
@@ -35,6 +32,25 @@
                     (dom/span nil (display-name contact))
                     (dom/button #js {:onClick (fn [e] (put! delete @contact))} "Delete")))))

+(defn parse-contact [contact-str]
+  (let [[first middle last :as parts] (string/split contact-str #"\s+")
+        [first last middle] (if (nil? last) [first middle] [first last middle])
+        middle (when middle (string/replace middle "." ""))
+        c (if middle (count middle) 0)]
+    (when (>= (count parts) 2)
+      (cond-> {:first first :last last}
+              (== c 1) (assoc :middle-initial middle)
+              (>= c 2) (assoc :middle middle)))))
+
+(defn add-contact [data owner]
+  (let [input-el (om/get-node owner "new-contact")
+        new-contact (-> input-el
+                        .-value
+                        parse-contact)]
+    (when new-contact
+      (om/transact! data :contacts #(conj % new-contact))
+      (set! (.-value input-el) ""))))
+
 (defn contacts-view [data owner]
   (reify
     om/IInitState
@@ -54,7 +70,10 @@
                      (dom/h2 nil "Contact List")
                      (apply dom/ul nil
                             (om/build-all contact-view (:contacts data)
-                                          {:init-state {:delete delete}}))))))
+                                          {:init-state {:delete delete}}))
+                     (dom/div nil
+                              (dom/input #js {:type "text" :ref "new-contact"})
+                              (dom/button #js {:onClick #(add-contact data owner)} "Add Contact"))))))

 (om/root contacts-view app-state
   {:target (. js/document (getElementById "contacts"))})


Added cljfmt to core project - all files already formatted.

--- evermind.core/project.clj
+++ evermind.core/project.clj
@@ -6,9 +6,10 @@

   :plugins [[lein-modules "0.3.11"]
             [lein-cljsbuild "1.1.6"]
-            [lein-doo "0.1.7" :exclusions [[org.clojure/clojurescript]]]]
+            [lein-doo "0.1.7" :exclusions [[org.clojure/clojurescript]]]
+            [lein-cljfmt "0.5.6"]]

   :dependencies [[org.clojure/clojure "_"]
                  [cljs-uuid "0.0.4"]]

-  :profiles {:dev {:dependencies [[evermind.test-util :version]]}})+  :profiles {:dev {:dependencies [[evermind.test-util :version]]}})


Move `:forward-events` to be its own library.

--- src/re_frame/fx.cljs
+++ src/re_frame/fx.cljs
@@ -38,9 +38,10 @@
 ;; -- Standard Builtin Effects Handlers  --------------------------------------

 (defn dispatch-helper
+  "There are cases where eitherone event is to be dipatch "
   [effect]
   (cond
-    (list? effect)   (map dispatch effect)
+    (list? effect)   (doall (map dispatch effect))
     (vector? effect) (dispatch effect)
     :else (console :error "re-frame: expected :dispatch effect to be a list or vector, but got: " effect)))

@@ -68,35 +69,6 @@
     (dispatch-helper val)))

-;; Provides a way to "forward" events. To put it another way, it provides
-;; a way to "sniff" events.
-;;
-;; Normally, when `(dispatch [:a 42])` happens the event will be routed to
-;; the registered handler for `:a`, and that is the end of the matter.
-;;
-;; BUT with this effect, you can ask that an event is ALSO
-;; forwarded to another handler for further processing. This allows this
-;; 2nd handler to further process events.
-;;
-;; You provide a set of events to which you'd like to subscribe.
-;; "listen" for a set of events and, when they occur,
-;; to "forward" the events to another handler.
-;;
-;; In effect, if you registered a "listener" for event `:a`  and asked for them
-;; to be forewared to `[:another "hello"]`, then:
-;;   - when some did (dispatch [:a 42])
-;;   - the event would be handler by the normal handler for event `:a`
-;;   - but then a further dispatch would be made (dispatch [:naother "hello"  [:a 42]])
-;;
-;; As you can see the enter event is "forwarded' to enother handler for further
-;; processing.
-;;
-;; {:forward-events  {:register    :an-id-for-this-listner
-;;                    :events      #{:event1  :event2}
-;;                    :dispatch-to [:eid "eg. param"]}     ;; the forwared event will be conj to the end of the dispatch.
-;;
-;; {:forward-events  {:unregister :the-id-supplied-when-registering}}
-;;
 #_(register
   :forward-events
   (let [id->listen-fn (atom {})