improve aethestics/view of method configs listing

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/workspace_method_confs.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/workspace_method_confs.cljs
@@ -13,24 +13,31 @@
     (fn [i] {:name (rand-nth ["rand_name_1" "rand_name_2" "rand_name_3" "rand_name_4"])
          :namespace (str "ns_s_" (inc i))
          :root-ent-type (str "r_e_t_" (inc i))
-         :workspaceName {:namespace (str "*ws_ns_" (inc i))
-                        :name (str "*ws_n_" (inc i))}
-         :methodStoreMethod {:namespace (str "*ms_ns_" (inc i))
-                            :name (str "*ms_n_" (inc i))
-                            :version (str "*ms_v_" (inc i))}
-         :methodStoreConfig {:namespace (str "*msc_ns_" (inc i))
-                             :name (str "*msc_n_" (inc i))
-                             :version (str "*msc_v_" (inc i))
+         :workspaceName {:namespace (str "ws_ns_" (inc i))
+                        :name (str "ws_n_" (inc i))}
+         :methodStoreMethod {:methodNamespace (str "ms_ns_" (inc i))
+                            :methodName (str "ms_n_" (inc i))
+                            :methodVersion (str "ms_v_" (inc i))}
+         :methodStoreConfig {:namespace (str "msc_ns_" (inc i))
+                             :name (str "msc_n_" (inc i))
+                             :version (str "msc_v_" (inc i))
                              }
-         :inputs {:i1 (str "*i_1_" (inc i))
-                  :i2 (str "*i_2_" (inc i))}
-         :outputs {:o1 (str "*o_1_" (inc i))
-                  :o2 (str "*o_2_" (inc i))}
-         :prerequisites {:p1 (str "*p_1_" (inc i))
-                  :p2 (str "*p_2_" (inc i))}})
+         :inputs {:i1 (str "i_1_" (inc i))
+                  :i2 (str "i_2_" (inc i))}
+         :outputs {:o1 (str "o_1_" (inc i))
+                  :o2 (str "o_2_" (inc i))}
+         :prerequisites {:p1 (str "p_1_" (inc i))
+                  :p2 (str "p_2_" (inc i))}})
     (range (rand-int 50))))

+
+
+(defn
+  stringify_map
+  [the_map]
+  (for [s (keys the_map)] (let [k s v (get the_map k)] (str k "," v " ; ")))
+  )

 (react/defc WorkspaceMethodsConfigurationsList
@@ -39,7 +46,7 @@
      [:div {:style {:padding "0 4em"}}
       (if (zero? (count (:method-confs props)))
         [:div {:style {:textAlign "center" :backgroundColor (:background-gray style/colors)
-                       :padding "1em 0" :borderRadius 8}}
+                       :padding   "1em 0" :borderRadius 8}}
          "There are no method configurations to display."]
         [table/Table
          (let [cell-style {:flexBasis  "8ex" :flexGrow 1 :whiteSpace "nowrap" :overflow "hidden"
@@ -49,41 +56,46 @@
                                [:span {:style {:fontSize "90%"}} text]])]
            {:columns [{:label (header-label "Name")
                        :style (merge cell-style {:borderLeft "none"})}
-                      {:label (header-label "Namespace")
-                       :style cell-style
+                      {:label        (header-label "Namespace")
+                       :style        cell-style
                        :header-style {:borderLeft "none"}}
-                      {:label (header-label "Root Entity Type")
-                       :style cell-style
+                      {:label        (header-label "Root Entity Type")
+                       :style        cell-style
                        :header-style {:borderLeft "none"}}
-                      {:label (header-label "Workspace Name")
+                      {:label        (header-label "Workspace Name")
                        :header-style {:borderLeft "none"}
-                       :style cell-style}
-                      {:label (header-label "Method Store Method")
-                       :style cell-style
+                       :style        cell-style}
+                      {:label        (header-label "Method Store Method")
+                       :style        cell-style
                        :header-style {:borderLeft "none"}}
-                      {:label (header-label "Method Store Config")
-                       :style cell-style
+                      {:label        (header-label "Method Store Config")
+                       :style        cell-style
                        :header-style {:borderLeft "none"}}
-                      {:label (header-label "Inputs")
+                      {:label        (header-label "Inputs")
                        :header-style {:borderLeft "none"}
-                       :style cell-style}
-                      {:label (header-label "Outputs")
-                       :style cell-style
+                       :style        cell-style}
+                      {:label        (header-label "Outputs")
+                       :style        cell-style
                        :header-style {:borderLeft "none"}}
-                      {:label (header-label "Pre-Requisites")
-                       :style (merge cell-style {:flexBasis "30ex"})
+                      {:label        (header-label "Pre-Requisites")
+                       :style        (merge cell-style {:flexBasis "30ex"})
                        :header-style {:borderLeft "none"}}]
-            :data (map (fn [m]
-                         [(m "name")
-                          (m "namespace")
-                          (m "root-ent-type")
-                          (m "workspaceName")
-                          (m "methodStoreMethod")
-                          (m "methodStoreConfig")
-                          (m "inputs")
-                          (m "outputs")
-                          (m "prerequisites")])
-                    (:method-confs props))})])])})
+            :data    (map (fn [m]
+                            [(m "name")
+                             (m "namespace")
+                             (m "root-ent-type")
+                             (str (get (m "workspaceName") "namespace") ":"
+                                  (get (m "workspaceName") "name"))
+                             (str (get (m "methodStoreMethod") "methodNamespace") ":"
+                                  (get (m "methodStoreMethod") "methodName") ":"
+                                  (get (m "methodVersion") "methodVersion"))
+                             (str (get (m "methodStoreConfig") "namespace") ":"
+                                  (get (m "methodStoreConfig") "name") ":"
+                                  (get (m "methodStoreConfig") "version"))
+                             (stringify_map (m "inputs"))
+                             (stringify_map (m "outputs"))
+                             (stringify_map (m "prerequisites"))])
+                          (:method-confs props))})])])})

 (react/defc WorkspaceMethodConfigurations


Still playing with clojure on the cannons problem

It seems like there should be a nice way to handle this: When two words
collide, matching letters "cancel out", and the leftovers fall to the
ground. The word with the most left-over letters "wins". A good way to
handle this without mutating the strings isn't coming to me.

--- cannons/cannons.clj
+++ cannons/cannons.clj
@@ -2,11 +2,24 @@

 (defn word-collision
   [w1 w2]
-    [(reduce (fn [x] (.replaceFirst w2 (.toString x) "")) w1)
-     (reduce (fn [x] (.replaceFirst w1 (.toString x) "")) w2)])
+  (let [left-letters (reduce
+                       (fn [acc x] (assoc acc x (inc (get acc x 0))))
+                       {}
+                       w1)
+        right-letters (reduce
+                        (fn [acc x] (assoc acc x (inc (get acc x 0))))
+                        {}
+                        w2)]
+    (merge-with (fn [x y]
+                  (let [diff (- x y)]
+                    (cond
+                      (> diff 0) :left
+                      (< diff 0) :right
+                      :else diff)))
+                left-letters
+                right-letters)))

 (doseq [line (take-while (partial not= ":q") (repeatedly read-line))]
   (let [[left-word right-word] (.split line " ")
-        [left-score right-score] (word-collision left-word right-word)]
-    (println (into left-score right-score))
-    (println (count left-score) (count right-score))))
+        result (word-collision left-word right-word)]
+    (println result)))


Test for add-macros-suffix / drop-macros-suffix

--- planck-cljs/test/planck/repl_test.cljs
+++ planck-cljs/test/planck/repl_test.cljs
@@ -35,14 +35,16 @@
                          :column 3}))
           "foo.core"))))

-(defspec first-element-is-min-after-sorting                 ;; the name of the test
-  100                                                       ;; the number of iterations for test.check to test
-  (prop/for-all [v (gen/not-empty (gen/vector gen/int))]
-    (= (apply min v)
-      (first (sort v)))))
-
 (deftest undo-reader-conditional-whitespace-docstring-test
   (is (= "a\n  b" (planck.repl/undo-reader-conditional-whitespace-docstring "a\n     b"))))

 (deftest root-resource-test
   (is (= "/foo_bar_baz/boo/core" (planck.repl/root-resource 'foo-bar-baz.boo.core))))
+
+(defspec add-drop-macros-suffix-test
+  (prop/for-all [ns-sym gen/symbol]
+    (= ns-sym (-> ns-sym
+                repl/add-macros-suffix
+                str
+                repl/drop-macros-suffix
+                symbol))))


Exclude chain

Exclude chain

--- test/cljc/reitit/chain.clj
+++ test/cljc/reitit/chain.clj
@@ -10,6 +10,7 @@
 ;
 ; You must not remove this notice, or any other, from this software.

+(comment
 (ns reitit.chain
   "Interceptor pattern. Executes a chain of Interceptor functions on a
   common \"context\" map, maintaining a virtual \"stack\", with error
@@ -378,3 +379,4 @@
        context)))
   ([context interceptors]
    (execute (enqueue context interceptors))))
+)


refactor tests to show individual failures

--- library/test/clj/test/doo/core.clj
+++ library/test/clj/test/doo/core.clj
@@ -100,7 +100,7 @@
   (zero? (:exit doo-output)))

 (deftest integration
-  (testing "We can compile a cljs project"
+  (testing "We can compile a cljs project and run the script"
     (let [doo-opts {:verbose false
                     :paths {:slimer "../example/node_modules/.bin/slimerjs"}}
           compiler-opts {:output-to "out/testable.js"
@@ -108,22 +108,18 @@
                          :main 'example.runner
                          :optimizations :none}
           srcs (cljs/inputs "../example/src" "../example/test")]
-      (are [opts envs] (let [compiler-opts' (merge compiler-opts opts)]
-                         (cljs/build srcs compiler-opts')
-                         (->> envs
-                           (mapv (fn [env]
-                                   (-> env
-                                     (doo/run-script compiler-opts' doo-opts)
-                                     doo-ok?)))
-                           (every? true?)))
-           {} [:phantom :chrome :firefox :karma-phantom]
-           {:target :nodejs} [:node]
-           {:optimizations :whitespace} [:rhino :nashorn :phantom
-                                         :chrome :firefox :karma-phantom]
-           {:optimizations :simple :target :nodejs} [:node]
-           {:optimizations :advanced :target :nodejs} [:node]
-           {:optimizations :advanced} [:phantom :rhino :nashorn
-                                       :chrome :firefox :karma-phantom]))))
+      (doseq [[opts envs] [[{} [:phantom :chrome :firefox :karma-phantom]]
+                           [{:target :nodejs} [:node]]
+                           [{:optimizations :whitespace} [:rhino :nashorn :phantom
+                                                          :chrome :firefox :karma-phantom]]
+                           [{:optimizations :simple :target :nodejs} [:node]]
+                           [{:optimizations :advanced :target :nodejs} [:node]]
+                           [{:optimizations :advanced} [:phantom :rhino :nashorn
+                                                        :chrome :firefox :karma-phantom]]]]
+        (let [compiler-opts' (merge compiler-opts opts)]
+          (cljs/build srcs compiler-opts')
+          (doseq [env envs]
+            (is (doo-ok? (doo/run-script env compiler-opts' doo-opts)))))))))

 (deftest paths-with-options
   (testing "We can pass paths with options"
@@ -137,5 +133,5 @@
       (is (doo-ok? (doo/run-script :phantom compiler-opts doo-opts)))
       (testing "but there are problems with bad options"
         (is (not (doo-ok? (->> {:phantom "phantomjs --bad-opts=asdfa"}
-                            (assoc doo-opts :paths)
-                            (doo/run-script :phantom compiler-opts)))))))))
+                               (assoc doo-opts :paths)
+                               (doo/run-script :phantom compiler-opts)))))))))


Document the process of adding namespaces to devcards home.

Clarified that devcards_src/core.cljs needs to be edited in order for
new namespaces to appear.

--- src/leiningen/new/devcards/devcards-core.cljs
+++ src/leiningen/new/devcards/devcards-core.cljs
@@ -22,6 +22,9 @@
     I can be found in `devcards_src/{{sanitized}}_devcards/core.cljs`.

     If you add cards to this file, they will appear here on this page.
+    As you add cards to other namespaces, those namespaces will
+    be listed on the Devcards **home** page, provided you require
+    those files in `devcards_src/{{sanitized}}_devcards/core.cljs`.

     You can add devcards to any file as long as you require
     `devcards.core` like so:
@@ -30,8 +33,5 @@
     (:require [devcards.core :as dc :include-macros true])
     ```

-    As you add cards to other namspaces, those namspaces will
-    be listed on the Devcards **home** page.
-
     Here are some Devcard examples"))


rooted-relative returns a string already

--- src/adzerk/boot_cljs/middleware.clj
+++ src/adzerk/boot_cljs/middleware.clj
@@ -151,7 +151,7 @@
           output-dir  (util/get-name (:output-dir opts))
           cljs-paths  (map core/tmppath (:cljs files))
           main*       (-> main core/tmppath deps/strip-extension)
-          rooted-path #(.getPath (util/rooted-relative docroot (core/tmppath %)))
+          rooted-path #(util/rooted-relative docroot (core/tmppath %))
           scripts     (-> (:incs files)
                           (->> (mapv rooted-path))
                           (conj (io/file output-dir "goog" "base.js"))


CMR-1397: Refactored to remove var

CMR-1397: Refactored to remove var

--- search-app/test/cmr/search/test/api/routes.clj
+++ search-app/test/cmr/search/test/api/routes.clj
@@ -5,9 +5,6 @@

 (def ^:private api (#'cmr.search.api.routes/build-routes
                      {:search-public-conf {:protocol "https" :relative-root-url "/search"}}))
-
-;; referring the private get-search-results-format function into this namespace for testing
-(def get-search-results-format (ns-resolve 'cmr.search.api.routes 'get-search-results-format))

 (defn- substring?
   [test-value string]
@@ -48,7 +45,7 @@
 (deftest get-search-results-format-test
   (testing "format from headers"
     (are [path headers default-mime-type expected-format]
-         (=  expected-format (get-search-results-format path headers default-mime-type))
+         (=  expected-format (#'r/get-search-results-format path headers default-mime-type))
          ;; Accept header
          "search/collections" {"accept" "application/echo10+xml"} "application/xml" :echo10
          "search/collections" {"accept" "application/dif+xml"} "application/xml" :dif
@@ -90,7 +87,7 @@

   (testing "format from extension"
     (are [path headers default-mime-type expected-format]
-         (=  expected-format (get-search-results-format path headers default-mime-type))
+         (=  expected-format (#'r/get-search-results-format path headers default-mime-type))
          "search/collections.echo10" {"accept" "application/dif+xml"} "application/xml" :echo10
          "search/collections.dif" {"accept" "application/json"} "application/xml" :dif
          "search/collections.dif10" {"accept" "application/json"} "application/xml" :dif10
@@ -105,7 +102,7 @@

   (testing "using default format"
     (are [path headers default-mime-type expected-format]
-         (=  expected-format (get-search-results-format path headers default-mime-type))
+         (=  expected-format (#'r/get-search-results-format path headers default-mime-type))
          "search/collections" {} "application/echo10+xml" :echo10
          "search/collections" {} "application/dif+xml" :dif
          "search/collections" {} "application/dif10+xml" :dif10


Use :none optimization level on watch.

Use :none optimization level on watch.

--- scripts/watch.clj
+++ scripts/watch.clj
@@ -5,7 +5,7 @@
    :target :nodejs
    :output-to "out/tests.js"
    :output-dir "out"
-   :optimizations :simple
+   :optimizations :none
    :pretty-print true
    :language-in  :ecmascript6
    :language-out :ecmascript5


Add greatest common divisors fn to toolset.clj

--- euler_clojure/src/euler/toolset.clj
+++ euler_clojure/src/euler/toolset.clj
@@ -42,3 +42,8 @@
     (= n 1) 1
     :else (let [ps (distinct (prime-factors n))]
             (int (* n (reduce * (map #(- 1 (/ 1 %)) ps)))))))
+
+(defn gcd [a b]
+  (if (zero? b)
+    a
+    (recur b (mod a b))))


commented toplevel calls

commented toplevel calls

--- src/clj/xl/max_1_line_in_matrix.clj
+++ src/clj/xl/max_1_line_in_matrix.clj
@@ -87,4 +87,4 @@
     )
   )

-(samples)+;(samples)


harvest-board-indices: a better selector.

--- src/clj_ptt_crawler/crawl_board.clj
+++ src/clj_ptt_crawler/crawl_board.clj
@@ -1,6 +1,7 @@
 (ns clj-ptt-crawler.crawl-board
   (:import java.net.URL)
-  (:require [net.cgrand.enlive-html :as enlive]
+  (:require [clojure.string :as str]
+            [net.cgrand.enlive-html :as enlive]
             [clj-http.client :as client])
   (:gen-class))

@@ -11,7 +12,7 @@
   (-> url-board-index
       (client/get {:insecure? true})
       (enlive/html-snippet)
-      (enlive/select [:a])))
+      (enlive/select [[:a (enlive/attr-contains :href (str/join ["/bbs/" board-name "/index"]) )]])))

 (defn -main [board_name output_dir]
   (println (harvest-board-indices (clojure.string/join "" [PTT_URL "/bbs/" board_name "/index.html"]) board_name)))


Rename a predicate

Rename a predicate

--- src/cljam/io/vcf/util/normalize.clj
+++ src/cljam/io/vcf/util/normalize.clj
@@ -62,15 +62,15 @@
            :start (Math/max 1 (- e (dec window))),
            :end (dec e)}))))

-(defn- char-equals-ignore-case
+(defn- char-equals-ignore-case?
   ([_]
    true)
   ([x y]
    (= (Character/toUpperCase ^char x)
       (Character/toUpperCase ^char y)))
   ([x y & z]
-   (and (char-equals-ignore-case x y)
-        (apply char-equals-ignore-case y z))))
+   (and (char-equals-ignore-case? x y)
+        (apply char-equals-ignore-case? y z))))

 (defn- trim-right
   "Trims all duplicated allele sequences from right. If reached the start,
@@ -90,7 +90,7 @@
                   regs)
         allele-seqs (map #(concat (cstr/reverse %) ref-seqs) alleles)
         matched-length (->> allele-seqs
-                            (apply map char-equals-ignore-case)
+                            (apply map char-equals-ignore-case?)
                             (take-while true?)
                             count
                             long
@@ -121,8 +121,7 @@
   [{:keys [ref alt] :as v}]
   (let [alleles (cons ref alt)
         n-trim-left (->> alleles
-                         (map cstr/upper-case)
-                         (apply map =)
+                         (apply map char-equals-ignore-case?)
                          (take-while true?)
                          count)
         min-len (long (apply min (map count alleles)))


when-let is better here

when-let is better here

--- src/cljs/asciinema_player/view.cljs
+++ src/cljs/asciinema_player/view.cljs
@@ -131,12 +131,11 @@
 (defn player-style [] {})

 (defn handle-event [f events dom-event]
-  (if-let [[event-name & _ :as event] (f dom-event)]
-    (do
-      (.preventDefault dom-event)
-      (if (= event-name :toggle-fullscreen) ; has to be processed synchronously
-        (fullscreen/toggle (.-currentTarget dom-event))
-        (go (>! events event))))))
+  (when-let [[event-name & _ :as event] (f dom-event)]
+    (.preventDefault dom-event)
+    (if (= event-name :toggle-fullscreen) ; has to be processed synchronously
+      (fullscreen/toggle (.-currentTarget dom-event))
+      (go (>! events event)))))

 (defn map-key-press [dom-event]
   (case (.-key dom-event)


Need doall to force eval of seq with ratoms

--- src/cljs/cglossa/search_inputs.cljs
+++ src/cljs/cglossa/search_inputs.cljs
@@ -92,11 +92,14 @@
       [search-button multilingual?]
       (when multilingual? [language-add-button])]

-     (for [index (range (count @search-queries))]
-       (let [query-cursor (cursor [index] search-queries)
-             selected-language (-> @query-cursor :query :lang)]
-         (when multilingual? [language-select languages selected-language])
-         [simple query-cursor multilingual?]))]))
+     ; Now create a cursor into the search-queries ratom for each search expression
+     ; and display a row of search inputs for each of them. The doall call is needed
+     ; because ratoms cannot be derefed inside lazy seqs.
+     (doall (for [index (range (count @search-queries))]
+              (let [query-cursor (cursor [index] search-queries)
+                    selected-language (-> @query-cursor :query :lang)]
+                (when multilingual? [language-select languages selected-language])
+                [simple query-cursor multilingual?])))]))

 (def components {:cwb        cwb-search-inputs
-                 :cwb-speech (fn [] [:div "CWB-SPEECHE"])})
+                 :cwb-speech (fn [] [:div "CWB-SPEECH"])})


super-aggregation-fn is optional

super-aggregation-fn is optional

--- src/cljs/onyx_cheat_sheet/core.cljs
+++ src/cljs/onyx_cheat_sheet/core.cljs
@@ -285,7 +285,7 @@
                      :optional? false}
     :aggregation/super-aggregation-fn {:doc "Fn (state-1, state-2, window) to combine two states in the case of two windows being merged, e.g. session windows."
                                        :type :function
-                                       :optional? false}
+                                       :optional? true}
     :aggregation/apply-state-update {:doc "Fn (state, entry) to apply state machine update entry to a state."
                                      :type :function
                                      :optional? false}}


Improve formatting

Improve formatting

--- src/clojure/paredit_widget/core.clj
+++ src/clojure/paredit_widget/core.clj
@@ -6,7 +6,7 @@
             [seesaw.core :as s])
   (:import [java.awt.event InputMethodListener KeyEvent KeyListener]))

-(defn exec-command
+(defn exec-command!
   [cmd widget buffer]
   (let [old-parse-tree (paredit.parser/buffer-parse-tree @buffer nil)
         old-text (paredit.loc-utils/node-text old-parse-tree)
@@ -24,7 +24,7 @@
                            :length (- (.getSelectionEnd widget)
                                       (.getSelectionStart widget))})))

-(defn insert-result
+(defn insert-result!
   [w pe]
   (dorun
     (map #(if (= 0 (:length %))
@@ -60,8 +60,8 @@
    [nil "{"] :paredit-open-curly
    [nil "}"] :paredit-close-curly
    [nil "\b"] :paredit-backward-delete
-   [nil "\""] :paredit-doublequote
    [nil "DEL"] :paredit-forward-delete
+   [nil "\""] :paredit-doublequote ;; \"
    ; ["C" "K"] :paredit-kill
    ["M" "("] :paredit-wrap-round
    ; ["M" ")"] :paredit-close-round-and-newline
@@ -82,20 +82,18 @@
    ["M" "{"] :paredit-open-curly
    ["M" "}"] :paredit-close-curly})

-(defn exec-paredit
+(def ^:const special-chars
+  #{"(" ")" "[" "]" "{" "}" "\""}) ;; \"
+
+(defn exec-paredit!
   [k w buffer enable-default? enable-advanced?]
   (when-let [cmd (or (and enable-default?
                           (default-keymap k))
                      (and @enable-advanced?
                           (or (advanced-keymap k)
                               (foreign-keymap k))))]
-    (let [result (exec-command cmd w buffer)]
-      (insert-result w result))
+    (insert-result! w (exec-command! cmd w buffer))
     cmd))
-
-(defn convert-input-method-event
-  [event]
-  ["M" (os-x-charmap (str (.first (.getText event))))])

 (defn convert-key-event
   [event]
@@ -115,22 +113,24 @@
   (reify KeyListener
     (keyReleased [this e] nil)
     (keyTyped [this e]
-      (when (and @enable-advanced?
-                 (get #{"(" ")" "[" "]" "{" "}" "\""}
-                      (str (.getKeyChar e))))
+      (when (and @enable-advanced? (special-chars (str (.getKeyChar e))))
         (.consume e)))
     (keyPressed [this e]
       (when-not (.isConsumed e)
         (let [k (convert-key-event e)
-              p (exec-paredit k w buffer enable-default? enable-advanced?)]
+              p (exec-paredit! k w buffer enable-default? enable-advanced?)]
           (when p (.consume e)))))))
+
+(defn convert-input-method-event
+  [event]
+  ["M" (os-x-charmap (str (.first (.getText event))))])

 (defn input-method-event-handler
   [w buffer enable-default? enable-advanced?]
   (reify InputMethodListener
     (inputMethodTextChanged [this e]
       (let [k (convert-input-method-event e)
-            p (exec-paredit k w buffer enable-default? enable-advanced?)]
+            p (exec-paredit! k w buffer enable-default? enable-advanced?)]
         (when p (.consume e))))))

 (defn init-paredit!


bugfix offsets

bugfix offsets

--- src/clojure/paredit_widget/core.clj
+++ src/clojure/paredit_widget/core.clj
@@ -80,7 +80,7 @@
 (defn reformat-all-forms [s]
   (let [rvec (map (fn [[offs p]]
                     (let [len (v/length p)]
-                      (vector (- offs len) len (with-out-str (clojure.pprint/pprint (read-string (v/text p)))))))
+                      (vector (- offs len) len (.trim (with-out-str (clojure.pprint/pprint (read-string (v/text p))))))))
                   (filter (fn [me] (= :list (v/tag (val me)))) (v/offsets (sexp-dup s))))
           ;_ (println "rvec: " rvec)
           first-offset (first (first rvec))
@@ -90,12 +90,13 @@
           rlist (partition 2 1 rvec)
           ;_ (println "rlist: " rlist)
           sb (StringBuffer. s)
+          first-diff (- (.length first-s) first-len)
         ]
           ; replace first form
-          (.replace sb first-offset (+ first-offset first-len) first-s)
+          (.replace sb (+ first-offset first-diff) (+ first-offset first-len) first-s)

           ; replace from 2nd to last form
-          (loop [offsum 0
+          (loop [diff-offset (- (.length first-s) first-len)
                  rl rlist]
             (if (empty? rl)
               (.toString sb)
@@ -103,14 +104,14 @@
                     rb (second (first rl))
                     ;_ (println "ra: " ra)
                     ;_ (println "rb: " rb)
-                    diff-a (- (.length (last ra)) (second ra))
-                    offset-b (first rb)
-                    len-b (second rb)
-                    off-next (+ diff-a offsum offset-b)]
+                    diff-offset-next (- (.length (last ra)) (second ra))
+                    diff-sum (+ diff-offset diff-offset-next)
+                    offset-b (+ (first rb) diff-sum)
+                    len-b (second rb)]

                       ; replace next form
-                      (.replace sb offset-b (+ off-next len-b) (last rb))
-                      (recur (+ diff-a offsum) (rest rl)))))))
+                      (.replace sb offset-b (+ offset-b len-b) (last rb))
+                      (recur diff-sum (rest rl)))))))

 (def formatting-keymap
   {["M" "f"] :fmt-pprint})


Fixes bug in when validating exported file

--- reports/src/reports/scheduler.clj
+++ reports/src/reports/scheduler.clj
@@ -14,7 +14,7 @@
 (defn- valid-report? [report-path]
   "Returns if a File is a valid one (exists and non zero length)"
   (if (and (.exists ^File report-path)
-           (> 0 (.length ^File report-path)))
+           (> (.length ^File report-path) 0))
     true false))

 (defn- get-path [report-file]


fix tests

fix tests

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -125,19 +125,20 @@
               (if (:show-all-commits build-data)
                 [:i.fa.fa-caret-up]
                 [:i.fa.fa-caret-down])])]
-          [:div.build-commits-list
-           (if-not (seq (:all_commit_details build))
-             (om/build commit-line {:build build
-                                    :subject (:subject build)
-                                    :body (:body build)
-                                    :commit_url (build-model/github-commit-url build)
-                                    :commit (:vcs_revision build)})
-             (list
-              (om/build-all commit-line (take 3 (map #(assoc % :build build)
-                                                     (:all_commit_details build))))
-              (when (:show-all-commits build-data)
-                (om/build-all commit-line (drop 3 (map #(assoc % :build build)
-                                                       (:all_commit_details build)))))))]])))))
+          (when (:subject build)
+            [:div.build-commits-list
+             (if-not (seq (:all_commit_details build))
+               (om/build commit-line {:build build
+                                      :subject (:subject build)
+                                      :body (:body build)
+                                      :commit_url (build-model/github-commit-url build)
+                                      :commit (:vcs_revision build)})
+               (list
+                (om/build-all commit-line (take 3 (map #(assoc % :build build)
+                                                       (:all_commit_details build))))
+                (when (:show-all-commits build-data)
+                  (om/build-all commit-line (drop 3 (map #(assoc % :build build)
+                                                         (:all_commit_details build)))))))])])))))

 (defn ssh-ad [build owner]
   (let [build-id (build-model/id build)
@@ -325,10 +326,9 @@
          [:div.sub-head
           [:div.sub-head-top
            [:ul.nav.nav-tabs
-            (when (:subject build)
-              [:li {:class (when (= :commits selected-tab) "active")}
-               [:a {:on-click #(raise! owner [:build-header-tab-clicked {:tab :commits}])}
-                "Commit Log"]])
+            [:li {:class (when (= :commits selected-tab) "active")}
+             [:a {:on-click #(raise! owner [:build-header-tab-clicked {:tab :commits}])}
+              "Commit Log"]]

             [:li {:class (when (= :config selected-tab) "active")}
              [:a {:on-click #(raise! owner [:build-header-tab-clicked {:tab :config}])}


Simplified the piece to better serve as an example to newcomers.

--- src/overtunes/songs/row_row_row_your_boat.clj
+++ src/overtunes/songs/row_row_row_your_boat.clj
@@ -1,34 +1,39 @@
 (ns overtunes.songs.row-row-row-your-boat
   (:use
-    [overtone.live :only [at now]]
-    [overtone.inst.sampled-piano :only [sampled-piano] :rename {sampled-piano piano}]))
+    [overtone.live]))

-(defn sum-n [series n] (reduce + (take n series)))
-(def major-scale (partial sum-n (cycle [2 2 1 2 2 2 1])))
-(def g-major #(-> % major-scale (+ 67)))
+(definst harpsichord [freq 440]
+  (let [duration 1]
+    (*
+      (line:kr 1 1 duration FREE)
+      (pluck (* (white-noise) (env-gen (perc 0.001 5) :action FREE))
+             1 1 (/ 1 freq) (* duration 2) 0.25))))

-(defn bpm [per-minute] #(-> % (/ per-minute) (* 60) (* 1000)))
-(defn after [timing beats] #(-> % (+ beats) timing))
-(defn syncopate [timing durations] #(->> % (sum-n durations) timing))
-(defn from [timing start] #(-> % timing (+ start)))
+(def notes
+  (let [pitches
+         [67 67 67 69 71              ; Row, row, row your boat,
+          71 69 71 72 74              ; Gently down the stream,
+          79 79 79 74 74 74 71 71 71  ; Merrily, merrily, merrily, merrily,
+          67 67 67 74 72 71 69 67]    ; Life is but a dream!
+        durations
+         [1 1 2/3 1/3 1
+          2/3 1/3 2/3 1/3 2
+          1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3
+          2/3 1/3 2/3 1/3 2]
+        times (reductions + 0 durations)]
+    (map vector timings pitches)))

-(def pitches [0 0 0 1 2, 2 1 2 3 4, 7 7 7 4 4 4 2 2 2 0 0 0, 4 3 2 1 0])
-(def durations [1 1 2/3 1/3 1, 2/3 1/3 2/3 1/3 2, 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3, 2/3 1/3 2/3 1/3 2])

-(defn melody# [timing notes]
-  (let [note# #(at (timing %1) (piano (g-major %2)))]
-    (dorun (map-indexed note# notes))))
+(defn play [metro notes]
+  (let [play-note (fn [[beat midi]] (at (metro beat) (-> midi midi->hz harpsichord)))]
+    (dorun (map play-note notes))))

-(defn play# []
-  (let [timing (-> (bpm 150) (from (now)))
-        rhythm-from #(syncopate (after timing %) durations)]
-    (melody# (rhythm-from 0)  pitches)
-    (melody# (rhythm-from 16) pitches)
-    (melody# (rhythm-from 20) pitches)
-    (melody# (rhythm-from 24) pitches)
-    (melody# (rhythm-from 28) pitches)
-    ))
+(defn play-round [metro notes]
+  (let [after (fn [beats metro] (comp metro #(+ % beats)))]
+    (play metro notes)
+    (play (after 4 metro) notes)
+    (play (after 8 metro) notes)
+    (play (after 16 metro) notes)))

-(play#)
-
-(piano 77)
+;(play (metronome 120) notes)
+;(play-round (metronome 120) notes)


Better errors reading sparql results.

Better errors reading sparql results.

Surprisingly it looks like hasNext can raise an exception too!

--- src/rdf-repository/grafter/rdf/repository.clj
+++ src/rdf-repository/grafter/rdf/repository.clj
@@ -286,16 +286,19 @@
   ([^Query prepared-query converter-f]
      (let [^CloseableIteration results (.evaluate prepared-query)
            run-query (fn pull-query []
-                       (if (.hasNext results)
-                         (let [current-result (try
-                                                (converter-f (.next results))
-                                                (catch Exception e
-                                                  (.close results)
-                                                  (throw (ex-info "Error reading results" {:prepared-query prepared-query} e))))]
-                           (lazy-cat
-                            [current-result]
-                            (pull-query)))
-                         (.close results)))]
+                       (try
+                         (if (.hasNext results)
+                           (let [current-result (try
+                                                  (converter-f (.next results))
+                                                  (catch Exception e
+                                                    (.close results)
+                                                    (throw (ex-info "Error reading results" {:prepared-query prepared-query} e))))]
+                             (lazy-cat
+                              [current-result]
+                              (pull-query)))
+                           (.close results))
+                         (catch Exception e
+                           (throw (ex-info "Error waiting on results" {:prepared-query prepared-query} e)))))]
        (run-query))))

 (defprotocol IQueryEvaluator


GAWB-1622 : fixing codemirror elsewhere

GAWB-1622
: fixing codemirror elsewhere

--- src/cljs/main/broadfcui/common/codemirror.cljs
+++ src/cljs/main/broadfcui/common/codemirror.cljs
@@ -71,6 +71,7 @@
                        #js{:mode "wdl" :lineNumbers (:line-numbers? props) :readOnly (:read-only? props)})))
    :component-will-receive-props
    (fn [{:keys [refs props next-props locals]}]
-     (-> (@locals :code-mirror-component)
-         (js-invoke "getDoc")
-         (js-invoke "setValue" (:text next-props))))})+     (when (:read-only? props)
+       (-> (@locals :code-mirror-component)
+           (js-invoke "getDoc")
+           (js-invoke "setValue" (:text next-props)))))})


Remove build-statement- method

Remove build-statement- method

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -244,18 +244,6 @@
   [^Cluster cluster]
   (.close cluster))

-(defn ^:private build-statement-
-  "Builds a Prepare or Simple statement out of given params.
-
-   Arities:
-     * query + args - for building prepared statements, `query` is a string with placeholders, `values`
-       are values to be bound to the built statement for execution.
-     * query - for building simple, not prepared statements."
-  ([^PreparedStatement query values]
-     (set-statement-options- (.bind query (to-array values))))
-  ([^String string-query]
-     (set-statement-options- (SimpleStatement. string-query))))
-
 (defn bind
   "Binds prepared statement to values, for example:


bump boot-cljs

bump boot-cljs

--- build.boot
+++ build.boot
@@ -1,7 +1,7 @@
 (set-env!
  :source-paths    #{"src"}
  :resource-paths  #{"html" "conf"}
- :dependencies    '[[adzerk/boot-cljs   "0.0-2760-0"]
+ :dependencies    '[[adzerk/boot-cljs   "0.0-2814-1"]
                     [pandeiro/boot-http "0.6.2"]])

 (require


Add external deps as test dependencies for testing

--- build.boot
+++ build.boot
@@ -1,13 +1,15 @@
 (set-env!
   :source-paths #{"src"}
   :resource-paths #{"resources"}
-  :dependencies '[[org.clojure/clojure "1.6.0"]
+  :dependencies '[[boot/core "2.1.2" :scope "provided"]
                   [adzerk/bootlaces "0.1.9" :scope "test"]
                   [jeluard/boot-notify "0.1.2" :scope "test"]
-
-                  [clj-time "0.9.0" :scope "provided"]
-                  [markdown-clj "0.9.40" :scope "provoded"]
-                  [endophile "0.1.2" :scope "provided"]])
+                  [clj-time "0.9.0" :scope "test"]
+                  [markdown-clj "0.9.40" :scope "test"]
+                  [endophile "0.1.2" :scope "test"]
+                  [time-to-read "0.1.0" :scope "test"]
+                  [sitemap "0.2.4" :scope "test"]
+                  [clj-rss "0.1.9" :scope "test"]])

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


As-pure-as-possible clojurescript compilation isolation

--- build.boot
+++ build.boot
@@ -1,4 +1,5 @@
 (require '[boot.pod :as pod])
+(require '[clojure.java.io :as io])

 (deftask server
   "Develop the server backend"
@@ -53,8 +54,8 @@
                             [org.slf4j/jul-to-slf4j "1.7.13"]
                             [org.slf4j/log4j-over-slf4j "1.7.13"]
                             [ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
-                            [com.cemerick/piggieback "0.2.1" :scope "test"]
-                            [weasel "0.7.0" :scope "test"]])
+                            [com.cemerick/piggieback "0.2.1" :scope "test"] ;; Needed for start-repl in cljs repl
+                            [weasel "0.7.0" :scope "test"]]);; Websocket Server

   (require '[adzerk.boot-cljs :refer [cljs]]
            '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
@@ -67,21 +68,40 @@
   (let [reload (resolve 'adzerk.boot-reload/reload)
         cljs-repl (resolve 'adzerk.boot-cljs-repl/cljs-repl)
         cljs (resolve 'adzerk.boot-cljs/cljs)
+        assert-clojure-version! (resolve 'adzerk.boot-cljs/assert-clojure-version!)
         less (resolve 'deraen.boot-less/less)
-        sass (resolve 'mathias.boot-sassc/sass)]
+        sass (resolve 'mathias.boot-sassc/sass)

-    ;; Add dependencies for our pod
+        ;; Direct Clojurescript Code dependencies
+        cljs-deps '[[org.omcljs/om "1.0.0-alpha28"]
+                    [org.clojure/core.async "0.2.374"]
+                    [org.clojure/clojurescript "1.7.170"]]
+
+        remove-unneeded-deps
+        (fn [deps]
+          ;; # Reasons to keep each:
+          ;; - adzerk/boot-cljs     The impl stuff needs this as a dep
+          ;; - adzerk/boot-reload   Reloading requires that the cljs namespace of this is pulled in
+          ;; - weasel               Websocket client
+          (filter (comp #{'weasel 'adzerk/boot-cljs 'adzerk/boot-reload} first) deps))
+
+        add-cljs-deps
+        (fn [deps]
+          (concat deps @(resolve 'adzerk.boot-cljs/deps) cljs-deps))]
+
     (alter-var-root (resolve 'adzerk.boot-cljs/deps)
-      (fn [old-deps]
-        (delay
-          (concat
-            ;; Suppress warnings from boot cljs about clojurescript.
-            ;; We resolve dependencies later. We might want to re-add the
-            ;; warning if nobody adds clojurescript back in though!
-            (with-redefs [boot.util/*verbosity* (atom 0)] @old-deps)
-            '[[org.omcljs/om "1.0.0-alpha28"]
-              [org.clojure/core.async "0.2.374"]
-              [org.clojure/clojurescript "1.7.170"]]))))
+       (fn [deps]
+         ;; Suppress warnings from boot cljs about clojurescript.
+         ;; We resolve dependencies later. We might want to re-add the
+         ;; warning if nobody adds clojurescript back in though!
+         (with-redefs [boot.util/*verbosity* (atom 0)] @deps)))
+
+    (intern 'adzerk.boot-cljs 'new-pod!
+      (fn new-pod! [tmp-src]
+        (let [env (-> (get-env)
+                      (update :dependencies (comp vec add-cljs-deps remove-unneeded-deps))
+                      (update :directories conj (.getPath tmp-src)))]
+          (future (doto (pod/make-pod env) 'adzerk.boot-cljs/assert-clojure-version!)))))

     (comp
      (watch)


Add boot test-once task for running tests once

--- build.boot
+++ build.boot
@@ -81,6 +81,14 @@
   (merge-env! :source-paths #{"src/test"})
   identity)

+(deftask test-once
+  []
+  (comp
+    (testing)
+    (test-cljs)
+    (test)
+    (exit!)))
+
 (deftask test-auto
   []
   (comp


Bump to clojurescript 1.9.293

Bump to clojurescript 1.9.293

--- build.boot
+++ build.boot
@@ -10,7 +10,7 @@
   :license {"MIT" "https://en.wikipedia.org/MIT_License"}
   :dependencies '[[org.clojure/clojure "1.8.0"           :scope "provided"]
                   [com.stuartsierra/component "0.3.1"]
-                  [org.clojure/clojurescript "1.9.229"          :scope "test"]
+                  [org.clojure/clojurescript "1.9.293"          :scope "test"]
                   [adzerk/boot-cljs "1.7.228-1"                 :scope "test"]
                   [adzerk/boot-test "1.1.0"                     :scope "test"]
                   [crisptrutski/boot-cljs-test "0.2.2-SNAPSHOT" :scope "test"]])


remove no-longer-existent `-a` argument from dev task docstring

--- build.boot
+++ build.boot
@@ -57,11 +57,11 @@
 (deftask dev
   "Runs the Alda client for development.

-   To test changes to the Alda client, run `boot dev -a client -x \"args here\"`.
+   To test changes to the Alda client, run `boot dev -x \"args here\"`.

    For example:

-      boot dev -a client -x \"play --file /path/to/file.alda\"
+      boot dev -x \"play --file /path/to/file.alda\"

    The arguments must be a single command-line string to be passed to the
    command-line client as if entering them on the command line. The example


Update content-pre-wrap to content-task

Update content-pre-wrap to content-task

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

 (deftask header-links
   []
-  (content-pre-wrap
+  (content-task
    {:task-name "header-links"
     :render-form-fn (fn [data] `(io.perun.site/add-header-link-content ~data))
     :paths-fn #(content-paths % {:filterer guide? :extensions [".html"]})


Update pom description

Update pom description

--- build.boot
+++ build.boot
@@ -51,9 +51,9 @@
 (task-options!
  pom {:project        'frankiesardo/auto-parcel
       :version        +version+
-      :description    "Sandbox for experiments"
-      :url            "https://github.com/frankiesardo/lab"
-      :scm            {:url "https://github.com/frankiesardo/lab"}
+      :description    "AutoValue extensions that supports Parcelable generation"
+      :url            "https://github.com/frankiesardo/auto-parcel"
+      :scm            {:url "https://github.com/frankiesardo/auto-parcel"}
       :license        {"Eclipse Public License" "http://www.eclipse.org/legal/epl-v10.html"}})

 (deftask build []


This thang now mostly works?

This thang now mostly works?

--- src/doctopus/storage/storage_impls/temp_fs.clj
+++ src/doctopus/storage/storage_impls/temp_fs.clj
@@ -1,12 +1,13 @@
 (ns doctopus.storage-impls.temp-fs
-  (:require [doctopus.files :as files]
+  (:require [clojure.string :as str]
+            [doctopus.files :as files]
             [doctopus.files.storage-impls :refer :all]
             [me.raynes.fs :as fs])
   (:import [doctopus.files.storage-impls.BackendImplementation]))

 ;; The root of the temp filesystem. Each Thing will store its stuff
 ;; within this directory
-(def temp-dir (atom (fs/temp-dir "doctopus-temp")))
+(def temp-dir (atom (fs/temp-dir  "doctopus-temp")))

 (defn regenerate-temp-dir
   "Generates a new temp dir"
@@ -26,7 +27,9 @@
   becomes the primary subdirectory in the filesystem."
   [key rel-path data]
   (binding [fs/*cwd* @temp-dir]
-    (let [file-handle (fs/file key rel-path)]
+    (let [assure-relativity #(if (re-find #"^/" %) (subs % 1) %)
+          file-handle (fs/file key (assure-relativity rel-path))]
+      (fs/mkdirs (fs/parent file-handle))
       (spit file-handle data))))

 (defn save-fn
@@ -39,5 +42,7 @@
   1. We load html
   2. We wrap that html in a function that returns itself, so we can Bidi"
   [key]
-  (let [rel-path-html-pairs (files/read-html key)]
-    (into [] (map (fn [[rel-path html]] [rel-path (fn [_] html)]) rel-path-html-pairs))))
+  (binding [fs/*cwd* @temp-dir]
+    (let [dir (fs/file key)
+          rel-path-html-pairs (files/read-html dir)]
+      (into [] (map (fn [[rel-path html]] [rel-path (fn [_] html)]) rel-path-html-pairs)))))


add remove-dep! for removing specific task deps

--- src/cake/core.clj
+++ src/cake/core.clj
@@ -87,6 +87,9 @@

 (defmacro undeftask [& names]
   `(swap! tasks dissoc ~@(map #(list 'quote %) names)))
+
+(defmacro remove-dep! [task dep]
+  `(swap! tasks update-in ['~task :deps] disj '~dep))

 (defn run-task
   "Execute the specified task after executing all prerequisite tasks."


rethrow dependency errors so deps don't get cached empty

--- src/cake/deps.clj
+++ src/cake/deps.clj
@@ -54,7 +54,7 @@
            (println "\nUnable to resolve the following dependencies:\n")
            (doall (map println (filter (partial re-matches #"\d+\) .*")
                                        (split (.getMessage e) #"\n"))))
-           (println)))))
+           (throw e)))))

 (defn deps-cache []
   (file (first (:library-path *project*)) "deps.cache"))


remove extra newline in generate-file nil

--- src/cake/task.clj
+++ src/cake/task.clj
@@ -130,8 +130,7 @@
   [forms]
   (with-outfile
     (doseq [form forms]
-      (println form)
-      (println))))
+      (println form))))

 (defmethod generate-file :clj
   [forms]


fix: count events without join for replay

--- src/main/clojure/pdok/featured/persistence.clj
+++ src/main/clojure/pdok/featured/persistence.clj
@@ -163,10 +163,8 @@

 (defn jdbc-count-records [{:keys [db dataset]} collections]
   (let [query (str "SELECT count(*) as cnt FROM "
-                   (qualified-feature-stream dataset) " fs JOIN"
-                   (qualified-features dataset) " f ON fs.collection = f.collection AND
-                    fs.feature_id = f.feature_id"
-                   (when (seq collections) (str " AND fs.collection in ("
+                   (qualified-feature-stream dataset) " fs"
+                   (when (seq collections) (str " WHERE fs.collection in ("
                                                 (clojure.string/join "," (repeat (count collections) "?"))
                                                 ")")))
         result (j/with-db-connection [c db]


Add alias for visit

Add alias for visit

I think "visit" is a little too ASM-specific. Provide a more general name.

--- src/insn/core.clj
+++ src/insn/core.clj
@@ -207,6 +207,10 @@
       (.visitMaxs -1 -1)
       .visitEnd)))

+(def ^{:arglists '([t])
+       :doc "Alias of `visit`."}
+  generate visit)
+
 ;;;

 (defprotocol Loader


show ans even if user know the answer

show ans even if user know the answer

--- src/juzi/core.clj
+++ src/juzi/core.clj
@@ -32,7 +32,9 @@
           (flush)
           (let [i (.readCharacter cr)]
             (if (= \y (char i))
-              (do (clear-screen)
+              (do (println "ans:" zh)
+                  (.readCharacter cr)
+                  (clear-screen)
                   (recur (s/mark-passed s id)))
               (do (println "ans:" zh)
                   (.readCharacter cr)


Whitespace changes for readability

Whitespace changes for readability

--- src/uruk/core.clj
+++ src/uruk/core.clj
@@ -31,10 +31,9 @@
    :version-patch (Version/getVersionPatch)})

 (def ->doc-format
-  "Mapping of keywords to allowed document formats. Used at insertion
-  time.
+  "Mapping of keywords to allowed document formats. Used at insertion time.
   See https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/DocumentFormat.html"
-  {:xml DocumentFormat/XML
+  {:xml    DocumentFormat/XML
    :json   DocumentFormat/JSON
    :text   DocumentFormat/TEXT
    :none   DocumentFormat/NONE
@@ -58,9 +57,9 @@
 (def ->transaction-mode
   "Mapping of keywords to valid Session transaction modes. See
   https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/Session.TransactionMode.html"
-  {:auto Session$TransactionMode/AUTO
-   :query Session$TransactionMode/QUERY
-   :update Session$TransactionMode/UPDATE
+  {:auto               Session$TransactionMode/AUTO
+   :query              Session$TransactionMode/QUERY
+   :update             Session$TransactionMode/UPDATE
    :update-auto-commit Session$TransactionMode/UPDATE_AUTO_COMMIT})

@@ -80,8 +79,7 @@
       (clojure.edn/read-string s))))

 (defn java-json->clj-json
-  "Given a MarkLogic XCC JSON object, returns a Clojure representation
-  of its JSON data."
+  "Given a MarkLogic XCC JSON object, returns a Clojure representation of its JSON data."
   [java-json]
   (json/read-str (.toString (.asJsonNode java-json))))

@@ -126,7 +124,7 @@

   `:xcc-type` maps to the corresponding
   com.marklogic.xcc.types.ValueType field"
-  {:attribute {;; FIXME Causes "Unhandled java.lang.InternalError | Unrecognized valueType: attribute()" if passed as variable :type
+  {:attribute {;; FIXME Causes "Unhandled java.lang.InternalError | Unrecognized valueType: attribute()" if passed as variable :type
                :ml->clj #(.asString %)
                :clj->xdm identity ;; doesn't seem to be implemented by ValueFactory: "java.lang.InternalError Unrecognized valueType: attribute()"
                :xml-name "attribute()"
@@ -472,7 +470,7 @@
    :request-time-limit (.getRequestTimeLimit req-opts)
    :result-buffer-size (.getResultBufferSize req-opts)
    :timeout-millis (.getTimeoutMillis req-opts)
-   :timezone (.getTimeZone req-opts)})
+   :timezone (.getTimeZone req-opts)})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -738,7 +736,7 @@
    :current-server-time (.getCurrentServerPointInTime session)
    :content-source (.getContentSource session)
    :xaresource (.getXAResource session)
-   :user-object (.getUserObject session)
+   :user-object (.getUserObject session)
    :user-credentials (user-credentials->map (.getUserCredentials session))
    :closed? (.isClosed session) ;; TODO maybe create (defn closed? [session] ...) ? Except it wouldn't be specific to Session in this ns, and ResultSequence also has isClosed, so it's ambiguous.
    :cached-transaction-timeout (.getCachedTxnTimeout session)
@@ -910,7 +908,7 @@
   Variables may be passed as a map of Strings or with String names
   corresponding to maps describing the variable using mandatory key
   `:value` and optional keys `:namespace` and `:type`.`
-
+
   See https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/ModuleSpawn.html"
   ([session module]
    (spawn-module session module {}))


New endpoint - add word into Glossary

New endpoint - add word into Glossary

--- src/zg/server.clj
+++ src/zg/server.clj
@@ -397,8 +397,9 @@
             "/deleted-words-in-glossary"     (process-deleted-words     request title emender-page :glossary)
             "/add-word-to-blacklist"    (process-add-word      request title emender-page :blacklist)
             ;"/find-words"       (process-find-words    request)
-            "/add-words-to-whitelist"   (process-add-words     request title emender-page :whitelist)
-            "/add-word-to-atomic-typos" (process-add-word     request title emender-page :atomic-typos)
+            "/add-words-to-whitelist"   (process-add-words   request title emender-page :whitelist)
+            "/add-word-to-atomic-typos" (process-add-word    request title emender-page :atomic-typos)
+            "/add-word-to-glossary"     (process-add-word    hrequest title emender-page :glossary)
             "/users-whitelist"        (process-user-list     request title :whitelist)
             "/users-blacklist"        (process-user-list     request title :blacklist)
             "/users-atomic-typos"     (process-user-list     request title :atomic-typos)


add middleware for handling exceptions

add middleware for handling exceptions

--- src/pc/server.clj
+++ src/pc/server.clj
@@ -127,6 +127,19 @@
                                                 :query (:query-string req)}))}
        :body ""})))

+(defn exception-middleware [handler]
+  (fn [req]
+    (try+
+      (handler req)
+      (catch :status t
+        (log/error t)
+        {:status (:status t)
+         :body (:public-message t)})
+      (catch Object e
+        (log/error e)
+        {:status 500
+         :body "Sorry, something completely unexpected happened!"}))))
+
 (defn handler [sente-state]
   (->
    (app sente-state)
@@ -138,6 +151,7 @@
                                  :max-age (* 60 60 24 365)
                                  :secure (profile/force-ssl?)}})
    (ssl-middleware)
+   (exception-middleware)
    (logging-middleware)
    (site)))


Whitespace

Whitespace

--- src/test/clojure/clojure/test/check/test.cljc
+++ src/test/clojure/clojure/test/check/test.cljc
@@ -53,14 +53,12 @@
            (is (let [p (prop/for-all* [gen/int gen/int gen/int] passes-monoid-properties)]
                  (:result
                    (tc/quick-check 1000 p)))))
+  ;; NOTE: no ratios in ClojureScript - David
   #?(:clj
     (testing "with ratios as well"
            (is (let [p (prop/for-all* [gen/ratio gen/ratio gen/ratio] passes-monoid-properties)]
                  (:result
-                   (tc/quick-check 1000 p)))))
-
-    ;; NOTE: no ratios in ClojureScript - David
-    ))
+                   (tc/quick-check 1000 p)))))))

 ;; reverse
 ;; ---------------------------------------------------------------------------
@@ -295,8 +293,7 @@

     (testing "vector" (t (gen/vector gen/int) vector?))
     (testing "list"   (t (gen/list gen/int)   list?))
-    (testing "map"    (t (gen/map gen/int gen/int) map?))
-    ))
+    (testing "map"    (t (gen/map gen/int gen/int) map?))))

 ;; Distinct collections
 ;; --------------------------------------------------------------------------


Revert "Move name editor outside of grid properties."

This reverts commit 4b8cf6a3a58253368ee60feab8cc0024dfa5224e.

--- sonic-jam/src/sonic_jam/core.cljs
+++ sonic-jam/src/sonic_jam/core.cljs
@@ -714,17 +714,17 @@
           :init (dom/table nil
                            (dom/tbody nil
                                       (dom/tr nil
-                                              (dom/td nil (om/build name-editor inputs))
-                                              (dom/td nil " ")
+                                              (dom/td nil (str name " "))
                                               (dom/td #js {:onClick #(transition {:state :open})
                                                            :style #js {:color (:link theme)}}
                                                       "{..}"))))
           :open (dom/table nil
                            (dom/tbody nil
                                       (dom/tr nil
+                                              (dom/td nil (closer "{"))
+                                              (dom/td nil " name: ")
                                               (dom/td nil (om/build name-editor inputs))
                                               (dom/td nil " ")
-                                              (dom/td nil (closer "{"))
                                               (dom/td nil " bpc: ")
                                               (dom/td nil (om/build bpc-editor inputs))
                                               (dom/td nil " ")


Extend example.

Extend example.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -19,14 +19,21 @@

 (deftest simple-documenation-example-test-1
   (let [in-vector [1.23 "FOO" 42 "bar" "baz"]
-        expected "{\"myFloat\":1.23,\"myStr\":\"foo\",\"myRatio\":0.42,\"myStr2\":\"barbaz\"}"
-        dsl-expression {:output-type :json-str
+        expected-clj-map {"myFloat" 1.23, "myStr" "foo", "myRatio" 0.42, "myStr2" "barbaz"}
+        expected-json-str "{\"myFloat\":1.23,\"myStr\":\"foo\",\"myRatio\":0.42,\"myStr2\":\"barbaz\"}"
+        expected-csv-str "1.23,\"foo\",0.42,\"barbaz\""
+        dsl-expression {:output-type :csv-str
                         :rules [['myFloat '(nth 0)]
                                 ['myStr '(clojure.string/lower-case (nth 1)) :string]
-                                ['myRatio '(float (/ (nth 2) 100.0))]
+                                ['myRatio '(/ (nth 2) 100.0)]
                                 ['myStr2 '(str (nth 3) (nth 4)) :string]]}
-        data-processing-fn (create-proc-fn dsl-expression)]
-    (is (= expected (str (data-processing-fn in-vector))))))
+        data-proc-fn-csv-str (create-proc-fn dsl-expression)
+        data-proc-fn-json-str (create-proc-fn (assoc dsl-expression :output-type :json-str))
+        data-proc-fn-clj-map (create-proc-fn (assoc dsl-expression :output-type :clj-map))
+        ]
+    (is (= expected-csv-str (str (data-proc-fn-csv-str in-vector))))
+    (is (= expected-json-str (str (data-proc-fn-json-str in-vector))))
+    (is (= expected-clj-map (data-proc-fn-clj-map in-vector)))))


Change ididupdate to will-update

Change ididupdate to will-update

--- src/discuss/components/bubbles.cljs
+++ src/discuss/components/bubbles.cljs
@@ -44,15 +44,15 @@

 (defn bubble-view [bubble]
   (reify
-    om/IDidUpdate
-    (did-update [_ _ _]
+    om/IWillUpdate
+    (will-update [_ _ _]
       (vlib/scroll-divs-to-bottom "bubbles")
       (convert-links-in-bubbles))
     om/IRender
     (render [_]
       (let [bubble-class (get-bubble-class bubble)]
-        (comment (println bubble)
-                 (println (:id bubble)))
+        (vlib/scroll-divs-to-bottom "bubbles")
+        (convert-links-in-bubbles)
         (dom/li #js {:className bubble-class}
                 (dom/div #js {:className "avatar"})
                 (dom/p #js {:className "messages"}
@@ -60,8 +60,8 @@

 (defn view []
   (reify
-    om/IDidUpdate
-    (did-update [_ _ _]
+    om/IWillUpdate
+    (will-update [_ _ _]
       (vlib/scroll-divs-to-bottom "bubbles"))
     om/IRender
     (render [_]


Minor refactoring.

Minor refactoring.

--- umm-spec-lib/src/cmr/umm_spec/iso_keywords.clj
+++ umm-spec-lib/src/cmr/umm_spec/iso_keywords.clj
@@ -131,9 +131,9 @@
          variable-level-2 :VariableLevel2
          variable-level-3 :VariableLevel3
          detailed-variable :DetailedVariable} science-keyword]
-    (str/join iso/keyword-separator (map #(or % nil-science-keyword-field)
-                                               [category topic term variable-level-1 variable-level-2
-                                                variable-level-3 detailed-variable]))))
+    (->> [category topic term variable-level-1 variable-level-2 variable-level-3 detailed-variable]
+         (map #(or % nil-science-keyword-field))
+         (str/join iso/keyword-separator))))

 (defn- generate-descriptive-keywords
   "Returns the content generator instructions for the given descriptive keywords."


Ability to close files

Ability to close files

Former-commit-id: c12b705551c92728a5803f1237a0aba5c17ee8d0

--- planck-cljs/src/planck/io.cljs
+++ planck-cljs/src/planck/io.cljs
@@ -38,13 +38,19 @@
       (as-file (.getPath u))
       (throw (js/Error. (str "Not a file: " u))))))

+(defprotocol IClosaeable
+  (-close [this]))
+
 (defprotocol IReader
   (-read [this] "Returns available characters as a string or nil of EOF."))

 (defrecord Reader [raw-read raw-close]
   IReader
   (-read [_]
-    (raw-read)))
+    (raw-read))
+  IClosaeable
+  (-close [_]
+    (raw-close)))

 (defrecord Writer [raw-write raw-flush]
   IWriter


CMR-7720: Updated granule_v2_facets_search_test for stac format

--- system-int-test/test/cmr/system_int_test/search/facets/granule_v2_facets_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/facets/granule_v2_facets_search_test.clj
@@ -127,7 +127,11 @@
           (let [url-extension (if (#{:umm-json :umm-json-results} format-key)
                                 (umm-format->extension fmt)
                                 (name fmt))
-                response (search/find-concepts-in-format fmt :granule {:include-facets "v2"}
+                facet-params {:include-facets "v2"}
+                params (if (= :stac fmt)
+                         (merge facet-params {:collection-concept-id "C1-PROV1"})
+                         facet-params)
+                response (search/find-concepts-in-format fmt :granule params
                                                          {:url-extension url-extension
                                                           :throw-exceptions false})]
             (is (= {:status 400


Add warming up to timing-utils

Add warming up to timing-utils

--- src/edu/berkeley/ai/util/timing.clj
+++ src/edu/berkeley/ai/util/timing.clj
@@ -139,6 +139,20 @@
 		   (do (kill-future pool# future#) :memout))))))))))

+;; When we're actually timing, we need to warmup first.
+
+(defmacro warm-up "Run expr until at least min-secs have elapsed, default 10."
+  ([expr] `(warm-up ~expr 10))
+  ([expr min-secs]
+     `(let [c# (counter-from 0)]
+	(time-limit (while true (timeout) (c#) ~expr) ~min-secs)
+	(dec (c#)))))
+
+(defmacro with-warm-up [expr min-secs time-macro & macro-args]
+  `(do (warm-up ~expr ~min-secs)
+       (~time-macro ~expr ~@macro-args)))
+
+
 (defn interrupt-all-threads []
   (doseq [#^Thread thread (.keySet (Thread/getAllStackTraces))]
     (.interrupt thread)))


remove bad param emission from defrecord

--- src/main/clojure/cljs/compiler.cljc
+++ src/main/clojure/cljs/compiler.cljc
@@ -993,11 +993,6 @@
     (emitln "")
     (emitln "/**")
     (emitln "* @constructor")
-    (doseq [fld fields]
-      (emitln "* @param {*} " fld))
-    (emitln "* @param {*=} __meta ")
-    (emitln "* @param {*=} __extmap")
-    (emitln "* @param {number|null} __hash")
     (emitln "*/")
     (emitln (munge t) " = (function (" (comma-sep fields) "){")
     (doseq [fld fields]


Bump cider-nrepl to 0.13.0

Bump cider-nrepl to 0.13.0

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,4 +1,4 @@
-{:user {:plugins [[cider/cider-nrepl "0.12.0"]
+{:user {:plugins [[cider/cider-nrepl "0.13.0"]

                   ;; Linters
                   [jonase/eastwood "0.2.3"]


Metrics on instance fetch rates. (#1206)

--- scheduler/src/cook/rest/api.clj
+++ scheduler/src/cook/rest/api.clj
@@ -987,43 +987,45 @@
 (defn fetch-instance-map
   "Converts the instance entity to a map representing the instance fields."
   [db instance]
-  (let [hostname (:instance/hostname instance)
-        task-id (:instance/task-id instance)
-        executor (:instance/executor instance)
-        sandbox-directory (:instance/sandbox-directory instance)
-        url-path (retrieve-url-path hostname task-id sandbox-directory)
-        start (:instance/start-time instance)
-        mesos-start (:instance/mesos-start-time instance)
-        end (:instance/end-time instance)
-        cancelled (:instance/cancelled instance)
-        reason (reason/instance-entity->reason-entity db instance)
-        exit-code (:instance/exit-code instance)
-        progress (:instance/progress instance)
-        progress-message (:instance/progress-message instance)
-        file-url (plugins/file-url file-plugin/plugin instance)]
-    (cond-> {:backfilled false ;; Backfill has been deprecated
-             :compute-cluster (fetch-compute-cluster-map db (:instance/compute-cluster instance))
-             :executor_id (:instance/executor-id instance)
-             :hostname hostname
-             :ports (vec (sort (:instance/ports instance)))
-             :preempted (:instance/preempted? instance false)
-             :slave_id (:instance/slave-id instance)
-             :status (name (:instance/status instance))
-             :task_id task-id}
-      executor (assoc :executor (name executor))
-      file-url (assoc :file_url file-url)
-      start (assoc :start_time (.getTime start))
-      mesos-start (assoc :mesos_start_time (.getTime mesos-start))
-      end (assoc :end_time (.getTime end))
-      cancelled (assoc :cancelled cancelled)
-      exit-code (assoc :exit_code exit-code)
-      url-path (assoc :output_url url-path)
-      reason (assoc :reason_code (:reason/code reason)
-                    :reason_string (:reason/string reason)
-                    :reason_mea_culpa (:reason/mea-culpa? reason))
-      progress (assoc :progress progress)
-      progress-message (assoc :progress_message progress-message)
-      sandbox-directory (assoc :sandbox_directory sandbox-directory))))
+  (timers/time!
+    (timers/timer ["cook-mesos" "internal" "fetch-instance-map"])
+    (let [hostname (:instance/hostname instance)
+          task-id (:instance/task-id instance)
+          executor (:instance/executor instance)
+          sandbox-directory (:instance/sandbox-directory instance)
+          url-path (retrieve-url-path hostname task-id sandbox-directory)
+          start (:instance/start-time instance)
+          mesos-start (:instance/mesos-start-time instance)
+          end (:instance/end-time instance)
+          cancelled (:instance/cancelled instance)
+          reason (reason/instance-entity->reason-entity db instance)
+          exit-code (:instance/exit-code instance)
+          progress (:instance/progress instance)
+          progress-message (:instance/progress-message instance)
+          file-url (plugins/file-url file-plugin/plugin instance)]
+      (cond-> {:backfilled false ;; Backfill has been deprecated
+               :compute-cluster (fetch-compute-cluster-map db (:instance/compute-cluster instance))
+               :executor_id (:instance/executor-id instance)
+               :hostname hostname
+               :ports (vec (sort (:instance/ports instance)))
+               :preempted (:instance/preempted? instance false)
+               :slave_id (:instance/slave-id instance)
+               :status (name (:instance/status instance))
+               :task_id task-id}
+              executor (assoc :executor (name executor))
+              file-url (assoc :file_url file-url)
+              start (assoc :start_time (.getTime start))
+              mesos-start (assoc :mesos_start_time (.getTime mesos-start))
+              end (assoc :end_time (.getTime end))
+              cancelled (assoc :cancelled cancelled)
+              exit-code (assoc :exit_code exit-code)
+              url-path (assoc :output_url url-path)
+              reason (assoc :reason_code (:reason/code reason)
+                            :reason_string (:reason/string reason)
+                            :reason_mea_culpa (:reason/mea-culpa? reason))
+              progress (assoc :progress progress)
+              progress-message (assoc :progress_message progress-message)
+              sandbox-directory (assoc :sandbox_directory sandbox-directory)))))

 (defn- docker-parameter->response-map
   [{:keys [docker.param/key docker.param/value]}]


Remove comment

Remove comment

--- src/yada/core.clj
+++ src/yada/core.clj
@@ -416,7 +416,6 @@
                      ;; Otherwise return the context unchanged
                      %)))

-              ;; Split the flow based on the existence of the resource
               (fn [ctx]

                 (case method


CMR-6183: Fix broken test

CMR-6183: Fix broken test

--- system-int-test/test/cmr/system_int_test/search/collection_shapefile_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_shapefile_search_test.clj
@@ -125,7 +125,7 @@
         "test_box_with_holes.zip" [whole-world very-wide-cart richmond]

         "Polygon across the antimeridian"
-        "antimeridian.zip" [whole-world very-tall-cart across-am-poly across-am-br along-am-line am-point]
+        "antimeridian.zip" [whole-world very-wide-cart across-am-poly across-am-br along-am-line am-point]

         "Line near North pole"
         "np_line.zip" [on-np whole-world]


Use d/squuid to derive task ID's do that they're more tightly clustered. (#762)

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -609,7 +609,7 @@
    during the same Fenzo scheduling cycle as the newly created TaskRequest."
   [db job & {:keys [resources task-id assigned-resources guuid->considerable-cotask-ids reserved-hosts running-cotask-cache]
           :or {resources (util/job-ent->resources job)
-               task-id (str (java.util.UUID/randomUUID))
+               task-id (str (d/squuid))
                assigned-resources (atom nil)
                guuid->considerable-cotask-ids (constantly #{})
                running-cotask-cache (atom (cache/fifo-cache-factory {} :threshold 1))


Remove pending job atom contention

Remove pending job atom contention

Signed-off-by: Wil <41c73e1c187a64e501bf473cfef5419e8eb5a640@twosigma.com>

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -41,7 +41,8 @@
   (import java.util.concurrent.TimeUnit
           com.netflix.fenzo.TaskAssignmentResult
           com.netflix.fenzo.TaskScheduler
-          com.netflix.fenzo.VirtualMachineLease))
+          com.netflix.fenzo.VirtualMachineLease
+          com.netflix.fenzo.plugins.BinPackingFitnessCalculators))

 (defn now
   []
@@ -538,8 +539,6 @@
   (log/debug "invoked handle-resource-offers!")
   (let [offer-stash (atom nil)] ;; This is a way to ensure we never lose offers fenzo assigned if an errors occures in the middle of processing
     ;; TODO: It is possible to have an offer expire by mesos because we recycle it a bunch of times.
-    ;; TODO: We will see a lot of pending job contention as fenzo takes a long time to schedule. This is *probably* fine as long as some iterations are faster than ranking..
-    ;;       Can we *just* update the new job atom?
     ;; TODO: If there is an exception before offers are sent to fenzo (scheduleOnce) then the offers will be lost. This is fine with offer expiration, but not great.
     (timers/time!
       handle-resource-offer!-duration
@@ -563,10 +562,11 @@
                                  :let [task-request (.getRequest task-result)]]
                              (:job task-request))
               processed-matches (process-matches-for-backfill scheduler-contents (first considerable) matched-jobs)
-              new-scheduler-contents (remove (fn [{pending-job-uuid :job/uuid}]
+              update-scheduler-contents (fn update-scheduler-contents [scheduler-contents]
+                                          (remove (fn [{pending-job-uuid :job/uuid}]
                                                (or (contains? (:fully-processed processed-matches) pending-job-uuid)
                                                    (contains? (:upgrade-backfill processed-matches) pending-job-uuid)))
-                                             scheduler-contents)
+                                             scheduler-contents))
               ;; We don't remove backfilled jobs here, because although backfilled
               ;; jobs have already been scheduled in a sense, the scheduler still can't
               ;; adjust the status of backfilled tasks.
@@ -585,15 +585,9 @@
             ;; "Penalization" should only be employed when Fenzo does successfully match,
             ;; but the matches don't align with Cook's priorities.
             (empty? matches) true
-            (not (compare-and-set! pending-jobs scheduler-contents new-scheduler-contents))
-            (do
-              (log/warn "Pending job atom contention encountered, recycling offers:" @offer-stash)
-              (async/go
-                (async/>! offers-chan @offer-stash))
-              (meters/mark! pending-job-atom-contended)
-              true)
             :else
-            (let [task-txns (for [{:keys [tasks leases]} matches
+            (let [_ (swap! pending-jobs update-scheduler-contents)
+                  task-txns (for [{:keys [tasks leases]} matches
                                   :let [offers (mapv :offer leases)
                                         slave-id (:slave-id (first offers))]
                                   ^TaskAssignmentResult task tasks


cleanup; nCompleted ui-label color refactor

--- src/main/untangled/ui/elements.cljc
+++ src/main/untangled/ui/elements.cljc
@@ -101,7 +101,6 @@
   "Render the given children within a label. Normal HTML/React attributes can be included, and should be a cljs map (not a js object).
   color (optional): :positive, :informative, :informative-alt, :neutral, :live, :alterable, :negative"
   [{:keys [className color] :as props :or {className ""}} & children]
-  ; TODO: Stephen fix colors
   (let [legal-colors #{:primary :accent}
         classes      (cond-> className
                        :always (str " c-label")


Use channel as state key

Use channel as state key

--- src/adzerk/boot_reload/server.clj
+++ src/adzerk/boot_reload/server.clj
@@ -17,19 +17,18 @@
     (.getCanonicalPath (io/file tgt-path rel-path))))

 (defn send-visual! [messages]
-  (doseq [[id {:keys [channel]}] @state]
+  (doseq [[channel _] @state]
     (http/send! channel (pr-str [:visual messages]))))

 (defn send-changed! [tgt-path asset-path changed]
-  (doseq [[id {:keys [protocol channel]}] @state]
+  (doseq [[channel {:keys [protocol]}] @state]
     (http/send! channel
       (pr-str (into [:reload] (map #(web-path protocol % tgt-path asset-path) changed))))))

 (defmulti handle-message (fn [_ channel message] (:type message)))

 (defmethod handle-message :set-protocol [_ channel {:keys [protocol]}]
-  (doseq [[id {c :channel}] @state]
-    (when (= c channel) (swap! state assoc-in [id :protocol] protocol))))
+  (swap! state assoc-in [channel :protocol] protocol))

 (defmethod handle-message :open-file [{:keys [open-file]} channel {:keys [file line column]}]
   (when open-file
@@ -41,10 +40,9 @@
           (util/fail "There was a problem running open-file command: %s\n" cmd))))))

 (defn connect! [opts channel]
-  (let [id (gensym)]
-    (swap! state assoc id {:channel channel})
-    (http/on-close channel (fn [_] (swap! state dissoc id)))
-    (http/on-receive channel #(handle-message opts channel (read-string %)))))
+  (swap! state assoc channel {})
+  (http/on-close channel (fn [_] (swap! state dissoc channel)))
+  (http/on-receive channel #(handle-message opts channel (read-string %))))

 (defn handler [opts request]
   (if-not (:websocket? request)


fix subgroup clusters being the same as group clusters (compute subgroup clusters on subsert of matrix)

--- src/polismath/math/conversation.clj
+++ src/polismath/math/conversation.clj
@@ -312,29 +312,33 @@
       ;;     {:group-id {:k [clusters] ...} ...}
       :subgroup-clusterings
       (plmb/fnk [conv base-clusters-weights base-clusters-proj group-clusters opts']
-        (let [group-ids (mapv :id group-clusters)]
+        (into {}
           ;; For each group cluster id
-          (plmb/map-from-keys
-            (fn [gid]
-              ;; For each k value...
-              ;; TODO Here we should really:
-              ;; * not return anyting if group cluster less than 10% (or some such) of population
-              ;; * not return anything if group cluster generally too small to subcluster (10?)
-              ;; * how do we handle these possibilties downstream?
-              (plmb/map-from-keys
-                (fn [k]
-                  ;; We sort by id just to have a canonical repr
-                  (sort-by
-                    :id
-                    (clusters/kmeans base-clusters-proj k
-                                     ;; This is where we grab the last-clusters from the last update's conv
-                                     :last-clusters (get-in conv [:subgroup-clusterings gid k]) ;; ok if nil
-                                     ;; TODO: Really need to properly account for what happens when group k changes...
-                                     ;; QUESTION: Add subgroup iters? For now assume same parameter value as group; level
-                                     :cluster-iters (:group-iters opts')
-                                     :weights base-clusters-weights)))
-                (range 2 (inc (max-k-fn base-clusters-proj (:max-k opts'))))))
-            group-ids)))
+          (map
+            (fn [group-cluster]
+              (let [gid (:id group-cluster)
+                    group-members (:members group-cluster)
+                    group-cluster-proj (nm/rowname-subset base-clusters-proj group-members)]
+                ;; For each k value...
+                ;; TODO Here we should really:
+                ;; * not return anyting if group cluster less than 10% (or some such) of population
+                ;; * not return anything if group cluster generally too small to subcluster (10?)
+                ;; * how do we handle these possibilties downstream?
+                [gid
+                 (plmb/map-from-keys
+                   (fn [k]
+                     ;; We sort by id just to have a canonical repr
+                     (sort-by
+                       :id
+                       (clusters/kmeans group-cluster-proj k
+                                        ;; This is where we grab the last-clusters from the last update's conv
+                                        :last-clusters (get-in conv [:subgroup-clusterings gid k]) ;; ok if nil
+                                        ;; TODO: Really need to properly account for what happens when group k changes...
+                                        ;; QUESTION: Add subgroup iters? For now assume same parameter value as group; level
+                                        :cluster-iters (:group-iters opts')
+                                        :weights base-clusters-weights)))
+                   (range 2 (inc (max-k-fn group-cluster-proj (:max-k opts')))))]))
+            group-clusters)))

       ; Compute silhouette values for the various clusterings
       :subgroup-clusterings-silhouettes
@@ -345,6 +349,7 @@
             (partial clusters/silhouette bucket-dists))
           subgroup-clusterings))

+      ;; Should call this the k-selector:
       ; This smooths changes in cluster counts (K-vals) by remembering what the last K was, and only changing
       ; after (:group-k-buffer opts') many times on a new K value
       :subgroup-k-smoother


Fix it's -> its on `kill-job`

Fix it's -> its on `kill-job`

--- src/onyx/api.clj
+++ src/onyx/api.clj
@@ -226,7 +226,7 @@
        result))))

 (defn ^{:added "0.6.0"} kill-job
-  "Kills a currently executing job, given it's job ID. All peers executing
+  "Kills a currently executing job, given its job ID. All peers executing
    tasks for this job cleanly stop executing and volunteer to work on other jobs.
    Task lifecycle APIs for closing tasks are invoked. This job is never again scheduled
    for execution."


fix portability problems

fix portability problems

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -14,9 +14,6 @@

    (= input :fail)
    (str input)
-
-   (= (type input) clojure.lang.LazySeq)
-   (str "['" (string/join "','" (map fo input)) "']")

    (string? input)
    input
@@ -373,7 +370,7 @@
          ;; TODO: throw exception rather than encoding error "(no root)" as part
          ;; of the english string.
          root (if (nil? root) "(no root)" root)
-         root (if (not (= (type root) java.lang.String))
+         root (if (not (string? root))
                 (get-in word '(:english :english))
                 root)
          person (get-in word '(:agr :person))


adjust scheduler to new schema

adjust scheduler to new schema

--- src/ceres_collector/scheduler.clj
+++ src/ceres_collector/scheduler.clj
@@ -20,15 +20,10 @@
       (info "Writing tweets backup...")
       (db/backup-yesterday "demeter" "tweets" path)))

-(defjob ReactionsBackup [ctx]
+(defjob RefsBackup [ctx]
   (let [path (get (qc/from-job-data ctx) "folder-path")]
-      (info "Writing reactions backup...")
-    (db/backup-yesterday "demeter" "reactions" path)))
-
-(defjob PubsBackup [ctx]
-  (let [path (get (qc/from-job-data ctx) "folder-path")]
-      (info "Writing publications backup...")
-    (db/backup-yesterday "demeter" "publications" path)))
+      (info "Writing refs backup...")
+    (db/backup-yesterday "demeter" "refs" path)))

 (defjob UrlsBackup [ctx]
   (let [path (get (qc/from-job-data ctx) "folder-path")]
@@ -40,15 +35,15 @@
       (info "Writing users backup...")
     (db/backup-yesterday "demeter" "users" path)))

-(defjob MentionsBackup [ctx]
+(defjob MessagesBackup [ctx]
   (let [path (get (qc/from-job-data ctx) "folder-path")]
-      (info "Writing mentions backup...")
-      (db/backup-yesterday "demeter" "mentions" path)))
+      (info "Writing messages backup...")
+      (db/backup-yesterday "demeter" "messages" path)))

 (defjob HashtagsBackup [ctx]
   (let [path (get (qc/from-job-data ctx) "folder-path")]
-      (info "Writing hashtags backup...")
-      (db/backup-yesterday "demeter" "hashtags" path)))
+      (info "Writing tags backup...")
+      (db/backup-yesterday "demeter" "tags" path)))

 ;; --- Schedules ---
@@ -91,13 +86,13 @@
     (qs/schedule job trigger)))

-(defn reactions-backup-schedule
+(defn refs-backup-schedule
   "Create a schedule to backup the reactions at 3.10 am"
   [path]
   (let [job (j/build
-             (j/of-type ReactionsBackup)
+             (j/of-type RefsBackup)
              (j/using-job-data {"folder-path" path})
-             (j/with-identity (j/key "jobs.reactionsbackup.1")))
+             (j/with-identity (j/key "jobs.refsbackup.1")))
         tk (t/key "triggers.3")
         trigger (t/build
                  (t/with-identity tk)
@@ -110,23 +105,7 @@
     (qs/schedule job trigger)))

-(defn pubs-backup-schedule
-  "Create a schedule to backup the reactions at 3.15 am"
-  [path]
-  (let [job (j/build
-             (j/of-type PubsBackup)
-             (j/using-job-data {"folder-path" path})
-             (j/with-identity (j/key "jobs.pubsbackup.1")))
-        tk (t/key "triggers.4")
-        trigger (t/build
-                 (t/with-identity tk)
-                 (t/start-now)
-                 (t/with-schedule
-                   (schedule
-                    (every-day)
-                    (starting-daily-at (time-of-day 3 15 00))
-                    (ending-daily-at (time-of-day 3 15 01)))))]
-    (qs/schedule job trigger)))
+

 (defn urls-backup-schedule
@@ -167,13 +146,13 @@
     (qs/schedule job trigger)))

-(defn mentions-backup-schedule
+(defn messages-backup-schedule
   "Create a schedule to backup the mentions at 3.30 am"
   [path]
   (let [job (j/build
-             (j/of-type MentionsBackup)
+             (j/of-type MessagesBackup)
              (j/using-job-data {"folder-path" path})
-             (j/with-identity (j/key "jobs.mentionsbackup.1")))
+             (j/with-identity (j/key "jobs.messagesbackup.1")))
         tk (t/key "triggers.7")
         trigger (t/build
                  (t/with-identity tk)
@@ -212,9 +191,8 @@
   (qs/start)
   (tweets-backup-schedule path)
   (htmls-backup-schedule path)
-  (reactions-backup-schedule path)
-  (pubs-backup-schedule path)
+  (refs-backup-schedule path)
   (urls-backup-schedule path)
   (users-backup-schedule path)
-  (mentions-backup-schedule path)
+  (messages-backup-schedule path)
   (hashtags-backup-schedule path))


with-configured-nimbus-connection fixed

with-configured-nimbus-connection fixed

--- src/clj/backtype/storm/thrift.clj
+++ src/clj/backtype/storm/thrift.clj
@@ -11,6 +11,7 @@
   (:import [org.apache.thrift7.protocol TBinaryProtocol TProtocol])
   (:import [org.apache.thrift7.transport TTransport TFramedTransport TSocket])
   (:use [backtype.storm util config log])
+  (:use [backtype.storm.nimbus elections])
   )

 (defn instantiate-java-object [^JavaObject obj]
@@ -65,7 +66,7 @@

 (defmacro with-configured-nimbus-connection [client-sym & body]
   `(let [conf# (read-storm-config)
-         host# (conf# NIMBUS-HOST)
+         host# (get-nimbus-leader-host conf#)
          port# (conf# NIMBUS-THRIFT-PORT)]
      (with-nimbus-connection [~client-sym host# port#]
        ~@body )))


implement optimized extremes protocols and fastempty for IPersistentVector rather than PersistentVector

--- src/clj/com/rpl/specter/impl.cljx
+++ src/clj/com/rpl/specter/impl.cljx
@@ -457,15 +457,15 @@
   (append (butlast l) (afn (last l))))

 #+clj
-(defn vec-count [^clojure.lang.PersistentVector v]
-  (.count v))
+(defn vec-count [^clojure.lang.IPersistentVector v]
+  (.length v))

 #+cljs
 (defn vec-count [v]
   (count v))

 (extend-protocol UpdateExtremes
-  #+clj clojure.lang.PersistentVector #+cljs cljs.core/PersistentVector
+  #+clj clojure.lang.IPersistentVector #+cljs cljs.core/PersistentVector
   (update-first [v afn]
     (let [val (get v 0)]
       (assoc v 0 (afn val))
@@ -485,7 +485,7 @@
     ))

 (extend-protocol GetExtremes
-  #+clj clojure.lang.PersistentVector #+cljs cljs.core/PersistentVector
+  #+clj clojure.lang.IPersistentVector #+cljs cljs.core/PersistentVector
   (get-first [v]
     (get v 0))
   (get-last [v]
@@ -499,7 +499,7 @@

 (extend-protocol FastEmpty
-  #+clj clojure.lang.PersistentVector #+cljs cljs.core/PersistentVector
+  #+clj clojure.lang.IPersistentVector #+cljs cljs.core/PersistentVector
   (fast-empty? [v]
     (= 0 (vec-count v)))
   #+clj Object #+cljs default


noted a future improvement for FORMA, which has obviated the immediate need for a previous TODO.

--- src/clj/forma/trends/analysis.clj
+++ src/clj/forma/trends/analysis.clj
@@ -60,13 +60,17 @@
 ;; was 15 in the original FORMA specification (3) the length of the
 ;; window that smooths the OLS coefficients, which was originally 5.

-;; TODO: make sure that whoopbang can take a variety of different
-;; filters, including a composition of filters.
+;; TODO: check the values of reliability time-series data to make sure
+;; that the good- and bad-set values are correct in
+;; make-reliable. This need not be done for the first run, since it
+;; wasn't done for the original FORMA application.  All we did was
+;; deseasonalize the data, which is reflected below.  It would be a
+;; good and feasible (easy) bonus to utilize the reliability data.

 (defn whoop-full
-  "whoop-full will find the greatest OLS drop over a timeseries [ts] given
-  sub-timeseries of length [long-block].  The drops are smoothed by a moving
-  average window of length [window]."
+  "`whoop-full` will find the greatest OLS drop over a timeseries `ts` given
+  sub-timeseries of length `long-block`.  The drops are smoothed by a moving
+  average window of length `window`."
   [ts reli-ts long-block window]
   (->> (deseasonalize ts)
        (windowed-apply ols-coefficient long-block)


rez ice and complete runs in quetzal test

--- src/clj/test/cards-identities.clj
+++ src/clj/test/cards-identities.clj
@@ -131,18 +131,26 @@
       (make-deck "Quetzal: Free Spirit" [(qty "Sure Gamble" 3)]))
     (play-from-hand state :corp "Ice Wall" "HQ")
     (take-credits state :corp)
+    (core/run state :runner "HQ")
     (let [q (get-in @state [:runner :identity])
+          iwall (get-in @state [:corp :servers :hq :ices 0])
           qdef (core/card-def (get-in @state [:runner :identity]))]
+      (core/rez state :corp iwall)
       (card-ability state :runner q 0)
       (is (last-log-contains? state (get-in qdef [:abilities 0 :msg])))
+      (core/jack-out state :runner nil)
       (core/click-credit state :runner nil)
+      (core/run state :runner "HQ")
       (card-ability state :runner (refresh q) 0)
       (is (not (last-log-contains? state (get-in qdef [:abilities 0 :msg]))))
+      (core/jack-out state :runner nil)
       (take-credits state :runner)
       (take-credits state :corp)
       (core/click-credit state :runner nil)
+      (core/run state :runner "HQ")
       (card-ability state :runner (refresh q) 0)
       (is (last-log-contains? state (get-in qdef [:abilities 0 :msg])))
+      (core/jack-out state :runner nil)
       )))

 (deftest reina-rez-cost-increase


Adds toasts of disconnect and reconnect.

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -37,16 +37,22 @@
   (swap! game-state assoc :side side)
   (swap! last-state #(identity @game-state)))

-(defn notify [text]
-  (swap! game-state update-in [:log] #(conj % {:user "__system__" :text text})))
+(declare toast)
+
+(defn notify
+  "Send a notification to the chat, and a toast to the current player of the specified severity"
+  [text severity]
+  (swap! game-state update-in [:log] #(conj % {:user "__system__" :text text}))
+  (toast text severity))

 (def zoom-channel (chan))
 (def socket (.connect js/io (str js/iourl "/lobby")))
 (def socket-channel (chan))
 (.on socket "netrunner" #(put! socket-channel (js->clj % :keywordize-keys true)))
-(.on socket "disconnect" #(notify "Connection to the server lost. Attempting to reconnect."))
+(.on socket "disconnect" #(notify "Connection to the server lost. Attempting to reconnect."
+                                  "error"))
 (.on socket "reconnect" #(when (.-onbeforeunload js/window)
-                           (notify "Reconnected to the server.")
+                           (notify "Reconnected to the server." "success")
                            (.emit socket "netrunner" #js {:action "reconnect" :gameid (:gameid @app-state)})))

 (def anr-icons {"[Credits]" "credit"


Highlight run credit UI, always show run credits during a run

This allows users to manually add run credits if needed, even
if there currently isn't any.

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -465,8 +465,8 @@
        [:h4.ellipsis (om/build avatar user {:opts {:size 22}}) (:username user)]
        [:div (str click " Click" (if (> click 1) "s" "")) (when me? (controls :click))]
        [:div (str credit " Credit" (if (> credit 1) "s" "")) (when me? (controls :credit))]
-       (when (> run-credit 0)
-        [:div (str run-credit " Run Credit" (if (> credit 1) "s" "")) (when me? (controls :run-credit))])
+       (when (:run @game-state)
+        [:div.fake-link (str run-credit " Run Credit" (if (> credit 1) "s" "")) (when me? (controls :run-credit))])
        [:div (str memory " Memory Unit" (if (> memory 1) "s" "")) (when me? (controls :memory))]
        [:div (str link " Link" (if (> link 1) "s" "")) (when me? (controls :link))]
        [:div (str agenda-point " Agenda Point" (when (> agenda-point 1) "s"))


Remove logging.

Remove logging.

--- src/cljs/town_client/control.cljs
+++ src/cljs/town_client/control.cljs
@@ -21,7 +21,6 @@
   (fetch-data channel "answers" {:category category :respondent__neighborhood nid}))

 (defn handle-user-input [intent data-channel user-channel]
-  (log "Handling intent")
   (condp = (:type intent)
     :newlocation
     (let [nid (:location intent)]
@@ -35,11 +34,9 @@
   [category]
   (first (first (filter (fn [[k v]] (v category)) aggregates))))

-; todo better way
 (def app-state (atom {}))

 (defn category [data]
-  (log "category")
   (if (or (nil? data) (empty? (data "features")))
     nil
     (((-> (data "features")
@@ -117,8 +114,6 @@
                                aggregate-keys
                                new-keys)
            new-data           (assoc-in data [aggregate-id category] val)]
-       (log (str "aggregate " (if aggregate-complete? "complete" "incomplete")))
-       (log (str "got some partial data" " key " category " agg-id " aggregate-id))
        (if aggregate-complete?
          (do
            (>! complete-channel {:resource-type :answer-aggregate


specs

specs

--- src/cljs/triboard/logic/game.cljs
+++ src/cljs/triboard/logic/game.cljs
@@ -9,15 +9,9 @@
     ))

-(s/def ::game
-  #(every? (partial s/valid? ::turn/turn) %))
+(s/def ::game-state ::turn/turn)

-(s/def ::game-state
-  (s/keys :req-un
-    [::board/board
-     ::player/player
-     ::move/available-moves
-     ::scores/scores]))
+(s/def ::game #(every? (partial s/valid? ::game-state) %))

 (s/fdef current-state :args (s/tuple ::game) :ret ::game-state)
 (s/fdef play-move :args (s/tuple ::game ::board/coord) :ret ::game)


fix specs

fix specs

--- src/cljs/triboard/logic/game.cljs
+++ src/cljs/triboard/logic/game.cljs
@@ -17,7 +17,8 @@
   :ret ::game)

 (s/fdef undo-player-move
-  :args ::game :ret ::game)
+  :args (s/cat :game ::game)
+  :ret ::game)

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


Remove 'map-keyed' and duplicate (in = >>).

--- src/cljx/active/clojure/lens.cljx
+++ src/cljx/active/clojure/lens.cljx
@@ -215,40 +215,3 @@
             (concat front
                     [v]
                     (rest back))))))
-
-(defn at-key
-  [extract-key key]
-  (lens (fn [coll]
-          (some (fn [el]
-                  (and (= key (extract-key el))
-                       el))
-                coll))
-        (fn [coll v]
-          (map (fn [el]
-                 (if (= key (extract-key el))
-                   v
-                   el))
-               coll))))
-
-(defn map-keyed
-  [extract-key f coll]
-  (map (fn [el]
-         (let [key (extract-key el)]
-           (f el key (at-key extract-key key))))
-       coll))
-
-(defrecord Path
-    [path]
-  Lens
-  (-yank [this data]
-    (reduce yank data path))
-  (-shove [this data v]
-    (letfn [(u [data path]
-              (if-let [[p & ps] path]
-                (shove data p (u (yank data p) ps))
-                v))]
-      (u data (seq path)))))
-
-(defn in
-  [& accessors]
-  (Path. accessors))


Fix code style related to docstrings on crypto ns.

--- src/clojure/buddy/core/crypto.clj
+++ src/clojure/buddy/core/crypto.clj
@@ -41,12 +41,12 @@

 (defprotocol BlockCipher
   "Protocol that defines interface for all
-supported block ciphers by `buddy`."
+  supported block ciphers by `buddy`."
   (process-block! [obj input] "Encrypt/Decrypt a block of bytes."))

 (defprotocol StreamCipher
   "Protocol that defines interface for all
-supported stream ciphers by `buddy`."
+  supported stream ciphers by `buddy`."
   (process-bytes! [obj input] "Encrypt/Decrypt a set of bytes."))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -55,7 +55,7 @@

 (defn- make-block-cipher-params
   "Generate CipherParameters instance from
-clojure hash map."
+  clojure hash map."
   [params]
   (if (:iv params)
     (let [keyparams (make-block-cipher-params (dissoc params :iv))]


Default to UTF-8

Default to UTF-8

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -248,7 +248,7 @@
             (proxy-super setMarginLinePosition size))
           (processKeyBinding [ks e condition pressed]
             (proxy-super processKeyBinding ks e condition pressed)))
-    (.load (FileLocation/create path) nil)
+    (.load (FileLocation/create path) "UTF-8")
     .discardAllEdits
     (.setAntiAliasingEnabled true)
     (.setSyntaxEditingStyle (get-syntax-style path))


Make `mr/taid` private.

Make `mr/taid` private.

--- src/clojure/parkour/mapreduce.clj
+++ src/clojure/parkour/mapreduce.clj
@@ -143,9 +143,9 @@
   (defmacro ^:private tac*
     [& args] `(new ~cname ~@args)))

-(defprotocol GetTaskAttemptID
+(defprotocol ^:private GetTaskAttemptID
   "Protocol for extracting a task attempt ID."
-  (taid [x] "Task attempt ID for `x`."))
+  (^:private taid [x] "Task attempt ID for `x`."))

 (extend-protocol GetTaskAttemptID
   TaskAttemptContext (taid [tac] (.getTaskAttemptID tac))


Fixed failing ci test

Fixed failing ci test

--- src/clojure/staircase/handler.clj
+++ src/clojure/staircase/handler.clj
@@ -267,6 +267,15 @@
       (binding [staircase.resources/context {:user user}]
         (handler request)))))

+(def friendly-hosts [ #"http://localhost:"
+                     #"http://[^/]*labs.intermine.org"
+                     #"http://intermine.github.io"
+                     #"http://alexkalderimis.github.io"])
+
+(defn allowed-origins
+  [audience]
+  (if audience (conj friendly-hosts (re-pattern audience)) friendly-hosts))
+
 (defrecord Router [session-store
                    asset-pipeline
                    config
@@ -296,11 +305,7 @@
                           pm/wrap-persona-resources))]
       (assoc this :handler (-> handler
                                wrap-restful-format
-                               (wrap-cors :access-control-allow-origin [(re-pattern (:audience config))
-                                                                        #"http://localhost:"
-                                                                        #"http://[^/]*labs.intermine.org"
-                                                                        #"http://intermine.github.io"
-                                                                        #"http://alexkalderimis.github.io"])))))
+                               (wrap-cors :access-control-allow-origin (allowed-origins (:audience config)))))))

   (stop [this] this))