Simplify 64361d8

Simplify 64361d8

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -182,20 +182,13 @@

 (defn- db-val->clj-val "Returns the Clojure value of given AttributeValue object."
   [^AttributeValue x]
-  (let [[type x*]
-        (or (when-let [x* (.getS  x)] [:s  x*])
-            (when-let [x* (.getN  x)] [:n  x*])
-            (when-let [x* (.getB  x)] [:b  x*])
-            (when-let [x* (.getSS x)] [:ss x*])
-            (when-let [x* (.getNS x)] [:ns x*])
-            (when-let [x* (.getBS x)] [:bs x*]))]
-    (case type
-      :s  (->> x*)
-      :n  (->> x* ddb-num-str->num)
-      :b  (->> x* nt-thaw)
-      :ss (->> x* (into #{}))
-      :ns (->> x* (mapv ddb-num-str->num) (into #{}))
-      :bs (->> x* (mapv nt-thaw)          (into #{})))))
+  (or (.getS x)
+      (some->> (.getN  x) ddb-num-str->num)
+      (some->> (.getSS x) (into #{}))
+      (some->> (.getNS x) (mapv ddb-num-str->num) (into #{}))
+      (some->> (.getBS x) (mapv nt-thaw)          (into #{}))
+      (some->> (.getB  x) nt-thaw) ; Last, may be falsey
+      ))

 (defn- clj-val->db-val "Returns an AttributeValue object for given Clojure value."
   ^AttributeValue [x]


more session updates

more session updates

--- src/tic_tac_toe/core.clj
+++ src/tic_tac_toe/core.clj
@@ -157,19 +157,25 @@
                       blank-board)]
          (response/content-type
           (assoc (response/response (get-board board))
-            :session (assoc session :board board)) "text/html" )))
+            :session (assoc session :board board))
+          "text/html" )))
   (GET "/dump-session" {session :session} {:body (str "waaaaaa " session)
                                            :session (assoc session :1 1)})
-  (GET "/place-piece/:pos/:piece" [pos piece]
-       (do
-         (swap! board place-piece (keyword piece) (Integer/parseInt pos))
-         (when (= :ongoing (get-game-state @board))
-           (swap! board place-piece :o (rand-nth (available-squares @board ))))
-
-         (let [players-turn  (place-piece (keyword piece) (Integer/parseInt pos))
-               computer-turn (place-piece :o (rand-nth (available-squares players-turn)))]
-
-         (resp/redirect "/")))
+  (GET "/place-piece/:pos/:piece"  {{pos :pos piece :piece} :params
+                                     session :session}
+
+         (let [players-turn  (place-piece (:board session) (keyword piece) (Integer/parseInt pos))
+               computer-turn (place-piece players-turn :o (rand-nth (available-squares players-turn)))
+               ]
+
+           (response/content-type
+            (assoc (response/response (get-board computer-turn))
+                                      :session (assoc session :board computer-turn))
+            "text/html")))
+
+
+  (GET "/clear" {session :session}
+       (assoc (response/response (str "" )) :session (assoc session :board blank-board)))
   (POST "/post" [] (do
                      (reset! board blank-board)
                      (resp/redirect "/")))


Workaround for browser-npm minified error

--- test/reagenttest/testreagent.cljs
+++ test/reagenttest/testreagent.cljs
@@ -968,10 +968,12 @@
     ;      :default #"Expected React component in: \[:> \[:div]]"
     ;      (rstr [:> [:div]])))
     ;; This is from React.createElement
+    ;; NOTE: browser-npm uses production cjs bundle for now which only shows
+    ;; the minified error
     (debug/track-warnings
       (wrap-capture-console-error
         #(is (thrown-with-msg?
-               :default #"Element type is invalid:"
+               :default #"(Element type is invalid:|Minified React error)"
                (rstr [:> [:div]])))))
     (is (thrown-with-msg?
          :default #"Invalid tag: 'p.'"


fixed another typo

fixed another typo

--- src/word_keeper/core.clj
+++ src/word_keeper/core.clj
@@ -46,4 +46,4 @@
 (defn -main [& args]
   (let [port (Integer/parseInt (get (System/getenv) "OPENSHIFT_CLOJURE_HTTP_PORT" "8080"))
         ip (get (System/getenv) "OPENSHIFT_CLOJURE_HTTP_IP" "0.0.0.0")]
-    (server/run-server (site #'routes) {:ip ip :port port})))
+    (run-server (site #'routes) {:ip ip :port port})))


Many small bug fixes

Many small bug fixes

--- src/nube/app.clj
+++ src/nube/app.clj
@@ -52,7 +52,7 @@

 (defn load-app-instances [app] (redis! (car/smembers (str app ":instances"))))
 (defn add-app-instance [app instance] (redis! (car/sadd (str app ":instances") instance) (notify-routers)))
-(defn remove-app-instance [app instance] (redis! (car/srem (str app ":instance") instance) (notify-routers)))
+(defn remove-app-instance [app instance] (redis! (car/srem (str app ":instances") instance) (notify-routers)))

 (defn load-hosts [] (redis! (car/smembers :hosts)))
 (defn add-host [host] (redis! (car/sadd :hosts host)))
@@ -94,7 +94,7 @@
   (rand-nth (vec (clojure.set/difference port-range (load-ports-in-use host)))))

 (defn load-container-by-host-and-port [host port]
-  (first (filter #(= port (:PublicPort (first (:Ports %)))) (get-containers host))))
+  (first (filter #(= port (str (:PublicPort (first (:Ports %))))) (get-containers host))))

 (defn stop-container [host id]
   (docker! :post host (str "containers/" id "/stop")))
@@ -131,7 +131,7 @@
     (println "Checking host health")
     (if-not (health-check-host host port)
       (do
-        ;(stop-container host id)
+        (stop-container host id)
         (throw (Exception. "Failed to deploy new instance.")))
       (try
         (println "Adding" (str host ":" port) "to router")
@@ -178,8 +178,8 @@

 (defn kill-app-instances [app]
   (doseq [instance (load-app-instances app)]
-    (let [[host port] instance]
-      kill-app-instance app host port)))
+    (let [[host port] (ssplit instance)]
+      (kill-app-instance app host port))))

 (defn describe []
   (into {} (for [app (load-apps)]
@@ -204,7 +204,7 @@
                          ["/add/" :env] #'add-app-env
                          ["/delete/" :env] #'remove-app-env}
                 "/logs" #'load-app-logs
-                "/kill" #'kill-app-instance}}])
+                "/kill" #'kill-app-instances}}])

 (defn controller-app [{:keys [params uri] :as req}]
   (if-let [{:keys [handler route-params] :as all} (match-route routes uri)]


Support arm usbhid lib.

Support arm usbhid lib.

--- src/org/playasophy/wonderdome/input/usb_hid.clj
+++ src/org/playasophy/wonderdome/input/usb_hid.clj
@@ -31,8 +31,9 @@
   []
   (let [arch (System/getProperty "os.arch")
         bits (condp re-find arch
-               #"32" 32
-               #"64" 64
+               #"32"  "32"
+               #"64"  "64"
+               #"arm" "arm"
                (throw (IllegalStateException.
                  (str "Unknown architecture bit size: " arch))))
         libname (str "hidapi-jni-" bits)]


Test ctor throws on invalid key

Test ctor throws on invalid key

Also, use public configuration key string for the encryption key.

--- test/clj/backtype/storm/security/serialization/BlowfishTupleSerializer_test.clj
+++ test/clj/backtype/storm/security/serialization/BlowfishTupleSerializer_test.clj
@@ -15,8 +15,15 @@
       "Throws RuntimeException when no encryption key is given.")
 )

+(deftest test-constructor-throws-on-invalid-key
+  ; The encryption key must be hexadecimal.
+  (let [conf {BlowfishTupleSerializer/SECRET_KEY "0123456789abcdefg"}]
+    (is (thrown? RuntimeException (new BlowfishTupleSerializer nil conf))
+        "Throws RuntimeException when an invalid encryption key is given.")
+  )
+)
+
 (deftest test-encrypts-and-decrypts-message
-
   (let [
         test-text (str
 "Tetraodontidae is a family of primarily marine and estuarine fish of the order"
@@ -32,7 +39,7 @@
 )
         kryo (new Kryo)
         arbitrary-key "7dd6fb3203878381b08f9c89d25ed105"
-        storm_conf {"topology.tuple.serializer.blowfish.key" arbitrary-key}
+        storm_conf {BlowfishTupleSerializer/SECRET_KEY arbitrary-key}
         writer-bts (new BlowfishTupleSerializer kryo storm_conf)
         reader-bts (new BlowfishTupleSerializer kryo storm_conf)
         buf-size 1024


GAWB-2189 : drop state from component-did-mount

--- src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
+++ src/cljs/main/broadfcui/page/workspace/method_configs/method_config_editor.cljs
@@ -41,8 +41,8 @@
              error (style/create-server-error-message error)
              :else [comps/Spinner {:text "Loading details..."}])))
    :component-did-mount
-   (fn [{:keys [this props state]}]
-     (react/call :load-agora-method this props state))
+   (fn [{:keys [this props]}]
+     (this :load-agora-method props))
    :load-agora-method
    (fn [{:keys [state]} method-ref]
      (endpoints/call-ajax-orch
@@ -52,7 +52,6 @@
                   (if success?
                     (swap! state assoc :loaded-method (get-parsed-response))
                     (swap! state assoc :error status-text)))}))})
-

 (defn- input-output-list [{:keys [values ref-prefix invalid-values editing? all-values]}]
   (create-section


Clarify error message.

Clarify error message.

--- web/src/immutant/web/async.clj
+++ web/src/immutant/web/async.clj
@@ -109,7 +109,7 @@
 (extend-protocol MessageDispatch
   Object
   (dispatch-message [message _ _]
-    (throw (IllegalStateException. (str "Can't pump source of type " (class message)))))
+    (throw (IllegalStateException. (str "Can't send message of type " (class message)))))

   nil
   (dispatch-message [_ ch options]


Final set of api tests, sans tests for group-by, group-by-key and flat-map-to-pair

--- test/flambo/api_test.clj
+++ test/flambo/api_test.clj
@@ -143,22 +143,36 @@
             f/collect) => [1 4 7 11 14])

       (fact
-        "fold returns aggregate each partition, and then the results for all the partitions,
-        using a given associative function and a neutral 'zero value'"
-        (-> (f/parallelize c [1 2 3 4 5])
-            (f/fold 0 (f/fn [x y] (+ x y)))) => 15)
-
-      #_(fact
-        "group-by"
-        (-> (f/parallelize c [["key1" 1]
-                              ["key1" 2]
-                              ["key2" 3]
-                              ["key2" 4]
-                              ["key3" 5]])
-            (f/group-by (f/fn [x] (first x)))
-            (f/map f/untuple)
-            f/collect
-            vec) => [["key1" [1 2]] ["key2" [3 4]] ["key3" [5]]])
+        "combine-by-key returns an RDD by combining the elements for each key using a custom
+        set of aggregation functions"
+        (-> (f/parallelize c [["key1" 1]
+                              ["key2" 1]
+                              ["key1" 1]])
+            (f/combine-by-key identity + +)
+            f/collect) => [["key1" 2] ["key2" 1]])
+
+      (fact
+        "sort-by-key returns an RDD of (K, V) pairs sorted by keys in asc or desc order"
+        (-> (f/parallelize c [[2 "aa"]
+                              [5 "bb"]
+                              [3 "cc"]
+                              [1 "dd"]])
+            (f/sort-by-key compare false)
+            f/collect) => [[5 "bb"] [3 "cc"] [2 "aa"] [1 "dd"]])
+
+      #_(fact
+        "coalesce"
+        (-> (f/parallelize c [1 2 3 4 5])
+            coalesce
+            f/collect) => [1 2 3 4 5])
+
+      #_(fact
+        "group-by returns an RDD of items grouped by the grouping function"
+        (-> (f/parallelize c [1 1 2 3 5 8])
+            (f/group-by (f/fn [x] (mod x 2)))
+            #_(f/map f/untuple)
+            f/collect
+            #_vec) => [[0 [2 8]] [1 [1 1 3 5]]])

       #_(fact
         "group-by-key"
@@ -170,7 +184,7 @@
             f/group-by-key
             (f/map f/double-untuple)
             f/collect
-            vec) => [])
+            vec) => [["key1" [1 2]] ["key2" [3 4]] ["key3" [5]]])

       #_(fact
         "flat-map-to-pair"
@@ -211,6 +225,12 @@
             (f/foreach (f/fn [x] x))) => nil)

       (fact
+        "fold returns aggregate each partition, and then the results for all the partitions,
+        using a given associative function and a neutral 'zero value'"
+        (-> (f/parallelize c [1 2 3 4 5])
+            (f/fold 0 (f/fn [x y] (+ x y)))) => 15)
+
+      (fact
         "first returns the first element of an RDD"
         (-> (f/parallelize c [1 2 3 4 5])
             f/first) => 1)


refactor test case on indexing docs

refactor test case on indexing docs

--- test/wb_es/core_test.clj
+++ test/wb_es/core_test.clj
@@ -29,34 +29,46 @@

 (use-fixtures :once wrap-setup)

-(defn index-docs [& docs]
+(defn index-doc [& docs]
   (let [formatted-docs (bulk/format-bulk "index" "test" docs)]
     (bulk/submit formatted-docs :refresh true)))

-(defn index-datomic-entity [entity]
-  (->> entity
-       (create-document)
-       (conj [])
-       (apply index-docs)))
+(defn index-datomic-entity [& entities]
+  (->> entities
+       (map create-document)
+       (apply index-doc)))

-(defn with-index [search-func]
+(defn with-default-options
+  "create a new search func that "
+  [search-func]
   (fn [& search-args]
-    (let [parameterized-search-func (partial search-func es-base-url index-name)]
-      (apply parameterized-search-func search-args))))
+    (let [[q options] search-args]
+      (search-func es-base-url
+                   index-name
+                   q
+                   (or options {})))))

-(def search (with-index web/search))
-(def autocomplete (with-index web/autocomplete))
+(def search (with-default-options web/search))
+(def autocomplete (with-default-options web/autocomplete))

-(deftest autocomplete-test
+(deftest clone-type-test
   (let [db (d/db datomic-conn)]
-    (testing "autocomplete by clone name"
-      (do
-        (index-datomic-entity (d/entity db [:clone/id "W02C12"]))
-        (let [first-hit (->> (search "W02C12" {})
+    (do
+      (index-datomic-entity (d/entity db [:clone/id "W02C12"]))
+      (testing "search by clone WBID"
+        (let [first-hit (->> (search "W02C12")
                              :hits
                              :hits
                              (first))]
           (is (= "W02C12" (get-in first-hit [:_source :wbid])))
           (is (= "clone" (get-in first-hit [:_type])))))
-      )))
+      (testing "autocomplete by clone WBID"
+        (let [hits (->> (autocomplete "W02C")
+                        :hits
+                        :hits)]
+          (is (some (fn [hit]
+                      (= "W02C12" (get-in hit [:_source :wbid])))
+                    hits)))
+        ))
+    ))


Fixing a namespace issue.

Fixing a namespace issue.


fixing the build

fixing the build


Tighten up Clojure STM example

Tighten up Clojure STM example

--- clojure/stm.clj
+++ clojure/stm.clj
@@ -1,13 +1,13 @@
+(use 'clojure.test)
+
 (def savings (ref 10000))
 (def checking (ref 500))

-(assert (and (= @savings 10000) (= @checking 500)))
-
-;(alter savings 200)
+(is (and (= @savings 10000) (= @checking 500)))

 (dosync
   (let [amount 100]
-    (alter savings - amount)
-    (alter checking + amount)))
+    (alter savings - amount)     ; alter savings by subtracting amount
+    (alter checking + amount)))  ; alter checking by adding amount

-(assert (and (= @savings 9900) (= @checking 600)))
+(is (and (= @savings 9900) (= @checking 600)))


Update dependencies

Update dependencies

--- mtg-pairings-server/project.clj
+++ mtg-pairings-server/project.clj
@@ -15,7 +15,7 @@
                  [korma "0.4.3"]
                  [mount "0.1.16"]
                  [org.postgresql/postgresql "42.2.5"]
-                 [hikari-cp "2.7.0"]
+                 [hikari-cp "2.7.1"]
                  [metosin/compojure-api "1.1.12"]
                  [org.flatland/ordered "1.5.7"]
                  [cheshire "5.8.1"]
@@ -24,7 +24,7 @@
                  [com.taoensso/timbre "4.10.0"]
                  [com.cognitect/transit-clj "0.8.313"]
                  [com.fzakaria/slf4j-timbre "0.3.12"]]
-  :plugins [[lein-asset-minifier "0.4.5"]
+  :plugins [[lein-asset-minifier "0.4.6"]
             [lein-cljfmt "0.6.4"]
             [lein-ancient "0.6.15"]
             [lein-garden "0.3.0" :exclusions [org.apache.commons/commons-compress]]]
@@ -99,10 +99,10 @@
                                        [com.cognitect/transit-cljs "0.8.256"]
                                        [com.andrewmcveigh/cljs-time "0.5.2"]
                                        [re-frame "0.10.6" :exclusions [cljsjs/react org.clojure/clojurescript]]
-                                       [binaryage/oops "0.6.4"]
-                                       [cljsjs/react "16.8.1-0"]
-                                       [cljsjs/react-dom "16.8.1-0"]
-                                       [cljsjs/react-dom-server "16.8.1-0"]
+                                       [binaryage/oops "0.7.0"]
+                                       [cljsjs/react "16.8.3-0"]
+                                       [cljsjs/react-dom "16.8.3-0"]
+                                       [cljsjs/react-dom-server "16.8.3-0"]
                                        [cljs-react-material-ui "0.2.50" :exclusions [org.clojure/clojurescript]]
                                        [cljsjs/prop-types "15.6.2-0"]
                                        [cljsjs/rc-slider "8.6.1-0"]


CMR-4343: Fix missing checks for synchronous parameter

--- bootstrap-app/src/cmr/bootstrap/api/routes.clj
+++ bootstrap-app/src/cmr/bootstrap/api/routes.clj
@@ -64,7 +64,7 @@
         provider-id (get provider-id-map "provider_id")
         start-index (Long/parseLong (get params :start_index "0"))
         result (bs/index-provider context dispatcher provider-id start-index)
-        msg (if
+        msg (if (synchronous? params)
               result
               (str "Processing provider " provider-id " for bulk indexing from start index "
                    start-index))]
@@ -78,7 +78,7 @@
         date-time (:date_time params)]
     (if-let [date-time-value (date-time-parser/try-parse-datetime date-time)]
       (let [result (bs/index-data-later-than-date-time context dispatcher date-time-value)
-            msg (if
+            msg (if (synchronous? params)
                   (:message result)
                   (str "Processing data after " date-time " for bulk indexing"))]
         {:status 202
@@ -93,7 +93,7 @@
         provider-id (get provider-id-collection-map "provider_id")
         collection-id (get provider-id-collection-map "collection_id")
         result (bs/index-collection context dispatcher provider-id collection-id)
-        msg (if
+        msg (if (synchronous? params)
               result
               (str "Processing collection " collection-id " for bulk indexing."))]
     {:status 202


Improve example project

Improve example project

--- examples/nightpad/src/nightpad/core.clj
+++ examples/nightpad/src/nightpad/core.clj
@@ -7,23 +7,23 @@
   (:gen-class))

 (defn init-completer!
-  [text-area]
-  (->> (editors/create-completer text-area "clj")
-       (editors/install-completer! text-area)))
+  [text-area extension]
+  (some->> (editors/create-completer text-area extension)
+           (editors/install-completer! text-area)))

 (defn create-window-content
-  []
+  [extension]
   (doto (editors/create-text-area)
-    (.setSyntaxEditingStyle (get editors/styles "clj"))
+    (.setSyntaxEditingStyle (get editors/styles extension))
     (.setTabSize 2)
-    init-completer!
+    (init-completer! extension)
     (editors/init-paredit! true true)
     (.setText "(println \"Hello, world!\")")))

 (defn create-window
   []
   (doto (s/frame :title "Nightpad"
-                 :content (create-window-content)
+                 :content (create-window-content "clj")
                  :on-close :exit
                  :size [800 :by 600])
     ; listen for keys while modifier is down


core: zipmap

core: zipmap


Doc string for `with-ns-aliases` explains why it doesn't load namespaces

--- test/com/nomistech/clojure_the_language/c_200_clojure_basics/s_500_namespaces.clj
+++ test/com/nomistech/clojure_the_language/c_200_clojure_basics/s_500_namespaces.clj
@@ -35,7 +35,10 @@
        ...]
   Symbols that have `alias-i` as their namespace have it replaced with
   `namepace-i`.
-  Does not load any namespaces."
+  Does not load any namespaces.
+  Note: One might arrgue that this should load namespaces, but that would be
+  bad -- better not to have side effects that would make things confusing
+  when doing REPL-based development."
   {:style/indent 1}
   [[& ns-alias-forms]
    & body]


Track any join code in mixpanel

Track any join code in mixpanel

--- frontend/routes.cljs
+++ frontend/routes.cljs
@@ -3,6 +3,7 @@
             [clojure.string :as str]
             [frontend.async :refer [put!]]
             [goog.events :as events]
+            [frontend.analytics.mixpanel :as mixpanel]
             [frontend.models.project :as proj-mod]
             [frontend.utils.docs :as doc-utils]
             [frontend.utils :as utils :include-macros true]
@@ -14,6 +15,8 @@
   (put! nav-ch [navigation-point (assoc args :inner? true)]))

 (defn open-to-outer! [nav-ch navigation-point args]
+  (when-let [join (-> args :query-params :join)]
+    (mixpanel/track "Has join code" {:join join}))
   (put! nav-ch [navigation-point (assoc args :inner? false)]))

 (defn logout! [nav-ch]


CMR-3691: Change the schema version in variable_util.clj to v1.10 to see if it can fix the CI build errors.

--- system-int-test/src/cmr/system_int_test/utils/variable_util.clj
+++ system-int-test/src/cmr/system_int_test/utils/variable_util.clj
@@ -16,7 +16,7 @@
    [cmr.transmit.echo.tokens :as tokens]
    [cmr.transmit.variable :as transmit-variable]))

-(def schema-version "1.9")
+(def schema-version "1.10")
 (def unique-index (atom 0))
 (def content-type "application/vnd.nasa.cmr.umm+json")
 (def default-opts {:accept-format :json


CMR-7854:Add subscription-job manual endpoint (#1457)

--- system-int-test/test/cmr/system_int_test/ingest/subscription_processing_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/subscription_processing_test.clj
@@ -73,7 +73,7 @@
                                     :items
                                     first
                                     :concept_id))
-           _ (echo-util/grant (urs-context)
+           _ (echo-util/grant (system/context)
                               [{:group_id user2-group-id
                                 :permissions [:read]}]
                               :catalog_item_identity
@@ -120,7 +120,7 @@

        (testing "given a valid time constraint, return the correct granules"
          (let [time-constraint "2016-01-02T00:00:00Z,2016-01-04T00:00:00Z"
-               system-context (urs-context)
+               system-context (system/context)
                result (->> (jobs/email-subscription-processing system-context time-constraint)
                            (first)
                            (second))]
@@ -190,7 +190,7 @@
                                     first
                                     :concept_id))

-           _ (echo-util/grant (urs-context)
+           _ (echo-util/grant (system/context)
                               [{:group_id user2-group-id
                                 :permissions [:read]}]
                               :catalog_item_identity
@@ -217,7 +217,7 @@

        (testing "First query executed does not have a last-notified-at and looks back 24 hours"
          (let [gran1 (create-granule-and-index "PROV1" coll1 "Granule1")
-               results (->> (urs-context)
+               results (->> (system/context)
                             (jobs/email-subscription-processing)
                             (map #(nth % 1))
                             flatten
@@ -228,7 +228,7 @@

        (testing "Second run finds only granules created since the last notification"
          (let [gran2 (create-granule-and-index "PROV1" coll1 "Granule2")
-               response (->> (urs-context)
+               response (->> (system/context)
                              (jobs/email-subscription-processing)
                              (map #(nth % 1))
                              flatten
@@ -242,7 +242,7 @@
            (ingest/delete-concept concept))
          (subscription-util/create-subscription-and-index coll1 "test_sub_prov1" "user2" "provider=PROV1")
          (is (= 2
-                (->> (urs-context)
+                (->> (system/context)
                      (jobs/email-subscription-processing)
                      (map #(nth % 1))
                      flatten
@@ -254,26 +254,26 @@
    (with-redefs
     [jobs/send-email mock-send-email]
      (testing "Tests subscriber-id filtering in subscription email processing job"
-       (let [user1-group-id (echo-util/get-or-create-group (urs-context) "group1")
+       (let [user1-group-id (echo-util/get-or-create-group (system/context) "group1")
            ;; User 1 is in group1
-             user1-token    (echo-util/login (urs-context) "user1" [user1-group-id])
-             _              (echo-util/ungrant (urs-context)
-                                               (-> (access-control/search-for-acls (urs-context)
+             user1-token    (echo-util/login (system/context) "user1" [user1-group-id])
+             _              (echo-util/ungrant (system/context)
+                                               (-> (access-control/search-for-acls (system/context)
                                                                                {:provider      "PROV1"
                                                                                :identity-type "catalog_item"}
                                                                                {:token "mock-echo-system-token"})
                                                    :items
                                                    first
                                                    :concept_id))
-             _              (echo-util/ungrant (urs-context)
-                                               (-> (access-control/search-for-acls (urs-context)
+             _              (echo-util/ungrant (system/context)
+                                               (-> (access-control/search-for-acls (system/context)
                                                                                {:provider      "PROV2"
                                                                                :identity-type "catalog_item"}
                                                                                {:token "mock-echo-system-token"})
                                                    :items
                                                    first
                                                    :concept_id))
-             _              (echo-util/grant (urs-context)
+             _              (echo-util/grant (system/context)
                                              [{:group_id    user1-group-id
                                                :permissions [:read]}]
                                              :catalog_item_identity
@@ -284,7 +284,7 @@
                                               :granule_identifier    {:access_value {:include_undefined_value true
                                                                                :min_value               1
                                                                                :max_value               50}}})
-             _              (echo-util/grant (urs-context)
+             _              (echo-util/grant (system/context)
                                              [{:user_type   :registered
                                                :permissions [:read]}]
                                              :catalog_item_identity
@@ -345,7 +345,7 @@
                                               {:token "mock-echo-system-token"})
              _              (index/wait-until-indexed)
              expected       (set [(:concept-id gran1) (:concept-id gran3)])
-             actual         (->> (urs-context)
+             actual         (->> (system/context)
                                  (jobs/email-subscription-processing)
                                  (map #(nth % 1))
                                  flatten


access service logs by using name

access service logs by using name

--- src/cljs/swarmpit/component/service/info/settings.cljs
+++ src/cljs/swarmpit/component/service/info/settings.cljs
@@ -176,7 +176,7 @@
         (comp/button
           {:size  "small"
            :color "primary"
-           :href  (routes/path-for-frontend :service-log {:id (:id service)})}
+           :href  (routes/path-for-frontend :service-log {:id (:serviceName service)})}
           "View log"))
       (comp/divider
         {})
@@ -184,4 +184,4 @@
         {:style {:paddingBottom "16px"}}
         (form/item-date (:createdAt service)
                         (:updatedAt service))
-        (form/item-id (:id service))))))+        (form/item-id (:id service))))))


Fix table stat collection.

Fix table stat collection.

--- lib/tools/src/merkle_db/tools/stats.clj
+++ lib/tools/src/merkle_db/tools/stats.clj
@@ -61,8 +61,8 @@
       (.store table)
       #{}
       (conj (clojure.lang.PersistentQueue/EMPTY)
-            (::data table)
-            (::patch table))
+            (::table/data table)
+            (::table/patch table))
       (fn [node]
         (let [data (::node/data node)]
           (case (:data/type data)
@@ -115,16 +115,19 @@
                                                  unknown-size
                                                  tablet-sizes))
         table-pct #(* (/ (double %) table-size) 100.0)
-        unit-str (fn [scale units n]
-                   (-> (->> (map vector (iterate #(/ (double %) scale) n) units)
-                            (drop-while #(< scale (first %)))
-                            (first))
-                       (as-> [n u]
-                         (if (integer? n)
-                           (format "%d%s" n (or u ""))
-                           (format "%.2f%s" (double n) (or u ""))))))
+        unit-str (fn unit-str
+                   [scale units n]
+                   (if (number? n)
+                     (-> (->> (map vector (iterate #(/ (double %) scale) n) units)
+                              (drop-while #(< scale (first %)))
+                              (first))
+                         (as-> [n u]
+                           (if (integer? n)
+                             (format "%d%s" n (or u ""))
+                             (format "%.2f%s" (double n) (or u "")))))
+                     (pr-str n)))
         byte-str (partial unit-str 1024 [" B" " KB" " MB" " GB" " TB" " PB"])
-        count-str (partial unit-str 1000 [nil " K" " M" " B" " T"])
+        count-str (partial unit-str 1000 ["" " K" " M" " B" " T"])
         stats-str (fn [data k f]
                     (format "min %s, mean %s, max %s"
                             (f (get-in data [k :min]))


Create a tiny shim main namespace to run the test-app at port 8080

--- src/main.clj
+++ src/main.clj
@@ -1,108 +1,4 @@
-; This is a temporary file that allows the use of "lein ring server"
-; to test the framework with a sample app.
+(ns main
+  (:use test-app ring.adapter.jetty))

-(ns main
-  (:use compojure.core cascade cascade.asset cascade.import ring.adapter.jetty)
-  (:require
-    :reload
-    [cascade.request :as cr]
-    [ring.util.response :as response]
-    [compojure.route :as route]
-    [compojure.handler :as handler]))
-
-(set! *warn-on-reflection* true)
-
-(defragment layout [title body]
-  (import-stylesheet classpath-asset "cascade/bootstrap.css")
-  (import-stylesheet file-asset "app.css")
-  :html [
-  :head>title [title]
-  :body>div.container [
-    :h1 [title]
-    body
-    :hr
-    :&copy " 2011 Howard M. Lewis Ship"
-    ]])
-
-(defn alert-message [level body]
-  (javascript-invoke ["cascade/bootstrap-alerts"] ".alert-message" "alert")
-  (markup
-    :div {:class [:alert-message level] :data-alert :alert} [
-    :a.close {:href "#"} ["x"]
-    :p [body]
-    ])
-  )
-
-(defview hello-world [req]
-  (javascript-invoke ["cascade/bootstrap-twipsy" "cascade/bootstrap-popover"] "#force-failure" "popover")
-  (layout "Cascade Hello World"
-    (markup
-      (alert-message :warning
-        (markup
-          :p [
-          "This page rendered at "
-          :strong [(str (java.util.Date.))]
-          "."
-          ]))
-      :div.well [
-      :a.btn.primary.large {:href "/hello"} ["Refresh"] " "
-      :a.btn {:href "/cascade/grid"} ["Grid Demo"] " "
-      :a.btn.danger#force-failure {:href "/hello/fail"
-                                   :title "Caution!"
-                                   :data-content "We force a divide by zero error to see Cascade's exception report."} ["Force Failure"]
-      ])))
-
-(defn grid-url
-  [width height]
-  (format "/cascade/grid/%d/%d" width height))
-
-(defragment add-button [
-  width height]
-  :a.btn {:href (grid-url width height)} ["+"])
-
-(defview grid [width height]
-  (layout "Grid Demo"
-    (markup
-      :div.well>a.btn.primary.large {:href "/hello"} ["Main"]
-      :h2 [width "x" height " Grid"]
-      :table.bordered-table.zebra-striped [
-      :thead>tr [
-        :th
-        (markup-for [column (range 1 (inc width))]
-          :th ["Column " column])
-        :th [(add-button (inc width) height)]
-        ]
-      :tbody [
-        (markup-for [row (range 1 (inc height))]
-          :tr [
-          :td ["# " row]
-          (markup-for [column (range 1 (inc width))]
-            :td>a {:href (grid-url column row)} ["Cell " column "x" row])
-          :td [:&nbsp]
-          ])
-        ]
-      :tfoot>tr [
-        :td [(add-button width (inc height))]
-        (markup-for [column (range (inc width))] :td [:&nbsp])
-        ]
-      ])))
-
-(defn parse-int [string]
-  (Integer/parseInt string))
-
-(defroutes html-routes
-  (GET "/hello" [] hello-world)
-  (GET "/cascade/grid" [] (grid 3 5))
-  (GET "/cascade/grid/:width/:height" [width height] (grid (parse-int width) (parse-int height)))
-  ; /hello/fail provokes an exception:
-  (GET "/hello/fail" [] (try (/ 0 0) (catch Exception e (throw (RuntimeException. "Failure dividing by zero." e))))))
-
-(defroutes master-routes
-  (cr/initialize "1.0"
-    :public-folder "webapp"
-    :html-routes html-routes)
-  (ANY "/" [] (response/redirect "/hello"))
-  (route/not-found "Cascade Demo: No such resource"))
-
-(def app
-  (handler/site master-routes))
+(run-jetty app {:port 8080})


CMR-1694: Added additional comments.

CMR-1694: Added additional comments.

--- virtual-product-app/src/cmr/virtual_product/services/virtual_product_service.clj
+++ virtual-product-app/src/cmr/virtual_product/services/virtual_product_service.clj
@@ -66,6 +66,7 @@
       (info (format "Ingested virtual granule [%s] with the following response: [%s]"
                     granule-ur (pr-str body)))

+      ;; Conflict (status code 409)
       ;; This would occurs when an ingest event with lower revision-id is consumed after an event with
       ;; higher revision id for the same granule. The event is ignored and the revision is lost.
       (= status 409)
@@ -136,6 +137,7 @@
       (info (format "Deleted virtual granule [%s] with the following response: [%s]"
                     granule-ur (pr-str body)))

+      ;; Not Found (status code 404)
       ;; This would occur if delete event is consumed before the concept creation event and
       ;; metadata-db does not yet have the granule concept. This usually means that an ingest event
       ;; for the same granule is present in the virtual product queue and is not yet consumed. The
@@ -158,6 +160,7 @@
                      "retried.")
                 granule-ur (pr-str body)))

+      ;; Conflict (status code 409)
       ;; This would occurs if a delete event with lower revision-id is consumed after an event with
       ;; higher revision id for the same granule. The event is ignored and the revision is lost.
       (= status 409)


randomize data a little better

randomize data a little better

--- POC/aggregation/tools/genAssessments/src/genAssessments/core.clj
+++ POC/aggregation/tools/genAssessments/src/genAssessments/core.clj
@@ -6,12 +6,12 @@
   (element :Student {}
            (element :StudentUniqueStateId {} (str id))
            (element :Name {}
-                    (element :FirstName {} (str "Kid" id))
-                    (element :LastSurname {} (str "Smith" id)))
-           (element :Sex {} "Male")
+                    (element :FirstName {} (rand-nth ["Nathan" "Gina" "Alan" "Morena" "Adam" "Jewel" "Sean" "Summer" "Ron"]))
+                    (element :LastSurname {} (rand-nth ["Fillion" "Torres" "Tudyk" "Baccarin" "Baldwin" "Staite" "Maher" "Glau" "Glass"])))
+           (element :Sex {} (rand-nth ["Male" "Female"]))
            (element :BirthData {}
-                    (element :BirthDate {} "2001-06-18"))
-           (element :HispanicLatinoEthnicity {} "false")
+                    (element :BirthDate {} (str "2001-" (format "%02d" (inc (rand-int 12))) "-" (format "%02d" (inc (rand-int 28))))))
+           (element :HispanicLatinoEthnicity {} (rand-nth ["true" "false"]))
            (element :Race {})))

 (defn get-perf-level


Tweak history handling in demo

Tweak history handling in demo

--- demo/sitetools/core.cljs
+++ demo/sitetools/core.cljs
@@ -43,8 +43,9 @@
     :goto-page (let [path x
                      _ (assert (string? path))]
                  (when-some [h history]
-                   (.setToken h x)
-                   (r/after-render #(set! js/document.body.scrollTop 0))
+                   (r/after-render (fn []
+                                     (.setToken h x)
+                                     (js/scrollTo 0 0)))
                    state)
                  (recur state [:set-page x]))))

@@ -76,7 +77,8 @@
                                           (string/replace #"/*$" ""))))
                     (History.)))
         (evt/listen EventType.NAVIGATE #(when (.-isNavigation %)
-                                          (emit [:set-page (.-token %)])))
+                                          (emit [:set-page (.-token %)])
+                                          (r/flush)))
         (.setEnabled true))
       (let [token (.getToken history)
             p (if (and page (not html5) (empty? token))


CMR-1319: Addressed review comments by Leo

--- system-int-test/test/cmr/system_int_test/search/collection_spatial_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_spatial_search_test.clj
@@ -318,11 +318,11 @@
            [-5.95,-23.41,12.75,-23.69,11.11,-10.38,-6.62,-10.89,-5.95,-23.41]
            [whole-world polygon-with-holes-cart wide-south-cart normal-poly-cart]))

-    (testing "multiple bounding-box searches"
-      (are [wnes1 wnes2 items]
+    (testing "multiple bounding-box searches should returns collections which intersect all the
+             supplied bounding boxes"
+      (are [wnes-vec items]
            (let [found (search/find-refs :collection {:bounding-box
-                                                      [(codec/url-encode (apply m/mbr wnes1))
-                                                       (codec/url-encode (apply m/mbr wnes2))]
+                                                      (map #(codec/url-encode (apply m/mbr %)) wnes-vec)
                                                       :page-size 50})
                  matches? (d/refs-match? items found)]
              (when-not matches?
@@ -330,22 +330,35 @@
                (println "Actual:" (->> found :refs (map :name) sort pr-str)))
              matches?)

-           [-23.43 5 25.54 -6.31]
-           [-1.74 47.05 5.27 44.04]
+           [[-23.43 5 25.54 -6.31]]
+           [whole-world polygon-with-holes normal-poly normal-brs]
+
+           [[-1.74 47.05 5.27 44.04]]
+           [whole-world wide-north]
+
+           [[-23.43 5 25.54 -6.31]
+            [-1.74 47.05 5.27 44.04]]
            [whole-world]))

-    (testing "multiple polygon searches"
-      (are [ords1 ords2 items]
-           (let [found (search/find-refs :collection {:polygon [(apply search-poly ords1)
-                                                                (apply search-poly ords2)]})
+    (testing "multiple polygon searches should return collections which intersect all the supplied
+             bounding boxes"
+      (are [ords-vec items]
+           (let [found (search/find-refs :collection {:polygon
+                                                      (map (partial apply search-poly) ords-vec)})
                  matches? (d/refs-match? items found)]
              (when-not matches?
                (println "Expected:" (->> items (map :entry-title) sort pr-str))
                (println "Actual:" (->> found :refs (map :name) sort pr-str)))
              matches?)

-           [58.41,76.95,163.98,80.56,-122.99,81.94,-26.18,82.82,58.41,76.95]
-           [-161.53,-69.93,25.43,-51.08,13.89,-39.94,-2.02,-40.67,-161.53,-69.93]
+           [[58.41,76.95,163.98,80.56,-122.99,81.94,-26.18,82.82,58.41,76.95]]
+           [whole-world on-np touches-np north-pole very-tall-cart along-am-line]
+
+           [[-161.53,-69.93,25.43,-51.08,13.89,-39.94,-2.02,-40.67,-161.53,-69.93]]
+           [whole-world on-sp wide-south touches-sp south-pole very-tall-cart]
+
+           [[58.41,76.95,163.98,80.56,-122.99,81.94,-26.18,82.82,58.41,76.95]
+            [-161.53,-69.93,25.43,-51.08,13.89,-39.94,-2.02,-40.67,-161.53,-69.93]]
            [whole-world very-tall-cart]))

     (testing "AQL spatial search"


State.

State.

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_030_refs.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_030_refs.clj
@@ -16,16 +16,16 @@
 ;;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ;;;; `ref`, `dosync`, `alter`

-(def bank-account-1-atom (ref 100))
-(def bank-account-2-atom (ref 200))
+(def bank-account-1-ref (ref 100))
+(def bank-account-2-ref (ref 200))

 (fact
   (let [amount 20]
     (dosync
-     (alter bank-account-1-atom + amount)
-     (alter bank-account-2-atom - amount))
-    [@bank-account-1-atom
-     @bank-account-2-atom])
+     (alter bank-account-1-ref + amount)
+     (alter bank-account-2-ref - amount))
+    [@bank-account-1-ref
+     @bank-account-2-ref])
   => [120
       180])


Fix some bugs in pixel-pusher display.

Fix some bugs in pixel-pusher display.

--- src/org/playasophy/wonderdome/display/pixel_pusher.clj
+++ src/org/playasophy/wonderdome/display/pixel_pusher.clj
@@ -26,7 +26,7 @@
 (defn- set-pixels!
   "Renders a sequence of pixel colors to an LED strip."
   [^Strip strip colors]
-  (dorun (map #(when %2 (.setPixel strip (int %1) (unchecked-int %2)))
+  (dorun (map #(when %2 (.setPixel strip (unchecked-int %2) (int %1)))
               (range (.getLength strip))
               colors)))

@@ -42,22 +42,14 @@
   (start
     [this]
     (log/info "Starting PixelPusher display...")
-    (when-not running
-      (doto registry
-        (.addObserver (registry-observer registry strips))
-        (.startPushing)
-        (.setExtraDelay 0)
-        (.setAutoThrottle true)))
+    (.startPushing registry)
     (assoc this :running true))

   (stop
     [this]
     (log/info "Stopping PixelPusher display...")
-    (doto registry
-      (.deleteObservers)
-      (.stopPushing))
-    (reset! strips [])
+    (.stopPushing registry)
     (assoc this :running false))

@@ -74,4 +66,10 @@
   "Creates a new display streaming color commands to connected pixel-pusher
   hardware."
   []
-  (PixelPusherDisplay. (DeviceRegistry.) (atom []) false))
+  (let [registry (DeviceRegistry.)
+        strips (atom [])]
+    (doto registry
+      (.addObserver (registry-observer registry strips))
+      (.setExtraDelay 0)
+      (.setAutoThrottle true))
+    (PixelPusherDisplay. registry strips false)))


Update interpreter.clj

Update interpreter.clj

--- src/simple_symbolic_regression_clojure/interpreter.clj
+++ src/simple_symbolic_regression_clojure/interpreter.clj
@@ -75,4 +75,4 @@
     score-penalty))

 (defn total-score-on [script rubrics]
-  (reduce + (map (partial score-on script) rubrics)))
+  (future (reduce + (map (partial score-on script) rubrics))) (deref rubrics))


Remove self-tests about Assertions

Remove self-tests about Assertions

--- src/test/clojure/com/stuartsierra/lazytest_asserts.clj
+++ src/test/clojure/com/stuartsierra/lazytest_asserts.clj
@@ -7,11 +7,7 @@
 ;;; SELF-TESTS

 ;; Assertions
-(def a1 (assertion [a] (pos? a)))
-
-(assert (= :com.stuartsierra.lazytest/AssertionPassed (type (a1 1))))
-(assert (= :com.stuartsierra.lazytest/AssertionFailed (type (a1 -1))))
-(assert (= :com.stuartsierra.lazytest/AssertionThrown (type (a1 "string"))))
+(def a1 pos?)

 ;; Contexts
 (def c1 (Context nil nil nil))
@@ -48,7 +44,7 @@
            (type (first (:children (run-test-case t2))))))

 ;; TestCase with multiple Contexts
-(def a2 (assertion [x y] (< x y)))
+(def a2 <)

 (def t3 (TestCase [c2 c4] [a2 a2]))

@@ -65,9 +61,9 @@
   `(binding [*log* (atom [])]
      ~@body))

-(def a3 (assertion [x] (log :a3) (pos? x)))
+(def a3 (fn [x] (log :a3) (pos? x)))

-(def a4 (assertion [x] (log :a4) (pos? x)))
+(def a4 (fn [x] (log :a4) (pos? x)))

 (def c5 (Context [] (fn [] (log :c5-open) 5)
                  (fn [x] (assert (= x 5)) (log :c5-close))))
@@ -120,18 +116,6 @@
     (dorun (result-seq results))
     (assert (= @*log* [:c6-open :a3 :a4 :a3 :a4]))))

-;; defassert form
-(defassert a5 "Assertion a5" [a b]
-  (comment "stuff")
-  (< a b))
-
-(assert (fn? a5))
-(assert (= 'a5 (:name (meta a5))))
-(assert (= *ns* (:ns (meta a5))))
-(assert (= "Assertion a5" (:doc (meta a5))))
-(assert (= :com.stuartsierra.lazytest/AssertionPassed (type (a5 1 2))))
-(assert (= :com.stuartsierra.lazytest/AssertionFailed (type (a5 2 1))))
-(assert (= :com.stuartsierra.lazytest/AssertionThrown (type (a5 "a" "b"))))

 ;; defcontext form
 (defcontext c7 "Context c7" [s5 c5]
@@ -175,37 +159,31 @@
 (assert (= [c4 c5] (:contexts t11)))
 (assert (= [t9 t10] (:children t11)))

-;; Assertions can be compiled on-the-fly
-(def t12 (TestCase [c2] [(Assertion '[a] '(= a 2))
-                         (Assertion '[a] '(> a 1))]))
-(assert (success? (t12)))
+;; README examples
+;;     (defassert positive [x] (pos? x))
+;;     (success? (positive 1))
+;;     ;;=> true
+;;     (success? (positive -1))
+;;     ;;=> false
+;;     (success? (positive "hello"))
+;;     ;;=> false
+;;     (deftest addition [a 1, b 2]
+;;       (integer? a)
+;;       (integer? b)
+;;       (integer? (+ a b)))
+;;     (success? (addition))
+;;     ;;=> true
+;;     (defcontext random-int []
+;;       (rand-int Integer/MAX_VALUE))
+;;     (deftest random-addition [a random-int, b random-int]
+;;       (integer? (+ a b))
+;;       (= (+ a b) (+ b a)))

+;;     (success? (random-addition))

-;; README examples
-    (defassert positive [x] (pos? x))
-    (success? (positive 1))
-    ;;=> true
-    (success? (positive -1))
-    ;;=> false
-    (success? (positive "hello"))
-    ;;=> false
-    (deftest addition [a 1, b 2]
-      (integer? a)
-      (integer? b)
-      (integer? (+ a b)))
-    (success? (addition))
-    ;;=> true
-    (defcontext random-int []
-      (rand-int Integer/MAX_VALUE))
-    (deftest random-addition [a random-int, b random-int]
-      (integer? (+ a b))
-      (= (+ a b) (+ b a)))
+;;     (deftest failure "This test always fails." [] (= 1 0))

-    (success? (random-addition))
+;;     (defsuite all-tests [] addition random-addition failure)

-    (deftest failure "This test always fails." [] (= 1 0))
-
-    (defsuite all-tests [] addition random-addition failure)
-
-    (success? (all-tests))
-    ;;=> false
+;;     (success? (all-tests))
+;;     ;;=> false


CMR-6988: Fixed intermittent variable-save-test failure in CI build.

--- metadata-db-app/int-test/cmr/metadata_db/int_test/concepts/variable_save_test.clj
+++ metadata-db-app/int-test/cmr/metadata_db/int_test/concepts/variable_save_test.clj
@@ -56,7 +56,13 @@
       (let [concept3 (assoc concept1 :provider-id "PROV2")
             {:keys [errors status concept-id revision-id]} (util/save-concept concept3)]
         (is (= status 409))
-        (is (= errors ["Variable [V1200000003-PROV2] and collection [C1200000000-PROV1] can not be associated because they do not belong to the same provider."])))
+        (is (re-matches
+             (re-pattern (str "Variable \\[V.*-PROV2\\] and collection \\["
+                              coll-concept-id
+                              "\\] can not be associated because they do not belong to the same provider."))
+             (first errors)))))
+
+    (testing "save variable with the same native-id, different variable name on the same provider"
       (let [concept4-var-name "different-variable-name"
             concept4 (update concept1 :extra-fields assoc :variable-name concept4-var-name)]
         (testing (str "save variable with the same native id, but a different variable name "


adding documentation for the frontend cljs code; loading the chunks not via the on-js-reload function but globally so it also loads in production

--- src-cljs/bitfondue/core.cljs
+++ src-cljs/bitfondue/core.cljs
@@ -7,6 +7,10 @@

 (defonce app-state (atom {:text "Hello world!"}))
 (defonce chunks-state (atom '()))
+
+;; ---
+;; View Template
+;; ---

 (defn hello-world []
   [:h1 (:text @app-state)])
@@ -24,8 +28,9 @@
    [hello-world]
    [chunks]])

-(reagent/render-component [layout]
-                          (. js/document (getElementById "app")))
+;; ---
+;; Load data from the API
+;; ---

 (defn chunks-success-handler
   [response]
@@ -42,6 +47,13 @@
                   :handler chunks-success-handler
                   :error-handler chunks-error-handler}))

+;; render the dom
+(reagent/render-component [layout]
+                          (. js/document (getElementById "app")))
+
+;; load the data from the API
+(fetch-chunks)
+
 (defn on-js-reload []
   ;; optionally touch your app-state to force rerendering depending on
   ;; your application


Use a better name for the channel that receives the response

--- src/io/aviso/rook/server.clj
+++ src/io/aviso/rook/server.clj
@@ -173,7 +173,7 @@
                          timeout-control-ch (chan 1)
                          request' (assoc request :timeout-ch timeout-ch
                                                  :timeout-control-ch timeout-control-ch)
-                         handler-ch (handler request')]
+                         response-ch (handler request')]
                      (log-response
                        (loop [timeout-ch' timeout-ch]
                          (alt!
@@ -203,14 +203,14 @@
                                          (l/warn message)
                                          (utils/failure-response HttpServletResponse/SC_GATEWAY_TIMEOUT "timeout" message))

-                           handler-ch ([response]
-                                        (or response
-                                            (do
-                                              (l/debugf "Handler for %s closed response channel." (utils/summarize-request request))
-                                              not-found-response)))
+                           response-ch ([response]
+                                         (or response
+                                             (do
+                                               (l/debugf "Handler for %s closed response channel." (utils/summarize-request request))
+                                               not-found-response)))

                            ;; In testing at least, the close of the control channel and returning nil (closing
-                           ;; the response channel) can happen close enough together that the handler-ch
+                           ;; response-ch) can happen close enough together that the handler-ch
                            ;; wins over the timeout-control-ch, resulting in a 404 response not a 504.
                            :priority true)))))))


Fixed two errors in object name

Fixed two errors in object name

--- resources/rules/post_identifier_merge/temp/hp/hp_phenotype_ice_to_bio.clj
+++ resources/rules/post_identifier_merge/temp/hp/hp_phenotype_ice_to_bio.clj
@@ -10,7 +10,7 @@
          (?/phenotype_sc rdfs/label ?/human_phenotype_label)

          ;; create a sublcass of the participating bioentity
-         (?/bioentity_sc rdfs/subClassOf ?/bioentity)
+         (?/bioentity_sc rdfs/subClassOf ?/participating_bioentity)
          ;; create a label for the bioentity subclass
          (?/bioentity_sc rdfs/label ?/bioentity_sc_label)

@@ -38,7 +38,7 @@
          (?/bioentity_field_value rdf/type ?/bioentity_ice_id)
          (?/bioentity_ice_id obo/IAO_0000219 ?/participating_bioentity)) ; IAO:denotes

-  :reify ([?/phenotype_sc {:ln (:sha-1 ?/human_phenotype ?/participation_restriction)
+  :reify ([?/phenotype_sc {:ln (:sha-1 ?/human_phenotype ?/participating_bioentity)
                  :ns "ccp" :prefix "PHENO_"}]
           [?/bioentity_sc {:ln (:sha-1 ?/human_phenotype ?/participating_bioentity)
                     :ns "ccp" :prefix "B_"}]


fix bug with watched delete on files

fix bug with watched delete on files

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/lt/objs/editor/pool.cljs
+++ src/lt/objs/editor/pool.cljs
@@ -47,7 +47,7 @@
 (defn by-path [path]
   (when path
     (let [path (string/lower-case path)]
-      (filter #(= (-> @% :info (get :path "") string/lower-case) path) (object/by-tag :editor)))))
+      (filter #(= (-> @% :info (get :path) (or "") string/lower-case) path) (object/by-tag :editor)))))

 (defn containing-path [path]
   (let [path (string/lower-case path)]
@@ -149,8 +149,8 @@
 (behavior ::watched.delete
           :triggers #{:watched.delete}
           :reaction (fn [ws del]
-                      (if (files/file? del)
-                        (when-let [ed (first (by-path del))]
+                      (if-let [ed (first (by-path del))]
+                        (do
                           (warn-delete ed)
                           (make-transient-dirty ed)
                           (when-let [ts (:lt.objs.tabs/tabset @ed)]
@@ -174,7 +174,7 @@
                           (when-let [ts (:lt.objs.tabs/tabset @ed)]
                             (object/raise ts :tab.updated)))
                         (let [old-folder (str old files/separator)
-                              open (filter #(= 0 (.indexOf (-> @% :info (get :path "")) old-folder)) (object/by-tag :editor))]
+                              open (filter #(= 0 (.indexOf (-> @% :info (get :path) (or "")) old-folder)) (object/by-tag :editor))]
                           (doseq [ed open
                                   :let [neue-path (string/replace (-> @ed :info :path) old neue)]]
                             (object/update! ed [:info] assoc :path neue-path :name (files/basename neue-path))


Content tweak.

Content tweak.

- That 'On VIM' post needs a lot of work. Some of it is wrong, the rest not
  expressed that well...
- hiccup as a markdown substitute is a bit painful, around inserting quotes for
  the content of [:b] elements, for example. Back to Markdown and its pipeline
  idiocy?
- the current pipeline (I think around the apostrophe replacement?) is eating
  the letter i in it's

--- resources/fragments/onvim.clj
+++ resources/fragments/onvim.clj
@@ -15,5 +15,5 @@
     [:li "Going backwards through text or shrinking text selections seems arbitrarily hard"]
     [:li "The God-damned pound symbol (aka why I gave up on Emacs more than once) and how it works properly on the commandline for arbitrary reasons, but other keypresses just don't (forward & back in the repl?)"]
     [:li "You can't contract selections, only expand them (cf. Drew Neil again, c. 47:30). BOOOOO."]
-    [:li "Inadvertent deletions: the delete key 'd' is on the home row in command mode, and idly resting your fingers there on a sensitive keyboard, then performing a motion without noticing you've pressed d first, means part of your work can be deleted without realising. This has happened me enough times to be embarrassing."]]]]]
-
+    [:li "Inadvertent deletions: the delete key 'd' is on the home row in command mode, and idly resting your fingers there on a sensitive keyboard, then performing a motion without noticing you've pressed d first, means part of your work can be deleted without realising. This has happened me enough times to be embarrassing."]
+    [:li "Inadvertent deletions, part two: The delete key 'd' is also the second half of the Spacemacs escape-analogue 'fd' which cancels the current mode or action, returning you to command mode. Unless you're in neotree, in which case it ignores the f, interprets the d as delete, and pops up a small are-you-sure y/n prompt - so if your next task is to " [:b "y"]"ank something... poof!"]]]]]


Clean up right-splititng logic

Clean up right-splititng logic

--- src/angelic/search/implicit/fah_astar_eval2.clj
+++ src/angelic/search/implicit/fah_astar_eval2.clj
@@ -19,19 +19,22 @@
 ;; Here we properly deal with weirdness of stubs/inner-sps decreaseing as they add
 ;; children, by makig sure to do the updates synchronously.

+;; Compared to old dash_astar_summary:
+;;  excluded-child-set went away, since we're now eager about pushing new outputs
+;;   output-constraints went away since we have refine-input.
+
+
 ;; TODO: find cleaner overall architecture.  Right now, names
 ;;   don't really do anything, and there's too much worrying about types, etc.
 ;;   Solution may be to have Generator (takes place of name) --> Stub --> SP.
 ;;   Generator knows how to take input set and produce stub., etc.
 ;;   For now, seems like too much complexity for too little gain.

-;; TODO: tail caching?
-;; TODO: cache refine-inputs and/or other SPs.
-;; TODO: encapsulate stub/sp behaviors somehow.
+;; TODO: tail (i.e., pair) caching?
+;; TODO: cache refine-inputs?
+;; TODO: cache children of output-collector?
 ;; TODO: garbage collect dead stuff

-;; TODO: remove extra stub indirection step when not needed?
-;; (i.e., either reverse directions, or just have get-stub-output when known..)
 ;; TODO: pessimistic

 ;; TODO: pseudo-solve
@@ -43,9 +46,6 @@

 ;; TODO: add options to search alg.

-;; TODO: think about relation to old dash_astar_summary --
-;;   i.e. where did excluded-child-set go ?
-;;   where did output-constraints go ?

 (set! *warn-on-reflection* true)
@@ -238,13 +238,9 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;     Wrappers     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-;; TODO: simplify these, avoid extra stub steps when possible ?
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;     Output Collection     ;;;;;;;;;;;;;;;;;;;;;;;;;;

-
-;; TODO: collect children too ?
 (declare make-output-collecting-subproblem)
 (defn make-output-collecting-stub [inner-stub]
   (assert (not (= (first (stub-name inner-stub)) :OS)))
@@ -258,11 +254,11 @@
   (util/assert-is (= (state/current-context s1) (state/current-context s2)) "%s" [s1 s2])
   (= s1 s2))

-;; TODO: is refine-input right ?
 (defn make-output-collecting-subproblem [stb inner-sp]
   (let [ts  (tree-summarizer inner-sp)
-        ret (traits/reify-traits ;; TODO: RI correct?
-             [(simple-subproblem stb (output-set inner-sp) ts false #(refine-input inner-sp %2))]
+        ret (traits/reify-traits
+             [(simple-subproblem stb (output-set inner-sp) ts false
+                                 #(doto (refine-input inner-sp %2) (-> stub-name first #{:SA :OS} assert)))]
              summaries/Summarizable (summarize [s] (summaries/or-summary s (top-down-bound ts))))]
     (connect-and-watch! ret inner-sp
       (fn child-watch [o]
@@ -407,9 +403,9 @@
 ;; TODO TODO: we should not use tree-summarizer when left-done
 ;; How do we know that current output set is actually solved ?
 ;; TODO: remove ss ?
-;; Note: this is the only place logic depends on summary.  Potential for problems?
+;; Note: this is the only place logic depends on summary.  Potential for problems?
 (defn- make-pair-subproblem [subsuming-sp pair-stub left-sp right-sp]
-  (let [expand-right? (not (or (summary/live? (summaries/summary left-sp)) (seq (get-outputs left-sp))))
+  (let [expand-right? (and (summary/solved? (summaries/summary left-sp)) (empty? (get-outputs left-sp)))
         [ss watch stub-f]
         (if expand-right?
           [(summaries/make-sum-summarizer [(tree-summarizer left-sp) right-sp])
@@ -422,8 +418,7 @@
                  (let [left-done? (atom false)]
                    (fn [s b]
                      (when (and (not @left-done?)
-                                (not (summary/live? (summaries/summary left-sp)))
-                                (not (= Double/NEGATIVE_INFINITY (summary/max-reward (summaries/summary left-sp))))) ;; TODO:??
+                                (summary/solved? (summaries/summary left-sp))) ;; TODO:??
                        (reset! left-done? true)
                        (summaries/disconnect! s ss)
                        (add-watcher! left-sp (fn [o] (def *sum* [s left-sp o])
@@ -444,6 +439,11 @@
         (summaries/summary-changed! ret))) ;; TODO: efficiency?

     ret))
+
+(comment
+  ;; Old test used this -- do we need to split on right for blocked left?
+  (not (summary/live? (summaries/summary left-sp)))
+ (not (= Double/NEGATIVE_INFINITY (summary/max-reward (summaries/summary left-sp)))))

 (defn- make-pair-stub2 [subsuming-sp left-sp right-stub]
   (let [nm [:Pair (subproblem-name left-sp) (stub-name right-stub)]
@@ -470,8 +470,7 @@
          (connect-and-watch-stub! ret
            (make-pair-stub2 subsuming-sp lo (right-stub-fn (output-set lo)))
            #(set-stub-output! ret %))
-         (summaries/summary-changed! ret))) ;; TODO: wasteful?
-
+         (summaries/summary-changed! ret))) ;; TODO: wasteful?
      ret)))


More doc tweakage.

More doc tweakage.

--- scheduling/src/immutant/scheduling.clj
+++ scheduling/src/immutant/scheduling.clj
@@ -36,7 +36,7 @@
   Units for periods are milliseconds, but can also be represented as a
   keyword or a sequence of multiplier/keyword pairs,
   e.g. `[1 :week, 4 :days, 2 :hours, 30 :minutes, 59 :seconds]`.
-  See {{every}} or {{in}} for a full list of valid period keywords.
+  See {{every}} for the list of valid period keywords.

   Time values can be a `java.util.Date`, a long denoting
   milliseconds-since-epoch, or a String in `HH:mm` format, interpreted
@@ -122,9 +122,8 @@
 (defoption ^{:arglists '([n] [kw] [n kw & n-kws])} in
   "Specifies the period after which the job will fire, in
   milliseconds, a period keyword, or multiplier/keyword pairs, e.g.
-  `(in 5 :minutes 30 :seconds)`. Valid period keywords
-  are: :second :seconds :minute :minutes :hour :hours :day :days :week :weeks. See
-  {{schedule}}.")
+  `(in 5 :minutes 30 :seconds)`. See {{every}} for the list of valid
+   period keywords. See {{schedule}}.")

 (defoption ^{:arglists '([date] [ms] [HHmm])} at
   "Takes a time after which the job will fire, so it will run
@@ -135,8 +134,8 @@
 (defoption ^{:arglists '([n] [kw] [n kw & n-kws])} every
   "Specifies a period between function calls, in milliseconds, a
   period keyword, or multiplier/keyword pairs, e.g.
-  `(every 1 :hour 20 :minutes)`.  Valid period keywords
-  are: :second :seconds :minute :minutes :hour :hours :day :days :week :weeks.
+  `(every 1 :hour 20 :minutes)`.  Both singular and plural versions of
+  :second, :minute, :hour, :day, and :week are valid period keywords.
   See {{schedule}}.")

 (defoption ^{:arglists '([date] [ms] [HHmm])} until


Add def eid/neid and set-exp for same in comment section

--- src/aerobio/htseq/common.clj
+++ src/aerobio/htseq/common.clj
@@ -318,7 +318,7 @@
 (defn info-ks [] (-> @exp-info first second keys))

 (defn get-exp-info [eid & ks]
-  (let [otks [:bams :cuffs :diffs :asms :charts]
+  (let [otks [:bams :fcnts :cuffs :diffs :asms :charts]
         rep? (coll/in :rep ks)
         ks (remove #{:rep} (filter identity ks)) ; remove any :rep or nil
         info (get-exp eid)
@@ -496,8 +496,13 @@

 (comment
-  (set-exp
-   "160307_NS500751_0013_AHL7L3BGXX")
+  (def eid "160930_161002_AHK72HBGXY_AHK7YKBGXY")
+  (def neid "161108_161109_AH2WWGBGX2_AH2WLJBGX2")
+
+  (set-exp "160307_NS500751_0013_AHL7L3BGXX")
+  (set-exp "160930_161002_AHK72HBGXY_AHK7YKBGXY")
+  (set-exp "161108_161109_AH2WWGBGX2_AH2WLJBGX2")
+
   (get-exp "160307_NS500751_0013_AHL7L3BGXX")
   ((get-exp "160307_NS500751_0013_AHL7L3BGXX") :base)
   (info-ks)


Remove useless code

Remove useless code

--- ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/proxy_redirect.clj
+++ ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/middleware/proxy_redirect.clj
@@ -46,14 +46,6 @@
         :body
         (slurp-binary (Integer/parseInt len))
         ByteArrayInputStream.)))
-
-(defn- slurp-body
-  [request]
-  (if-let [len (when (:body request) (get-in request [:headers "content-length"]))]
-    (-> request
-        :body
-        (slurp-binary (Integer/parseInt len))
-        String.)))

 (def ^{:private true, :doc "RFC6265 cookie-octet"}
 re-cookie-octet
@@ -156,13 +148,6 @@
   (log/debug "rewrite result" result)
   result))

-(defn- extract-body
-  [request]
-  (let [accept (get-in request [:headers "accept-encoding"])]
-    (if (and accept (.startsWith accept "gzip"))
-      (slurp-body-binary request)
-      (slurp-body request))))
-
 (defn- redirect
   [host request-uri request]

@@ -177,7 +162,7 @@

         response (request-fn @client redirected-url
                              {:query-params (merge (to-query-params (:query-string request)) (:params request))
-                              :body         (extract-body request)
+                              :body         (slurp-body-binary request)
                               :headers      (-> request
                                                 :headers
                                                 (dissoc "host" "content-length"))})]


Create modified file of tids

Create modified file of tids

--- src/clj/cglossa/data_import/metadata_values.clj
+++ src/clj/cglossa/data_import/metadata_values.clj
@@ -87,8 +87,8 @@

 (defn- create-tid-config! [corpus config-path orig-tsv-path]
   (with-open [tsv-file (io/reader orig-tsv-path)]
-    (let [other-cats     (->> (utils/read-csv tsv-file)
-                              first
+    (let [cats           (first (utils/read-csv tsv-file))
+          other-cats     (->> cats
                               rest
                               (filter #(not (get #{"startpos" "endpos"} %1))))
           cat-edges      (map (fn [cat]
@@ -116,13 +116,31 @@
                             (str/replace "###TSV-PATH###" orig-tsv-path)
                             (str/replace "###CORPUS###" corpus))))))

+(defn- fix-fields [row]
+  ;; Escape unescaped quotes with a backslash
+  (map #(str/replace % #"(?<!\\)\"" "\\\"") row))
+
+(defn- create-tid-tsv! [corpus orig-tsv-path tsv-path]
+  (with-open [orig-tsv-file (io/reader orig-tsv-path)
+              tsv-file      (io/writer tsv-path)]
+    (let [[headers & rows] (utils/read-csv orig-tsv-file)
+          [tid-header & other-headers] headers]
+      (assert (= "tid" tid-header)
+              (str "Format error: Expected first line to contain column headers "
+                   "with 'tid' (text ID) as the first header."))
+      (utils/write-csv tsv-file (->> rows
+                                     (map fix-fields)
+                                     (cons (cons "value" other-headers)))))))
+
 (defn import! [corpus]
   (let [orig-tsv-path       (-> (str "data/metadata_values/" corpus ".tsv") io/resource .getPath)
         non-tid-tsv-path    (.getPath (fs/temp-file "metadata_vals"))
-        tid-config-path     (.getPath (fs/temp-file "tid_config"))
-        non-tid-config-path (.getPath (fs/temp-file "metadata_val_config"))]
+        non-tid-config-path (.getPath (fs/temp-file "metadata_val_config"))
+        tid-tsv-path        (.getPath (fs/temp-file "tids"))
+        tid-config-path     (.getPath (fs/temp-file "tid_config"))]
     (create-non-tid-tsv! corpus orig-tsv-path non-tid-tsv-path)
     (create-non-tid-config! non-tid-config-path non-tid-tsv-path)
-    (create-tid-config! corpus tid-config-path orig-tsv-path)
+    (create-tid-tsv! corpus orig-tsv-path tid-tsv-path)
+    (create-tid-config! corpus tid-config-path tid-tsv-path)
     (utils/run-etl non-tid-config-path)
     (utils/run-etl tid-config-path)))


Actually disable controls on /enterprise.

--- src-cljs/frontend/components/enterprise.cljs
+++ src-cljs/frontend/components/enterprise.cljs
@@ -55,12 +55,13 @@
                      {:type "text"
                       :name "company"
                       :required true
-                      :class (when loading? "disabled")
+                      :disabled loading?
                       :placeholder "Company"})]
            [:div.col-sm-6
             (control :input.input-lg
                      {:type "text"
                       :name "phone"
+                      :disabled loading?
                       :placeholder "Phone"})]]
           [:div.row
            [:div.col-sm-6
@@ -68,12 +69,13 @@
                      {:type "text"
                       :name "name"
                       :required true
-                      :class (when loading? "disabled")
+                      :disabled loading?
                       :placeholder "Name"})]
            [:div.col-sm-6
             (control :input.input-lg
                      {:type "text"
                       :name "developer-count"
+                      :disabled loading?
                       :placeholder "# of Developers"})]]
           [:div.row
            [:div.col-sm-6
@@ -81,7 +83,7 @@
                      {:type "email"
                       :name "email"
                       :require true
-                      :class (when loading? "disabled")
+                      :disabled loading?
                       :placeholder "Email"})]
            [:div.col-sm-6
             [:div.telephone-info


generation failure exceptions for llamarse

--- src/babel/espanol/writer.clj
+++ src/babel/espanol/writer.clj
@@ -104,7 +104,7 @@
                                                                          (log/info (str "ignoring exception(funcionar-is-only-nonhuman): " e))

                                                                          ;; "llamarse": there is currently only singular
-                                                                         ;; proper names, so any attempt to use
+                                                                         ;; proper male names, so any attempt to use
                                                                          ;; plural number with this verb will fail.
                                                                          (and
                                                                           (= (get-in spec [:root :espanol :espanol])
@@ -112,7 +112,11 @@
                                                                           (or (= (get-in spec [:comp :synsem :agr :number])
                                                                                :plur)
                                                                               (= (get-in spec [:comp :synsem :agr :gender])
-                                                                                :fem)))
+                                                                                :fem)
+                                                                              (and (not (= (get-in spec [:synsem :sem :tense])
+                                                                                :present))
+                                                                                (not (= (get-in spec [:synsem :sem :aspect])
+                                                                                :progressive)))))
                                                                          (log/info (str "ignoring exception(llamarse-is-only-singular): " e))

                                                                          true


Little bit of scenario devcards refactoring

--- src/clj/zetawar/devcards/scenarios.cljs
+++ src/clj/zetawar/devcards/scenarios.cljs
@@ -1,9 +1,7 @@
 (ns zetawar.devcards.scenarios
   (:require
-   [datascript.core :as d]
    [devcards.core :as dc :include-macros true]
    [integrant.core :as ig]
-   [posh.core :as posh]
    [reagent.core :as r]
    [zetawar.app :as app]
    [zetawar.system :as system]
@@ -11,16 +9,18 @@
   (:require-macros
    [devcards.core :refer [defcard defcard-rg]]))

+(defn init-scenario [scenario-id]
+  (let [system (ig/init system/game-config)
+        game-cfg (:zetawar.system/game system)]
+    (app/start-new-game! game-cfg scenario-id)
+    system))
+
 (defcard-rg sterlings-aruba-multiplayer-card
-  (let [system (ig/init system/game-config)
-        game-cfg (:zetawar.system/game system)
-        views-cfg (:zetawar.system/game-views system)]
-    (app/start-new-game! game-cfg :sterlings-aruba-multiplayer)
+  (let [views-cfg (-> (init-scenario :sterlings-aruba-multiplayer)
+                      :zetawar.system/game-views)]
     [views/board views-cfg]))

 (defcard-rg city-sprawl-multiplayer-card
-  (let [system (ig/init system/game-config)
-        game-cfg (:zetawar.system/game system)
-        views-cfg (:zetawar.system/game-views system)]
-    (app/start-new-game! game-cfg :city-sprawl-multiplayer)
+  (let [views-cfg (-> (init-scenario :city-sprawl-multiplayer)
+                      :zetawar.system/game-views)]
     [views/board views-cfg]))


Fix broken var page nav

Fix broken var page nav

--- src/cljs/clojuredocs/mods/var_page.cljs
+++ src/cljs/clojuredocs/mods/var_page.cljs
@@ -26,7 +26,7 @@
                   (put! c {:success false :res res}))}))
     c))

-(defn $nav [!state owner]
+(defn $nav [!state]
   (let [{:keys [examples see-alsos notes]} @!state]
     [:div
      [:h5 "Nav"]
@@ -449,8 +449,14 @@
       [see-alsos/$see-alsos !state bus]
       (sel1 $root :.see-alsos-widget))))

+(defn init-nav [$root !state]
+  (rea/render-component
+    [$nav !state]
+    (sel1 $root :.var-page-nav)))
+
 (defn init [$root]
   (let [!state (rea/atom (init-state))]
+    (init-nav $root !state)
     (init-examples $root !state)
     (init-see-alsos $root !state)
     (init-notes $root !state)))


Fix broken migrate transaction

Fix broken migrate transaction

--- src/braid/server/migrate.clj
+++ src/braid/server/migrate.clj
@@ -246,7 +246,7 @@
       (let [u-id (:user/id p)
             u-prefs (edn/read-string (:user/preferences-old p))]
         (doseq [[k v] u-prefs]
-          (when k (user/user-set-preference! db/conn u-id k v)))))))
+          (when k (db/run-txns! (user/user-set-preference-txn u-id k v))))))))

 (defn migrate-2016-05-03
   "Add tag descriptions"


currently at 464 out of 1659

currently at 464 out of 1659

--- Clojure/cp/src/cp/threads.clj
+++ Clojure/cp/src/cp/threads.clj
@@ -1,4 +1,4 @@
-(ns threads.core)
+(ns cp.threads)

 (def d (delay
 	(println "Running ...")
@@ -70,6 +70,59 @@

 ;bad use of pmap

+(def files (repeat 100000
+	(apply str (concat (repeat 1000 \space) "sunil: 617.555.2937, Betty: 508.555.2218"))))
+
+(time (->> files
+	(partition-all 250)
+	(pmap (fn [chunk] (doall (map phone-numbers chunk))))
+	(apply concat)
+	dorun))
+
+(def sarah {:name "Sarah" :age 25 :wears-glasses? false})
+
+;reference types: var ref agent atom
+
+@(atom 12)
+
+(agent {:c 42})
+
+(map deref [(agent {:c 42}) (atom 12) (ref "http/clojure.org") (var +)])
+
+(comment
+	Key clojure concepts:
+
+	coordination:
+		coordinated: cooperation of multiple actors to not get in each others way
+		uncoordinated: multiple actors are unable to impact each other negatively.
+
+	synchronization:
+		synchronous: caller thread blocks until access is obtained
+		asynchronous: can start or stop without blocking intiating thread
+
+				 | coordinated 	| uncoordinated
+	-------------------------------------------
+	synchronous  | refs 		| atoms
+	asynchronous | 				| agents
+
+	vars are for local threads, thus don't concern with above
+
+	)
+
+(defmacro futures [n & exprs]
+	(vec (for [_ (range n)
+		       expr exprs]
+		       `(future ~expr))))
+
+(defmacro wait-futures [& args]
+	`(doseq [f# (futures ~@args)]
+		@f#))
+
+(comment
+	ATOMS:
+
+
+	)

@@ -93,3 +146,7 @@

+
+
+
+


formatting

formatting

--- src/clj/com/rpl/specter.cljc
+++ src/clj/com/rpl/specter.cljc
@@ -1070,10 +1070,10 @@

 (defnav regex-nav [re]
   (select* [this structure next-fn]
-           (doseqres NONE [s (re-seq re structure)]
-                     (next-fn s)))
-  (transform* [this structure next-fn]
-              (clojure.string/replace structure re next-fn)))
+    (doseqres NONE [s (re-seq re structure)]
+      (next-fn s)))
+  (transform* [this structure next-fn]
+    (clojure.string/replace structure re next-fn)))

 (defdynamicnav selected?
   "Filters the current value based on whether a path finds anything.


Use a "manual" transaction to rollback repair

The natural thing to do would of course be a transaction with
isolation level :none as we want others to see that the current
production is in state "repairing". But alas that level is not
supported by MySQL, so we have to resort to a "manual" transaction
using try/catch.

--- src/clj/mdr2/repair/core.clj
+++ src/clj/mdr2/repair/core.clj
@@ -72,21 +72,25 @@
       (fs/exists? tmp-dir)
       (throw (ex-info (format "Directory %s already exists" tmp-dir) {:error-id ::directory-already-exists}))
       :else
-      (let [production (prod/set-state! production "repairing")
-            container-id (container-id production)
-            url (archive-url container-id)
-            response (client/get url
-                                 {:as :stream
-                                  :basic-auth [(env :archive-web-user) (env :archive-web-password)]})]
-        (log/infof "Repairing %s" id)
-        (if (client/success? response)
-          (let [dam-number (prod/dam-number production)
-                tar-file (fs/path tmp-dir (str dam-number ".tar"))]
+      ;; rollback to the archived state if any exceptions occur in the process of repairing. But at
+      ;; the same time we want others to see that we are in the process of repairing, i.e. we want
+      ;; to have an isolation level of :none. Unfortunately that is not supported by MySQL, so we
+      ;; have to resort to a "manual" transaction using try/catch.
+      ;;      (conman/with-transaction [db/*db* {:isolation :none}]
+      (try
+        (let [production (prod/set-state! production "repairing")
+              container-id (container-id production)
+              url (archive-url container-id)
+              response (client/get url
+                                   {:as :stream
+                                    :basic-auth [(env :archive-web-user) (env :archive-web-password)]})]
+          (log/infof "Repairing %s" id)
+          (if (client/success? response)
+            (let [dam-number (prod/dam-number production)
+                  tar-file (fs/path tmp-dir (str dam-number ".tar"))]

-            ;; fail fast if any of the filesystem operations fail. If
-            ;; the filesystem operations silently ignore failures we
-            ;; check the results.
-            (try
+              ;; fail fast if any of the filesystem operations fail. Where filesystem operations
+              ;; silently ignore failures, we check the results and throw an exception.
               ;;create all dirs for this production
               (prod/create-dirs production)
               ;; copy tar to tmpdir
@@ -111,15 +115,13 @@
                         (obi/config-file production)
                         ;; set the state
                         (prod/set-state! production "structured"))))
-                  (do
-                    ;; re-set the state back to archived
-                    (prod/set-state! production "archived")
-                    (throw (ex-info (format "Failed to extract the tar file %s inside %s" tar-file tmp-dir) {:error-id ::tar-extract-failed})))))
-              (catch Exception e ;; FIXME: catch a more specific Exception and migrate to transactions for rollback
-                ;; re-set the state back to archived
-                (prod/set-state! production "archived")
-                e)))
-          (do
-            (.close (:body response)) ;; close the stream
-            (throw (ex-info (format "Couldn't get %s from archive (%s)" id url) {:error-id ::archive-fetch-failed}))))))))
+                  ;; if the extracting of the tar failed throw an exception which will roll back the
+                  ;; transaction and undo all changes in the database
+                  (throw (ex-info (format "Failed to extract the tar file %s inside %s" tar-file tmp-dir) {:error-id ::tar-extract-failed})))))
+            (do
+              (.close (:body response)) ;; close the stream
+              (throw (ex-info (format "Couldn't get %s from archive (%s)" id url) {:error-id ::archive-fetch-failed})))))
+        (catch Exception e
+          (prod/set-state! production "archived")
+          (throw e))))))


extract common fn

extract common fn

--- src/clj/searchbot/server.clj
+++ src/clj/searchbot/server.clj
@@ -50,13 +50,15 @@
    :aggregators []
    :widgets []})

+(defn load-view-edn [view]
+  (clojure.edn/read-string
+   (read-edn (str view ".edn") :default (pr-str default-app-state))))
+
 (defroutes routes
   (resources "/react" {:root "react"})
   (GET "/" req (apply str (init-page)))
-  (GET "/_init" req (response (clojure.edn/read-string
-                               (read-edn "app-state.edn" :default (pr-str default-app-state)))))
-  (GET "/_init/:view" [view] (response (clojure.edn/read-string
-                                        (read-edn (str view ".edn") :default (pr-str default-app-state)))))
+  (GET "/_init" req (response (load-view-edn "app-state")))
+  (GET "/_init/:view" [view] (response (load-view-edn view)))
   (GET "/es/:idx/_count" [idx]
        (response (es/es-count (get-es-host) idx)))
   (POST "/es/:idx/_search" [idx :as req]


fixes to combiner

fixes to combiner

--- src/cljc/commos/service.cljc
+++ src/cljc/commos/service.cljc
@@ -229,6 +229,7 @@
             #?(:clj (throw (IllegalArgumentException. msg))
                     :cljs (throw msg)))))
       (cancel [this ch]
-        (let [[subscribed-ch service] (@services ch)]
+        (when-let [[subscribed-ch service] (@services ch)]
           (cancel service subscribed-ch)
+          (close! subscribed-ch)
           (count (swap! services dissoc ch)))))))


comments

comments

--- src/cljs/tictactoe/core.cljs
+++ src/cljs/tictactoe/core.cljs
@@ -11,7 +11,9 @@

 (defn tic-tac-toe
-  "Main rendering entry: assemble the game logic, the view and control"
+  "Main entry point, assemble:
+   * the game state
+   * the game view"
   []
   [:div
    (panel/render-top-panel


minor renaming

minor renaming

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -30,7 +30,7 @@
     (conj conversions (move/empty-cell-conversion player point))
     ))

-(defn- next-worst-possible-score
+(defn- worst-possible-score-from
   [{:keys [player other-players] :as ai} turn]
   (scores/min-delta-for player
     (eduction
@@ -43,7 +43,7 @@
   [ai turn [coord converted :as move]]
   (let [new-turn (turn/play-move turn coord)
         move-diff (get (score-move ai move) (:player ai))
-        next-diff (next-worst-possible-score ai new-turn)]
+        next-diff (worst-possible-score-from ai new-turn)]
     (+ move-diff next-diff)))


Expose full(er) ToolRunner API.

Expose full(er) ToolRunner API.

--- src/clojure/parkour/tool.clj
+++ src/clojure/parkour/tool.clj
@@ -22,4 +22,7 @@

 (defn run
   "Run the Tool/function `t` with the arguments `args`."
-  [t args] (ToolRunner/run (coerce Tool tool t) (into-array String args)))
+  ([t args]
+     (ToolRunner/run (coerce Tool tool t) (into-array String args)))
+  ([^Configuration conf t args]
+     (ToolRunner/run conf (coerce Tool tool t) (into-array String args))))


Commit before renaming

Commit before renaming

--- src/clojure_fabric/chain.clj
+++ src/clojure_fabric/chain.clj
@@ -7,17 +7,21 @@
 ;; to join that channel.

 (ns clojure-fabric.chain
-  (:require [clojure-fabric.node :as peer]
-            [clojure-fabric.node :as orderer]
+  (:require [clojure-fabric.peer :as peer]
+            [clojure-fabric.orderer :as orderer]
             [clojure-fabric.utils :as utils]
             [medley.core :as medley]))

 (defonce ^:dynamic *chain* nil)

-(defrecord Chain [name peers orderers event-hubs listner-peer])
-
-(defn %make-chain [{:keys [peers orderers]}]
-  (map->Chain {:peers (atom `[~@peers]) :orderers (atom `[~@orderers])}))
+(defrecord Chain [name peers orderers event-hubs listener-peer])
+(defn make-chain [name {:keys [peers orderers event-hubs listener-peer]}]
+  (map->Chain {:peers (atom `[~@peers]) :orderers (atom `[~@orderers])
+               :listener-peer (atom ~listener-peer)}))
+
+;;;
+;;; Functions
+;;;

 (defn- add-chain-end
   [chain {:keys [name url] :as chain-end} chain-ends-key]
@@ -285,6 +289,5 @@
    ;;; TBD
    ))

-
 ;;;;;;;;;


Corrected namespace typo

Corrected namespace typo

--- src/clojure_todo/handler.clj
+++ src/clojure_todo/handler.clj
@@ -39,7 +39,7 @@
 (defn delete-task [id] (remove-by-id "clojure-todo" (ObjectId. id)))

 (defn insert-task [task]
-  (insert "clojure-todo" {:task (url-encode(task)) :done? false})
+  (insert "clojure-todo" {:task (c/url-encode(task)) :done? false})
   (str "task added")
 )


For custom ring handler, bind to var, not to its value

See also #241

--- sidecar/src/figwheel_sidecar/utils.clj
+++ sidecar/src/figwheel_sidecar/utils.clj
@@ -34,7 +34,7 @@
         (when-let [ns (namespace h)]
           (when (require? (symbol ns))
             (when-let [handler-var (resolve h)]
-              @handler-var)))))))
+              handler-var)))))))

 #_(require-resolve-handler figwheel-sidecar.components.cljs-autobuild/figwheel-build)


Tighten up

Tighten up

--- boot/core/src/boot/core.clj
+++ boot/core/src/boot/core.clj
@@ -396,12 +396,14 @@
   "Initialize the boot environment. This is normally run once by boot at
   startup. There should be no need to call this function directly."
   []
-  (let [dir (->> (io/file ".")
-                 .getCanonicalFile
-                 file/split-path
-                 rest
-                 (apply io/file (App/getBootDir) "tmp"))]
-    (->> dir tmp/registry tmp/init! (reset! tmpregistry)))
+  (->> (io/file ".")
+       .getCanonicalFile
+       file/split-path
+       rest
+       (apply io/file (App/getBootDir) "tmp")
+       tmp/registry
+       tmp/init!
+       (reset! tmpregistry))
   (doto boot-env
     (reset! {:dependencies   []
              :directories    #{}


call index-fn with correct argument

call index-fn with correct argument


Improve stack trace printing in html gui

--- app/gui/html/cljs/defpi/ws.cljs
+++ app/gui/html/cljs/defpi/ws.cljs
@@ -14,6 +14,7 @@
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require
    [cljs.core.async :as async :refer [>! <! put! chan]]
+   [clojure.string :as str]
    [om.core :as om :include-macros true]
    [om.dom :as dom :include-macros true]
    [goog.events :as events]
@@ -54,7 +55,8 @@
                  (dom/div nil (get m "val")
                           (when (get m "backtrace")
                             (dom/div nil
-                                     (dom/pre nil (get m "backtrace"))))))
+                                     (dom/pre nil
+                                              (str/join "\n" (get m "backtrace")))))))
                (:messages data)))))

 (om/root message-comp app-state {:target (.getElementById js/document "app-messages")})


use ! convention for set-item! and add a higher-level conj-item! fn


delaney.clj: added two more short functions.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -475,8 +475,6 @@
               (into {} (for [[i s] (.s# ds)] [(- (dim ds) i) s]))
               (into {} (for [[i v] (.v# ds)] [(- (dim ds) 1 i) v])))))

-(defn self-dual? [ds] (= (-> ds invariant) (-> ds dual invariant)))
-
 (defn canonical [ds]
   (let [ds (dsymbol ds)
         update (fn [m data D]
@@ -501,6 +499,12 @@
 (defn canonical? [ds]
   (= (dsymbol ds) (canonical ds)))

+(defn isomorphic? [ds1 ds2]
+  (= (invariant ds1) (invariant ds2)))
+
+(defn self-dual? [ds]
+  (isomorphic? ds (dual ds)))
+
 (defn minimal? [ds]
   (let [p (type-partition ds)]
     (every? (fn [D] (= D (pfind p D))) (elements ds))))


delaney.clj: added a function to create a Java from a Clojure D-symbol.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -293,7 +293,7 @@
 (defmethod dsymbol DSymbol [ds] ds)

 (defmethod dsymbol DelaneySymbol [ds]
-  (let [emap (zipmap (.elements ds) (range 1 (inc (size ds))))
+  (let [emap (zipmap (elements ds) (range 1 (inc (size ds))))
         imap (zipmap (indices ds) (range (inc (dim ds))))
         gluings (for [i (indices ds), D (orbit-reps ds [i])]
                   [(imap i) (emap D) (emap (s ds i D))])
@@ -308,6 +308,17 @@
                       spins)]
     d-sym))

+;; === Building a Java DSymbol instance from a Clojure one
+
+(defn java-dsymbol [ds]
+  (let [ops (make-array Integer/TYPE (inc (dim ds)) (inc (size ds)))
+        vs (make-array Integer/TYPE (dim ds) (inc (size ds)))]
+    (doseq [i (range 0 (inc (dim ds)))
+            D (range 1 (inc (size ds)))]
+      (aset-int ops i D (s ds i D))
+      (if (< i (dim ds)) (aset-int vs i D (v ds i (inc i) D))))
+    (org.gavrog.joss.dsyms.basic.DSymbol. ops vs)))
+
 ;; === Tests

 (deftest adding-elements


cleanup and reorganize babel.test.it

cleanup and reorganize babel.test.it

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -22,15 +22,48 @@
    [clojure.set :as set]
    [dag_unify.core :refer [copy fail? get-in strip-refs unify]]))

+;; TODO: move this from babel.test.it to babel.lexicon or similar.
 (btest/init-db)
 (log/info (str "recompiling and writing lexicon to database.."))
 (write-lexicon "it" (lexicon/compile-lexicon))
 (log/info (str "done."))
-(def model @@(get models :it))

 ;; TODO: consider removing special-purpose grammars like grammar/np-grammar
 ;; and just use model instead.
+;; TODO: create np-grammar here as we do with tiny-model (below).
 (def np-grammar (delay (grammar/np-grammar)))
+
+(defn generate-speed-test [spec & [times]]
+  (btest/generate-speed-test spec @@(get models :it) times))
+
+(defn run-passato-prossimo-test []
+  (generate-speed-test {:synsem {:cat :verb :subcat []
+                                 :sem {:reflexive true
+                                       :tense :present
+                                       :aspect :perfect}}}))
+(defn tiny-model []
+  (babel.italiano.grammar/model-plus-lexicon
+   ;; filtered lexicon:
+   (into {}
+         (for [[k lexemes] (babel.lexiconfn/read-lexicon "it")]
+           (let [filtered-lexemes
+                 (filter (fn [lexeme]
+                           (or (= k "vedere")
+                               (and (= (get-in lexeme [:synsem :cat])
+                                       :noun)
+                                    (= (get-in lexeme [:synsem :pronoun])
+                                       true))))
+                         lexemes)]
+             (if (not (empty? filtered-lexemes))
+               [k filtered-lexemes]))))
+
+   ;; filtered grammar:
+   (fn [rule]
+     (or (= (:rule rule)
+            "s-present-phrasal")
+         (= (:rule rule)
+            "vp-pronoun-nonphrasal")))))
+

 (defmacro deftest [test-name & arguments]
   (let [wrapped-arguments
@@ -411,7 +444,7 @@
           (let [semantics (strip-refs
                            (get-in
                             (first
-                             (reduce concat (map :parses (parse surface model))))
+                             (reduce concat (map :parses (parse surface))))
                             [:synsem :sem]))]
             (is (map? semantics))))
         ["la sua ragazza"
@@ -431,7 +464,7 @@
         (repeatedly #(let [generated
                            (morph (generate {:synsem {:cat :verb
                                                       :subcat []}}))
-                           parsed (reduce concat (map :parses (parse generated model)))]
+                           parsed (reduce concat (map :parses (parse generated)))]
                        (log/info (str "generated: " generated))
                        (log/info (str "semantics: "
                                       (or
@@ -827,15 +860,6 @@
              generate
              morph))))

-(defn generate-speed-test [spec & [times]]
-  (btest/generate-speed-test spec model times))
-
-(defn run-passato-prossimo-test []
-  (generate-speed-test {:synsem {:cat :verb :subcat []
-                                 :sem {:reflexive true
-                                       :tense :present
-                                       :aspect :perfect}}}))
-
 (deftest io-lo-vedo
   (is (= "io lo vedo"
          (let [spec
@@ -866,38 +890,3 @@
                generate
                morph)))))

-(defn tiny-model []
-  (babel.italiano.grammar/model-plus-lexicon
-   ;; filtered lexicon:
-   (into {}
-         (for [[k lexemes] (babel.lexiconfn/read-lexicon "it")]
-           (let [filtered-lexemes
-                 (filter (fn [lexeme]
-                           (or (= k "vedere")
-                               (and (= (get-in lexeme [:synsem :cat])
-                                       :noun)
-                                    (= (get-in lexeme [:synsem :pronoun])
-                                       true))))
-                         lexemes)]
-             (if (not (empty? filtered-lexemes))
-               [k filtered-lexemes]))))
-
-   ;; filtered grammar:
-   (fn [rule]
-     (or (= (:rule rule)
-            "s-present-phrasal")
-         (= (:rule rule)
-            "vp-pronoun-nonphrasal")))))
-
-(defn test-tiny-model []
-  (let [spec {:modified false,
-              :synsem {:cat :verb, :subcat [],
-                       :sem {:pred :see,
-                             :tense :present,
-                             :aspect :simple
-                             :obj {:spec :top}}}}
-        tm (tiny-model)]
-    (repeatedly #(println (morph (time (generate spec tm)))))))
-
-
-


Remove vestigial reference to lib we don't use

--- src/foreclojure/problems.clj
+++ src/foreclojure/problems.clj
@@ -19,7 +19,6 @@
             [hiccup.page-helpers      :only    [link-to]]
             [hiccup.core              :only    [html]]
             [useful.debug             :only    [?]]
-            [amalloy.utils            :only    [defcomp]]
             [compojure.core           :only    [defroutes GET POST]]))

 (def solved-stats (agent {:total 0}))


- Make sure times-solved always shows as an integer - Add a <span class='tag'> to each tag so we can decorate later - Simplify problem-page by using map destructuring

--- src/foreclojure/problems.clj
+++ src/foreclojure/problems.clj
@@ -90,16 +90,17 @@
    (let [solved (get-solved (session/session-get :user))
          problems (get-problem-list)]
      (map-indexed
-      (fn [x p]
+      (fn [x {:keys [title times-solved tags], id :id}]
         [:tr (row-class x)
          [:td {:class "title-link"}
-          [:a {:href (str "/problem/" (p :_id))}
-           (p :title)]]
+          [:a {:href (str "/problem/" id)}
+           title]]
          [:td {:class "centered"}
-          (map #(str % " ") (p :tags))]
-         [:td {:class "centered"} (p :times-solved)]
+          (s/join " " (map #(str "" % "")
+                           tags))]
+         [:td {:class "centered"} (int times-solved)]
          [:td {:class "centered"}
-          [:img {:src (if (contains? solved (p :_id))
+          [:img {:src (if (contains? solved id)
                         "/checkmark.png"
                         "/empty-sq.png")}]]])
       problems))])


Format code

Format code

--- src/github_changelog/cli.clj
+++ src/github_changelog/cli.clj
@@ -42,11 +42,11 @@

 (defn -main [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)
-        {:keys [help last]} options]
+        {:keys [help last]}                        options]
     (cond
-      help (exit 0 (usage summary))
+      help               (exit 0 (usage summary))
       (empty? arguments) (exit 1 (usage summary))
-      errors (exit 1 (error-msg errors)))
+      errors             (exit 1 (error-msg errors)))

     (doseq [config-file arguments]
       (println (generate config-file last)))


Send separate pyout and execute_result

Send separate pyout and execute_result

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -123,12 +123,6 @@
 (defn pyin-content [execution-count message]
   {:execution_count execution-count
    :code (get-in message [:content :code])})
-
-(defn pyout-content [execution-count message executer]
-  {:execution_count execution-count
-   :data {:text/plain (pr-str (eval (read-string (get-in message [:content :code]))))}
-   :metadata {}
-   })

 (defn get-message-signer [key]
   "returns a function used to sign a message"
@@ -212,9 +206,34 @@
                        :engine session-id
                        :status "ok"
                        :started (now)} session-id signer (:idents message))
-        (send-message iopub-socket "pyout"  (pyout-content @execution-count
-                                                           message executer)
-                      parent-header {} session-id signer)
+
+        (let [s# (new java.io.StringWriter)
+              [output results]
+              (binding [*out* s#]
+                (let [result (pr-str (eval (load-string (get-in message [:content :code]))))
+                      output (str s#)]
+                  [output, result]
+                  )
+                )
+              ]
+
+          ;; Send stdout
+          (send-message iopub-socket "pyout"
+                        {:execution_count @execution-count
+                         :data {:text/plain output}
+                         :metadata {}
+                         }
+                        parent-header {} session-id signer)
+
+          ;; Send results
+          (send-message iopub-socket "execute_result"
+                        {:execution_count @execution-count
+                         :data {:text/plain results}
+                         :metadata {}
+                         }
+                        parent-header {} session-id signer))
+
+
         (send-message iopub-socket "status" (status-content "idle")
                       parent-header {} session-id signer)))))