[scamp] use 'scamp-test wrapper for all tests.

--- modules/scamp/test/scamp/core_test.clj
+++ modules/scamp/test/scamp/core_test.clj
@@ -18,32 +18,34 @@
   (f))

 (deftest subscribe-new-node-test
-  (is (= (-> core/new-world
-             (core/add-new-node (core/node-contact-address->node "node-id0"))
-             (core/subscribe-new-node "node-id1" "node-id0")
-             (dissoc :config)
-             purge-world-envelope-ids)
-         {:message-envelopes [],
-          :network
-          {"node-id0"
-           {:self {:id "node-id0"},
-            :upstream #{"node-id1"},
-            :downstream #{},
-            :messages-seen {}},
-           "node-id1"
-           {:self {:id "node-id1"},
-            :upstream #{},
-            :downstream #{"node-id0"},
-            :messages-seen {}}}})))
+  (scamp-test
+   #(is (= (-> core/new-world
+               (core/add-new-node (core/node-contact-address->node "node-id0"))
+               (core/subscribe-new-node "node-id1" "node-id0")
+               (dissoc :config)
+               purge-world-envelope-ids)
+           {:message-envelopes [],
+            :network
+            {"node-id0"
+             {:self {:id "node-id0"},
+              :upstream #{"node-id1"},
+              :downstream #{},
+              :messages-seen {}},
+             "node-id1"
+             {:self {:id "node-id1"},
+              :upstream #{},
+              :downstream #{"node-id0"},
+              :messages-seen {}}}}))))

 (deftest forward-subscription-test
-  (binding [scamp.core/*rand* testing-rand*]
-    (let [result (->> (core/forward-subscription #{"stuffy-node" "stuffier-node"}
-                                                 "allergen-free-node"
-                                                 "43")
-                      (map purge-envelope-id))]
-      (is (= result
-           [[:message-envelope "stuffy-node" :forwarded-subscription "allergen-free-node"]])))))
+  (scamp-test
+   #(binding [scamp.core/*rand* testing-rand*]
+      (let [result (->> (core/forward-subscription #{"stuffy-node" "stuffier-node"}
+                                                   "allergen-free-node"
+                                                   "43")
+                        (map purge-envelope-id))]
+        (is (= result
+               [[:message-envelope "stuffy-node" :forwarded-subscription "allergen-free-node"]]))))))

 (def comm-test-world
   (-> core/new-world
@@ -92,29 +94,33 @@
                   :messages-seen {}}}}))))))

 (deftest notify-add-upstream-test
-  (is (= (-> {:self {:id "canticle"} :upstream #{} :downstream #{} :messages-seen {}}
-             (core/notify-add-upstream "liebowitz")
-             purge-envelope-id)
-         [:message-envelope "liebowitz" :add-upstream "canticle"])))
+  (scamp-test
+   #(is (= (-> {:self {:id "canticle"} :upstream #{} :downstream #{} :messages-seen {}}
+               (core/notify-add-upstream "liebowitz")
+               purge-envelope-id)
+           [:message-envelope "liebowitz" :add-upstream "canticle"]))))

 (deftest handle-add-upstream-test
-  (is (= (core/handle-add-upstream (:logging core/default-config)
-                                   {:self {:id "canticle"} :upstream #{} :downstream #{} :messages-seen {}}
-                                   "liebowitz")
-         [{:self {:id "canticle"}, :upstream #{"liebowitz"}, :downstream #{} :messages-seen {}} []])))
+  (scamp-test
+   #(is (= (core/handle-add-upstream (:logging core/default-config)
+                                     {:self {:id "canticle"} :upstream #{} :downstream #{} :messages-seen {}}
+                                     "liebowitz")
+           [{:self {:id "canticle"}, :upstream #{"liebowitz"}, :downstream #{} :messages-seen {}} []]))))

 (deftest update-self-test
-  (let [new-node (core/node-contact-address->node "node-id0")
-        non-networked-node (core/node-contact-address->node "non-networked-node")]
-    (is (= (-> core/new-world
-             (core/add-new-node new-node)
-             (core/update-self new-node #(update % :upstream conj "flimflam"))
-             (dissoc :config)
-             purge-world-envelope-ids)
-           {:message-envelopes []
-            :network
-            {"node-id0"
-             {:self {:id "node-id0"}, :upstream #{"flimflam"}, :downstream #{} :messages-seen {}}}}))))
+  (scamp-test
+   (fn []
+     (let [new-node (core/node-contact-address->node "node-id0")
+           non-networked-node (core/node-contact-address->node "non-networked-node")]
+       (is (= (-> core/new-world
+                  (core/add-new-node new-node)
+                  (core/update-self new-node #(update % :upstream conj "flimflam"))
+                  (dissoc :config)
+                  purge-world-envelope-ids)
+              {:message-envelopes []
+               :network
+               {"node-id0"
+                {:self {:id "node-id0"}, :upstream #{"flimflam"}, :downstream #{} :messages-seen {}}}}))))))

 (comment
 (binding [scamp.core/*rand* testing-rand*]


Update classifier ezbake config to use a version variable for consistency between upstream jar and ezbake artifact version.

--- configs/classifier/classifier.clj
+++ configs/classifier/classifier.clj
@@ -1,7 +1,9 @@
-(defproject puppetlabs.packages/classifier "0.2.2-SNAPSHOT"
+(def classifier-version "0.2.1")
+
+(defproject puppetlabs.packages/classifier ~classifier-version
   :description "Release artifacts for classifier"
   :pedantic? :abort
-  :dependencies [[puppetlabs/classifier "0.2.1" :exclusions [puppetlabs/trapperkeeper-webserver-jetty9]]
+  :dependencies [[puppetlabs/classifier ~classifier-version :exclusions [puppetlabs/trapperkeeper-webserver-jetty9]]
                  [puppetlabs/trapperkeeper-webserver-jetty9 "0.3.4"]]

   :uberjar-name "classifier-release.jar"


CMR-227: Added tests for collection data psa.

--- test/cmr/system_int_test/search/collection_psa_search_test.clj
+++ test/cmr/system_int_test/search/collection_psa_search_test.clj
@@ -430,3 +430,74 @@
            "time,bravo," nil 24 [coll1 coll2]

            "time,charlie," 44 45 [coll2]))))
+
+(deftest date-psas-search-test
+  (let [psa1 (dc/psa "alpha" :date (d/make-date 10 false))
+        psa2 (dc/psa "bravo" :date (d/make-date 23 false))
+        psa3 (dc/psa "charlie" :date (d/make-date 45 false))
+        coll1 (d/ingest "PROV1" (dc/collection {:product-specific-attributes [psa1 psa2]}))
+        coll2 (d/ingest "PROV1" (dc/collection {:product-specific-attributes [psa2 psa3]}))]
+
+    (index/refresh-elastic-index)
+
+    (testing "search by value"
+      (are [v n items]
+           (d/refs-match?
+             items (search/find-refs :collection {"attribute[]" (str v (d/make-date n))}))
+           "date,bravo," 23 [coll1 coll2]
+           "date,alpha," 11 []
+           "date,alpha," 10 [coll1]
+           "date,charlie," 45 [coll2]))
+
+    (testing "search by value legacy parameters"
+      (are [v n items]
+           (d/refs-match? items
+                          (search/find-refs :collection (search/csv->tuples (str v (d/make-date n)))))
+           "date,bravo," 23 [coll1 coll2]
+           "date,alpha," 11 []
+           "date,alpha," 10 [coll1]
+           "date,charlie," 45 [coll2]))
+
+    (testing "search by range"
+      (are [v min-n max-n items]
+           (let [min-v (d/make-date min-n)
+                 max-v (d/make-date max-n)
+                 full-value (str v min-v "," max-v)]
+             (d/refs-match? items (search/find-refs :collection {"attribute[]" full-value})))
+
+           ;; inside range
+           "date,alpha," 9 11 [coll1]
+           ;; beginning edge of range
+           "date,alpha," 10 11 [coll1]
+           ;; ending edge of range
+           "date,alpha," 9 10 [coll1]
+
+           ;; only min range provided
+           "date,bravo," 20 nil [coll1 coll2]
+
+           ;; only max range provided
+           "date,bravo," nil 24 [coll1 coll2]
+
+           "date,charlie," 44 45 [coll2]))
+
+    (testing "search by range legacy parameters"
+      (are [v min-n max-n items]
+           (let [min-v (d/make-date min-n)
+                 max-v (d/make-date max-n)
+                 full-value (str v min-v "," max-v)]
+             (d/refs-match? items (search/find-refs :collection (search/csv->tuples full-value) {:snake-kebab? false})))
+
+           ;; inside range
+           "date,alpha," 9 11 [coll1]
+           ;; beginning edge of range
+           "date,alpha," 10 11 [coll1]
+           ;; ending edge of range
+           "date,alpha," 9 10 [coll1]
+
+           ;; only min range provided
+           "date,bravo," 20 nil [coll1 coll2]
+
+           ;; only max range provided
+           "date,bravo," nil 24 [coll1 coll2]
+
+           "date,charlie," 44 45 [coll2]))))


implemented bucket distributor

implemented bucket distributor

--- clj/src/bucket_distributor_clj/core.clj
+++ clj/src/bucket_distributor_clj/core.clj
@@ -434,6 +434,26 @@
   (stop-bucket-consumer! (-> @state-atom :bucket-consumer))
   (broadcast! (str "retract:" peer-id)))

+(defprotocol BucketDistributor "A mechanism for coordinated distribution of
+                                hash buckets."
+
+  (acquire-buckets! [this] "Returns the set of buckets currently available to a
+                   distributor instance. This function may return an empty set
+                   if no buckets are yet available. Must not block.")
+
+  (release-buckets! [this buckets] "Releases the current set of buckets back to the
+                           cluster.  This method is a way of indicating that
+                           the client is done with the current set of buckets.
+                           The distributor is responsible for fetching the next
+                           set of buckets. Must not block."))
+
+(extend-protocol BucketDistributor
+  RabbitBucketDistributor
+  (acquire-buckets! [this]
+    (buckets! (-> this :state-atom deref :bucket-consumer)))
+  (release-buckets! [this buckets]
+    (release! (-> this :state-atom deref :bucket-consumer) buckets)))
+
 (comment

   (def distributors (atom []))
@@ -458,15 +478,13 @@

   (do
     (doseq [dist @distributors]
-      (let [consumer (-> @distributors first :state-atom deref :bucket-consumer)
-            buckets (buckets! consumer)]
-        (release! consumer buckets)))
+      (let [buckets (acquire-buckets! dist)]
+        (release-buckets! dist buckets)))

     (Thread/sleep 1000)

     (doseq [dist @distributors]
-      (let [consumer (-> dist :state-atom deref :bucket-consumer)
-            buckets (buckets! consumer)]
+      (let [buckets (acquire-buckets! dist)]
         (prn buckets))))

   (count @distributors)
@@ -475,16 +493,5 @@
   (buckets! consumer)
   (release! consumer (buckets! consumer))
   )
-
-(defprotocol BucketDistributor "A mechanism for coordinated distribution of
-                                hash buckets."
-
-  (acquire-buckets! [this] "Returns the set of buckets currently available to a
-                   distributor instance. This function may return an empty set
-                   if no buckets are yet available. Must not block.")
-
-  (release-buckets! [this buckets] "Releases the current set of buckets back to the
-                           cluster.  This method is a way of indicating that
-                           the client is done with the current set of buckets.
-                           The distributor is responsible for fetching the next
-                           set of buckets. Must not block."))
+
+


add authorization to liberator resource

add authorization to liberator resource

--- src/gangway/web.clj
+++ src/gangway/web.clj
@@ -8,11 +8,15 @@
             [liberator.core :refer [defresource]]
             [liberator.dev :refer [wrap-trace]]
             [gangway.publish :as gw-publish]
-            [gangway.validation :as gw-validation]))
+            [gangway.validation :as gw-validation]
+            [gangway.auth :as auth]))

 (defresource incoming!
   :allowed-methods [:post]
   :available-media-types ["text/plain"]
+  :authorized? (fn [ctx]
+                 (auth/validate-token ctx))
+  :handle-unauthorized "You are not authorized to access this resource."
   :malformed? (fn  [ctx]
                 (let [message (slurp (get-in ctx [:request :body]))]
                   (not (gw-validation/valid-batch? message))))


Whitesapce.

Whitesapce.

--- modules/bootstrap/src/main/clojure/immutant/runtime/bootstrap.clj
+++ modules/bootstrap/src/main/clojure/immutant/runtime/bootstrap.clj
@@ -68,17 +68,17 @@

 (defn ^{:internal true} read-full-app-config
   "Returns the full configuration for an app. This consists of
-the :immutant map from project.clj (if any) with the contents of the
-internal descriptor map merged onto it (if any) followed by the
-descriptor map (if any). Returns {} if none are available."
-[descriptor-file app-root]
-(let [external (read-descriptor descriptor-file)
-      internal (read-descriptor (io/file app-root ".immutant.clj"))
-      profiles (:lein-profiles external (:lein-profiles internal))]
-    (merge {}
-           (:immutant (read-project app-root profiles))
-           internal
-           external)))
+   the :immutant map from project.clj (if any) with the contents of
+   the internal descriptor map merged onto it (if any) followed by the
+   descriptor map (if any). Returns {} if none are available."
+   [descriptor-file app-root]
+   (let [external (read-descriptor descriptor-file)
+         internal (read-descriptor (io/file app-root ".immutant.clj"))
+         profiles (:lein-profiles external (:lein-profiles internal))]
+     (merge {}
+            (:immutant (read-project app-root profiles))
+            internal
+            external)))

 (defn ^{:internal true} read-and-stringify-full-app-config
   "Loads the full app config and stringifies the keys."


fixed bug that required a new image to be uploaded while editing

--- cljs/src/views/editor.cljs
+++ cljs/src/views/editor.cljs
@@ -258,7 +258,12 @@
                                            :attachment
                                            image-data))))))
         (. reader (readAsBinaryString file)))
-      (ui/display-error (dom/getElement "status-message") file-required-err))))
+      (if-not create?
+        ; update without changing image
+        (document/update-doc (.value (dom/getElement "slug"))
+                             save-existing-document-xhr-callback
+                             (get-document-value-map! feed-name))
+        (ui/display-error (dom/getElement "status-message") file-required-err)))))

 (defn handle-image-drop-callback [feed status e]
   (do


Removing unused imports

Removing unused imports

--- clojure/dbmgmt/project.clj
+++ clojure/dbmgmt/project.clj
@@ -6,12 +6,11 @@
     :url ""
   }
   :dependencies [
-    [org.clojure/clojure                  "1.8.0"           ]
-    [org.postgresql/postgresql            "9.4.1212"        ]
-    [org.clojure/data.json                "0.2.6"           ]
-    [uswitch/lambada                      "0.1.2"           ]
-    [com.amazonaws/aws-lambda-java-core   "1.1.0"           ]
-    [com.amazonaws/aws-lambda-java-log4j  "1.0.0"           ]
+    [org.clojure/clojure                  "1.8.0"     ]
+    [org.postgresql/postgresql            "9.4.1212"  ]
+    [org.clojure/data.json                "0.2.6"     ]
+    [com.amazonaws/aws-lambda-java-core   "1.1.0"     ]
+    [com.amazonaws/aws-lambda-java-log4j  "1.0.0"     ]
   ]
   :jvm-opts [
     "-Xms32m" "-Xmx32m"


Tweak normalise to take infinite seqs.

Tweak normalise to take infinite seqs.

TODO fix this so that it doesn't assume contiguous blocks of
id/measure columns.  It needs to calculate the set complement of
the selected measure column ids and use those.

--- src/grafter/csv.clj
+++ src/grafter/csv.clj
@@ -133,7 +133,6 @@
 ;; with mapc
 (def _ identity)

-
 (defn select-columns
   ([srange row]
      (drop srange row))
@@ -144,7 +143,12 @@
             (drop srange)
             (take ncols)))))

-(defn normalise [[header-row & data-rows] [srange erange]]
+
+;; TODO fix this so that it doesn't assume contiguous blocks of
+;; id/measure columns.  It needs to calculate the set complement of
+;; the selected measure column ids and use those.
+
+(defn normalise [[header-row & data-rows] measure-col-ids]
   "Takes a CSV with a header row and normalises it by transforming the
 selected columns into values within the rows.

@@ -168,8 +172,12 @@
 | 1 | 1 | 1 | normalise-me-a | normal-1-a |
 | 1 | 1 | 1 | normalise-me-b | normal-1-b |
 "
-  (let [colids           (range srange (inc erange))
-        ncols            (inc (- erange srange))
+  (let [ncols            (count header-row)
+        colids           (-> (take ncols measure-col-ids) set sort) ;; incase its an infinite seq
+        srange           (first colids)
+        colids           (take (- ncols srange) colids)
+        erange           (last colids)
+        ncols            (count colids)
         headers-to-move  (select-columns srange erange header-row)

         normalise-row (fn [id row]


Better

Better

--- src/icecap/rest.clj
+++ src/icecap/rest.clj
@@ -30,13 +30,13 @@
                             (cap-url request cap)
                             (str error))}))
            (context "/:encoded-cap" [encoded-cap]
-                    (GET "/" []
+                    (GET "/" request
                          (let [cap (spy (safebase64-decode encoded-cap))]
                            (spy (<!! (execute-cap cap
                                                   :store store
                                                   :kdf kdf
                                                   :scheme scheme)))))
-                    (DELETE "/" []
+                    (DELETE "/" request
                             (let [cap (spy (safebase64-decode encoded-cap))]
                               (spy (<!! (revoke-cap cap
                                                     :store store


More experiements with API

More experiements with API

--- src/re_frame/core.cljc
+++ src/re_frame/core.cljc
@@ -575,22 +575,30 @@
   std-interceptors/after)

 (def on-changes
-  "Interceptor factory which acts a bit like `reaction`  (but it flows into
-  `db`, rather than out). It observes N paths within `db` and if any of them
-  test not identical? to their previous value  (as a result of a event handler
-  being run) then it runs `f` to compute a new value, which is then assoc-ed
-  into the given `out-path` within `db`.
-
-  Usage:
-
+  "An interceptor factory, which is to say, a function which will return an interceptor.
+
+   The returned interceptor will observe N paths within `db`, and if any of them
+   test not identical? to their previous value  (as a result of a event handler
+   being run), then it runs `f` to compute a new value, which is then assoc-ed
+   into the given `out-path` within `db`.
+
+   Example Usage:
+
+   ```clj
       (defn my-f
         [a-val b-val]
         ... some computation on a and b in here)

-      (on-changes my-f [:c]  [:a] [:b])
-
-  Put this Interceptor on the right handlers (ones which might change :a or :b).
-  It will:
+      (reg-event-db
+        :event-id
+        [(on-changes my-f [:c]  [:a] [:b]) ... other interceptors]  <-- used here
+        (fn [db v]
+           ...))
+    ```
+
+    Put this Interceptor on the right handlers (ones which might change :a or :b)
+    and it will:
+
      - call `f` each time the value at path [:a] or [:b] changes
      - call `f` with the values extracted from [:a] [:b]
      - assoc the return value from `f` into the path  [:c]
@@ -604,35 +612,29 @@

    When you register an event handler you have the option of supplying an
    interceptor chain. Any global interceptors you register are effectively
-   prepending to this chain in the order that they are registered."
+   prepending to this chain.
+
+   Global interceptors are run in the order that they are registered."
   [interceptor]
   (settings/reg-global-interceptor interceptor))

 (defn clear-global-interceptor ;; think unreg-global-interceptor
-  "When called with no args, unregisters all global interceptors. When given
-   one arg, assumed to be the `id` of a currently registered global
+  "Unregisters (removes) global interceptors.
+
+   When called with no arguments, it unregisters all global interceptors. When given
+   one argument, assumed to be the `id` of a currently registered global
    interceptor, it unregisters the associated interceptor."
   ([]
    (settings/clear-global-interceptors))
   ([id]
    (settings/clear-global-interceptors id)))

-;; Utility functions for creating your own interceptors
-;;
-;;  (def my-interceptor
-;;     (->interceptor                ;; used to create an interceptor
-;;       :id     :my-interceptor     ;; an id - decorative only
-;;       :before (fn [context]                         ;; you normally want to change :coeffects
-;;                  ... use get-coeffect  and assoc-coeffect
-;;                       )
-;;       :after  (fn [context]                         ;; you normally want to change :effects
-;;                 (let [db (get-effect context :db)]  ;; (get-in context [:effects :db])
-;;                   (assoc-effect context :http-ajax {...}])))))
-;;
+
 (defn ->interceptor
   "A utility function for creating interceptors.

    Accepts three optional, named arguments:
+
      - `:id` - an id for the interceptor (decorative only)
      - `:before` - the before function
      - `:after`  - the after function
@@ -654,9 +656,12 @@
   (utils/apply-kw interceptor/->interceptor m))

 (defn get-coeffect
-  "When called with one arg, returns the coeffects map from the `context`.
-   When called with two or three args, behaves like `clojure.core/get`,
-   returns the value mapped to `key` in the coeffects map, `not-found` or
+  "A utility function, used when writing interceptors, typically within a `:before` function.
+
+   When called with one argument, it returns the `:coeffects` map from with that `context`.
+
+   When called with two or three arguments, behaves like `clojure.core/get` and
+   returns the value mapped to `key` in the `:coeffects` map within `context`, `not-found` or
    `nil` if `key` is not present."
   ([context]
    (interceptor/get-coeffect context))
@@ -666,14 +671,18 @@
    (interceptor/get-coeffect context key not-found)))

 (defn assoc-coeffect
-  "Returns a new `context` with a new coeffects map that contains `key`
-   mapped to the `value`."
+  "A utility function, used when writing interceptors, typically within a `:before` function.
+
+   Adds or updates a key/value pair in the `:coeffects` map within `context`. "
   [context key value]
   (interceptor/assoc-coeffect context key value))

 (defn get-effect
-  "When called with one arg, returns the effects map from the `context`.
-   When called with two or three args, behaves like `clojure.core/get`,
+  "A utility function, used when writing interceptors, typically within an `:after` function.
+
+   When called with one argument, returns the `:effects` map from the `context`.
+
+   When called with two or three arguments, behaves like `clojure.core/get` and
    returns the value mapped to `key` in the effects map, `not-found` or
    `nil` if `key` is not present."
   ([context]
@@ -684,53 +693,68 @@
    (interceptor/get-effect context key not-found)))

 (defn assoc-effect
-  "Returns a new `context` with a new effects map that contains `key`
-   mapped to the `value`."
+   "A utility function, used when writing interceptors, typically within an `:after` function.
+
+   Adds or updates a key/value pair in the `:effects` map within `context`. "
   [context key value]
   (interceptor/assoc-effect context key value))

 (defn enqueue
-  "Add a collection of `interceptors` to the end of `context's` execution `:queue`.
-  Returns the updated `context`.
-
-  In an advanced case, this function could allow an interceptor to add new
-  interceptors to the `:queue` of a context."
+  "An advanced utility function, used when writing interceptors, typically within a `:before` function.
+
+  Adds a collection of `interceptors` to the end of `context's` execution `:queue`, and then
+  returns the updated `context`."
   [context interceptors]
   (interceptor/enqueue context interceptors))

 ;; --  logging ----------------------------------------------------------------
-;; Internally, re-frame uses the logging functions: warn, log, error, group and groupEnd
-;; By default, these functions map directly to the js/console implementations,
-;; but you can override with your own fns (set or subset).
-;; Example Usage:
-;;   (defn my-fn [& args]  (post-it-somewhere (apply str args)))  ;; here is my alternative
-;;   (re-frame.core/set-loggers!  {:warn my-fn :log my-fn})       ;; override the defaults with mine
+
 (defn set-loggers!
-  "Change the set (or a subset) of logging functions used by re-frame.
-  `new-loggers` should be a map with the same keys as `loggers` (above)"
+  "Internally, re-frame uses the logging functions: `warn`, `log`, `error`, `group` and `groupEnd`
+
+   By default, these functions map directly to the default `js/console` implementations,
+   but you can override with your own fns (set or subset).
+
+   `new-loggers` should be a map with the same keys as `loggers`
+
+   Example Usage:
+   ```clj
+     (defn my-fn [& args]  (post-it-somewhere (apply str args)))  ;; here is my alternative
+     (re-frame.core/set-loggers!  {:warn my-fn :log my-fn})       ;; override the defaults with mine
+   ```
+   "
   [new-loggers]
   (loggers/set-loggers! new-loggers))

+
 (defn console
-  "Logs `args` to the console at `level`.
-   Level can be one of `:log` `:error` `:warn` `:debug` `:group` `:groupEnd`.
-   If you are writing an extension to re-frame, like prehaps an effect handler,
-   you may want to use re-frame logging so that users can configure logging
-   from a central location.
-
-   usage: (console :error \"Oh, dear God, it happened:\" a-var \"and\" another)
-          (console :warn \"Possible breach of containment wall at:\" dt)"
+  "A utility function designed to be used by libraries which are extending re-frame, like
+   perhaps an effect handler, which want to produce output via re-frame's loggers.
+
+   It will write `args` to the js/console at `level`.
+
+   `level` can be one of `:log` `:error` `:warn` `:debug` `:group` `:groupEnd`.
+
+   Example usage:
+
+   ```clj
+     (console :error \"Oh, dear God, it happened:\" a-var \"and\" another)
+     (console :warn \"Possible breach of containment wall at:\" dt)
+   ```
+   "
   [level & args]
   (apply loggers/console (into [level] args)))

 ;; -- unit testing ------------------------------------------------------------

 (defn make-restore-fn
-  "Checkpoints the state of re-frame and returns a function which, when
-  later called, will restore re-frame to that checkpointed state.
-
-  Checkpoint includes app-db, all registered handlers and all subscriptions.
+  "A utility function, typically used in testing.
+
+   Checkpoints the state of re-frame and returns a function which, when
+   later called, will restore re-frame to that checkpointed state.
+
+   Checkpoint includes app-db, all registered handlers and all subscriptions.
   "
   []
   (let [handlers @registrar/kind->id->handler


make session middleware consistent with other middleware

*request and *response fns operate on request and response directly

--- ring-core/src/ring/middleware/session.clj
+++ ring-core/src/ring/middleware/session.clj
@@ -13,34 +13,31 @@
                         (if-let [root (options :root)]
                           {:path root}))})

-(defn session-request-fn
-  "Given options, returns a function to process a session request."
-  [{:keys [store cookie-name]}]
-  (fn [request]
-    (let [req-key  (get-in request [:cookies cookie-name :value])
-          session  (store/read-session store req-key)
-          session-key (if session req-key)]
-      (merge request {:session (or session {})
-                      :session/key session-key}))))
+(defn session-request
+  "Reads current HTTP session map and adds it to :session key of the request."
+  [request & [{:keys [store cookie-name]}]]
+  (let [req-key  (get-in request [:cookies cookie-name :value])
+        session  (store/read-session store req-key)
+        session-key (if session req-key)]
+    (merge request {:session (or session {})
+                    :session/key session-key})))

-(defn session-response-fn
-  "Given options, returns a function to process a session response."
-  [{:keys [store cookie-name cookie-attrs]}]
-  (fn [{session-key :session/key :as response}]
-    (when (seq (dissoc response :session/key))
-      (let [new-session-key (when (contains? response :session)
-                              (if-let [session (response :session)]
-                                (store/write-session store session-key session)
-                                (when session-key
-                                  (store/delete-session store session-key))))
-            response (dissoc response :session)
-            cookie   {cookie-name
-                      (merge cookie-attrs
-                             (response :session-cookie-attrs)
-                             {:value new-session-key})}]
-        (if (and new-session-key (not= session-key new-session-key))
-          (assoc response :cookies (merge (response :cookies) cookie))
-          response)))))
+(defn session-response
+  "Updates session based on :session key in response."
+  [{session-key :session/key :as response} & [{:keys [store cookie-name cookie-attrs]}]]
+  (let [new-session-key (when (contains? response :session)
+                          (if-let [session (response :session)]
+                            (store/write-session store session-key session)
+                            (when session-key
+                              (store/delete-session store session-key))))
+        response (dissoc response :session)
+        cookie   {cookie-name
+                  (merge cookie-attrs
+                         (response :session-cookie-attrs)
+                         {:value new-session-key})}]
+    (if (and new-session-key (not= session-key new-session-key))
+      (assoc response :cookies (merge (response :cookies) cookie))
+      response)))

 (defn wrap-session
   "Reads in the current HTTP session map, and adds it to the :session key on
@@ -67,14 +64,13 @@
   ([handler]
      (wrap-session handler {}))
   ([handler options]
-     (let [options (session-options options)
-           session-request (session-request-fn options)
-           session-response (session-response-fn options)]
+     (let [options (session-options options)]
        (cookies/wrap-cookies
         (fn [request]
-          (let [new-request (session-request request)
-                session-key (:session/key new-request)]
-            (-> new-request
-                handler
-                (assoc :session/key session-key)
-                session-response)))))))
+          (let [new-request (session-request request options)
+                session-key (:session/key new-request)
+                response (-> new-request
+                             handler
+                             (assoc :session/key session-key))]
+            (when (seq (dissoc response :session/key))
+              (session-response response options))))))))


Shrink gauge to make room for animated indicators.

--- src/afterglow/controllers/ableton_push_2.clj
+++ src/afterglow/controllers/ableton_push_2.clj
@@ -625,10 +625,10 @@
         range (- highest lowest)
         fraction (/ (- value lowest)  range)
         x-center (+ (* index button-cell-width) (* encoder-count 0.5 button-cell-width))
-        arc (java.awt.geom.Arc2D$Double. (- x-center 25.0) 50.0 50.0 50.0 240.0 -300.0 java.awt.geom.Arc2D/OPEN)]
+        arc (java.awt.geom.Arc2D$Double. (- x-center 20.0) 50.0 40.0 40.0 240.0 -300.0 java.awt.geom.Arc2D/OPEN)]
     (set-graphics-color graphics track-color)
     (.draw graphics arc)
-    (.setStroke graphics (java.awt.BasicStroke. 5.0 java.awt.BasicStroke/CAP_ROUND java.awt.BasicStroke/JOIN_ROUND))
+    (.setStroke graphics (java.awt.BasicStroke. 4.0 java.awt.BasicStroke/CAP_ROUND java.awt.BasicStroke/JOIN_ROUND))
     (set-graphics-color graphics active-color)
     (.setAngleExtent arc (* -300.0 fraction))
     (.draw graphics arc)))


Simplify exceptions displayed

Simplify exceptions displayed

--- ClojureScript/replete/src/replete/core.cljs
+++ ClojureScript/replete/src/replete/core.cljs
@@ -9,7 +9,8 @@
             [cljs.compiler :as c]
             [cljs.env :as env]
             [cljs.reader :as edn]
-            [cognitect.transit :as t]))
+            [cognitect.transit :as t]
+            [clojure.string :as s]))

 (def DEBUG false)

@@ -57,12 +58,14 @@
                      (ensure
                        (c/emit ast)))
                 _ (when DEBUG (prn "js:" js))]
-            (prn (let [ret (js/eval js)]
-                   (when-not ('#{*1 *2 *3 *e} form)
-                     (set! *3 *2)
-                     (set! *2 *1)
-                     (set! *1 ret))
-                   ret)))
+            (try (prn (let [ret (js/eval js)]
+                        (when-not ('#{*1 *2 *3 *e} form)
+                          (set! *3 *2)
+                          (set! *2 *1)
+                          (set! *1 ret))
+                        ret))
+                 (catch js/Error e
+                   (set! *e e)
+                   (print (.-message e) "\n" (first (s/split (.-stack e) #"eval code"))))))
           (catch js/Error e
-            (set! *e e)
-            (println (str (.-message e) "\n" (.-stack e)))))))))
+            (println (.-message e))))))))


Add storm.home to logback/cluster.xml so workers can find it.

--- src/clj/backtype/storm/daemon/supervisor.clj
+++ src/clj/backtype/storm/daemon/supervisor.clj
@@ -409,6 +409,7 @@
 (defmethod launch-worker
     :distributed [supervisor storm-id port worker-id]
     (let [conf (:conf supervisor)
+          storm-home (System/getProperty "storm.home")
           stormroot (supervisor-stormdist-root conf storm-id)
           stormjar (supervisor-stormjar-path stormroot)
           storm-conf (read-supervisor-storm-conf conf storm-id)
@@ -420,8 +421,8 @@
           command (str "java -server " childopts
                        " -Djava.library.path=" (conf JAVA-LIBRARY-PATH)
                        " -Dlogfile.name=" logfilename
-                       " -Dstorm.home=" (System/getProperty "storm.home")
-                       " -Dlogback.configurationFile=logback/cluster.xml"
+                       " -Dstorm.home=" storm-home
+                       " -Dlogback.configurationFile=" storm-home "/logback/cluster.xml"
                        " -cp " classpath " backtype.storm.daemon.worker "
                        (java.net.URLEncoder/encode storm-id) " " (:assignment-id supervisor)
                        " " port " " worker-id)]


correct typo

correct typo

--- src/clj_money/models/storage/sql_storage.clj
+++ src/clj_money/models/storage/sql_storage.clj
@@ -66,7 +66,7 @@
   [model & keys]
   (-> model
       (select-keys keys)
-      (assoc :update-at (t/now))
+      (assoc :updated-at (t/now))
       ->sql-keys))

 (deftype SqlStorage [db-spec]


Fixes to reload-from-server

Fixes to reload-from-server

--- src/clojure/org/bytopia/foreclojure/main.clj
+++ src/clojure/org/bytopia/foreclojure/main.clj
@@ -44,12 +44,12 @@

 (defn reload-from-server [a]
   (long-running-job
-   (when (api/network-connected?)
+   (if (api/network-connected?)
      (let [user (:user (like-map (.getIntent a)))]
        ;; Try relogin
        (when (not (api/logged-in?))
          (user/login-via-saved user true))
-       (when (api/logged-in?)
+       (if (api/logged-in?)
          (let [last-id (db/initialize a)
                {:keys [solved-ids new-ids]} (api/fetch-solved-problem-ids last-id)
                locally-solved (db/get-solved-ids-for-user user)
@@ -69,14 +69,14 @@
                (on-ui (toast (str "(???) Server rejected our solution to problem " problem-id)))))
            ;; Download new problems and insert them into database
            (doseq [problem-id new-ids]
-             (when-let [json (assoc (api/fetch-problem problem-id)
-                               "id" problem-id)]
-               (db/insert-problem json)))
+             (when-let [json (api/fetch-problem problem-id)]
+               (db/insert-problem (assoc json "id" problem-id))))
            (when (pos? (+ (count new-ids) (count to-download) (count to-upload)))
              (on-ui (toast (format "Downloaded %d new problem(s).\nDiscovered %d server solution(s).\nUploaded %d local solution(s)."
                                    (count new-ids) (count to-download) (count to-upload))))))
          (on-ui (toast "Can't login to 4clojure.com. Working in offline mode."))))
-     (on-ui (refresh-ui a)))))
+     (on-ui (toast "Network is not available.")))
+   (on-ui (refresh-ui a))))

 ;; (reload-from-server (*a))


Improve env-gen docstring

Improve env-gen docstring

--- src/overtone/sc/machinery/ugen/metadata/envgen.clj
+++ src/overtone/sc/machinery/ugen/metadata/envgen.clj
@@ -78,11 +78,15 @@
               {:name "gate",
                :default 1.0
                :doc "this triggers the envelope and holds it open while
-               > 0. If the Env is fixed-length (e.g. perc), the gate
-               argument is used as a simple trigger. If it is an
+               > 0. If the envelope is fixed-length (e.g. perc), the
+               gate argument is used as a simple trigger. If it is an
                sustaining envelope (e.g. adsr, asr), the envelope is
                held open until the gate becomes 0, at which point is
-               released." }
+               released. If the gate of an env-gen is set to -1 or
+               below, then the envelope will cutoff immediately. The
+               time for it to cutoff is the amount less than -1, with -1
+               being as fast as possible, -1.5 being a cutoff in 0.5
+               seconds, etc. The cutoff shape is linear." }

               {:name "level-scale",
                :default 1.0


Changed finding references by post to find them by XML.

--- src/cmr/system_int_test/utils/search_util.clj
+++ src/cmr/system_int_test/utils/search_util.clj
@@ -165,39 +165,41 @@
          (json/decode true)
          (set/rename-keys {:references :refs})))))

+(defn- parse-reference-response
+  [response]
+  (let [parsed (-> response :body x/parse-str)
+        hits (cx/long-at-path parsed [:hits])
+        took (cx/long-at-path parsed [:took])
+        refs (map (fn [ref-elem]
+                    {:id (cx/string-at-path ref-elem [:id])
+                     :name (cx/string-at-path ref-elem [:name])
+                     :revision-id (cx/long-at-path ref-elem [:revision-id])
+                     :location (cx/string-at-path ref-elem [:location])})
+                  (cx/elements-at-path parsed [:references :reference]))]
+    {:refs refs
+     :hits hits
+     :took took}))
+
 (defn find-refs
   "Returns the references that are found by searching with the input params"
   ([concept-type params]
    (find-refs concept-type params {}))
   ([concept-type params options]
    (get-search-failure-data
-     (let [response (find-concepts-in-format "application/xml" concept-type params options)
-           parsed (-> response :body x/parse-str)
-           hits (cx/long-at-path parsed [:hits])
-           took (cx/long-at-path parsed [:took])
-           refs (map (fn [ref-elem]
-                       {:id (cx/string-at-path ref-elem [:id])
-                        :name (cx/string-at-path ref-elem [:name])
-                        :revision-id (cx/long-at-path ref-elem [:revision-id])
-                        :location (cx/string-at-path ref-elem [:location])})
-                     (cx/elements-at-path parsed [:references :reference]))]
-       {:refs refs
-        :hits hits
-        :took took}))))
+     (parse-reference-response
+       (find-concepts-in-format "application/xml" concept-type params options)))))

 (defn find-refs-with-post
   "Returns the references that are found by searching through POST request with the input params"
   [concept-type params]
   (get-search-failure-data
     (let [response (client/post (url/search-url concept-type)
-                                {:accept :json
+                                {:accept "application/xml"
                                  :content-type "application/x-www-form-urlencoded"
                                  :body (codec/form-encode params)
                                  :throw-exceptions false
                                  :connection-manager (url/conn-mgr)})]
-      (is (= 200 (:status response)))
-      (set/rename-keys (json/decode (:body response) true)
-                       {:references :refs}))))
+      (parse-reference-response response))))

 (defn get-concept-by-concept-id
   "Returns the concept metadata by searching metadata-db using the given cmr concept id"


Unbreak tests.

Unbreak tests.

--- test/active/clojure/match_test.clj
+++ test/active/clojure/match_test.clj
@@ -2,9 +2,7 @@
   (:require [active.clojure.match :as p]
             [active.clojure.functions :as f]
             [clojure.core.match.regex]
-            [clojure.test :as t]
-
-            [active.clojure.old-match :as old-match]))
+            [clojure.test :as t]))

 (t/deftest parse-clause-test
   (t/testing "key exists clause"


Got the tests running

Got the tests running

--- test/dragonmark/web/core_test.cljs
+++ test/dragonmark/web/core_test.cljs
@@ -32,7 +32,7 @@
 (deftest
   replacement-hiccup2
   "replace the element with a hiccup template"
-  (let [r (xform html ["span" [:div {:onclick (fn [x] (+ x 1))} "moo"]])
+  (let [r (xform html ["span" [:div {:on-click (fn [x] (+ x 1))} "moo"]])
         func? (-> r second second :on-click)]
     (t/is (= 2 (func? 1)))))


Removed inline comments

Removed inline comments

--- test/forma/trends/stretch_test.clj
+++ test/forma/trends/stretch_test.clj
@@ -50,9 +50,9 @@
      expanded-ts => expected-ts))
  ?extra-32 ?extra-16
  0          0
- 1          1 ;; outputs through first half of January
- 2          3 ;; outputs through mid-January
- 3          5 ;; outputs through
+ 1          1
+ 2          3
+ 3          5
  12         23)


Sharps and flats.

Sharps and flats.

--- src/leipzig_live/music.cljs
+++ src/leipzig_live/music.cljs
@@ -28,6 +28,9 @@
 (def F (from 77))
 (def G (from 79))

+(def sharp inc)
+(def flat dec)
+
 (defn bpm [beats] (fn [beat] (/ (* beat 60) beats)))

 (defn equal-temperament [midi]


fixed user-name

fixed user-name

--- src/dda/pallet/crate/dda_user_crate/user.clj
+++ src/dda/pallet/crate/dda_user_crate/user.clj
@@ -58,7 +58,7 @@
         (str ssh-dir "id_rsa")
         :overwrite-changes true
         :owner user-name
-        :group username
+        :group user-name
         :mode "600"
         :content (:private-key ssh-key))
       (actions/remote-file


Remove debug output.

Remove debug output.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -79,8 +79,6 @@
                     (interrupt pe))
                   (.interrupt out-proc-loop))
      :in-fn (fn [in]
-              (println in)
-              (println in-queue)
               (.put in-queue (LocalTransferContainer. in nil)))}))

 (defn get-in-fn


test fix ?

test fix ?

--- test/metabase/api/meta/db_test.clj
+++ test/metabase/api/meta/db_test.clj
@@ -141,10 +141,9 @@
     (do
       ;; Delete all the randomly created Databases we've made so far
       (cascade-delete Database :id [not-in (set (filter identity
-                                                        [(datasets/when-testing-dataset :h2
-                                                           (db-id))
-                                                         (datasets/when-testing-dataset :mongo
-                                                           @mongo-test-data/mongo-test-db-id)]))])
+                                                        (for [dataset (datasets/all-valid-dataset-names)]
+                                                          (datasets/when-testing-dataset dataset
+                                                            (db-id)))))])
       ;; Add an extra DB so we have something to fetch besides the Test DB
       (create-db db-name)
       ;; Now hit the endpoint


fix sanitized paths

fix sanitized paths

--- src/leiningen/new/clanhr_service/project.clj
+++ src/leiningen/new/clanhr_service/project.clj
@@ -11,6 +11,7 @@
                  [com.novemberain/validateur "2.4.2"]
                  [compojure "1.4.0"]
                  [ragtime "0.5.1"]
+                 [aleph "0.4.0"]
                  [postgresql "9.3-1102.jdbc41"]
                  [clanhr/result "0.9.2"]
                  [clanhr/reply "0.5.0"]
@@ -25,15 +26,15 @@
             [lein-environ "1.0.0"]
             [lein-ancient "0.6.8-SNAPSHOT"]]

-  :aliases {"migrate"  ["run" "-m" "clanhr.{{name}}.config.database/migrate"]
-                        "rollback" ["run" "-m" "clanhr.{{name}}.config.database/rollback"]}
+  :aliases {"migrate"  ["run" "-m" "clanhr.{{sanitized}}.config.database/migrate"]
+                        "rollback" ["run" "-m" "clanhr.{{sanitized}}.config.database/rollback"]}

   :source-paths ["src"]
   :test-paths ["test"]

-  :main clanhr.{{name}}.controllers.routes
-  :ring {:handler clanhr.{{name}}.controllers.routes/app}
-  :uberjar-name "clanhr.{{name}}.jar"
+  :main clanhr.{{sanitized}}.controllers.routes
+  :ring {:handler clanhr.{{sanitized}}.controllers.routes/app}
+  :uberjar-name "clanhr.{{sanitized}}.jar"

   :profiles {:uberjar {:aot :all
                        :env {:gateway-provider :postgres}}


CMR-1980: Change order of fields within maps to be more human readable

--- search-app/src/cmr/search/api/keyword.clj
+++ search-app/src/cmr/search/api/keyword.clj
@@ -205,19 +205,22 @@
                                                                 field value)
                   uuid (get values-to-uuids value)
                   value-map (util/remove-nil-keys
-                              {:value value
-                               :uuid uuid})
+                              {:uuid uuid
+                               :value value})
                   subfield-maps (util/remove-nil-keys
                                   (into {}
+                                        (reverse
                                         (for [subfield-name all-subfield-names
                                               :let [subfields
                                                     (parse-hierarchical-keywords
                                                       (get-hierarchy-from-field keyword-hierarchy subfield-name)
                                                       (filter #(= value (field %)) keywords))]]
-                                          [subfield-name (seq subfields)])))]]
+                                          [subfield-name (seq subfields)]))))]]
         ; (reduce #(assoc value-map (:subfield-name %) (:subfields %))
         (util/remove-nil-keys
-          (merge value-map subfield-maps {:subfields (seq (map name (keys subfield-maps)))}))))))
+          (merge subfield-maps
+                 {:subfields (seq (map name (keys subfield-maps)))}
+                 value-map))))))

         ; (if (seq subfields)
         ;   (assoc value-map


fix with beautiful code

fix with beautiful code

--- src/mermaid_ldjam/core.cljs
+++ src/mermaid_ldjam/core.cljs
@@ -23,10 +23,11 @@
     (assoc-in state [:entities hidden-entity] new-entity)))

 (def actions-map
-  {[:look :window] {:text "You look outside the window and see your home, the mighty ocean." :action ""}
-   [:look :bucket] {:text "You see a bucket. Maybe there is something inside." :action ""}
+  {[:look :window] {:text "You look outside the window and see your home, the mighty ocean." :action []}
+   [:look :bucket] {:text "You see a bucket. Maybe there is something inside." :action []}
    [:flap :window] {:text "You're too far away for that"}
-   [:flap :bucket] {:text "You flap against the bucket. BÄM. The bucket falls over and stones spill on the floor." :action [unhide :stone]}})
+   [:flap :bucket] {:text "You flap against the bucket. BÄM. The bucket falls over and stones spill on the floor." :action [unhide :stone]}
+   [:look :stone] {:text "There are stones on the floor. You can easily reach them" :action []}})

 (defn point-in-rect? [entity mx my]
   (and
@@ -65,7 +66,9 @@
     (if (and (= (count last-clicked) 2) todo)
       (let [new-state
             (assoc state :current-status (:text todo))]
-        ((first (:action todo)) new-state (last (:action todo))))
+        (if (> (count (:action todo)) 0)
+          ((first (:action todo)) new-state (last (:action todo)))
+          new-state))
       state)))

 (defn update-state [state]


util/zip.clj: added gzip-utf8-string

util/zip.clj: added gzip-utf8-string

--- src/org/altlaw/util/zip.clj
+++ src/org/altlaw/util/zip.clj
@@ -1,7 +1,9 @@
 (ns org.altlaw.util.zip
-  (:import (java.io File FileOutputStream FileInputStream)
-           (java.util.zip GZIPInputStream ZipOutputStream
-                          ZipEntry ZipInputStream)
+  (:import (java.io File FileOutputStream FileInputStream
+                    InputStream OutputStream
+                    ByteArrayInputStream ByteArrayOutputStream)
+           (java.util.zip GZIPInputStream GZIPOutputStream
+                          ZipInputStream ZipOutputStream ZipEntry)
            (org.apache.commons.io FileUtils IOUtils)))

 (defn write-zip-file
@@ -43,3 +45,13 @@
           (.closeEntry in)
           (recur (.getNextEntry in)))))))

+(defn gzip-utf8-string
+  "Converts a string to gzipped UTF-8 text, returns a byte array."
+  [s]
+  (let [input (ByteArrayInputStream. (.getBytes s "UTF-8"))
+        output (ByteArrayOutputStream.)
+        gzip-output (GZIPOutputStream. output)]
+    (IOUtils/copy input gzip-output)
+    (.close gzip-output)
+    (.toByteArray output)))
+


more (overc) diagnostics

more (overc) diagnostics

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -142,6 +142,21 @@

    {:parent [:comp :synsem :subcat]
     :childc [:synsem :subcat]}])
+
+(defn comp-pre-checks2 [parent child]
+  (some #(= :fail %)
+        (map (fn [pair]
+               (let [result
+                     (unifyc (get-in parent (:parent pair))
+                             (get-in child (:childc pair)))]
+                 (if (fail? result)
+                   (do
+                     (log/debug (str "comp precheck failed  for pair: " pair))
+                     :fail)
+                   (do
+                     (log/debug (str "comp precheck success for pair: " pair))
+                     :top))))
+             comp-precheck-pairs)))

 (defn comp-pre-checks [parent child]
   (or
@@ -238,7 +253,9 @@
   (log/debug (str "moreover-comp: child cat: " (get-in child [:synsem :cat])))
   (log/debug (str "moreover-comp: parent comp cat: " (get-in parent [:comp :synsem :cat])))

-  (let [pre-check (comp-pre-checks parent child)
+  (let [pre-check2 (comp-pre-checks2 parent child)
+        pre-check (comp-pre-checks parent child)
+
         result
         (if pre-check
           (do


the lwjgl update in penumbra broke shift-key UI controls, temporarily use 'z' instead of lshift

--- src/brevis/core.clj
+++ src/brevis/core.clj
@@ -31,7 +31,7 @@
   [state]
   (app/title! "brevis")
   (app/vsync! true)
-  ;(app/key-repeat! true)
+  ;(app/key-repeat! false)
   (enable :blend)
   (enable :depth-test)
   ;(clear-color [0 0 0 1])
@@ -185,7 +185,7 @@
 (defn screenshot
   "Take a screenshot. Currently captures the entire screen."
   [filename state]
-  (println [(:window-x state) (:window-y state) (:window-width state) (:window-height state)])
+  ;(println [(:window-x state) (:window-y state) (:window-width state) (:window-height state)])
   (let [img-type (second (re-find (re-matcher #"\.(\w+)$" filename)))
 				capture (.createScreenCapture (Robot.)
 							      ;(Rectangle. (.getScreenSize (Toolkit/getDefaultToolkit))));; captures entire screen
@@ -198,8 +198,10 @@
 (defn key-press
   "Update the state in response to a keypress."
   [key state]
+  ;(println "key-press" key)
   (cond
-    (= :lshift key) (do (reset! shift-key-down true) state)
+    ;(= :lshift key) (do (reset! shift-key-down true) state)
+    (= "z" key) (do (reset! shift-key-down true) state)
     (= "p" key) (do (app/pause!)
                   state)
     (= "o" key) (do (screenshot (str "brevis_screenshot_" (System/currentTimeMillis) ".png") state)
@@ -213,8 +215,10 @@
 (defn key-release
   "Update the state in response to the release of a key"
   [key state]
+  ;(println "key-release" key)
   (cond
-    (= :lshift key) (reset! shift-key-down false))
+    ;(= :lshift key) (reset! shift-key-down false))
+    (= "z" key) (reset! shift-key-down false))
   state)

 ;; ## Input handling
@@ -270,25 +274,25 @@
 (defn mouse-move
   "Respond to a change in x,y position of the mouse."
   [[[dx dy] [x y]] state]
-  #_(println x y)
+  (println "mouse-move" x y)
   state)

 (defn mouse-up
   "Respond to a mouse button being released"
   [[x y] button state]
-  #_(println button)
+  (println "mouse-up" button)
   state)

 (defn mouse-click
   "Respond to a click?"
   [[x y] button state]
-  #_(println button)
+  (println "mouse-click" button)
   state)

 (defn mouse-down
   "Respond to a mouse button being pressed"
   [[x y] button state]
-  #_(println button)
+  (println "mouse-down" button)
   state)


Basic keyboard-based movement logic

Basic keyboard-based movement logic

--- src/cas/client.cljs
+++ src/cas/client.cljs
@@ -6,7 +6,6 @@
 (def state (atom {:world []
                   :player {:pos {:x 0 :y 0}
                            :mov-time [0 0]}}))
-
 (def keystate (atom {}))

 (defn setup! []
@@ -79,10 +78,42 @@

 ;; Set up the event loop
 (defn tick! []
-  (println @keystate)
   (update!)
   (render!))
-(js/setInterval tick! 1000)
+(js/setInterval tick! 100)

 ;; Set up the basic program structure
 (setup!)
+
+
+;; Movement handling logic
+(defn walk! [dir]
+  (let [op (case dir :left dec :right inc)
+        world (:world @state)
+        player (:player @state)
+        pos (:pos player)]
+    (if (:passable ((world (:y pos)) (op (:x pos))))
+      (swap! state assoc :player (update-in player [:pos :x] op))
+      player)))
+
+(def movekeymap (atom {}))
+(defn start-walking! [dir]
+  (if-not (dir @movekeymap)
+    (do (walk! dir)
+        (swap! movekeymap assoc dir (js/setInterval #(walk! dir) 100)))))
+(.addEventListener js/document "keydown"
+  (fn [e]
+    (case (.-keyCode e)
+      37 (start-walking! :left)
+      39 (start-walking! :right)
+      nil)))
+
+(defn stop-walking! [dir]
+  (js/clearInterval (dir @movekeymap))
+  (swap! movekeymap assoc dir nil))
+(.addEventListener js/document "keyup"
+  (fn [e]
+    (case (.-keyCode e)
+      37 (stop-walking! :left)
+      39 (stop-walking! :right)
+      nil)))


wording tweaks

wording tweaks

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -260,20 +260,22 @@
         no-stream?
           (dom/div nil
             (dom/h1 nil "Hi")
-            (dom/p nil (str
-              "Cellf is an interactive experiment that reflects the player and their "
-              "surroundings as they play. Click OK to prompt for camera access*."))
-            (dom/em nil (str
-              "*There is no server or multiplayer component to this: "
-              "your image stays on your device."))
-            (dom/button #js {:onClick get-camera!} "ok"))
+            (dom/p nil
+              (str
+                "Cellf is an interactive experiment that reflects the player and their "
+                "surroundings as they play. When you click OK, Cellf will ask for camera access."))
+            (dom/p nil
+              (str
+                "There's no server or multiplayer component to this: "
+                "your image stays on your device."))
+            (dom/button #js {:onClick get-camera!} "✔ ok"))

         result-gif
           (dom/div nil
             (dom/h1 nil "Your Cellf")
             (dom/img #js {:src result-gif})
-            "Save this gif and share it with the world."
-            (dom/button #js {:onClick #(om/update! app :result-gif nil)} "done"))
+            "Save this gif and share your Cellf with the world."
+            (dom/button #js {:onClick #(om/update! app :result-gif nil)} "✔ done"))

         winner?
           (dom/div nil
@@ -297,13 +299,16 @@
                 "You can also export a replay of your moves to an animated gif by "
                 "clicking the 'make gif' button."))

-            (dom/p nil
+            (dom/h1 nil "About Cellf")
+            (dom/p nil
+              "Cellf was created by Dan Motzenbecker and is "
               (dom/a #js {:href "https://github.com/dmotz/cellf"} "open source")
+              " on Github. "
               "For more experiments like this, visit "
               (dom/a #js {:href "http://oxism.com"} "oxism.com")
               \.)

-            (dom/button #js {:onClick #(om/update! app :show-about? false)} "got it"))))))
+            (dom/button #js {:onClick #(om/update! app :show-about? false)} "✔ got it"))))))

 (om/root
@@ -337,8 +342,8 @@
             :className (when-not stream "hidden")
             :style     #js {:width capture-size}}

-            (dom/h1 nil "Cellf")
-            (dom/h2 nil "find yourself.")
+            (dom/h1 nil "cellf")
+            (dom/h2 nil "find yourself")
             (dom/canvas #js {
               :ref    "playback"
               :width  capture-size
@@ -358,7 +363,7 @@
                   :onChange #(om/update! app :show-nums (not show-nums))})

                 (dom/label nil
-                  (str "grid-size (" grid-size \× grid-size ")")
+                  (str "grid size (" grid-size \× grid-size ")")
                   (dom/em nil "(starts new game)"))
                 (dom/input #js {
                   :type     "range"


Fixing wrong order of arguments and docstring

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

--- src/conexp/util.clj
+++ src/conexp/util.clj
@@ -197,14 +197,14 @@
 ;;; Technical Helpers

 (defn proper-subset?
+  "Returns true iff set-1 is a proper subset of set-2."
   [set-1 set-2]
-  "Returns true iff set-1 is a proper subset of set-2."
   (and (not= set-1 set-2)
        (subset? set-1 set-2)))

 (defn proper-superset?
+  "Returns true iff set-1 is a proper superset of set-2."
   [set-1 set-2]
-  "Returns true iff set-1 is a proper superset of set-2."
   (proper-subset? set-2 set-1))

 (defn singleton?


Releasing new lein-template

Releasing new lein-template

--- lein-template/project.clj
+++ lein-template/project.clj
@@ -1,7 +1,7 @@
 ;; Copyright © 2014 JUXT LTD.

 ;; We call this project modular to make the invocation: lein new modular appname
-(defproject modular/lein-template "0.6.0"
+(defproject modular/lein-template "0.6.1"
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}


refactor make-job-spec, fix in_reply_to_status_id

--- src/thingybot/core.clj
+++ src/thingybot/core.clj
@@ -18,21 +18,18 @@
 (defn make-job-spec
   [{:keys [id text user] :as tweet}]
   (let [src       (str/trim (str/replace text (str "@" config/bot-name) ""))
-        idx       (.indexOf ^String src ",")
-        [cmd src] (if (pos? idx)
-                    [(subs src 0 idx) (subs src (inc idx))]
-                    [src src])]
+        [cmd src] (str/split src #",\s*" 2)]
     {:raw     tweet
      :id      id
      :src     src
      :cmd     cmd
-     :params  (select-keys tweet [:in_reply_to_status_id])
+     :params  {:in_reply_to_status_id id}
      :user-id (str "@" (:screen_name user))}))

 (defn process-tweet
   [tweet]
-  (println "---- processing tweet:" tweet)
   (let [job (make-job-spec tweet)]
+    (println "----\nprocessing job:" (:id job) (:user-id job) (:text tweet))
     (some
      (fn [[cmd handler]]
        (when (= cmd (:cmd job))


Add div-by-zero checks to HSL color functions.


Unnecessary extra vec.

Unnecessary extra vec.

--- src/onyx/log/commands/accept_join_cluster.clj
+++ src/onyx/log/commands/accept_join_cluster.clj
@@ -15,7 +15,6 @@
         (update-in [:accepted] dissoc accepted-observer)
         (update-in [:peers] vec)
         (update-in [:peers] conj accepted-joiner)
-        (update-in [:peers] vec)
         (assoc-in [:peer-state accepted-joiner] :idle))))

 (defmethod extensions/replica-diff :accept-join-cluster


lock/unlock/is-locked refacto

lock/unlock/is-locked refacto

--- src/sandbox/multithread.clj
+++ src/sandbox/multithread.clj
@@ -64,16 +64,31 @@
          (map :lock-id)
          (into []))))

-(defn lock [locks process-id lock-id]
+(defn lock
+  "locks lock lock-id in locks map"
+  [locks process-id lock-id]
   (assoc locks lock-id {:locker process-id :locked true}))
-
-(defn unlock [locks process-id lock-id]
+(defn unlock
+  "unlocks lock lock-id in locks map"
+  [locks process-id lock-id]
   (assoc locks lock-id {:locker process-id :locked false}))
-
-(defn is-locked? [process-id instructions locks instruction]
-  (->> (the-locks-inst-depends-on instructions instruction)
-       (some #(and (not= process-id ((get locks %) :locker))
-                   ((get locks %) :locked)))))
+;;=> The locks state contains its locked state and which process
+;; did lock it.
+
+(defn is-locked?
+  [process-id
+   instructions
+   locks
+   instruction]
+  (let [inst-locks (the-locks-inst-depends-on instructions
+                                              instruction)]
+    (some true? (map #(and (not= process-id ((get locks %)
+                                             :locker))
+                           ((get locks %) :locked))
+                     inst-locks))))
+;;=> If some of the locks the instruction depend on are locked (:locked true)
+;; and the locker is not its process, then it is considered as
+;; locked.

   [scheduled]
   (into [] (map  (fn [p] {:process-id (:process-id p)


Small refactoring.

Small refactoring.

--- src/vacation2/main.clj
+++ src/vacation2/main.clj
@@ -93,8 +93,7 @@
       (for [i (range n-reservations)]
         (ref {:id          i
               :status      :unprocessed
-              ; Status of reservation: :unprocessed|:in-process|:processed
-              ; FIXME: :processed is not used
+              ; Status of reservation: :unprocessed|:processed
               :n-people    (rand-number)
               ; Number of people to reserve for
               ; Note: the original vacation benchmark only seems to reserve for
@@ -112,6 +111,13 @@
      :cars    (generate-relation)
      :flights (generate-relation)
      :rooms   (generate-relation)}))
+
+(defn- log-data [{:keys [reservations cars flights rooms]}]
+  "Write `data` to log."
+  (log "reservations:" reservations)
+  (log "cars:" cars)
+  (log "flights:" flights)
+  (log "rooms:" rooms))

 (defn- look-for-seats [relations n-seats]
   "Look for a relation with `n-seats` free seats in `relations`, and return the
@@ -173,7 +179,7 @@
       (when found-flight (reserve-relation reservation found-flight n-people))
       (when found-room   (reserve-relation reservation found-room n-people))
       (alter reservation assoc
-        :status :in-process
+        :status :processed
         :pnr    pnr)))
   (log "finished reservation" (:id @reservation)))

@@ -219,13 +225,6 @@

 ; MAIN

-(defn- log-data [{:keys [reservations cars flights rooms]}]
-  "Write `data` to log."
-  (log "reservations:" reservations)
-  (log "cars:" cars)
-  (log "flights:" flights)
-  (log "rooms:" rooms))
-
 (defn -main [& args]
   "Main function. `args` should be a list of command line arguments."
   (when-let [options (parse-args args)]


[wallet] Avoid unnecessary balance checks

--- src/status_im/ethereum/transactions/core.cljs
+++ src/status_im/ethereum/transactions/core.cljs
@@ -145,6 +145,9 @@
 (defn get-min-known-block [db address]
   (get-in db [:wallet :accounts (eip55/address->checksum address) :min-block]))

+(defn get-max-block-with-transfers [db address]
+  (get-in db [:wallet :accounts (eip55/address->checksum address) :max-block]))
+
 (defn min-block-transfers-count [db address]
   (get-in db [:wallet :accounts
               (eip55/address->checksum address)
@@ -181,6 +184,17 @@
     {:db (update-in db [:wallet :accounts checksum] assoc
                     :min-block min-block
                     :min-block-transfers-count min-block-transfers-count)}))
+
+(fx/defn set-max-block-with-transfers
+  [{:keys [db]} address transfers]
+  (let [max-block (reduce
+                   (fn [max-block {:keys [block]}]
+                     (if (> block max-block)
+                       block
+                       max-block))
+                   (get-in db [:wallet :accounts address :max-block] 0)
+                   transfers)]
+    {:db (assoc-in db [:wallet :accounts address :max-block] max-block)}))

 (defn update-fetching-status
   [db addresses fetching-type state]
@@ -214,10 +228,12 @@
              "count" (count transfers)
              "limit" limit)
   (let [checksum (eip55/address->checksum address)
-        min-known-block (or (get-min-known-block db address)
-                            (:ethereum/current-block db))
+        max-known-block (or (get-max-block-with-transfers db address)
+                            0)
         effects (cond-> [(when (seq transfers)
-                           (set-lowest-fetched-block checksum transfers))]
+                           (set-lowest-fetched-block checksum transfers))
+                         (when (seq transfers)
+                           (set-max-block-with-transfers checksum transfers))]

                   (seq transfers)
                   (concat (mapv add-transfer transfers))
@@ -231,7 +247,7 @@
                   true
                   (conj (wallet/update-balances
                          (into [] (reduce (fn [acc {:keys [address block]}]
-                                            (if (>= block min-known-block)
+                                            (if (> block max-known-block)
                                               (conj acc address)
                                               acc))
                                           #{}


Fix bug preventing tests from running against HSQL

Because of an oddity in how our test-db fixture works, the tests
related to import/export would work properly against a Postgres
test database but would fail against an HSQL one.  This change
simply corrects how I was going about determining the database
connection info in my catalog test utils so that it works with
either database.

--- test/com/puppetlabs/puppetdb/testutils/catalog.clj
+++ test/com/puppetlabs/puppetdb/testutils/catalog.clj
@@ -3,7 +3,8 @@
             [cheshire.core :as json])
   (:use     [com.puppetlabs.utils :only [uuid]]
             [clj-time.core :only [now]]
-            [com.puppetlabs.puppetdb.testutils :only [test-db]]))
+            [com.puppetlabs.puppetdb.testutils :only [test-db]]
+            [com.puppetlabs.puppetdb.fixtures :only [*db*]]))

 (defn munge-resource-for-comparison
@@ -55,4 +56,4 @@
      :annotations {:id (uuid)
                    :received (now)}
      :version     2}
-    {:db          (test-db)}))
+    {:db          *db*}))


using get-parent-element-id in v5/util functions

--- src/vip/data_processor/validation/v5/util.clj
+++ src/vip/data_processor/validation/v5/util.clj
@@ -132,15 +132,7 @@
                 (reduce (fn [ctx path]
                           (let [missing-path (str path "."
                                                   (last xml-element-path))
-                                 parent-element-id (->(korma/exec-raw
-                                                       (:conn postgres/xml-tree-values)
-                                                       ["SELECT value
-                                                         FROM xml_tree_values
-                                                         WHERE path = subpath(text2ltree(?),0,4) || 'id'
-                                                         and results_id = ?" [missing-path import-id]]
-                                                       :results)
-                                                     first
-                                                     :value)]
+                                 parent-element-id (util/get-parent-element-id missing-path import-id)]
                             (errors/add-v5-errors ctx :errors schema-type
                                                missing-path :missing
                                                parent-element-id
@@ -227,17 +219,10 @@
             elements (elements-at-simple-path import-id simple-path)
             invalid-elements (remove (comp valid? :value) elements)]
         (reduce (fn [ctx row]
-                  (let [parent-element-id (->(korma/exec-raw
-                                              (:conn postgres/xml-tree-values)
-                                              ["SELECT value
-                                                FROM xml_tree_values
-                                                WHERE path = subpath(text2ltree(?),0,4) || 'id'
-                                                and results_id = ?" [(-> row :path .getValue) import-id]]
-                                              :results)
-                                            first
-                                            :value)]
+                  (let [path (-> row :path .getValue)
+                        parent-element-id (util/get-parent-element-id path import-id)]
                     (errors/add-v5-errors ctx error-severity error-root-element
-                                       (-> row :path .getValue) error-type parent-element-id
+                                       path error-type parent-element-id
                                        (:value row))))
                 ctx invalid-elements)))))


formatting fix

formatting fix

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -42,8 +42,7 @@
                                  (goog.dom.selection/setEnd (.-target e) 10000)
                                  (utils/stop-event e))
                   :value (urls/absolute-doc-url (:document/id app))}]
-         [:label
-          {:data-placeholder "Copy the url to share"}]]]))))
+         [:label {:data-placeholder "Copy the url to share"}]]]))))

 (defn auth-link [app owner {:keys [source] :as opts}]
   (reify


cleanup code

cleanup code

--- src-cljs/frontend/components/overlay.cljs
+++ src-cljs/frontend/components/overlay.cljs
@@ -120,24 +120,6 @@
               (common/icon :users)
               [:span "Request Access"]])

-           ;; (if (auth/has-document-access? app (:document/id app))
-           ;;   [:a.menu-item {:on-click #(cast! :invite-menu-opened)
-           ;;                  :role "button"}
-           ;;    (common/icon :users)
-           ;;    [:span "Invite Collaborators"]]
-
-           ;;   [:a.menu-item {:on-click #(cast! :document-permissions-opened)
-           ;;                  :role "button"}
-           ;;    (common/icon :users)
-           ;;    [:span "Request Access"]])
-
-           ;; (if (and (contains? (get-in app [:cust :flags]) :flags/private-docs)
-           ;;          (auth/admin? @db doc {:cust/uuid (get-in app [:cust :uuid])}))
-           ;;   [:a.menu-item {:on-click #(cast! :manage-permissions-opened)
-           ;;                  :role "button"}
-           ;;    (common/icon :users)
-           ;;    [:span "Manage permissions and privacy"]])
-
            [:a.menu-item {:on-click #(cast! :shortcuts-menu-opened)
                           :class "mobile-hidden"
                           :role "button"}
@@ -150,56 +132,7 @@
             [:span "Blog"]]
            (om/build auth-link app)]])))))

-; (defn invite [app owner]
-;   (reify
-;     om/IRender
-;     (render [_]
-;       (let [cast! (om/get-shared owner :cast!)
-;             invite-email (get-in app state/invite-email-path)]
-;         (html
-;          [:div.menu-view
-;           [:div.menu-view-frame
-;            [:article
-;             [:h2 "Share this with your team."]
-;             [:p "Send your teammates invites to come collaborate with you in this doc."]
-;             (if-not (:cust app)
-;               [:a.menu-button {:href (auth/auth-url)
-;                                :on-click #(do
-;                                             (.preventDefault %)
-;                                             (cast! :track-external-link-clicked
-;                                                    {:path (auth/auth-url)
-;                                                     :event "Signup Clicked"
-;                                                     :properties {:source "username-overlay"}}))
-;                                :role "button"}
-;                "Sign Up"]
-
-;               [:form.menu-invite-form {:on-submit #(do (cast! :invite-submitted)
-;                                                        false)
-;                                        :on-key-down #(when (= "Enter" (.-key %))
-;                                                        (cast! :email-invite-submitted)
-;                                                        false)}
-;                [:input {:type "text"
-;                         :required "true"
-;                         :data-adaptive ""
-;                         :value (or invite-email "")
-;                         :on-change #(cast! :invite-email-changed {:value (.. % -target -value)})}]
-;                [:label {:data-placeholder "Teammate's Email"
-;                         :data-placeholder-nil "What's your teammate's email?"
-;                         :data-placeholder-forgot "Don't forget to submit."}]])
-;             (when-let [response (first (get-in app (state/invite-responses-path (:document/id app))))]
-;               [:div response])
-;             ;; TODO: keep track of invites
-;             ;; [:p "You've sent 3 invitations to this doc."]
-;             ;; [:div.invite-recipient
-;             ;;  [:div.invite-recipient-email "fake@email.com"]
-;             ;;  [:a {:role "button"} "Resend"]]
-;             ;; [:div.invite-recipient
-;             ;;  [:div.invite-recipient-email "fake@email.com"]
-;             ;;  [:a {:role "button"} "Resend"]]
-;             ;; [:div.invite-recipient
-;             ;;  [:div.invite-recipient-email "fake@email.com"]
-;             ;;  [:a {:role "button"} "Resend"]]
-;             ]]])))))
+

 (defn private-sharing [app owner]
   (reify
@@ -226,7 +159,6 @@
       (let [{:keys [cast! db]} (om/get-shared owner)
             doc-id (:document/id app)
             doc (doc-model/find-by-id @db doc-id)
-            private? (= :document.privacy/private (:document/privacy doc))
             permission-grant-email (get-in app state/permission-grant-email-path)
             permissions (ds/touch-all '[:find ?t :in $ ?doc-id :where [?t :permission/document ?doc-id]] @db doc-id)
             access-grants (ds/touch-all '[:find ?t :in $ ?doc-id :where [?t :access-grant/document ?doc-id]] @db doc-id)


Warn against using `feature-on?` directly

--- src-cljs/frontend/utils/launchdarkly.cljs
+++ src-cljs/frontend/utils/launchdarkly.cljs
@@ -2,9 +2,13 @@
     (:refer-clojure :exclude [exists?]))

 (defn feature-on?
+  "True if the named feature is on in LaunchDarkly.
+
+  Do not use this function directly; instead use
+  `frontend.models.feature/enabled?`."
   ([feature-name default]
    (when (and (aget js/window "ldclient") js/ldclient.toggle)
-    (.toggle js/ldclient feature-name default)))
+     (.toggle js/ldclient feature-name default)))
   ([feature-name]
    (feature-on? feature-name nil)))


WIP Debug navigation events.

WIP Debug navigation events.

--- src-cljs/kixi/hecuba/tabs/programmes.cljs
+++ src-cljs/kixi/hecuba/tabs/programmes.cljs
@@ -78,6 +78,8 @@
 (defn history-loop [history-channel data]
   (go-loop []
     (let [nav-event (<! history-channel)]
+      (println "Old Active Components: " (:active-components @data))
+      (println "New Active Components: " (-> nav-event :args :ids))
       (om/update! data :active-components (-> nav-event :args :ids)))
     (recur)))


Remove dangling back-slash

Remove dangling back-slash

--- src/squelch/audio_node.cljs
+++ src/squelch/audio_node.cljs
@@ -6,7 +6,7 @@

 (defn get-context
   "Read only.
-  Returns the associated AudioContext, that is the object representing the \
+  Returns the associated AudioContext, that is the object representing the
   processing graph the node is participating in."
   [node]
   (.-context node))


Fix JWS example.

Fix JWS example.

--- examples/jws/src/authexample/web.clj
+++ examples/jws/src/authexample/web.clj
@@ -9,7 +9,7 @@
             [ring.middleware.json :refer [wrap-json-response wrap-json-body]]
             [ring.adapter.jetty :as jetty]
             [clj-time.core :as time]
-            [buddy.sign.jws :as jws]
+            [buddy.sign.jwt :as jwt]
             [buddy.auth :refer [authenticated? throw-unauthorized]]
             [buddy.auth.backends.token :refer [jws-backend]]
             [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]])
@@ -60,7 +60,7 @@
     (if valid?
       (let [claims {:user (keyword username)
                     :exp (time/plus (time/now) (time/seconds 3600))}
-            token (jws/sign claims secret {:alg :hs512})]
+            token (jwt/sign claims secret {:alg :hs512})]
         (ok {:token token}))
       (bad-request {:message "wrong auth data"}))))


Move everything around

Move everything around

--- src/invadm/core.clj
+++ src/invadm/core.clj
@@ -6,6 +6,9 @@
             [clj-time.format :as f]
             [clojure.string :as string])
   (:gen-class))
+
+(defn cwd []
+  (System/getProperty "user.dir"))

 (def date-formatter
   (f/formatter "yyyy-MM-dd"))
@@ -16,19 +19,63 @@
 (defn parse-date [date-string]
   (f/parse date-formatter date-string))

+(defn read-json [file]
+  (json/read-str (slurp file)))
+
+(defn write-json [file value]
+  (with-open [w (io/writer file)]
+    (.write w (json/write-str value))))
+
+(defn id-to-filename [id]
+  (str id ".json"))
+
+(defn read-invoice [id]
+  (read-json (id-to-filename id)))
+
+(defn write-invoice [id value]
+  (write-json (id-to-filename id) value))
+
+(defn get-invoice-filenames []
+  (filter #(.endsWith % ".json") (map #(.getName %) (file-seq (io/file (cwd))))))
+
+(defn read-all-invoices []
+  (map read-json (get-invoice-filenames)))
+
+(defn pretty-print-invoice [invoice]
+  (format (->> ["\nInvoice #%s"
+                "Client: %s"
+                "Issue date: %s"
+                "Due date: %s (Net %d)"
+                "Amount: %d %s"]
+               (string/join \newline))
+          (get invoice "id")
+          (get invoice "client")
+          (get invoice "issue-date")
+          (get invoice "due-date")
+          (get invoice "net")
+          (get invoice "amount")
+          (get invoice "currency")))
+
+(defn options-to-filter [options]
+  (fn [invoice]
+    (every? #(= (println %) (get options %) (get invoice (name %))) (keys options))))
+
 (def cli-options
   ;; TODO: add clever currency default
   [["-c" "--currency CURRENCY" "Invoice currency"]
    ["-r" "--client CLIENT" "Client"]
    ["-f" "--filename FILENAME" "Attached file"]
-   ["-i" "--issue-date ISSUE_DATE" "Issue date"
-    :default (unparse-date (t/now))]
-   ["-p" "--paid-on" "Paid on"
-    :default (unparse-date (t/now))]
+   ["-i" "--issue-date ISSUE_DATE" "Issue date"]
+   ["-p" "--paid-on PAID_ON" "Paid on"]
    ["-n" "--net NET" "Net"
     :parse-fn #(Integer/parseInt %)]
    ["-a" "--amount AMOUNT" "Total amount"
     :parse-fn #(Integer/parseInt %)]])
+
+(defn parse-today-default [value]
+  (cond
+    (nil? value) (unparse-date (t/now))
+    (string? value) value))

 (defn usage [options-summary]
   (->> ["invadm - an invoice manager"
@@ -55,22 +102,6 @@
   (println msg)
   (System/exit status))

-(defn read-json [file]
-  (json/read-str (slurp file)))
-
-(defn write-json [file value]
-  (with-open [w (io/writer file)]
-    (.write w (json/write-str value))))
-
-(defn id-to-filename [id]
-  (str id ".json"))
-
-(defn read-invoice [id]
-  (read-json (id-to-filename id)))
-
-(defn write-invoice [id value]
-  (write-json (id-to-filename id) value))
-
 (defn create [options arguments]
   (cond
     (not (:currency options)) (exit 1 (error-msg ["-c CURRENCY is required"]))
@@ -83,34 +114,6 @@
                         "id" (get arguments 1)
                         "due-date" (unparse-date (t/plus (parse-date (:issue-date options))
                                                          (t/days (:net options)))))))
-
-(defn cwd []
-  (System/getProperty "user.dir"))
-
-(defn get-invoice-filenames []
-  (filter #(.endsWith % ".json") (map #(.getName %) (file-seq (io/file (cwd))))))
-
-(defn read-all-invoices []
-  (map read-json (get-invoice-filenames)))
-
-(defn options-to-filter [options]
-  (fn [invoice]
-    (every? #(= (get options %) (get invoice (name %))) (keys options))))
-
-(defn pretty-print-invoice [invoice]
-  (format (->> ["\nInvoice #%s"
-                "Client: %s"
-                "Issue date: %s"
-                "Due date: %s (Net %d)"
-                "Amount: %d %s"]
-               (string/join \newline))
-          (get invoice "id")
-          (get invoice "client")
-          (get invoice "issue-date")
-          (get invoice "due-date")
-          (get invoice "net")
-          (get invoice "amount")
-          (get invoice "currency")))

 (defn data [options]
   (println (json/write-str (filter (options-to-filter options) (read-all-invoices)))))
@@ -137,8 +140,12 @@
       errors (exit 1 (error-msg errors)))
     ;; Execute program with options
     (case (first arguments)
-      "create" (create options arguments)
+      "create" (create (assoc options
+                              :issue-date (parse-today-default (:issue-date options)))
+                       arguments)
       "data" (data options)
       "list" (list_ options)
-      "record-payment" (record-payment options arguments)
+      "record-payment" (record-payment (assoc options
+                                              :paid-on (parse-today-default (:paid-on options)))
+                                       arguments)
       (exit 1 (usage summary)))))


add docstring note

add docstring note

--- src/keypin/util.clj
+++ src/keypin/util.clj
@@ -24,7 +24,7 @@

 (defn any?
-  "Dummy validator. Always return true."
+  "Dummy validator. Always return true. Same as clojure.core/any? in Clojure 1.9+."
   [_]
   true)


remove unused WORKER-HOOK-FIELD def

remove unused WORKER-HOOK-FIELD def

--- storm-core/src/clj/backtype/storm/thrift.clj
+++ storm-core/src/clj/backtype/storm/thrift.clj
@@ -282,6 +282,3 @@
   [StormTopology$_Fields/SPOUTS
    StormTopology$_Fields/STATE_SPOUTS])

-(def WORKER-HOOK-FIELD
-  [StormTopology$_Fields/WORKER_HOOKS])
-


Force the deadline value to a double when it's used.

--- src/appengine_magic/services/urlfetch.clj
+++ src/appengine_magic/services/urlfetch.clj
@@ -58,7 +58,7 @@
     (if follow-redirects
       (.followRedirects fetch-options)
       (.doNotFollowRedirects fetch-options))
-    (.setDeadline fetch-options deadline)
+    (.setDeadline fetch-options (double deadline))
     (let [method-obj (method {:delete HTTPMethod/DELETE
                               :get    HTTPMethod/GET
                               :head   HTTPMethod/HEAD


Improve ns loading logging

Improve ns loading logging

--- src/yetibot/core/loader.clj
+++ src/yetibot/core/loader.clj
@@ -36,9 +36,9 @@
    namespaces and return the seq of matched namespaces."
   [ns-patterns]
   (let [nss (flatten (map find-namespaces ns-patterns))]
-    (info "☐ Loading" (count nss) " namespaces...")
+    (info "☐ Loading" (count nss) "namespaces matching" ns-patterns)
     (dorun (map load-ns nss))
-    (info "☑ Loaded" (count nss) " namespaces")
+    (info "☑ Loaded" (count nss) "namespaces matching" ns-patterns)
     nss))

 (defn load-commands []


whitespace

whitespace

--- server/test/gratefulplace/email/sending/t_send.clj
+++ server/test/gratefulplace/email/sending/t_send.clj
@@ -12,9 +12,9 @@

 (def mail-options
   {:from (config :email :from-address)
-    :to (config :email :test-recipient)
-    :subject "[Grateful Place] test"
-    :body (email-content/body "test" template-vars)})
+   :to (config :email :test-recipient)
+   :subject "[Grateful Place] test"
+   :body (email-content/body "test" template-vars)})

 (fact "if deliver? is false, return params"
   (email/send-email*


Update label for :set-github-status project flag (#1624)

Update the label so that it says "GitHub" for GitHub projects and
"Bitbucket" for Bitbucket projects

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -638,12 +638,14 @@
                                     [:a {:href "/docs/test-metadata/#metadata-collection-in-custom-test-steps"}
                                      "the docs"] " for more information."]})

-            (describe-flag {:flag :set-github-status
-                            :title "GitHub Status updates"
-                            :blurb [:p
-                                    "By default, we update the status of every pushed commit with "
-                                    "GitHub's status API. If you'd like to turn this off (if, for example, "
-                                    "this is conflicting with another service), you can do so below."]})
+            (let [pretty-vcs (utils/prettify-vcs_type (:vcs-type project))]
+              (describe-flag {:flag :set-github-status
+                              :title (gstring/format "%s Status updates" pretty-vcs)
+                              :blurb [:p
+                                      "By default, we update the status of every pushed commit with "
+                                      (gstring/format "%s's status API. If you'd like to turn this off (if, for example, "
+                                                      pretty-vcs)
+                                      "this is conflicting with another service), you can do so below."]}))
             (describe-flag {:flag :oss
                             :title "Free and Open Source"
                             :blurb [:p


feature -> component

feature -> component

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -155,12 +155,15 @@
                         "."]
                        (when show-modal?
                          (let [close-fn #(om/set-state! owner :show-modal? false)
-                               cancel-fn-for-feature
-                               (fn [feature-clicked]
+                               ;; NB: "component" here is used in the analytics
+                               ;; sense; it's a string describing a UI element,
+                               ;; not a React component.
+                               cancel-fn-for-component
+                               (fn [component-clicked]
                                  #(do
                                     (close-fn)
                                     ((om/get-shared owner :track-event) {:event-type :stop-building-modal-dismissed
-                                                                         :properties {:feature-clicked feature-clicked}})))]
+                                                                         :properties {:component-clicked component-clicked}})))]
                            (modal/modal-dialog
                              {:title (gstring/format "Stop building %s/%s on CircleCI?" username reponame)
                               :body (html
@@ -169,7 +172,7 @@
                                         (gstring/format
                                           "When you stop building %s on CircleCI, we will stop all builds and unfollow all teammates who are currently following the project."
                                           reponame)]])
-                              :actions [(button/button {:on-click (cancel-fn-for-feature "cancel-button")} "Cancel")
+                              :actions [(button/button {:on-click (cancel-fn-for-component "cancel-button")} "Cancel")
                                         (button/managed-button
                                           {:on-click #(do
                                                         (raise! owner [:stopped-building-project {:vcs-url vcs-url
@@ -184,9 +187,9 @@
                               ;; the user clicks outside the modal to dismiss
                               ;; it (and potentially anywhere else the modal
                               ;; needs it). Therefore, we can't assign a
-                              ;; meaningful feature here. We can at least set it
+                              ;; meaningful component here. We can at least set it
                               ;; to nil so we don't lie.
-                              :close-fn (cancel-fn-for-feature nil)})))
+                              :close-fn (cancel-fn-for-component nil)})))

                        (button/managed-button
                          {:on-click #(raise! owner [:unfollowed-project {:vcs-url vcs-url :project-id project-id}])


Port fact/http tests to use properly isolated transactions

Signed-off-by: Deepak Giridharagopal <d11186354d1ef01ca06ae37d7e23e827da13e85f@puppetlabs.com>

--- test/com/puppetlabs/cmdb/test/http/facts.clj
+++ test/com/puppetlabs/cmdb/test/http/facts.clj
@@ -6,17 +6,16 @@
   (:use clojure.test
         ring.mock.request
         [com.puppetlabs.jdbc :only (with-transacted-connection)]
-        [com.puppetlabs.cmdb.testutils :only [test-db]]
+        [com.puppetlabs.cmdb.testutils :only [with-test-db]]
         [com.puppetlabs.cmdb.scf.migrate :only [migrate!]]))

 (def ^:dynamic *app* nil)
+(def ^:dynamic *db* nil)

 (use-fixtures :each (fn [f]
-                      (let [db (test-db)]
-                        (binding [*app* (server/build-app {:scf-db db})]
-                          (with-transacted-connection db
-                            (migrate!)
-                            (f))))))
+                      (with-test-db *db*
+                        (binding [*app* (server/build-app {:scf-db *db*})]
+                          (f)))))

 (def c-t "application/json")

@@ -38,9 +37,11 @@
                "hostname" "myhost"
                "kernel" "Linux"
                "operatingsystem" "Debian"}]
-    (scf-store/add-certname! certname_without_facts)
-    (scf-store/add-certname! certname_with_facts)
-    (scf-store/add-facts! certname_with_facts facts)
+    (with-transacted-connection *db*
+      (migrate!)
+      (scf-store/add-certname! certname_without_facts)
+      (scf-store/add-certname! certname_with_facts)
+      (scf-store/add-facts! certname_with_facts facts))
     (testing "for an absent node"
       (let [request (make-request "/facts/imaginary_node")
             response (*app* request)]


Add tests for derive-action-data

Add tests for derive-action-data

--- test/ctia/task/migration/migrations_test.clj
+++ test/ctia/task/migration/migrations_test.clj
@@ -308,3 +308,64 @@
                        judgement
                        verdict
                        casebook])))))
+
+(deftest derive-action-data-test
+  (is (= sut/empty-action-data
+         (sut/derive-action-data {:type "judgement"
+                                  :observable {:type "pki-serial" :value "12345"}})))
+
+  (is (= sut/empty-action-data
+         (sut/derive-action-data {:type "collect"
+                                  :result []})))
+  (is (= {:object_ids #{}
+          :investigated_observables
+          #{"sha256:585c2a90e4928f67af7be2d0bdc282b7eb6c90113ae588461a441d31b5268e88"
+            "sha256:ac517bb701f20fe2f1826a0170c8ba7ba3f0632c77d89ed2dfe1883f588e9d1f"}
+          :targets #{}}
+         (sut/derive-action-data {:type "collect"
+                                  :result [{:value "585c2a90e4928f67af7be2d0bdc282b7eb6c90113ae588461a441d31b5268e88"
+                                            :type "sha256"}
+                                           {:value "ac517bb701f20fe2f1826a0170c8ba7ba3f0632c77d89ed2dfe1883f588e9d1f"
+                                            :type "sha256"}]})))
+
+  (is (= {:object_ids #{"https://intel.test.iroh.site:443/ctia/indicator/indicator-97c97157-6592-43e3-a54e-f126b4950787"
+                        "https://intel.test.iroh.site:443/ctia/sighting/sighting-b1a75bb0-d10d-47e6-b70d-915a24f66a0b"
+                        "https://intel.test.iroh.site:443/ctia/relationship/relationship-c3c89cb9-b09a-4fe3-b92a-5bae7faca36a"}
+          :investigated_observables []
+          :targets #{}}
+         (sut/derive-action-data
+          {:type "investigate",
+           :result {:data [{:module "AMP Global Intel",
+                            :module-type "CTIAInvestigateModule",
+                            :data {:indicators {:docs [{:id "https://intel.test.iroh.site:443/ctia/indicator/indicator-97c97157-6592-43e3-a54e-f126b4950787"}]}
+                                   :relationships {:docs [{:id "https://intel.test.iroh.site:443/ctia/relationship/relationship-c3c89cb9-b09a-4fe3-b92a-5bae7faca36a"}]}
+                                   :sightings {:docs [{:id "https://intel.test.iroh.site:443/ctia/sighting/sighting-b1a75bb0-d10d-47e6-b70d-915a24f66a0b"}]}}}]}})))
+
+
+  (is (= {:object_ids #{"https://intel.test.iroh.site:443/ctia/indicator/indicator-97c97157-6592-43e3-a54e-f126b4950787"
+                        "https://intel.test.iroh.site:443/ctia/sighting/sighting-b1a75bb0-d10d-47e6-b70d-915a24f66a0b"
+                        "https://intel.test.iroh.site:443/ctia/relationship/relationship-c3c89cb9-b09a-4fe3-b92a-5bae7faca36a"},
+          :investigated_observables [],
+          :targets #{{:type "endpoint",
+                      :observables [{:value "Demo_iOS_3", :type "hostname"}],
+                      :observed_time {:start_time "2019-04-01T20:45:11.000Z"},
+                      :os "iOS 10.3 (1)"}
+                     {:type "endpoint",
+                      :observables [{:value "Demo_iOS_1", :type "hostname"}],
+                      :observed_time {:start_time "2019-03-27T15:30:24.000Z"},
+                      :os "iOS 10.3 (1)"}}}
+         (sut/derive-action-data
+          {:type "investigate",
+           :result {:data [{:module "AMP Global Intel",
+                            :module-type "CTIAInvestigateModule",
+                            :data {:indicators {:docs [{:id "https://intel.test.iroh.site:443/ctia/indicator/indicator-97c97157-6592-43e3-a54e-f126b4950787"
+                                                        :targets [{:type "endpoint",
+                                                                   :observables [{:value "Demo_iOS_3", :type "hostname"}]
+                                                                   :observed_time {:start_time "2019-04-01T20:45:11.000Z"}
+                                                                   :os "iOS 10.3 (1)"}]}]}
+                                   :relationships {:docs [{:id "https://intel.test.iroh.site:443/ctia/relationship/relationship-c3c89cb9-b09a-4fe3-b92a-5bae7faca36a"}]}
+                                   :sightings {:docs [{:id "https://intel.test.iroh.site:443/ctia/sighting/sighting-b1a75bb0-d10d-47e6-b70d-915a24f66a0b"
+                                                       :targets [{:type "endpoint",
+                                                                  :observables [{:value "Demo_iOS_1", :type "hostname"}]
+                                                                  :observed_time {:start_time "2019-03-27T15:30:24.000Z"},
+                                                                  :os "iOS 10.3 (1)"}]}]}}}]}}))))


fix tests

fix tests

--- test/hu/ssh/github_changelog/semver_test.clj
+++ test/hu/ssh/github_changelog/semver_test.clj
@@ -1,12 +1,12 @@
 (ns hu.ssh.github-changelog.semver-test
-  (:use clojure.test)
   (:require
     [hu.ssh.github-changelog.semver :as semver]
     [hu.ssh.github-changelog.schema :refer [Semver]]
     [schema.experimental.generators :as g]
-    [schema.experimental.complete :as c]))
+    [schema.experimental.complete :as c]
+    [clojure.test :refer :all]))

-(testing "semver/extract"
+(deftest extract
   (testing "with a v prefix"
     (is (semver/extract "v0.0.1"))
     (is (semver/extract "v0.9.3-pre0"))
@@ -16,5 +16,5 @@
     (is (semver/extract "0.9.3-pre0"))
     (is (semver/extract "1.0.1"))))

-(testing "semver/newer?"
+(deftest newer?
   (is (semver/newer? (c/complete {:major 1} Semver) (c/complete {:major 0} Semver))))