adjust test for short-circuit based on new implementaiton

--- test/clj_money/models/transactions_test.clj
+++ test/clj_money/models/transactions_test.clj
@@ -788,18 +788,7 @@
              #((fnil conj #{}) % (select-keys item [:index
                                                    :quantity
                                                    :balance]))))
-
-(defn- fake-update-item-index-and-balance
-  [context update-calls storage-spec item]
-  (swap! update-calls (partial record-update-call item))
-  (let [existing-item (->> context
-                           :transactions
-                           (mapcat :items)
-                           (filter #(= (:id item) (:id %)))
-                           first)]
-    (not= (select-keys item [:index :balance])
-          (select-keys existing-item
-                       [:index :balance]))))
+(def ^:dynamic real-upsert-item nil)

 ; Trans. Date quantity  Debit     Credit
 ; 2016-03-02    1000  Checking  Salary
@@ -817,31 +806,30 @@
                     (rename-keys {:transaction-date :original-transaction-date})
                     (assoc :transaction-date (t/local-date 2016 3 8)))
         update-calls (atom {})]
-    (with-redefs [transactions/update-item-index-and-balance (partial fake-update-item-index-and-balance
-                                                                      context
-                                                                      update-calls)]
-      (let [result (transactions/update storage-spec updated)
-            expected #{{:index 1
-                        :quantity 102M
-                        :balance 898M}
-                       {:index 2
-                        :quantity 101M
-                        :balance 797M}
-                       {:index 3
-                        :quantity 103M
-                        :balance 694M}} ; The first update that doesn't change
-                                        ; a value stops the chain.
-                                        ; The 4th item should never be updated
-                                        ; because the 3rd one did not change a value.
-            actual (get @update-calls (:id checking))]
-        (is (empty? (validation/error-messages result))
-            "The transaction is saved successfully")
-        (testing "the expected transactions are updated"
-          (pprint-diff expected actual)
-          (is (= expected actual)
-              "Only items with changes are updated")
-          (is (not-any? #(= (:index %) 4) actual) "The last item is never updated"))
-        (assert-account-quantities checking 590M)))))
+    (binding [real-upsert-item transactions/upsert-item]
+      (with-redefs [transactions/upsert-item (fn [storage item]
+                                               (swap! update-calls
+                                                      (partial record-update-call item))
+                                               (real-upsert-item storage item))]
+        (let [result (transactions/update storage-spec updated)
+              expected #{{:index 1
+                          :quantity 102M
+                          :balance 898M}
+                         {:index 2
+                          :quantity 101M
+                          :balance 797M}
+                         {:index 2 ; The item will be written once before item stats are recalculated
+                          :quantity 102M
+                          :balance 0M}}
+              actual (get @update-calls (:id checking))]
+          (is (empty? (validation/error-messages result))
+              "The transaction is saved successfully")
+          (testing "the expected transactions are updated"
+            (pprint-diff expected actual)
+            (is (= expected actual)
+                "Only items with changes are updated")
+            (is (not-any? #(= (:index %) 4) actual) "The last item is never updated"))
+          (assert-account-quantities checking 590M))))))

 (def change-account-context
   (-> base-context


DRY up category path testing.

DRY up category path testing.

--- test/fcms/unit/resources/taxonomy/paths.clj
+++ test/fcms/unit/resources/taxonomy/paths.clj
@@ -6,34 +6,38 @@

 (def tax "tax")

-(facts "about taxonomy slug parsing from a category path"
-  (taxonomy-slug-from-path "tax") => tax
-  (taxonomy-slug-from-path "tax/") => tax
-  (taxonomy-slug-from-path "/tax") => tax
-  (taxonomy-slug-from-path "/tax/") => tax
-  (taxonomy-slug-from-path "tax/a") => tax
-  (taxonomy-slug-from-path "tax/a/") => tax
-  (taxonomy-slug-from-path "/tax/a") => tax
-  (taxonomy-slug-from-path "/tax/a/") => tax
-  (taxonomy-slug-from-path "tax/a/b") => tax
-  (taxonomy-slug-from-path "tax/a/b/") => tax
-  (taxonomy-slug-from-path "/tax/a/b") => tax
-  (taxonomy-slug-from-path "/tax/a/b/") => tax)
+(tabular (facts "about taxonomy slug parsing from a category path"
+  (taxonomy-slug-from-path ?category-path) => tax)
+  ?category-path
+  "tax"
+  "tax/"
+  "/tax"
+  "/tax/"
+  "tax/a"
+  "tax/a/"
+  "/tax/a"
+  "/tax/a/"
+  "tax/a/b"
+  "tax/a/b/"
+  "/tax/a/b"
+  "/tax/a/b/")

-(facts "about category slug parsing from a category path"
-  (category-slugs-from-path "tax") => []
-  (category-slugs-from-path "tax/") => []
-  (category-slugs-from-path "/tax") => []
-  (category-slugs-from-path "/tax/") => []
-  (category-slugs-from-path "tax/a") => ["a"]
-  (category-slugs-from-path "tax/a/") => ["a"]
-  (category-slugs-from-path "/tax/a") => ["a"]
-  (category-slugs-from-path "/tax/a/") => ["a"]
-  (category-slugs-from-path "tax/a/b") => ["a" "b"]
-  (category-slugs-from-path "tax/a/b/") => ["a" "b"]
-  (category-slugs-from-path "/tax/a/b") => ["a" "b"]
-  (category-slugs-from-path "/tax/a/b/") => ["a" "b"]
-  (category-slugs-from-path "tax/a/b/c-d-e/f/g") => ["a" "b" "c-d-e" "f" "g"]
-  (category-slugs-from-path "tax/a/b/c-d-e/f/g/") => ["a" "b" "c-d-e" "f" "g"]
-  (category-slugs-from-path "/tax/a/b/c-d-e/f/g") => ["a" "b" "c-d-e" "f" "g"]
-  (category-slugs-from-path "/tax/a/b/c-d-e/f/g/") => ["a" "b" "c-d-e" "f" "g"])+(tabular (facts "about category slug parsing from a category path"
+  (category-slugs-from-path ?category-path) => ?category-slugs)
+  ?category-path        ?category-slugs
+  "tax"                 []
+  "tax/"                []
+  "/tax"                []
+  "/tax/"               []
+  "tax/a"               ["a"]
+  "tax/a/"              ["a"]
+  "/tax/a"              ["a"]
+  "/tax/a/"             ["a"]
+  "tax/a/b"             ["a" "b"]
+  "tax/a/b/"            ["a" "b"]
+  "/tax/a/b"            ["a" "b"]
+  "/tax/a/b/"           ["a" "b"]
+  "tax/a/b/c-d-e/f/g"   ["a" "b" "c-d-e" "f" "g"]
+  "tax/a/b/c-d-e/f/g/"  ["a" "b" "c-d-e" "f" "g"]
+  "/tax/a/b/c-d-e/f/g"  ["a" "b" "c-d-e" "f" "g"]
+  "/tax/a/b/c-d-e/f/g/" ["a" "b" "c-d-e" "f" "g"])


working pascal-triangle-print

working pascal-triangle-print

--- test/hackerrank/fp/pascal_triangle_test.clj
+++ test/hackerrank/fp/pascal_triangle_test.clj
@@ -53,7 +53,8 @@
   (testing "pascal-triangle-print"
     (is (= (pascal-triangle-print [[1]]) "1"))
     (is (= (pascal-triangle-print [[1] [1 1]]) "1\n1 1"))
-    (is (= (pascal-triangle-print [[1] [1 1] [1 2 1]]) "1\n1 1\n1 2 1")))
+    (is (= (pascal-triangle-print [[1] [1 1] [1 2 1]]) "1\n1 1\n1 2 1"))
+    (is (= (pascal-triangle-print [[1] [1 1] [1 2 1] [1 3 3 1]]) "1\n1 1\n1 2 1\n1 3 3 1")))

   (testing "pascal-triangle"


trying direct formation of pdgm-qry

trying direct formation of pdgm-qry

--- src/webapp/routes/home.clj
+++ src/webapp/routes/home.clj
@@ -26,18 +26,20 @@
        (let [pquery (sparql/pdgmquery language labbrev valstring)]
          [:p pquery]))

+;;(def values (split valstring #","))
+
+
+
 (defquery pdgm-qry [language lpref valstring]
-    (let [values (split valstring #",")
-          Language (capitalize language)]
         (select :lex :num :pers :gen :token)
         (where (graph [:aamag language]
         :s [lpref :pos] [lpref :Verb]  \.
-	:s [:aamas :lang] [:aama Language]  \.
+	:s [:aamas :lang] [:aama (capitalize language)]  \.
 	:s [:aamas :lang] :lang  \.
 	:lang [:rdfs :label] :langLabel  \.
-        (doseq [value values]
-          :s (str ":Q" value) [lpref value] \.
-          (str ":Q" value) [:rdfs :label] value  \.)
+        ;;(doseq [value values]
+        ;;  :s (str ":Q" value) [lpref value] \.
+        ;;  (str ":Q" value) [:rdfs :label] value  \.)
         (optional :s [:aamas :lexeme] :lex)  \.
 	(optional :s [lpref :number] :number)  \.
 	(optional :number [:rdfs :label] :num)  \.
@@ -47,7 +49,7 @@
 	(optional :s [lpref :gender] :gender)  \.
 	(optional :gender [:rdfs :label] :gen)  \.
 	:s [lpref :token] :token  \.))
-        (order-by :lex (desc :num) :pers (desc :gen))))
+        (order-by :lex (desc :num) :pers (desc :gen)))

 (defn home []
   (layout/common [:h1 "PDGM Display"]
@@ -56,14 +58,15 @@
                  [:hr]
                  (form-to [:post "/pdgm"]
                           [:p "Language:" (text-field "language")]
-                          [:p "LangAbbrev:" (text-field "labbrev")]
+                          [:p "LangAbbrev:" (text-field "lpref")]
                           [:p "Value String:" (text-field "valstring")]
                            (submit-button "Get pdgm"))
                           [:hr]))

 (defroutes home-routes
   (GET "/" [] (home))
-  (POST "/pdgm" [language labbrev valstring]
+  (POST "/pdgm" [language lpref valstring]
+        (pdgm-qry language lpref valstring)
        ;; send SPARQL over HTTP request
        (let [req (http/get aama
                            {:query-params


typo in comment

typo in comment

--- examples/todomvc/src/todomvc/handlers.cljs
+++ examples/todomvc/src/todomvc/handlers.cljs
@@ -41,7 +41,7 @@
 ;; -- Handlers ----------------------------------------------------------------

                                   ;; usage:  (dispatch [:initialise-db])
-(register-handler                 ;; On app startup, ceate initial state
+(register-handler                 ;; On app startup, create initial state
   :initialise-db                  ;; event id being handled
   check-schema-mw
   (fn [_ _]                       ;; the handler being registered


namespace fix

namespace fix

--- resources/leiningen/new/closp/clj/types.clj
+++ resources/leiningen/new/closp/clj/types.clj
@@ -1,4 +1,4 @@
-(ns {{ns}}.mct.types
+(ns {{ns}}.types
   (:require [clojure.core.typed :refer [HVec defalias HMap Num]])
   (:import (clojure.lang APersistentMap)))


Wrap lazy seq with reactive deref in doall

--- src/cljs/cglossa/result_views/cwb/core.cljs
+++ src/cljs/cglossa/result_views/cwb/core.cljs
@@ -12,6 +12,6 @@
     [:div.row>div.col-sm-12.search-result-table-container {:style {:height 320 :overflow "auto"}}
      [b/table {:striped true :bordered true}
       [:tbody
-       (map (partial concordance-rows a m)
-            results
-            (range (count results)))]]]))
+       (doall (map (partial concordance-rows a m)
+                   results
+                   (range (count results))))]]]))


No need for title with the new log entry modal

--- src/cljs/onyx_dashboard/components/log.cljs
+++ src/cljs/onyx_dashboard/components/log.cljs
@@ -14,8 +14,7 @@

 (defcomponent log-entry-row [entry owner {:keys [entry-ch] :as opts}]
   (render [_]
-          (dom/tr {:key (str "entry-" (:message-id entry))
-                   :title (str (om/value entry))}
+          (dom/tr {:key (str "entry-" (:message-id entry))}
                   (dom/td {:on-click (fn [e]
                                        (put! entry-ch {:id (:message-id entry)})
                                        true)}


Sieve of Sundaram

Sieve of Sundaram

--- src/clojureplayground/prime_numbers_fun.clj
+++ src/clojureplayground/prime_numbers_fun.clj
@@ -1,4 +1,5 @@
-(ns amazon.prime-numbers-fun)
+(ns clojureplayground.prime-numbers-fun
+  (:require [clojure.set :as cs]))

 ; (c) Dejo Josifovic 2016
 (def is-prime?
@@ -14,3 +15,13 @@
                         (reduced false) %))
                     true
                     (range 1 (inc num)))))))
+
+(defn sieve-of-sundaram [n]
+  (let [top (inc n)]
+    (map #(inc (* 2 %))
+         (sort
+           (cs/difference (set (range 1 top))
+                          (set (for [i (range 1 top) j (range i top)
+                                     :let [x (+ i j (* 2 i j))]
+                                     :while (<= x top)]
+                                 x)))))))


[#15] Add constructor for hash-map and hash-set

--- priv/clojure/core.clj
+++ priv/clojure/core.clj
@@ -75,6 +75,12 @@
 (def vector
   (fn* [& xs] (clj_core/vector (seq xs))))

+(def hash-map
+  (fn* [& xs] (clj_core/hash_map (seq xs))))
+
+(def hash-set
+  (fn* [& xs] (clj_core/hash_set (seq xs))))
+
 (def ^:macro defn
   (fn* [_form _env name args & body]
        `(def ~name (fn* ~args ~@body))))


CMR-4152: Remove time zone setting because it did not work correctly on our NGAP AWS instances.

--- common-lib/src/cmr/common/api/web_server.clj
+++ common-lib/src/cmr/common/api/web_server.clj
@@ -96,7 +96,6 @@
     (.setRequestLog
       (doto (NCSARequestLog.)
         (.setLogLatency true)
-        (.setLogTimeZone (.getID (TimeZone/getDefault)))
         (.setLogDateFormat "yyyy-MM-dd hh:mm:ss.SSS")))))

 (defn- create-gzip-handler


Fix Ropsten EthRegistrar address

Fix Ropsten EthRegistrar address

--- src/name_bazaar/shared/smart_contracts.cljs
+++ src/name_bazaar/shared/smart_contracts.cljs
@@ -6,7 +6,7 @@
       {:ens {:name "ENSRegistry" :address "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"}
        ;; Ropsten BaseRegistrarImplementation
        ;; https://ropsten.etherscan.io/address/0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85
-       :eth-registrar {:name "NameBazaarDevRegistrar" :address "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"}
+       :eth-registrar {:name "NameBazaarDevRegistrar" :address "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85"}
        :offering-registry {:name "OfferingRegistry" :address "0xa3634fE2E2973d5d0cB7f2a1b2b0327A0B6e2d0D"}
        :buy-now-offering {:name "BuyNowOffering" :address "0xfF58F3De9319f37BF9b6F355694fe4431b58E6a4"}
        :buy-now-offering-factory {:name "BuyNowOfferingFactory" :address "0x8dD4F32663771D73b387A983D1c40BdB431241fd"}


Fix typo in funk composition example

Fix typo in funk composition example

--- src/overtone/examples/compositions/funk.clj
+++ src/overtone/examples/compositions/funk.clj
@@ -25,7 +25,7 @@

 (defn subdivide
     "subdivide two time intervals by 4, and return the time interval
-    at position. this is a close-hihateap hack to sclose-hihatedule 16th notes without
+    at position. this is a cheap hack to schedule 16th notes without
     defining the whole pattern with the metronome firing every 16th note."
     [a b position]
     (+ a (* position (/ (- b a) 4) )))


Fix broken test data

Fix broken test data

--- test/cljam/test_common.clj
+++ test/cljam/test_common.clj
@@ -649,7 +649,7 @@
             {:id "Sample2", :assay "Exome", :ethnicity "CEU", :disease "Cancer",
              :tissue "Breast", :description "European patient exome from breast cancer"}
             {:id "Blood", :genomes "Germline", :mixture "1.", :description "Patient germline genome"}
-            {:id "TissueSample", :genomes "Germline", :mixture ".3", :description "Patient germline genome;Patient tumor genome"}]
+            {:id "TissueSample", :genomes "Germline;Tumor", :mixture ".3;.7", :description "Patient germline genome;Patient tumor genome"}]
    :pedigree [{:id "TumourSample", :original "GermlineID"}
               {:id "SomaticNonTumour", :original "GermlineID"}
               {:id "ChildID", :father "FatherID", :mother "MotherID"}


Remove unused test skeleton.

Remove unused test skeleton.

--- core/test/immutant/core_test.clj
+++ core/test/immutant/core_test.clj
@@ -1,18 +0,0 @@
-;; Copyright 2014 Red Hat, Inc, and individual contributors.
-;;
-;; Licensed under the Apache License, Version 2.0 (the "License");
-;; you may not use this file except in compliance with the License.
-;; You may obtain a copy of the License at
-;;
-;; http://www.apache.org/licenses/LICENSE-2.0
-;;
-;; Unless required by applicable law or agreed to in writing, software
-;; distributed under the License is distributed on an "AS IS" BASIS,
-;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-;; See the License for the specific language governing permissions and
-;; limitations under the License.
-
-(ns immutant.core-test
-  (:require [clojure.test :refer :all]
-            [immutant.core :refer :all]))
-


correct short-circuit test

correct short-circuit test

because we're grouping all items to have index
and balance updated together (instead of doing it
once within the transaction and again for
all subsequent transactions) the item in
the transaction itself should now appear
in the list of updated items

--- test/clj_money/models/transactions_test.clj
+++ test/clj_money/models/transactions_test.clj
@@ -1,5 +1,6 @@
 (ns clj-money.models.transactions-test
   (:require [clojure.test :refer :all]
+            [clojure.set :refer [rename-keys]]
             [environ.core :refer [env]]
             [clojure.pprint :refer [pprint]]
             [clj-time.core :as t]
@@ -814,25 +815,38 @@
           (select-keys existing-item
                        [:index :balance]))))

+; Trans. Date Amount  Debit     Credit
+; 2016-03-02    1000  Checking  Salary
+; 2016-03-09     101  Groceries Checking
+; 2016-03-16     102  Groceries Checking move this to 3/8
+; 2016-03-23     103  Groceries Checking
+; 2016-03-30     104  Groceries Checking
 (deftest update-a-transaction-short-circuit-updates
   (let [context (serialization/realize storage-spec short-circuit-context)
         [checking
          salary
          groceries] (:accounts context)
         [t1 t2 t3 t4] (:transactions context)
-        updated (assoc t3 :transaction-date (t/local-date 2016 3 8))
+        updated (-> t3
+                    (rename-keys {:transaction-date :original-transaction-date})
+                    (assoc :transaction-date (t/local-date 2016 3 8)))
         update-calls (atom {})]
     (with-redefs [transactions/update-item-index-and-balance (partial fake-update-item-index-and-balance
                                                                       context
                                                                       update-calls)]
       (let [result (transactions/update storage-spec updated)
-            expected #{{:index 2
-                       :amount 101M
-                       :balance 797M}
-                      {:index 3
-                       :amount 103M
-                       :balance 694M}} ; The first update that doesn't change a value stops the chain
-                                               ; the 4th item should never be updated because the 4rd one did not change a value
+            expected #{{:index 1
+                        :amount 102M
+                        :balance 898M}
+                       {:index 2
+                        :amount 101M
+                        :balance 797M}
+                       {:index 3
+                        :amount 103M
+                        :balance 694M}} ; The first update that doesn't change
+                                        ; a value stops the chain.
+                                        ; The 4th item should never be updated
+                                        ; because the 3rd one did not change a value.
             actual (get @update-calls (:id checking))]
         (is (empty? (validation/error-messages result))
             "The transaction is saved successfully")


Finushed writing the tests, but some are red

--- test/clojure_rest/integration/controllers/document_controller_test.clj
+++ test/clojure_rest/integration/controllers/document_controller_test.clj
@@ -2,6 +2,7 @@
   (:require [clojure.test :refer :all]
             [ring.mock.request :as mock]
             [cheshire.core :as json]
+            [clojure.java.jdbc :as jdbc]
             [clojure-rest.handler :refer :all]
             [clojure-rest.config.database :as database]))

@@ -34,34 +35,37 @@
     (let [request (mock/request :post "/documents" (json/generate-string {:id_document "dummy" :title "newDocumentTitle" :text "newDocumentText"}))]
     (let [response (app (mock/content-type request "application/json"))]
       (is (= (:status response) 200)))))
-    ) ; TODO Add body test and count test
+  ; TODO Add body test and count test

-  ; TODO
-  ; (testing "Testing document creation route failed"
-  ;   (let [response (app (mock/request :post "/documents"))]
-  ;     (is (= (:status response) 200))))
+  (testing "Testing document creation route failed because of incorrect document"
+    (let [request (mock/request :post "/documents" (json/generate-string {:id_document "dummy" :title "newDocumentTitle" :text "newDocumentText" :wrongattribute "badvalue"}))]
+    (let [response (app (mock/content-type request "application/json"))]
+      (is (= (:status response) 400)))))) ; FIXME This test causes an error

+(deftest test-document-controller-update
+  (database/initDatabase)

+  (testing "Testing document update route worked"
+    (let [request (mock/request :put "/documents/1" (json/generate-string {:id_document "1" :title "titre1Updated" :text "texte1Updated"}))]
+      (let [response (app (mock/content-type request "application/json"))]
+      (is (= (:status response) 200)))))
+  ; TODO Add tests on body returned and database

-; (deftest test-document-controller-update
-;   (database/initDatabase)
-;
-;   (testing "Testing document update route worked"
-;     (let [response (app (mock/request :put "/documents/1"))]
-;       (is (= (:status response) 200))))
-;
-;   (testing "Testing document update route failed"
-;     (let [response (app (mock/request :put "/documents/1"))]
-;       (is (= (:status response) 200)))))
+  (testing "Testing document update route failed with incorrect id"
+    (let [request (mock/request :put "/documents/notfound" (json/generate-string {:id_document "noid" :title "wontwork" :text "causeIncorrectid"}))]
+      (let [response (app (mock/content-type request "application/json"))]
+      (is (= (:status response) 404)))))
+  ) ; TODO Add tests on body returned and database

+(deftest test-document-controller-delete
+  (database/initDatabase)

-; (deftest test-document-controller-delete
-;   (database/initDatabase)
-;
-;   (testing "Testing document delete route worked"
-;     (let [response (app (mock/request :delete "/documents/1"))]
-;       (is (= (:status response) 200))))
-;
-;   (testing "Testing document delete route failed"
-;     (let [response (app (mock/request :delete "/documents/1"))]
-;       (is (= (:status response) 200)))))
+  (testing "Testing document delete route worked"
+    (let [response (app (mock/request :delete "/documents/1"))]
+      (is (= (:status response) 204))))
+  ; TODO Add tests on database
+
+  (testing "Testing document delete route failed"
+    (let [response (app (mock/request :delete "/documents/notfound"))]
+      (is (= (:status response) 404))))) ; FIXME This test fails
+; TODO Add tests on database and correct error


(SERVER-885) Trim line length in general_puppet_int_test

--- test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
+++ test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
@@ -3,7 +3,8 @@
             [puppetlabs.puppetserver.bootstrap-testutils :as bootstrap]
             [puppetlabs.http.client.sync :as http-client]
             [puppetlabs.services.jruby.jruby-testutils :as jruby-testutils]
-            [puppetlabs.services.jruby.puppet-environments-int-test :refer [write-site-pp-file get-catalog catalog-contains?]]
+            [puppetlabs.services.jruby.puppet-environments-int-test :refer
+             [write-site-pp-file get-catalog catalog-contains?]]
             [me.raynes.fs :as fs]))

 (def test-resources-dir
@@ -28,9 +29,12 @@
     ; This function calls into Puppet::Util::Execution.execute(), which calls into
     ; our shell-utils code via Puppet::Util::ExecutionStub which we call in
     ; Puppet::Server::Execution.
-    (write-site-pp-file (format "$a = generate('%s', 'this command echoes a thing'); notify {$a:}" (script-path "echo")))
-    (bootstrap/with-puppetserver-running app {:jruby-puppet
-                                              {:max-active-instances num-jrubies}}
-                                         (testing "calling generate successfully executes shell command"
-                                           (let [catalog (get-catalog)]
-                                             (is (catalog-contains? catalog "Notify" "this command echoes a thing\n")))))))
+    (write-site-pp-file
+     (format "$a = generate('%s', 'this command echoes a thing'); notify {$a:}"
+             (script-path "echo")))
+    (bootstrap/with-puppetserver-running
+     app {:jruby-puppet
+          {:max-active-instances num-jrubies}}
+     (testing "calling generate successfully executes shell command"
+       (let [catalog (get-catalog)]
+         (is (catalog-contains? catalog "Notify" "this command echoes a thing\n")))))))


create special build once builder

create special build once builder

--- sidecar/src/figwheel_sidecar/repl.clj
+++ sidecar/src/figwheel_sidecar/repl.clj
@@ -262,11 +262,25 @@
         (let [opts (or (:build-options build) (:compiler build))]
           (cljs.compiler/with-core-cljs opts (fn []))))))

+(defn build-once-builder [figwheel-server]
+  (-> cbuild/build-source-paths*
+    (autobuild/default-build-options {:recompile-dependents false})
+    (autobuild/insert-figwheel-connect-script figwheel-server)
+    (auto/warning (auto/warning-message-handler
+              #(when-let [msg (:message %)]
+                 (println msg))))
+    auto/time-build
+    (auto/after auto/compile-success)
+    (auto/error auto/compile-fail)
+    (auto/before auto/compile-start)))
+
 (defn build-once [ids]
-  (let [builds (->> (focused-builds ids)
+  (let [build-it-once (build-once-builder (get *autobuild-env* :figwheel-server))
+        builds (->> (focused-builds ids)
                  (map #(assoc % :reload-clj-files false)))]
     (display-focus-ids (map :id builds))
-    (doseq [build builds] (auto/build-once build))))
+    (doseq [build builds]
+      (build-it-once build))))

 (defn clean-builds [ids]
   (let [builds (focused-builds ids)]


clean up formatting

clean up formatting

--- euler-clj/src/euler_clj/core.clj
+++ euler-clj/src/euler_clj/core.clj
@@ -13,8 +13,8 @@
     (/ (* n p (+ p 1)) 2)))

 (defn problem-1-smart
-  "Find the sum of all the multiples of 4 or 5 below n."
+  "Find the sum of all the multiples of 3 or 5 below n."
   [n]
-  (- (+ (sum-divisible-by 3  (- n 1))
-        (sum-divisible-by 5  (- n 1)))
+  (- (+ (sum-divisible-by 3 (- n 1))
+        (sum-divisible-by 5 (- n 1)))
      (sum-divisible-by 15 (- n 1))))


Docstring improvements.

Docstring improvements.

--- messaging/src/immutant/messaging/hornetq.clj
+++ messaging/src/immutant/messaging/hornetq.clj
@@ -13,6 +13,7 @@
 ;; limitations under the License.

 (ns immutant.messaging.hornetq
+  "HornetQ-specific messaging utilities."
   (:require [immutant.internal.options   :as o]
             [immutant.internal.util      :as u]
             [immutant.util               :as pu]
@@ -44,7 +45,7 @@
    destination  control-type  controller
    -------------------------------------------------------------------------
    Queue        :jms          org.hornetq.api.jms.management.JMSQueueControl
-   Queue        :core         org.hornetq.core.management.impl.QueueControl
+   Queue        :core         org.hornetq.api.core.management.QueueControl
    Topic        <ignored>     org.hornetq.api.jms.management.TopicControl

    Refer to the javadocs for those control classes for details on the
@@ -133,7 +134,7 @@
      here. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/message-expiry.html#message-expiry.configuring

-   * :expiry-delay [-1] - If > -1, this value (in ms) is used as the
+   * :expiry-delay [-1] - If > -1, this value (in millis) is used as the
      default :ttl for messages that don't have a :ttl > 0 set.

    * :last-value-queue [false] - If true, only the most recent message
@@ -148,7 +149,7 @@
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/undelivered-messages.html#undelivered-messages.configuring

    * :max-redelivery-delay [:redelivery-delay] - Specifies the maximum
-     redelivery delay (in ms) when a :redelivery-multiplier is used.
+     redelivery delay (in millis) when a :redelivery-multiplier is used.

    * :max-size-bytes [20971520 (20MB)] - The maximum size (in bytes) of retained messages
      on an address before :address-full-message-policy is applied. See
@@ -162,7 +163,7 @@
      when paging. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/paging.html

-   * :redelivery-delay [0] - Specifies the delay (in ms) between
+   * :redelivery-delay [0] - Specifies the delay (in millis) between
      redelivery attempts. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/undelivered-messages.html#undelivered-messages.delay

@@ -171,7 +172,7 @@
      :redelivery-delay * (:redelivery-multiplier ^ attempt-count). This won't have
      any effect if you don't also set :redelivery-delay and :max-redelivery-delay.

-   * :redistribution-delay [1000] - Specifies the delay (in ms) to wait before
+   * :redistribution-delay [1000] - Specifies the delay (in millis) to wait before
      redistributing messages from a node in a cluster to other nodes when the
      queue no longer has consumers on the current node. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/clusters.html


Add some gh logins + email addresses.

Add some gh logins + email addresses.

--- src-cljs/frontend/components/about.cljs
+++ src-cljs/frontend/components/about.cljs
@@ -270,19 +270,19 @@
     :img-path (scaled-image-path "bear")
     :role "Operations"
     :github "bear"
-    :email ""
+    :email "bear@circleci.com"
     :bio "Bio coming soon!"}
    {:name "Mark Pundsack"
     :img-path (scaled-image-path "mark")
     :role "VP Product"
-    :github ""
-    :email ""
+    :github "markpundsack"
+    :email "mark@circleci.com"
     :bio "Bio coming soon!"}
    {:name "Brady Lill"
     :img-path (scaled-image-path "brady")
     :role "Developer"
-    :github ""
-    :email ""
+    :github "bradylill"
+    :email "brady@circleci.com"
     :bio "Bio coming soon!"}]
   )


Need a default multimethod for log-notifications

--- src/clj/onyx_dashboard/onyx_deployment.clj
+++ src/clj/onyx_dashboard/onyx_deployment.clj
@@ -121,6 +121,7 @@
                                     :peer-id (:id (:args entry))
                                     :task (select-keys task [:id :name])}])))

+(defmethod log-notifications :default [send-fn! replica log entry tracking-id])
 (defn track-deployment [send-fn! deployment-id subscription ch f-check-pulses tracking-id]
   (let [log (:log (:env subscription))
         up-to-date? (atom false)


Removed empty line.

Removed empty line.

--- src/clj_formal_specifications_app/core.clj
+++ src/clj_formal_specifications_app/core.clj
@@ -18,7 +18,6 @@
   (route/resources "/")
   (route/not-found "Not found!"))

-
 (def app-routes (routes (wrap-defaults api-routes api-defaults)
                         (wrap-defaults site-routes site-defaults)))


Add cookie signed storage.

Add cookie signed storage.

--- src/clojure/catacumba/handlers/session.clj
+++ src/clojure/catacumba/handlers/session.clj
@@ -28,6 +28,7 @@
   (:require [promissum.core :as p]
             [buddy.core.nonce :as nonce]
             [buddy.core.codecs :as codecs]
+            [buddy.sign.jws :as jws]
             [promissum.core :as p]
             [catacumba.impl.atomic :as atomic]
             [catacumba.impl.handlers :as hs]
@@ -156,6 +157,31 @@
         (p/promise
          (fn [deliver]
            (swap! internalstore dissoc key)
+           (deliver key)))))))
+
+(defn signed-cookie
+  [& {:keys [key] :as opts}]
+  (let [pkey (or key (nonce/random-nonce 128))]
+    (reify ISessionStorage
+      (-read [_ dkey]
+        (p/promise
+         (fn [deliver]
+           (if (nil? dkey)
+             (deliver [(jws/sign {} pkey opts) {}])
+             (try
+               (println 2222 dkey)
+               (deliver [dkey (jws/unsign dkey pkey opts)])
+               (catch clojure.lang.ExceptionInfo e
+                 (deliver [(jws/sign {} pkey opts) {}])))))))
+
+      (-write [_ key data]
+        (p/promise
+         (fn [deliver]
+           (deliver (jws/sign data pkey opts)))))
+
+      (-delete [_ key]
+        (p/promise
+         (fn [deliver]
            (deliver key)))))))

 (defn lookup-storage


format files 6

format files 6

--- src/com/wsscode/pathom/fulcro/network.cljs
+++ src/com/wsscode/pathom/fulcro/network.cljs
@@ -75,10 +75,10 @@
       (if-let [edn' (transform-query env edn)]
         (if transform-transmission
           (transform-transmission edn'
-                                  (fn [edn']
-                                    (fulcro.network/send network edn'
-                                      #(->> % (transform-response env) ok)
-                                      #(->> % (transform-error env) error))))
+            (fn [edn']
+              (fulcro.network/send network edn'
+                #(->> % (transform-response env) ok)
+                #(->> % (transform-error env) error))))
           (fulcro.network/send network edn'
             #(->> % (transform-response env) ok)
             #(->> % (transform-error env) error)))
@@ -109,12 +109,12 @@
       (if-let [edn' (transform-query env edn)]
         (if transform-transmission
           (transform-transmission env edn'
-                                  (fn [edn']
-                                    (fulcro.network/transmit network
-                                      {::fulcro.network/edn              edn'
-                                       ::fulcro.network/ok-handler       (fn [response] (ok-handler (update response :body #(transform-response env %))))
-                                       ::fulcro.network/error-handler    (fn [error] (error-handler (update error :body #(transform-error env %))))
-                                       ::fulcro.network/progress-handler (fn [progress] (progress-handler (transform-progress env progress)))})))
+            (fn [edn']
+              (fulcro.network/transmit network
+                {::fulcro.network/edn              edn'
+                 ::fulcro.network/ok-handler       (fn [response] (ok-handler (update response :body #(transform-response env %))))
+                 ::fulcro.network/error-handler    (fn [error] (error-handler (update error :body #(transform-error env %))))
+                 ::fulcro.network/progress-handler (fn [progress] (progress-handler (transform-progress env progress)))})))
           (fulcro.network/transmit network
             {::fulcro.network/edn              edn'
              ::fulcro.network/ok-handler       (fn [response] (ok-handler (update response :body #(transform-response env %))))
@@ -123,7 +123,7 @@
         (ok-handler nil))))

   (abort [this abort-id]
-         (fulcro.network/abort network abort-id)))
+    (fulcro.network/abort network abort-id)))

 (defn transform-remote
   "Given a network, provides some hooks to modify the network behavior.


Let components override parent properties and evolvers with nil intentionally when needed

--- flatguicore/src/flatgui/base.clj
+++ flatguicore/src/flatgui/base.clj
@@ -201,9 +201,9 @@
   (let [ key-order (distinct (concat (for [[k v] a] k) (for [[k v] b] k)))
          result (apply array-map (mapcat (fn [k] (if (and (map? (a k)) (map? (b k)))
                                              [k (merge-ordered (a k) (b k))]
-                                             (if (nil? (b k))
-                                               [k (a k)]
-                                               [k (b k)]))) key-order))]
+                                             (if (contains? b k) ; b may intentionally override smth with nil
+                                               [k (b k)]
+                                               [k (a k)]))) key-order))]
     (do
       ;(log-debug " Merged result of class: " (.getClass result))
       result)))


tab class got testimonials

tab class got testimonials

--- frontend/components/landing.cljs
+++ frontend/components/landing.cljs
@@ -215,7 +215,7 @@
               [:ul#tech.nav.nav-tabs
                (for [tab [:languages :databases :queues :browsers :libraries :deployment :custom]]
                  (tech-tab tab selected-tab controls-ch))]]]
-            [:div.tab-content
+            [:div.tab-content (:class (tech-class selected-tab))
              (let [templates {:languages {:img-url "/img/outer/home/tech-languages.png"
                                           :blurb "CircleCI automatically infers how to run your Ruby, Node, Python and Java tests. You can customize any step, or set up your test steps manually for PHP or other languages."}
                               :databases {:img-url "/img/outer/home/tech-databases.png"


make the stories-procedure work with some dangerouslySetInnerHTML


Reduce table size; add move types; fix #15

--- frontend/src/cruncher/views.cljs
+++ frontend/src/cruncher/views.cljs
@@ -123,7 +123,9 @@
 (defui PokeTableEntry
   Object
   (render [this]
-    (let [pokemon (om/props this)]
+    (let [pokemon (om/props this)
+          move-1 (moves/get-move (:move_1 pokemon))
+          move-2 (moves/get-move (:move_2 pokemon))]
       (dom/tr #js {:id              (str "poketable-row-" (:id pokemon))
                    :className       "poketable-row"
                    :data-favorite   (:favorite pokemon)
@@ -140,10 +142,9 @@
               (dom/td nil (favorite-td (:id pokemon) (:favorite pokemon)))
               (dom/td nil (:pokemon_id pokemon))
               (dom/td nil (dom/img #js {:src (str "img/pokemon/models/" (:pokemon_id pokemon) ".png") :className "pokemon-image-thumb"}))
-              (dom/td nil (:name pokemon))
-              (dom/td nil (:nickname pokemon))
-              (dom/td nil (moves/get-name (:move_1 pokemon)))
-              (dom/td nil (moves/get-name (:move_2 pokemon)))
+              (vlib/td-two-lines (:name pokemon) (:nickname pokemon))
+              (vlib/td-two-lines (:name move-1) (:type move-1))
+              (vlib/td-two-lines (:name move-2) (:type move-2))
               (dom/td nil (:cp pokemon))
               (dom/td nil (:individual_percentage pokemon))
               (dom/td nil (:individual_attack pokemon))
@@ -172,14 +173,13 @@
                                            (vlib/sortable-table-header :pokemon_id "#")
                                            (dom/th nil "")
                                            (vlib/sortable-table-header :name "Name")
-                                           (vlib/sortable-table-header :nickname "Nickname")
                                            (vlib/sortable-table-header :move_1 "Fast")
                                            (vlib/sortable-table-header :move_2 "Special")
                                            (vlib/sortable-table-header :cp "CP")
-                                           (vlib/sortable-table-header :individual_percentage "IV % Perfect")
-                                           (vlib/sortable-table-header :individual_attack "Attack")
-                                           (vlib/sortable-table-header :individual_defense "Defense")
-                                           (vlib/sortable-table-header :individual_stamina "Stamina")
+                                           (vlib/sortable-table-header :individual_percentage "IV%")
+                                           (vlib/sortable-table-header :individual_attack "AT")
+                                           (vlib/sortable-table-header :individual_defense "DF")
+                                           (vlib/sortable-table-header :individual_stamina "ST")
                                            (dom/th nil "")))
                         (dom/tbody nil
                                    (interleave


[frontend]: Fix cljfmt

[frontend]: Fix cljfmt

--- frontend/src/warehouse/subs.cljs
+++ frontend/src/warehouse/subs.cljs
@@ -2,7 +2,7 @@
   (:require
    [warehouse.util :as util]
    [warehouse.infinite-scroll.db :as scroll]
-   [warehouse.search.db : as search]
+   [warehouse.search.db :as search]
    [re-frame.core :refer [reg-sub subscribe]]
    [warehouse.search.db :as search]))


Pass the event value in, not the current input value

--- fulcro-todo/src/main/app/ui.cljs
+++ fulcro-todo/src/main/app/ui.cljs
@@ -22,7 +22,7 @@
                    :type "text"
                    :placeholder "add an item here"
                    :value input-value
-                   :onChange #(update-input-value! {:input-value input-value})})
+                   :onChange #(update-input-value! {:input-value (-> % .-target .-value)})})
              (dom/input
               #js {:className (if valid-input-value?
                                 "item-adder__button"


bring the re-select back for the moment

bring the re-select back for the moment

--- src/er_cassandra/model/alia/unique_key.clj
+++ src/er_cassandra/model/alia/unique_key.clj
@@ -387,6 +387,11 @@

             :let [updated? (applied? update-response)]

+            ;; TODO - removing the reselect - it's
+            ;; ok for an upsert to return just what was upserted...
+            ;; but there are some upstream things to work through
+            ;; to make it work properly
+
             upserted-record (cond
                               ;; definitely a first insert
                               (and inserted? if-not-exists)
@@ -402,11 +407,13 @@

                               ;; failure
                               :else
-                              (return nil))]
+                              (return nil))
+            ]

        (return
-        (if upserted-record
-          [upserted-record nil]
+        (if (or inserted? updated?)
+          [upserted-record
+           nil]

           [nil [(e/general-error-log-entry
                  {:error-tag :upsert/primary-record-upsert-error


consider manual time in daily aggregate

consider manual time in daily aggregate

--- src/clj/iwaswhere_web/graph/stats.clj
+++ src/clj/iwaswhere_web/graph/stats.clj
@@ -24,9 +24,9 @@
   (let [custom-fields (:custom-fields entry)
         duration-secs (filter identity (map (fn [[k v]]
                                               (let [dur (:duration v)]
-                                               (if (= k "#audio")
-                                                 dur
-                                                 (* 60 (or dur 0)))))
+                                                (if (= k "#audio")
+                                                  dur
+                                                  (* 60 (or dur 0)))))
                                             custom-fields))]
     (apply + duration-secs)))

@@ -47,7 +47,7 @@
                             (assoc-in acc [story] summed)
                             acc)))
         by-story (reduce story-reducer {} nodes)]
-    {:total-time    (apply + (map #(or (:completed-time %) 0) nodes))
+    {:total-time    (apply + (map second by-story))
      :time-by-story by-story
      :time-by-book  (time-by-books g by-story)}))


linked cid list

linked cid list

--- src/clj/morpheus/models/edge/base.clj
+++ src/clj/morpheus/models/edge/base.clj
@@ -159,7 +159,7 @@
                           {:next-list empty-cid :cid-array []}))]
     (if (< list-length max-list-size)
       (let [cids-num-to-go (- max-list-size list-length)
-            cids-to-go (take cids-to-go target-cids)]
+            cids-to-go (take cids-num-to-go target-cids)]
         (neb-cell/update-cell trunk hash 'morpheus.models.edge.base/concat-into-list-cell
                               cids-num-to-go)
         (if (= cids-to-go target-cids)


extract process-updated-transaction-items

--- src/clj_money/models/transactions.clj
+++ src/clj_money/models/transactions.clj
@@ -731,6 +731,23 @@
                          :index (Integer/MAX_VALUE)))
          (map #(get-previous-item storage %)))))

+(defn- process-updated-transaction-items
+  [storage transaction existing-tx]
+  (->> (:items transaction)
+       (map #(as-> % i
+                (assoc i :transaction-id (:id transaction))
+                (before-save-item i)
+                (upsert-item storage i)))
+       (map (fn [current-item]
+              ; TODO: no need to find the matching item, just use the value from the transaction
+              (let [existing-item (some #(= (:id %) (:id current-item))
+                                        (:items existing-tx))]
+                (if (> 0 (compare (:transaction-date current-item)
+                                  (:transaction-date existing-item)))
+                  existing-item
+                  current-item))))
+       (mapv #(get-previous-item storage %))))
+
 (defn- find-existing-transaction
   "Given a transaction that has been updated, find the existing
   transaction in storage. If none can be found, throw an exception."
@@ -754,22 +771,7 @@
         (let [existing (find-existing-transaction storage validated)
               dereferenced-base-items (remove-dereferenced-items storage validated existing)
               dereferenced-account-base-items (dereferenced-account-base-items storage validated existing)
-
-              ; current items
-              upserted-items (mapv #(as-> % i
-                                      (assoc i :transaction-id (:id validated))
-                                      (before-save-item i)
-                                      (upsert-item storage i))
-                                   (:items validated))
-
-              current-base-items (->> upserted-items
-                                      (map (fn [current-item]
-                                             (let [existing-item (some #(= (:id %) (:id current-item))(:items existing))]
-                                               (if (> 0 (compare (:transaction-date current-item)
-                                                                 (:transaction-date existing-item)))
-                                                 existing-item
-                                                 current-item))))
-                                      (map #(get-previous-item storage %)))
+              current-base-items (process-updated-transaction-items storage validated existing)

               ; process all item updates


Fix hide button.

Fix hide button.

--- src/cljs/editor/quil_site/editor.cljs
+++ src/cljs/editor/quil_site/editor.cljs
@@ -17,7 +17,7 @@
 (defn show-result-pane []
   (let [view-width (.-offsetWidth (.querySelector js/document "#content"))
         pane-width (first @result-pane-size)
-        pane-bigger? (> pane-width (j/outer-width (j/$ "iframe")))]
+        pane-bigger? (> pane-width (int (j/attr (j/$ "iframe") "width")))]
     (j/css (j/$ "#result-content") "left" (str (- view-width
                                                   pane-width
                                                   scroll-width)


Drop comment about event listener registration.

Will make an issue in the repository instead.

--- src/cljs/goya/components/drawing.cljs
+++ src/cljs/goya/components/drawing.cljs
@@ -477,10 +477,6 @@
               (when (= ch command-chan) (handle-command app owner v))
           (recur))))))

-    ;; =============================================================================
-    ;; I shouldn't have to listen to the events like this, but if I simply setup
-    ;; the listeners in the render function, I get bogus events
-
     om/IDidMount
       (did-mount [_]
         (let [painter-watcher (om/get-node owner "painter-watcher-ref")


Minor changes on server bootstrap function arguments.

--- src/clojure/catacumba/impl/server.clj
+++ src/clojure/catacumba/impl/server.clj
@@ -30,9 +30,9 @@
   "A bootstrap server hook for setup initial
   registry entries and execute a user provided
   hook for do the same thing."
-  [^RegistrySpec registryspec setup]
+  [^RegistrySpec spec {:keys [setup debug]}]
   (when (fn? setup)
-    (setup registryspec)))
+    (setup spec)))

 (defn- build-server-config
   "Given user specified options, return a `ServerConfig` instance."
@@ -53,7 +53,7 @@
   "The ratpack server configuration callback."
   [^RatpackServerSpec spec handler {:keys [setup] :as options}]
   (.serverConfig spec ^ServerConfig (build-server-config options))
-  (.registryOf spec (helpers/action #(bootstrap-registry % setup)))
+  (.registryOf spec (helpers/action #(bootstrap-registry % options)))
   (setup-handler handler spec))

 (defn run-server


Fix badge adverts sql check not_before and not_after

--- src/clj/salava/extra/application/db.clj
+++ src/clj/salava/extra/application/db.clj
@@ -81,13 +81,13 @@
                 (= order "mtime") "ORDER BY ba.mtime DESC"
                 (= order "name") "ORDER BY bc.name"
                 (= order "issuer_content_name") "ORDER BY ic.name"
-                :else "")
+                :else "ORDER BY ba.mtime DESC")
         query (str "SELECT DISTINCT ba.id, ba.country, bc.name, ba.info, bc.image_file, ic.name AS issuer_content_name, ic.url AS issuer_content_url,GROUP_CONCAT( bct.tag) AS tags, ba.mtime, ba.not_before, ba.not_after, ba.kind, application_url, IF(scba.user_id, true, false) AS followed FROM badge_advert AS ba
        JOIN badge_content AS bc ON (bc.id = ba.badge_content_id)
        JOIN issuer_content AS ic ON (ic.id = ba.issuer_content_id)
        LEFT JOIN badge_content_tag AS bct ON (bct.badge_content_id = ba.badge_content_id)
        LEFT JOIN social_connections_badge_advert AS scba ON (scba.badge_advert_id = ba.id and scba.user_id = ?)
-       where ba.deleted = 0
+       where ba.deleted = 0 AND (not_before = 0 OR not_before < UNIX_TIMESTAMP()) AND (not_after = 0 OR not_after > UNIX_TIMESTAMP())
        "
                    where
                    "GROUP BY ba.id "


Modal - moved all state animation transitions to go loop in will-mount

--- src/cljs/om_pages/components/modal.cljs
+++ src/cljs/om_pages/components/modal.cljs
@@ -35,20 +35,13 @@
     (will-mount [_]
       (go (loop []
         (om/set-state! owner :modal {:opts (<! modal-opts-chan) :state :init})
+        (<! (timeout 50))
+        (om/set-state! owner [:modal :state] :in)
         (<! modal-close-chan)
         (om/set-state! owner [:modal :state]  :out)
         (<! (timeout fade-time))
+        (om/set-state! owner :modal {:opts nil :state :clear})
         (recur))))
-
-    om/IDidUpdate
-    (did-update [_ _ _]
-      (let [state (om/get-state owner [:modal :state])]
-        (cond
-          (= state :init) (js/setTimeout
-                            #(om/set-state! owner [:modal :state] :in))
-          (= state :out) (go
-                           (<! (timeout fade-time))
-                           (om/set-state! owner [:modal] {:state :clear})))))

     om/IRenderState
     (render-state [_ {{:keys [opts state]} :modal}]


Update specs for Om Next query generation functions

--- src/main/workflo/macros/query/om_next.cljc
+++ src/main/workflo/macros/query/om_next.cljc
@@ -1,24 +1,22 @@
 (ns workflo.macros.query.om-next
   (:require [clojure.spec :as s]
             [clojure.walk :refer [keywordize-keys]]
+            #?(:cljs [om.next])
             #?(:cljs [workflo.macros.util.js :refer [resolve]])
-            [workflo.macros.specs.om-query]
-            [workflo.macros.specs.parsed-query]))
+            [workflo.macros.specs.om-query :as om-query]
+            [workflo.macros.specs.parsed-query :as parsed-query]))

 (s/def ::property-query-from-parsed-property
   (s/and
    (s/or :keyword
          (s/and #(= :property (-> % :args :prop :type))
-                #(s/conform :workflo.macros.specs.om-query/keyword
-                            (:ret %)))
+                #(s/conform ::om-query/keyword (:ret %)))
          :link
          (s/and #(= :link (-> % :args :prop :type))
-                #(s/conform :workflo.macros.specs.om-query/link
-                            (:ret %)))
+                #(s/conform ::om-query/link (:ret %)))
          :join
          (s/and #(= :join (-> % :args :prop :type))
-                #(s/conform :workflo.macros.specs.om-query/join
-                            (:ret %))))
+                #(s/conform ::om-query/join (:ret %))))
    (s/or :regular
          #(not (contains? (-> % :args :prop) :parameters))
          :parameterized
@@ -30,9 +28,9 @@
                     (second (:ret %)))))))

 (s/fdef property-query
-  :args (s/cat :prop :workflo.macros.specs.parsed-query/property)
-  :ret  :workflo.macros.specs.om-query/property
-  :fn   ::property-query-from-parsed-property)
+  :args (s/cat :prop ::parsed-query/property)
+  :ret ::om-query/property
+  :fn ::property-query-from-parsed-property)

 (defn property-query
   "Generates an Om Next query for a parsed property query"
@@ -67,8 +65,8 @@
         (cond-> params parameterize))))

 (s/fdef query
-  :args (s/cat :parsed-query :workflo.macros.specs.parsed-query/query)
-  :ret  :workflo.macros.specs.om-query/query)
+  :args (s/cat :parsed-query ::parsed-query/query)
+  :ret ::om-query/query)

 (defn query
   "Generates an Om Next query from a parsed query."


(MAINT) remove unused imports

(MAINT) remove unused imports

--- src/puppetlabs/trapperkeeper/bootstrap.clj
+++ src/puppetlabs/trapperkeeper/bootstrap.clj
@@ -1,10 +1,9 @@
 (ns puppetlabs.trapperkeeper.bootstrap
-  (:import (java.io Reader FileNotFoundException)
+  (:import (java.io FileNotFoundException)
            (java.net URI))
   (:require [clojure.string :as string]
             [clojure.java.io :as io]
             [clojure.tools.logging :as log]
-            [puppetlabs.trapperkeeper.plugins :as plugins]
             [puppetlabs.trapperkeeper.internal :as internal]
             [puppetlabs.trapperkeeper.services :as services]))


[WM] remove profiles.clj.sample

[WM] remove profiles.clj.sample

These typically won't need Datomic access, which is what we use profiles.clj for.

--- src/leiningen/new/kraken_http_api.clj
+++ src/leiningen/new/kraken_http_api.clj
@@ -25,7 +25,6 @@
              ["Dockerfile" (render "Dockerfile" data)]
              ["{{name}}@.service.template" (render "PROJECT@.service.template" data)]
              ["docker-compose.yml" (render "docker-compose.yml" data)]
-             ["profiles.clj.sample" (render "profiles.clj.sample" data)]
              ["project.clj" (render "project.clj" data)]
              ["README.md" (render "README.md" data)]
              ["LICENSE" (render "LICENSE" data)]


Update top contrib calculation

Update top contrib calculation

--- src/clj/clojuredocs/pages/intro.clj
+++ src/clj/clojuredocs/pages/intro.clj
@@ -105,19 +105,19 @@
         [:p "First, take a look at the examples style guide, and then add an example for your favorite var (or pick one from the list)."]
         [:p "In addition to examples, you also have the ability to add 'see also' references between vars."]]]]]]])

+
 (defn top-contribs []
   (let [scores (atom {})]
-    (doseq [{:keys [history author]} (mon/fetch :examples)]
-      (let [history (->> history
-                         (concat [{:author author}])
-                         reverse)
-            first-author (-> history first :author)]
-        (swap! scores update-in [first-author] #(+ 4 (or % 0)))
-        (doseq [author (->> history rest (map :author))]
-          (swap! scores update-in [author] #(inc (or % 0))))))
+    (doseq [{:keys [author _id]} (mon/fetch :examples)]
+      (let [editors (->> (mon/fetch :example-histories :where {:example-id _id})
+                         (map :editor))]
+        (swap! scores update-in [author] #(+ 4 (or % 0)))
+        (doseq [editor editors]
+          (swap! scores update-in [editor] #(inc (or % 0))))))
     (->> @scores
          (sort-by second)
          reverse
+         (remove #(get #{"zkim" "zk"} (-> % first :login)))
          (take (* 24 3))
          (map #(assoc (first %) :score (second %))))))


Wrap Transport/send with response.

Wrap Transport/send with response.

--- src/clj/com/draines/postal/smtp.clj
+++ src/clj/com/draines/postal/smtp.clj
@@ -4,5 +4,9 @@

 (defn smtp-send [msg]
   (let [jmsg (make-jmessage msg)]
-    (Transport/send jmsg)))
+    (try
+     (Transport/send jmsg)
+     {:code 0 :error :SUCCESS :message "message sent"}
+     (catch Exception e
+       {:code 99 :error (class e) :message (.getMessage e)}))))


beta-dict :full fallback now average of beta vectors

--- src/clj/forma/classify/logistic.clj
+++ src/clj/forma/classify/logistic.clj
@@ -198,13 +198,27 @@
   {(keyword (str (second v)))
    (last v)})

-(defn beta-dict [eco-beta-src full-beta-src]
+(defn beta-dict
+  "create dictionary of beta vectors by ecoregion, adding an intelligent default (average) for ecoregions without betavectors"
+  [eco-beta-src]
   (let [src (name-vars eco-beta-src
                        ["?s-res" "?eco" "?beta"])
-        full-src (name-vars full-beta-src
-                            ["?s-res" "?beta"])
-        beta-full (first (??- (c/first-n full-src 1)))
-        beta-vec  (first (??- (c/first-n src 200)))]
+        beta-vec    (first (??- (c/first-n src 200)))
+        n           (count (last (first beta-vec)))
+        avg-beta-vec (map #(/ % n)
+                         (apply map + (map last beta-vec)))]
     (assoc (apply merge-with identity
                   (map make-dict beta-vec))
-      :full (last (first beta-full)))))
+      :full avg-beta-vec)))
+
+
+;; (defn beta-dict [eco-beta-src full-beta-src]
+;;   (let [src (name-vars eco-beta-src
+;;                        ["?s-res" "?eco" "?beta"])
+;;         full-src (name-vars full-beta-src
+;;                             ["?s-res" "?beta"])
+;;         beta-full (first (??- (c/first-n full-src 1)))
+;;         beta-vec  (first (??- (c/first-n src 200)))]
+;;     (assoc (apply merge-with identity
+;;                   (map make-dict beta-vec))
+;;       :full (last (first beta-full)))))


Add unwrap function to be used for arguments.

--- src/clj/guangyin/internal/types.clj
+++ src/clj/guangyin/internal/types.clj
@@ -11,6 +11,10 @@
   (or (instance? c x) ; FIXME This should be removed
       (and (instance? ObjectWrapper x)
            (instance? c @x))))
+
+(defn unwrap
+  [x]
+  (if (instance? ObjectWrapper x) @x x))

 (defmacro wrap-object
   [& body]


No need to merge frames, they're already complete

--- src/cljs/asciinema_player/core.cljs
+++ src/cljs/asciinema_player/core.cljs
@@ -126,7 +126,7 @@
         start-at (:start-at state)
         speed (:speed state)
         frames (-> (:frames state) (next-frames start-at) (frames-at-speed speed))
-        screen-state-chan (coll->chan frames (partial merge-with merge) {})
+        screen-state-chan (coll->chan frames)
         timer-chan (coll->chan (repeat [0.3 true]))
         stop-playback-chan (chan)
         elapsed-time #(* (elapsed-time-since start) speed)


Timeout sent-messages until ACK arrives

Timeout sent-messages until ACK arrives

Since sending the same message multiple times is idempotent, it
shouldn't cause any issue to re-send any number of times.

--- src/cljs/catsocket_client/core.cljs
+++ src/cljs/catsocket_client/core.cljs
@@ -1,16 +1,51 @@
 (ns catsocket-client.core
   (:require
-            [cljs.core.async :as async :refer [<! >! put! chan]]
+            [cljs.core.async :as async :refer [<! >! put! chan close!]]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
             )
-  (:require-macros [cljs.core.async.macros :refer [go]]))
+  (:require-macros [cljs.core.async.macros :refer [go go-loop]]))
+
+(declare log send do-send on-message on-open on-close)

 (defonce app-state (atom {:text "CatSocket client"}))

 (def logger (atom true))
 (defn stop-logging [] (reset! logger false))
 (defn start-logging [] (reset! logger true))
+
+(defn timeout [ms]
+  (let [c (chan)]
+    (js/setTimeout (fn [] (close! c)) ms)
+    c))
+
+(defn should-send? [timestamp]
+  (< (+ timestamp 5000) (.valueOf (js/Date.))))
+
+(defn start-timer
+  [cat ms]
+  (let [keep-looping (atom true)]
+    (go
+      (loop []
+        (log "Inside loop")
+        (<! (timeout 1000))
+
+        (let [groups (group-by (comp should-send? :timestamp)
+                               (:sent-messages @cat))
+
+              {to-send true, to-keep false} groups]
+
+          (swap! cat assoc :sent-messages (or to-keep {}))
+
+          (doseq [[_ params] to-send]
+            (log "RESENDING" params)
+            (let [new-params (assoc params :timestamp (.valueOf (js/Date.)))]
+              (do-send cat new-params))))
+
+        (when @keep-looping
+          (recur))))
+
+    #(reset! keep-looping false)))

 (defn log [& args]
   (if @logger
@@ -38,8 +73,6 @@
         (let [id (guid)]
           (.setItem js/localStorage user id)
           id)))))
-
-(declare send on-message on-open on-close)

 (defn build-socket [host port]
   (js/WebSocket. (str "ws://" host ":" port "/api/ws")))
@@ -83,6 +116,17 @@
      (set-handlers! cat socket)
      cat)))

+(defn do-send [cat params]
+  (if (and (:connected? @cat) (or (:identified? @cat)
+                                  (= (:action params) "identify")))
+    (do
+      (log "sending" (clj->js params))
+      (swap! cat update-in [:sent-messages] assoc (:id params) params)
+      (.send (:socket @cat) (stringify params)))
+    (do
+      (log "enqueing")
+      (swap! cat update-in [:queue] conj params))))
+
 (defn send [cat action data]
   (let [params {:api_key (:api-key @cat)
                 :user (user)
@@ -90,14 +134,7 @@
                 :data data
                 :id (guid)
                 :timestamp (.getTime (js/Date.))}]
-    (if (and (:connected? @cat) (or (:identified? @cat) (= action "identify")))
-      (do
-        (log "sending" (clj->js params))
-        (swap! cat update-in [:sent-messages] assoc (:id params) params)
-        (.send (:socket @cat) (stringify params)))
-      (do
-        (log "enqueing")
-        (swap! cat update-in [:queue] conj params)))))
+    (do-send cat params)))

 (defn flush-queue [cat]
   (log "identified, flushing queue")


Fixed issue in OCTGN export

Fixed issue in OCTGN export

--- src/cljs/netrunner/deckbuilder.cljs
+++ src/cljs/netrunner/deckbuilder.cljs
@@ -121,7 +121,7 @@
         xml (str
              "<deck game=\"0f38e453-26df-4c04-9d67-6d43de939c77\">
<card qty=\"1\" id=\""
              id (:code identity) "\">" (:title identity) "</card>
"
-             "
"
+             "
"
              (apply str (for [c (:cards deck)]
                           (str "<card qty=\"" (:qty c) "\" id=\"" id (get-in c [:card :code]) "\">"
                                (get-in c [:card :title]) "</card>")))


Fix docstring location

Fix docstring location

--- src/overtone/sc/cgens/oscillators.clj
+++ src/overtone/sc/cgens/oscillators.clj
@@ -12,10 +12,10 @@

 (defcgen square
   "A square wave generator"
+  [freq {:default 440 :doc "Signal frequency"}]
   "A square wave only exists in two states: high and low. This wave
    produces only odd harmonics resulting in a mellow, hollow sound. This
    makes it particularly suitable for emulating wind instruments, adding
    width to strings and pads, or for the creation of deep, wide bass
    sounds."
-  [freq {:default 440 :doc "Signal frequency"}]
   (:ar (pulse:ar freq 0.5)))


Minor subscriber cleanup.

Minor subscriber cleanup.

--- src/onyx/messaging/aeron/subscriber.clj
+++ src/onyx/messaging/aeron/subscriber.clj
@@ -64,6 +64,12 @@
     (onAvailableImage [this image]
       (info "Available network image" (.position image) (.sessionId image) :correlation-id (.correlationId image) sub-info))))

+(defn new-error-handler [error error-counter]
+  (reify ErrorHandler
+    (onError [this x]
+      (reset! error x)
+      (.addAndGet error-counter 1))))
+
 (deftype Subscriber
   [peer-id
    ticket-counters
@@ -73,7 +79,7 @@
    site
    batch-size
    ^AtomicLong read-bytes
-   ^AtomicLong errors
+   ^AtomicLong error-counter
    error
    ^bytes bs
    channel
@@ -90,15 +96,11 @@
    ^:unsynchronized-mutable batch]
   sub/Subscriber
   (start [this]
-    (let [error-handler (reify ErrorHandler
-                          (onError [this x]
-                            (reset! error x)
-                            (.addAndGet errors 1)))
-          media-driver-dir (:onyx.messaging.aeron/media-driver-dir peer-config)
+    (let [media-driver-dir (:onyx.messaging.aeron/media-driver-dir peer-config)
           sinfo [dst-task-id slot-id site]
           lost-sessions (atom #{})
-          ctx (cond-> (Aeron$Context.)
-                error-handler (.errorHandler error-handler)
+          ctx (cond-> (.errorHandler (Aeron$Context.)
+                                     (new-error-handler error error-counter))
                 media-driver-dir (.aeronDirectoryName ^String media-driver-dir))
           conn (Aeron/connect ctx)
           channel (autil/channel peer-config)
@@ -112,7 +114,7 @@
           status {}
           new-subscriber (sub/add-assembler
                           (Subscriber. peer-id ticket-counters peer-config dst-task-id
-                                       slot-id site batch-size read-bytes errors error bs channel
+                                       slot-id site batch-size read-bytes error-counter error bs channel
                                        conn sub lost-sessions sources short-id-status-pub
                                        status-pubs nil nil nil status nil))]
       (info "Created subscriber" (sub/info new-subscriber))
@@ -127,7 +129,7 @@
     (when conn (.close conn))
     (run! status-pub/stop (vals status-pubs))
     (Subscriber. peer-id ticket-counters peer-config dst-task-id slot-id site
-                 batch-size read-bytes errors error bs nil nil nil nil nil nil nil
+                 batch-size read-bytes error-counter error bs nil nil nil nil nil nil nil
                  nil nil nil nil nil))
   (add-assembler [this]
     (set! assembler (ControlledFragmentAssembler. this))


Add resolver response to node-resolver-success data

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -1114,21 +1114,27 @@
                          (serial-cache-resolver-call env e))
                        (try
                          (let [r (call-resolver env e)]
-                           (reader3-node-log! env node {::pt/event ::node-resolver-success})
+                           (reader3-node-log! env node {::pt/event            ::node-resolver-success
+                                                        ::resolver-call-input e
+                                                        ::resolver-response   r})
                            r)
                          (catch #?(:clj Throwable :cljs :default) e
-                           (reader3-node-log! env node {::pt/event       ::node-resolver-error
-                                                        ::resolver-error e})
+                           (reader3-node-log! env node {::pt/event            ::node-resolver-error
+                                                        ::resolver-call-input e
+                                                        ::resolver-error      e})
                            (throw e))))]
       (if async-parser?
         (go-promise
           (let [response (try
                            (let [r (<?maybe response)]
-                             (reader3-node-log! env node {::pt/event ::node-resolver-success})
+                             (reader3-node-log! env node {::pt/event            ::node-resolver-success
+                                                          ::resolver-call-input e
+                                                          ::resolver-response   r})
                              r)
                            (catch #?(:clj Throwable :cljs :default) e
-                             (reader3-node-log! env node {::pt/event       ::node-resolver-error
-                                                          ::resolver-error e})
+                             (reader3-node-log! env node {::pt/event            ::node-resolver-error
+                                                          ::resolver-call-input e
+                                                          ::resolver-error      e})
                              (throw e)))]
             (if (reader3-merge-resolver-response env sym response)
               (<?maybe (reader3-run-next-node env plan node)))))


Remove old async code frmo profile

Remove old async code frmo profile

--- src/com/wsscode/pathom/profile.cljc
+++ src/com/wsscode/pathom/profile.cljc
@@ -50,47 +50,6 @@
                    (swap! profile* assoc k (- (current-time-ms) start-time))
                    res))))))))})

-(defn process-pending? [m]
-  (if (map? m)
-    (->> m
-         (filter (fn [[k v]] (and (not= k ::self) (= ::processing v))))
-         first)))
-
-#?(:clj
-   (defn sleep [ms]
-     (go
-       (Thread/sleep ms)
-       ::done))
-
-   :cljs
-   (defn sleep [ms]
-     (let [c (chan)]
-       (js/setTimeout #(put! c ::done) ms)
-       c)))
-
-(defn async-wrap-profile [f]
-  (fn [{::keys [profile]
-        :as    env} k p]
-    (let [{::p/keys [path]} (p/normalize-env env)
-          start-time (current-time-ms)
-          res        (f env k p)]
-      (if profile
-        (if (pa/chan? (:value res))
-          (do
-            (swap! profile update-in path append-at ::processing)
-            (go
-              (let [v (<! (:value res))]
-                (while (process-pending? (get-in @profile path))
-                  (<! (sleep 1)))
-                (swap! profile update-in path append-at
-                  (- (current-time-ms) start-time))
-                (assoc res :value v))))
-          (do
-            (swap! profile update-in path append-at
-              (- (current-time-ms) start-time))
-            res))
-        res))))
-
 ;; Helper computing functions

 (defn node-name [x]


remove extra dep

remove extra dep

--- examples/ring-swagger/src/example/server.clj
+++ examples/ring-swagger/src/example/server.clj
@@ -8,7 +8,6 @@
             [reitit.ring.middleware.exception :as exception]
             [ring.middleware.params :as params]
             [ring.adapter.jetty :as jetty]
-            [ring.middleware.params]
             [muuntaja.core :as m]))

 (def app


include positions

include positions

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@5894 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- clojure/acq_engine.clj
+++ clojure/acq_engine.clj
@@ -84,11 +84,12 @@
       :position-index       "PositionIndex"
       :slice-index          "Slice"
       :slice                "SlicePosition"
+      "ElapsedTime-ms"      "ElapsedTime-ms"
     )
-    (assoc "PositionIndex" 0
-           "Channel" (get-in event [:channel :name])
-           "PixelType" "GRAY8"
-           )))
+    (assoc
+      "Channel" (get-in event [:channel :name])
+      "PixelType" "GRAY8"
+    )))

 ;; acq-engine

@@ -151,7 +152,7 @@

 (defn collect-image [event out-queue]
   (println event)
-  (.add out-queue (generate-tagged-image (. mmc getImage) event)))
+  (.add out-queue (generate-tagged-image (. mmc getImage) (assoc event "ElapsedTime-ms" (clock-ms)))))

 (defn run-event [event last-wake-time out-queue]
   (run-actions (create-presnap-actions event))
@@ -193,7 +194,6 @@
     (proxy [AcquisitionWrapperEngine] []
       (runPipeline [^SequenceSettings settings]
         (let [out-queue (LinkedBlockingQueue.)]
-          (run-acquisition (convert-settings settings) out-queue)
           (.start (LiveAcqDisplay. mmc out-queue settings (.channels settings) (.save settings) this)))))
     (.setCore mmc (.getAutofocusManager gui))
     (.setParentGUI gui)


remove accidental comment-outings

remove accidental comment-outings

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@5953 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- clojure/acq_engine.clj
+++ clojure/acq_engine.clj
@@ -213,13 +213,13 @@
 (defn make-event-fns [event out-queue]
   (let [event (compute-z-position event)]
     (list
-	;	#(run-actions (create-presnap-actions event))
-	;	#(await-for 10000 (device-agents (. mmc getCameraDevice)))
-	;	#(when-let [wait-time-ms (event :wait-time-ms)]
-	;	  (acq-sleep wait-time-ms))
-	;	#(when (:autofocus event)
-	;	  (store-z-correction (run-autofocus)))
-	;	#(snap-image true (:close-shutter event))
+		#(run-actions (create-presnap-actions event))
+		#(await-for 10000 (device-agents (. mmc getCameraDevice)))
+		#(when-let [wait-time-ms (event :wait-time-ms)]
+		  (acq-sleep wait-time-ms))
+		#(when (:autofocus event)
+		  (store-z-correction (run-autofocus)))
+		#(snap-image true (:close-shutter event))
 		#(collect-image event out-queue)
     )))


(PDB-5128) Handle have-newer-record-for-certname? in one round trip

--- src/puppetlabs/puppetdb/scf/storage.clj
+++ src/puppetlabs/puppetdb/scf/storage.clj
@@ -339,8 +339,8 @@
                                (comp :id first sql/result-set-seq))))

 (pls/defn-validated ensure-row :- (s/maybe s/Int)
-  "Check if the given row (defined by `row-map` exists in `table`, creates it if it does not. Always returns
-   the id of the row (whether created or existing)"
+  "Ensures the row defined by row-map exists in the table,
+   creating it if it does not.  Returns the id of the row."
   [table :- s/Keyword
    row-map :- {s/Keyword s/Any}]
   (when row-map
@@ -1698,24 +1698,27 @@
                :limit 1}]
     (:producer_timestamp (first (jdbc/query (hcore/format query))))))

-(pls/defn-validated have-record-produced-after?
-  [entity :- s/Keyword
-   certname :- String
-   time :- pls/Timestamp]
-  (let [time (to-timestamp time)]
-    (boolean
-     (some-> entity
-             (timestamp-of-newest-record certname)
-             (.after time)))))
-
 (pls/defn-validated have-newer-record-for-certname?
   "Returns a truthy value indicating whether a record exists that has
   a producer_timestamp newer than the given timestamp."
   [certname :- String
    timestamp :- pls/Timestamp]
-  (some (fn [entity]
-          (have-record-produced-after? entity certname timestamp))
-        [:catalogs :factsets :reports]))
+  (when-let [newest (-> ["select producer_timestamp"
+                         "  from (select producer_timestamp from catalogs"
+                         "          where certname = ?"
+                         "          order by producer_timestamp desc limit 1) cats"
+                         "  union all (select producer_timestamp from factsets"
+                         "               where certname = ?"
+                         "               order by producer_timestamp desc limit 1)"
+                         "  union all (select producer_timestamp from reports"
+                         "               where certname = ?"
+                         "               order by producer_timestamp desc limit 1)"
+                         "  order by producer_timestamp desc"
+                         "  limit 1"]
+                        (jdbc/do-prepared (repeat 3 certname))
+                        first
+                        :producer_timestamp)]
+    (.after newest timestamp)))

 (pls/defn-validated maybe-activate-node!
   "Reactivate the given host, only if it was deactivated or expired before


fix service test

fix service test

--- test/github_contributions/service_test.clj
+++ test/github_contributions/service_test.clj
@@ -8,17 +8,9 @@
   (::bootstrap/service-fn (bootstrap/create-servlet service/service)))

 (deftest home-page-test
-  (is (=
+  (is (.contains
        (:body (response-for service :get "/"))
-       "Hello World!"))
+       "Contributions on Github"))
   (is (=
        (:headers (response-for service :get "/"))
-       {"Content-Type" "text/html"})))
-
-(deftest about-page-test
-  (is (.contains
-       (:body (response-for service :get "/about"))
-       "Clojure 1.5"))
-  (is (=
-       (:headers (response-for service :get "/about"))
-       {"Content-Type" "text/html"})))
+       {"Content-Type" "text/html"})))


Too aggressive in tests

Too aggressive in tests

--- test/midje/internal_ideas/t_compendium.clj
+++ test/midje/internal_ideas/t_compendium.clj
@@ -68,15 +68,12 @@
     (embodied-fact compendium symbol-namespace (fact-body-source named)) => named))

-(fact "there is a useful error message when the symbol does not name a loaded namespace"
-  (remove-namespace-facts-from (fresh) 'no-such-namespace)
-  => (throws Error #"namespace.*never been loaded")
-
+(fact "there is sometimes a useful error message when the symbol does not name a loaded namespace"
   (namespace-facts (fresh) 'no-such-namespace)
   => (throws Error #"namespace.*never been loaded")

   (named-fact (fresh) 'no-such-namespace "something")
-  => (throws Error #"namespace.*no-such-namespace.*never been loaded"))
+  => (throws Error #"no-such-namespace.*never been loaded"))


silence 'declared queue' output

silence 'declared queue' output

--- src/fscrawler_tika_convert/core.clj
+++ src/fscrawler_tika_convert/core.clj
@@ -91,7 +91,7 @@
   (le/declare ch exchange-name "topic")
   (let [queue-name (format "%s.%s.%s" exchange-name command filesystem)]
     (let [queue-state (lq/declare ch queue-name :auto-delete false)]
-      (logging/info "declared queue" (select-keys queue-state [:queue :consumer-count :message-count])))
+      (logging/debug "declared queue" (select-keys queue-state [:queue :consumer-count :message-count])))
     (lq/bind ch queue-name exchange-name :routing-key queue-name)
     queue-name))


alternative grouping function

alternative grouping function

--- src/unspun/screens/number_needed.cljs
+++ src/unspun/screens/number_needed.cljs
@@ -15,17 +15,17 @@
   (ionicon {:name  "ios-disc"
             :size  size
             :color "green"
-            :style {:position  "absolute"
-                    :left      (+ x (/ size 2))
-                    :top       (+ y (/ size 2))
+            :style {:position "absolute"
+                    :left     x
+                    :top      y
                     }
             #_:style #_{:color           white
                         :backgroundColor "rgba(0,0,0,0)"
                         ;:flex            -1
-                        :width           30                    ; the grid width - should be 30 for a packed icon whatever the scale
-                        :transform       [{:translateX 0}        ;(* 15 scale kk)
-                                          {:translateY 0}        ;(* 15 scale kk)
-                                          {:scale 1}]}}))        ; the scale. higher = denser, but on same centres.
+                        :width           30                 ; the grid width - should be 30 for a packed icon whatever the scale
+                        :transform       [{:translateX 0}   ;(* 15 scale kk)
+                                          {:translateY 0}   ;(* 15 scale kk)
+                                          {:scale 1}]}}))   ; the scale. higher = denser, but on same centres.

 #_(defn draw-icon [scenar color scale kk]
@@ -37,31 +37,40 @@
                      :transform       [{:translateX 0}      ;(* 15 scale kk)
                                        {:scale (* scale kk)}]}}))

+(defn grouper
+  [j]
+  (+ j (/ (js/Math.floor (/ j 5)) 3)))

 (rum/defc page < rum/reactive []
   (let [scenar ((rum/react stories) (rum/react story-index))
+        palette (get-palette (rum/react palette-index))
         br (:baseline-risk scenar)
         rr (:relative-risk scenar)
         nn (number-needed rr br)
         [w h] (screen-w-h)
         w (- w 0)
-        h  (- h 168)                                        ; adjustment for existing header and footer
-        isz 30
+        h (- h 168)                                         ; adjustment for existing header and footer
+        isz 24
         row-n (dec (js/Math.floor (/ w isz)))
         col-n (dec (js/Math.floor (/ h isz)))
-        dw (- w (* row-n isz))
-        dh (- h (* col-n isz))]
+        dw (/ (- w (* row-n isz)) 2)
+        dh (/ (- h (* col-n isz)) 2)]
     (prn [w h])
-    (view {:style {:backgroundColor "black"
-                   :borderWidth "1"
-                   :borderColor "cyan"
-                   :width           w
-                   :height          h
-                   :position "relative"
-                   }}
-          (for [i (range row-n)]
-            (for [j (range col-n)]
-              (draw-circle scenar "red" isz (+ 10 (* i isz)) (+ 10 (* j isz))))))))
+    (scroll-view {:style {:flex            1
+                          :padding         0
+                          :backgroundColor (:primary palette)}}
+                 (view {:style {:backgroundColor "black"
+                                :borderWidth     1
+                                :borderColor     "cyan"
+                                :width           w
+                                :height          h
+                                :position        "relative"
+                                }}
+                       (for [i (range row-n)]
+                         (for [j (range col-n)]
+                           (draw-circle scenar "red" isz
+                                        (+ dw (* (grouper i) isz))
+                                        (+ dh (* (grouper j) isz)))))))))

 #_(rum/defc page < rum/reactive []


Makes process log more clear (#1312)

Makes process log more clear (#1312)

--- scheduler/src/cook/kubernetes/controller.clj
+++ scheduler/src/cook/kubernetes/controller.clj
@@ -107,6 +107,12 @@
     (assoc expected-state-dict :launch-pod [:elided-for-brevity])
     expected-state-dict))

+(defn prepare-existing-state-dict-for-logging
+  [existing-state-dict]
+  (-> existing-state-dict
+      (update-in [:synthesized-state :state] #(or % :missing))
+      (dissoc :pod)))
+
 (defn pod-has-started
   "A pod has started. So now we need to update the status in datomic."
   [kcc {:keys [pod] :as existing-state-dictionary}]
@@ -130,12 +136,12 @@
 (defn process
   "Visit this pod-name, processing the new level-state. Returns the new expected state. Returns
   empty dictionary to indicate that the result should be deleted. NOTE: Must be invoked with the lock."
-  [{:keys [api-client existing-state-map expected-state-map] :as kcc} ^String pod-name]
+  [{:keys [api-client existing-state-map expected-state-map name] :as kcc} ^String pod-name]
   (loop [{:keys [expected-state] :as expected-state-dict} (get @expected-state-map pod-name)
          {:keys [synthesized-state pod] :as existing-state-dict} (get @existing-state-map pod-name)]
-    ;; TODO: Remove the printing of existing-state-dict once we test on real kubernetes and get synthesized-pod-state robust.
-    (log/info "Processing: " pod-name ": ((" (prepare-expected-state-dict-for-logging expected-state-dict)
-              " ===== " (or (:state synthesized-state) :missing)  "///" existing-state-dict  "))")
+    (log/info "In compute cluster" name ", processing pod" pod-name ";"
+              "expected:" (prepare-expected-state-dict-for-logging expected-state-dict) ","
+              "existing:" (prepare-existing-state-dict-for-logging existing-state-dict))
     ; TODO: We added an :expected/starting state to the machine, to represent when a pod is starting. We map instance.status/unknown to that state
     ; The todo is to add in cases for [:expected/starting *] for those other states.
     (let


Add keys and display name

Add keys and display name

--- src/cljs/cglossa/search_inputs/cwb/core.cljs
+++ src/cljs/cglossa/search_inputs/cwb/core.cljs
@@ -177,7 +177,9 @@
                              has-phonetic?         (:has-phonetic corpus)
                              remove-term-handler   #()]
                          (list (when-not first?
+                                 ^{:key (str "interval" index)}
                                  [interval query-cursor term])
+                               ^{:key (str "term" index)}
                                [multiword-term query-cursor term first? last? has-phonetic?
                                 show-remove-row-btn? remove-row-handler
                                 show-remove-term-btn? remove-term-handler])))
@@ -202,7 +204,10 @@
   or CQP query view) and displays it."
   [{:keys [search-view search-queries]} {:keys [corpus]}]
   (reagent/create-class
-    {:component-did-mount
+    {:display-name
+     "search-inputs"
+
+     :component-did-mount
      focus-text-input

      :reagent-render
@@ -268,9 +273,10 @@
                      (let [query-cursor       (reagent/cursor query-get-set [index])
                            selected-language  (-> @query-cursor :query :lang)
                            remove-row-handler (partial remove-query index)]
+                       ^{:key index}
                        [:div.row
                         [:div.col-md-12
-                         (when multilingual? [language-select languages selected-language])
-                         ^{:key index} [view @corpus query-cursor show-remove-row-btn?
-                                        remove-row-handler]]]))))
+                         (when multilingual?
+                           [language-select languages selected-language])
+                         [view @corpus query-cursor show-remove-row-btn? remove-row-handler]]]))))
           (when-not multilingual? [add-phrase-button])]))}))


Fix evaluation order.

Fix evaluation order.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -65,7 +65,6 @@
                                       (do
                                         (.inc ~dropped-counter)
                                         (Thread/yield)))
-               "put" `(.put ~queue ~data)
                "put-counted-yield" `(if (< (.size ~queue) queue-size)
                                       (do
                                         (.put ~queue ~data)
@@ -73,10 +72,7 @@
                                       (do
                                         (.inc ~dropped-counter)
                                         (Thread/yield)))
-               "offer" `(.offer ~queue ~data)
-               "offer-counted" `(if (.offer ~queue ~data)
-                                  (.inc ~enqueued-counter)
-                                  (.inc ~dropped-counter))
+               "put" `(.put ~queue ~data)
                "offer-counted-yield" `(if (< (.size ~queue) queue-size)
                                         (do
                                           (.offer ~queue ~data)
@@ -84,7 +80,10 @@
                                         (do
                                           (.inc ~dropped-counter)
                                           (Thread/yield)))
-               "transfer" `(.transfer ~queue ~data)
+               "offer-counted" `(if (.offer ~queue ~data)
+                                  (.inc ~enqueued-counter)
+                                  (.inc ~dropped-counter))
+               "offer" `(.offer ~queue ~data)
                "transfer-counted-no-sleep" `(if (.hasWaitingConsumer ~queue)
                                               (do
                                                 (.transfer ~queue ~data)
@@ -104,6 +103,7 @@
                                                (do
                                                  (.inc ~dropped-counter)
                                                  (Thread/yield)))
+               "transfer" `(.transfer ~queue ~data)
                "tryTransfer-counted-no-timeout" `(if (.tryTransfer ~queue ~data)
                                                    (.inc ~enqueued-counter)
                                                    (.inc ~dropped-counter))


Clean up printing

Clean up printing

--- src/tree/core.clj
+++ src/tree/core.clj
@@ -142,10 +142,17 @@
   [node writer]
   (print-index-node node writer true))

+(defn node-status-bits
+  [node]
+  (str "["
+       (if (dirty? node) "D" " ")
+       "]"))
+
 (defmethod pp/simple-dispatch IndexNode
   [node]
   (let [out ^Writer *out*]
     (.write out "IndexNode")
+    (.write out (node-status-bits node))
     (pp/pprint-logical-block
       :prefix "{" :suffix "}"
       (pp/pprint-logical-block
@@ -191,7 +198,7 @@
   (instance? DataNode node))

 ;(println (b-tree :foo :bar :baz))
-;(pp/pprint (b-tree :foo :bar :baz))
+;(pp/pprint (apply b-tree (range 100)))
 (defn print-data-node
   [node ^Writer writer fully-qualified?]
   (.write writer (if fully-qualified?
@@ -209,7 +216,10 @@

 (defmethod pp/simple-dispatch DataNode
   [node]
-  (print-data-node node *out* false))
+  (let [out ^Writer *out*]
+    (.write out (str "DataNode"
+                     (node-status-bits node)))
+    (.write out (str {:children (:children node)}))))

 (defn backtrack-up-path-until
   "Given a path (starting with root and ending with an index), searches backwards,
@@ -414,6 +424,28 @@
   (last-key [_] last-key)
   (resolve [_] node))

+(defn print-testing-addr
+  [node ^Writer writer fully-qualified?]
+  (.write writer (if fully-qualified?
+                   (pr-str TestingAddr)
+                   "TestingAddr"))
+  (.write writer (str {})))
+
+(defmethod print-method TestingAddr
+  [node writer]
+  (print-testing-addr node writer false))
+
+(defmethod print-dup TestingAddr
+  [node writer]
+  (print-testing-addr node writer true))
+
+(defmethod pp/simple-dispatch TestingAddr
+  [node]
+  (let [out ^Writer *out*]
+    (.write out (str "TestingAddr"
+                     (node-status-bits node)))
+    (.write out (str {}))))
+
 ;;TODO make this a loop/recur instead of mutual recursion
 (declare flush-tree)

@@ -443,16 +475,33 @@
            cleaned-node (assoc tree :children cleaned-children)
            new-addr (->TestingAddr (last-key tree) cleaned-node)]
        (deliver (:storage-addr tree) new-addr)
+       (when (not= new-addr @(:storage-addr tree))
+         ;;here's where we'd rollback a write
+         )
        {:tree new-addr :stats (update-in stats [:writes] inc)})
      {:tree tree :stats stats})))

+;; The parts of the serialization system that seem like they're need hooks are:
+;; - Must provide a function that takes a node, serializes it, and returns an addr
+;; - Must be able to rollback writing an addr
+;; - Whatever the addr it returns, it should cache its resolve in-mem somehow
+;; - The serialize a node & rollback a node functions should accept a "stats" object as well
+;; - The "stats" object must be convertible to a summary or whatever at the end
+
+;; could make a redis backend using refcounting for nodes :)
+
 (comment
   (clojure.pprint/pprint (apply b-tree (range 30)))

-  (let [t (:tree (flush-tree (apply b-tree (range 30))))]
+  (let [t (:tree (flush-tree (apply b-tree (range 30))))
+        t' (reduce insert t [-7 100])]
     (assert (= 0 (:writes (:stats (flush-tree t)))))
     (assert (= (range 30) (lookup-fwd-iter t -1)))
-    (:stats (flush-tree (insert t -7)))
+    (pp/pprint t)
+    (pp/pprint (insert t -7))
+    (pp/pprint t')
+    (pp/pprint (flush-tree t'))
+    (pp/pprint t')
     )


fix denorm

fix denorm

--- src/er_cassandra/model/alia/relationship.clj
+++ src/er_cassandra/model/alia/relationship.clj
@@ -22,11 +22,17 @@
 (s/defschema DenormalizeOp
   (s/enum :upsert :delete))

-(defn deref-target-entity
-  [kw]
-  (let [var (ns-resolve (-> kw namespace symbol)
-                        (-> kw name symbol))]
-    @var))
+(defn- deref-target-entity
+  "given a namespace qualififed symbol or keyword referring to a
+   var with an Entity, return the Entity... otherwise return whatever
+   is given"
+  [entity-var-ref]
+  (if (or (keyword? entity-var-ref)
+          (symbol? entity-var-ref))
+    (deref
+     (ns-resolve (namespace entity-var-ref) (name entity-var-ref)))
+
+    entity-var-ref))

 (s/defn foreign-key-val
   "returns [fk fk-val] for the denorm relationship"
@@ -53,7 +59,7 @@
    target-record :- t/RecordSchema
    denorm-op :- DenormalizeOp]
   (let [[fk fk-val :as fk-vals] (foreign-key-val source-entity source-record denorm-rel)
-        fk-map (into {} fk-vals)
+        fk-map (into {} (map vector fk fk-val))
         denorm-vals (->> (:denormalize denorm-rel)
                          (map (fn [[scol tcol]]
                                 [tcol (get source-record scol)]))
@@ -96,13 +102,16 @@
    target-entity :- Entity
    source-record :- t/RecordSchema
    denorm-rel :- t/DenormalizationRelationshipSchema]
-  (let [[fk fk-val] (foreign-key-val source-entity source-record denorm-rel)
+  (with-context deferred-context
+    (mlet [:let [[fk fk-val] (foreign-key-val source-entity source-record denorm-rel)]

-        trs (m/select-buffered
-             session
-             target-entity
-             fk-val)]
-    (return deferred-context trs)))
+          trs (m/select-buffered
+               session
+               target-entity
+               fk
+               fk-val)]
+
+      (return deferred-context trs))))

 (defn only-error
   "given a Deferred keep only errors, otherwise returning Deferred<nil>"
@@ -117,6 +126,7 @@
    source-entity :- Entity
    target-entity :- Entity
    source-record :- t/RecordSchema
+   denorm-rel-kw :- s/Keyword
    denorm-rel :- t/DenormalizationRelationshipSchema
    denorm-op :- DenormalizeOp]
   (with-context deferred-context
@@ -131,7 +141,7 @@
                              (st/map #(denormalize-to-target-record
                                        session
                                        source-entity
-                                       (-> % :target deref-target-entity)
+                                       target-entity
                                        source-record
                                        denorm-rel
                                        %
@@ -143,24 +153,27 @@

       ;; if there are errors, return the first as an exemplar
       (if (nil? maybe-err)
-        (return [denorm-rel [:ok]])
-        (return [denorm-rel [:fail maybe-err]])))))
+        (return [denorm-rel-kw [:ok]])
+        (return [denorm-rel-kw [:fail maybe-err]])))))

-;; (s/defn denormalize
-;;   "denormalize all relationships for a given source record
-;;    returns [[denorm-rel [status maybe-err]]*]"
-;;   [session :- Session
-;;    source-entity :- Entity
-;;    source-record :- t/RecordSchema
-;;    denorm-op :- DenormalizeOp]
-;;   (let [rels (-> source-entity :denorm-targets vals)
-;;         v (uuid/v1)
-;;         resps (->> rels
-;;                    (map #(denormalize-rel session
-;;                                           source-entity
-;;                                           target-entity
-;;                                           source-record
-;;                                           %
-;;                                           denorm-op
-;;                                           v)))]
-;;     (apply d/zip resps)))
+
+
+(s/defn denormalize
+  "denormalize all relationships for a given source record
+   returns [[denorm-rel-kw [status maybe-err]]*]"
+  [session :- Session
+   source-entity :- Entity
+   source-record :- t/RecordSchema
+   denorm-op :- DenormalizeOp]
+  (let [resps (->> source-entity
+                   :denorm-targets
+                   (map
+                    (fn [[rel-kw rel]]
+                      (denormalize-rel session
+                                       source-entity
+                                       (deref-target-entity (:target rel))
+                                       source-record
+                                       rel-kw
+                                       rel
+                                       denorm-op))))]
+    (apply d/zip resps)))


2.0.0

--- metrics-clojure-ring/project.clj
+++ metrics-clojure-ring/project.clj
@@ -1,5 +1,5 @@
-(defproject metrics-clojure-ring "2.0.0-SNAPSHOT"
+(defproject metrics-clojure-ring "2.0.0"
   :description "Various things gluing together metrics-clojure and ring."
   :dependencies [[cheshire "5.3.1"]
-                 [metrics-clojure "1.1.0"]]
+                 [metrics-clojure "2.0.0"]]
   :profiles {:dev {:dependencies [[ring "1.2.2"]]}})


Notes.

Notes.

--- test/com/nomistech/clojure_the_language/take_while_ascending_etc_test.clj
+++ test/com/nomistech/clojure_the_language/take_while_ascending_etc_test.clj
@@ -2,7 +2,7 @@
   (:require [midje.sweet :refer :all]))

-;; Or was what you did at the Citi interview better?
+;; Or was what you did at that interview better?
 ;; - partition into pairs...

 (defn take-while-binary-pred


Corrected inner-product definition to ensure that either matrix in the product could be non-complex.

--- src/main/clj/clojure/core/matrix/complex.clj
+++ src/main/clj/clojure/core/matrix/complex.clj
@@ -91,11 +91,15 @@

    mp/PMatrixProducts
      (inner-product [m a]
-       (ComplexArray. (mp/add-scaled (mp/inner-product (.real m) (clojure.core.matrix.complex/real a))
-                                     (mp/inner-product (.imag m) (clojure.core.matrix.complex/imag a))
+       (ComplexArray. (mp/add-scaled (mp/inner-product (clojure.core.matric.complex/real m)
+                                                       (clojure.core.matrix.complex/real a))
+                                     (mp/inner-product (clojure.core.matric.complex/imag m)
+                                                       (clojure.core.matrix.complex/imag a))
                                      -1)
-                      (mp/matrix-add (mp/inner-product (.real m) (clojure.core.matrix.complex/imag a))
-                                     (mp/inner-product (.imag m) (clojure.core.matrix.complex/real a))))))
+                      (mp/matrix-add (mp/inner-product (clojure.core.matric.complex/real m)
+                                                       (clojure.core.matrix.complex/imag a))
+                                     (mp/inner-product (clojure.core.matric.complex/imag m)
+                                                       (clojure.core.matrix.complex/real a))))))

 (defn complex-array