~(deftest chiamarsi): use babel.reader/target-lexical-filter and rather than babel.reader/target-grammar-subset to control target-language generation

--- test/babel/test/reader.cljc
+++ test/babel/test/reader.cljc
@@ -9,19 +9,14 @@
 (btest/init-db)

 (deftest chiamarsi
-  (let [target-grammar-rules
-        #{"sentence-phrasal-head"
-          "vp-32"
-          "vp-pronoun-phrasal"}
-        source-grammar-rules
-        #{"sentence-phrasal-head"
-          "transitive-vp-nonphrasal-head"
-          "transitive-vp-phrasal-head"
-          "noun-phrase"}
-
-        generated
-        (binding [babel.reader/target-grammar-subset target-grammar-rules
-                  babel.reader/source-grammar-subset source-grammar-rules]
+  (let [generated
+        (binding [reader/target-lexical-filter
+                    #(or (= :verb (u/get-in % [:synsem :cat]))
+                         (and (= :noun (u/get-in % [:synsem :cat]))
+                              (not (= :acc (u/get-in % [:synsem :case]))))
+                         (and (= :noun (u/get-in % [:synsem :cat]))
+                              (= :acc (u/get-in % [:synsem :case]))
+                              (= true (u/get-in % [:synsem :reflexive]))))]
           (reader/generate-question-and-correct-set
             {:root {:italiano {:italiano "chiamarsi"}}
              :synsem {:sem {:tense :present


Prune requirements in store-tests ns.

Prune requirements in store-tests ns.

--- test/blocks/store_tests.clj
+++ test/blocks/store_tests.clj
@@ -1,15 +1,11 @@
 (ns blocks.store-tests
   (:require
-    [blocks.core :as block]
     (blocks.store
       [file :refer [file-store]]
       [memory :refer [memory-store]]
       [tests :refer [test-block-store]])
-    [byte-streams :as bytes]
     [clojure.java.io :as io]
-    [clojure.test :refer :all])
-  (:import
-    blocks.data.PersistentBytes))
+    [clojure.test :refer :all]))

 (deftest test-memory-store


Add tests to menu

Add tests to menu

--- dev/src/yada/dev/website.clj
+++ dev/src/yada/dev/website.clj
@@ -56,6 +56,7 @@
                   (for [i (range 7230 (inc 7240))]
                     [:li [:a {:href (format "/static/spec/rfc%d.html" i)}
                           (format "RFC %d: %s" i (or (get titles i) ""))]])]]
+                [:li [:a {:href (path-for (:routes @router) :yada.dev.examples/tests)} "Tests"]]
                 ]]

               [:script {:src "/jquery/jquery.min.js"}]


remove hgtags default/master

remove hgtags default/master

--- test/websync/core_test.clj
+++ test/websync/core_test.clj
@@ -34,11 +34,11 @@

 (deftest write-file-test
-  (let [tmp (java.io.File/createTempFile "websync" "")
-        _ (.delete tmp) ; TODO: Create a dir not a file
-        dt (ts/date-time 2008)
+  (let [tmp    (java.io.File/createTempFile "websync" "")
+        _      (.delete tmp) ; TODO: Create a dir not a file
+        dt     (ts/date-time 2008)
         before (ts/minus dt (ts/years 1))
-        after (ts/plus dt (ts/secs 12))]
+        after  (ts/plus dt (ts/secs 12))]
     (testing "Write File"
       (is (= (write-tmp tmp "a" dt) dt)))
     (testing "Update File"


Remove test folder

Remove test folder

--- test/firebase/core_test.clj
+++ test/firebase/core_test.clj
@@ -1,7 +0,0 @@
-(ns firebase.core-test
-  (:require [clojure.test :refer :all]
-            [firebase.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


Remove unused imports from parsers.core.

--- src/incise/parsers/core.clj
+++ src/incise/parsers/core.clj
@@ -1,10 +1,6 @@
 (ns incise.parsers.core
-  (:require [incise.config :as conf]
-            [incise.parsers.helpers :refer [extension]]
-            [clj-time.core :as tm]
-            [clojure.java.io :refer [file]]
-            [taoensso.timbre :refer [info]]
-            [clojure.string :as s])
+  (:require [incise.parsers.helpers :refer [extension]]
+            [taoensso.timbre :refer [info]])
   (:import [java.io File]))

 (defrecord Parse [^String title


revert lazy REPL init

revert lazy REPL init

tools might expect the REPL env to be available before
an actual runtime has connected so shouldn't delay making
that available until a runtime connects

--- src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -311,6 +311,14 @@
          {:used-by {}
           :used-ts {}})))

+(defn ensure-repl-init [build-state]
+  ;; FIXME: repl-state should be coupled to the client "session" not the runtime
+  (if (seq (get-in build-state [:repl-state :repl-sources]))
+    build-state
+    ;; ensure that all REPL related things have been compiled
+    ;; so the runtime can properly load them
+    (repl/prepare build-state)))
+
 (defn build-compile
   [{:keys [build-state macros-modified namespaces-modified] :as worker-state}]
   ;; this may be nil if configure failed, just silently do nothing for now
@@ -332,6 +340,7 @@
                 (build/compile)
                 (build/flush)
                 (build-find-hooks)
+                (ensure-repl-init)
                 (update ::compile-attempt inc))]

         (>!!output worker-state
@@ -418,46 +427,29 @@
   (async/close! chan)
   worker-state)

-(defn ensure-repl-init [{:keys [build-state] :as worker-state}]
-  ;; FIXME: repl-state should be coupled to the client "session" not the runtime
-  (if (seq (get-in build-state [:repl-state :repl-sources]))
-    worker-state
-    ;; ensure that all REPL related things have been compiled
-    ;; so the runtime can properly load them
-    ;; delaying this until a runtime actually connects
-    (let [build-state (repl/prepare build-state)]
-      (assoc worker-state :build-state build-state)
-      )))
-
 (defmethod do-proc-control :runtime-connect
-  [worker-state {:keys [runtime-id runtime-out runtime-info]}]
+  [{:keys [build-state] :as worker-state} {:keys [runtime-id runtime-out runtime-info]}]
   (log/debug ::runtime-connect {:runtime-id runtime-id})

-  (let [{:keys [build-state] :as worker-state} (ensure-repl-init worker-state)]
-
-    ;; FIXME: potential race condition, this is sent out immediately
-    ;; and may arrive before the rest of this handler completes and has a chance to
-    ;; "save" the updated worker-state. should really get rid of this handling and just use
-    ;; an atom for the state directly instead of hidden by server-thread
-    (>!! runtime-out {:type :repl/init
-                      :repl-state
-                      (-> (:repl-state build-state)
-                          (update :repl-sources repl-sources-as-client-resources build-state))})
-
-    ;; (>!!output worker-state {:type :repl/runtime-connect :runtime-id runtime-id :runtime-info runtime-info})
-
-    ;; don't do anything that takes time here until race condition is fixed
-    ;; otherwise things may try to access the repl-state that hasn't been set yet
-    (-> worker-state
-        (cond->
-          (zero? (count (:runtimes worker-state)))
-          (assoc :default-runtime-id runtime-id))
-        (update :runtimes assoc runtime-id
-          {:runtime-id runtime-id
-           :runtime-out runtime-out
-           :runtime-info runtime-info
-           :connected-since (System/currentTimeMillis)
-           :init-sent true}))))
+  (>!! runtime-out {:type :repl/init
+                    :repl-state
+                    (-> (:repl-state build-state)
+                        (update :repl-sources repl-sources-as-client-resources build-state))})
+
+  ;; (>!!output worker-state {:type :repl/runtime-connect :runtime-id runtime-id :runtime-info runtime-info})
+
+  ;; don't do anything that takes time here until race condition is fixed
+  ;; otherwise things may try to access the repl-state that hasn't been set yet
+  (-> worker-state
+      (cond->
+        (zero? (count (:runtimes worker-state)))
+        (assoc :default-runtime-id runtime-id))
+      (update :runtimes assoc runtime-id
+        {:runtime-id runtime-id
+         :runtime-out runtime-out
+         :runtime-info runtime-info
+         :connected-since (System/currentTimeMillis)
+         :init-sent true})))

 (defn maybe-pick-different-default-runtime [{:keys [runtimes default-runtime-id] :as worker-state} runtime-id]
   (cond
@@ -765,14 +757,16 @@
           worker-state)))))

 (defmethod do-proc-control :start-autobuild
-  [{:keys [build-config autobuild] :as worker-state} msg]
+  [{:keys [build-state autobuild] :as worker-state} msg]
   (if autobuild
     ;; do nothing if already in auto mode
     worker-state
     ;; compile immediately, autobuild is then checked later
     (-> worker-state
         (assoc :autobuild true)
-        (build-configure)
+        (cond->
+          (not build-state)
+          (build-configure))
         (build-compile)
         )))


looking for UI designer ...

looking for UI designer ...

--- src/main/shadow/cljs/ui/components/build_status.cljs
+++ src/main/shadow/cljs/ui/components/build_status.cljs
@@ -81,16 +81,13 @@
                 ])))]))

 (defn render-completed-status [{:keys [duration warnings] :as build-status}]
-  (<< [:div
-       [:div (str (if (seq warnings) "!" "✔") " Compilation completed in " duration " seconds.")]
-       (when (seq warnings)
-         (<< [:div
-              [:div.text-xl.px-1.py-2 (str (count warnings) " Warnings")]
-              (sg/render-seq warnings nil
-                (fn [warning]
-                  (render-build-warning warning)))]))
-
-       ]))
+  (<< [:div.p-2 (str (if (seq warnings) "!" "✔") " Compilation completed in " duration " seconds.")]
+      (when (seq warnings)
+        (<< [:div.flex-1.overflow-auto
+             [:div.text-xl.px-1.py-2 (str (count warnings) " Warnings")]
+             (sg/render-seq warnings nil
+               (fn [warning]
+                 (render-build-warning warning)))]))))

 (defn render-failed-status [{:keys [report] :as build-status}]
   (<< [:div
@@ -132,8 +129,8 @@

     :completed
     (<< [:div.p-2
-         [:div.text-lg "Build Status"]
-         (render-completed-status build-status)]
+         [:div.text-lg "Build Status"]]
+        (render-completed-status build-status)
         [:div.flex-1.overflow-auto
          (render-build-log build-status)])


BK stateful check can deref promises later to test batching

--- test/onyx/state/log/bookkeeper_stateful_check.clj
+++ test/onyx/state/log/bookkeeper_stateful_check.clj
@@ -19,12 +19,6 @@
             [com.gfredericks.test.chuck :refer [times]]
             [com.gfredericks.test.chuck.clojure-test :refer [checking]]))

-(defn new-replica []
-    (atom {:replica {:job-scheduler :onyx.job-scheduler/balanced
-                     :messaging {:onyx.messaging/impl :dummy-messenger}}
-           :message-id 0}))
-
-
 (def messenger (dummy-messenger {:onyx.peer/try-join-once? false}))

 (def id (java.util.UUID/randomUUID))
@@ -35,18 +29,10 @@

 (def peer-config (assoc (:peer-config config)
                         :onyx/id id
-                        :onyx.bookkeeper/write-batch-size 1
-                        :onyx.bookkeeper/write-batch-timeout 10000000))
+                        :onyx.bookkeeper/write-batch-size 2
+                        :onyx.bookkeeper/write-batch-timeout 5))

 (def bookkeeper-peer-state (atom nil))
-
-(defn add-to-bookkeeper [arg]
-  (let [event (:event @bookkeeper-peer-state)
-        state-log (:onyx.core/state-log event)
-        ack-promise (promise)]
-    (state-ext/store-log-entry state-log event (fn [] (deliver ack-promise :done)) arg)
-    ;; Wait until it's acked
-    @ack-promise))

 (defn init-state [& args]
   [])
@@ -63,14 +49,29 @@

 (def previous-peer-state (atom nil))

+(defn add-to-bookkeeper [arg]
+  (let [event (:event @bookkeeper-peer-state)
+        state-log (:onyx.core/state-log event)
+        ack-promise (promise)]
+    (swap! bookkeeper-peer-state update :ack-promises conj ack-promise)
+    (state-ext/store-log-entry state-log event (fn [] (deliver ack-promise :done)) arg)))
+
 (defn new-log-after-crash []
   (let [pipeline (new-pipeline)]
+    (run! deref (:ack-promises @bookkeeper-peer-state))
     (reset! previous-peer-state @bookkeeper-peer-state)
     (swap! bookkeeper-peer-state assoc :event pipeline)))

 (defn close-peer [event]
   (close! (:onyx.core/task-kill-ch event))
   (state-ext/close-log (:onyx.core/state-log event) event))
+
+(defn new-peer-log []
+  (reset! bookkeeper-peer-state {:ledger-ids []
+                                 :ack-promises []
+                                 :event-log []})
+  ;; must setup before new-pipeline so that ledger id is recorded
+  (swap! bookkeeper-peer-state assoc :event (new-pipeline)))

 (def crash-and-playback-spec
   {:model/args (fn [state]
@@ -91,19 +92,12 @@
                                 (close-peer (:event @previous-peer-state)))))
    :real/command #'new-log-after-crash})

-
 (def add-to-log-espec
   {:model/args (fn [state]
                  [gen/int])
    :next-state (fn [state [arg] result]
                  (conj state arg))
    :real/command #'add-to-bookkeeper})
-
-(defn new-peer-log []
-  (reset! bookkeeper-peer-state {:ledger-ids []
-                                 :event-log []})
-  ;; must setup before new-pipeline so that ledger id is recorded
-  (swap! bookkeeper-peer-state assoc :event (new-pipeline)))

 (defn close-peer-cleanup [state]
   (close-peer (:event @bookkeeper-peer-state)))


Change the parameters in DBDA ch08 example.

--- test/clojure/uncomplicate/bayadera/examples/dbda/ch08_test.clj
+++ test/clojure/uncomplicate/bayadera/examples/dbda/ch08_test.clj
@@ -49,10 +49,10 @@
 (defn analysis [prior-plot posterior-plot]
   (with-default
     (let [sample-count (* 256 44)
-          a 15
-          b 50
-          z 8.0
-          N 21.0
+          a 1
+          b 1
+          z 15
+          N 50
           posterior-model (posterior binomial-likelihood beta-model)]
       (with-release [engine-factory (gcn-engine-factory *context* *command-queue*)
                      prior-distribution (beta engine-factory a b)


take section manipulation from mainline + update for component

--- test/open_company/integration/section/section_manipulation.clj
+++ test/open_company/integration/section/section_manipulation.clj
@@ -1,10 +1,10 @@
 (ns open-company.integration.section.section-manipulation
   (:require [midje.sweet :refer :all]
-            [open-company.db.pool :as pool]
-            [open-company.lib.test-setup :as ts]
             [open-company.lib.rest-api-mock :as mock]
             [open-company.lib.resources :as r]
             [open-company.lib.db :as db]
+            [open-company.db.pool :as pool]
+            [open-company.lib.test-setup :as ts]
             [open-company.api.common :as common]
             [open-company.resources.common :as common-res]
             [open-company.resources.company :as company]
@@ -54,8 +54,8 @@
                                       (section/put-section conn r/slug :values r/text-section-1 r/coyote)))
                      (after :facts (pool/with-pool [conn (-> @ts/test-system :db-pool :pool)]
                                      (company/delete-all-companies! conn)))]
+
   (pool/with-pool [conn (-> @ts/test-system :db-pool :pool)]
-
   (facts "about failing to reorder sections"

     (fact "with an invalid JWToken"
@@ -156,228 +156,224 @@
           (:sections (company/get-company conn r/slug)) => new-order))

       (fact "the section order in the progress and company category can both be adjusted at once"
-        (let [new-order {:progress ["help" "update"]
+        (let [new-order {:progress ["help" "team" "update"]
                          :financial ["finances"]
                          :company ["values" "diversity"]}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-order}})]
+          (:status response) => 200
+          (:sections (mock/body-from-response response)) => new-order
+          ;; verify the new order
+          (:sections (company/get-company conn r/slug)) => new-order)))
+
+    (future-facts "when the new order is NOT valid"))
+
+  (facts "about placeholder section removal"
+    (let [slug     "hello-world"
+          payload  {:name "Hello World" :description "x"}
+          response (mock/api-request :post "/companies" {:body payload})
+          company  (company/get-company conn slug)]
+      ;; ensure all placeholder sections are in company
+      (:sections company) => {:progress ["update" "growth" "challenges" "team" "product"]
+                              :financial ["finances"]
+                              :company ["mission" "values"]}
+      (:growth company) => truthy
+      (:challenges company) => truthy
+      (:team company) => truthy
+      (:product company) => truthy
+      (:mission company) => truthy
+      (let [new-set {:company ["values"]
+                     :progress ["update" "finances" "help"]
+                     :financial []}
+            response (mock/api-request :patch (company-rep/url slug) {:body {:sections new-set}})
+            body     (mock/body-from-response response)
+            company  (company/get-company conn slug)]
+        (:status response) => 200
+        (:sections company) => new-set
+        (:growth company) => falsey
+        (:challenges company) => falsey
+        (:team company) => falsey
+        (:product company) => falsey
+        (:mission company) => falsey)))
+
+  (facts "about section removal"
+
+    ;; verify the initial set of sections
+    (:sections (company/get-company conn r/slug)) => {:company ["help" "diversity" "values"]
+                                                 :progress ["update" "team"]
+                                                 :financial ["finances"]}
+
+      (fact "a section can be removed from the progress category"
+        (let [new-set {:company ["help" "diversity" "values"]
+                       :progress ["update"]
+                       :financial ["finances"]}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-set}})
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-set
+          (:update body) => (contains r/text-section-1)
+          (:finances body) => (contains r/finances-section-1)
+          (:team body) => nil
+          (:help body) => (contains r/text-section-1)
+          (:diversity body) => (contains r/text-section-2)
+          (:values body) => (contains r/text-section-1)
+          ;; verify the new set
+          (:sections db-company) => new-set
+          (:update db-company) => (contains r/text-section-1)
+          (:finances db-company) => (contains r/finances-section-1)
+          (:team db-company) => nil
+          (:help db-company) => (contains r/text-section-1)
+          (:diversity db-company) => (contains r/text-section-2)
+          (:values db-company) => (contains r/text-section-1)))
+
+      (fact "multiple sections can be removed from the progress category"
+        (let [new-set {:company ["help" "diversity" "values"]
+                       :progress []
+                       :financial ["finances"]}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-set}})
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-set
+          (:update body) => nil
+          (:team body) => nil
+          (:finances body) => (contains r/finances-section-1)
+          (:help body) => (contains r/text-section-1)
+          (:diversity body) => (contains r/text-section-2)
+          (:values body) => (contains r/text-section-1)
+          ;; verify the new set
+          (:sections db-company) => new-set
+          (:update db-company) => nil
+          (:team db-company) => nil
+          (:finances db-company) => (contains r/finances-section-1)
+          (:help db-company) => (contains r/text-section-1)
+          (:diversity db-company) => (contains r/text-section-2)
+          (:values db-company) => (contains r/text-section-1)))
+
+      (fact "a section can be removed from the company category"
+        (let [new-order {:company ["help" "diversity"]
+                         :progress ["update" "team"]
+                         :financial ["finances"]}
               response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-order}})
-              company  (company/get-company conn r/slug)]
-          (:status response) => 200
-          (:sections company) => new-order
-          (:growth company) => falsey
-          (:challenges company) => falsey
-          (:team company) => falsey
-          (:product company) => falsey
-          (:mission company) => falsey)))
-
-    (facts "about section removal"
-
-      (facts "about placeholder section removal"
-        (let [slug     "hello-world"
-              payload  {:name "Hello World" :description "x" :slug slug}
-              response (mock/api-request :post "/companies" {:body payload})
-              company  (company/get-company conn slug)]
-          ;; ensure all placeholder sections are in company
-          (:sections company) => {:progress ["update" "growth" "challenges" "team" "product"]
-                                  :financial ["finances"]
-                                  :company ["mission" "values"]}
-          (:growth company) => truthy
-          (:challenges company) => truthy
-          (:team company) => truthy
-          (:product company) => truthy
-          (:mission company) => truthy
-          (let [new-set {:company ["values"]
-                         :progress ["update" "finances" "help"]
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-order
+          (:update body) => (contains r/text-section-1)
+          (:finances body) => (contains r/finances-section-1)
+          (:team body) => (contains r/text-section-2)
+          (:help body) => (contains r/text-section-1)
+          (:diversity body) => (contains r/text-section-2)
+          (:values body) => nil
+          ;; verify the new set
+          (:sections db-company) => new-order
+          (:update db-company) => (contains r/text-section-1)
+          (:finances db-company) => (contains r/finances-section-1)
+          (:team db-company) => (contains r/text-section-2)
+          (:help db-company) => (contains r/text-section-1)
+          (:diversity db-company) => (contains r/text-section-2)
+          (:values db-company) => nil))
+
+      (fact "sections can be removed from all the categories at once"
+        (let [new-order {:company ["values"]
+                         :progress ["update" "help"]
                          :financial []}
-                response (mock/api-request :patch (company-rep/url slug) {:body {:sections new-set}})
-                body     (mock/body-from-response response)
-                company  (company/get-company conn slug)]
-            (:status response) => 200
-            (:sections company) => new-set
-            (:growth company) => falsey
-            (:challenges company) => falsey
-            (:team company) => falsey
-            (:product company) => falsey
-            (:mission company) => falsey)))
-
-      (facts "about section removal"
-
-        ;; verify the initial set of sections
-        (:sections (company/get-company conn r/slug)) => {:company ["help" "diversity" "values"]
-                                                          :progress ["update" "team"]
-                                                          :financial ["finances"]}
-
-        (fact "a section can be removed from the progress category"
-          (let [new-set {:company ["help" "diversity" "values"]
-                         :progress ["update"]
-                         :financial ["finances"]}
-                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-set}})
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-order}})
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-order
+          (:update body) => (contains r/text-section-1)
+          (:finances body) => nil
+          (:team body) => nil
+          (:help body) => (contains r/text-section-1)
+          (:diversity body) => nil
+          (:values body) => (contains r/text-section-1)
+          ;; verify the new set
+          (:sections db-company) => new-order
+          (:update db-company) => (contains r/text-section-1)
+          (:finances db-company) => nil
+          (:team db-company) => nil
+          (:help db-company) => (contains r/text-section-1)
+          (:diversity db-company) => nil
+          (:values db-company) => (contains r/text-section-1))))
+
+  (facts "about adding sections"
+
+    (fact "that don't really exist"
+      (let [new-sections {:company [] :progress ["health"] :financial []}
+            response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
+            body (mock/body-from-response response)]
+        (:status response) => 422))
+
+    (facts "without any section content"
+
+      (fact "that never existed"
+        (let [new-sections {:company [] :progress ["highlights"] :financial []}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
+              body (mock/body-from-response response)
+              resp-highlights (:highlights body)
+              db-company (company/get-company conn r/slug)
+              db-highlights (:highlights db-company)
+              placeholder (dissoc (common-res/section-by-name :highlights) :section-name :core)]
+          (:status response) => 200
+          (:sections body) => new-sections
+          ; verify placeholder flag and content in response
+          (:placeholder resp-highlights) => true
+          resp-highlights => (contains placeholder)
+          ; verify placeholder flag and content in DB
+          (:placeholder db-highlights) => true
+          db-highlights => (contains placeholder)))
+
+      (future-fact "that used to exist"
+        (let [new-sections {:company [] :progress [] :financial []}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-sections
+          ; verify update is not in the response
+          (:update body) => nil
+          ; verify update not in the DB
+          (:update db-company) => nil)
+        (let [new-sections {:company [] :progress ["update"] :financial []}
+              response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
+              body (mock/body-from-response response)
+              db-company (company/get-company conn r/slug)]
+          (:status response) => 200
+          (:sections body) => new-sections
+          ; verify update is not in the response
+          (:update body) => (contains r/text-section-1)
+          ; verify update not in the DB
+          (:update db-company) => (contains r/text-section-1))))
+
+    (facts "with section content"
+
+      (let [new-sections {:company ["help" "diversity" "values"]
+                            :progress ["update" "team" "kudos"]
+                            :financial ["finances"]}
+            kudos-placeholder (common-res/section-by-name "kudos")]
+
+        (future-fact "with minimal content"
+          (let [kudos-content {:body "Fred is killing it"}
+                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections
+                                                                                :kudos kudos-content}})
                 body (mock/body-from-response response)
                 db-company (company/get-company conn r/slug)]
             (:status response) => 200
-            (:sections body) => new-set
-            (:update body) => (contains r/text-section-1)
-            (:finances body) => (contains r/finances-section-1)
-            (:team body) => nil
-            (:help body) => (contains r/text-section-1)
-            (:diversity body) => (contains r/text-section-2)
-            (:values body) => (contains r/text-section-1)
-            ;; verify the new set
-            (:sections db-company) => new-set
-            (:update db-company) => (contains r/text-section-1)
-            (:finances db-company) => (contains r/finances-section-1)
-            (:team db-company) => nil
-            (:help db-company) => (contains r/text-section-1)
-            (:diversity db-company) => (contains r/text-section-2)
-            (:values db-company) => (contains r/text-section-1)))
-
-        (fact "multiple sections can be removed from the progress category"
-          (let [new-set {:company ["help" "diversity" "values"]
-                         :progress []
-                         :financial ["finances"]}
-                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-set}})
+            (:body response) => nil))
+
+        (future-fact "with maximal content"
+          (let [kudos-content {:title "Great Jobs!" :headline "Good stuff" :body "Fred is killing it"}
+                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections
+                                                                                :kudos kudos-content}})
                 body (mock/body-from-response response)
                 db-company (company/get-company conn r/slug)]
             (:status response) => 200
-            (:sections body) => new-set
-            (:update body) => nil
-            (:team body) => nil
-            (:finances body) => (contains r/finances-section-1)
-            (:help body) => (contains r/text-section-1)
-            (:diversity body) => (contains r/text-section-2)
-            (:values body) => (contains r/text-section-1)
-            ;; verify the new set
-            (:sections db-company) => new-set
-            (:update db-company) => nil
-            (:team db-company) => nil
-            (:finances db-company) => (contains r/finances-section-1)
-            (:help db-company) => (contains r/text-section-1)
-            (:diversity db-company) => (contains r/text-section-2)
-            (:values db-company) => (contains r/text-section-1)))
-
-        (fact "a section can be removed from the company category"
-          (let [new-order {:company ["help" "diversity"]
-                           :progress ["update" "team"]
-                           :financial ["finances"]}
-                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-order}})
-                body (mock/body-from-response response)
-                db-company (company/get-company conn r/slug)]
-            (:status response) => 200
-            (:sections body) => new-order
-            (:update body) => (contains r/text-section-1)
-            (:finances body) => (contains r/finances-section-1)
-            (:team body) => (contains r/text-section-2)
-            (:help body) => (contains r/text-section-1)
-            (:diversity body) => (contains r/text-section-2)
-            (:values body) => nil
-            ;; verify the new set
-            (:sections db-company) => new-order
-            (:update db-company) => (contains r/text-section-1)
-            (:finances db-company) => (contains r/finances-section-1)
-            (:team db-company) => (contains r/text-section-2)
-            (:help db-company) => (contains r/text-section-1)
-            (:diversity db-company) => (contains r/text-section-2)
-            (:values db-company) => nil))
-
-        (fact "sections can be removed from all the categories at once"
-          (let [new-order {:company ["values"]
-                           :progress ["update" "help"]
-                           :financial []}
-                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-order}})
-                body (mock/body-from-response response)
-                db-company (company/get-company conn r/slug)]
-            (:status response) => 200
-            (:sections body) => new-order
-            (:update body) => (contains r/text-section-1)
-            (:finances body) => nil
-            (:team body) => nil
-            (:help body) => (contains r/text-section-1)
-            (:diversity body) => nil
-            (:values body) => (contains r/text-section-1)
-            ;; verify the new set
-            (:sections db-company) => new-order
-            (:update db-company) => (contains r/text-section-1)
-            (:finances db-company) => nil
-            (:team db-company) => nil
-            (:help db-company) => (contains r/text-section-1)
-            (:diversity db-company) => nil
-            (:values db-company) => (contains r/text-section-1))))
+            (:body response) => nil))
+
+        (future-fact "with too much content"

-      (facts "about adding sections"
-
-        (fact "that don't really exist"
-          (let [new-sections {:company [] :progress ["health"] :financial []}
-                response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
-                body (mock/body-from-response response)]
-            (:status response) => 422))
-
-        (facts "without any section content"
-
-          (fact "that never existed"
-            (let [new-sections {:company [] :progress ["highlights"] :financial []}
-                  response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
-                  body (mock/body-from-response response)
-                  resp-highlights (:highlights body)
-                  db-company (company/get-company conn r/slug)
-                  db-highlights (:highlights db-company)
-                  placeholder (dissoc (common-res/section-by-name :highlights) :section-name :core)]
-              (:status response) => 200
-              (:sections body) => new-sections
-              ;; verify placeholder flag and content in response
-              (:placeholder resp-highlights) => true
-              resp-highlights => (contains placeholder)
-              ;; verify placeholder flag and content in DB
-              (:placeholder db-highlights) => true
-              db-highlights => (contains placeholder)))
-
-          (future-fact "that used to exist"
-            (let [new-sections {:company [] :progress [] :financial []}
-                  response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
-                  body (mock/body-from-response response)
-                  db-company (company/get-company conn r/slug)]
-              (:status response) => 200
-              (:sections body) => new-sections
-              ;; verify update is not in the response
-              (:update body) => nil
-              ;; verify update not in the DB
-              (:update db-company) => nil)
-            (let [new-sections {:company [] :progress ["update"] :financial []}
-                  response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections}})
-                  body (mock/body-from-response response)
-                  db-company (company/get-company conn r/slug)]
-              (:status response) => 200
-              (:sections body) => new-sections
-              ;; verify update is not in the response
-              (:update body) => (contains r/text-section-1)
-              ;; verify update not in the DB
-              (:update db-company) => (contains r/text-section-1))))
-
-        (facts "with section content"
-
-          (let [new-sections {:company ["help" "diversity" "values"]
-                              :progress ["update" "team" "kudos"]
-                              :financial ["finances"]}
-                kudos-placeholder (common-res/section-by-name "kudos")]
-
-            (future-fact "with minimal content"
-              (let [kudos-content {:body "Fred is killing it"}
-                    response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections
-                                                                                :kudos kudos-content}})
-                    body (mock/body-from-response response)
-                    db-company (company/get-company conn r/slug)]
-                (:status response) => 200
-                (:body response) => nil))
-
-            (future-fact "with maximal content"
-              (let [kudos-content {:title "Great Jobs!" :headline "Good stuff" :body "Fred is killing it"}
-                    response (mock/api-request :patch (company-rep/url r/slug) {:body {:sections new-sections
-                                                                                :kudos kudos-content}})
-                    body (mock/body-from-response response)
-                    db-company (company/get-company conn r/slug)]
-                (:status response) => 200
-                (:body response) => nil))
-
-            (future-fact "with too much content"
-
-              (future-fact "extra properties aren't allowed")
-
-              (future-fact "read/only properties are ignored")))))))))+          (future-fact "extra properties aren't allowed")
+
+          (future-fact "read/only properties are ignored")))))))


Remove fully qualified name.

Remove fully qualified name.

--- src/onyx/state/serializers/windowing_key_encoder.clj
+++ src/onyx/state/serializers/windowing_key_encoder.clj
@@ -2,8 +2,6 @@
   (:import [org.agrona.concurrent UnsafeBuffer]
            [java.nio ByteOrder]))

-;; TODO: try to remove the extra allocation in get-bytes
-;; It would be preferable to directly write from the buffer into LMDB
 (defprotocol PEncoder
   (set-state-idx [this idx])
   (set-group-id [this group-id])
@@ -59,7 +57,7 @@
   (set-min-extent [this]
     (set-extent this 0))
   (set-extent [this extent]
-    (.putLong buffer (unchecked-add-int offset 10) extent java.nio.ByteOrder/BIG_ENDIAN))
+    (.putLong buffer (unchecked-add-int offset 10) extent ByteOrder/BIG_ENDIAN))
   (length [this] 18)
   (wrap-impl [this bs]
     (.wrap buffer ^bytes bs))
@@ -80,8 +78,8 @@
     (let [[extent1 extent2] ee
           extent1-offset (unchecked-add-int offset 10)
           extent2-offset (unchecked-add-int offset 18)]
-      (.putLong buffer extent1-offset extent1 java.nio.ByteOrder/BIG_ENDIAN)
-      (.putLong buffer extent2-offset extent2 java.nio.ByteOrder/BIG_ENDIAN)))
+      (.putLong buffer extent1-offset extent1 ByteOrder/BIG_ENDIAN)
+      (.putLong buffer extent2-offset extent2 ByteOrder/BIG_ENDIAN)))
   (length [this] 26)
   (wrap-impl [this bs]
     (.wrap buffer ^bytes bs))
@@ -128,7 +126,7 @@
   (set-min-extent [this]
     (set-extent this 0))
   (set-extent [this extent]
-    (.putLong buffer 2 extent java.nio.ByteOrder/BIG_ENDIAN))
+    (.putLong buffer 2 extent ByteOrder/BIG_ENDIAN))
   (length [this] 10)
   (wrap-impl [this bs]
     (.wrap buffer ^bytes bs))
@@ -145,8 +143,8 @@
   (set-min-extent [this]
     (set-extent this [0 0]))
   (set-extent [this [extent1 extent2]]
-    (.putLong buffer 2 extent1 java.nio.ByteOrder/BIG_ENDIAN)
-    (.putLong buffer 10 extent2 java.nio.ByteOrder/BIG_ENDIAN))
+    (.putLong buffer 2 extent1 ByteOrder/BIG_ENDIAN)
+    (.putLong buffer 10 extent2 ByteOrder/BIG_ENDIAN))
   (length [this] 18)
   (wrap-impl [this bs]
     (.wrap buffer ^bytes bs))


Add tests for limit and offset.

Add tests for limit and offset.

--- test/suricatta/dsl_test.clj
+++ test/suricatta/dsl_test.clj
@@ -127,6 +127,14 @@
                 (dsl/order-by [:name :desc :nulls-last]))]
       (is (= (fmt/get-sql q)
              "select name from book order by name desc nulls last"))))
+
+  (testing "select with limit and offset"
+    (let [q (-> (dsl/select :name)
+                (dsl/from :book)
+                (dsl/limit 10)
+                (dsl/offset 100))]
+      (is (= (fmt/get-sql q)
+             "select name from book limit ? offset ?"))))
 )

 (deftest dsl-common-table-expressions


[#207] Maybe quick fix

[#207] Maybe quick fix

--- api/test/clojure/org/akvo/flow_api/datastore/user_test.clj
+++ api/test/clojure/org/akvo/flow_api/datastore/user_test.clj
@@ -63,12 +63,12 @@
         (testing "User is cached"
           (let [unique-email (uuid)]
             (create-user ds unique-email)
-            (is (some? (user-cache/id-by-email remote-api "akvoflowsanbox" unique-email)))
+            (is (some? (user-cache/id-by-email* remote-api "akvoflowsanbox" unique-email)))
             (delete-user ds unique-email)
-            (is (some? (user-cache/id-by-email remote-api "akvoflowsanbox" unique-email)))))
+            (is (some? (user-cache/id-by-email* remote-api "akvoflowsanbox" unique-email)))))

         (testing "Cache also if the user does not exist"
           (let [unique-email (uuid)]
-            (is (nil? (user-cache/id-by-email remote-api "akvoflowsanbox" unique-email)))
+            (is (nil? (user-cache/id-by-email* remote-api "akvoflowsanbox" unique-email)))
             (create-user ds unique-email)
-            (is (nil? (user-cache/id-by-email remote-api "akvoflowsanbox" unique-email)))))))))
+            (is (nil? (user-cache/id-by-email* remote-api "akvoflowsanbox" unique-email)))))))))


Restructure lein profile

Restructure lein profile

--- etc/lein/profiles.clj
+++ etc/lein/profiles.clj
@@ -1,8 +1,8 @@
 {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0"]
                        [org.clojure/tools.namespace "0.3.0-alpha4"]
+                       [cljfmt "0.6.4"]
                        [lambdaisland/kaocha "0.0-389"]]
         :repl-options {:color false}}
- :user {:plugins [[lein-cljfmt "0.4.1" :exclusions [org.clojure/clojure]]
-                  [lein-cloverage "1.0.6" :exclusions [org.clojure/clojure]]
-                  [lein-kibit "0.1.3" :exclusions [org.clojure/clojure]]
-                  [lein-ancient "0.6.15", :exclusions [org.clojure/clojure]]]}}
+ :user {:plugins [[lein-cljfmt "0.6.4"]
+                  [lein-cloverage "1.1.1"]
+                  [lein-ancient "0.6.15"]]}}


cd/ts| refactor tests, using with-started

--- test/de/otto/tesla/serving_with_jetty_test.clj
+++ test/de/otto/tesla/serving_with_jetty_test.clj
@@ -7,14 +7,14 @@
             [clj-http.client :as client]
             [de.otto.tesla.stateful.handler :as handlers]))

-(deftest should-start-up-jetty
-  (let [was-started (atom false)]
-    (with-redefs [jetty/run-jetty (fn [_ _]
-                                    (reset! was-started true)
-                                    nil)]
-      (let [started (system/start (with-jetty/add-server (system/base-system {})))
-            _       (system/stop started)]
-        (is (= true @was-started))))))
+(deftest add-server-test
+  (testing "it adds the jetty component to a system"
+    (let [was-started (atom false)]
+      (with-redefs [jetty/run-jetty (fn [_ _]
+                                      (reset! was-started true)
+                                      nil)]
+        (tutils/with-started [_ (system/start (with-jetty/add-server (system/base-system {})))]
+          (is (= true @was-started)))))))

 (deftest JettyServer-test
   (let [port 8081]
@@ -23,46 +23,41 @@
         (is (= 404
                (:status (client/get (format "http://localhost:%d" port) {:throw-exceptions false}))))))
     (testing "it returns the response of matching routes"
-        (tutils/with-started [system (with-jetty/add-server (system/base-system {:server-port port :status-url "/status-test"}))]
-          (is (= 200
-                 (:status (client/get (format "http://localhost:%d/status-test" port) {:throw-exceptions false}))))))))
+      (tutils/with-started [system (with-jetty/add-server (system/base-system {:server-port port :status-url "/status-test"}))]
+        (is (= 200
+               (:status (client/get (format "http://localhost:%d/status-test" port) {:throw-exceptions false}))))))))

-  (deftest determing-the-port
-    (testing "using the configured port"
-      (let [config {:config {:server-port 8081}}]
-        (is (= (with-jetty/port config) 8081))))
+(deftest port-test
+  (testing "uses the configured port"
+    (let [config {:config {:server-port 8081}}]
+      (is (= (with-jetty/port config) 8081))))
+  (testing "uses 8080 as default"
+    (let [config {:config {:config {}}}]
+      (is (= (with-jetty/port config) 8080)))))

-    (testing "using 8080 as default"
-      (let [config {:config {:config {}}}]
-        (is (= (with-jetty/port config) 8080)))))
+(deftest server-dependencies
+  (with-redefs [jetty/run-jetty (fn [_ _] nil)]
+    (testing "it starts up the server with no extra dependencies"
+      (let [system-with-server (with-jetty/add-server (system/base-system {}))]
+        (tutils/with-started [started (system/start system-with-server)]
+          (is (= #{:config :handler :jetty} (into #{} (keys (:server started))))))))

-  (deftest server-dependencies
-    (with-redefs [jetty/run-jetty (fn [_ _] nil)]
-      (testing "it starts up the server with no extra dependencies"
-        (let [system-with-server (with-jetty/add-server (system/base-system {}))
+    (testing "it starts up the server with extra dependencies"
+      (let [with-page (assoc (system/base-system {}) :dummy-page (Object.))
+            system-with-server (with-jetty/add-server with-page :dummy-page)]
+        (tutils/with-started [started (system/start system-with-server)]
+          (is (= #{:config :handler :jetty :dummy-page} (into #{} (keys (:server started))))))))))
+
+(deftest use-configurator
+  (testing "using the configurator from config"
+    (let [jetty-config (atom nil)]
+      (with-redefs [jetty/run-jetty (fn [_ config]
+                                      (reset! jetty-config config) nil)]
+        (let [my-configurator    identity
+              system-with-server (with-jetty/add-server (system/base-system {:jetty-options {:configurator my-configurator}}))
               started            (system/start system-with-server)
-              _                  (system/stop started)]
-          (is (= #{:config :handler :jetty} (into #{} (keys (:server started)))))))
+              stop               (system/stop started)]
+          (is (= (:configurator @jetty-config) my-configurator))))))

-      (testing "it starts up the server with extra dependencies"
-
-        (let [with-page (assoc (system/base-system {}) :dummy-page (Object.))]
-          (let [system-with-server (with-jetty/add-server with-page :dummy-page)
-                started            (system/start system-with-server)
-                _                  (system/stop started)]
-            (is (= #{:config :handler :jetty :dummy-page} (into #{} (keys (:server started))))))))))
-
-  (deftest use-configurator
-    (testing "using the configurator from config"
-      (let [jetty-config (atom nil)]
-        (with-redefs [jetty/run-jetty (fn [_ config]
-                                        (reset! jetty-config config) nil)]
-          (let [my-configurator    identity
-                system-with-server (with-jetty/add-server (system/base-system {:jetty-options {:configurator my-configurator}}))
-                started            (system/start system-with-server)
-                stop               (system/stop started)]
-            (is (= (:configurator @jetty-config) my-configurator))
-            ))))
-
-    (testing "configurator should be extracted from config"
-      (is (= (with-jetty/jetty-options {:jetty-options {:configurator "test"}}) {:configurator "test"}))))+  (testing "configurator should be extracted from config"
+    (is (= (with-jetty/jetty-options {:jetty-options {:configurator "test"}}) {:configurator "test"}))))


Caught the custom sections not getting revisions bug in 3 failing tests.

--- test/open_company/integration/section/section_revision.clj
+++ test/open_company/integration/section/section_revision.clj
@@ -288,18 +288,23 @@
                                                                                r/coyote)))
                            (after :facts (c/delete-company! conn (:slug r/buffer)))]

-        (facts "with PUT"
-          (fact "update title"
-            (let [updated  (assoc r/text-section-1 :title "New Title")
-                  put-response (mock/api-request :put (section-rep/url (:slug r/buffer) :update) {:body updated})
-                  body     (mock/body-from-response put-response)
-                  company  (c/get-company conn (:slug r/buffer))]
-              (:status put-response) => 200
-              (-> company :update :placeholder) => falsey
-              body => (contains updated)
-              (:placeholder body) => falsey)))
-
-        (facts "with PATCH"
+        (facts "with a PUT of the section"
+          (doseq [topic [:update :custom-c3p0]]
+            (fact "update title"
+              (let [updated  (assoc r/text-section-1 :title "New Title")
+                    put-response (mock/api-request :put (section-rep/url (:slug r/buffer) topic) {:body updated})
+                    put-topic (mock/body-from-response put-response)
+                    company (c/get-company conn (:slug r/buffer))
+                    db-topic (company topic)
+                    db-topic-2 (s/get-section conn (:slug r/buffer) topic)]
+                (:status put-response) => 200
+                (:sections company) => ["update" "custom-c3p0"] ; still just 1 update section, prior defect
+                (count (s/list-revisions conn (:slug r/buffer) topic)) => 1
+                (doseq [test-topic [put-topic db-topic db-topic-2]]
+                  (:placeholder test-topic) => falsey
+                  test-topic => (contains updated))))))
+
+        (facts "with a PATCH of the section"
           (doseq [topic [:update :custom-c3p0]]
             (fact "update title"
               (let [updated  {:title "New Title"}
@@ -310,6 +315,25 @@
                     db-topic-2 (s/get-section conn (:slug r/buffer) topic)]
                 (:status response) => 200
                 (:sections company) => ["update" "custom-c3p0"] ; still just 1 update section, prior defect
+                (count (s/list-revisions conn (:slug r/buffer) topic)) => 1
+                (doseq [test-topic [patch-topic db-topic db-topic-2]]
+                  (:placeholder test-topic) => falsey
+                  (:title test-topic) => (:title updated))))))
+
+        (facts "with a PATCH of the company"
+          (doseq [topic [:update :custom-c3p0]]
+            (fact "update title"
+              (let [updated  {:title "New Title"}
+                    response (mock/api-request :patch (company-rep/url (:slug r/buffer)) {:body {:sections [:update :custom-c3p0]
+                                                                                topic updated}})
+                    patch-body (mock/body-from-response response)
+                    patch-topic (patch-body topic)
+                    company (c/get-company conn (:slug r/buffer))
+                    db-topic (company topic)
+                    db-topic-2 (s/get-section conn (:slug r/buffer) topic)]
+                (:status response) => 200
+                (:sections company) => ["update" "custom-c3p0"] ; still just 1 update section, prior defect
+                (count (s/list-revisions conn (:slug r/buffer) topic)) => 1
                 (doseq [test-topic [patch-topic db-topic db-topic-2]]
                   (:placeholder test-topic) => falsey
                   (:title test-topic) => (:title updated))))))


Added error message for when the HTTP get for getting the weather failed.

--- app/src/weather/localization.cljc
+++ app/src/weather/localization.cljc
@@ -8,7 +8,9 @@
                  :snow "It snowed!"
                  :hail "It hailed!"
                  :highest "Highest temp: "
-                 :lowest "Lowest temp: "})
+                 :lowest "Lowest temp: "
+                 :bad-request "Bad request! Maybe you are trying to look too
+                               far in the future or in the past?"})

 (defn tr
   [key]


Have web/start wait for completion [IMMUTANT-147]

--- modules/web/src/main/clojure/immutant/web/internal.clj
+++ modules/web/src/main/clojure/immutant/web/internal.clj
@@ -17,8 +17,10 @@

 (ns immutant.web.internal
   (:require
-   [immutant.registry  :as reg]
-   [immutant.utilities :as util])
+   [immutant.registry     :as reg]
+   [immutant.utilities    :as util]
+   [clojure.tools.logging :as log])
+
   (use [immutant.try :only [try-defn try-def]]))

 (def ^{:dynamic true} ^javax.servlet.http.HttpServletRequest current-servlet-request nil)
@@ -82,7 +84,8 @@
         wrapper (.createWrapper context)
         mapper (-> (reg/fetch "jboss.web")
                    (.getService)
-                   (.getMapper))]
+                   (.getMapper))
+        complete (promise)]
     (when-context-available
      context
      (doto wrapper
@@ -95,8 +98,11 @@
        (.addChild wrapper)
        (.addServletMapping sub-context-path name))
      (doseq [host (virtual-hosts)]
-       (.addWrapper mapper host (.getPath context) sub-context-path wrapper)))
-    wrapper))
+       (.addWrapper mapper host (.getPath context) sub-context-path wrapper))
+     (deliver complete true))
+    (if (deref complete 5000 nil)
+      wrapper
+      (log/error "Failed to install servlet for" context))))

 (try-defn reqs remove-servlet [sub-context-path wrapper]
   (let [context (reg/fetch "web-context")


Loading constants.clj in ns clause

Loading constants.clj in ns clause

--- rosado/processing/processing.clj
+++ rosado/processing/processing.clj
@@ -2,7 +2,8 @@
 ;; Roland Sadowski [szabla gmail com]

 (clojure/ns rosado.processing
-			(:import (processing.core PApplet PImage PGraphics PFont)))
+			(:import (processing.core PApplet PImage PGraphics PFont))
+			(:load-resources "constants.clj"))

 ;; used by functions in this lib. Use binding to set it
 ;; to an instance of processing.core.PApplet


fixing file test

fixing file test

--- test/celestial/test/ssh.clj
+++ test/celestial/test/ssh.clj
@@ -9,7 +9,7 @@

 (scenario
   (copy "localhost" "file://home/ronen/redis-sandbox.tar.gz" "/tmp")
-  (expect (interaction (put "localhost" "redis-sandbox.tar.gz" "/tmp"))))
+  (expect (interaction (put "localhost" "/home/ronen/redis-sandbox.tar.gz" "/tmp"))))

 (scenario
   (let [uri "http://dl.bintray.com/content/narkisr/boxes/redis-sandbox.tar.gz"


Only def android tests if ANDROID_HOME is set

Workaround for travis build until I figure out how to get it
to have the Android SDK *and* leiningen...

--- test/cljast/gradle_test.clj
+++ test/cljast/gradle_test.clj
@@ -16,11 +16,12 @@
                         (gradle/get-dependencies)
                         )))))

-(deftest android-project-test
-  (testing "classpath"
-    (let [cp (gradle/classpath android-proj-dir)]
-      (is (not-empty cp))
-      (is (.exists (file (first cp))))
-      )))
+(when (System/getenv "ANDROID_HOME")
+  (deftest android-project-test
+    (testing "classpath"
+      (let [cp (gradle/classpath android-proj-dir)]
+        (is (not-empty cp))
+        (is (.exists (file (first cp))))
+        ))))

 ;; (clojure.test/run-tests)


Adds basic test for map-of spec

Adds basic test for map-of spec

--- test/expound/spec_test.cljc
+++ test/expound/spec_test.cljc
@@ -572,4 +572,32 @@
 Detected 2 errors"
          (e.s/pretty-explain-str :cat-wrapped-in-or-spec/kv-or-string {"foo" "hi"}))))

-;; TODO - need to add unit tests for map-of specs!!!
+(s/def :map-of-spec/name string?)
+(s/def :map-of-spec/age pos-int?)
+(s/def :map-of-spec/name->age (s/map-of :map-of-spec/name :map-of-spec/age))
+(deftest map-of-spec
+  (is (= "-- Spec failed --------------------
+
+  {\"Sally\" \"30\"}
+           ^^^^
+
+should satisfy
+
+  pos-int?
+
+-- Relevant specs -------
+
+:map-of-spec/age:
+  cljs.core/pos-int?
+:map-of-spec/name->age:
+  (cljs.spec.alpha/map-of :map-of-spec/name :map-of-spec/age)
+
+-------------------------
+Detected 1 error"
+         (e.s/pretty-explain-str :map-of-spec/name->age {"Sally" "30"})))
+  ;; FIXME - this won't work due to an issue with how 'in' paths work
+  ;; when they key itself is invalid. See
+  ;; https://dev.clojure.org/jira/browse/CLJ-2080
+  ;; for context (but not a full fix)
+  #_(is (= "foobar"
+           (er/pretty-explain-str :map-of-spec/name->age {:sally 30}))))


Converted TPN command output

Converted TPN command output

Now the following slots are used
:command -- just the method name
:args -- a vector of positional args
:argsmap a map of formal arg -> arg values

Also json/pprint added the option :escape-slash false
FFI: http://clojure.github.io/data.json/#clojure.data.json/write

Signed-off-by: Tom Marble <b248307e886b80bf9cb4014595572a835b049bf4@info9.net>

--- src/main/clj/pamela/tpn.clj
+++ src/main/clj/pamela/tpn.clj
@@ -524,14 +524,15 @@
             net-objects (build-non-primitive non-primitive)
             network-id (:network-id net-objects)
             non-primitive (or network-id false)
+            positional-args (mapv #(first (vals %)) args)
+            argsmap (apply merge args)
             act-details (if delay?
                           {:controllable (or controllable false)}
                           {:plant (str pclass)
                            :plantid (or id "")
-                           ;; :command method
-                           :command (if (pos? (count args))
-                                      (apply str method " " args)
-                                      method)
+                           :command method
+                           :args positional-args
+                           :argsmap argsmap
                            :controllable (or controllable false)
                            :non-primitive non-primitive})
             act-details (assoc-if act-details
@@ -1070,8 +1071,10 @@
         out-format (or out-format "tpn")
         out (case out-format
               "tpn" (with-out-str (pp/pprint tpn))
-              "json" (with-out-str (json/pprint tpn))
-              "cytoscape" (with-out-str (json/pprint (tpn->cytoscape tpn)))
+              "json" (with-out-str (json/pprint tpn :escape-slash false))
+              "cytoscape" (with-out-str
+                            (json/pprint (tpn->cytoscape tpn)
+                              :escape-slash false))
               "dot" (tpn->dot tpn)
               ;; default
               (str "ERROR: unknown format: " out-format))]
@@ -1133,8 +1136,10 @@
                 "tpn" tpn
                 ;; consider...
                 ;; "tpn" (with-out-str (pp/pprint tpn))
-                "json" (with-out-str (json/pprint tpn))
-                "cytoscape" (with-out-str (json/pprint (tpn->cytoscape tpn)))
+                "json" (with-out-str (json/pprint tpn) :escape-slash false)
+                "cytoscape" (with-out-str
+                              (json/pprint (tpn->cytoscape tpn)
+                                :escape-slash false))
                 "dot" (tpn->dot tpn)
                 ;; default
                 (str "ERROR: unknown format: " out-format))]


Extend and clean-up game credits topology tests

--- clstreams/test/clstreams/examples/game_credits/topology_test.clj
+++ clstreams/test/clstreams/examples/game_credits/topology_test.clj
@@ -31,8 +31,12 @@
         edn-des (serdes/edn-deserializer)

         process (fn [k v] (.process driver "game-credits-requests" k v str-ser edn-ser))
-        read-output (fn [] (prod-record->map
-                            (.readOutput driver "game-credits-requests-errors" str-des edn-des)))
+
+        read-error-event
+        (fn [] (prod-record->map
+                (.readOutput driver
+                             "game-credits-requests-errors"
+                             str-des edn-des)))

         account-key "gamer1"]

@@ -46,19 +50,25 @@
         (is (= type ::st/account-created))
         (is (= balance 0))
         (is (nil? credits))
-        (is (nil? errors))))
+        (is (nil? errors)))
+
+      (is (nil? (read-error-event)) "no error was produced"))

     (testing "using more credits than available results in an error"
-      (.put states account-key {:balance 7})
-      (process account-key {:type ::st/use-credits-requested
-                            :credits 10})
-      (let [{key :key {:keys [type balance credits errors]} :value :as out} (read-output)]
-        (is (some? out))
+      (let [state {:balance 7}]
+        (.put states account-key state)

-        (is (= key account-key))
+        (process account-key {:type ::st/use-credits-requested
+                              :credits 10})
+        (let [{key :key {:keys [type balance credits errors]} :value :as out} (read-error-event)]
+          (is (some? out))

-        (is (= type ::st/insufficient-credits-error))
-        (is (nil? balance))
-        (is (nil? credits))
-        (is (some? errors))))))
+          (is (= key account-key))

+          (is (= type ::st/insufficient-credits-error))
+          (is (nil? balance))
+          (is (nil? credits))
+          (is (some? errors)))
+
+        (is (= (.get states account-key) state) "state wasn't changed")))))
+


add autodocs.edn file

add autodocs.edn file

--- src/core.clj
+++ src/core.clj
@@ -21,6 +21,8 @@

 (def docs-branch "docs")
 (def examples-branch "examples")
+
+(def edn-output-file "autodocs.edn")

 ;; location of the documents generated by this program
 (def ^:dynamic *output-dir* nil)
@@ -493,8 +495,6 @@

 (defn transform-repl-special-doc
   [doc-map]
-  (println "repl-special-doc-map")
-  (prn doc-map)
   (let [transform-val (fn [value]
                         (-> value
                             (rename-keys {:doc :docstring, :arglists :signatures})
@@ -784,10 +784,31 @@
     (spit filename cljsdoc-content) ;; use `:append true` to see overwrites
     ))

+(defn dump-edn-file!
+  [api]
+  (let [outfile (str *output-dir* "/" edn-output-file)
+        transform (fn [x]
+                    (-> x
+                        (select-keys [:full-name
+                                      :ns
+                                      :name
+                                      :type
+                                      :signatures
+                                      :history
+                                      :return-type
+                                      :filename
+                                      :github-link
+                                      :source])
+                        (rename-keys {:filename    :source-filename
+                                      :github-link :source-link})))
+        outdata (map transform api)]
+  (spit outfile (pr-str outdata))))
+
 (defn dump-api-docs!
   [api]
   (doseq [item api]
-    (dump-doc-file! item)))
+    (dump-doc-file! item))
+  (dump-edn-file! api))

 ;;------------------------------------------------------------
 ;; Examples Scraping from clojuredocs.org


Add `defmacro` to list of forms supported by `def-form?`

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -1618,7 +1618,7 @@
 (defn- def-form?
   "Determines if the expression is a def expression which returns a Var."
   [expression-form]
-  (call-form? expression-form '#{def defn defn- defonce defmulti}))
+  (call-form? expression-form '#{def defn defn- defonce defmulti defmacro}))

 (defn- process-execute-source
   [source-text expression-form


Incorrect name in ->>

Incorrect name in ->>

--- src/aerobio/htseq/tnseq.clj
+++ src/aerobio/htseq/tnseq.clj
@@ -272,7 +272,7 @@
      (if (not (fs/exists? aggr-file))
        (get-comparison-files- eid true)
        (let [aggr (cmn/get-exp-info eid :rep :aggrs)
-             compvec (->> comp-filename
+             compvec (->> aggr-filename
                           (fs/join (pams/get-params :nextseq-base) eid)
                           slurp csv/read-csv rest)]
          compvec


Improves requests insertion to avoid concurrent collections

--- jar-async/src/slipstream/async/collector.clj
+++ jar-async/src/slipstream/async/collector.clj
@@ -20,15 +20,30 @@
   [msecs]
   (/ msecs 1000))

+(defn get-name
+  [user]
+  (.getName user))
+
 (def busy (atom #{}))

 (defn- mark-busy
  [current-busy v]
  (conj current-busy v))

-(defn- free
+(defn- mark-free
  [current-busy v]
  (disj current-busy v))
+
+(defn- busy? [u c]
+  (@busy [(get-name u) c]))
+
+(defn- busy!
+  [u c]
+  (swap! busy mark-busy [(get-name u) c]))
+
+(defn- free!
+  [u c]
+  (swap! busy mark-free [(get-name u) c]))

 (def collector-chan-size 512)
 (def number-of-readers 32)
@@ -57,10 +72,6 @@
 (defn online-users
   []
   (filter online? (users)))
-
-(defn get-name
-  [user]
-  (.getName user))

 ; This is the channel for queuing the online user requests
 (def online-collector-chan (chan (sliding-buffer collector-chan-size)))
@@ -110,7 +121,7 @@
     (go
       (let [ [v _] (alts! [ch (timeout timeout-collect-reader-release)])
              elapsed (- (System/currentTimeMillis) start-ts) ]
-        (swap! busy free [(get-name user) connector])
+        (free! user connector)
         (cond
           (nil? v) (log-timeout user connector elapsed)
           (= v Collector/NO_CREDENTIALS) (log-no-credentials user connector elapsed)
@@ -130,8 +141,7 @@
     (go
       (while true
         (let [[[user connector] ch] (alts! [chan (timeout timeout-processing-loop)])]
-          (when (not-nil? user)
-            (swap! busy mark-busy [(get-name user) connector])
+          (when (not-nil? user)
             (try
               (log/log-info (str "executing collect request for " (get-name user) " and " (.getConnectorInstanceName connector)))
               (collect! user connector)
@@ -159,13 +169,17 @@
           ucts (add-increasing-space ucs (int (/ time-to-spread (count ucs))))]
       (check-channel-size users connectors)
       (doseq [[u c t] ucts]
-        (if-not (@busy [(get-name u) c])
+        (if (busy? u c)
+          (log/log-info context ": avoiding inserting on " (user-connector u c) " being in a process.")
           (go
             (<! (timeout t))
-            (log/log-info "Inserting collect request for " (user-connector u c) " after timeout " t)
-            (>! chan [u c]))
-          (log/log-info "Avoiding working on " (user-connector u c) " being in a process." ))))
-    (log/log-info "No users to collect for " context)))
+            (if-not (busy? u c)
+              (do
+                (busy! u c)
+                (>! chan [u c])
+                (log/log-info context ": Inserted collect request for " (user-connector u c) " after timeout " t))
+              (log/log-info context ": Avoiding working on " (user-connector u c) " being in a process.")))))
+    (log/log-info context ": No users to collect"))))

 ; Start collector writers
 (defn collect-writers


releasing hface client 0.1.0

releasing hface client 0.1.0

--- client/project.clj
+++ client/project.clj
@@ -1,4 +1,4 @@
-(defproject com.gitpod/hface-client "0.1.0-SNAPSHOT"
+(defproject com.gitpod/hface-client "0.1.0"
   :description "look your Hazelcast cluster in the face!"
   :url "https://github.com/tolitius/hface"
   :license {:name "Eclipse Public License"
@@ -6,15 +6,23 @@

   :java-source-paths ["src/java"]

-  :dependencies [[chazel "0.1.0-SNAPSHOT"]]
+  :dependencies [[chazel "0.1.0"]]

-  :scm {:url "https://github.com/tolitius/hface.git"}
+  :scm {:name "git"
+        :url "https://github.com/tolitius/hface.git"}

-  :pom-addition [:developers [:developer {:id "tolitius"}
-                             [:name "Anatoly"]
-                             [:url "https://github.com/tolitius"]]]
+  :pom-addition [:developers [:developer
+                               [:id "tolitius"]
+                               [:name "Anatoly"]
+                               [:url "https://github.com/tolitius"]]]

   :deploy-repositories {"releases" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
                                     :creds :gpg}
                         "snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots/"
-                                     :creds :gpg}})
+                                     :creds :gpg}}
+
+  :classifiers {:javadoc {:java-source-paths ^:replace ["src/java"]
+                          :source-paths ^:replace []
+                          :resource-paths ^:replace []}
+                :sources {:java-source-paths ^:replace ["src/java"]
+                          :resource-paths ^:replace []}})


whitespace

whitespace

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -55,7 +55,6 @@
                       :physical-object true
                       :place false
                       :speakable false}
-
    {:consumable
     false}           {:drinkable false
                       :edible false}


Example how to change database connection pool.

--- src/ruuvi_server/standalone/config.clj
+++ src/ruuvi_server/standalone/config.clj
@@ -2,6 +2,7 @@
   (:use korma.db)
   (:use ruuvi-server.database)
   (:use ruuvi-server.models.entities)
+  (:require [korma.config :as conf])
   )

 (defn init-config []
@@ -13,7 +14,18 @@
      :password "ruuvi"
      :subname "//localhost/ruuvi_server"})
   (def *server-port* 8080)
-
-  (defdb db (postgres (create-connection-pool *database-config*)))
+
+  (defn- db-with-connection-pool [spec]
+    (let [engine-conf (postgres spec)]
+      (defonce db {:pool (create-connection-pool spec)
+                   :options (conf/extract-options engine-conf)})
+      (default-connection db)
+      )
+    )
+
+
+  (defdb db (postgres *database-config*))
+  ;; setup korma to use connection pool of my choosing
+  ;;(db-with-connection-pool *database-config*)
   (init-entities)
-  )+)


Finished tests for hi-res data.

Finished tests for hi-res data.

--- test/cmr/opendap/tests/system/app/ous/params_v1.clj
+++ test/cmr/opendap/tests/system/app/ous/params_v1.clj
@@ -156,7 +156,7 @@
                            variable-ids)
                    (request/add-token-header {} (util/get-sit-token)))]
     (is (= 200 (:status response)))
-    (is (= ["https://f5eil01.edn.ecs.nasa.gov/opendap/DEV01/user/FS2/DEMO/MUR-JPL-L4-GLOB-v4_1.001/2018.05.23/20180523090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc.nc?analysed_sst,analysis_error,lat,lon"]
+    (is (= ["https://f5eil01.edn.ecs.nasa.gov/opendap/DEV01/user/FS2/DEMO/MUR-JPL-L4-GLOB-v4_1.001/2018.05.23/20180523090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc.nc?analysed_sst,lat,lon"]
            (util/parse-response response)))))

 (deftest collection-GET-query-coverage-subset-hires
@@ -173,7 +173,7 @@
                            granule-id)
                    (request/add-token-header {} (util/get-sit-token)))]
     (is (= 200 (:status response)))
-    (is (= ["XXX"]
+    (is (= ["https://f5eil01.edn.ecs.nasa.gov/opendap/DEV01/user/FS2/DEMO/MUR-JPL-L4-GLOB-v4_1.001/2018.05.23/20180523090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc.nc?analysed_sst[0:1:0][13161:1:17071][10630:1:11419],analysis_error[0:1:0][13161:1:17071][10630:1:11419],mask[0:1:0][13161:1:17071][10630:1:11419],sea_ice_fraction[0:1:0][13161:1:17071][10630:1:11419],lat[13161:1:17071],lon[10630:1:11419]"]
            (util/parse-response response)))))

 (deftest collection-GET-query-coverage-subset-rangesubset-hires
@@ -193,5 +193,5 @@
                            variable-ids)
                    (request/add-token-header {} (util/get-sit-token)))]
     (is (= 200 (:status response)))
-    (is (= ["XXX"]
+    (is (= ["https://f5eil01.edn.ecs.nasa.gov/opendap/DEV01/user/FS2/DEMO/MUR-JPL-L4-GLOB-v4_1.001/2018.05.23/20180523090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc.nc?analysed_sst[0:1:0][13161:1:17071][10630:1:11419],lat[13161:1:17071],lon[10630:1:11419]"]
            (util/parse-response response)))))


Minor cleanup of stacktrace processing names and docstring

--- Clojure/src/ambly/repl/jsc.clj
+++ Clojure/src/ambly/repl/jsc.clj
@@ -51,8 +51,8 @@
        :line     (Long/parseLong line)
        :column   (Long/parseLong column)})))

-(defn process-exception
-  "Process a JSC stack representation parsing it into stack frames."
+(defn raw-stacktrace->frames
+  "Parse a raw JSC stack representation, parsing it into stack frames."
   [raw-stacktrace]
   (apply vector
     (remove nil?
@@ -70,7 +70,7 @@
         {:status (keyword (:status result))
          :value  (:value result)}
         (when-let [raw-stacktrace (:stacktrace result)]
-          {:stacktrace (process-exception raw-stacktrace)})))))
+          {:stacktrace (raw-stacktrace->frames raw-stacktrace)})))))

 (defn load-javascript
   "Load a Closure JavaScript file into the JSC REPL process."


fix bot fake user client lookup

fix bot fake user client lookup

--- src/braid/common/state.cljs
+++ src/braid/common/state.cljs
@@ -39,7 +39,7 @@
                u
                (let [g-id (@state :open-group-id)
                      group-bots (get-in @state [:groups g-id :bots])]
-                 (first (filter (fn [b] (= (b :user-id user-id)))
+                 (first (filter (fn [b] (= (b :user-id) user-id))
                                 group-bots)))))))

 (defn get-users


Refactor to use tail-call recursion

Refactor to use tail-call recursion

--- src/buildviz/testsuites.clj
+++ src/buildviz/testsuites.clj
@@ -70,22 +70,22 @@
       (update-in testsuite [testsuite-name] merge testcase )
       (assoc testsuite testsuite-name testcase))))

-(defn- build-hierarchy-recursivley [testsuite testcase-fail-frequencies]
+(defn- build-suite-hierarchy-recursivley [testsuite testcase-fail-frequencies]
   (if-let [next-testcase (first testcase-fail-frequencies)]
     (let [testcase-id (key next-testcase)
           fail-count (val next-testcase)]
-      (build-hierarchy-recursivley
+      (recur
        (assoc-testcase testsuite testcase-id fail-count)
        (rest testcase-fail-frequencies)))
     testsuite))

-(defn- build-hierarchy [testcase-fail-frequencies]
-  (build-hierarchy-recursivley {} testcase-fail-frequencies))
+(defn- build-suite-hierarchy [testcase-fail-frequencies]
+  (build-suite-hierarchy-recursivley {} testcase-fail-frequencies))

 (defn accumulate-testsuite-failures [test-runs]
   (->> (mapcat unroll-testcases test-runs)
        (failed-testcase-ids)
        (frequencies)
-       (build-hierarchy)
+       (build-suite-hierarchy)
        (testsuites-map->list)))


Make eastwood happy.

Make eastwood happy.

--- src/oc/storage/api/orgs.clj
+++ src/oc/storage/api/orgs.clj
@@ -130,7 +130,7 @@
 ;; ----- Validations -----

 (defn- is-first-org? [conn user]
-  {:pre (db-common/conn? conn)}
+  {:pre [(db-common/conn? conn)]}
   (let [authed-orgs (org-res/list-orgs-by-teams conn (:teams user))]
     (zero? (count authed-orgs))))


added with-options

added with-options

--- src/clj/datasplash/core.clj
+++ src/clj/datasplash/core.clj
@@ -52,13 +52,28 @@
       (let [rdr (transit/reader in :msgpack)]
         (transit/read rdr)))))

+(defmacro with-opts
+  [schema opts & body]
+  `(let [pcoll# (do ~@body)]
+     (reduce
+      (fn [pc# [k# f#]]
+        (if-let [v# (get ~opts k#)]
+          (f# pc# v#)
+          pc#))
+      pcoll# ~schema)))
+
+(def base-schema
+  {:named (fn [pcoll n] (.setName pcoll n))
+   :coder (fn [pcoll coder] (.setCoder pcoll coder))})
+
 (defn map-op
   ([transform coder]
    (fn
-     [f ^PCollection pcoll]
-     (-> pcoll
-         (.apply (ParDo/of (dofn (transform f))))
-         (.setCoder coder))))
+     [f opts ^PCollection pcoll]
+     (with-opts base-schema opts
+       (-> pcoll
+           (.apply (ParDo/of (dofn (transform f))))
+           (.setCoder coder)))))
   ([transform]
    (map-op transform (make-transit-coder))))

@@ -67,10 +82,11 @@
 (def dfilter (map-op filter-fn))

 (defn generate-input
-  [coll p]
-  (-> p
-      (.apply (Create/of (seq coll)))
-      (.setCoder (make-transit-coder))))
+  [coll opts ^Pipeline p]
+  (with-opts base-schema opts
+    (-> p
+        (.apply (Create/of (seq coll)))
+        (.setCoder (make-transit-coder)))))

 (defn- to-edn*
   [^DoFn$Context c]
@@ -81,10 +97,12 @@
 (def to-edn (partial (map-op identity (StringUtf8Coder/of)) to-edn*))

 (defn to-edn
-  [^PCollection pcoll]
-  (-> pcoll
-      (.apply (ParDo/of (dofn to-edn*)))
-      (.setCoder (StringUtf8Coder/of))))
+  ([opts ^PCollection pcoll]
+   (with-opts base-schema opts
+     (-> pcoll
+         (.apply (ParDo/of (dofn to-edn*)))
+         (.setCoder (StringUtf8Coder/of)))))
+  ([pcoll] (to-edn {} pcoll)))

 (defn make-pipeline
   [str-args]
@@ -92,11 +110,17 @@
         options (.create builder)]
     (Pipeline/create options)))

-(defn write-file
+(defn load-text-file
+  [from opts ^Pipeline p]
+  (-> p
+      (.apply (TextIO$Read/from from))
+      (.setCoder (StringUtf8Coder/of))))
+
+(defn write-text-file
   ([to opts ^PCollection pcoll]
    (-> pcoll
        (.apply (-> (TextIO$Write/to to)))))
-  ([to pcoll] (write-file to {} pcoll)))
+  ([to pcoll] (write-text-file to {} pcoll)))

 (comment
   (compile 'datasplash.core))
@@ -105,10 +129,10 @@
   [& args]
   (let [p (make-pipeline args)
         final (->> p
-                   (generate-input (range 10000))
-                   (dmap inc)
-                   (dfilter even?)
-                   (to-edn)
-                   (write-file "tee"))]
+                   (generate-input (range 10000) {:named "gengen"})
+                   (dmap inc {:named "map"})
+                   (dfilter even? {:named "filter"})
+                   (to-edn {:named "edn"})
+                   (write-text-file "tee"))]

     (.run p)))


added dgroup-by

added dgroup-by

--- src/clj/datasplash/core.clj
+++ src/clj/datasplash/core.clj
@@ -8,7 +8,7 @@
            [com.google.cloud.dataflow.sdk Pipeline]
            [com.google.cloud.dataflow.sdk.io TextIO$Read TextIO$Write]
            [com.google.cloud.dataflow.sdk.transforms
-            DoFn DoFn$Context ParDo DoFnTester Create
+            DoFn DoFn$Context ParDo DoFnTester Create PTransform
             SerializableFunction WithKeys GroupByKey]
            [com.google.cloud.dataflow.sdk.values PCollection]
            [com.google.cloud.dataflow.sdk.coders ByteArrayCoder StringUtf8Coder CustomCoder Coder$Context]
@@ -129,6 +129,22 @@
          (.apply (GroupByKey/create)))))
   ([pcoll] (group-by-key {} pcoll)))

+(defn- group-by-transform
+  [f options]
+  (let [safe-opts (dissoc options :name)]
+    (proxy [PTransform] []
+      (apply [^PCollection pcoll]
+        (->> pcoll
+             (with-keys f safe-opts)
+             (group-by-key safe-opts))))))
+
+(defn dgroup-by
+  ([f options ^PCollection pcoll]
+   (let [opts (assoc options :label :group-by)]
+     (.apply pcoll (with-opts base-schema opts
+                     (group-by-transform f options)))))
+  ([f pcoll] (dgroup-by f {} pcoll)))
+
 (defn make-pipeline
   [str-args]
   (let [builder (PipelineOptionsFactory/fromArgs
@@ -157,6 +173,22 @@
                    (TextIO$Write/to to))))))
   ([to pcoll] (write-text-file to {} pcoll)))

+(defn- write-edn-file-transform
+  [to options]
+  (let [safe-opts (dissoc options :name)]
+    (proxy [PTransform] []
+      (apply [^PCollection pcoll]
+        (->> pcoll
+             (to-edn)
+             (write-text-file to options))))))
+
+(defn write-edn-file
+  ([to options ^PCollection pcoll]
+   (let [opts (assoc options :label :write-edn-file)]
+     (-> pcoll
+         (.apply (write-edn-file-transform to opts)))))
+  ([to pcoll] (write-edn-file to {} pcoll)))
+
 (comment
   (compile 'datasplash.core))

@@ -165,10 +197,8 @@
   (let [p (make-pipeline args)
         final (->> p
                    (generate-input [{:key :a :val 10} {:key :b :val 5} {:key :a :val 42}] {:name "gengen"})
-                   (with-keys :key {:name :group-by-key})
-                   (group-by-key)
-                   (dmap (fn [kv] (vector (.getKey kv) (.getValue kv))) )
-                   (to-edn {:name "edn"})
-                   (write-text-file "tee"))]
+                   (dgroup-by :key)
+                   (dmap (fn [kv] (vector (.getKey kv) (seq (.getValue kv)))) )
+                   (write-edn-file "gs://oscaro-test-dataflow/results/group-by.edn" {:name :output-edn}))]

     (.run p)))


Ace editor for HTML

Ace editor for HTML

--- src/cljs/tohiccup/core.cljs
+++ src/cljs/tohiccup/core.cljs
@@ -12,8 +12,8 @@
 (defonce app-state (atom
                     {:html-text ""
                      :hiccup-text ""}))
-
 (defonce hiccup-ace-editor (atom nil))
+(defonce html-ace-editor (atom nil))

 (declare beautify-hiccup)

@@ -43,22 +43,29 @@

 (defn set-ace-editor-value [ace-editor value]
   (let [cursor (.getCursorPositionScreen ace-editor)]
-    (.setValue ace-editor (@app-state :hiccup-text) cursor)))
+    (.. ace-editor getSession (setValue (@app-state :hiccup-text) cursor))))

 (defcomponentk html-input-view
   "HTML text input view"
   [state owner]
   (display-name [this] "HtmlArea")
-  (render-state [this {:keys [action-chan]}]
-    (html [:div
-           [:h2 "<html>"]
-           [:textarea
-            {:class "form-control"
-             :value (@app-state :html-text)
-             :onChange (fn [e]
-                         (let [new-value (.. e -target -value)]
-                           (put! action-chan [:update-hiccup new-value])
-                           (swap! app-state assoc :html-text new-value)))}]])))
+  (render [this] (html [:div
+                        [:h2 "<html>"]
+                        [:div {:ref "html-ace-editor"}]]))
+  (did-mount [this]
+    (let [action-chan (@state :action-chan)
+          ace-editor (.edit js/ace (om/get-node owner "html-ace-editor"))
+          ace-session (.getSession ace-editor)]
+      (.setOptions ace-editor (js-obj "minLines" 25 "maxLines" 25))
+      (.setTheme ace-editor "ace/theme/github")
+      (.setMode ace-session "ace/mode/html")
+      (reset! html-ace-editor ace-editor)
+      (.on ace-session "change"
+           #(put! action-chan [:update-hiccup
+                               (.getValue @html-ace-editor)])))))
+      ;(set-ace-editor-value ace-editor (@app-state :html-text))
+  ;(will-update [this _ {:keys [action-chan]}]
+  ;  (set-ace-editor-value @html-ace-editor (@app-state :html-text))))

 (defcomponentk hiccup-input-view
   "Hiccup text input view"
@@ -66,18 +73,20 @@
   (display-name [this] "HiccupArea")
   (render [this] (html [:div
                         [:h2 "[:hiccup]"]
-                        [:div#hiccup-ace-editor]]))
+                        [:div {:ref "hiccup-ace-editor"}]]))
   (did-mount [this]
-    (let [ace-editor (.edit js/ace "hiccup-ace-editor")]
+    (let [action-chan (@state :action-chan)
+          ace-editor (.edit js/ace (om/get-node owner "hiccup-ace-editor"))
+          ace-session (.getSession ace-editor)]
       (.setOptions ace-editor (js-obj "minLines" 25 "maxLines" 25))
       (.setTheme ace-editor "ace/theme/github")
-      (.setMode (.getSession ace-editor) "ace/mode/clojure")
+      (.setMode ace-session "ace/mode/clojure")
       (.setReadOnly ace-editor true) ; Read-only for now
-      (.. ace-editor
-          getSession
-          (on "change" #(put! (@state :action-chan) [:update-html (.getValue @hiccup-ace-editor)])))
-      (set-ace-editor-value ace-editor (@app-state :hiccup-text))
-      (reset! hiccup-ace-editor ace-editor)))
+      (reset! hiccup-ace-editor ace-editor)
+      (.on ace-session "change"
+           #(put! action-chan [:update-html
+                               (.getValue @hiccup-ace-editor)]))
+      (set-ace-editor-value ace-editor (@app-state :hiccup-text))))
   (will-update [this _ {:keys [action-chan]}]
     (set-ace-editor-value @hiccup-ace-editor (@app-state :hiccup-text))))


Refactor to plug several different ai

Refactor to plug several different ai

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -15,6 +15,7 @@
 ;; TODO - Try to plug the history of brower for "back"
 ;; TODO - Try to bring some domain vocabulary here: it gets too complicated to trace
 ;; TODO - http://www.w3schools.com/howto/howto_js_sidenav.asp
+;; TODO - http://www.w3schools.com/svg/svg_grad_radial.asp

 ;; -----------------------------------------
 ;; GAME PARAMETERS
@@ -25,7 +26,7 @@
 (def init-block-count 12) ;; Init blocks for red, blue, green, gray
 (def players [:blue :red :green])
 (def directions [[-1 0] [1 0] [0 -1] [0 1] [-1 1] [1 1] [-1 -1] [1 -1]])
-(def max-score (- (* 16 11) 12))
+(def max-score (- (* board-width board-height) init-block-count))

 ;; -----------------------------------------
 ;; EXTRINSIC TYPES
@@ -310,25 +311,34 @@
 (def board (reagent/cursor app-state [:board]))
 (def scores (reagent/cursor app-state [:scores]))
 (def current-player (reagent/cursor app-state [:player]))
-
-(def player-is-blue (reaction (= @current-player :blue)))
 (def end-of-game (reaction (nil? @current-player)))

+(def players-ai-algorithms
+  {:red best-move
+   :green best-move})
+
+(defn is-human?
+  [player]
+  (not (contains? players-ai-algorithms player)))
+
+
 ;; -----------------------------------------
 ;; GAME LOOP
 ;; -----------------------------------------

 (defn- handle-ai []
-  (let [move (time (best-move @app-state (:player @app-state)))]
+  (let [ai-algo (get players-ai-algorithms @current-player)
+        move (ai-algo @app-state @current-player)]
     (swap! app-state play-move move)))

 (defn start-game-loop
   "Manage transitions between player moves, ai moves, and generic game events"
   []
-  (let [is-human (fn [_] @player-is-blue)
-        is-ai (fn [_] (and (not @end-of-game) (not @player-is-blue)))
-        ai-events (chan 1 (filter is-ai))
-        player-events (chan 1 (filter is-human))
+  (let [game-on-xf (fn [_] (not @end-of-game))
+        is-human-xf (fn [_] (is-human? @current-player))
+        is-ai-xf (fn [_] (not (is-human? @current-player)))
+        ai-events (chan 1 (comp (filter game-on-xf) (filter is-ai-xf)))
+        player-events (chan 1 (comp (filter game-on-xf) (filter is-human-xf)))
         game-events (chan 1)]

     (go


Log exceptions during upload

Log exceptions during upload

--- src/clojars/routes/repo.clj
+++ src/clojars/routes/repo.clj
@@ -83,9 +83,13 @@

 (defn- throw-forbidden
   [e-or-message meta]
-  (let [[message cause] (if (instance? Throwable e-or-message)
+  (let [throwable? (instance? Throwable e-or-message)
+        [message cause] (if throwable?
                           [(.getMessage e-or-message) (.getCause e-or-message)]
                           [e-or-message])]
+    (when throwable?
+      (log/error {:tag :upload-exception
+                  :error e-or-message}))
     (throw-invalid
      message
      (merge
@@ -392,8 +396,8 @@
                     ;; maven-metadata.xml file doesn't match the one
                     ;; we already have
                     ;; https://github.com/clojars/clojars-web/issues/640
-                    (if-not (or (deploy-finalized? upload-dir)
-                              (= (fu/checksum file :sha1) existing-sum))
+                    (when-not (or (deploy-finalized? upload-dir)
+                                  (= (fu/checksum file :sha1) existing-sum))
                       (try
                         (finalize-deploy storage db search
                           account upload-dir)


idempotent db component

idempotent db component

--- src/clojento/magento/db.clj
+++ src/clojento/magento/db.clj
@@ -31,6 +31,7 @@
    (c/config configurator :db)))

 (defn make-datasource [configurator]
+  (l/info "starting connection pool")
   (hikari/make-datasource (datasource-options configurator)))

 ; TODO make idempotent
@@ -38,21 +39,17 @@
   component/Lifecycle

   (start [this]
-         (l/info "starting connection pool")
-
-         (let [ds (make-datasource configurator)]
-           ;; Return an updated version of the component with
-           ;; the run-time state assoc'd in.
-           (assoc this :datasource ds)))
+         (if datasource  ; already started
+           this
+           (assoc this :datasource (make-datasource configurator))))

   (stop [this]
-        (l/info "stopping connection pool")
-
-        (hikari/close-datasource datasource)
-        ;(.close connection)
-        ;; Return the component, optionally modified. Remember that if you
-        ;; dissoc one of a record's base fields, you get a plain map.
-        (assoc this :datasource nil)))
+        (if (not datasource) ; already stopped
+          this
+          (do
+            (l/info "stopping connection pool")
+            (hikari/close-datasource datasource)
+            (assoc this :datasource nil)))))

 (defn new-database []
   (map->Database {}))


Removing extra argument left in consume-all function by accident.

--- src/cmr/common/channels.clj
+++ src/cmr/common/channels.clj
@@ -71,7 +71,7 @@
 (defn consume-all
   "Consumes all the messages on the channel with the function f. Continues to wait until channel
   returns nil."
-  [chan f sleeper]
+  [chan f]
   (let [start (System/currentTimeMillis)]
     (loop [item (pull chan) num-items 1]
       (when item
@@ -129,7 +129,7 @@

   (process-tasks :tasks-fn #(range 4000)
                  :processor (fn [t]
-                              (info "processing " t)
+                              ; (info "processing " t)
                               (Thread/sleep 10))
                  :num-threads 4
                  :task-name "sleep-test")


Added channel-size option when processing tasks asynchronously.

--- src/cmr/common/channels.clj
+++ src/cmr/common/channels.clj
@@ -100,9 +100,11 @@
   * tasks-fn - a function that returns a sequence of tasks to process
   * processor - A function that can process a single task
   * num-threads - The number of threads to use to process the tasks
-  * task-name - The name of the task to use for logging"
-  [& {:keys [tasks-fn processor num-threads task-name]}]
-  (let [channel (channel 5)
+  * task-name - The name of the task to use for logging
+  * channel-size - Optionally indicate how many items can be buffered in the channel."
+  [& {:keys [tasks-fn processor num-threads task-name channel-size]
+      :or {channel-size 5}}]
+  (let [channel (channel channel-size)
         pusher (util/future-with-logging
                  (str task-name "Message Pusher")
                  (push-seq channel (tasks-fn))


clearer arg name

clearer arg name

--- storm-core/src/clj/backtype/storm/daemon/logviewer.clj
+++ storm-core/src/clj/backtype/storm/daemon/logviewer.clj
@@ -92,8 +92,8 @@
   (fn [req]
     (app (assoc req :log-root log-root))))

-(defn start-logviewer [port conf]
-  (run-jetty (conf-middleware logapp conf) {:port port}))
+(defn start-logviewer [port log-root]
+  (run-jetty (conf-middleware logapp log-root) {:port port}))

 (defn -main []
   (let [conf (read-storm-config)


Make renaming convention to Java names more strict

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/java.clj
+++ src/conexp/contrib/java.clj
@@ -17,15 +17,21 @@
 (defn- to-valid-Java-name
   "Convert old-name to a valid Java variable name."
   [old-name]
-  (let [new-name (-> (str old-name)
-                     (.replaceAll "-" "_")
-                     (.replaceAll " " "_")
-                     (.replaceAll "!" "_f")   ;assume ! only at end
-                     (.replaceAll "\\?" "_p") ;assume ? only at end
-                     (.replaceAll "<" "_lt_")
-                     (.replaceAll ">" "_gt_")
-                     (.replaceAll "=" "_eq_"))]
-    (symbol new-name)))
+  (let [old-name (str old-name),
+        length   (count old-name)]
+    (when (<= 0 (.indexOf old-name "!") (- length 2))
+      (illegal-argument "Name has exclamation mark not as last symbol."))
+    (when (<= 0 (.indexOf old-name "?") (- length 2))
+      (illegal-argument "Name has question mark not as last symbol."))
+    (-> old-name
+        (.replace "-" "_")
+        (.replace " " "_")
+        (.replace "!" "_f")             ;assume ! only at end
+        (.replace "?" "_p")             ;assume ? only at end
+        (.replace "<" "_lt_")
+        (.replace ">" "_gt_")
+        (.replace "=" "_eq_")
+        symbol)))

 (defn- conexp-functions
   "Returns a hash-map of function names to vars of ns. The function


[caffe io] support an additional way of specifying input dims in model text description (#21)

--- cortex/src/cortex/nn/caffe.clj
+++ cortex/src/cortex/nn/caffe.clj
@@ -118,14 +118,18 @@
   [layer-param]
   (println "Found unknown layer type: " (.getType layer-param)))

-
 (defn model-to-input
+  "Munges input description from caffe model file to cortex input desc.
+  Note that `getInputDimList` and `getInputShapeList` are two ways of
+  reading this based on version/type of caffe model file and there may
+  be others we haven't yet tried to support."
   [model]
-  (let [input-shape-data (first (.getInputShapeList model))
-        dims (into [] (.getDimList input-shape-data))
-        [input-batch-size n-channels width height] dims]
-    (assoc (first (desc/input width height n-channels)) :output-data-format :planar)))
-
+  (let [[batch-size n-chan width height] (or (.getInputDimList model)
+                                             (-> (.getInputShapeList model)
+                                                 first
+                                                 (.getDimList)
+                                                 (into [])))]
+    (assoc (first (desc/input width height n-chan)) :output-data-format :planar)))

 (defn caffe->description
   [proto-model trained-model]


forms can have cursor too

forms can have cursor too

--- cljs/src/main/plastic/main/editor/render/editor.cljs
+++ cljs/src/main/plastic/main/editor/render/editor.cljs
@@ -61,14 +61,17 @@
           (dispatch :editor-toggle-selection editor-id #{selected-node-id}))))))

 (defn form-component [editor-id form-id]
-  (let [focused-form? (subscribe [:editor-focused-form-node editor-id form-id])]
+  (let [focused-form? (subscribe [:editor-focused-form-node editor-id form-id])
+        cursor? (subscribe [:editor-cursor-node editor-id (id/make form-id :root)])]
     (fn [editor-id form-id]
       (log-render "form" form-id
         [:tr
          [:td
           [:div.form
            {:data-qnid form-id
-            :class     (if @focused-form? "focused")
+            :class     (classv
+                         (if @cursor? "cursor")
+                         (if @focused-form? "focused"))
             :on-click  (partial handle-form-click form-id)}
            [form-skelet-component editor-id form-id]]]]))))


remove unused param

remove unused param

--- cljs/src/main/plastic/cogs/editor/layout/core.cljs
+++ cljs/src/main/plastic/cogs/editor/layout/core.cljs
@@ -37,8 +37,8 @@
         selectables (utils/extract-all-selectables render-tree)
         spatial-web (build-spatial-web render-tree)
         structural-web (build-structural-web top-id selectables root-loc)
-        layout-info {:id             root-id
-                     :node           root-node
+        layout-info {:id             root-id                ; also known as form-id
+                     :node           root-node              ; source node - used for optimization
                      :selectables    selectables            ; used for selections
                      :spatial-web    spatial-web            ; used for spatial left/right/up/down movement
                      :structural-web structural-web         ; used for structural left/right/up/down movement
@@ -46,7 +46,7 @@
     (log "LAYOUT: form #" root-id "=> render-info:" layout-info)
     layout-info))

-(defn prepare-render-infos-of-top-level-forms [independent-top-level-locs settings editor form-id]
+(defn prepare-render-infos-of-top-level-forms [independent-top-level-locs settings editor]
   (let [prepare-item (fn [loc]
                        (let [node (z/node loc)
                              old-render-info (editor/get-render-info-by-id editor (:id node))]
@@ -55,21 +55,21 @@
                            (prepare-form-layout-info settings loc))))]
     (into {} (map (fn [loc] [(zip-utils/loc-id loc) (prepare-item loc)]) independent-top-level-locs))))

-(defn layout-editor [settings form-id editor]
+(defn layout-editor [settings editor]
   (if-not (editor/parsed? editor)
     editor
     (let [independent-top-level-locs (map zip/down (map zip-utils/independent-zipper (editor/get-top-level-locs editor)))
           render-state {:order             (map #(zip-utils/loc-id %) independent-top-level-locs)
-                        :forms             (prepare-render-infos-of-top-level-forms independent-top-level-locs settings editor form-id)
+                        :forms             (prepare-render-infos-of-top-level-forms independent-top-level-locs settings editor)
                         :debug-parse-tree  (editor/get-parse-tree editor)
                         :debug-text-input  (editor/get-input-text editor)
                         :debug-text-output (editor/get-output-text editor)}]
       (-> editor
         (editor/set-render-state render-state)))))

-(defn update-layout [db [editor-selector form-id]]
+(defn update-layout [db [editor-selector]]
   (let [{:keys [editors settings]} db
-        new-editors (editor/apply-to-specified-editors (partial layout-editor settings form-id) editors editor-selector)]
+        new-editors (editor/apply-to-specified-editors (partial layout-editor settings) editors editor-selector)]
     (assoc db :editors new-editors)))

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


Fix exception being thrown when pressing CTRL-D

--- src/containium/commands.clj
+++ src/containium/commands.clj
@@ -19,8 +19,11 @@
 (defn parse-quoted
   "Parses quoted parts in a command string. Returns [command & args]"
   [string]
-  (map (fn [[normal quoted]] (or quoted normal))
-       (re-seq #"'([^']+)'|[^\s]+" (trim string))))
+  (if-not (nil? string)
+    (map (fn [[normal quoted]] (or quoted normal))
+         (re-seq #"'([^']+)'|[^\s]+" (trim string)))
+  ;else
+    ["shutdown"]))

 ;;; Actual commands.