Change iterator to support new join algorithm (seek in both directions, seek to end instead of past end). Sketch out join.

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -365,8 +365,8 @@
 ;; ITERATORS
 ;; .key / .val return key and val currently pointed at. key may be aliased
 ;; On creation/reset, points to first key
-;; On next, either point to next key or set .-end? true. Return (not .-end?)
-;; On seek, point to first key greater than or equal to seek-key. Return (key= (.key this) seek-key)
+;; On next, either point to next key or set .-end? true.
+;; On seek, point to first key greater than or equal to seek-key, or otherwise the last key
 ;; NOTE iterators are not write-safe unless reset after writing

 ;; TODO think we might need to be able to get last key on end
@@ -379,16 +379,14 @@
            (set! node (aget (.-children node) 0)))
          (set! end? (<= (alength (.-keys node)) 0)))
   (key [this]
-       (when (false? end?)
-         (aget (.-keys node) ix)))
+       (aget (.-keys node) ix))
   (val [this]
-       (when (false? end?)
-         (aget (.-vals node) ix)))
+       (aget (.-vals node) ix))
   (next [this]
-        (if (true? end?)
-          false
+        (when (false? end?)
           (if (nil? (.-children node))
-            (do
+            (let [old-node node
+                  old-ix ix]
               (set! ix (+ ix 1))
               (loop []
                 (if (>= ix (alength (.-keys node)))
@@ -398,63 +396,59 @@
                       (set! node (.-parent node))
                       (recur))
                     (do
-                      (set! end? true)
-                      false))
-                  true)))
+                      (set! node old-node)
+                      (set! ix old-ix)
+                      (set! end? true)))
+                  nil)))
             (do
               (set! node (aget (.-children node) (+ ix 1)))
               (set! ix 0)
               (loop []
                 (if (nil? (.-children node))
-                  true
+                  nil
                   (do
                     (set! node (aget (.-children node) 0))
                     (recur))))))))
   (seek [this key]
         (let [start-node node
               start-ix ix]
-          ;; TODO seek backwards instead of resetting and seeking forwards
-          (when (key-lt key (.key this))
-            (set! node (.-root tree))
-            (set! ix 0)
-            (set! end? false))
-          (if (true? end?)
-            false
-            (loop []
-              (if (key-lt (.-upper node) key)
-                (if (instance? Node (.-parent node))
-                  (do
-                    (set! ix (.-parent-ix node))
-                    (set! node (.-parent node))
-                    (recur))
-                  (do
-                    (set! end? true)
-                    false))
-                (loop []
-                  (set! ix (.seek node key ix))
-                  (if (>= ix (alength (.-keys node)))
+          (loop []
+            (if (and (instance? Node (.-parent node))
+                     (or (key-lt (.-upper node) key)
+                         (key-lt key (.-lower node))))
+              (do
+                (set! ix 0)
+                (set! node (.-parent node))
+                (recur))
+              (loop []
+                (.-keys node)
+                key
+                (set! ix (.seek node key 0))
+                (if (>= ix (alength (.-keys node)))
+                  (if (nil? (.-children node))
+                    (do
+                      (set! ix (- ix 1)) ;; point to last key
+                      (set! end? true))
                     (do
                       (set! node (aget (.-children node) ix))
                       (set! ix 0)
-                      (recur))
-                    (if (key= key (aget (.-keys node) ix))
-                      true
-                      (if (or (and (identical? node start-node) (== ix start-ix))
-                              (nil? (.-children node))
-                              (key-lt (.-upper (aget (.-children node) ix)) key))
-                        false
-                        (do
-                          (set! node (aget (.-children node) ix))
-                          (set! ix 0)
-                          (recur))))))))))))
+                      (recur)))
+                  (if (or (nil? (.-children node))
+                          (key= key (aget (.-keys node) ix))
+                          (key-lt (.-upper (aget (.-children node) ix)) key))
+                    (set! end? false)
+                    (do
+                      (set! node (aget (.-children node) ix))
+                      (set! ix 0)
+                      (recur))))))))))

 (defn iterator [tree]
-  (let [iterator (Iterator. tree (.-root tree) 0 false nil nil nil #js [] #js [] #js [] (.-key-len tree))]
+  (let [iterator (Iterator. tree (.-root tree) 0 false (.-key-len tree))]
     (.reset iterator)
     iterator))

 ;; used only inside Join
-(deftype JoinIterator [iterator inner->outer inner-key outer-key key-len blocked?]
+(deftype JoinIterator [iterator inner->outer inner-key outer-key key-len ^:mutable blocked?]
   Object
   (maintain [this]
             (if (.-end? iterator)
@@ -479,34 +473,66 @@
           (aset outer-key outer-ix (aget key outer-ix)))
         (.maintain this)))

-(deftype Join [current-key iterators ^:mutable end?]
+(deftype Join [iterators ^:mutable end?]
   Object
   (maintain [this]
-            ;; if all equal, done
-            ;; if all blocked but max, .next on max
-            ;; if all blocked, set end? true
-            ;; otherwise seek smallest non-blocked to max, recur
-            )
+            (loop [i -1]
+              (cond
+
+               ;; see if we need to do anything
+               (== i -1)
+               (let [min-key (.key (aget iterators 0))
+                     max-key (.key (aget iterators (- (alength iterators) 1)))]
+                 (if (key= min-key max-key)
+                   (debug :found min-key)
+                   (recur 0)))
+
+               ;; find the minimum non-blocked iter and seek it
+               (< i (- (alength iterators) 1))
+               (let [iterator (aget iterators i)]
+                 (if (false? (.-blocked? iterator))
+                   (do
+                     (.splice iterators i 1)
+                     (.seek iterator (.key (aget iterators (- (alength iterators) 1))))
+                     (js/goog.array.binaryInsert iterators iterator (fn [i0 i1] (key-compare (.key i0) (.key i1))))
+                     (recur -1))
+                   (recur (+ i 1))))
+
+               ;; otherwise see if we can bump the max iterator along
+               (== i (- (alength iterators) 1))
+               (let [max-iterator (aget iterators (- (alength iterators) 1))]
+                 (if (false? (.-blocked? max))
+                   (do
+                     (.next max-iterator)
+                     (debug :bump-max max-key)
+                     (recur 0))
+                   (do
+                     (set! end? true)
+                     (debug :end))))
+
+               )))
   (reset [this]
          (debug)
          (debug :reset)
-         (dotimes [i (alength current-key)]
-           (aset current-key i least))
          (dotimes [i (alength iterators)]
            (.reset (aget iterators i)))
+         (js/goog.array.sort iterators (fn [i0 i1] (key-compare (.key i0) (.key i1))))
          (set! end? false)
          (.maintain this))
   (key [this]
-       (when (false? end?)
-         current-key))
+       (.key (aget iterators 0)))
   (next [this]
-        ;; .next on smallest non-blocked iter
-        ;; maintain
-        )
+        (when (false? end?)
+          (let [max-iterator (aget iterators (- (alength iterators) 1))]
+            (assert (false? (.-blocked? max-iterator)))
+            (.next max-iterator)
+            (.maintain this))))
   (seek [this key]
-        ;; .seek on all iters
-        ;; maintain
-        ))
+        (when (false? end?)
+          (let [max-iterator (aget iterators (- (alength iterators) 1))]
+            (assert (false? (.-blocked? max-iterator)))
+            (.seek max-iterator key)
+            (.maintain this)))))

 (defn join [iterators num-vars iterator->var->nextable? iterator->var->present?]
   (let [seek-key (least-key num-vars)
@@ -762,19 +788,23 @@
 (defn apply-to-iterator [iterator movements]
   (for [movement movements]
     (case (nth movement 0)
-      :next [(.next iterator) (.key iterator)]
-      :seek [(.seek iterator (nth movement 1)) (.key iterator)])))
+      :next (do
+              (.next iterator)
+              (.key iterator))
+      :seek (do
+              (.seek iterator (nth movement 1))
+              (.key iterator)))))

 (defn apply-to-elems [elems movements]
-  (let [elems (atom elems)]
+  (let [cur-elems (atom elems)]
     (for [movement movements]
       (case (nth movement 0)
         :next (do
-                (swap! elems rest)
-                [(not (empty? @elems)) (first (first @elems))])
+                (swap! cur-elems rest)
+                (or (first (first @cur-elems)) (first (last elems))))
         :seek (do
-                (swap! elems (fn [elems] (drop-while #(key-lt (nth % 0) (nth movement 1)) elems)))
-                [(and (not (nil? (first @elems))) (key= (nth movement 1) (first (first @elems)))) (first (first @elems))])))))
+                (reset! cur-elems (drop-while #(key-lt (nth % 0) (nth movement 1)) elems))
+                (or (first (first @cur-elems)) (first (last elems))))))))

 (defn run-iterator-prop [min-keys key-len actions movements]
   (let [tree (apply-to-tree (tree min-keys key-len) actions)
@@ -805,7 +835,7 @@
 (defn self-join-prop [key-len]
   (prop/for-all [min-keys gen/s-pos-int
                  actions (gen/vector (gen-action key-len))
-                 movements (gen/vector (gen-next key-len))] ;; TODO implement Join.seek
+                 movements (gen/vector (gen-movement key-len))]
                 (run-self-join-prop min-keys key-len actions movements)))

 (defn run-product-join-prop [min-keys key-len actions movements]
@@ -830,32 +860,8 @@
 (defn product-join-prop [key-len]
   (prop/for-all [min-keys gen/s-pos-int
                  actions (gen/vector (gen-action key-len))
-                 movements (gen/vector (gen-next key-len))] ;; TODO implement Join.seek
+                 movements (gen/vector (gen-movement key-len))]
                 (run-product-join-prop min-keys key-len actions movements)))
-
-(defn magic-run-product-join-prop [min-keys key-len actions]
-  (let [tree (apply-to-tree (tree min-keys key-len) actions)
-        itr1 (iterator->keys (iterator tree))
-        iterator-results (for [i1 itr1
-                               i2 itr1]
-                           (vec (concat i1 i2)))
-        iterator-a (js/aurora.join.magic-iterator tree (let [arr (array)]
-                                                         (dotimes [x key-len]
-                                                           (.push arr x))
-                                                         (dotimes [x key-len]
-                                                           (.push arr nil))
-                                                         arr
-                                                         ))
-        iterator-b (js/aurora.join.magic-iterator tree (let [arr (array)]
-                                                         (dotimes [x key-len]
-                                                           (.push arr nil))
-                                                         (dotimes [x key-len]
-                                                           (.push arr x))
-                                                         arr
-                                                         ))
-        join-itr (js/aurora.join.join-iterator #js [iterator-a iterator-b])
-        join-results (js/aurora.join.all-join-results join-itr)]
-    (= iterator-results (map vec join-results))))

 (comment
   (dc/quick-check 1000 (least-prop 1))
@@ -1001,28 +1007,4 @@
      (map vec (iterator->keys join-itr))
     )

-
-
  )
-
-(let [tree1 (tree 10)
-        _ (.assoc! tree1 #js ["a" "b"] 0)
-        _ (.assoc! tree1 #js ["b" "c"] 0)
-        _ (.assoc! tree1 #js ["c" "d"] 0)
-        _ (.assoc! tree1 #js ["d" "b"] 0)
-        tree2 (tree 10)
-        _ (.assoc! tree2 #js ["b" "a"] 0)
-        _ (.assoc! tree2 #js ["c" "b"] 0)
-        _ (.assoc! tree2 #js ["d" "c"] 0)
-        _ (.assoc! tree2 #js ["b" "d"] 0)
-        join-itr (join #js [(iterator tree1) (iterator tree2) (function-iterator identity 1)]
-                       4
-                       #js [#js [true true false false]
-                            #js [false false true true]
-                            #js [false false false true]]
-                       #js [#js [true true false false]
-                            #js [false false true true]
-                            #js [false true false true]])]
-  (js/console.log join-itr)
-  (iterator->keys join-itr)
-  )


Update btree benchmarks

Update btree benchmarks

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -894,7 +894,7 @@
     (time
      (let [tree (tree 100)]
        (dotimes [i 500000]
-         (.assoc! tree i (* 2 i))))))
+         (.assoc! tree #js [i i i] (* 2 i))))))

   (f)

@@ -902,7 +902,7 @@
     (time
      (let [tree (tree 100)]
        (dotimes [i 500000]
-         (.assoc! tree (if (even? i) i (str i)) (* 2 i))))))
+         (.assoc! tree (if (even? i) #js [i i i] #js [(str i) (str i) (str i)]) (* 2 i))))))

   (g)

@@ -910,9 +910,9 @@
     (time
      (let [tree (tree 100)]
        (dotimes [i 500000]
-         (.assoc! tree (js/Math.sin i) (* 2 i))))))
-
-  (h)
+         (.assoc! tree #js [(js/Math.sin i) (js/Math.cos i) (js/Math.tan i)] (* 2 i))))))
+
+  (time (dotimes [_ 10] (h)))

   (do
     (def samples (gen/sample (gen/tuple gen/s-pos-int (gen/vector gen-action) (gen/vector gen-movement)) 100))


Remove dead code

Remove dead code

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -587,9 +587,7 @@
         (debug)
         (debug :next seek-key)
         (when (false? end?)
-          (let [iterators (aget var->iterators (- (alength var->iterators) 1))
-                iterator (aget iterators (- (alength var->iterators) 1))]
-            (.search this (alength var->iterators) (- (alength var->iterators) 1) 0)))
+          (.search this (alength var->iterators) (- (alength var->iterators) 1) 0))
         (false? end?)))

 (defn join [iterators num-vars iterator->var->present?]


Debugging statement => assertion

Debugging statement => assertion

--- test/desdemona/cli_test.clj
+++ test/desdemona/cli_test.clj
@@ -143,7 +143,7 @@
           redefs (into {} redef-pairs)]
       (with-redefs-fn redefs
         (fn []
-          (info "BEFORE" @events)
+          (is (= [] @events))
           (let [[result stdout] (with-fake-launcher-side-effects
                                   (peers/-main (str n-peers)))]
             (info "AFTER" @events)


Kill bogus-scheme test

Kill bogus-scheme test

--- test/icecap/crypto_test.clj
+++ test/icecap/crypto_test.clj
@@ -19,5 +19,3 @@

 (defspec secretbox-scheme-roundtrip
   (scheme-roundtrip-prop (secretbox-scheme) 32))
-(defspec bogus-scheme-roundtrip
-  (scheme-roundtrip-prop (bogus-scheme) 16))


add tests for adjoining protobuf extensions

--- test/protobuf/core_test.clj
+++ test/protobuf/core_test.clj
@@ -42,7 +42,24 @@
       (is (= "very" (:label p))))
     (let [p (adjoin p {:doubles [3.4] :floats [0.02]})]
       (is (= [1.2 3.4] (:doubles p)))
-      (is (= [(float 0.01) (float 0.02)] (:floats  p))))))
+      (is (= [(float 0.01) (float 0.02)] (:floats  p)))))
+  (testing "adjoining works with set extension"
+    (let [p (protobuf Foo :tag-set #{"foo" "bar" "baz"})
+          q (protobuf Foo :tag-set {"bar" false "foo" false "bap" true})
+          r (adjoin p q)]
+      (is (= #{"foo" "bar" "baz"} (p :tag-set)))
+      (is (= #{"bap"}             (q :tag-set)))
+      (is (= #{"bap" "baz"}       (r :tag-set)))))
+  (testing "adjoining works with counters"
+    (let [p (protobuf Foo :counts {"foo" {:i 5 :d  5.0}})
+          q (protobuf Foo :counts {"foo" {:i 8 :d -3.0}})
+          r (adjoin p q)]
+      (is (=  5   (get-in p [:counts "foo" :i])))
+      (is (=  5.0 (get-in p [:counts "foo" :d])))
+      (is (=  8   (get-in q [:counts "foo" :i])))
+      (is (= -3.0 (get-in q [:counts "foo" :d])))
+      (is (=  13  (get-in r [:counts "foo" :i])))
+      (is (=  2.0 (get-in r [:counts "foo" :d]))))))

 (deftest test-ordered-adjoin
   (let [inputs (apply ordered-map (for [x (range 26)


Don't need to encapsulate .solve in an anon func

--- test/schedule/core_test.clj
+++ test/schedule/core_test.clj
@@ -9,4 +9,4 @@

 (fact "Can make solver" (-> (makeSolverConfig) (makeSolver)) => anything) ; doesn't throw exception

-(fact "Can solve" (-> (makeSolverConfig) (makeSolver) (#(.solve % (ScheduleSolution.)))) => nil)+(fact "Can solve" (-> (makeSolverConfig) (makeSolver) (.solve (ScheduleSolution.))) => nil)


Log HTTP method with error

Log HTTP method with error

--- src/buildviz/http.clj
+++ src/buildviz/http.clj
@@ -28,7 +28,8 @@
     (let [resp (handler req)
           status (:status resp)
           body (:body resp)
+          method (.toUpperCase (name (:request-method req)))
           uri (:uri req)]
       (when (and (some? status) (>= status 400))
-        (log/warn (format "Returned %s for %s: \"%s\"" status uri body)))
+        (log/warn (format "Returned %s for %s %s: \"%s\"" status method uri body)))
       resp)))


Refactored code to be a little neater

Refactored code to be a little neater

--- src/hiccup.clj
+++ src/hiccup.clj
@@ -7,7 +7,7 @@
 ;; this software.

 (ns hiccup
-  "Efficiently generate HTML from a Clojure data structure."
+  "Dynamically generates HTML from a Clojure data structure."
   (:use clojure.contrib.def)
   (:use clojure.contrib.java-utils))

@@ -49,30 +49,35 @@
     "strong" "style" "textarea" "ul"}
   "A list of tags that need an explicit ending tag when rendered.")

-(defn parse-tag-name
+(defn- parse-tag-name
   "Parse the id and classes from a tag name."
   [tag]
   (rest (re-matches re-tag (as-str tag))))

+(defn- parse-element
+  "Ensure a tag vector is of the form [tag-name attrs content]."
+  [[tag & content]]
+  (let [[tag id class] (parse-tag-name tag)
+        tag-attrs      {:id id
+                        :class (if class (.replace class "." " "))}
+        map-attrs      (first content)]
+    (if (map? map-attrs)
+      [tag (merge tag-attrs map-attrs) (next content)]
+      [tag tag-attrs content])))
+
 (declare render-html)

-(defn render-tag
+(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
-                         :class (if class (.replace class "." " "))}
-        map-attrs       (first content)
-        [attrs content] (if (map? map-attrs)
-                          [(merge tag-attrs map-attrs) (next content)]
-                          [tag-attrs content])]
+  [element]
+  (let [[tag attrs content] (parse-element element)]
     (if (or content (container-tags tag))
       (str "<" tag (make-attrs attrs) ">"
            (render-html content)
            "</" tag ">")
       (str "<" tag (make-attrs attrs) " />"))))

-(defn render-html
+(defn- render-html
   "Render a Clojure data structure to a string of HTML."
   [data]
   (cond
@@ -81,6 +86,6 @@
     :otherwise     (as-str data)))

 (defn html
-  "Render Clojure data structures to HTML."
+  "Render Clojure data structures to a string of HTML."
   [& content]
   (render-html content))


Minor comments change.

Minor comments change.

--- src/uxbox/shapes.cljs
+++ src/uxbox/shapes.cljs
@@ -211,7 +211,7 @@
   [shape _]
   (throw (ex-info "Not implemented (size)" (select-keys shape [:type]))))

-;; Move
+;; Move (with deltas)

 (defmethod move ::rect
   [shape {dx :x dy :y}]


remove Cyber-Cypher overlay when trashed

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -138,9 +138,9 @@
 (defn desactivate
   ([state side card] (desactivate state side card nil))
   ([state side card keep-counter]
-   (let [c (dissoc card :current-strength :abilities :rezzed :special :named-target)
+   (let [c (dissoc card :current-strength :abilities :rezzed :special)
          c (if (and (= (:side c) "Runner") (not= (last (:zone c)) :facedown))
-             (dissoc c :installed :facedown :counter :rec-counter :pump) c)
+             (dissoc c :installed :facedown :counter :rec-counter :pump :named-target) c)
          c (if keep-counter c (dissoc c :counter :rec-counter :advance-counter))]
      (when-let [leave-effect (:leave-play (card-def card))]
        (when (or (and (= (:side card) "Runner") (:installed card) (not (:facedown card)))


:bug: Removed all but one set of reflection warnings from clj-http.core

--- src/clj_http/core.clj
+++ src/clj_http/core.clj
@@ -13,7 +13,7 @@
                             HttpRequestInterceptor HttpResponseInterceptor)
            (org.apache.http.auth UsernamePasswordCredentials AuthScope
                                  NTCredentials)
-           (org.apache.http.client HttpRequestRetryHandler RedirectStrategy)
+           (org.apache.http.client HttpRequestRetryHandler RedirectStrategy CredentialsProvider)
            (org.apache.http.client.config RequestConfig CookieSpecs)
            (org.apache.http.client.methods HttpDelete HttpGet HttpPost HttpPut
                                            HttpOptions HttpPatch
@@ -24,7 +24,7 @@
            (org.apache.http.client.protocol HttpClientContext)
            (org.apache.http.config RegistryBuilder)
            (org.apache.http.conn HttpClientConnectionManager)
-           (org.apache.http.conn.routing HttpRoute)
+           (org.apache.http.conn.routing HttpRoute HttpRoutePlanner)
            (org.apache.http.conn.ssl BrowserCompatHostnameVerifier
                                      SSLConnectionSocketFactory SSLContexts)
            (org.apache.http.conn.socket PlainConnectionSocketFactory)
@@ -72,7 +72,7 @@
     nil (DefaultRedirectStrategy/INSTANCE)
     (DefaultRedirectStrategy/INSTANCE)))

-(defn add-retry-handler [^HttpClientBuilder builder handler]
+(defn ^HttpClientBuilder add-retry-handler [^HttpClientBuilder builder handler]
   (when handler
     (.setRetryHandler
      builder
@@ -113,10 +113,10 @@
     (when max-redirects (.setMaxRedirects config max-redirects))
     (.build config)))

-(defn get-route-planner
+(defn ^HttpRoutePlanner get-route-planner
   "Return an HttpRoutePlanner that either use the supplied proxy settings
   if any, or the JVM/system proxy settings otherwise"
-  [proxy-host proxy-port proxy-ignore-hosts http-url]
+  [^String proxy-host ^Long proxy-port proxy-ignore-hosts http-url]
   (let [url (URL. http-url)]
     (if (and (not (contains? (set proxy-ignore-hosts) (.getHost url)))
              proxy-host)
@@ -239,17 +239,17 @@
       ((make-proxy-method-with-body request-method) http-url)
       (make-proxy-method request-method http-url))))

-(defn http-context [request-config]
+(defn ^HttpClientContext http-context [request-config]
   (doto (HttpClientContext/create)
     (.setRequestConfig request-config)))

-(defn credentials-provider []
+(defn ^CredentialsProvider credentials-provider []
   (BasicCredentialsProvider.))

 (defn- coerce-body-entity
   "Coerce the http-entity from an HttpResponse to a stream that closes itself
   and the connection manager when closed."
-  [^HttpEntity http-entity conn-mgr ^CloseableHttpResponse response]
+  [^HttpEntity http-entity ^HttpClientConnectionManager conn-mgr ^CloseableHttpResponse response]
   (if http-entity
     (proxy [FilterInputStream]
         [^InputStream (.getContent http-entity)]
@@ -292,7 +292,7 @@
   (clojure.pprint/pprint (bean http-req)))

 (defn- build-response-map
-  [^HttpResponse response req conn-mgr context]
+  [^HttpResponse response req conn-mgr ^HttpClientContext context]
   (let [^HttpEntity entity (.getEntity response)
         status (.getStatusLine response)
         protocol-version (.getProtocolVersion status)]
@@ -334,6 +334,8 @@
                        (when server-port (str ":" server-port))
                        uri
                        (when query-string (str "?" query-string)))
+; #### THIS DEADLOCKS THE TESTS FOR SOME REASON!!!!
+;         ^HttpClientConnectionManager conn-mgr (or connection-manager
          conn-mgr (or connection-manager
                       (get-conn-mgr async? req))
          proxy-ignore-hosts (or proxy-ignore-hosts


Remove unused import that causes compilation failures

Fixes #338

--- src/clj_http/core.clj
+++ src/clj_http/core.clj
@@ -40,7 +40,6 @@
            (org.apache.http.impl.nio.client HttpAsyncClientBuilder
                                             HttpAsyncClients
                                             CloseableHttpAsyncClient)
-           (org.eclipse.jetty.util FutureCallback)
            (org.apache.http.message BasicHttpResponse)
            (java.util.concurrent ExecutionException)))


Add resources

Add resources

--- build.boot
+++ build.boot
@@ -1,64 +1,64 @@
 (set-env!
-  :dependencies '[;; Core
+  :source-paths #{"src/"}
+  :resource-paths #{"resources/"}
+  :dependencies '[
+                 ;; Core
                  [org.clojure/clojure "1.8.0"]
                  [org.clojure/core.async "0.2.385"]
                  [org.clojure/tools.namespace "0.2.10"]
-                 ;[org.clojure/clojurescript "1.8.51"]
                  [org.clojure/clojurescript "1.9.93"]
                  [org.clojure/core.match "0.3.0-alpha4"]
-
                  [com.datomic/datomic-free "0.9.5385"]
                  [datascript "0.15.1"]
-
                  [com.cognitect/transit-clj "0.8.285"]
-
+
                  ;; Utils
                  [com.stuartsierra/component "0.3.1"]
                  [org.clojure/data.xml "0.0.8"]
                  [org.clojure/data.zip "0.1.2"]
                  [clj-time "0.12.0"]
                  [prismatic/schema "1.1.2"]
-
+
                  ;; Logging
                  [com.taoensso/timbre "4.6.0"]
-
+
                  ;; Web UI
                  [org.omcljs/om "1.0.0-alpha40"]
                  [com.taoensso/sente "1.9.0"]
-
                  [http-kit "2.2.0"]
-
-                 [ring                      "1.5.0"]
-                 [ring/ring-defaults        "0.2.1"]
+                 [ring "1.5.0"]
+                 [ring/ring-defaults "0.2.1"]
                  [ring-transit "0.1.6"]
-
                  [hiccup "1.0.5"]
-
                  [compojure "1.5.1"]
-
+
                  ; Code cleaness tools
                  [repetition-hunter "1.0.0"]
-
+
                  ;; Cljs
+                 [adzerk/boot-cljs "1.7.228-1"]
                  [com.andrewmcveigh/cljs-time "0.4.0"]
                  [cljs-http "0.1.41"]
                  [com.cognitect/transit-cljs "0.8.239"]
                  [alandipert/storage-atom "2.0.1"]]
+  )

-  :source-paths #{"src/"})
+(require '[adzerk.boot-cljs :refer [cljs]])

 (task-options!
  pom {:project 'tango
       :version "1.0.0"}
- jar {:main 'tango.core}
+ jar {:main 'tango.core
+      }
  aot {:all true}
  target {:dir #{"target"}}
  )

 (deftask build "Create a standalone tango server jar." []
-  (comp (aot)
+  (comp (cljs)
+        (aot)
         (pom)
         (uber)
         (jar)
-	(target)
+        (target)
         ))


Revert "Update bootutils dependency."

Revert "Update bootutils dependency."

This reverts commit 7ba779ff260735ba5a38ad6831126b76cd41dd15.

--- build.boot
+++ build.boot
@@ -2,7 +2,7 @@
  :source-paths #{"src"}
  :resource-paths #{"assets"}
  :dependencies '[[cats "0.4.0"]
-                 [funcool/bootutils "0.1.0" :scope "test"]
+                 [funcool/bootutils "0.1.0-SNAPSHOT" :scope "test"]
                  [adzerk/boot-cljs "0.0-2814-3" :scope "test"]
                  [boot-cljs-test/node-runner "0.1.0" :scope "test"]
                  [org.clojure/clojurescript "0.0-3123"  :scope "test"]
@@ -11,7 +11,7 @@

 (require
  '[adzerk.boot-cljs :refer [cljs]]
- '[funcool.bootutils :refer :all]
+ '[bootutils.core :refer :all]
  '[boot-cljs-test.node-runner :refer :all])

 (def +version+ "0.1.2")


0.0-2629-1 -- fix issue with shim when loaded from page in subdirs

--- build.boot
+++ build.boot
@@ -6,7 +6,7 @@

 (require '[adzerk.bootlaces :refer :all])

-(def +version+ "0.0-2629-0")
+(def +version+ "0.0-2629-1")

 (bootlaces! +version+)


fixed source paths

fixed source paths

--- build.boot
+++ build.boot
@@ -59,13 +59,13 @@
    :source-map-timestamp true})

 (deftask build []
-  (set-env! :source-paths #{"src/clj" "src/cljs" "env/prod"})
+  (set-env! :source-paths #{"src/clj" "src/cljs" "env/prod/cljs"})
   (comp (cljs :compiler-options compiler-options)))

 (deftask dev
   "Start the dev env..."
   []
-  (set-env! :source-paths #{"src/clj" "src/cljs" "env/dev"})
+  (set-env! :source-paths #{"src/clj" "src/cljs" "env/dev/cljs"})
   (comp (serve :dir "resources/public")
         (watch)
         (cljs-repl)


Bump all dependencies to the latest versions available

--- build.boot
+++ build.boot
@@ -3,20 +3,20 @@
 (set-env!
  :resource-paths #{"resources" "src/main" "src/docs"}
  :dependencies '[;; Boot setup
-                 [adzerk/boot-cljs "1.7.228-1" :scope "test"]
-                 [adzerk/boot-reload "0.4.5" :scope "test"]
-                 [adzerk/boot-test "1.1.0" :scope "test"]
-                 [adzerk/bootlaces "0.1.13" :scope "test"]
-                 [pandeiro/boot-http "0.7.2" :scope "test"]
-                 [crisptrutski/boot-cljs-test "0.2.2-SNAPSHOT" :scope "test"]
+                 [adzerk/boot-cljs "1.7.228-1"]
+                 [adzerk/boot-reload "0.4.8"]
+                 [adzerk/boot-test "1.1.1"]
+                 [adzerk/bootlaces "0.1.13"]
+                 [pandeiro/boot-http "0.7.3"]
+                 [crisptrutski/boot-cljs-test "0.2.1"]

                  ;; Library dependencies
-                 [org.clojure/clojurescript "1.7.228"]
-                 [org.omcljs/om "1.0.0-alpha30"]
+                 [org.clojure/clojurescript "1.9.14"]
+                 [org.omcljs/om "1.0.0-alpha36"]
                  [org.clojure/data.json "0.2.6"]

                  ;; Development dependencies
-                 [devcards "0.2.1-6"]])
+                 [devcards "0.2.1-7"]])

 (require '[adzerk.boot-cljs :refer [cljs]]
          '[adzerk.boot-reload :refer [reload]]


Only require ring-core instead of all of ring

--- build.boot
+++ build.boot
@@ -1,7 +1,7 @@
 (set-env!
  :source-paths #{"src"}
  :dependencies '[[org.clojure/clojure "1.7.0"]
-                 [ring/ring "1.4.0"]
+                 [ring/ring-core "1.4.0"]
                  [adzerk/bootlaces "0.1.12" :scope "test"]])

 (require


Added support for a PagerDuty formatter for events

--- src/riemann/pagerduty.clj
+++ src/riemann/pagerduty.clj
@@ -17,30 +17,44 @@
                 :accept :json
                 :throw-entire-message? true}))

-(defn- format-event
-  "Formats an event for PD. event-type is one of :trigger, :acknowledge,
-  :resolve"
-  [service-key event-type event]
-  {:service_key service-key
-   :event_type event-type
-   :incident_key (str (:host event) " " (:service event))
+(defn format-event
+  "Formats an event for PagerDuty"
+  [event]
+  {:incident_key (str (:host event) " " (:service event))
    :description (str (:host event) " "
                      (:service event) " is "
                      (:state event) " ("
                      (:metric event) ")")
    :details event})

+(defn send-event
+  "Sends an event to PD. event-type is one of :trigger, :acknowledge,
+  :resolve"
+  [service-key event-type formatter event]
+  (merge
+    {:service_key service-key, :event_type event-type} (formatter event)))
+
 (defn pagerduty
-  "Creates a pagerduty adapter. Takes your PD service key, and returns a map of
-  functions which trigger, acknowledge, and resolve events. Event service will
-  be used as the incident key. The PD description will be the service, state,
-  and metric. The full event will be attached as the details.
+  "Creates a PagerDuty adapter. Takes your PD service key, and returns a map of
+  functions which trigger, acknowledge, and resolve events. By default, event
+  service will be used as the incident key. The PD description will be the service,
+  state, and metric. The full event will be attached as the details.

-  (let [pd (pagerduty \"my-service-key\")]
+  You can override this by specifying a formatter. The formatter must be a function that
+  accepts an event and emits a hash.
+
+  (defn pd-format-event
+    [event]
+    {:incident_key 'Incident key', :description 'Incident Description',
+     :details 'Incident details'})
+
+  The :formatter is an optional argument.
+
+  (let [pd (pagerduty :service-key \"my-service-key\" :formatter pd-format-event )]
     (changed-state
       (where (state \"ok\") (:resolve pd))
       (where (state \"critical\") (:trigger pd))))"
-  [service-key]
-  {:trigger     (fn [e] (post (format-event service-key :trigger e)))
-   :acknowledge (fn [e] (post (format-event service-key :acknowledge e)))
-   :resolve     (fn [e] (post (format-event service-key :resolve e)))})
+  [{:keys [service-key formatter] :or {formatter format-event}}]
+  {:trigger     (fn [e] (post (send-event service-key :trigger formatter e)))
+   :acknowledge (fn [e] (post (send-event service-key :acknowledge formatter e)))
+   :resolve     (fn [e] (post (send-event service-key :resolve formatter e)))})


tag version number as dynamic

tag version number as dynamic

--- src/rosado/processing.clj
+++ src/rosado/processing.clj
@@ -907,10 +907,11 @@
                           :minor       (Integer/valueOf ^String (prop "minor"))
                           :incremental (Integer/valueOf ^String (prop "incremental"))
                           :qualifier   (prop "qualifier")}]
-  (def *processing-version*
-       (if (not (= (prop "interim") "false"))
-         (clojure.lang.RT/assoc processing-version :interim true)
-         processing-version)))
+  (def ^{:dynamic true}
+    *processing-version*
+    (if (not (= (prop "interim") "false"))
+      (clojure.lang.RT/assoc processing-version :interim true)
+      processing-version)))

 (alter-meta! (var *processing-version*) assoc :doc
   "The version info for clj-processing, as a map containing :major :minor


simplify noun-phrase3

simplify noun-phrase3

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -395,37 +395,31 @@
    ;;      noun-phrase3      ->  noun-phrase[1,2] slash-obj
    ;; e.g. "the man you saw" ->  "the man"        "you saw"
    (unify-check
-    {:rule "noun-phrase3"
-     :synsem {:cat :noun
-              :subcat '()}}
+    {:rule "noun-phrase3"}
     head-principle
     head-first
     (let [head-sem (atom :top)
-          agr (atom :top)
           cat (atom :noun)
-          comp-sem (atom {:obj head-sem})
-          head-mod (atom :top)]
+          comp-sem (atom :top)
+          head-mod (atom :top)
+          head-synsem (atom {:cat cat
+                             :subcat '()
+                             :mod head-mod
+                             :sem head-sem})]
       {:phrasal true
        :synsem {:cat cat
-                :agr agr
                 :sem head-sem
                 :mod {:first comp-sem
-                      :rest head-mod}}
+                      :rest head-mod}
+                :subcat '()}
        :head {:rule "noun-phrase2"
               :phrasal true
-              :synsem {:agr agr
-                       :cat cat
-                       :subcat '()
-                       :mod head-mod
-                       :sem head-sem}}
+              :synsem head-synsem}
        :comp {:phrasal true
               :slash true
-              :synsem {:sem comp-sem}}})
-
-    (let [head-modified-by-comp (atom :top)]
-      {:comp {:synsem {:subcat {:1 head-modified-by-comp}}}
-       :head {:synsem head-modified-by-comp}}))
-
+              :synsem {:subcat {:1 head-synsem
+                                :2 '()}
+                       :sem comp-sem}}}))
    (unify-check
     {:rule "slash-obj"}
     head-last head-semantics


add require

add require

--- src/sicp/chapter2/2_2.clj
+++ src/sicp/chapter2/2_2.clj
@@ -1,4 +1,5 @@
-(ns sicp.chapter2.2-2)
+(ns sicp.chapter2.2-2
+  (:require [sicp.chapter2.2-1 :refer [reverse']]))

 ;;;; 2.2  Hierarchical Data and the Closure Property


uploads are sorted newest-first

uploads are sorted newest-first

--- src/braid/server/db/upload.clj
+++ src/braid/server/db/upload.clj
@@ -22,4 +22,4 @@
               [?u :upload/thread ?t]]
             (d/db conn) group-id upload-pull-pattern)
        (map (comp db->upload first))
-       (sort-by :uploaded-at)))
+       (sort-by :uploaded-at #(compare %2 %1))))


RS & ML | 121 | Add delete-account link to email confirmation email

--- src/stonecutter/email.clj
+++ src/stonecutter/email.clj
@@ -39,7 +39,9 @@
     "Click this link to confirm your email address:\n"
     base-url (r/path :confirm-email-with-id :confirmation-id confirmation-id)
     "\nCheers,"
-    "\nAdmin"))
+    "\nAdmin\n\n\n\n"
+    "This was not me (delete account):\n"
+    base-url (r/path :show-confirmation-delete :confirmation-id confirmation-id)))

 (defn confirmation-renderer [email-data]
   {:subject (format "Confirm your email for %s" (:app-name email-data))


Defer trial creation until job and tasks have been commited

--- src/cider_ci/builder/tasks.clj
+++ src/cider_ci/builder/tasks.clj
@@ -132,8 +132,7 @@
         rows (map task/build-task-row raw-tasks)
         _ (logging/debug 'rows rows)
         tasks (jdbc/insert-multi! tx :tasks rows)]
-    (doseq [task tasks]
-      (trials/create-trials (:id task) {:tx tx :task task :job job}))))
+    tasks))

 ;### create tasks for job ###############################################


De-duplicate deep-merge

De-duplicate deep-merge

--- src/cider_ci/builder/tasks.clj
+++ src/cider_ci/builder/tasks.clj
@@ -2,11 +2,15 @@
 ; Licensed under the terms of the GNU Affero General Public License v3.
 ; See the "LICENSE.txt" file provided with this software.

+
+; TODO key of attachment as name if possible
+
 (ns cider-ci.builder.tasks
   (:require
+    [cider-ci.builder.expansion :as expansion]
+    [cider-ci.builder.spec :as spec]
     [cider-ci.builder.task :as task]
-    [cider-ci.builder.spec :as spec]
-    [cider-ci.builder.expansion :as expansion]
+    [cider-ci.builder.util :as util]
     [cider-ci.utils.config-loader :as config-loader]
     [cider-ci.utils.debug :as debug]
     [cider-ci.utils.exception :as exception]
@@ -42,18 +46,13 @@

 ;### build tasks ##############################################################
-(defn deep-merge [& vals]
-  (if (every? map? vals)
-    (apply merge-with deep-merge vals)
-    (last vals)))
-
 (defn build-scripts [task script-defaults]
   (into {} (for [[name-key script] (or (:scripts task) {})]
-             (let [final-script  (deep-merge script-defaults script)]
+             (let [final-script  (util/deep-merge script-defaults script)]
                [name-key final-script]))))

 (defn build-task [task-spec task-defaults script-defaults name-prefix]
-  (let [merged-task (deep-merge task-defaults task-spec)]
+  (let [merged-task (util/deep-merge task-defaults task-spec)]
     ;(logging/debug {:merged-task merged-task})
     (conj merged-task
           {:scripts (build-scripts merged-task script-defaults)
@@ -99,10 +98,10 @@
          (map
            (fn [context]
              (logging/debug {:context context})
-             (let [task-defaults (deep-merge inherited-task-defaults
+             (let [task-defaults (util/deep-merge inherited-task-defaults
                                              (or (:task_defaults context)
                                                  {}))
-                   script-defaults (deep-merge inherited-script-defaults
+                   script-defaults (util/deep-merge inherited-script-defaults
                                                (or (:script_defaults context)
                                                    {}))]
                (build-tasks-for-single-context context


specs for defn, defn-, fn

specs for defn, defn-, fn

Signed-off-by: Rich Hickey <2f3b32171da334ad5d7d0db393d0928eef4308ab@gmail.com>

--- src/clj/clojure/core/specs.clj
+++ src/clj/clojure/core/specs.clj
@@ -61,3 +61,38 @@
 (s/fdef clojure.core/when-let
   :args (s/cat :bindings (s/and vector? ::binding)
                :body (s/* any?)))
+
+;; defn, defn-, fn
+
+(s/def ::arg-list
+  (s/and
+    vector?
+    (s/cat :args (s/* ::binding-form)
+           :varargs (s/? (s/cat :amp #{'&} :form ::binding-form)))))
+
+(s/def ::args+body
+  (s/cat :args ::arg-list
+         :prepost (s/? map?)
+         :body (s/* any?)))
+
+(def defn-args
+  (s/cat :name simple-symbol?
+         :docstring (s/? string?)
+         :meta (s/? map?)
+         :bs (s/alt :arity-1 ::args+body
+                    :arity-n (s/cat :bodies (s/+ (s/spec ::args+body))
+                                    :attr (s/? map?)))))
+
+(s/fdef clojure.core/defn
+  :args defn-args
+  :ret any?)
+
+(s/fdef clojure.core/defn-
+  :args defn-args
+  :ret any?)
+
+(s/fdef clojure.core/fn
+  :args (s/cat :name (s/? simple-symbol?)
+               :bs (s/alt :arity-1 ::args+body
+                          :arity-n (s/+ (s/spec ::args+body))))
+  :ret any?)


close handler after finished with it in tests

--- src/clj/elephantdb/testing.clj
+++ src/clj/elephantdb/testing.clj
@@ -167,7 +167,9 @@
   (let [global-conf {:replication 1 :hosts hosts :domains domains-conf}]
     `(with-local-tmp [lfs# localtmp#]
        (let [~handler-sym (mk-service-handler ~global-conf localtmp# (System/currentTimeMillis) ~domain-to-host-to-shards)]
-         ~@body
+         (try
+           ~@body
+           (finally (.shutdown ~handler-sym)))
          ))))

 (defmacro with-single-service-handler


fix params into filter form

fix params into filter form

--- src/clj_money/web/accounts.clj
+++ src/clj_money/web/accounts.clj
@@ -193,7 +193,7 @@

 (defn- filter-form
   [params]
-  [:form {:action (format "/accounts/%s" (:id params))
+  [:form {:action (format "/accounts/%s" (:account-id params))
           :method :get}
    [:div.input-group
     [:select.form-control {:name "transaction-date"
@@ -223,7 +223,8 @@
                              (:year-month formatters)
                              (t/today)))]
     (html
-      (filter-form {:transaction-date transaction-date})
+      (filter-form {:transaction-date transaction-date
+                    :account-id (:id account)})
       [:table.table.table-striped.table-hover
        [:tr
         [:th.text-right "Date"]


Small bugfix

Small bugfix

--- src/clj_simple_chart/ticks.clj
+++ src/clj_simple_chart/ticks.clj
@@ -31,9 +31,9 @@
             (let [sstart (Math/ceil (/ start step))
                   sstop (Math/floor (/ stop step))
                   n (Math/ceil (inc (- sstop sstart)))]
-              (mapv #(* (+ start %) step) (range 0 n)))
+              (mapv #(* (+ sstart %) step) (range 0 n)))
             :else
             (let [sstart (Math/floor (* start step))
                   sstop (Math/ceil (* stop step))
                   n (Math/ceil (inc (- sstart sstop)))]
-              (mapv #(/ (- start %) step) (range 0 n)))))))
+              (mapv #(/ (- sstart %) step) (range 0 n)))))))


Use threading-api for config.parser/fqp

Use threading-api for config.parser/fqp

Signed-off-by: Gregory Haskins <640d9fe47775e6723f0355b7315e38f7d98d3539@gmail.com>

--- src/cljparse/config/parser.clj
+++ src/cljparse/config/parser.clj
@@ -22,7 +22,7 @@
          (into [] path)

          :else
-         (recur (zip/up loc) (conj path (nodename (zip/node loc)))))))
+         (recur (zip/up loc) (->> loc zip/node nodename (conj path))))))

 (defn find [path tree]
   (loop [loc tree]


Fixed websocket url

Fixed websocket url

--- src/cljs/asols/client/app.cljs
+++ src/cljs/asols/client/app.cljs
@@ -157,7 +157,8 @@

 (go
   (when (nil? (:connection @app-state))
-    (let [ws-chan (ws-ch "ws://localhost:8000/ws" {:format :edn})
+    (let [ws-url (str "ws://" (.. js/window -location -host) "/ws")
+          ws-chan (ws-ch ws-url {:format :edn})
           {connection :ws-channel error :error} (<! ws-chan)]
       (if error
         (do


Saving works now

Saving works now

Also, fixed a problem where fewer than PAGESIZE
items would throw an error.

--- src/cljs/modern_cljs/core.cljs
+++ src/cljs/modern_cljs/core.cljs
@@ -12,7 +12,7 @@
 ;

 (def ^:const PAGESIZE 10)
-
+(def ^:const DB "/data2.json")
 ;
 ; Mithril helpers
 ;
@@ -58,7 +58,6 @@
   "Data request error handler"
   (.log js/console (str "something went wrong: " status " " status-text)))

-
 (defn fetch [url]
   "Get data from URL"
   (GET url {:handler handler
@@ -72,6 +71,10 @@
            (println "Fetched data from DB")
            (let [data (.parse js/JSON resp)]
            (updatedb [:data] (js->clj data))))))
+
+(defn data_to_db [url]
+  "Send data to db"
+  (.write js/crud url (.stringify js/JSON (clj->js (:data db)))))

 (defn setpage [next]
   (updatedb [:start] next))
@@ -140,7 +143,9 @@
             pos (+ start i)]
           (m "li" nil [(m "button" {:onclick #(edit item pos)} "Edit")
                        title])))
-    (subvec data start (+ start PAGESIZE))))
+    (if (< PAGESIZE (count data))
+      (subvec data start (+ start PAGESIZE))
+      data)))

 (defn page [start direction count]
   (let [next (direction start PAGESIZE)
@@ -168,11 +173,12 @@
       (println "initial param was:" par)))
   (if (not (:data db nil))
     (do (println "Calling major Tom")
-        (data_from_db "/data.json"))))
+        (data_from_db DB))))

 (defn viewer [c]
   (m "div" nil
      [(m "h1" {:style {:color "green"}} (:var db))
+      (m "div" nil [(m "button" {:onclick #(data_to_db DB)} "Send!")])
       (editor (:editing db))
       (m "div" {} [(m "ol" nil (notes (:data db) (:start db)))])
       (pages)]))


CMR-512: Added check for component existence when starting up.

--- src/cmr/metadata_db/system.clj
+++ src/cmr/metadata_db/system.clj
@@ -36,7 +36,7 @@
   (info "System starting")
   (let [started-system (reduce (fn [system component-name]
                                  (update-in system [component-name]
-                                            #(lifecycle/start % system)))
+                                            #(when % (lifecycle/start % system))))
                                this
                                component-order)
         db (:db started-system)]
@@ -57,7 +57,7 @@
   (info "System shutting down")
   (let [stopped-system (reduce (fn [system component-name]
                                  (update-in system [component-name]
-                                            #(lifecycle/stop % system)))
+                                            #(when % (lifecycle/stop % system))))
                                this
                                (reverse component-order))]
     (info "Metadata DB stopped")


remove cruft

remove cruft

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -159,27 +159,6 @@
                                       (update-in [:vpc_security_group_ids] concat default-vpc-sgs)))))

-(defn logstash-user-data []
-  (cloud-config {:package_update true
-                 :packages ["oracle-java8-installer" "oracle-java8-set-default" "logstash" "dnsmasq"]
-                 :apt_sources
-                 [{:source "ppa:webupd8team/java"}
-                  {:source "deb http://packages.elastic.co/logstash/2.2/debian stable main"
-                   :key (snippet "system-files/elasticsearch-apt.pem")} ]
-                 :write_files
-                 [{:path "/etc/logstash/conf.d/in-gelf.conf"
-                   :content (snippet "vpc-logstash/in-gelf.conf")}
-                  {:path "/etc/logstash/conf.d/out-logstash.conf"
-                   :content (snippet "vpc-logstash/out-logstas.conf")}
-                  {:path "/etc/ssl/ca.cert"
-                   :content (snippet "vpn-keys/ca.crt")}
-                  {:path "/etc/dnsmasq.conf"
-                   :content (snippet "system-files/dnsmasq.conf")}]
-                 :bootcmd
-                 ["cloud-init-per once accepted-oracle-license-v1-1 echo \"oracle-java8-installer shared/accepted-oracle-license-v1-1 select true\" | debconf-set-selections"]
-                 :runcmd
-                 ["update-rc.d logstash defaults"]}))
-
 (defn open-elb-ports
   [listeners]
   (mapv #(assoc {} :port (or (:port %) (:lb_port %)) :cidr_blocks [all-external]) listeners))


simpler name of parameter

simpler name of parameter

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -211,7 +211,7 @@
            public-slave-alb-listeners
            public-slave-alb-sg
            application-policies
-           slave-internal-alb-listeners
+           slave-alb-listeners
            slave-alb-sg
            slave-sg
            account-number]}]
@@ -488,7 +488,7 @@
                    :elb []
                    :alb [{:name "internal-tasks"
                           :internal true
-                          :listeners (map #(assoc % :account-number account-number) slave-internal-alb-listeners)
+                          :listeners (map #(assoc % :account-number account-number) slave-alb-listeners)
                           :subnets elb-private-subnets
                           :security-groups (concat [(cluster-id-of "aws_security_group" "slave-alb-sg")]
                                                    remote-default-sgs)}] })


Refactor render calls

Refactor render calls

--- src/utf8ify/web/core.cljs
+++ src/utf8ify/web/core.cljs
@@ -11,19 +11,18 @@
                  {:cells (take grid-size (map (fn [n] {:id n :on false}) (iterate inc 0)))}))

 (defn grid [data owner]
-  (defn create-cell [cell]
+  (def render-grid
+    (let [push-event (partial xy-message app/mouse-events)]
+      (partial dom/div #js {:className "grid"
+                            :onMouseDown #(push-event :start %)
+                            :onMouseMove #(push-event :move %)
+                            :onMouseUp #(push-event :stop %)})))
+  (defn render-cell [cell]
     (dom/div #js {:data-id (:id cell)
                   :data-on (:on cell)
                   :className "cell"}))
-  (om/component
-    (let [cells (:cells data) mouse-events app/mouse-events
-          post-event (partial xy-message mouse-events)]
-      (apply dom/div
-             #js {:className "grid"
-                  :onMouseDown #(post-event :start %)
-                  :onMouseMove #(post-event :move %)
-                  :onMouseUp #(post-event :stop %)}
-             (map create-cell cells)))))
+  (om/component (apply render-grid
+                       (map render-cell (:cells data)))))

 (defn xy-message [ch msg-name xy-obj]
   (put! ch [msg-name {:x (.-pageX xy-obj) :y (.-pageY xy-obj)}]))
@@ -49,4 +48,3 @@
       (recur (<! app/draw-events)))))

 (main)
-


Add support for new profile persistence.

--- src/uxbox/repo/users.cljs
+++ src/uxbox/repo/users.cljs
@@ -6,22 +6,31 @@

 (ns uxbox.repo.users
   "A main interface for access to remote resources."
-  (:refer-clojure :exclude [do])
   (:require [beicon.core :as rx]
             [uxbox.repo.core :refer (request url send!)]
-            [uxbox.state :as ust]))
+            [uxbox.util.transit :as t]))
+
+(defn- decode-payload
+  [{:keys [payload] :as rsp}]
+  (let [metadata (:metadata payload)]
+    (assoc rsp :payload
+           (assoc payload :metadata (t/decode metadata)))))

 (defmethod request :fetch/profile
   [type _]
-  (let [url (str url "/profile/me")]
-    (send! {:method :get :url url})))
+  (let [url (str url "/profile/me")
+        params {:method :get :url url}]
+    (->> (send! params)
+         (rx/map decode-payload))))

 (defmethod request :update/profile
-  [type data]
-  (let [params {:url (str url "/profile/me")
+  [type {:keys [metadata id] :as body}]
+  (let [body (assoc body :metadata (t/encode metadata))
+        params {:url (str url "/profile/me")
                 :method :put
-                :body data}]
-    (send! params)))
+                :body body}]
+    (->> (send! params)
+         (rx/map decode-payload))))

 (defmethod request :update/password
   [type data]


Reuse the output material.

Reuse the output material.

--- src/videotest/buffers.clj
+++ src/videotest/buffers.clj
@@ -40,6 +40,7 @@
   {:b-array (byte-array PIX-CNT1)
    :i-array (int-array PIX-CNT2)
    :frame-mat (Mat. WIDTH HEIGHT CvType/CV_8UC3)
+   :output-mat (Mat. WIDTH HEIGHT CvType/CV_8UC4)
    :camera (camera 0)
    :p-image (q/create-image WIDTH HEIGHT :rgb)})

@@ -49,22 +50,21 @@
             (is-opened? camera)
             (update-in [:frame-mat] (partial grab-frame! camera) ))))

-(defn mat->p-img [mat b-array i-array p-img]
-  (let [n-mat (Mat. WIDTH HEIGHT CvType/CV_8UC4)]
-    (Imgproc/cvtColor mat n-mat Imgproc/COLOR_RGB2RGBA 4)
-    (.get n-mat 0 0 b-array)
-    (-> (ByteBuffer/wrap b-array)
-        (.order ByteOrder/LITTLE_ENDIAN)
-        (.asIntBuffer)
-        (.get i-array)))
+(defn mat->p-img [in-mat out-mat b-array i-array p-img]
+  (Imgproc/cvtColor in-mat out-mat Imgproc/COLOR_RGB2RGBA 4)
+  (.get out-mat 0 0 b-array)
+  (-> (ByteBuffer/wrap b-array)
+      (.order ByteOrder/LITTLE_ENDIAN)
+      (.asIntBuffer)
+      (.get i-array))
   (.loadPixels p-img)
   (set! (.pixels p-img) (aclone i-array))
   (.updatePixels p-img)
   p-img)

 (defn update-p-image [state]
-  (let [{:keys [frame-mat b-array i-array]} state]
-    (update-in state [:p-image] #(mat->p-img frame-mat b-array i-array %))))
+  (let [{:keys [frame-mat output-mat b-array i-array]} state]
+    (update-in state [:p-image] #(mat->p-img frame-mat output-mat b-array i-array %))))

 (defn update [state]
   (-> state


Adding wait until indexed calls so that background processing will not cause sporadic exceptions in logs when running tests.

--- system-int-test/test/cmr/system_int_test/ingest/granule_ingest_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/granule_ingest_test.clj
@@ -141,12 +141,14 @@
       (let [granule (d/item->concept (dg/granule collection {:concept-id "G1-PROV1"}))
             _ (ingest/ingest-concept granule)
             response (ingest/delete-concept granule {:accept-format :json :raw? true})]
+        (index/wait-until-indexed)
          (is (= {:concept-id "G1-PROV1" :revision-id 2}
              (ingest/parse-ingest-body :json response)))))
     (testing "xml response"
       (let [granule (d/item->concept (dg/granule collection {:concept-id "G2-PROV1"}))
             _ (ingest/ingest-concept granule)
             response (ingest/delete-concept granule {:accept-format :xml :raw? true})]
+        (index/wait-until-indexed)
         (is (= {:concept-id "G2-PROV1" :revision-id 2}
              (ingest/parse-ingest-body :xml response)))))))

@@ -225,6 +227,7 @@
         granule (d/item->concept umm-granule)
         _ (ingest/delete-concept (d/item->concept collection :echo10))
         {:keys [status errors]} (ingest/ingest-concept granule)]
+    (index/wait-until-indexed)
     (is (= [400 ["Collection with Entry Title [Coll1] referenced in granule [Gran1] provider [PROV1] does not exist."]]
            [status errors]))
     (is (not (ingest/concept-exists-in-mdb? "G1-PROV1" 0)))))
@@ -276,6 +279,7 @@
                              (assoc :collection-ref (umm-g/map->CollectionRef attrs))
                              (d/item->concept :iso-smap))
                  {:keys [status]} (ingest/ingest-concept granule)]
+             (index/wait-until-indexed)
              (= 200 status))

            {:entry-title "correct"}


Flush *err* and *out* when exiting nailMain

--- src/de/kotka/gorilla/nails.clj
+++ src/de/kotka/gorilla/nails.clj
@@ -63,7 +63,9 @@
          (with-command-line (.getArgs ~'nailContext)
            ~usage
            ~arguments
-           ~@body)))))
+           ~@body)
+         (.flush *out*)
+         (.flush *err*)))))

 (defnail DocLookup
   "Usage: ng de.kotka.gorilla.nails.DocString [options] [--] symbol ..."


Write wrapper for json posts, refactor and tidy up

--- src/discuss/communication.cljs
+++ src/discuss/communication.cljs
@@ -69,50 +69,45 @@
   (let [bubble (first (lib/get-bubbles))]
     (:data_statement_uid bubble)))

+;;; POST functions
+(defn post-json
+  "Wrapper to prepare a POST request. Sending and receiving JSON."
+  ([url body handler headers]
+   (POST (make-url url)
+         {:body            (lib/clj->json body)
+          :handler         handler
+          :error-handler   error-handler
+          :format          :json
+          :response-format :json
+          :headers         headers
+          :keywords?       true}))
+  ([url body]
+   (post-json url body success-handler {"Content-Type" "application/json"})))
+
 (defn post-origin-get-references
   "When this app is loaded, request all available references from the external discussion system."
   []
-  (let [host js/location.host
-        path js/location.pathname]
-    (POST (make-url "api/get/references")
-          {:body            (lib/clj->json {:host host
-                                            :path path})
-           :handler         success-handler
-           :error-handler   error-handler
-           :format          :json
-           :response-format :json
-           :headers         {"Content-Type" "application/json"}
-           :keywords?       true})))
+  (let [url  "api/get/references"
+        body {:host js/location.host
+              :path js/location.pathname}]
+    (post-json url body)))

 (defn post-statement [statement reference add-type]
-  (let [id            (get-in @lib/app-state [:issues :uid])
-        slug          (get-in @lib/app-state [:issues :slug])
-        conclusion-id (get-conclusion-id)                   ; Relevant for add-start-premise
-        supportive?   (get-in @lib/app-state [:discussion :is_supportive])
-        arg-uid       (get-in @lib/app-state [:discussion :arg_uid]) ; For premisses for arguments
-        attack-type   (get-in @lib/app-state [:discussion :attack_type])
-        host          js/location.host
-        path          js/location.pathname
-        url           (str (:base config/api) (get-in config/api [:add add-type]))]
-    (POST (make-url url)
-          {:body            (lib/clj->json {:statement statement
-                                            :reference reference
-                                            :conclusion_id conclusion-id
-                                            :supportive supportive?
-                                            :arg_uid arg-uid
-                                            :attack_type attack-type
-                                            :host host
-                                            :path path
-                                            :issue_id id
-                                            :slug slug})
-           :handler         success-handler
-           :error-handler   error-handler
-           :format          :json
-           :response-format :json
-           :headers         (merge {"Content-Type" "application/json"}
-                                   (token-header))
-           :keywords?       true})))
+  (let [url           (str (:base config/api) (get-in config/api [:add add-type]))
+        body          {:statement statement
+                       :reference reference
+                       :conclusion_id (get-conclusion-id)   ; Relevant for add-start-premise
+                       :supportive    (get-in @lib/app-state [:discussion :is_supportive])
+                       :arg_uid       (get-in @lib/app-state [:discussion :arg_uid]) ; For premisses for arguments
+                       :attack_type   (get-in @lib/app-state [:discussion :attack_type])
+                       :host          js/location.host
+                       :path          js/location.pathname
+                       :issue_id      (get-in @lib/app-state [:issues :uid])
+                       :slug          (get-in @lib/app-state [:issues :slug])}
+        headers        (merge {"Content-Type" "application/json"} (token-header))]
+    (post-json url body success-handler headers)))

+;;; For preparation
 (defn dispatch-add-action
   "Check which action needs to be performed based on the type previously stored in the app-state."
   [statement reference]


test hook

test hook

--- src/main/cawala/api/read.clj
+++ src/main/cawala/api/read.clj
@@ -6,7 +6,7 @@
                      :person/relation :friend}
                  2  {:db/id 2 :person/name "Sally" :person/age 22
                      :person/relation :friend}
-                 3  {:db/id 3 :person/name "Allie" :person/age 62
+                 3  {:db/id 3 :person/name "Allie" :person/age 61
                      :person/relation :enemy}
                  4  {:db/id 4 :person/name "Zoe" :person/age 32
                      :person/relation :friend}


this is not the map-reduce you are looking for.

--- src/useful.clj
+++ src/useful.clj
@@ -75,6 +75,19 @@
         (for [[k v] m]
           [k (f k v)])))

+(defn map-reduce
+  "Perform a map and a reduce over a collection in a single pass. Unlike map, this is not lazy.
+   Returns the equivalent of [(vec (map map-fn coll)) (reduce reduce-fn val coll)]."
+  ([map-fn reduce-fn val coll & [include-val-in-map?]]
+     (reduce
+      (fn [results item]
+        [(conj (first results) (map-fn item))
+         (reduce-fn (second results) item)])
+      [(if include-val-in-map? [(map-fn val)] []) val]
+      coll))
+  ([map-fn reduce-fn coll]
+     (map-reduce map-fn reduce-fn (first coll) (rest coll) true)))
+
 (defn include?
   "Check if val exists in coll."
   [val coll]


generating iterator at aggregate level

generating iterator at aggregate level

--- src/ophion/server.clj
+++ src/ophion/server.clj
@@ -54,7 +54,7 @@
   (let [query (mapv identity (read-json (:body request)))
         label (get-in request [:params :label])
         result (aggregate/evaluate mongo label query)
-        out (map output (iterator-seq result))]
+        out (map output result)]
     {:status 200
      :headers {"content-type" "application/json"}
      :body (stream/->source out)}))


Dunno why that last patch dropped my UTF8 chars

--- src/oxcart/passes.clj
+++ src/oxcart/passes.clj
@@ -32,7 +32,7 @@

 (defn whole-ast->modules
-  "  Whole-AST   (Seq Module)
+  "λ Whole-AST → (Seq Module)

   Returns the modules of the ASt as a sequence."
   [{:keys [modules] :as whole-ast}]
@@ -40,7 +40,7 @@

 (defn whole-ast->forms
-  "  Whole-AST   (Seq AST)
+  "λ Whole-AST → (Seq AST)

   Returns a sequence of all the individual top level form ASTs in the
   given Whole-AST."
@@ -51,7 +51,7 @@

 (defn update-forms
-  "  Whole-AST   (  Form   Form)   arg *
+  "λ Whole-AST → (λ Form → Form) → arg *

   Updates every form in the given Whole-ast, replacing it with (apply
   f form args). Intended to eliminate repetitive Whole-AST


save frontend ids for the docs

save frontend ids for the docs

--- src/pc/models/doc.clj
+++ src/pc/models/doc.clj
@@ -1,23 +1,25 @@
 (ns pc.models.doc
   (:require [pc.datomic :as pcd]
             [pc.models.chat-bot :as chat-bot-model]
-            [datomic.api :refer [db q] :as d]))
+            [datomic.api :refer [db q] :as d])
+  (:import java.util.UUID))

 (defn create! [doc-attrs]
   (let [temp-id (d/tempid :db.part/user)
         {:keys [tempids db-after]} @(d/transact (pcd/conn)
                                                 [(assoc doc-attrs :db/id temp-id)])]
-    (->> (d/resolve-tempid db-after
+    (let [eid (d/resolve-tempid db-after
                            tempids
-                           temp-id)
-         (d/entity db-after)
-         pcd/touch+)))
+                           temp-id)]
+      (-> (d/transact (pcd/conn) [[:db/add eid :frontend/id (UUID. eid eid)]])
+        deref
+        :db-after
+        (d/entity eid)))))

 (def default-name "Untitled")

 (defn create-public-doc! [doc-attrs]
-  (create! (merge {:dummy :dummy/dummy
-                   :document/name "Untitled"
+  (create! (merge {:document/name "Untitled"
                    :document/privacy :document.privacy/public}
                   doc-attrs)))


Fix nasty conceptual `watch` problem

Fix nasty conceptual `watch` problem

--- src/re_demo/core.cljs
+++ src/re_demo/core.cljs
@@ -48,7 +48,7 @@
 (defn nav-item
   []
   (let [mouse-over? (reagent/atom false)]
-    (fn [tab selected-tab-id]
+    (fn [tab selected-tab-id on-select-tab]
       (let [selected (= @selected-tab-id (:id tab))]
       [:div
        {:style {:color            (if selected "#111")
@@ -60,7 +60,7 @@
         :class "nav-item"
         :on-mouse-over (handler-fn (reset! mouse-over? true))
         :on-mouse-out  (handler-fn (reset! mouse-over? false))
-        :on-click      (handler-fn (reset! selected-tab-id (:id tab)))
+        :on-click      (handler-fn (on-select-tab (:id tab)))
         }
        [:span
         {:style {:cursor "default"}}    ;; removes the I-beam over the label
@@ -68,10 +68,10 @@

 (defn left-side-nav-bar
-  [selected-tab-id]
+  [selected-tab-id on-select-tab]
     [v-box
      :children (for [tab tabs-definition]
-                 [nav-item tab selected-tab-id])])
+                 [nav-item tab selected-tab-id on-select-tab])])

 (defn re-com-title
@@ -93,7 +93,7 @@
   []
   (let [id-store        (local-storage (atom nil) ::id-store)
         selected-tab-id (reagent/atom (if (nil? @id-store) (:id (first tabs-definition)) @id-store))   ;; id of the selected tab
-        _               (add-watch selected-tab-id nil #(reset! id-store %4))]                         ;; remember the current navigation item being viewed.
+        on-select-tab   #(do (reset! selected-tab-id %1) (reset! id-store %1))]
     (fn ;; _main
       []
       [h-box
@@ -110,7 +110,7 @@
                    :h-scroll :off
                    :child [v-box
                            :children [[re-com-title]
-                                      [left-side-nav-bar selected-tab-id]]]]
+                                      [left-side-nav-bar selected-tab-id on-select-tab]]]]
                   [scroller
                    :child [box
                            :size      "auto"


Dancers with no marks are now included in export

--- src/tango/export2.clj
+++ src/tango/export2.clj
@@ -21,6 +21,11 @@
                             {:number 5}]
              :dances       [{:name "X-Quick Forward"}
                             {:name "Quick"}]
+             :dancers      [{:number 20}
+                            {:number 30}
+                            {:number 31}
+                            {:number 32}
+                            {:number 40}]
              :result-array [{:dancer-number 30
                              :marks         [true false true]}
                             {:dancer-number 31
@@ -39,6 +44,11 @@
     {:adjudicator/number 1}
     {:adjudicator/number 5}]},
   :round/dances [{:dance/name "Medium"}],
+  :round/starting [{:participant/number 140}
+                   {:participant/number 141}
+                   {:participant/number 142}
+                   {:participant/number 143}
+                   {:participant/number 144}]
   :result/_activity
   [{:result/mark-x true,
     :result/adjudicator {:adjudicator/number 1},
@@ -198,9 +208,6 @@
     :result/adjudicator {:adjudicator/number 1},
     :result/participant {:participant/number 144}}])

-(defn get-dancers [result-facts]
-  (vec (sort  (apply hash-set (map #(get-in % [:result/participant :participant/number]) result-facts)))))
-
 (defn get-mark [result-facts dancer-number adjudicator-number]
   (let [marks (filterv #(= dancer-number (get-in % [:result/participant :participant/number]))
                        (filter #(= adjudicator-number (get-in % [:result/adjudicator :adjudicator/number])) result-facts))]
@@ -211,9 +218,9 @@
 (defn get-marks-for-dancer [result-facts adjudicator-numbers dancer-number]
   (mapv (partial get-mark result-facts dancer-number) adjudicator-numbers))

-(defn result-facts->result-array [result-facts adjudicators]
+(defn result-facts->result-array [result-facts dancers adjudicators]
   (let [adjudicator-numbers (map :adjudicator/number adjudicators)
-        dancer-numbers (get-dancers result-facts)]
+        dancer-numbers (map :participant/number dancers)]
     (mapv #(hash-map :dancer-number %
                      :marks (get-marks-for-dancer result-facts adjudicator-numbers %))
           dancer-numbers)))
@@ -228,9 +235,13 @@
             :dances (vec (map #(hash-map :name (:dance/name %))
                                 (get-in activity-result [:round/dances])))
             :result-array (result-facts->result-array (:result/_activity activity-result)
+                                                      (get-in activity-result [:round/starting])
                                                       (get-in activity-result
                                                               [:round/panel
-                                                               :adjudicator-panel/adjudicators]))}})
+                                                               :adjudicator-panel/adjudicators])
+                                                      )}})
+
+(activity-result->class-result (first (activities-with-result)))

 (def adjudicators
   [{:adjudicator/number 1}


api-note-creation test added

api-note-creation test added

--- test/NoteHub/test/api.clj
+++ test/NoteHub/test/api.clj
@@ -1,7 +1,9 @@
 (ns NoteHub.test.api
   (:require
+    [cheshire.core :refer :all]
     [NoteHub.storage :as storage])
   (:use [NoteHub.api]
+        [noir.util.test]
         [clojure.test]))

 (def note "hello world! This is a _test_ note!")
@@ -82,3 +84,74 @@
           (is (= "password invalid" (:message (:status update-response)))))
         (is (= new-note (:note (get-note note-id))))
         (is (= new-note (:note (get-note note-id))))))))
+
+(deftest api-note-creation
+  (testing "Note creation"
+    (let [response (send-request [:post "/api/note"]
+                                 {:note note
+                                  :pid pid
+                                  :signature (get-signature pid psk note)
+                                  :version "1.0"})
+          body (parse-string (:body response))]
+      (is (has-status response 200))
+      (is (get-in body ["status" "success"]))
+      (is (= note ((parse-string
+                     (:body (send-request [:get "/api/note"] {:version "1.0" :noteID (body "noteID")}))) "note")))
+      (is (do
+            (storage/delete-note (body "noteID"))
+            (not (storage/note-exists? (body "noteID"))))))))
+
+#_
+(deftest note-update
+  (let [session-key (create-session)
+        date (get-date)
+        title "test-note"
+        [year month day] date]
+    (testing "Note update"
+      (is (has-status
+            (send-request
+              [:post "/post-note"]
+              {:session-key session-key
+               :draft "test note"
+               :password "qwerty"
+               :session-value (str (get-hash (str "test note" session-key)))}) 302))
+      (is (note-exists? (build-key date title)))
+      (is (substring? "test note"
+                      ((send-request (url year month day title)) :body)))
+      (is (has-status
+            (send-request
+              [:post "/update-note"]
+              {:key (build-key [year month day] title)
+               :draft "WRONG pass"
+               :password "qwerty1" }) 403))
+      (is (substring? "test note"
+                      ((send-request (url year month day title)) :body)))
+      (is (has-status
+            (send-request
+              [:post "/update-note"]
+              {:key (build-key [year month day] title)
+               :draft "UPDATED CONTENT"
+               :password "qwerty" }) 302))
+      (is (substring? "UPDATED CONTENT"
+                      ((send-request (url year month day title)) :body)))
+      (is (do
+            (delete-note (build-key date title))
+            (not (note-exists? (build-key date title))))))))
+#_
+
+(deftest requests
+  (testing "HTTP Status"
+    (testing "of a wrong access"
+      (is (has-status (send-request "/wrong-page") 404))
+      (is (has-status (send-request (url 2012 6 3 "lol" "stat")) 404))
+      (is (has-status (send-request (url 2012 6 3 "lol" "export")) 404))
+      (is (has-status (send-request (url 2012 6 3 "lol")) 404))
+      (is (has-status (send-request (url 2012 6 4 "wrong-title")) 404)))
+    (testing "of corrupt note-post"
+      (is (has-status (send-request [:post "/post-note"]) 400)))
+    (testing "valid accesses"
+      ;(is (has-status (send-request "/new") 200) "accessing /new")
+      (is (has-status (send-request (url 2012 6 3 "some-title")) 200) "accessing test note")
+      (is (has-status (send-request (url 2012 6 3 "some-title" "export")) 200) "accessing test note's export")
+      (is (has-status (send-request (url 2012 6 3 "some-title" "stats")) 200) "accessing test note's stats")
+      (is (has-status (send-request "/") 200) "accessing landing page"))))


Use FLUSHDB instead of FLUSHALL to clear Redis.

--- test/shale/test/utils.clj
+++ test/shale/test/utils.clj
@@ -77,6 +77,6 @@
   "Clear Redis before and after a test. Right now, though, we're relying on
   connection state in shale.redis :/"
   [test-fn]
-  (with-car* (car/flushall))
+  (with-car* (car/flushdb))
   (test-fn)
-  (with-car* (car/flushall)))
+  (with-car* (car/flushdb)))


Reformatting the generated comments. Few more constant tests.

--- test/cljs/go_test.clj
+++ test/cljs/go_test.clj
@@ -56,6 +56,13 @@
     (println "\t" "." (pr-str "github.com/hraberg/cljs.go/cljs/core"))
     (println ")")))

+(defn test-comment [code ast]
+  (println "/*")
+  (clojure.pprint/pprint code)
+  (println)
+  (clojure.pprint/pprint ast)
+  (println"*/"))
+
 (defn testify [test & assertions]
   (with-out-str
     (printf "func Test_%s(t *testing.T) {\n" (name test))
@@ -63,14 +70,10 @@
             :let [ast (-> [actual] (cljs->ast (assoc (cljs.analyzer/empty-env) :context :expr)))]]
       (when setup
         (printf "{\n")
-        (printf "/*\n")
-        (printf "%s\n" (with-out-str (clojure.pprint/pprint setup)))
-        (printf " */\n")
-        (printf "\t%s\n" (-> [setup] cljs->ast ast->go)))
-      (printf "/*\n")
-      (printf "%s\n" (with-out-str (clojure.pprint/pprint actual)))
-      (printf "%s\n" (with-out-str (clojure.pprint/pprint (first ast))))
-      (printf " */\n")
+        (let [ast (-> [setup] cljs->ast)]
+          (comment setup ast)
+          (printf "\t%s\n" (ast->go ast))))
+      (test-comment actual (first ast))
       (printf "\tassert.Equal(t%s, %s%s)\n"
               (if (nil? expected) "" (str ", \n" expected))
               (str "\n" (ast->go ast))
@@ -84,7 +87,7 @@
         src (gofmt (apply str (testify-header package) tests))]
     (io/make-parents f)
     (spit f src)
-    (go-test (io/file "." (.getParent f))))  )
+    (go-test (io/file "." (.getParent f)))))

 (deftest constants
   (->>
@@ -110,8 +113,12 @@
               #uuid "15c52219-a8fd-4771-87e2-42ee33b79bca"]
              ["&js.RegExp{Pattern: `x`, Flags: ``}" #"x"]
              ["&js.RegExp{Pattern: ``, Flags: ``}" #""]
+             ["&CljsCoreSymbol{Ns: nil, Name: `x`, Str: `x`, Hash: float64(-555367584), Meta: nil}"
+              ''x]
              ["&CljsCoreSymbol{Ns: `user`, Name: `x`, Str: `user/x`, Hash: float64(-568535109), Meta: nil}"
               ''user/x]
+             ["&CljsCoreKeyword{Ns: nil, Name: `x`, Fqn: `x`, Hash: float64(2099068185)}"
+              :x]
              ["&CljsCoreKeyword{Ns: `user`, Name: `x`, Fqn: `user/x`, Hash: float64(2085900660)}"
               :user/x])]
    (emit-test "go_test" "constants_test")))


Removed sample JDBC code.

Removed sample JDBC code.

--- tagcount/src/tagcount/core.clj
+++ tagcount/src/tagcount/core.clj
@@ -92,44 +92,3 @@
 (defn -main
   [& argv]
     (start-worker))
-
-;; example on using clojure.jdbc 0.3.0 api
-
-(def test-upsert
-  "WITH upsert AS
-   (UPDATE spider_count SET tally=tally+1
-    WHERE date='today' AND
-          spider='Googlebot'
-    RETURNING *)
-   INSERT INTO spider_count (spider, tally)
-    SELECT 'Googlebot', 1
-     WHERE NOT EXISTS (SELECT * FROM upsert)")
-
-(defn test-jdbc []
-  (try
-    (println)
-    (println "dropping table")
-    (jdbc/db-do-commands
-     pooled-db-spec
-     (jdbc/drop-table-ddl :spider_count))
-    (println "creating table")
-    (jdbc/db-do-commands
-     pooled-db-spec
-     (jdbc/create-table-ddl :spider_count
-                            [:date :date "NOT NULL" "DEFAULT NOW()"]
-                            [:spider :varchar "NOT NULL"]
-                            [:tally :int "NOT NULL" "DEFAULT 0"]))
-    (println "upserting"
-             (jdbc/execute! pooled-db-spec [test-upsert])
-             (jdbc/execute! pooled-db-spec [test-upsert])
-             (jdbc/execute! pooled-db-spec [test-upsert]))
-    (println (jdbc/query pooled-db-spec ["SELECT * FROM spider_count"]))
-    (finally
-      (println "dropping table")
-      (jdbc/db-do-commands
-       pooled-db-spec
-       (jdbc/drop-table-ddl :spider_count)))))
-
-(comment
-  (test-jdbc)
-  )


CMR-3742: PR comment fixes

CMR-3742: PR comment fixes

--- indexer-app/src/cmr/indexer/api/routes.clj
+++ indexer-app/src/cmr/indexer/api/routes.clj
@@ -73,8 +73,7 @@
       ;; after a deployment using the same deployment code that other apps use for db-migrate.
       (POST "/db-migrate" {:keys [request-context]}
         (acl/verify-ingest-management-permission request-context :update)
-        (index-svc/update-g73)
-        indexes request-context
+        (index-svc/update-indexes request-context)
         {:status 200})

       ;; add routes for accessing caches


added support for alphabetical order - A-N: upper half left to right - O-Z: lower half left to right

--- src/mastersign/wordcloud.clj
+++ src/mastersign/wordcloud.clj
@@ -25,14 +25,15 @@

 (def default-args
   {:width 600
-   :height 200
-   :precision 0.5
+   :height 300
+   :precision 0.7
    :font base-font
-   :min-font-size 13
+   :min-font-size 14
    :max-font-size 60
    :max-test-radius 350
-   :padding 2
-   :shape-mode :word-box ; :word-box, :glyph-box
+   :order-priority 0.7
+   :padding 3
+   :shape-mode :glyph-box ; :word-box, :glyph-box
    :allow-rotation true
    :color-fn #'default-color-fn
    })
@@ -79,20 +80,57 @@
    ([] (lazy-numbers 0))
    ([n] (lazy-seq (cons n (lazy-numbers (inc n))))))

+(defn- priority-angle
+  [text]
+  (let [clean-DE (fn [c] (case c \Ä \A \Ö \O \Ü \U \ß \S c))
+        c (clean-DE (first (.toUpperCase text)))
+        n (int c)
+        s (- (if (or (< n 64) (> n 90)) 64 n) 65)
+        a (* (/ Math/PI 13) s)]
+    (if (<= a Math/PI) (- Math/PI a) a)))
+
+(defn- ring-step
+  [r prec]
+  (/ 2.0 (+ 4 (* prec prec (* Math/PI r)))))
+
+(ring-step 5 1.0)
+
+(defn- scale-radius
+  [priority r a]
+  (let [base (* r (- 1.0 priority))
+        a* (* Math/PI (Math/sqrt a))]
+    (+ base (* (- r base) (+ (* (Math/cos a*) 0.5) 0.5)))))
+
+(defn- ring-angles
+  [precision priority r a]
+  (lazy-seq (cons
+             a
+             (ring-angles precision priority r
+                          (+ a (ring-step (scale-radius priority r a) precision))))))
+
 (defn- test-ring
-  [r precision]
-  (let [n (int (+ 4 (* precision precision (- (* Math/PI r) 4))))
-        step (/ (* 2 Math/PI) n)]
-    (map (partial polar-point r) (range 0.0 (* 2 Math/PI) step))))
+  [r precision pa priority]
+  (cons
+   (polar-point r pa)
+   (apply concat (map
+             (fn [a]
+               (let [sr (scale-radius priority r a)
+                     a* (* Math/PI a)]
+                 [(polar-point sr (+ pa a*))
+                  (polar-point sr (- pa a*))]))
+             (take-while #(< % 1.0) (ring-angles precision priority r 0))))))

 (defn- test-sequence
-  [{:keys [precision max-font-size max-test-radius] :as args} {:keys [text] :as word-info}]
+  [{:keys [width height precision max-font-size max-test-radius order-priority] :as args} {:keys [text] :as word-info}]
   (let [imprecision (* (- 1.0 precision) (- 1.0 precision))
         radii (take-while
-                  #(< % max-test-radius)
+                  #(< (scale-radius order-priority % 1) max-test-radius)
                   (map #(* (+ 1 (* imprecision max-font-size 0.5)) %) (lazy-numbers 1)))
-        rings (map #(test-ring % precision) radii)]
-    (cons (point) (apply concat rings))))
+        pa (priority-angle text)
+        rings (map #(test-ring % precision pa order-priority) radii)
+        boundaries (rectangle (- (/ width 2.0)) (- (/ height 2.0)) width height)
+        reject-pred (fn [p] (.contains boundaries (.x p) (.y p)))]
+    (filter reject-pred (cons (point) (apply concat rings)))))

 (defn- rotate-rect
   [r c a]
@@ -190,7 +228,7 @@
         text "MjgqAIkqQ$§|"
         p1 (point 100 30)
         p2 (point 100 60)
-        pc (point 200 150)
+        pc (point (/ (:width default-args) 2.0) (/ (:height default-args) 2.0))
         r1 (string-centered-bounds g font text p1)
         r2 (string-centered-bounds g font text p2)
         a1 (Area. r1)
@@ -198,24 +236,23 @@
         c2 (rect-center r2)]
     (doto g
       setup
-      ;(draw-rect (rectangle 0 0 (dec w) (dec h)))
-      ;(fill-rect r1)
-      ;(draw-rect r1)
+      ;(draw-dots (test-ring 50 0.2) pc)
+      ;(draw-dots (test-ring 10 0.2) pc)
+      (draw-dots (test-sequence default-args {:text "Alpha"}) pc)
+      (draw-rect (rectangle 0 0 (dec w) (dec h)))
+      (fill-rect r1)
+      (draw-rect r1)
       ;(fill-rect r2)
       ;(draw-rect r2)
-      ;(draw-string-centered text p1 :font font)
-      ;(draw-string-centered text p2 :font font)
+      (draw-string-centered text p1 :font font)
+      (draw-string-centered text p2 :font font)
       ;(draw-dot c1)
-      ;(draw-dot c2)
+      (draw-dot c2 :color Color/GREEN)

       (draw-dot pc)
-      ;(draw-dots (test-ring 50 0.2) pc)
-      ;(draw-dots (test-ring 10 0.2) pc)
-
-      (draw-dots (test-sequence default-args {:text "Alpha"}) pc)
       )))

-(let [img (create-image 400 300 test-painter)]
+(let [img (create-image (:width default-args) (:height default-args) test-painter)]
   (save-image img "D:/Temp/test.png"))

 ; ########################


Unset the draft flag.

Unset the draft flag.

When crating an entry or publishing one unset the draft flag to the board if needed.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -2,7 +2,7 @@
   "Liberator API for entry resources."
   (:require [clojure.string :as s]
             [defun.core :refer (defun-)]
-            [if-let.core :refer (if-let*)]
+            [if-let.core :refer (if-let* when-let*)]
             [taoensso.timbre :as timbre]
             [compojure.core :as compojure :refer (ANY)]
             [liberator.core :refer (defresource by-method)]
@@ -123,6 +123,12 @@
                       (assoc :auto-share true))]
       (share-entry conn share-ctx (:uuid entry-result)))))

+(defn undraft-board [conn user org board]
+  (when (:draft board)
+    (let [updated-board (assoc board :draft false)]
+      (timbre/info "Unsetting draft for board:" (:slug board))
+      (board-res/update-board! conn (:uuid board) updated-board))))
+
 (defn- create-entry [conn ctx entry-for]
   (timbre/info "Creating entry for:" entry-for)
   (if-let* [org (:existing-org ctx)
@@ -133,6 +139,7 @@
     (do
       (timbre/info "Created entry for:" entry-for "as" (:uuid entry-result))
       (when (= (:status entry-result) "published")
+        (undraft-board conn (:user ctx) org board)
         (auto-share-on-publish conn ctx entry-result))
       (notification/send-trigger! (notification/->trigger :add org board {:new entry-result} (:user ctx) nil))
       {:created-entry entry-result})
@@ -163,6 +170,7 @@
             updated-entry (:updated-entry ctx)
             publish-result (entry-res/publish-entry! conn (:uuid updated-entry) updated-entry user)]
     (do
+      (undraft-board conn user org board)
       (timbre/info "Published entry for:" (:uuid updated-entry))
       (auto-share-on-publish conn ctx publish-result)
       (timbre/info "Published entry:" entry-for)


Make sure all unread threads ar moved to the top if the unread cap days is zero.

--- src/oc/storage/db/common.clj
+++ src/oc/storage/db/common.clj
@@ -255,7 +255,9 @@
              (pos? limit))
          (boolean? count)]}
   (let [order-fn (if (= order :desc) r/desc r/asc)
-        unread-cap-ms (* 60 60 24 config/threads-unread-cap-days 1000)
+        unread-cap-ms (if (zero? config/threads-unread-cap-days)
+                        (* (c/to-long (t/date-time 0)) 1000)
+                        (* 60 60 24 config/threads-unread-cap-days 1000))
         read-items-map (r/coerce-to (zipmap (map :item-id read-items) (map :read-at read-items)) :object)]
     (db-common/with-timeout db-common/default-timeout
       (as-> (r/table "interactions") query


made uberjar able to run

made uberjar able to run

--- src/ocr_evaluator/server.clj
+++ src/ocr_evaluator/server.clj
@@ -1,12 +1,13 @@
 (ns ocr-evaluator.server
-  (:use [ring.middleware.resource :only [wrap-resource]]
+  (:use [compojure.core]
+        [compojure.handler]
+        [ring.adapter.jetty :as jetty]
         [ring.middleware.file-info :only [wrap-file-info]]
-        [ring.adapter.jetty :as jetty]
-        [compojure.core]
-        [compojure.handler])
-  (:require [compojure.route :as route]
-            [me.raynes.laser :as l]
-            [clojure.java.io :refer :all])
+        [ring.middleware.resource :only [wrap-resource]])
+  (:require [clojure.java.io :as io]
+            [clojure.java.io :refer :all]
+            [compojure.route :as route]
+            [me.raynes.laser :as l])
   (:gen-class))

 (defn get-files-sorted [dir]
@@ -14,8 +15,21 @@
        rest
        (sort-by #(.getName %))))

+(defn read-file
+  "List eine Datei ein entweder vom Verzeichnis oder vom jar
+   Achtung! fügt automatisch ein / am Anfang ein wenn es im jar archiv sucht
+   Ordner können im jar archiv nicht! gefunden werden"
+  [path]
+  (let [f (file path)]
+    (if (.exists f)
+      f
+      (reader (.getResourceAsStream (class false)
+                                    (.substring path
+                                                (count "resources")
+                                                (count path)))))))
+
 (defn index-site []
-  (l/document (l/parse (file "resources/public/indey.html"))))
+  (l/document (l/parse (read-file "resources/public/indey.html"))))

 (defroutes handler
   (GET "/index.html" [] (index-site))


influxdb tests: add request for mocked tests

--- test/riemann/influxdb_test.clj
+++ test/riemann/influxdb_test.clj
@@ -7,6 +7,9 @@

 (logging/init)

+; Would the next person working on influxdb kindly update these tests to use
+; riemann.test-utils/with-mock? Would be nice to have something besides just
+; integration tests. --Kyle, Sep 2015 :)

 (deftest ^:influxdb-8 ^:integration influxdb-test-8
   (let [k (influxdb/influxdb {:block-start true})]


More type hinting and ensure aeron ids are properly cast

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -246,12 +246,12 @@
     (taoensso.timbre/info "Stopping Aeron Peer Group")
     (future-cancel (:subscriber-fut subscriber))
     (future-cancel (:pub-gc-thread component))
-    (.close (:subscription subscriber))
-    (.close (:conn subscriber))
+    (.close ^uk.co.real_logic.aeron.Subscription (:subscription subscriber))
+    (.close ^Aeron (:conn subscriber))
     (doseq [pub (vals @publications)]
       (.close ^Publication (:publication pub)))
     (doseq [conn (vals @connections)]
-      (.close conn))
+      (.close ^Aeron conn))
     (when media-driver (.close ^MediaDriver media-driver))
     (assoc component
            :pub-gc-thread nil
@@ -264,10 +264,10 @@
   (map->AeronPeerGroup {:opts opts}))

 (def possible-ids
-  (set (range -32768 32768)))
+  (set (map short (range -32768 32768))))

 (defn choose-id [used]
-  (short (first (clojure.set/difference possible-ids used))))
+  (first (clojure.set/difference possible-ids used)))

 ;;; Assigns a unique id to each peer so that messages do not need
 ;;; to send the entire peer-id in a payload, saving 14 bytes per


Add some logging to SQS trigger send.

Add some logging to SQS trigger send.

--- src/open_company/lib/bot.clj
+++ src/open_company/lib/bot.clj
@@ -1,5 +1,6 @@
 (ns open-company.lib.bot
   (:require [amazonica.aws.sqs :as sqs]
+            [taoensso.timbre :as timbre]
             [medley.core :as med]
             [clojure.string :as string]
             [schema.core :as s]
@@ -60,7 +61,9 @@
                     :stakeholder-update {:type :all-members})}))

 (defn send-trigger! [trigger]
+  (timbre/info "[bot] request to send " trigger " to " c/aws-sqs-queue)
   (s/validate BotTrigger trigger)
+  (timbre/info "[bot] sending")
   (sqs/send-message
    {:access-key c/aws-access-key-id
     :secret-key c/aws-secret-access-key}


Fixed vestigal speed-up.

Fixed vestigal speed-up.

--- src/overtunes/songs/at_all.clj
+++ src/overtunes/songs/at_all.clj
@@ -3,9 +3,8 @@
     [overtone.live :only [at now]]
     [overtone.inst.sampled-piano :only [sampled-piano]]))

-(defn bpm [beats-per-minute]
-  (let [start (now)
-        ms-per-minute (* 60 1000)
+(defn bpm [beats-per-minute start]
+  (let [ms-per-minute (* 60 1000)
         ms-per-beat (/ ms-per-minute beats-per-minute)]
     #(+ start (* ms-per-beat %))))

@@ -101,10 +100,11 @@
       (chord# (update-in I [:i] raise))))

 (defn play# [] (->
-                 (bpm 160) (after 2)
+                 (bpm 160 (now))
+                 (after 2)
                  intro# intro#
                  first-bit#
-                 (speed-up 3/2)
+                 (tempo 3/2)
                  first-bit# variation#
                  final-chord#))


add an example

add an example

--- src/pc/views/email_landing.clj
+++ src/pc/views/email_landing.clj
@@ -4,6 +4,14 @@
             [pc.views.scripts :as scripts]
             [pc.profile :refer (prod-assets?)]))

+(def template->gif-url
+  {"simple-tools" "/email/simple-tools.gif"})
+
+(defn get-gif-url [template-name]
+  (get template->gif-url template-name "/email/simple-tools.gif"))
+

 (defn email-landing [template-name]
-  [:div "Welcome to Precursor"])
+  [:div
+   [:p "Welcome to Precursor"]
+   [:p [:img {:src (get-gif-url template-name)}]]])


db/docids.clj: added assign-docid

db/docids.clj: added assign-docid

This first checks if ANY of the passed keys have a docid,
and uses that before assigning a new docid.

--- src/org/altlaw/db/docids.clj
+++ src/org/altlaw/db/docids.clj
@@ -32,8 +32,13 @@
   (alter (get-next-docid) inc))

 (defn assign-next-docid [collection keys]
-  (dosync (set-docid collection keys @(get-next-docid))
-          (increment-next-docid)))
+  (set-docid collection keys @(get-next-docid))
+  (increment-next-docid))
+
+(defn assign-docid [collection keys]
+  (dosync (if-let [docid (some #(get-docid collection %) keys)]
+            (set-docid collection keys docid)
+            (assign-next-docid collection keys))))

 (defn save-next-docid []
   (props/set-property "next_docid" @(get-next-docid)))
@@ -48,4 +53,4 @@
   (assert (contains? request :collection))
   (assert (contains? request :keys))
   (assert (coll? (:keys request)))
-  (assign-next-docid (:collection request) (:keys request)))
+  (assign-docid (:collection request) (:keys request)))


[#533] Changes after feedback

[#533] Changes after feedback

--- backend/src/akvo/lumen/component/keycloak.clj
+++ backend/src/akvo/lumen/component/keycloak.clj
@@ -54,9 +54,8 @@
       :body json/decode))

 (defn request-headers
-  "Create a partial request with json content type and a valid bearer token.
-   This token can be used for a batch of requests. This enables us to not have
-   to get a new token for every request to Keycloak but one for task we have."
+  "Create a set of request headers to use for interaction with the Keycloak
+   REST API. This allows us to reuse the same token for multiple requests."
   [{:keys [openid-config credentials]}]
   (let [params (merge {"grant_type" "client_credentials"}
                       credentials)
@@ -158,7 +157,7 @@

 (defn tenant-member?
   "Return true for both members and admins."
-  [{api-root :api-root :as keycloak} tenant email]
+  [{:keys [api-root] :as keycloak} tenant email]
   (let [request-headers (request-headers keycloak)]
     (if-let [user-id
              (get (fetch-user-by-email request-headers api-root email) "id")]
@@ -277,7 +276,7 @@
            (= 204 (set-user-have-verified-email
                    request-headers api-root user-id)))))

-  (create-user [{api-root :api-root} request-headers email]
+  (create-user [{:keys [api-root]} request-headers email]
     (client/post (format "%s/users" api-root)
                  {:body (json/encode
                    {"username" email
@@ -293,7 +292,7 @@
     [this tenant author-claims user-id]
     (do-promote-user-to-admin this tenant author-claims user-id))

-  (reset-password [{api-root :api-root} request-headers user-id tmp-password]
+  (reset-password [{:keys [api-root]} request-headers user-id tmp-password]
     (client/put (format "%s/users/%s/reset-password" api-root user-id)
                 {:body (json/encode {"temporary" true
                                      "type" "password"


Medium update graph; closes 28; cleaned up comments and opts

--- src/polismath/conversation.clj
+++ src/polismath/conversation.clj
@@ -20,12 +20,14 @@

 (def base-conv-update-graph
+  "Base of all conversation updates; handles default update opts and does named matrix updating"
   {:opts'       (plmb/fnk [opts]
                   "Merge in opts with the following defaults"
                   (merge opts {:n-comps 2
                                :pca-iters 10
-                               :cluster-iters 10
+                               :base-iters 10
                                :base-k 100
+                               :group-iters 10
                                :group-k 3}))
    :rating-mat  (plmb/fnk [conv votes]
                   (update-nmat (:rating-mat conv)
@@ -33,9 +35,10 @@

 (def small-conv-update-graph
+  "For computing small conversation updates (those without need for base clustering)"
   (merge base-conv-update-graph
     {:mat   (plmb/fnk [rating-mat]
-              "swap nils for zeros"
+              "swap nils for zeros - most things need the 0s, but repness needs the nils"
               (map (fn [row] (map #(if (nil? %) 0 %) row))
                 (:matrix rating-mat)))
      :pca   (plmb/fnk [conv mat opts']
@@ -49,10 +52,29 @@
               (kmeans (assoc rating-mat :matrix mat :cols (map #(str "pc" %) (:n-comps opts')))
                 (:group-k opts')
                 :last-clusters (:group-clusters conv)
-                :cluster-iters (:cluster-iters opts')))
+                :cluster-iters (:group-iters opts')))
      :repness
             (plmb/fnk [rating-mat group-clusters]
               (conv-repness rating-mat group-clusters))}))
+
+
+(def med-conv-update-graph1
+  "For computing small conversation updates (those with need of base clustering)"
+  (merge small-conv-update-graph
+    {:base-clusters
+            (plmb/fnk [conv rating-mat mat opts']
+              (kmeans (assoc rating-mat :matrix mat)
+                (:base-k opts')
+                :last-clusters (:base-clusters conv)
+                :cluster-iters (:base-iters opts')))
+     :proj  (plmb/fnk [base-clusters pca]
+              (pca-project (map :center base-clusters) pca))
+     :group-clusters
+            (plmb/fnk [conv rating-mat proj opts']
+              (kmeans (assoc rating-mat :matrix proj)
+                (:grop-k opts')
+                :last-clusters (:group-clusters conv)
+                :cluster-iters (:group-iters opts')))}))

 (defn partial-pca


Hook up plan cancelling UI to dangerzone API

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -1230,7 +1230,9 @@
     (go
      (let [api-result (<! (ajax/managed-ajax
                            :delete
-                           (gstring/format "/api/v1/organization/%s/plan" org-name)
+                           (gstring/format "/api/dangerzone/organization/%s/%s/plan"
+                                           vcs_type
+                                           org-name)
                            :params {:cancel-reasons cancel-reasons :cancel-notes cancel-notes}))]
        (if-not (= :success (:status api-result))
          (put! errors-ch [:api-error api-result])


Clean up the defgauge macro a bit.

Clean up the defgauge macro a bit.

--- metrics-clojure-core/src/metrics/gauges.clj
+++ metrics-clojure-core/src/metrics/gauges.clj
@@ -24,17 +24,18 @@
                     (proxy [Gauge] []
                       (value [] (f)))))

+
 (defmacro defgauge
   "Define a new Gauge metric with the given title.

   The rest of the arguments may be a body form or function to call to
   retrieve the value of the Gauge."
-  [title & body]
-  (cond (and (= 1 (count body)) (and (symbol? (first body))
-                                     (fn? (eval (first body)))))
-        `(gauge-fn ~(str title) ~(first body))
-        true
-        `(gauge ~(str title) ~@body)))
+  [title & [b & bs :as body]]
+  (if (and (empty? bs)
+           (symbol? b)
+           (fn? (eval b)))
+    `(def ~title (gauge-fn ~(str title) ~b))
+    `(def ~title (gauge ~(str title) ~@body))))

 ; Read ------------------------------------------------------------------------


Formatting

Formatting

--- test/cljs/go_test.clj
+++ test/cljs/go_test.clj
@@ -72,9 +72,9 @@
       (printf "%s\n" (with-out-str (clojure.pprint/pprint (first ast))))
       (printf " */\n")
       (printf "\tassert.Equal(t%s, %s%s)\n"
-              (if (nil? expected) "" (str ", " expected))
-              (ast->go ast)
-              (if (nil? message) "" (str ", `" message "`")))
+              (if (nil? expected) "" (str ", \n" expected))
+              (str "\n" (ast->go ast))
+              (if (nil? message) "" (str ", \n`" message "`")))
       (when setup
         (printf "}\n")))
     (printf "}\n")))