Add more docstrings

Add more docstrings

--- src/main/hbase_region_inspector/core.clj
+++ src/main/hbase_region_inspector/core.clj
@@ -15,22 +15,16 @@
             [hbase-region-inspector.config :as config])
   (:gen-class))

-;;; ZooKeeper quorum we point to
-(defonce config (atom {}))
-
-;;; Whether we should allow region relocation or not
-(defonce read-only? (atom true))
-
-;;; Whether we should include system regions or not
-(defonce with-system? (atom true))
-
-;;; Cache the result of previous inspection
-(defonce cached (atom {:updated-at nil :regions [] :response {}}))
-
-;;; Inspection interval
-(defonce update-interval (atom 10))
-
-(defn long-fmt [val]
+(defonce ^{:doc "Application configuration"} config (atom {}))
+(defonce ^{:doc "Whether we should allow region relocation or not"} read-only? (atom true))
+(defonce ^{:doc "Whether we should include system regions or not"} with-system? (atom true))
+(defonce ^{:doc "Cached result of the previous inspection"} cached
+  (atom {:updated-at nil :regions [] :response {}}))
+(defonce ^{:doc "Inspection interval"} update-interval (atom 10))
+
+(defn long-fmt
+  "Returns string representation of the given integer"
+  [val]
   (str/replace (str (long val)) #"\B(?=(\d{3})+(?!\d))" ","))

 (defn format-val
@@ -316,10 +310,13 @@
       (recur))))

 (defn json-response
+  "Returns JSON response for the given data"
   [data]
   (-> data json/generate-string response))

 (defmacro cached-json-response
+  "Evaluates forms and builds JSON response with the result of it. The response
+  is cached by the keys."
   [[& keys] & forms]
   (let [keys (vec keys)]
     `(if-let [body# (get-in @cached [:response ~keys])]
@@ -331,6 +328,7 @@
          (response json#)))))

 (defn strip-zookeeper-quorum
+  "Returns a compact representation of the ZooKeeper quorum"
   [zk]
   (->> (str/split zk #",")
        (map #(first (str/split % #"[:\.]")))
@@ -401,7 +399,9 @@
        (update-regions!)
        (json-response {})))

-(defn wrap-exception [handler]
+(defn wrap-exception
+  "Ring middleware that catches the exception and turn it into 500 response"
+  [handler]
   (fn [request]
     (try
       (handler request)
@@ -423,7 +423,9 @@
               wrap-exception)
           (route/not-found "404")))

-(defn- bootstrap [conf port bg]
+(defn- bootstrap
+  "Starts the application"
+  [conf port bg]
   ;; Make sure that we can connect to the cluster before
   ;; starting background process
   (reset! config conf)
@@ -438,7 +440,9 @@
     (util/info (format "  http://%s:%d" ip port)))
   (run-jetty app {:port port}))

-(defn exit [message]
+(defn exit
+  "Prints the message and terminates the program"
+  [message]
   (println message)
   (println
     (str/join


Add duration physical quantity

Add duration physical quantity

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -667,7 +667,7 @@
   ([physical-quantity]
    ((quantity-generate-measurement-map physical-quantity) (rand-unit physical-quantity))))

-((quantity-generate-measurement-map :angle))
-((quantity-generate-measurement-map :angle) (rand-unit :angle))
-(rand-measurement :angle)
-(generate-measurement-pair #{:deg} (fn [] :deg) (fn [] (typical-azimuth (rand-nth 360))) identity)
+((quantity-generate-measurement-map :duration))
+((quantity-generate-measurement-map :duration) (rand-unit :duration))
+(rand-measurement :duration)
+(generate-measurement-pair #{:deg} (fn [] :deg) (fn [] (typical-azimuth (rand-nth (range 360)))) identity)


[CS] Close over jurisdiction-tables

[CS] Close over jurisdiction-tables

--- src/vip/data_processor/validation/db.clj
+++ src/vip/data_processor/validation/db.clj
@@ -18,9 +18,9 @@
     (reduce refs/validate-references-for-csv-spec ctx csv-specs)))

 (defn validate-jurisdiction-references [csv-specs]
-  (fn [ctx]
-    (let [jurisdiction-tables (filter
+  (let [jurisdiction-tables (filter
                                (fn [spec] (some #{"jurisdiction_id"}
                                                 (map :name (:columns spec))))
                                csv-specs)]
+    (fn [ctx]
       (reduce refs/validate-jurisdiction-reference ctx jurisdiction-tables))))


Actually lets use mapply syntax

Actually lets use mapply syntax


poll: Remove logging.

poll: Remove logging.

--- src/pepa/web/poll.clj
+++ src/pepa/web/poll.clj
@@ -34,11 +34,9 @@
   ((send-fn content-type) ch {:seqs (m/sequence-numbers db)}))

 (defn lock! [db topic]
-  (println "taking locks")
   (db/with-transaction [db db]
-   (doseq [lock db/advisory-locks]
-     (db/advisory-xact-lock! db lock)))
-  (println "releasing locks"))
+    (doseq [lock db/advisory-locks]
+      (db/advisory-xact-lock! db lock))))

 (defn ^:private handle-poll! [config db bus ch seqs content-type]
   (let [send! (send-fn content-type)


Changed the format to be more condusive to changing the options via git

--- src/cljs/hearthstone_randomizer/hearthstone.cljs
+++ src/cljs/hearthstone_randomizer/hearthstone.cljs
@@ -1,8 +1,24 @@
 (ns hearthstone-randomizer.hearthstone)

-(def characters ["Druid" "Hunter" "Mage" "Paladin" "Priest" "Rogue" "Shaman" "Warlock" "Warrior"])
+(def characters
+  ["Druid"
+   "Hunter"
+   "Mage"
+   "Paladin"
+   "Priest"
+   "Rogue"
+   "Shaman"
+   "Warlock"
+   "Warrior"])

-(def styles ["Suggest a Card" "Opponent's Choice" "Random - Click Done" "Max 3 Cost" "Minimum 5 Cost" "Class Specific" "Neutral Only"])
+(def styles
+  ["Suggest a Card"
+   "Opponent's Choice"
+   "Random - Click Done"
+   "Max 3 Cost"
+   "Minimum 5 Cost"
+   "Class Specific"
+   "Neutral Only"])

 (defn format-characters [player1 player2]
   (println (str "Player 1 is " player1))


Remove cassaforte.embedded

Remove cassaforte.embedded

We are getting rid of dynamic vars and no longer use embedded
ourselves. Not worth keeping for now.

--- src/clojure/clojurewerkz/cassaforte/embedded.clj
+++ src/clojure/clojurewerkz/cassaforte/embedded.clj
@@ -1,71 +0,0 @@
-;; Copyright (c) 2012-2014 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
-;;
-;; The use and distribution terms for this software are covered by the
-;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-;; which can be found in the file epl-v10.html at the root of this distribution.
-;; By using this software in any fashion, you are agreeing to be bound by
-;; the terms of this license.
-;; You must not remove this notice, or any other, from this software.
-
-(ns clojurewerkz.cassaforte.embedded
-  "Provides facility functions for working with an embedded Cassandra server, which is very useful
-   for testing your application without having a C* cluster running and for cases when application
-   requires Standalone Cassandra without additional installation.
-
-   In order to work with an embedded cluster, you'll have to have `cassandra-all` dependency in your
-   project.clj, for example:
-
-      [org.apache.cassandra/cassandra-all \"2.0.2\"]"
-  (:require [clojure.java.io :as io])
-  (:import [org.apache.cassandra.service CassandraDaemon]
-           [org.apache.cassandra.config DatabaseDescriptor]))
-
-(declare daemon)
-
-(defn- delete-file
-  "Delete file f. Raise an exception if it fails unless silently is true."
-  [f & [silently]]
-  (or (.delete (io/file f))
-      silently
-      (throw (java.io.IOException. (str "Couldn't delete " f)))))
-
-(defn- delete-file-recursively
-  "Delete file f. If it's a directory, recursively delete all its contents.
-Raise an exception if any deletion fails unless silently is true."
-  [f & [silently]]
-  (let [f (io/file f)]
-    (if (.isDirectory f)
-      (doseq [child (.listFiles f)]
-        (delete-file-recursively child silently)))
-    (delete-file f silently)))
-
-(defn start-server!
-  "Starts embedded server using configuration file located under `resources/cassandra.yaml`.
-
-   Keys:
-     * cleanup: wether or not remove previously existing cluster files. Cleanup is especially useful when
-       embedded server is used for test purposes. Break your server, wipe it out and start breaking it again."
-  [& {:keys [cleanup] :or {:cleanup true}}]
-  (System/setProperty "cassandra.config" (str (io/resource "cassandra20.yaml")))
-  ;; If you're running Cassandra on Mac Os X on 1.7, you'll get in trouble with parsing version, because
-  ;; "1.7.0_06-ea" ea doesn't parse as int. That's a workaround
-  (System/setProperty "java.version" "1.7.0_15")
-  (System/setProperty "cassandra-foreground" "yes")
-  (System/setProperty "log4j.defaultInitOverride" "false")
-  (System/setProperty "log4j.appender.R.File" "/var/log/cassandra/system.log")
-
-  (when-not (bound? (var daemon))
-    (if (and cleanup
-             (.exists (io/file "tmp")))
-      (delete-file-recursively "tmp"))
-    (def daemon (let [d (CassandraDaemon.)]
-                  (.init d nil)
-                  (.start d)
-                  d))))
-
-
-(defn stop-server!
-  "Stops started embedded server"
-  []
-  (.deactivate ^CassandraDaemon daemon)
-  (.unbindRoot #'daemon))


Fixed bug in Vectors Summed problem

Fixed bug in Vectors Summed problem

--- src/clojush/problems/software/vectors_summed.clj
+++ src/clojush/problems/software/vectors_summed.clj
@@ -119,7 +119,9 @@
                                      (*' 10000 (abs (- (count correct-output) (count result))))) ; penalty of 10000 times difference in sizes of vectors
                                  1000000000) ; penalty for no return value
                                ; Error 2: Levenshtein distance
-                               (levenshtein-distance correct-output result)
+                               (if (vector? result)
+                                 (levenshtein-distance correct-output result)
+                                 1000000000) ; penalty for no return value
                                )))))]
           (when @global-print-behavioral-diversity
             (swap! population-behaviors conj @behavior))


s/demo-name/demo/

s/demo-name/demo/

--- src/babel/english/demo.cljc
+++ src/babel/english/demo.cljc
@@ -21,29 +21,29 @@

 (defn demo [ & [n spec]]
   (let [demo-specs
-        [{:demo-name "Dog noun phrases"
+        [{:demo "Dog noun phrases"
           :synsem {:cat :noun
                    :sem {:pred :dog}}}

-         {:demo-name "Sentences about dogs eating"
+         {:demo "Sentences about dogs eating"
           :synsem {:cat :verb
                    :sem {:subj {:pred :dog}
                          :pred :eat}}}

-         {:demo-name "The adventures of Luisa's yellow cat"
+         {:demo "The adventures of Luisa's yellow cat"
           :synsem {:cat :verb
                    :sem {:subj {:pred :cat
                                 :mod {:pred :yellow}
                                 :spec {:def :genitive
                                        :of {:pred :luisa}}}}}}

-         {:demo-name "Women who read books"
+         {:demo "Women who read books"
           :synsem {:cat :verb
                    :sem {:subj {:pred :woman}
                          :pred :read
                          :obj {:pred :book}}}}

-         {:demo-name "Thinking"
+         {:demo "Thinking"
           :synsem {:cat :verb
                    :sem {:pred :think}}}

@@ -51,7 +51,7 @@

     (doall (map (fn [spec]
                   (let [log-message
-                        (str "running demo: " (:demo-name spec) "..")]
+                        (str "running demo: " (:demo spec) "..")]
                     (do (if timings? (log/info log-message))
                         (println)
                         (println log-message)
@@ -66,7 +66,7 @@
                                                  "."))))
                                        expressions))))))
                 (if (and spec (not (empty? (string/trim spec))))
-                  (filter #(= (:demo-name %)
+                  (filter #(= (:demo %)
                               spec)
                           demo-specs)
                   demo-specs)))


Refactor user-join-group! event to just user user-join-group-txn

--- src/braid/server/events.clj
+++ src/braid/server/events.clj
@@ -6,22 +6,12 @@
     [braid.server.db.user :as user]
     [braid.server.sync-helpers :as sync-helpers]))

-(defn add-user-to-recent-threads-in-group!
-  [user-id group-id]
-  (->> (thread/recent-threads {:user-id user-id
-                               :group-id group-id
-                               :num-threads 5})
-      (mapcat (fn [t] (thread/user-show-thread-txn user-id (t :id))))
-      (db/run-txns!)))
-
 (defn user-join-group!
   [user-id group-id]
-  (db/run-txns!
-    (concat
-      (group/user-add-to-group-txn user-id group-id)
-      (group/user-subscribe-to-group-tags-txn user-id group-id)))
-  (add-user-to-recent-threads-in-group! user-id group-id)
-  (sync-helpers/broadcast-group-change group-id [:braid.client/new-user (user/user-by-id user-id)]))
+  (db/run-txns! (group/user-join-group-txn user-id group-id))
+  (sync-helpers/broadcast-group-change
+    group-id
+    [:braid.client/new-user (user/user-by-id user-id)]))

 (defn register-user!
   [email group-id]


Fix type hint

Fix type hint

--- src/play_clj/math.clj
+++ src/play_clj/math.clj
@@ -88,7 +88,7 @@

 (defmacro catmull-rom-spline!
   [object k & options]
-  `(u/call! ^BSpline ~object ~k ~@options))
+  `(u/call! ^CatmullRomSpline ~object ~k ~@options))

 ; circle


Wip: run multijob all the way through.

Wip: run multijob all the way through.

--- test/onyx/coordinator/multi_job_test.clj
+++ test/onyx/coordinator/multi_job_test.clj
@@ -4,6 +4,7 @@
             [com.stuartsierra.component :as component]
             [onyx.coordinator.async :as async]
             [onyx.extensions :as extensions]
+            [onyx.coordinator.impl :as impl]
             [onyx.coordinator.sim-test-utils :refer [with-system]]))

 (facts
@@ -132,128 +133,122 @@
          (extensions/touch-place sync (:node/completion (:nodes payload-a))))

        (<!! offer-ch-spy)
-       (prn "1")
        (<!! sync-spy-a)
-       (prn "2")
-
-       #_(let [payload-a (extensions/read-place sync payload-node-a-2)]
+
+       (let [payload-a (extensions/read-place sync (:node payload-node-a-2))]
          (facts "Payload A is for job B"
-                (let [db (d/db (:conn log))
-                      query '[:find ?job :in $ ?task ?catalog :where
-                              [?job :job/task ?task]
-                              [?job :job/catalog ?catalog]]
-                      result (d/q query db (:db/id (:task payload-a)) (pr-str catalog-b))
-                      jobs (map first result)]
-                  (fact (count jobs) => 1)))
-
-         (extensions/on-change sync (:status (:nodes payload-a)) #(>!! status-spy %))
-         (extensions/touch-place sync (:ack (:nodes payload-a)))
-
-         (<!! ack-ch-spy)
-         (<!! status-spy))
-
-       (let [payload-b (extensions/read-place sync payload-node-b-1)]
-         (extensions/write-place sync peer-node-b {:pulse pulse-node-b
-                                                   :payload payload-node-b-2
-                                                   :shutdown shutdown-node-b})
-         (extensions/on-change sync payload-node-b-2 #(>!! sync-spy-b %))
-         (extensions/touch-place sync (:completion (:nodes payload-b)))
+                (extensions/read-place sync (:node/catalog (:nodes payload-a))) => catalog-b
+                (extensions/read-place sync (:node/workflow (:nodes payload-a))) => workflow-b)
+
+         (extensions/on-change sync (:node/status (:nodes payload-a)) #(>!! status-spy %))
+         (extensions/touch-place sync (:node/ack (:nodes payload-a)))
+
+         (<!! ack-ch-spy)
+         (<!! status-spy))
+
+       (let [payload-b (extensions/read-place sync (:node payload-node-b-1))]
+         (extensions/write-place sync (:node peer-node-b)
+                                 {:id (:uuid peer-node-b)
+                                  :peer-node (:node peer-node-b)
+                                  :pulse-node (:node pulse-node-b)
+                                  :payload-node (:node payload-node-b-2)
+                                  :shutdown-node (:node shutdown-node-b)})
+
+         (extensions/on-change sync (:node payload-node-b-2) #(>!! sync-spy-b %))
+         (extensions/touch-place sync (:node/completion (:nodes payload-b)))

          (<!! offer-ch-spy)
          (<!! sync-spy-b))

-       #_(let [payload-b (extensions/read-place sync payload-node-b-2)]
-         (facts "Payload B is for job A"
-                (let [db (d/db (:conn log))
-                      query '[:find ?job :in $ ?task ?catalog :where
-                              [?job :job/task ?task]
-                              [?job :job/catalog ?catalog]]
-                      result (d/q query db (:db/id (:task payload-b)) (pr-str catalog-a))
-                      jobs (map first result)]
-                  (fact (count jobs) => 1)))
-
-         (extensions/on-change sync (:status (:nodes payload-b)) #(>!! status-spy %))
-         (extensions/touch-place sync (:ack (:nodes payload-b)))
-
-         (<!! ack-ch-spy)
-         (<!! status-spy))
-
-       (let [payload-a (extensions/read-place sync payload-node-a-2)]
-         (extensions/write-place sync peer-node-a {:pulse pulse-node-a
-                                                   :shutdown shutdown-node-a
-                                                   :payload payload-node-a-1})
-         (extensions/on-change sync payload-node-a-1 #(>!! sync-spy-a %))
-         (extensions/touch-place sync (:completion (:nodes payload-a)))
+       (let [payload-b (extensions/read-place sync (:node payload-node-b-2))]
+         (facts
+          "Payload B is for job A"
+          (extensions/read-place sync (:node/catalog (:nodes payload-b))) => catalog-a
+          (extensions/read-place sync (:node/workflow (:nodes payload-b))) => workflow-a)
+
+         (extensions/on-change sync (:node/status (:nodes payload-b)) #(>!! status-spy %))
+         (extensions/touch-place sync (:node/ack (:nodes payload-b)))
+
+         (<!! ack-ch-spy)
+         (<!! status-spy))
+
+       (let [payload-a (extensions/read-place sync (:node payload-node-a-2))]
+         (extensions/write-place sync (:node peer-node-a)
+                                 {:id (:uuid peer-node-a)
+                                  :peer-node (:node peer-node-a)
+                                  :pulse-node (:node pulse-node-a)
+                                  :shutdown-node (:node shutdown-node-a)
+                                  :payload-node (:node payload-node-a-1)})
+
+         (extensions/on-change sync (:node payload-node-a-1) #(>!! sync-spy-a %))
+         (extensions/touch-place sync (:node/completion (:nodes payload-a)))

          (<!! offer-ch-spy)
          (<!! sync-spy-a))

-       #_(let [payload-a (extensions/read-place sync payload-node-a-1)]
-         (facts "Payload A is for job B"
-                (let [db (d/db (:conn log))
-                      query '[:find ?job :in $ ?task ?catalog :where
-                              [?job :job/task ?task]
-                              [?job :job/catalog ?catalog]]
-                      result (d/q query db (:db/id (:task payload-a)) (pr-str catalog-b))
-                      jobs (map first result)]
-                  (fact (count jobs) => 1)))
-
-         (extensions/on-change sync (:status (:nodes payload-a)) #(>!! status-spy %))
-         (extensions/touch-place sync (:ack (:nodes payload-a)))
-
-         (<!! ack-ch-spy)
-         (<!! status-spy))
-
-       (let [payload-b (extensions/read-place sync payload-node-b-2)]
-         (extensions/write-place sync peer-node-b {:pulse pulse-node-b
-                                                   :shutdown shutdown-node-b
-                                                   :payload payload-node-b-1})
-         (extensions/on-change sync payload-node-b-1 #(>!! sync-spy-b %))
-         (extensions/touch-place sync (:completion (:nodes payload-b)))
+       (let [payload-a (extensions/read-place sync (:node payload-node-a-1))]
+         (facts
+          "Payload A is for job B"
+          (extensions/read-place sync (:node/catalog (:nodes payload-a))) => catalog-b
+          (extensions/read-place sync (:node/workflow (:nodes payload-a))) => workflow-b)
+
+         (extensions/on-change sync (:node/status (:nodes payload-a)) #(>!! status-spy %))
+         (extensions/touch-place sync (:node/ack (:nodes payload-a)))
+
+         (<!! ack-ch-spy)
+         (<!! status-spy))
+
+       (let [payload-b (extensions/read-place sync (:node payload-node-b-2))]
+         (extensions/write-place sync (:node peer-node-b)
+                                 {:id (:uuid peer-node-b)
+                                  :peer-node (:node peer-node-b)
+                                  :pulse-node (:node pulse-node-b)
+                                  :shutdown-node (:node shutdown-node-b)
+                                  :payload-node (:node payload-node-b-1)})
+
+         (extensions/on-change sync (:node payload-node-b-1) #(>!! sync-spy-b %))
+         (extensions/touch-place sync (:node/completion (:nodes payload-b)))

          (<!! offer-ch-spy)
          (<!! sync-spy-b))

-       #_(let [payload-b (extensions/read-place sync payload-node-b-1)]
-         (facts "Payload B is for job B"
-                (let [db (d/db (:conn log))
-                      query '[:find ?job :in $ ?task ?catalog :where
-                              [?job :job/task ?task]
-                              [?job :job/catalog ?catalog]]
-                      result (d/q query db (:db/id (:task payload-b)) (pr-str catalog-b))
-                      jobs (map first result)]
-                  (fact (count jobs) => 1)))
-
-         (extensions/on-change sync (:status (:nodes payload-b)) #(>!! status-spy %))
-         (extensions/touch-place sync (:ack (:nodes payload-b)))
-
-         (<!! ack-ch-spy)
-         (<!! status-spy))
-
-       (let [payload-a (extensions/read-place sync payload-node-a-1)
-             payload-b (extensions/read-place sync payload-node-b-1)]
-         (extensions/touch-place sync (:completion (:nodes payload-a)))
-         (extensions/touch-place sync (:completion (:nodes payload-b)))
+       (let [payload-b (extensions/read-place sync (:node payload-node-b-1))]
+         (facts
+          "Payload B is for job B"
+          (extensions/read-place sync (:node/catalog (:nodes payload-b))) => catalog-b
+          (extensions/read-place sync (:node/workflow (:nodes payload-b))) => workflow-b)
+
+         (extensions/on-change sync (:node/status (:nodes payload-b)) #(>!! status-spy %))
+         (extensions/touch-place sync (:node/ack (:nodes payload-b)))
+
+         (<!! ack-ch-spy)
+         (<!! status-spy))
+
+       (let [payload-a (extensions/read-place sync (:node payload-node-a-1))
+             payload-b (extensions/read-place sync (:node payload-node-b-1))]
+         (extensions/touch-place sync (:node/completion (:nodes payload-a)))
+         (extensions/touch-place sync (:node/completion (:nodes payload-b)))

          (<!! offer-ch-spy)
          (<!! offer-ch-spy))

-       #_(let [db (d/db (:conn log))]
-           (facts "All tasks are complete"
-                  (let [query '[:find (count ?task) :where
-                                [?task :task/complete? true]]
-                        result (ffirst (d/q query db))]
-                    (fact result => 6)))
-
-           (facts "All peers are idle"
-                  (let [query '[:find (count ?peer) :where
-                                [?peer :peer/status :idle]]
-                        result (ffirst (d/q query db))]
-                    (fact result => 2))))
+       (facts
+        "All tasks are complete"
+        (let [job-nodes (extensions/bucket sync :job)
+              task-paths (map #(extensions/resolve-node sync :task %) job-nodes)]
+          (doseq [task-path task-paths]
+            (doseq [task-node (extensions/children sync task-path)]
+              (when-not (impl/completed-task? task-node)
+                (fact (impl/task-complete? sync task-node) => true))))))
+
+       (facts "All peers are idle"
+              (doseq [state-path (extensions/bucket sync :peer-state)]
+                (let [state (extensions/dereference sync state-path)]
+                  (fact (:state (:content state)) => :idle))))

        (facts "Peer death succeeds"
-              (extensions/delete sync pulse-node-a)
-              (extensions/delete sync pulse-node-b)
+              (extensions/delete sync (:node pulse-node-a))
+              (extensions/delete sync (:node pulse-node-b))
               (<!! offer-ch-spy)
               (<!! offer-ch-spy))))


fixed badly fixed commit

fixed badly fixed commit

--- src/re_demo/core.cljs
+++ src/re_demo/core.cljs
@@ -167,7 +167,7 @@

 (def id-store        (local-storage (atom nil) ::id-store))
 (def selected-tab-id (reagent/atom (if (or (nil? @id-store) (nil? (item-for-id @id-store tabs-definition)))
-                                     (:id date(first tabs-definition))
+                                     (:id (first tabs-definition))
                                      @id-store)))  ;; id of the selected tab from local storage

 (defroute demo-page "/:tab" [tab] (let [id (keyword tab)]


making cycle props more generic

making cycle props more generic

--- src/clj/greenhouse/grid.clj
+++ src/clj/greenhouse/grid.clj
@@ -118,21 +118,24 @@

 (defn cycle-props
   "Returns the relevant properties to implementing column cycling."
-  [cycle side margin-r margin-last]
-  (if (zero? cycle)
-    [:&:last-child {(opposite-margin side) (percent margin-last)}]
-
-    [["&:nth-of-type(n)"
-     {(opposite-margin side) (percent margin-r)
-      :float side
-      :clear :none}]
-
-     [(str "&:nth-of-type(" cycle "n)")
-     {(opposite-margin side) (percent margin-last)
-      :float (opposite-side side)}]
-
-     [(str "&:nth-of-type(" cycle "n+1)")
-     {:clear :both}]]))
+  ([n side margin]
+   (cycle-props n side margin margin))
+
+  ([n side margin-r margin-last]
+   (if (zero? n)
+     [:&:last-child {(opposite-margin side) (percent margin-last)}]
+
+     [["&:nth-of-type(n)"
+       {(opposite-margin side) (percent margin-r)
+        :float side
+        :clear :none}]
+
+      [(str "&:nth-of-type(" n "n)")
+       {(opposite-margin side) (percent margin-last)
+        :float (opposite-side side)}]
+
+      [(str "&:nth-of-type(" n "n+1)")
+       {:clear :both}]])))

 (defn column
   [& {:keys [ratio offset cycle uncycle gutter]


catching also npe token

catching also npe token

--- src/clj/swarmpit/server.clj
+++ src/clj/swarmpit/server.clj
@@ -72,7 +72,7 @@
         (if (some? token)
           (let [claims (try
                          (token/verify-jwt token)
-                         (catch ExceptionInfo _
+                         (catch Exception _
                            (resp-unauthorized "Invalid token")))]
             (if (invalid-claims? claims)
               (resp-unauthorized "Invalid token")
@@ -81,7 +81,8 @@
                   (handler request)
                   (resp-unauthorized "Unauthorized access"))
                 (handler request))))
-          (resp-error 400 "Missing token")))
+          (resp-error 400 "Missing token"))
+        )
       (handler request))))

 (def app


calc inner-tokens var from main markup definition

--- src/cljs/greffe/markup.cljs
+++ src/cljs/greffe/markup.cljs
@@ -27,11 +27,22 @@
    :rhyme {:type :inner
            :begin-token "//"
            :end-token "//"
-           :contains []}})
-
+           :contains []
+           :html "em"}})

 (def inner-tokens
-  {"//" {:tag :rhyme
-         :closing-tag "//"}
-   "|" {:tag :caesura
-        :no-content true}})
+  (->>  markup
+   (filter
+     (fn [[_ descrip]]
+       (#{:inner :empty} (:type descrip))))
+   (map
+     (fn [[tag descrip]]
+       (let [info {:tag tag}]
+        [(:begin-token descrip)
+         (if (= :empty (:type descrip))
+           (assoc info :no-content true)
+           (assoc info :closing-tag
+             (or
+               (:end-token descrip)
+               (:begin-token descrip))))])))
+   (into {})))


every view accept route (due to cleanup state mixin) #186

--- src/cljs/swarmpit/view.cljs
+++ src/cljs/swarmpit/view.cljs
@@ -50,8 +50,8 @@
   (page-403/form))

 (defmethod dispatch :error
-  [_]
-  (page-error/form))
+  [route]
+  (page-error/form route))

 (defmethod dispatch :login
   [_]
@@ -64,137 +64,137 @@
 ;;; Service view

 (defmethod dispatch :service-list
-  [{:keys [params]}]
-  (service-list/form params))
+  [route]
+  (service-list/form route))

 (defmethod dispatch :service-info
-  [{:keys [params]}]
-  (service-info/form params))
+  [route]
+  (service-info/form route))

 (defmethod dispatch :service-log
-  [{:keys [params]}]
-  (service-log/form params))
+  [route]
+  (service-log/form route))

 (defmethod dispatch :service-create-image
-  [_]
-  (service-image/form))
+  [route]
+  (service-image/form route))

 (defmethod dispatch :service-create-config
-  [{:keys [params]}]
-  (service-config/form params))
+  [route]
+  (service-config/form route))

 (defmethod dispatch :service-edit
-  [{:keys [params]}]
-  (service-edit/form params))
+  [route]
+  (service-edit/form route))

 ;;; Network view

 (defmethod dispatch :network-list
-  [_]
-  (network-list/form))
+  [route]
+  (network-list/form route))

 (defmethod dispatch :network-info
-  [{:keys [params]}]
-  (network-info/form params))
+  [route]
+  (network-info/form route))

 (defmethod dispatch :network-create
-  [_]
-  (network-create/form))
+  [route]
+  (network-create/form route))

 ;;; Node view

 (defmethod dispatch :node-list
-  [_]
-  (node-list/form))
+  [route]
+  (node-list/form route))

 ;;; Volume view

 (defmethod dispatch :volume-list
-  [_]
-  (volume-list/form))
+  [route]
+  (volume-list/form route))

 (defmethod dispatch :volume-info
-  [{:keys [params]}]
-  (volume-info/form params))
+  [route]
+  (volume-info/form route))

 (defmethod dispatch :volume-create
-  [_]
-  (volume-create/form))
+  [route]
+  (volume-create/form route))

 ;;; Secret view

 (defmethod dispatch :secret-list
-  [_]
-  (secret-list/form))
+  [route]
+  (secret-list/form route))

 (defmethod dispatch :secret-info
-  [{:keys [params]}]
-  (secret-info/form params))
+  [route]
+  (secret-info/form route))

 (defmethod dispatch :secret-create
-  [_]
-  (secret-create/form))
+  [route]
+  (secret-create/form route))

 ;;; Task view

 (defmethod dispatch :task-list
-  [_]
-  (task-list/form))
+  [route]
+  (task-list/form route))

 (defmethod dispatch :task-info
-  [{:keys [params]}]
-  (task-info/form params))
+  [route]
+  (task-info/form route))

 ;;; User view

 (defmethod dispatch :user-list
-  [_]
-  (user-list/form))
+  [route]
+  (user-list/form route))

 (defmethod dispatch :user-info
-  [{:keys [params]}]
-  (user-info/form params))
+  [route]
+  (user-info/form route))

 (defmethod dispatch :user-create
-  [_]
-  (user-create/form))
+  [route]
+  (user-create/form route))

 (defmethod dispatch :user-edit
-  [{:keys [params]}]
-  (user-edit/form params))
+  [route]
+  (user-edit/form route))

 ;;; Registry view

 (defmethod dispatch :registry-list
-  [_]
-  (registry-list/form))
+  [route]
+  (registry-list/form route))

 (defmethod dispatch :registry-info
-  [{:keys [params]}]
-  (registry-info/form params))
+  [route]
+  (registry-info/form route))

 (defmethod dispatch :registry-create
-  [_]
-  (registry-create/form))
+  [route]
+  (registry-create/form route))

 (defmethod dispatch :registry-edit
-  [{:keys [params]}]
-  (registry-edit/form params))
+  [route]
+  (registry-edit/form route))

 ;;; Dockerhub user view

 (defmethod dispatch :dockerhub-user-list
-  [_]
-  (dockerhub-list/form))
+  [route]
+  (dockerhub-list/form route))

 (defmethod dispatch :dockerhub-user-info
-  [{:keys [params]}]
-  (dockerhub-info/form params))
+  [route]
+  (dockerhub-info/form route))

 (defmethod dispatch :dockerhub-user-create
-  [_]
-  (dockerhub-create/form))
+  [route]
+  (dockerhub-create/form route))

 (defmethod dispatch :dockerhub-user-edit
-  [{:keys [params]}]
-  (dockerhub-edit/form params))+  [route]
+  (dockerhub-edit/form route))


AI improvement ideas

AI improvement ideas

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -264,7 +264,7 @@
     (cells-strength point)
     converted))

-(defn- worst-immediate-loss
+(defn- worst-immediate-loss ;; TODO - It should consider what the other player could win
   "Return the next worse lost game move for 'looser' if 'player' plays"
   {:pre [(player? player) (player? looser)]}
   [cells-strength game player looser]


fixes description of quotient*

fixes description of quotient*

--- src/riemann/folds.clj
+++ src/riemann/folds.clj
@@ -120,9 +120,9 @@
   (fold-all - events))

 (defn quotient*
-  "Divides events. Returns the first event, with its metric multiplied by the
-  metrics of all subsequent events. Like quotient, but throws when any metric
-  is nil or a divisor is zero."
+  "Divides events. Returns the first event, with its metric divided by the
+  product of the metrics of all subsequent events. Like quotient, but throws
+  when any metric is nil or a divisor is zero."
   [events]
   (fold* / events))

@@ -132,7 +132,7 @@
   [events]
   (when-let [event (first events)]
     (try
-      (fold-all / events)
+      (fold-all / events)
       (catch ArithmeticException e
         (merge event
                {:metric nil


CMR-564: Changed error message to match changes in search app.

--- test/cmr/system_int_test/search/granule_search_format_test.clj
+++ test/cmr/system_int_test/search/granule_search_format_test.clj
@@ -31,7 +31,7 @@
         (search/find-metadata :granule :echo10 {:granule-ur "g1"})))

     (testing "invalid format"
-      (is (= {:errors ["The mime type [application/echo11+xml] is not supported for search results."],
+      (is (= {:errors ["The mime type [application/echo11+xml] is not supported."],
               :status 400}
              (search/get-search-failure-data
                (search/find-concepts-in-format


Add explanation to sahucs

Add explanation to sahucs

--- src/exp/sahucs_inverted.clj
+++ src/exp/sahucs_inverted.clj
@@ -15,6 +15,8 @@

 ;; Or, at time of first pop, snatch current parent set, order it, pop only best at a time.
 ;; Generate immediate refinements
+
+;; TODO: why is it OK to do things state-based, not effect-based, here?

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Helpers       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -173,4 +175,60 @@

 ;                (util/assert-is (seq good-parents)  "%s" [(keyword? cpa-val) neg-rew (:reward-to-state best) best-rew (map second cur-parents) (env/action-name (:action (:sanode best))) (count cur-parents) (count (:parent-vec-atom (:sanode best)))])

-;                    (util/assert-is (nil? (queues/g-pq-priority queue nxt)) "%s" [(:reward-to-state best) (second (first bad-parents))  (count cur-parents) (count bad-parents) (map second cur-parents) (count @(:parent-vec-atom (:sanode best)))])+;                    (util/assert-is (nil? (queues/g-pq-priority queue nxt)) "%s" [(:reward-to-state best) (second (first bad-parents))  (count cur-parents) (count bad-parents) (map second cur-parents) (count @(:parent-vec-atom (:sanode best)))])
+
+
+(comment
+
+  Inefficient in cyclic hierarchies, expensive since lots of queues.
+
+Detailed workings
+------------------------
+At top-level, keep a queue of ``entries''
+Each ``entry'' has a concrete state, reward-to-state, ``sanode'', and remaining-parents list.
+  - remaining-parents can be :fresh, whith means ..., or list of [parent-entry pre-reward]
+  - Equality based on the state, sanode identity, and identity of first parent.
+Each ``sanode'' represents a particular subproblem
+ -- computing the results of a particular action from a particular (abstracted) state.
+ - Contains an action, atom of results found so far, atom of [parent-entry reward] parents
+ -    (set is redundant?).  Never compared on equality.
+ - Redundant parent entries (i.e., from coalescence within parent) skipped.
+
+Global cache maps [action, state-in-context] pairs to sanodes.
+
+Each ``parent entry'' has a concrete state, reward-to-state, remaining-actions, parent sanode
+ - (reward is reward *within the parent*)
+ - Equality is based on remaining-actions and sanode (enough for uniqueness in context ? )
+ - Represents a reference to an sanode from a parent sanode, more or less.
+    - State in parent context, reward within parent context, remaining actions, ...
+ - If we followed chain upwards, we would get particular context + cost.
+
+
+So, we have a chain of sanode --> parent --> sanode --> parent upwards.
+
+Basic idea: when we discover a subproblem, we create an sanode and register ourselves as a parent.
+
+Get-sa-node
+-----------------------
+This is probably the main workhorse.  We pass in an action, parent-entry, and pre-reward.
+If the node exists
+ If the parent is already known, we've found a worse path, and skip.
+ Else, add the parent entry, and return queue entries for already discovered states.
+Else, create a new SA-node, and make queue entries for its children (either primitive result, or refinements left to go).
+
+TODO: how aren't we missing intermediate states here?
+
+
+Flow
+-----------------------
+Each queue entry represents an *outcome* state for some action, in a (tail) subset of contexts discovered so far.  By default it's remaining parent set is just ``fresh'', meaning grab the list of contexts from the sanode on first expansion.  After that, it's the set of not-yet-good-enough parents.
+
+Pop the best state off the queue.  The reward associated it is the best reward to reach this state, in any currently established hierarchical context.  We've discovered a new output state for some HLA, so we
+(1) Add new queue entries for all optimal parents, by looking up cached results, and
+  (a) adding entry for parent, if we're done there too, or
+  (b) jumping through next action / adding to notify list, if it exists, or
+  (c) Creating a cascade of node/pe all the way to the primitive level, where we take our first step, for each refinement at each level.
+
+Note, exploit canonicality of extra variables at any SA-node.
+
+  )


Update core.clj

Update core.clj

--- src/hasta_la_vista/core.clj
+++ src/hasta_la_vista/core.clj
@@ -171,7 +171,7 @@
               (go-loop []
                 (let [  ids       (blocking-consumer work-chan)
                         start     (. System (nanoTime))
-                        _         (doseq [id ids] (client/delete client-del id))
+                        _         (doall (pmap #(client/delete client-del %) ids))
                         exec-time (with-precision 3 (/ (- (. System (nanoTime)) start) 1000000.0))
                         perf      (with-precision 3 (/ (count ids) exec-time)) ]
                   ;; send results to stat-chan


More debugging

More debugging

--- src-shared/cljs/cljs_webrepl/repl_thread.cljs
+++ src-shared/cljs/cljs_webrepl/repl_thread.cljs
@@ -23,8 +23,9 @@
            (t/read reader)))

 (defn- serialize [writer msg]
-  (debugf "Serialize: %s %s"  (worker-type) msg)
+  (debugf "Serialize: %s %s" (worker-type) msg)
   (let [msg (t/write writer msg)]
+    (debugf "Serialized: %s %s" (worker-type) msg)
     (js-obj "msg" msg)))

 (defn- async-worker [& [target close-fn]]


:bug: Fix incorrect usage of pool on rename-page mutation.

--- backend/src/uxbox/services/mutations/project_pages.clj
+++ backend/src/uxbox/services/mutations/project_pages.clj
@@ -122,7 +122,7 @@
                 set name = $2
               where id = $1
                 and deleted_at is null"]
-    (-> (db/query-one db/pool [sql id name])
+    (-> (db/query-one conn [sql id name])
         (p/then su/constantly-nil))))

 ;; --- Mutation: Update Page


Catch exeception caused when searching for a commit with incorrect hash.

--- src/tyranitar/git.clj
+++ src/tyranitar/git.clj
@@ -8,6 +8,7 @@
             [cheshire.core :refer [parse-string]])
   (:import [org.eclipse.jgit.api Git MergeCommand MergeCommand$FastForwardMode]
            [org.eclipse.jgit.api.errors InvalidRemoteException]
+           [org.eclipse.jgit.errors MissingObjectException]
            [org.eclipse.jgit.revwalk RevWalk]
            [org.eclipse.jgit.treewalk TreeWalk]
            [org.eclipse.jgit.transport JschConfigSessionFactory SshSessionFactory]
@@ -187,6 +188,8 @@
       (catch InvalidRemoteException e
         nil)
       (catch NullPointerException e
+        nil)
+      (catch MissingObjectException e
         nil))))

 (defn get-list


fix rhythm example

fix rhythm example

--- src/overtone/examples/getting_started/rhythm.clj
+++ src/overtone/examples/getting_started/rhythm.clj
@@ -1,6 +1,6 @@
 (ns overtone.examples.getting-started.rhythm
   (:use [overtone.live]
-        [overtone.inst.drum :only [quick-kick haziti-clap soft-hat]]))
+        [overtone.inst.drum :only [quick-kick haziti-clap soft-hat open-hat]]))

 (def m (metronome 128))

@@ -10,7 +10,7 @@
     (at (m beat)
         (quick-kick :amp 0.5)
         (if (zero? (mod beat 2))
-          (hat :amp 0.1)))
+          (open-hat :amp 0.1)))
     (at (m (+ 0.5 beat))
         (haziti-clap :decay 0.05 :amp 0.3))


http-kit 0.5.1 built on ring 0.5.1

http-kit 0.5.1 built on ring 0.5.1

--- modules/http-kit/project.clj
+++ modules/http-kit/project.clj
@@ -1,11 +1,11 @@
 ;; Copyright © 2014 JUXT LTD.

-(defproject juxt.modular/http-kit "0.5.0"
+(defproject juxt.modular/http-kit "0.5.1"
   :description "A modular extension that provides support for http-kit channels"
   :url "https://github.com/juxt/modular/tree/master/modules/http-kit"
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}
   :dependencies [[http-kit "2.1.13"]
                  [prismatic/schema "0.2.1"]
-                 [juxt.modular/ring "0.5.0"]
+                 [juxt.modular/ring "0.5.1"]
                  ])


Update leiningen dependency for metrics-clojure-graphite

--- ssclj/jar/project.clj
+++ ssclj/jar/project.clj
@@ -22,6 +22,8 @@
                  [metrics-clojure-ring/metrics-clojure-ring "2.5.1"
                    :exclusions [[cheshire/cheshire]] ]
                  [metrics-clojure-jvm/metrics-clojure-jvm   "2.5.1"]
+                 [metrics-clojure-graphite/metrics-clojure-graphite   "2.5.1"]
+
                  [fs/fs                                     "1.3.3"]
                  [org.slf4j/slf4j-log4j12                   "1.7.12"]
                  [instaparse                                "1.4.1"]


adding style formatting metadata in when* macros

--- moebius/src/moebius/core.clj
+++ moebius/src/moebius/core.clj
@@ -383,6 +383,7 @@
           (assoc event :new-property \"a-value\"))

   "
+  {:style/indent 2}
   [event name & body]
   `(let [_event# ~event _name# ~name
          _names# (if (string? _name#) [_name#] _name#)]
@@ -416,6 +417,7 @@
   It implies a `:else` statement so you can't use one in yours.

   "
+  {:style/indent 1}
   [event & body]
   `(let [_event# ~event]
      (match [_event#]


Update information model.

Update information model.

--- src/onyx/kafka/information_model.cljc
+++ src/onyx/kafka/information_model.cljc
@@ -100,7 +100,7 @@
               :optional? true}

              :kafka/target-offsets
-             {:doc "Allows a task to be supplied with target offsets for all partitions. Maps partition to target offset, e.g. `{0 50, 1 90}` and will cause the plugin to stop consuming records after reaching the specified offsets."
+             {:doc "Allows a task to be supplied with target offsets for all partitions. The consumer will read up to and including the target offset for each partition."
               :type :map
               :optional? true}}}


Add a User-Agent header for tracking

Add a User-Agent header for tracking

--- src/kale/watson_service.clj
+++ src/kale/watson_service.clj
@@ -3,11 +3,29 @@
 ;;

 (ns kale.watson-service
-    (:require [kale.common :refer [trace-enabled get-command-msg]]
-              [clojure.pprint :refer [pprint]]
-              [cheshire.core :as json]
-              [clj-http.client :as client]
-              [slingshot.slingshot :refer [throw+ try+]]))
+  (:require [kale.common :refer [trace-enabled get-command-msg]]
+            [kale.version :refer [kale-version]]
+            [clojure.pprint :refer [pprint]]
+            [cheshire.core :as json]
+            [clj-http.client :as client]
+            [slingshot.slingshot :refer [throw+ try+]]
+            [clojure.string :as str]))
+
+(def props #{"java.vendor"
+             "java.version"
+             "os.arch"
+             "os.name"
+             "os.version"})
+
+(def user-agent-string
+  (str "ibm-watson-kale/" (kale-version)
+       " ("
+       (str/join "; " (map #(.toString %)
+                           (filter (fn [[k v]] (props k))
+                                   (System/getProperties))))
+       ")"))
+
+(def user-agent-header {:user-agent user-agent-string})

 (defn get-msg
   "Return the corresponding service message"
@@ -49,7 +67,9 @@
   ([method endpoint path] (raw method endpoint path {}))
   ([method {:keys [url username password token]} path options]
    (try+ (let [url (str url path)
-               request (merge {:method method :url url} options)
+               request (merge {:method method
+                               :headers user-agent-header
+                               :url url} options)
                authorization (generate-auth username password token)
                response (client/request (merge request authorization))]


CMR-1856 Removes sensors from SMAP expected conversion results.

--- umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/expected_conversion.clj
@@ -233,10 +233,12 @@
       ;; Because SMAP cannot account for type, all of them are converted to Spacecraft.
       ;; Platform Characteristics are also not supported.
       (update-in-each [:Platforms] assoc :Type "Spacecraft" :Characteristics nil)
+      ;; The following instrument fields are not supported by SMAP.
       (update-in-each [:Platforms] update-in-each [:Instruments] assoc
                       :Characteristics nil
                       :OperationalModes nil
                       :NumberOfSensors nil
+                      :Sensors nil
                       :Technique nil)
       (update-in [:Platforms] normalize-instruments)))


CMR-2930: Made DIF9 GranuleSpatialRepresentation default to NO_SPATIAL.

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif9.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif9.clj
@@ -115,7 +115,7 @@
                                              :EndingDateTime (parse-dif-end-date (value-of temporal "Stop_Date"))})}])
      :PaleoTemporalCoverages (pt/parse-paleo-temporal doc)
      :SpatialExtent (merge {:GranuleSpatialRepresentation (or (value-of doc "/DIF/Extended_Metadata/Metadata[Name='GranuleSpatialRepresentation']/Value")
-                                                              "CARTESIAN")}
+                                                              "NO_SPATIAL")}
                            (when-let [brs (seq (parse-mbrs doc))]
                              {:SpatialCoverageType "HORIZONTAL"
                               :HorizontalSpatialDomain


pmap here a bid idea - registerView may have side-effects - rethink

--- dada-core/src/main/clojure/org/dada/core/JoinModel.clj
+++ dada-core/src/main/clojure/org/dada/core/JoinModel.clj
@@ -241,7 +241,7 @@
 	i-to-lhs-getters (into (sorted-map) (map (fn [[i [model getters]]] [i getters]) i-to-rhs-model-and-lhs-getters))]

     (dorun
-     (pmap
+     (map
       (fn [[i [^Model rhs-model lhs-getters]]]
 	(debug ["post-init: watching rhs:" i rhs-model])
 	(let [^Metadata rhs-metadata (.getMetadata rhs-model)


Add titles and fitzhugh-nagamo model

Add titles and fitzhugh-nagamo model

--- src/cljs/ode_solver/components/dashboard.cljs
+++ src/cljs/ode_solver/components/dashboard.cljs
@@ -22,6 +22,7 @@
       (range (+ start-time timestep) end timestep))))

+;; Boring plots
 (defn dy-dt-1 [_ _]
   1)

@@ -32,14 +33,34 @@
   y)

-; Circle
+;; Circle
 (defn circle-dy1-dt [y1 y2 t]
   y2)

 (defn circle-dy2-dt [y1 y2 t]
   (- y1))

-(defn plotter [[labels dataset] owner]
+;; FitzHugh-Nagumo Model
+
+(defn fhn-dv [alpha epsilon Iapp]
+  (fn [v w t]
+    (/
+      (+
+        (-
+          (*
+            (- v)
+            (- v alpha)
+            (- v 1))
+          w)
+        Iapp)
+      epsilon)))
+
+(defn fhn-dw [gamma]
+  (fn [v w t]
+    (- v (* gamma w))))
+
+;; a beautiful plotter component
+(defn plotter [[labels dataset title] owner]
   (reify
     om/IInitState
     (init-state [_]
@@ -70,10 +91,9 @@
     (render-state [this state]
       (dom/div
         #js {:className "ui segment"}
-        (dom/h2 nil "Bro.")
         (dom/div
           #js {}
-          (dom/h3 nil "A graph of your ODE solver!")
+          (dom/h3 nil title)
           (dom/svg #js {:className "ode-graph"}))))

     om/IWillUpdate
@@ -81,6 +101,9 @@
       (.datasets
         (om/get-state owner :plot)
         #js [(js/Plottable.Dataset. (clj->js dataset))]))))
+
+(defn fitzhugh-nagumo [{:keys [alpha epsilon gamma Iapp]}]
+  (forward-euler-integrate [(fhn-dv alpha epsilon Iapp) (fhn-dw gamma)] {:v 0.64 :w 0} 0 1 0.001))

 (defn dashboard-view[app-state owner]
   (reify
@@ -95,13 +118,11 @@
             "ODE Solver in Clojurescript"))
         (dom/div
           #js {:className "dashboard-content"}
-          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-1] {:y 0} 0 10 0.01)])
-          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-t] {:y 0} 0 10 0.01)])
-          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-y] {:y 1} 0 10 0.01)])
-          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 10 0.01)])
-          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 10 0.1)])
-          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 100 0.1)])
-          (with-out-str (print (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 10 1)))
-          )))))
-
-
+          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-1] {:y 0} 0 10 0.01) "dy/dt = 1"])
+          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-t] {:y 0} 0 10 0.01) "dy/dt = t"])
+          (om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-y] {:y 1} 0 10 0.01) "dy/dt = y"])
+          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 10 0.5) "Circle, timestep of 0.5"])
+          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 1 :y2 0} 0 100 0.1) "Cricle, timestep of 0.1"])
+          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 5 :y2 0} 0 6.3 0.01) "Circle, timestep of 0.01"])
+          (om/build plotter [["y1" "y2"] (forward-euler-integrate [circle-dy1-dt circle-dy2-dt] {:y1 10 :y2 0} 0 6.3 0.001) "Circle timestep of 0.001"])
+          (om/build plotter [["v" "t"] (fitzhugh-nagumo {:alpha 0.2 :epsilon 0.01 :gamma 0.5 :Iapp 0.0}) "FitzHugh-Nagumo model"]))))))


pmap for go go fast

pmap for go go fast

--- src/com/billpiel/mem_tracer/string_output.clj
+++ src/com/billpiel/mem_tracer/string_output.clj
@@ -266,5 +266,5 @@

 (defn print-trees
   [trees]
-  (doall (map print-tree
-              trees)))
+  (doseq [o (pmap tree->string trees)]
+    (print o)))


Reverse order of checkout deps vs lib deps in classpath. Fixes #72.

--- src/leiningen/classpath.clj
+++ src/leiningen/classpath.clj
@@ -36,9 +36,9 @@
            (:test-path project)
            (:compile-path project)
            (:resources-path project)
-		   (:test-resources-path project)]
-          (find-lib-jars project)
-          (checkout-deps-paths project)))
+           (:test-resources-path project)]
+          (checkout-deps-paths project)
+          (find-lib-jars project)))

 (defn classpath
   "Print out the classpath in which the project operates, within the


Fixed parse-find for the file fact-test.

--- src/dda/pallet/crate/servertest/fact/file.clj
+++ src/dda/pallet/crate/servertest/fact/file.clj
@@ -46,9 +46,7 @@
                               (map #(clojure.string/split % #"'") (clojure.string/split file-resource #"\n"))))))
         existing-path-keys (keys maps)
         path-keys (map #(keyword %) paths)
-        non-existing-path-keys (seq (clojure.set/union
-                                      (clojure.set/difference (set existing-path-keys) (set path-keys))
-                                      (clojure.set/difference (set path-keys) (set existing-path-keys))))]
+        non-existing-path-keys (seq (clojure.set/difference (set path-keys) (set existing-path-keys)))]
     (merge
       maps
       (#(zipmap (map (fn [n] n) %) (repeat (count %) {:exists false}))


Using testing macro to avoid Eastwood failures

--- test/desdemona/plugins/swift_test.clj
+++ test/desdemona/plugins/swift_test.clj
@@ -1,5 +1,5 @@
 (ns desdemona.plugins.swift-test
-  (:require [clojure.test :refer [deftest is]]
+  (:require [clojure.test :refer [deftest testing is]]
             [cheshire.core :as json]
             [camel-snake-kebab.core :refer [->kebab-case-keyword]]
             [clojure.java.io :as io]
@@ -34,50 +34,50 @@
     (is (= token got))))

 (deftest authenticate-test
-  "This test verifies that the authenticate function makes a request to the
-  URL specified by the auth-url parameter, and includes the username and api-key
-  in the expected JSON format."
-  (http/with-fake-routes
-    {"http://authurl.com" {:post (fn [req]
-                                   (let [body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)
-                                         username (-> body :auth :rax-kskey:api-key-credentials :username)
-                                         api-key (-> body :auth :rax-kskey:api-key-credentials :api-key)]
-                                     {:status 200
-                                      :headers {}
-                                      :body (json/generate-string {:username username
-                                                                   :api-key api-key})}))}}
-    (let [result (swift/authenticate "http://authurl.com" "username" "apikey")]
-      (is (= {:username "username" :api-key "apikey"} result)))))
+  (testing "This test verifies that the authenticate function makes a request to the
+           URL specified by the auth-url parameter, and includes the username and api-key
+           in the expected JSON format."
+    (http/with-fake-routes
+      {"http://authurl.com" {:post (fn [req]
+                                     (let [body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)
+                                           username (-> body :auth :rax-kskey:api-key-credentials :username)
+                                           api-key (-> body :auth :rax-kskey:api-key-credentials :api-key)]
+                                       {:status 200
+                                        :headers {}
+                                        :body (json/generate-string {:username username
+                                                                     :api-key api-key})}))}}
+      (let [result (swift/authenticate "http://authurl.com" "username" "apikey")]
+        (is (= {:username "username" :api-key "apikey"} result))))))

 (deftest create-container-test
-  "This test verifies that the create-container function makes a request to the
-  URL specified, with the container-name in the path, and includes the given
-  auth token as a header."
-  (http/with-fake-routes
-    {"http://cf-url.com/containername" {:put (fn [req]
-                                               (let [token (-> req :headers (get "X-Auth-Token"))]
-                                                 (is (= "authtoken" token))
-                                                 {:status 200
-                                                  :headers {}
-                                                  :body ""}))}}
-    (let [result (swift/create-container "http://cf-url.com" "authtoken" "containername")]
-      (is (= 200 result)))))
+  (testing "This test verifies that the create-container function makes a request to the
+           URL specified, with the container-name in the path, and includes the given
+           auth token as a header."
+    (http/with-fake-routes
+      {"http://cf-url.com/containername" {:put (fn [req]
+                                                 (let [token (-> req :headers (get "X-Auth-Token"))]
+                                                   (is (= "authtoken" token))
+                                                   {:status 200
+                                                    :headers {}
+                                                    :body ""}))}}
+      (let [result (swift/create-container "http://cf-url.com" "authtoken" "containername")]
+        (is (= 200 result))))))

 (deftest write-file-test
-  "This test verifies that the write-file function makes a request to the URL
-  specified, with the container-name and file-name in the path, that it includes
-  the auth token as a header, and encodes the given contents as JSON."
-  (http/with-fake-routes
-    {"http://cf-url.com/containername/filename" {:put (fn [req]
-                                                        (let [token (-> req :headers (get "X-Auth-Token"))
-                                                              body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)]
-                                                          (is (= "authtoken" token))
-                                                          (is (= {:contents 123} body))
-                                                          {:status 200
-                                                           :headers {}
-                                                           :body ""}))}}
-    (let [result (swift/write-file "http://cf-url.com" "authtoken" "containername" "filename" {:contents 123})]
-      (is (= 200 result)))))
+  (testing "This test verifies that the write-file function makes a request to the URL
+           specified, with the container-name and file-name in the path, that it includes
+           the auth token as a header, and encodes the given contents as JSON."
+    (http/with-fake-routes
+      {"http://cf-url.com/containername/filename" {:put (fn [req]
+                                                          (let [token (-> req :headers (get "X-Auth-Token"))
+                                                                body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)]
+                                                            (is (= "authtoken" token))
+                                                            (is (= {:contents 123} body))
+                                                            {:status 200
+                                                             :headers {}
+                                                             :body ""}))}}
+      (let [result (swift/write-file "http://cf-url.com" "authtoken" "containername" "filename" {:contents 123})]
+        (is (= 200 result))))))

 (deftest calculate-container-name-test
   (freeze-time (t/date-time 2016 6 8 4 15 45 401)
@@ -90,13 +90,13 @@
                  (is (= "14:15:45-401" file-name)))))

 (deftest swift-write-rows-read-batch-test
-  "This test verifies that read-batch calls function/read-batch with the event
-  that is passed into it."
-  (with-redefs [function/read-batch (fn [event] event)]
-    (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
-          event {:event 1}
-          result (.read-batch record event)]
-      (is (= event result)))))
+  (testing "This test verifies that read-batch calls function/read-batch with the event
+           that is passed into it."
+    (with-redefs [function/read-batch (fn [event] event)]
+      (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
+            event {:event 1}
+            result (.read-batch record event)]
+        (is (= event result))))))

 (deftest swift-write-rows-write-batch-test
   (with-redefs [swift/authenticate (fn [auth-url username api-key]
@@ -130,17 +130,17 @@
       (is (= {:onyx.core/written? true} result)))))

 (deftest swift-write-rows-write-batch-empty-test
-  "This test verifies that a batch with no segments does not make any HTTP calls."
-  (let [record (swift/->SwiftWriteRows "url" "username" "apikey")
-        event {:onyx.core/results {:tree '()}}
-        result (.write-batch record event)]
-    (is (= {:onyx.core/written? true} result))))
+  (testing "This test verifies that a batch with no segments does not make any HTTP calls."
+    (let [record (swift/->SwiftWriteRows "url" "username" "apikey")
+          event {:onyx.core/results {:tree '()}}
+          result (.write-batch record event)]
+      (is (= {:onyx.core/written? true} result)))))

 (deftest swift-write-rows-seal-resource-test
-  "This test verifies that seal-resource does nothing."
-  (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
-        result (.seal-resource record :empty-event)]
-    (is (= {} result))))
+  (testing "This test verifies that seal-resource does nothing."
+    (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
+          result (.seal-resource record :empty-event)]
+      (is (= {} result)))))

 (deftest write-batch-test
   (let [pipeline-data {:onyx.core/task-map {:swift/auth-url "authurl"


added shantanus solution.

added shantanus solution.

--- integration/dda/pallet/dda_managed_vm/app/external_config.clj
+++ integration/dda/pallet/dda_managed_vm/app/external_config.clj
@@ -18,8 +18,9 @@
     [schema.core :as s]
     [clojure.string :as str]
     [clojure.edn :as edn]
-    [dda.config.commons.user-env :as user-env]
-    [keypin.core :refer [defkey letval] :as k]))
+    [keypin.core :refer [defkey letval] :as k]
+    [keypin.util :as ku]
+    [dda.config.commons.user-env :as user-env]))

 (def ExternalConfigSchema
   {:provisioning {:ip s/Str
@@ -38,34 +39,10 @@
   [file-name]
   (keyword (last (str/split file-name #"\."))))

-;TODO: works with keypin and additional recursive conversion protocols
-;TODO: source: https://groups.google.com/forum/#!topic/clojure/1NzLnWUtj0Q
-(defprotocol ConvertibleToClojure
-  (->clj [o]))
-(extend-protocol ConvertibleToClojure
-  java.util.Map
-  (->clj [o] (let [entries (.entrySet o)]
-               (reduce (fn [m [^String k v]]
-                         (assoc m (keyword k) (->clj v)))
-                       {} entries)))
-
-  java.util.List
-  (->clj [o] (vec (map ->clj o)))
-
-  java.lang.Object
-  (->clj [o] o)
-
-  nil
-  (->clj [_] nil))
-
-(defn as-clj-map
-  [m]
-  (->clj m))
-
 (defmulti parse-config dispatch-file-type)
 (defmethod parse-config :edn
   [file-path]
-  (as-clj-map (k/read-config [file-path])))
+  (ku/clojurize-data (k/read-config [file-path])))

 (defn ex-config
   "reads external edn-config"
@@ -73,7 +50,7 @@
   (parse-config user-config))

 (def user-config-path
-  "./user-config.edn")
+  "user-config.edn")

 (defn provisioning-ip []
   (let [file user-config-path]


Add login operation to API

Add login operation to API

--- src/madouc/handlers/api.clj
+++ src/madouc/handlers/api.clj
@@ -1,12 +1,17 @@
 (ns madouc.handlers.api
   (:require [ring.util.http-response :as http-resp]
             [compojure.api.sweet :refer :all]
-            [madouc.db :as db]))
+            [schema.core :as s]
+            [madouc.db :as db]
+            [madouc.controllers :refer :all]))

 (defapi handler-old
   (context "/api" []
     (GET "/status" [] (http-resp/ok {:api-status "ok"}))))

+(s/defschema LoginReq {:username String :password String})
+(s/defschema Token {:token String})
+(s/defschema APIError {:error String})

 (def handler
   (api
@@ -16,6 +21,11 @@
                             :description "API for the Madouc service"
                             :version "0.1.3"}}}}
    (context "/api" []
-    (GET "/status" [] (http-resp/ok {:api-status "ok"})))))
+     (GET "/status" [] (http-resp/ok {:api-status "ok"}))
+     (POST "/login" []
+       :responses {401 {:schema APIError :description "Unauthorized"}}
+       :return Token
+       :body [req LoginReq]
+       (login-controller req)))))


Update Ring-Codec dependency to 1.1.3

Update Ring-Codec dependency to 1.1.3

--- ring-core/project.clj
+++ ring-core/project.clj
@@ -5,7 +5,7 @@
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}
   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [ring/ring-codec "1.1.2"]
+                 [ring/ring-codec "1.1.3"]
                  [commons-io "2.6"]
                  [commons-fileupload "1.4"]
                  [crypto-random "1.2.0"]


added on-anim-change to make-app

added on-anim-change to make-app

--- src/maqueta/application.clj
+++ src/maqueta/application.clj
@@ -56,14 +56,15 @@
         (keys key-map))))

 (defn make-app
-  [& {:keys [root-node setup-fn update-fn show-settings
-             on-action on-analog on-anim-cycle-done]
-      :or {root-node nil
+  [& {:keys [show-settings root-node setup-fn update-fn
+             on-action on-analog on-anim-change on-anim-cycle-done]
+      :or {show-settings false
+           root-node nil
            setup-fn no-op
            update-fn no-op
-           show-settings false
            on-action {}
            on-analog {}
+           on-anim-change {}
            on-anim-cycle-done {}}}]
   (doto
       (proxy [SimpleApplication
@@ -87,7 +88,9 @@
           (if-let [callback (on-analog (name->keyword name))]
             (callback this value tpf)))
         (onAnimChange
-          [control channel name])
+          [control channel name]
+          (if-let [callback (on-anim-change name)]
+            (callback this control channel)))
         (onAnimCycleDone
           [control channel name]
           (if-let [callback (on-anim-cycle-done name)]


CMR-4418: Added handling of deleted collections during association index.

--- indexer-app/src/cmr/indexer/services/index_service.clj
+++ indexer-app/src/cmr/indexer/services/index_service.clj
@@ -357,7 +357,8 @@
         coll-concept (if (and need-to-index? (not assoc-to-latest-revision?))
                        (meta-db/get-concept context associated-concept-id associated-revision-id)
                        coll-concept)]
-    (when need-to-index?
+    (when (and need-to-index?
+               (not (:deleted coll-concept)))
       (let [parsed-coll-concept (cp/parse-concept context coll-concept)]
         (index-concept context coll-concept parsed-coll-concept options)))))


Support deeper namespaces betterer

Support deeper namespaces betterer

--- integration-tests/src/test/clojure/immutant/integs.clj
+++ integration-tests/src/test/clojure/immutant/integs.clj
@@ -71,7 +71,7 @@
 (defn from-property []
   "Gets the namespace to test from the system property 'ns'"
   (if-let [value (read-string (System/getProperty "ns"))]
-    (if (re-find #"\." (name value))
+    (if (re-find #"^immutant\.integs\." (name value))
       (list value)
       (list (symbol (str "immutant.integs." (name value)))))))


setting up keyword names

setting up keyword names

--- txf/pva-trans.clj
+++ txf/pva-trans.clj
@@ -1,3 +1,5 @@
+
+  :case_assess
 select
   a.case_id,
   a.listedness,
@@ -10,17 +12,18 @@
   b.effective_end_date,
   a.enterprise_id
 from
-  argusmart.rm_case_assess as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
+  rm_case_assess as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :case_classifications
 select
   a.enterprise_id,
   a.enterprise_id,
@@ -32,8 +35,8 @@
   b.effective_start_date,
   b.effective_end_date
 from
-  argusmart.rm_case_classifications as a,
-  argusmart.case_version_table as b
+  rm_case_classifications as a,
+  case_version_table as b
 where
   (a.case_id = b.case_id) and
   (a.effective_start_date <= b.effective_start_date) and
@@ -41,6 +44,7 @@

 --------------------

+  :case_event
 select
   a.enterprise_id,
   a.case_id,
@@ -101,17 +105,18 @@
   b.effective_start_date,
   b.effective_end_date
 from
-  argusmart.rm_case_event as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
+  rm_case_event as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :case_event_assess
 select
   a.case_id,
   a.prod_seq_num,
@@ -133,17 +138,18 @@
   b.effective_end_date,
   a.enterprise_id
 from
-  argusmart.rm_case_event_assess as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
+  rm_case_event_assess as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :case_followup
 select
   cf.case_id
   cf.seq_num
@@ -157,8 +163,8 @@
   cvt.effective_end_date
   cf.enterprise_id
 from
-  argusmart.rm_case_followup as cf,
-  argusmart.case_version_table as cvt
+  rm_case_followup as cf,
+  case_version_table as cvt
 where
   (cf.case_id = cvt.case_id) and
   (cf.enterprise_id = cvt.enterprise_id) and
@@ -168,6 +174,7 @@

 --------------------

+  :case_master
 select
   cm.case_id
   cm.global_num
@@ -202,8 +209,8 @@
   cvt.effective_end_date
   cm.enterprise_id
 from
-  argusmart.rm_case_master as cm,
-  argusmart.case_version_table as cvt
+  rm_case_master as cm,
+  case_version_table as cvt
 where
   (cvt.case_id = cm.case_id) and
   (cvt.effective_start_date >= convert(cm.effective_start_date,timestamp)) and
@@ -213,6 +220,7 @@

 --------------------

+  :case_narrative
 select
   a.enterprise_id
   a.case_id
@@ -224,8 +232,8 @@
   b.effective_start_date
   b.effective_end_date
 from
-  argusmart.rm_case_narrative as a,
-  argusmart.case_version_table as b
+  rm_case_narrative as a,
+  case_version_table as b
 where
   (a.case_id = b.case_id) and
   (a.effective_start_date <= b.effective_start_date) and
@@ -233,6 +241,7 @@

 --------------------

+  :case_pat_info
 select
   a.case_id
   a.age_group_id
@@ -247,17 +256,18 @@
   b.effective_end_date
   a.enterprise_id
 from
-  argusmart.rm_case_pat_info as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
+  rm_case_pat_info as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :case_prod_drugs
 select
   a.case_id
   a.seq_num
@@ -296,8 +306,8 @@
   a.first_dose_partial
   a.last_dose_partial
 from
-  argusmart.rm_case_prod_drugs as a,
-  argusmart.case_version_table as b
+  rm_case_prod_drugs as a,
+  case_version_table as b
 where
   (a.case_id = b.case_id) and
   (a.enterprise_id = b.enterprise_id) and
@@ -307,6 +317,7 @@

 --------------------

+  :case_product
 select
   cp.sdrug_not_admin
   cp.prod_reptd
@@ -330,8 +341,8 @@
   cp.enterprise_id
   cp.sort_id
 from
-  argusmart.rm_case_product as cp,
-  argusmart.case_version_table as cvt
+  rm_case_product as cp,
+  case_version_table as cvt
 where
   (cp.case_id = cvt.case_id) and
   (cp.enterprise_id = cvt.enterprise_id) and
@@ -341,6 +352,7 @@

 --------------------

+  :case_reporters
 select
   a.enterprise_id
   a.case_id
@@ -363,17 +375,18 @@
   b.effective_start_date
   b.effective_end_date
 from
-  argusmart.rm_case_reporters as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
+  rm_case_reporters as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :case_study
 select
   a.case_id
   a.blind_name
@@ -390,79 +403,85 @@
   b.effective_end_date
   a.enterprise_id
 from
-  argusmart.rm_case_study as a,
-  argusmart.case_version_table as b
-where
-  (a.case_id = b.case_id) and
-  (a.enterprise_id = b.enterprise_id) and
-  (a.deleted_flag = convert(0,bigdecimal)) and
-  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
-  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
-
---------------------
-
-select * from argusmart.rm_lm_case_classification
-
---------------------
-
-select * from argusmart.rm_lm_causality
-
---------------------
-
-select * from argusmart.rm_lm_countries
-
---------------------
-
-select
-  argusmart.rm_lm_product.enterprise_id
-  argusmart.rm_lm_product.product_id,
-  argusmart.rm_lm_product.prod_name
-  argusmart.rm_lm_product.family_id,
-  argusmart.rm_lm_product.formulation_id
-  argusmart.rm_lm_product.manufacturer_id,
-  argusmart.rm_lm_product.concentration
-  argusmart.rm_lm_product.conc_unit_id,
-  argusmart.rm_lm_product.indication_id
-  argusmart.rm_lm_product.code_dict,
-  argusmart.rm_lm_product.indication_text
-  argusmart.rm_lm_product.intl_birth_date,
-  argusmart.rm_lm_product.model_no
-  argusmart.rm_lm_product.drug_code,
-  argusmart.rm_lm_product.prod_generic_name
-  argusmart.rm_lm_product.ind_llt_code,
-  argusmart.rm_lm_product.ind_llt
-  argusmart.rm_lm_product.ind_hlt_code,
-  argusmart.rm_lm_product.ind_hlt
-  argusmart.rm_lm_product.ind_hlgt_code,
-  argusmart.rm_lm_product.ind_hlgt
-  argusmart.rm_lm_product.ind_soc_code,
-  argusmart.rm_lm_product.ind_soc
-  argusmart.rm_lm_product.ind_syn_code,
-  argusmart.rm_lm_product.ind_code_status
-  argusmart.rm_lm_product.prod_name_abbrv,
-  argusmart.rm_lm_product.ind_coded
-  argusmart.rm_lm_product.ind_reptd
-from
-  argusmart.rm_lm_product
-where
-  argusmart.rm_lm_product.deleted is null
-
---------------------
-
-select
-  argusmart.rm_lm_product_family.enterprise_id,
-  argusmart.rm_lm_product_family.family_id
-  argusmart.rm_lm_product_family.name,
-  argusmart.rm_lm_product_family.primary_view,
-  argusmart.rm_lm_product_family.product_group_id,
-  argusmart.rm_lm_product_family.deleted
-  argusmart.rm_lm_product_family.name_j
-from
-  argusmart.rm_lm_product_family
-
---------------------
-
-select * from argusmart.rm_lm_report_type
-
---------------------
-
+  rm_case_study as a,
+  case_version_table as b
+where
+  (a.case_id = b.case_id) and
+  (a.enterprise_id = b.enterprise_id) and
+  (a.deleted_flag = convert(0,bigdecimal)) and
+  (convert(a.effective_start_date,timestamp) <= b.effective_start_date) and
+  (convert(a.effective_end_date,timestamp) > b.effective_start_date)
+
+--------------------
+
+  :lm_case_classification
+select * from rm_lm_case_classification
+
+--------------------
+
+  :lm_causality
+select * from rm_lm_causality
+
+--------------------
+
+  :lm_countries
+select * from rm_lm_countries
+
+--------------------
+
+  :lm_product
+select
+  enterprise_id
+  product_id,
+  prod_name
+  family_id,
+  formulation_id
+  manufacturer_id,
+  concentration
+  conc_unit_id,
+  indication_id
+  code_dict,
+  indication_text
+  intl_birth_date,
+  model_no
+  drug_code,
+  prod_generic_name
+  ind_llt_code,
+  ind_llt
+  ind_hlt_code,
+  ind_hlt
+  ind_hlgt_code,
+  ind_hlgt
+  ind_soc_code,
+  ind_soc
+  ind_syn_code,
+  ind_code_status
+  prod_name_abbrv,
+  ind_coded
+  ind_reptd
+from
+  rm_lm_product
+where
+  deleted is null
+
+--------------------
+
+  :lm_product_family
+select
+  enterprise_id,
+  family_id
+  name,
+  primary_view,
+  product_group_id,
+  deleted
+  name_j
+from
+  rm_lm_product_family
+
+--------------------
+
+  :lm_report_type
+select * from rm_lm_report_type
+
+--------------------
+


Limit future parallelism in partition-records.

--- src/merkle_db/partition.clj
+++ src/merkle_db/partition.clj
@@ -122,34 +122,52 @@
         (::node/data)))))

+; TODO: copy of this method that uses futures moved to 'load' ns?
 (defn partition-records
   "Divides the given (possibly lazy) sequence of records into one or more
   partitions. Returns a sequence of node data for the persisted partitions."
   [store params records]
   (let [part-size (max-limit params)
-        threshold (+ part-size (min-limit params))]
-    ; TODO: callback on partition creation?
+        threshold (+ part-size (min-limit params))
+        save-part! (fn [rs]
+                     (future
+                       ; TODO: callback on partition creation?
+                       (printf "~") (flush)
+                       (let [start (System/nanoTime)
+                             part (from-records store params rs)
+                             elapsed (/ (- (System/nanoTime) start) 1e6)]
+                         (printf "%d records => part in %.2f ms\n"
+                                 (count rs) elapsed)
+                         (flush)
+                         part)))]
     (loop [partitions []
+           futures []
            pending []
            records (patch/remove-tombstones records)]
       (cond
+        ; Futures are full, so block.
+        (< 6 (count futures))
+          (recur (conj partitions @(first futures))
+                 (vec (rest futures))
+                 pending
+                 records)
         ; Enough pending records to serialize a full partition.
         (<= threshold (count pending))
           (let [[output remnant] (split-at part-size pending)
-                part (from-records store params output)]
-            (recur (conj partitions part) (vec remnant) records))
+                pending-part (save-part! output)]
+            (recur partitions (conj futures pending-part) (vec remnant) records))
         ; Pull next record into pending.
         (seq records)
-          (recur partitions (conj pending (first records)) (next records))
+          (recur partitions futures (conj pending (first records)) (next records))
         ; No more records, but too many pending to fit in one partition.
         (< part-size (count pending))
           (let [[output remnant] (split-at (int (Math/ceil (/ (count pending) 2))) pending)
-                part (from-records store params output)]
-            (recur (conj partitions part) (vec remnant) nil))
+                pending-part (save-part! output)]
+            (recur partitions (conj futures pending-part) (vec remnant) nil))
         ; Emit one final partition.
         :else
-          (let [part (from-records store params pending)]
-            (conj partitions part))))))
+          (let [part (save-part! pending)]
+            (concat partitions (map deref (conj futures part))))))))


components are now being closed

components are now being closed

--- storm-multicore/src/clj/backtype/storm/daemon/executor.clj
+++ storm-multicore/src/clj/backtype/storm/daemon/executor.clj
@@ -38,7 +38,6 @@
 ;
 ;
 ;(defmulti mk-executor-stats executor-selector)
-;(defmulti close-component executor-selector)
 ;
 ;
 ;(defn throttled-report-error-fn [executor]
@@ -76,11 +75,6 @@
 ;          [[nil (TupleImpl. worker-context [interval] Constants/SYSTEM_TASK_ID Constants/METRICS_TICK_STREAM_ID)]]))))))
 ;
 ;
-;(defmethod close-component :spout [executor-data spout]
-;  (.close spout))
-;
-;(defmethod close-component :bolt [executor-data bolt]
-;  (.cleanup bolt))
 ;
 ;;; TODO: refactor this to be part of an executor-specific map
 ;(defmethod mk-executor-stats :spout [_ rate]
@@ -91,6 +85,19 @@

 ;; Stuff below here should be ok
+
+(defn executor-selector [executor-data & _] (:type executor-data))
+
+(defmulti close-component executor-selector)
+(defmulti mk-threads executor-selector)
+
+
+(defmethod close-component :spout [executor-data spout]
+  (.close spout))
+
+
+(defmethod close-component :bolt [executor-data bolt]
+  (.cleanup bolt))

 (defn throttled-report-error-fn [executor]
@@ -296,10 +303,6 @@
                     clojurify-structure)]
     (merge storm-conf (apply dissoc spec-conf to-remove))
     ))
-
-
-(defn executor-selector [executor-data & _] (:type executor-data))
-(defmulti mk-threads executor-selector)

 (defn- tuple-execute-time-delta!
@@ -738,8 +741,8 @@
 ;        (doseq [user-context (map :user-context (vals task-datas))]
 ;          (doseq [hook (.getHooks user-context)]
 ;            (.cleanup hook)))
-;        (when @(:open-or-prepare-was-called? executor-data)
-;          (doseq [obj (map :object (vals task-datas))]
-;            (close-component executor-data obj)))
+        (when @(:open-or-prepare-was-called? executor-data)
+          (doseq [obj (map :object (vals task-datas))]
+            (close-component executor-data obj)))
         (log-message "Shut down executor " component-id ":" (pr-str executor-id)))
         )))


datamunging part1 (clojure)

datamunging part1 (clojure)

--- src/main/clojure/datamunging/datamunging0.clj
+++ src/main/clojure/datamunging/datamunging0.clj
@@ -1,4 +1,22 @@
-(ns datamunging.datamunging0)
+(ns datamunging.datamunging0
+  (:use [clojure.string :only [split]]
+        clojure.test))

-(def data (slurp "/Users/dima/IdeaProjects/katas/src/main/scala/ru/katas/n4/weather.dat"))
-(print data)
+(defn find-day-with-min-temperature-spread []
+  (defn file-as-string [] (slurp "/Users/dima/IdeaProjects/katas/src/main/scala/ru/katas/n4/weather.dat"))
+  (defn lines [] (drop 8 (drop-last 2 (seq (.split (file-as-string) "\n")))))
+  (defn data [] (map #(vec (.split (.trim %) "\\s+")) (lines)))
+  (defn temperatures []
+    (defn as-int [s] (. Integer parseInt (.replace s "*" "")))
+    (map #(vec [(nth % 0) (as-int (nth % 1)) (as-int (nth % 2))]) (data)))
+  (defn row-with-min-temperature-diff []
+    (apply min-key #(Math/abs (- (nth % 1) (nth % 2))) (temperatures)))
+
+  (nth (row-with-min-temperature-diff) 0)
+)
+
+
+(deftest should-find-day-with-min-temperature-spread
+  (is (= "14" (find-day-with-min-temperature-spread)))
+)
+(run-tests)


We need to parse the 2nd argument of 'generate', since it's an integer.

--- KataTrigrams/src/kata_trigrams/cli.clj
+++ KataTrigrams/src/kata_trigrams/cli.clj
@@ -15,7 +15,7 @@
       (if (= "index" action)
         (index arg1 arg2)
         (if (= "generate" action)
-          (generate arg1 arg2)
+          (generate arg1 (. Integer parseInt arg2))
           (do
             (println (str "Unknown action: '" action "'."))
             (System/exit 1)))))))


Make pages a list as claimed.

Make pages a list as claimed.

--- src/org/scode/sob/repos.clj
+++ src/org/scode/sob/repos.clj
@@ -26,7 +26,7 @@
         :last-scan 0
         :scan-interval 1
         :scan-checkpoint 0
-        :pages {}}))
+        :pages []}))

 (defn- now [] (System/currentTimeMillis))