wrap our main create/update persistence methods for pulses in a transaction so that everything is atomic and we don't get partially modified db records in the event of an error.

--- src/metabase/models/pulse.clj
+++ src/metabase/models/pulse.clj
@@ -46,7 +46,7 @@

 ;; ## Helper Functions

-(defn update-pulse-cards
+(defn- update-pulse-cards
   "Update the `PulseCards` for a given PULSE.
    CARD-IDS should be a definitive collection of *all* IDs of cards for the pulse in the desired order.

@@ -80,7 +80,7 @@
       ;; 4. NOT in channels, NOT in db-channels = NO-OP
       :else nil)))

-(defn update-pulse-channels
+(defn- update-pulse-channels
   "Update the `PulseChannels` for a given PULSE.
    CHANNELS should be a definitive collection of *all* of the channels for the the pulse.

@@ -108,11 +108,11 @@
          (every? integer? cards)
          (coll? channels)
          (every? map? channels)]}
-  ;; TODO: ideally this would all be in a transaction
-  (db/upd Pulse id :name name)
-  (update-pulse-cards pulse cards)
-  (update-pulse-channels pulse channels)
-  (db/sel :one Pulse :id id))
+  (kdb/transaction
+    (db/upd Pulse id :name name)
+    (update-pulse-cards pulse cards)
+    (update-pulse-channels pulse channels)
+    (db/sel :one Pulse :id id)))

 (defn create-pulse
   "Create a new `Pulse` by inserting it into the database along with all associated pieces of data such as:
@@ -125,12 +125,12 @@
          (every? integer? cards)
          (coll? channels)
          (every? map? channels)]}
-  ;; TODO: ideally this would all be in a transaction
-  (let [{:keys [id] :as pulse} (db/ins Pulse
-                                 :creator_id creator-id
-                                 :name name)]
-    ;; add cards to the Pulse
-    (update-pulse-cards pulse cards)
-    ;; add channels to the Pulse
-    (update-pulse-channels pulse channels)
-    (db/sel :one Pulse :id id)))
+  (kdb/transaction
+    (let [{:keys [id] :as pulse} (db/ins Pulse
+                                   :creator_id creator-id
+                                   :name name)]
+      ;; add cards to the Pulse
+      (update-pulse-cards pulse cards)
+      ;; add channels to the Pulse
+      (update-pulse-channels pulse channels)
+      (db/sel :one Pulse :id id))))


don't update the PulseCards if there hasn't been a change.

--- src/metabase/models/pulse.clj
+++ src/metabase/models/pulse.clj
@@ -130,7 +130,8 @@
          (every? map? channels)]}
   (kdb/transaction
     (db/upd Pulse id :name name)
-    (update-pulse-cards pulse cards)
+    (when (not= cards (db/sel :many :field [PulseCard :card_id] :pulse_id id (k/order :position :asc)))
+      (update-pulse-cards pulse cards))
     (update-pulse-channels pulse channels)
     (retrieve-pulse id)))


Starting problem 73. (Tic-Tac-Toe Board)

--- src/fourclojure/4_clojure.clj
+++ src/fourclojure/4_clojure.clj
@@ -60,13 +60,13 @@
 ; 4. Combine sets found in parts 2 and 3
 ; Well, didn't manage to find correct solution as per above, now trying wikipedia way:
 ; https://en.wikipedia.org/wiki/Power_set
-(defn ^:private op-f [e t]
+(defn- ^:private op-f [e t]
   (map #(conj % e) t))

 (defn powerset [s]
   (if (seq s)
     (let [e (first s) t (powerset (disj s e))]
-      (clojure.set/union t (map #(conj % e) t)))
+      (clojure.set/union t (op-f e t)))
     #{#{}}))

 (defn tic-tac-toe [board]


Remove dead code.

Remove dead code.

--- src/onyx/metrics_endpoint.clj
+++ src/onyx/metrics_endpoint.clj
@@ -60,12 +60,6 @@
    (some (fn [r] (re-find r metric))
          blacklists)))

-
-
-(comment )
-;(identity beann)
-
-
 (defn metrics-endpoint [peer-config]
   (let [builder (java.lang.StringBuilder.)
         blacklists (:onyx.query.server/metrics-blacklist peer-config)


Reorder functions so documentation is consistent

--- src/play_clj/core_cameras.clj
+++ src/play_clj/core_cameras.clj
@@ -50,6 +50,14 @@
     (set! (. (. camera position) y) (/ height 2))
     (.update camera)))

+(defn width
+  "Returns the width of the camera in `screen`.
+
+    (width screen)"
+  [screen]
+  (let [^Camera camera (u/get-obj screen :camera)]
+    (. camera viewportWidth)))
+
 (defn width!
   "Sets the width of the camera in `screen`, adjusting the height so the ratio
 remains in tact.
@@ -58,13 +66,13 @@
   [screen new-width]
   (size! screen new-width (* new-width (/ (game :height) (game :width)))))

-(defn width
-  "Returns the width of the camera in `screen`.
+(defn height
+  "Returns the height of the camera in `screen`.

-    (width screen)"
+    (height screen)"
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera viewportWidth)))
+    (. camera viewportHeight)))

 (defn height!
   "Sets the height of the camera in `screen`, adjusting the width so the ratio
@@ -74,13 +82,11 @@
   [screen new-height]
   (size! screen (* new-height (/ (game :width) (game :height))) new-height))

-(defn height
-  "Returns the height of the camera in `screen`.
-
-    (height screen)"
+(defn x
+  "Returns the x position of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera viewportHeight)))
+    (. (. camera position) x)))

 (defn x!
   "Sets only the x position of the camera in `screen`."
@@ -89,11 +95,11 @@
     (set! (. (. camera position) x) x-val)
     (.update camera)))

-(defn x
-  "Returns the x position of the camera in `screen`."
+(defn y
+  "Returns the y position of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. (. camera position) x)))
+    (. (. camera position) y)))

 (defn y!
   "Sets only the y position of the camera in `screen`."
@@ -102,11 +108,11 @@
     (set! (. (. camera position) y) y-val)
     (.update camera)))

-(defn y
-  "Returns the y position of the camera in `screen`."
+(defn z
+  "Returns the z position of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. (. camera position) y)))
+    (. (. camera position) z)))

 (defn z!
   "Sets only the z position of the camera in `screen`."
@@ -115,11 +121,11 @@
     (set! (. (. camera position) z) z-val)
     (.update camera)))

-(defn z
-  "Returns the z position of the camera in `screen`."
+(defn position
+  "Returns the position of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. (. camera position) z)))
+    (. camera position)))

 (defn position!
   "Sets the position of the camera in `screen`."
@@ -135,11 +141,11 @@
       (when z-val (set! (. (. camera position) z) z-val))
       (.update camera))))

-(defn position
-  "Returns the position of the camera in `screen`."
+(defn direction
+  "Returns the direction of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera position)))
+    (. camera direction)))

 (defn direction!
   "Sets the direction of the camera in `screen`."
@@ -148,11 +154,11 @@
     (.lookAt camera x y z)
     (.update camera)))

-(defn direction
-  "Returns the direction of the camera in `screen`."
+(defn near
+  "Returns the near clipping plane distance of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera direction)))
+    (. camera near)))

 (defn near!
   "Sets the near clipping plane distance of the camera in `screen`."
@@ -161,11 +167,11 @@
     (set! (. camera near) n)
     (.update camera)))

-(defn near
-  "Returns the near clipping plane distance of the camera in `screen`."
+(defn far
+  "Returns the far clipping plane distance of the camera in `screen`."
   [screen]
   (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera near)))
+    (. camera far)))

 (defn far!
   "Sets the far clipping plane distance of the camera in `screen`."
@@ -173,9 +179,3 @@
   (let [^Camera camera (u/get-obj screen :camera)]
     (set! (. camera far) n)
     (.update camera)))
-
-(defn far
-  "Returns the far clipping plane distance of the camera in `screen`."
-  [screen]
-  (let [^Camera camera (u/get-obj screen :camera)]
-    (. camera far)))


fix tests for BAM indexer a bit

fix tests for BAM indexer a bit

--- test/cljam/t_bam.clj
+++ test/cljam/t_bam.clj
@@ -53,15 +53,16 @@
   (fact "about BAM indexer"
         (bai/create-index
           temp-file-sorted (str temp-file-sorted ".bai")) => anything
+        (.exists (file (str temp-file-sorted ".bai"))) => truthy
         (with-open [r (bam/reader temp-file-sorted)]
           (io/read-alignments r {:chr "ref" :start 0 :end 1000})
           ) => (filter #(= "ref" (:rname %))
-                       (:alignments test-sam-sorted-by-pos))
-        ))
+                       (:alignments test-sam-sorted-by-pos))))

 (let [f (str temp-dir "/test.incomplete.bam")
       sorted-f (str temp-dir "/test.incomplete.sorted.bam")]
   (with-state-changes [(before :facts (do (prepare-cache!)
+                                          ;; generate incomplete bam on the fly
                                           (spit-bam-for-test
                                             f test-sam-incomplete-alignments)
                                           ;; TODO: go independent from sorter
@@ -70,8 +71,8 @@
                                             (bam/writer sorted-f))))
                        (after :facts (clean-cache!))]
     (fact "about BAM indexer (for incomplete alignments)"
-          ;; generate incomplete bam file on the fly
           (bai/create-index sorted-f (str sorted-f ".bai")) => anything
+          (.exists (file (str sorted-f ".bai"))) => truthy
           (with-open [r (bam/reader sorted-f)]
             (io/read-alignments r {:chr "ref" :start 0 :end 1000})
             ) => (filter #(= "ref" (:rname %))
@@ -86,7 +87,8 @@
                      (after :facts (clean-cache!))]
   (fact "about BAM indexer (medium file)" :slow
         (bai/create-index
-          temp-file-sorted (str temp-file-sorted ".bai")) => anything))
+          temp-file-sorted (str temp-file-sorted ".bai")) => anything
+          (.exists (file (str temp-file-sorted ".bai"))) => truthy))

 (with-state-changes [(before :facts (do (prepare-cavy!)
                                         (prepare-cache!)
@@ -95,5 +97,6 @@
                      (after :facts (clean-cache!))]
   (fact "about BAM indexer (large file)" :slow
         (bai/create-index
-          temp-file-sorted (str temp-file-sorted ".bai")) => anything))
+          temp-file-sorted (str temp-file-sorted ".bai")) => anything
+          (.exists (file (str temp-file-sorted ".bai"))) => truthy))


Update to ClojureScript 1.9.473

Update to ClojureScript 1.9.473

--- planck-cljs/project.clj
+++ planck-cljs/project.clj
@@ -1,6 +1,6 @@
 (defproject planck "0.1.0"
   :profiles {:shared
-             {:dependencies [[org.clojure/clojurescript "1.9.456"]]}
+             {:dependencies [[org.clojure/clojurescript "1.9.473"]]}
              :dev
              [:shared
               {:dependencies [[org.clojure/test.check "0.9.0"]


(SERVER-882) Update get-static-file-content function

This commit updates the get-static-file-content test helper to request
text instead of a stream and removes the then unneeded slurp calls.

--- test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
+++ test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
@@ -24,7 +24,7 @@
   [url-end]
   (http-client/get (str "https://localhost:8140/puppet/v3/static_file_content/" url-end)
                    (assoc testutils/ssl-request-options
-                     :as :stream)))
+                     :as :text)))

 (deftest ^:integration test-external-command-execution
   (testing "puppet functions can call external commands successfully"
@@ -92,21 +92,21 @@
       (testing "the /static_file_content endpoint successfully streams file content"
         (let [response (get-static-file-content "modules/foo/files/bar.txt?code_id=foobar&environment=test")]
           (is (= 200 (:status response)))
-          (is (= "test foobar modules/foo/files/bar.txt\n" (slurp (:body response))))))
+          (is (= "test foobar modules/foo/files/bar.txt\n" (:body response)))))

       (let [error-message "Error: A /static_file_content request requires an environment, a code-id, and a file-path"]
         (testing "the /static_file_content endpoint returns an error if code_id is not provided"
           (let [response (get-static-file-content "modules/foo/files/bar.txt?environment=test")]
             (is (= 400 (:status response)))
-            (is (= error-message (slurp (:body response))))))
+            (is (= error-message (:body response)))))
         (testing "the /static_file_content endpoint returns an error if environment is not provided"
           (let [response (get-static-file-content "modules/foo/files/bar.txt?code_id=foobar")]
             (is (= 400 (:status response)))
-            (is (= error-message (slurp (:body response))))))
+            (is (= error-message (:body response)))))
         (testing "the /static_file_content endpoint returns an error if file-path is not provided"
           (let [response (get-static-file-content "?code_id=foobar&environment=test")]
             (is (= 400 (:status response)))
-            (is (= error-message (slurp (:body response)))))))
+            (is (= error-message (:body response))))))
       (let [error-message "Request Denied: A /static_file_content request must be a file within the files directory of a module or a module in an environment"
             valid-paths ["modules/foo/files/bar.txt"
                          "modules/foo/files/bar/"
@@ -127,12 +127,12 @@
           (doseq [path valid-paths]
             (let [response (get-static-file-content (str path "?code_id=foobar&environment=production"))]
               (is (= 200 (:status response)))
-              (is (= (str "production foobar " path "\n") (slurp (:body response)))))))
+              (is (= (str "production foobar " path "\n") (:body response))))))
         (testing "invalid requests return 403 and the error message"
           (doseq [path invalid-paths]
             (let [response (get-static-file-content (str path "?code_id=foobar&environment=production"))]
               (is (= 403 (:status response)))
-              (is (= error-message (slurp (:body response))))))))))))
+              (is (= error-message (:body response)))))))))))

 (deftest ^:integration static-file-content-endpoint-test-no-code-content-command
   (logging/with-test-logging
@@ -146,4 +146,4 @@
       (let [response (get-static-file-content "modules/foo/files/bar/?code_id=foobar&environment=test")]
         (is (= 500 (:status response)))
         (is (re-matches #".*Cannot retrieve code content because the \"versioned-code\.code-content-command\" setting is not present in configuration.*"
-                        (slurp (:body response)))))))))
+                        (:body response))))))))


add test for transactions affected by split

--- test/clj_money/trading_test.clj
+++ test/clj_money/trading_test.clj
@@ -958,21 +958,33 @@
                         :purchase-price 5M
                         :shares-purchased 200M
                         :shares-owned 200M}]
-        transactions (transactions/search-items storage-spec
-                                                {:account-id (:id commodity-account)})
-        actual-transactions (map #(dissoc % :id :created-at :updated-at) transactions)
-        expected-transactions [{:transaction-date (t/local-date 2015 1 1)
-                                :description "Purchase 200 shares of AAPL"
-                                :items [{:action :debit
-                                         :account-id (:id commodity-account)
-                                         :amount 200M
-                                         :value 1000M}
-                                        {:action :credit
-                                         :account-id (:id ira)
-                                         :amount 1000M
-                                         :value 1000M}]}]]
+        items (transactions/search-items storage-spec
+                                         {:account-id (:id commodity-account)})
+        actual-items (map #(dissoc %
+                                   :id
+                                   :updated-at
+                                   :created-at
+                                   :index
+                                   :transaction-id
+                                   :negative
+                                   :polarized-amount
+                                   :transaction-date
+                                   :memo
+                                   :reconciliation-id
+                                   :reconciliation-status
+                                   :reconciled?)
+                          items)
+        expected-items [{:action :debit
+                         :account-id (:id commodity-account)
+                         :amount 200M
+                         :value 1000M
+                         :balance 200M
+                         :description "Purchase 200 shares of AAPL at 5.000"}]]
     (is (= 2M (:ratio result))
         "The correct split ratio is returned")
     (pprint-diff expected-lots actual-lots)
     (is (= expected-lots actual-lots)
-        "The lots are adjusted correctly")))
+        "The lots are adjusted correctly")
+    (pprint-diff expected-items actual-items)
+    (is (= expected-items actual-items)
+        "The items are adjusted correctly.")))


Add test for set-positions

Add test for set-positions

--- test/cljs/fatlip/core_test.cljs
+++ test/cljs/fatlip/core_test.cljs
@@ -73,3 +73,21 @@
     (is (= (f/replace-ps graph layer)
            (assoc layer :minus-ps [(f/SegmentContainer. [p-edge seg-c-edge]) not-p]))
         "P nodes get replaced by segment containers, and joined with adjacent segment containers")))
+
+
+(deftest set-positions
+  (let [seg-1 (f/SegmentContainer. [(f/Edge. "src" "dest" #{})
+                                    (f/Edge. "src" "dest" #{})])
+        node-1 (f/Node. :0-0 0 #{})
+        node-2 (f/Node. :0-1 0 #{})
+        seg-2 (f/SegmentContainer. [(f/Edge. "src" "dest" #{})
+                                    (f/Edge. "src" "dest" #{})
+                                    (f/Edge. "src" "dest" #{})])
+        node-3 (f/Node. :0-2 0 #{})
+        seg-3 (f/SegmentContainer. [(f/Edge. "src" "dest" #{})])
+        node-4 (f/Node. :0-2 0 #{})
+        layer (-> (f/Layer. 0 0 [])
+                  (assoc :minus-ps [seg-1 node-1 node-2 seg-2 node-3 seg-3 node-4]))]
+    (is (= (f/set-positions layer) (assoc layer :positions {seg-1 0, node-1 2, node-2 3
+                                                            seg-2 4, node-3 7, seg-3 8
+                                                            node-4 9})))))


chopping to clojure 1.7-alpha5 issue: previous failed

--- test/midje/util/t_one_seven.clj
+++ test/midje/util/t_one_seven.clj
@@ -3,6 +3,18 @@
         [midje.util laziness thread-safe-var-nesting]
         [midje.test-util]))

+;; Justification for use of eagerly
+(def counter (atom :needs-to-be-initialized))
+(def #^:dynamic *mocked-function-produces-next-element* inc)
+
+(defn function-under-test-produces-a-lazy-list []
+  (iterate *mocked-function-produces-next-element* 1))
+
+(defn mock-use []
+  (binding [*mocked-function-produces-next-element* (fn [n] (swap! counter inc) (inc n))]
+    (eagerly (take 5 (function-under-test-produces-a-lazy-list)))))
+
+;; After justification, more facts.

 (unfinished exploder)


Log topic creation

Log topic creation

--- test/onyx/plugin/test_utils.clj
+++ test/onyx/plugin/test_utils.clj
@@ -8,7 +8,8 @@
              [protocols :refer [send-sync!]]]
             [franzy.serialization.serializers :refer [byte-array-serializer]]
             [onyx.kafka.embedded-server :as ke]
-            [schema.core :as s])
+            [schema.core :as s]
+            [taoensso.timbre :as log])
   (:import franzy.clients.producer.types.ProducerRecord))

 ;; Set the log level, otherwise Kafka emits a huge amount
@@ -18,6 +19,10 @@
 (s/defn create-topic
   ([zk-address topic-name] (create-topic zk-address topic-name 1))
   ([zk-address :- s/Str topic-name :- s/Str partitions :- s/Int]
+   (log/info {:msg "Creating new topic"
+              :zk-address zk-address
+              :topic-name topic-name
+              :partitions partitions})
    (k-topics/create-topic!
     (k-admin/make-zk-utils {:servers [zk-address]} false)
     topic-name


get auto-connect working for node

get auto-connect working for node

--- sidecar/src/figwheel_sidecar/auto_builder.clj
+++ sidecar/src/figwheel_sidecar/auto_builder.clj
@@ -201,8 +201,8 @@
                   "\ndocument.write(\"<script>if (typeof goog != \\\"undefined\\\") { goog.require(\\\"devcards.core\\\"); }</script>\");")
                 "\ndocument.write(\"<script>if (typeof goog != \\\"undefined\\\") { goog.require(\\\"figwheel.connect\\\"); }</script>\");")
                "\ngoog.require(\"figwheel.connect\");")]
-    (when (and output-to (not node?))
-      (if main?
+    (when output-to
+      (if (and main? (not node?))
         (let [lines (string/split (slurp output-to) #"\n")]
           ;; require before app
           (spit output-to (string/join "\n" (concat (butlast lines) [line] [(last lines)]))))


♻ Extract helpers for calling the API

♻ Extract helpers for calling the API

Why:
- Making HTTP calls is verbose and repetitive
- Convention: "try-" prefix means the function returns a HTTP response
- read-body did not parse JSON response when the body was a string,
  which lead to having to parse the body in get-user-id

--- test/territory_bro/api_test.clj
+++ test/territory_bro/api_test.clj
@@ -50,11 +50,14 @@
 (defn parse-json [body]
   (cond
     (nil? body) body
-    (string? body) body
+    (string? body) (json/parse-string body)
     :else (json/parse-string (slurp (io/reader body)))))

 (defn read-body [response]
-  (update response :body parse-json))
+  (let [content-type (get-in response [:headers "Content-Type"])]
+    (if (str/starts-with? content-type "application/json")
+      (update response :body parse-json)
+      response)))

 (defn app [request]
   (-> request router/app read-body))
@@ -63,6 +66,9 @@
   (assert (predicate response)
           (str "Unexpected response " response))
   response)
+
+
+;;;; API Helpers

 (defn login! [app]
   (let [response (-> (request :post "/api/login")
@@ -77,6 +83,69 @@
       app
       (assert-response ok?)))

+(defn get-user-id [session]
+  (let [response (-> (request :get "/api/settings")
+                     (merge session)
+                     app
+                     (assert-response ok?))
+        user-id (UUID/fromString (:id (:user (:body response))))]
+    user-id))
+
+(defn try-create-congregation! [session name]
+  (-> (request :post "/api/congregations")
+      (json-body {:name name})
+      (merge session)
+      app))
+
+(defn create-congregation! [session name]
+  (let [response (-> (try-create-congregation! session name)
+                     (assert-response ok?))
+        cong-id (UUID/fromString (:id (:body response)))]
+    cong-id))
+
+(defn try-rename-congregation! [session cong-id name]
+  (-> (request :post (str "/api/congregation/" cong-id "/rename"))
+      (json-body {:name name})
+      (merge session)
+      app))
+
+(defn try-add-user! [session cong-id user-id]
+  (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
+      (json-body {:userId (str user-id)})
+      (merge session)
+      app))
+
+(defn create-congregation-without-user! [name]
+  (let [cong-id (UUID/randomUUID)
+        state (projections/cached-state)]
+    (db/with-db [conn {}]
+      (dispatcher/command! conn state
+                           {:command/type :congregation.command/create-congregation
+                            :command/time (Instant/now)
+                            :command/system "test"
+                            :congregation/id cong-id
+                            :congregation/name name}))
+    (projections/refresh-async!)
+    (projections/await-refreshed (Duration/ofSeconds 1))
+    cong-id))
+
+(defn revoke-access-from-all! [cong-id]
+  (let [state (projections/cached-state)
+        user-ids (congregation/get-users state cong-id)]
+    (db/with-db [conn {}]
+      (doseq [user-id user-ids]
+        (dispatcher/command! conn state
+                             {:command/type :congregation.command/set-user-permissions
+                              :command/time (Instant/now)
+                              :command/system "test"
+                              :congregation/id cong-id
+                              :user/id user-id
+                              :permission/ids []})))
+    (projections/refresh-async!)
+    (projections/await-refreshed (Duration/ofSeconds 1))))
+
+
+;;;; Tests

 (deftest format-for-api-test
   (is (= {} (api/format-for-api {})))
@@ -244,26 +313,8 @@
                          app)]
         (is (unauthorized? response))))))

-(defn- get-user-id [session]
-  (let [response (-> (request :get "/api/settings")
-                     (merge session)
-                     app)]
-    (assert (ok? response) {:response response})
-    (UUID/fromString (get-in (json/parse-string (:body response)) [:user :id]))))
-
-(defn- create-congregation! [name]
-  (db/with-db [conn {}]
-    (let [cong-id (UUID/randomUUID)]
-      (dispatcher/command! conn (projections/cached-state)
-                           {:command/type :congregation.command/create-congregation
-                            :command/time (Instant/now)
-                            :command/system "test"
-                            :congregation/id cong-id
-                            :congregation/name name})
-      cong-id)))
-
 (deftest super-user-test
-  (let [cong-id (create-congregation! "sudo test")
+  (let [cong-id (create-congregation-without-user! "sudo test")
         session (login! app)
         user-id (get-user-id session)]

@@ -293,36 +344,29 @@
                        (str cong-id)))))

     (testing "super user can configure all congregations"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str user-id)})
-                         (merge session)
-                         app)]
+      (let [response (try-add-user! session cong-id user-id)]
         (is (ok? response))))))

 (deftest create-congregation-test
   (let [session (login! app)
         user-id (get-user-id session)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "foo"})
-                     (merge session)
-                     app)]
+        response (try-create-congregation! session "foo")]
     (is (ok? response))
     (is (:id (:body response)))

-    (let [cong-id (UUID/fromString (:id (:body response)))]
+    (let [cong-id (UUID/fromString (:id (:body response)))
+          state (projections/cached-state)]
       (testing "grants access to the current user"
-        (is (= 1 (count (congregation/get-users (projections/cached-state) cong-id)))))
+        (is (= 1 (count (congregation/get-users state cong-id)))))

       (testing "creates a GIS user for the current user"
-        (let [gis-user (gis-user/get-gis-user (projections/cached-state) cong-id user-id)]
+        (let [gis-user (gis-user/get-gis-user state cong-id user-id)]
           (is gis-user)
           (is (true? (db/with-db [conn {:read-only? true}]
                        (gis-db/user-exists? conn (:gis-user/username gis-user)))))))))

   (testing "requires login"
-    (let [response (-> (request :post "/api/congregations")
-                       (json-body {:name "foo"})
-                       app)]
+    (let [response (try-create-congregation! nil "foo")]
       (is (unauthorized? response)))))

 (deftest list-congregations-test
@@ -338,29 +382,9 @@
                        app)]
       (is (unauthorized? response)))))

-(defn revoke-access-from-all! [cong-id]
-  (db/with-db [conn {}]
-    (let [state (projections/cached-state)]
-      (doseq [user-id (congregation/get-users state cong-id)]
-        (dispatcher/command! conn state
-                             {:command/type :congregation.command/set-user-permissions
-                              :command/time (Instant/now)
-                              :command/system "test"
-                              :congregation/id cong-id
-                              :user/id user-id
-                              :permission/ids []}))))
-  (projections/refresh-async!)
-  (projections/await-refreshed (Duration/ofSeconds 1)))
-
-
 (deftest get-congregation-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "foo"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))]
+        cong-id (create-congregation! session "foo")]

     (testing "get congregation"
       (let [response (-> (request :get (str "/api/congregation/" cong-id))
@@ -392,12 +416,7 @@

 (deftest get-demo-congregation-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "foo"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))]
+        cong-id (create-congregation-without-user! "foo")]
     (binding [config/env (assoc config/env :demo-congregation cong-id)]

       (testing "get demo congregation"
@@ -428,12 +447,7 @@
 (deftest download-qgis-project-test
   (let [session (login! app)
         user-id (get-user-id session)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Example Congregation"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))]
+        cong-id (create-congregation! session "Example Congregation")]

     (let [response (-> (request :get (str "/api/congregation/" cong-id "/qgis-project"))
                        (merge session)
@@ -470,57 +484,34 @@

 (deftest add-user-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Congregation"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))
+        cong-id (create-congregation! session "Congregation")
         new-user-id (db/with-db [conn {}]
                       (user/save-user! conn "user1" {:name "User 1"}))]

     (testing "add user"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str new-user-id)})
-                         (merge session)
-                         app)]
-        (is (ok? response)))
-      ;; TODO: check the result through the API
-      (let [users (congregation/get-users (projections/cached-state) cong-id)]
-        (is (contains? (set users) new-user-id))))
+      (let [response (try-add-user! session cong-id new-user-id)]
+        (is (ok? response))
+        ;; TODO: check the result through the API
+        (let [users (congregation/get-users (projections/cached-state) cong-id)]
+          (is (contains? (set users) new-user-id)))))

     (testing "invalid user"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str (UUID. 0 1))})
-                         (merge session)
-                         app)]
+      (let [response (try-add-user! session cong-id (UUID. 0 1))]
         (is (bad-request? response))
         (is (= {:errors [["no-such-user" "00000000-0000-0000-0000-000000000001"]]}
                (:body response)))))

     (testing "no access"
       (revoke-access-from-all! cong-id)
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                         (json-body {:userId (str new-user-id)})
-                         (merge session)
-                         app)]
+      (let [response (try-add-user! session cong-id new-user-id)]
         (is (forbidden? response))))))

 (deftest set-user-permissions-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Congregation"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))
+        cong-id (create-congregation! session "Congregation")
         user-id (db/with-db [conn {}]
                   (user/save-user! conn "user1" {:name "User 1"}))]
-    (let [response (-> (request :post (str "/api/congregation/" cong-id "/add-user"))
-                       (json-body {:userId (str user-id)})
-                       (merge session)
-                       app)]
-      (is (ok? response)))
+    (is (ok? (try-add-user! session cong-id user-id)))

     ;; TODO: test changing permissions (after new users no more get full admin access)?

@@ -556,18 +547,10 @@

 (deftest rename-congregation-test
   (let [session (login! app)
-        response (-> (request :post "/api/congregations")
-                     (json-body {:name "Old Name"})
-                     (merge session)
-                     app
-                     (assert-response ok?))
-        cong-id (UUID/fromString (:id (:body response)))]
+        cong-id (create-congregation! session "Old Name")]

     (testing "rename congregation"
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/rename"))
-                         (json-body {:name "New Name"})
-                         (merge session)
-                         app)]
+      (let [response (try-rename-congregation! session cong-id "New Name")]
         (is (ok? response)))
       (let [response (-> (request :get (str "/api/congregation/" cong-id))
                          (merge session)
@@ -577,8 +560,5 @@

     (testing "no access"
       (revoke-access-from-all! cong-id)
-      (let [response (-> (request :post (str "/api/congregation/" cong-id "/rename"))
-                         (json-body {:name "should not be allowed"})
-                         (merge session)
-                         app)]
+      (let [response (try-rename-congregation! session cong-id "should not be allowed")]
         (is (forbidden? response))))))


add option to setup socket option so_rcvbuf

--- src/riemann/transport/udp.clj
+++ src/riemann/transport/udp.clj
@@ -54,6 +54,7 @@
 (defrecord UDPServer [^String host
                       ^int port
                       max-size
+                      ^int so-rcvbuf
                       ^ChannelGroup channel-group
                       ^ChannelHandler handler
                       stats
@@ -91,6 +92,7 @@
                   (.option ChannelOption/SO_BROADCAST false)
                   (.option ChannelOption/MESSAGE_SIZE_ESTIMATOR
                            (DefaultMessageSizeEstimator. max-size))
+                  (.option ChannelOption/SO_RCVBUF so-rcvbuf)
                   (.handler handler))

                 ; Start bootstrap
@@ -141,6 +143,7 @@
   :host             The address to listen on (default 127.0.0.1).
   :port             The port to listen on (default 5555).
   :max-size         The maximum datagram size (default 16384 bytes).
+  :so-rcvbuf        The socket option for receive buffer in bytes (SO_RCVBUF)
   :channel-group    A ChannelGroup used to track all connections
   :initializer      A ChannelInitializer"
   ([] (udp-server {}))
@@ -150,6 +153,7 @@
          host  (get opts :host "127.0.0.1")
          port  (get opts :port 5555)
          max-size (get opts :max-size 16384)
+         so-rcvbuf (get opts :so-rcvbuf 124928)
          channel-group (get opts :channel-group
                             (channel-group
                               (str "udp-server" host ":" port "(" max-size ")")))
@@ -160,4 +164,4 @@
                    ^:shared msg-decoder      (msg-decoder)
                    ^{:shared true :executor shared-event-executor} handler
                    (gen-udp-handler core stats channel-group udp-handler)))]
-     (UDPServer. host port max-size channel-group ci stats core (atom nil)))))
+     (UDPServer. host port max-size so-rcvbuf channel-group ci stats core (atom nil)))))


use a normal image

use a normal image

--- src-cljs/frontend/components/clip_viewer.cljs
+++ src-cljs/frontend/components/clip_viewer.cljs
@@ -50,7 +50,7 @@
              [:div.clip.make
               [:a.recent-doc {:role "button"
                               :on-click #(cast! :clip-pasted clip)}
-               [:object {:data (:clip/s3-url clip) :type "image/svg+xml"}]
+               [:img {:src (:clip/s3-url clip)}]
                [:i.loading-ellipses
                 [:i "."]
                 [:i "."]


Remove confusing destructuring in build nav controller

The :container-id key is now always contained in the args map, and can
have a value of nil. The :or part of the destructuring here is no longer
necessary since the :container-id is always present in the map being
passed in.

--- src-cljs/frontend/controllers/navigation.cljs
+++ src-cljs/frontend/controllers/navigation.cljs
@@ -128,8 +128,7 @@

 (defmethod navigated-to :build
   [history-imp navigation-point {:keys [vcs_type project-name build-num org repo tab container-id action-id]
-                                 :as args
-                                 :or {container-id 0}}
+                                 :as args}
    state]
   (mlog "navigated-to :build with args " args)
   (if (and (= :build (state/current-view state))


delete unused folder

delete unused folder


Move instruments after code will be showing.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -45,6 +45,152 @@
   (->> (clapping-music)
        live/play))

+(defn vary [t f]
+  (fn [notes]
+    (let [before? #(-> % :time (< t))
+          before (->> notes (take-while before?))
+          [note & after] (->> notes (drop-while before?))]
+      (concat before (f note) after))))
+
+(defn split [t fraction]
+  (letfn [(f [note]
+            [(-> note
+                 (assoc :duration fraction))
+             (-> note
+                 (update-in [:duration] - fraction)
+                 (update-in [:time] + fraction))])]
+    (vary t f)))
+
+(defn accent [t]
+  (letfn [(f [note] [(-> note (update-in [:pitch] dec))])]
+    (vary t f)))
+
+(defn omit [t]
+  (vary t (constantly [])))
+
+(defn rand-variations [variations]
+  (let [variation (rand-nth variations)]
+    (concat
+      variation
+      (lazy-seq
+        (->> (rand-variations variations)
+             (after (duration variation) ))))))
+
+(defn part [model & variations]
+  ((apply juxt identity variations) model))
+
+(def tete
+  (let [model (phrase [8/4 3/4 5/4] (repeat 0))
+        a (split 0 1/4)
+        b (comp (split 1/4 1/4) a)
+        c (comp (accent 2/4) (split 2/4 1/4) b)
+        d (comp (omit 0/4) c)]
+    (part model a b c d)))
+
+(def ta
+  (let [model (->> (phrase [5/4 3/4 4/4] (repeat 1)) (after 4/4))
+        a (split 9/4 1/4)
+        b (comp (split 10/4 1/4) a)
+        c (comp (accent 11/4) (split 11/4 1/8) b) ; 17
+        d (split 4/4 1/4)
+        e (comp (omit 10/4) c)] ; 8
+    (part model a b c d e)))
+
+(def ha
+  (let [model (->> (phrase [12/4 2/4] (repeat 2)) (after 2/4))
+        a (comp (split 2/4 1/4) (split 0 1/4))
+        b (comp (split 6/4 1/4))
+        c (comp (split 0 1/4) b)
+        d (comp a b)]
+    (part model a b c d)))
+
+(def tulule
+  (let [model (phrase [8/4 8/4] (repeat 3))
+        a (comp (split 8/4 2/4) (split 0 2/4)) ; 28
+        b (comp (split 0 1/4) (split 2/4 1/4) a) ; 6
+        c (comp (accent 7/8) (split 3/4 1/8) b)] ; 5
+    (part model a b c)))
+
+(def bongo
+  (let [model (->> (phrase [3/4 7/4] (repeat 4)) (after 6/4)) ; 5
+        a (split 9/4 5/4) ; 6
+        b (comp (split 6/4 1/4) a) ; 9
+        c (comp (split 14/4 1/4) b) ; 8
+        d (comp (accent 10/4) (split 9/4 1/4) b)] ; 19
+    (part model a b c d)))
+
+(defn big [notes]
+  (->> notes
+       (map (partial where :pitch #(+ % 5)))))
+
+(defn pan [{:keys [pitch] :as note}]
+  (if pitch
+    (let [p (-> note :pitch (/ 18) dec)]
+      (if (odd? pitch)
+        (assoc note :pan (- p))
+        (assoc note :pan p)))
+    note))
+
+(def ndereje-balendoro ; p 343
+  (->> [tete ta ha tulule bongo
+        (big tete) (big ta) (big ha) (big tulule) (big bongo)
+        (big (big tete)) (big (big ta)) (big (big ha)) (big (big tulule)) (big (big bongo))
+        (big (big (big tete))) (big (big (big ta))) (big (big (big ha)))]
+       ;(map (comp list first))
+       (map rand-variations)
+       (map after (range 0 (* 4 18) 4))
+       (reduce with)
+       (map pan)))
+
+(comment
+  (->>
+    ndereje-balendoro
+    (where :pitch (comp temperament/equal A car))
+    (tempo (bpm 120))
+    (live/play)))
+
+(def first-drum
+  (let [model (->> (rhythm [2/5 3/5 1/5 1/5 3/5]) (all :part :clap1))
+        a (split 6/5 1/10)
+        b (split 5/5 1/10)
+        c (comp (split 17/15 2/15) (split 5/5 2/15) (omit 6/5))
+        d (comp (omit 7/5) (omit 6/5))]
+    (part model a b c d)))
+
+(def second-drum
+  (let [model (->> (rhythm [2/5 2/5 4/5 1/5 1/5]) (all :part :clap2))
+        a (omit 9/5)
+        b (omit 0)
+        c (comp a b)
+        d #(then % (->> (rhythm (repeat 5 2/5)) (all :part :clap2)))]
+    (part model a b c d)))
+
+(def third-drum
+  (let [model (->> (rhythm [2/5 1/5 2/5]) (all :part :clap3))
+        a (omit 2/5)
+        b (omit 3/5)
+        c (comp (split 0 1/5) a)
+        d (split 3/5 1/5)
+        e (comp (split 3/5 1/10) d)
+        f (split 0 1/5)
+        g (comp (split 0 1/10) f)]
+    (part model a b c d e f g)))
+
+(def aga-terumo ; p299
+  (let [drums [first-drum second-drum third-drum]]
+    (->> drums
+         ;(map (comp list first))
+         (map rand-variations)
+         (map after (range 0 (* 4 3) 4))
+         (reduce with))))
+
+(comment
+  (->>
+    aga-terumo
+    (tempo (bpm 90))
+    (live/play)))
+
+; Instruments
 (definst drum [freq 440 vol 0.5 pan 0]
   (-> (* 2/3 (brown-noise))
       (+ (* 1/2 (sin-osc (* 3 freq))))
@@ -63,29 +209,6 @@

 (defmethod live/play-note :clap3 [_]
   (drum 75 :pan 0))
-
-(defn vary [t f]
-  (fn [notes]
-    (let [before? #(-> % :time (< t))
-          before (->> notes (take-while before?))
-          [note & after] (->> notes (drop-while before?))]
-      (concat before (f note) after))))
-
-(defn split [t fraction]
-  (letfn [(f [note]
-            [(-> note
-                 (assoc :duration fraction))
-             (-> note
-                 (update-in [:duration] - fraction)
-                 (update-in [:time] + fraction))])]
-    (vary t f)))
-
-(defn accent [t]
-  (letfn [(f [note] [(-> note (update-in [:pitch] dec))])]
-    (vary t f)))
-
-(defn omit [t]
-  (vary t (constantly [])))

 (definst horn [freq 440 vol 0.5 pan 0]
   (-> (sin-osc freq)
@@ -101,125 +224,3 @@

 (defmethod live/play-note :default [{:keys [pitch pan]}]
   (when pitch (horn :freq pitch :pan (or pan 0))))
-
-(defn rand-variations [variations]
-  (let [variation (rand-nth variations)]
-    (concat
-      variation
-      (lazy-seq
-        (->> (rand-variations variations)
-             (after (duration variation) ))))))
-
-(defn part [model & variations]
-  ((apply juxt identity variations) model))
-
-(def tete
-  (let [model (phrase [8/4 3/4 5/4] (repeat 0))
-        a (split 0 1/4)
-        b (comp (split 1/4 1/4) a)
-        c (comp (accent 2/4) (split 2/4 1/4) b)
-        d (comp (omit 0/4) c)]
-    (part model a b c d)))
-
-(def ta
-  (let [model (->> (phrase [5/4 3/4 4/4] (repeat 1)) (after 4/4))
-        a (split 9/4 1/4)
-        b (comp (split 10/4 1/4) a)
-        c (comp (accent 11/4) (split 11/4 1/8) b) ; 17
-        d (split 4/4 1/4)
-        e (comp (omit 10/4) c)] ; 8
-    (part model a b c d e)))
-
-(def ha
-  (let [model (->> (phrase [12/4 2/4] (repeat 2)) (after 2/4))
-        a (comp (split 2/4 1/4) (split 0 1/4))
-        b (comp (split 6/4 1/4))
-        c (comp (split 0 1/4) b)
-        d (comp a b)]
-    (part model a b c d)))
-
-(def tulule
-  (let [model (phrase [8/4 8/4] (repeat 3))
-        a (comp (split 8/4 2/4) (split 0 2/4)) ; 28
-        b (comp (split 0 1/4) (split 2/4 1/4) a) ; 6
-        c (comp (accent 7/8) (split 3/4 1/8) b)] ; 5
-    (part model a b c)))
-
-(def bongo
-  (let [model (->> (phrase [3/4 7/4] (repeat 4)) (after 6/4)) ; 5
-        a (split 9/4 5/4) ; 6
-        b (comp (split 6/4 1/4) a) ; 9
-        c (comp (split 14/4 1/4) b) ; 8
-        d (comp (accent 10/4) (split 9/4 1/4) b)] ; 19
-    (part model a b c d)))
-
-(defn big [notes]
-  (->> notes
-       (map (partial where :pitch #(+ % 5)))))
-
-(defn pan [{:keys [pitch] :as note}]
-  (if pitch
-    (let [p (-> note :pitch (/ 18) dec)]
-      (if (odd? pitch)
-        (assoc note :pan (- p))
-        (assoc note :pan p)))
-    note))
-
-(def ndereje-balendoro ; p 343
-  (->> [tete ta ha tulule bongo
-        (big tete) (big ta) (big ha) (big tulule) (big bongo)
-        (big (big tete)) (big (big ta)) (big (big ha)) (big (big tulule)) (big (big bongo))
-        (big (big (big tete))) (big (big (big ta))) (big (big (big ha)))]
-       ;(map (comp list first))
-       (map rand-variations)
-       (map after (range 0 (* 4 18) 4))
-       (reduce with)
-       (map pan)))
-
-(comment
-  (->>
-    ndereje-balendoro
-    (where :pitch (comp temperament/equal A car))
-    (tempo (bpm 120))
-    (live/play)))
-
-(def first-drum
-  (let [model (->> (rhythm [2/5 3/5 1/5 1/5 3/5]) (all :part :clap1))
-        a (split 6/5 1/10)
-        b (split 5/5 1/10)
-        c (comp (split 17/15 2/15) (split 5/5 2/15) (omit 6/5))
-        d (comp (omit 7/5) (omit 6/5))]
-    (part model a b c d)))
-
-(def second-drum
-  (let [model (->> (rhythm [2/5 2/5 4/5 1/5 1/5]) (all :part :clap2))
-        a (omit 9/5)
-        b (omit 0)
-        c (comp a b)
-        d #(then % (->> (rhythm (repeat 5 2/5)) (all :part :clap2)))]
-    (part model a b c d)))
-
-(def third-drum
-  (let [model (->> (rhythm [2/5 1/5 2/5]) (all :part :clap3))
-        a (omit 2/5)
-        b (omit 3/5)
-        c (comp (split 0 1/5) a)
-        d (split 3/5 1/5)
-        e (comp (split 3/5 1/10) d)
-        f (split 0 1/5)
-        g (comp (split 0 1/10) f)]
-    (part model a b c d e f g)))
-
-(def aga-terumo ; p299
-  (let [drums [first-drum second-drum third-drum]]
-    (->> drums
-         ;(map (comp list first))
-         (map rand-variations)
-         (map after (range 0 (* 4 3) 4))
-         (reduce with))))
-
-(comment
-  (->>
-    aga-terumo
-    (tempo (bpm 90))
-    (live/play)))


Atom committers error

Atom committers error

--- src/atom_finder/questions/atom_committers.clj
+++ src/atom_finder/questions/atom_committers.clj
@@ -33,7 +33,7 @@
            (remove empty?)
            (map prn)
            dorun
-          (log-err (str "atom-committers " (->> rev-commit :srcs first :rev-str)) {})
+          (log-err "atom-committers " {})
           )))
        (log-to "tmp/atom-committers_gcc_2018-01-07_02_continuation.edn")
        time-mins


simplify form

simplify form

--- src/cljs/clj_money/api/transaction_items.cljs
+++ src/cljs/clj_money/api/transaction_items.cljs
@@ -17,8 +17,7 @@
    (api/get-resources (api/path :transaction-items)
                       criteria
                       options
-                      (fn [items]
-                        (success-fn (map after-read items)))
+                      #(success-fn (map after-read %))
                       error-fn)))

 (defn search-a


Refactored code.

Refactored code.

--- src/cmr/bootstrap/services/health_service.clj
+++ src/cmr/bootstrap/services/health_service.clj
@@ -13,9 +13,7 @@
         indexer-health (indexer/health indexer-context)
         internal-meta-db-context (assoc context :system (get-in context [:system :metadata-db]))
         internal-meta-db-health (ps/health internal-meta-db-context)
-        ok? (and (:ok? metadata-db-health)
-                 (:ok? internal-meta-db-health)
-                 (:ok? indexer-health))]
+        ok? (every? :ok? [metadata-db-health internal-meta-db-health indexer-health])]
     {:ok? ok?
      :dependencies {:metadata-db metadata-db-health
                     :internal-meta-db internal-meta-db-health


small bugfix in statuses.views.common/linkify

--- src/statuses/views/common.clj
+++ src/statuses/views/common.clj
@@ -49,6 +49,6 @@
         anchor  (fn [[m _]] (str "" m ""))]
     (-> text
         escape-html
-        (clojure.string/replace #"@(\w*)" handle)
+        (clojure.string/replace #"@(\w+)" handle)
         (clojure.string/replace uri anchor)
-        (clojure.string/replace #"#(\w*)" hashtag))))
+        (clojure.string/replace #"#(\w+)" hashtag))))


(PDB-240) Replace anonymize.clj read-string with clojure.edn/read-string

This patch replaces a call to read-string in anonymize.clj with a call to
clojure.edn/read-string. Unlike clojure.core/read-string,
clojure.edn/read-string is safe to use with untrusted data and guaranteed to
be free of side-effects.

--- src/com/puppetlabs/puppetdb/cli/anonymize.clj
+++ src/com/puppetlabs/puppetdb/cli/anonymize.clj
@@ -255,7 +255,7 @@
 (defn -main
   [& args]
   (let [[{:keys [outfile infile profile config]} _] (validate-cli! args)
-        extra-config                                (if (empty? config) {} (read-string (slurp config)))
+        extra-config                                (if (empty? config) {} (clojure.edn/read-string (slurp config)))
         profile-config                              (get (merge anon-profiles extra-config) profile)
         metadata                                    (parse-metadata infile)]


Tighten the fact-value anonymization for the moderate profile

--- src/com/puppetlabs/puppetdb/cli/anonymize.clj
+++ src/com/puppetlabs/puppetdb/cli/anonymize.clj
@@ -92,12 +92,12 @@
         "fact-value"
         [{"context" {"fact-name" ["/password/" "/pwd/" "/secret/" "/key/" "/private/"]}
           "anonymize" true}
-         {"context" {"fact-name" ["/architecture/" "/augeasversion.*/" "/bios_.*/" "/blockdevice.*/" "/board.*/" "/facterversion/"
-                                  "/hardwareisa/" "/hardwaremodel/" "/id/" "/interfaces/" "/iptables.*/" "/ip6tables.*/" "/is_pe/"
-                                  "/is_virtual/" "/kernel.*/" "/lsb.*/" "/macosx.*/" "/memory.*/" "/mtu_.*/" "/netmask.*/"
-                                  "/operatingsystem.*/" "/osfamily/" "/postgres_.*/" "/processor.*/" "/physicalprocessorcount.*/"
-                                  "/productname/" "/ps/" "/puppetversion/" "/rubysitedir/" "/rubyversion/" "/selinux.*/"
-                                  "/swapencrypted/" "/swapfree.*/" "/swapsize.*/" "/timezone/" "/uptime.*/" "/virtual/"]}
+         {"context" {"fact-name" ["architecture" "/^augeasversion.*/" "/^bios_.*/" "/^blockdevice.*/" "/^board.*/" "facterversion"
+                                  "hardwareisa" "hardwaremodel" "id" "interfaces" "/^iptables.*/" "/^ip6tables.*/" "is_pe"
+                                  "is_virtual" "/^kernel.*/" "/^lsb.*/" "/^macosx.*/" "/^memory.*/" "/^mtu_.*/" "/^netmask.*/"
+                                  "/^operatingsystem.*/" "osfamily" "/^postgres_.*/" "/^processor.*/" "/^physicalprocessorcount.*/"
+                                  "productname" "ps" "puppetversion" "rubysitedir" "rubyversion" "/^selinux.*/"
+                                  "swapencrypted" "/^swapfree.*/" "/^swapsize.*/" "timezone" "/^uptime.*/" "virtual"]}
           "anonymize" false}
          {"context" {} "anonymize" true}]}
     }


Made interpret to locally memoize its results

don't know whether this does anything useful...

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

--- src/conexp/contrib/dl/framework/semantics.clj
+++ src/conexp/contrib/dl/framework/semantics.clj
@@ -45,7 +45,7 @@
                                                    (model-interpretation model))))]
     (.write out (.trim output))))

-;;; Interpretation
+;;; Interpretations

 (defmulti compile-expression
   "Compiles an expression to a function mapping a model to the extent
@@ -105,7 +105,7 @@
      (fn [~model]
        ~@body)))

-;;;
+;;; Model Syntax

 (defmacro model
   "Defines model for language on base-set: interpretation maps atomic
@@ -129,7 +129,7 @@
   [name language base-set & interpretation]
   `(def ~name (model ~language ~base-set ~@interpretation)))

-;;;
+;;; Most Specific Concepts

 (defmulti most-specific-concept
   "Computes the model based most specific concept of a set of objects
@@ -151,7 +151,8 @@
   "Return the most specific concept of the interpretation of dl-exp in
   model."
   [model dl-exp]
-  (most-specific-concept model (interpret model dl-exp)))
+  (with-memoized-fns [interpret]        ;?
+    (most-specific-concept model (interpret model dl-exp))))

 ;;;


Better naming

Better naming

--- src/cylon/oauth/impl/authorization_server.clj
+++ src/cylon/oauth/impl/authorization_server.clj
@@ -27,31 +27,34 @@
   (request-handlers [this]
     {::authorize
      (-> (fn [req]
-        ;; TODO Establish whether the user-agent is already authenticated.
-        ;; If not, create a session with client-id, scope and state and redirect to the login form
-        (if-let [session
-                 (get-session
-                  (:session-store this)
-                  (-> req cookies-request :cookies (get SESSION-ID) :value))]
-          ;; TODO Obey the 'prompt' value in OpenID/Connect
-          (do
-            (infof "Hi - it appears you're already logged in, session is %s" (pr-str session))
-            {:status 302
-             :headers {"Location" (path-for (:modular.bidi/routes req) ::get-authenticate-form)}})
-          (let [session (create-session!
-                         (:session-store this)
-                         {:client-id (-> req :query-params (get "client_id"))
-                          :scope (-> req :query-params (get "scope"))
-                          :state (-> req :query-params (get "state"))
-                          })]
-            (infof "Hi - it appears you're not already logged in, so I'm going to create a session for you and redirect you")
-            (cookies-response
-                      {:status 302
-                       :headers {"Location" (path-for (:modular.bidi/routes req) ::get-authenticate-form)}
-                       :cookies {SESSION-ID (->cookie session)}}))))
+           ;; TODO Establish whether the user-agent is already authenticated.
+           ;; If not, create a session with client-id, scope and state and redirect to the login form
+           (let [session-id (-> req cookies-request :cookies (get SESSION-ID) :value)]
+             (infof "Session id is %s" session-id)
+             (if-let [session
+                      (get-session
+                       (:session-store this)
+                       session-id)]
+               ;; TODO Obey the 'prompt' value in OpenID/Connect
+               (do
+                 (infof "Hi - it appears you're already logged in, session is %s" (pr-str session))
+                 {:status 302
+                  :headers {"Location" (path-for (:modular.bidi/routes req) ::get-login-form)}})
+
+               (let [session (create-session!
+                              (:session-store this)
+                              {:client-id (-> req :query-params (get "client_id"))
+                               :scope (-> req :query-params (get "scope"))
+                               :state (-> req :query-params (get "state"))
+                               })]
+                 (infof "Hi - it appears you're not already logged in, so I'm going to create a session for you and redirect you")
+                 (cookies-response
+                  {:status 302
+                   :headers {"Location" (path-for (:modular.bidi/routes req) ::get-login-form)}
+                   :cookies {SESSION-ID (->cookie session)}})))))
          wrap-params)

-     ::get-authenticate-form
+     ::get-login-form
      (->
       (fn [req]
         {:status 200
@@ -61,7 +64,7 @@
                  [:p "The application with client id " (get-session-value req  SESSION-ID (:session-store this) :client-id)
                   " is requesting access to the Azondi API on your behalf. Please login if you are happy to authorize this client."]
                  [:form {:method :post
-                         :action (path-for (:modular.bidi/routes req) ::post-authenticate-form)}
+                         :action (path-for (:modular.bidi/routes req) ::post-login-form)}
                   [:p
                    [:label {:for "user"} "User"]
                    [:input {:name "user" :id "user" :type "text"}]]
@@ -72,7 +75,7 @@
                   [:p [:a {:href (path-for (:modular.bidi/routes req) :cylon.impl.signup/signup-form)} "Signup"]]]])})
       wrap-params)

-     ::post-authenticate-form
+     ::post-login-form
      (-> (fn [req]
            (let [params (-> req :form-params)
                  identity (get params "user")
@@ -119,8 +122,8 @@
                                      :state state)

                      (cookies-response {:status 302
-                       :headers {"Location" (path-for (:modular.bidi/routes req) ::get-totp-code)}
-                       :cookies {SESSION-ID (->cookie session)}}))
+                                        :headers {"Location" (path-for (:modular.bidi/routes req) ::get-totp-code)}
+                                        :cookies {SESSION-ID (->cookie session)}}))

                    ;; So it's not 2FA, continue with OAuth exchange
                    ;; Generate the temporary code that we'll exchange for an access token later
@@ -133,16 +136,16 @@
                              :cylon/identity identity})

                      (cookies-response {:status 302
-                       :headers {"Location"
-                                 (format
-                                  ;; TODO: Replace this with the callback uri
-                                  "%s?code=%s&state=%s"
-                                  callback-uri code state
-                                  )}
-                       :cookies {SESSION-ID (->cookie session)}}))))
+                                        :headers {"Location"
+                                                  (format
+                                                   ;; TODO: Replace this with the callback uri
+                                                   "%s?code=%s&state=%s"
+                                                   callback-uri code state
+                                                   )}
+                                        :cookies {SESSION-ID (->cookie session)}}))))
                ;; Fail
                {:status 302
-                :headers {"Location" (format "%s" (path-for (:modular.bidi/routes req) ::get-authenticate-form))}
+                :headers {"Location" (format "%s" (path-for (:modular.bidi/routes req) ::get-login-form))}
                 :body "Try again"})))

          wrap-params wrap-cookies s/with-fn-validation)
@@ -246,8 +249,8 @@

   (routes [this]
     ["/" {"authorize" {:get ::authorize}
-          "login" {:get ::get-authenticate-form
-                   :post ::post-authenticate-form}
+          "login" {:get ::get-login-form
+                   :post ::post-login-form}
           "totp" {:get ::get-totp-code
                   :post ::post-totp-code}
           "access_token" {:post ::exchange-code-for-access-token}}])


Make the tests pass

Make the tests pass

--- src/desdemona/launcher/aeron_media_driver.clj
+++ src/desdemona/launcher/aeron_media_driver.clj
@@ -55,5 +55,5 @@
   (let [{:keys [options errors summary]} (parse-opts args cli-options)]
     (cond
       (options :help) (exit! 0 (usage summary))
-      errors (exit! 1 (concat (cli-error-msg errors) (usage summary)))
+      errors (exit! 1 (into errors (usage summary)))
       :else (run-media-driver-and-block! options))))


Make kibit happy.

Make kibit happy.

--- src/oc/storage/api/boards.clj
+++ src/oc/storage/api/boards.clj
@@ -101,7 +101,7 @@
     (try
       (let [notifications (:private-notifications board-map)
             entry-data (map #(valid-entry-with-board?
-                               conn (assoc % :status (or (:status %) "published")) author) (:entries board-map))
+                               conn (update-in % [:status] or "published") author) (:entries board-map))
             board-data (-> board-map
                         (dissoc :private-notifications :note)
                         (assoc :entries entry-data))]


Re-enable riemann metrics

Re-enable riemann metrics

--- src/onyx_benchmark/submit.clj
+++ src/onyx_benchmark/submit.clj
@@ -15,13 +15,13 @@
     :lifecycle/calls :onyx-benchmark.peer/no-op-calls}
    {:lifecycle/task :no-op
     :lifecycle/calls :onyx.plugin.core-async/writer-calls}
-   {:lifecycle/task :all ; or :task-name for an individual task
+   #_{:lifecycle/task :all ; or :task-name for an individual task
     :lifecycle/calls :onyx.lifecycle.metrics.metrics/calls
     :metrics/buffer-capacity 10000
     :metrics/workflow-name "your-workflow-name"
     :metrics/sender-fn :onyx.lifecycle.metrics.timbre/timbre-sender
     :lifecycle/doc "Instruments a task's metrics to timbre"}
-   #_{:lifecycle/task :all
+   {:lifecycle/task :all
     :lifecycle/calls :onyx.lifecycle.metrics.metrics/calls
     :metrics/buffer-capacity 10000
     :metrics/workflow-name "bench-workflow"
@@ -96,5 +96,5 @@
                           :acker/percentage 20
                           :acker/exempt-input-tasks? true
                           :task-scheduler :onyx.task-scheduler/balanced})
-    (<!! (chan))
-    ))
+    (println "Job successfully submitted")
+    (<!! (chan))))


capitalize user name before storing it in config

--- src/overtone/config/store.clj
+++ src/overtone/config/store.clj
@@ -3,13 +3,14 @@
      :author "Jeff Rose"}
   overtone.config.store
   (:use [overtone.config file-store]
+        [overtone.helpers.string :only [capitalize]]
         [overtone.util.lib :only [get-os system-user-name]]
         [overtone.helpers.file :only [mkdir! file-exists? mv!]]
         [clojure.java.io :only [delete-file]]))

 (def CONFIG-DEFAULTS
   {:os (get-os)
-   :user-name (system-user-name)})
+   :user-name (capitalize (system-user-name))})

 (defn config-get
   "Get config value"


add mv! file helper fn

add mv! file helper fn

--- src/overtone/helpers/file.clj
+++ src/overtone/helpers/file.clj
@@ -152,6 +152,15 @@
     (when-not (.exists f)
       (.mkdir f))))

+(defn mv!
+  "Moves a file from source to dest path"
+  [src dest]
+  (let [src    (resolve-tilde-path src)
+        dest   (resolve-tilde-path dest)
+        f-src  (File. src)
+        f-dest (File. dest)]
+    (.renameTo f-src f-dest)))
+
 (defn file-exists?
   "Returns true if the file specified by path exists"
   [path]


Make story and code wording match.

Make story and code wording match.

--- src/tryclojure/views/home.clj
+++ src/tryclojure/views/home.clj
@@ -67,7 +67,7 @@
            > play The Hallway

Are you sitting comfortably? Then, we shall begin.

            > look
-
You are in a hallway.  A candle burns in front of a mirror.
+
You are in a hallway.  A candle burns on a table.
            You can see a door.

            > open door

The door is locked.


+require dag_unify/unifyc: use it in preference to lexiconfn/unify

--- src/babel/english/pos.cljc
+++ src/babel/english/pos.cljc
@@ -2,11 +2,13 @@
   (:refer-clojure :exclude [get-in])
   (:require
    [babel.english.morphology :refer (fo)]
+   ;; TODO: use unify/unifyc, not lexiconfn/unify: they are (should be equivalent), and
+   ;; to have both is confusing.
    [babel.lexiconfn :as lexiconfn :refer (map-function-on-map-vals unify)]
    [babel.pos :as pos]
    #?(:clj [clojure.tools.logging :as log])
    #?(:cljs [babel.logjs :as log])
-   [dag_unify.core :as unify :refer (dissoc-paths get-in serialize)]))
+   [dag_unify.core :as unify :refer (dissoc-paths get-in serialize unifyc)]))

 (def adjective pos/adjective)
 (def animal pos/common-noun)


Don't include full namespace

Don't include full namespace

--- src/bejeweled_bot/core.clj
+++ src/bejeweled_bot/core.clj
@@ -12,8 +12,8 @@
 ;Mat mat = new Mat(width, height, CvType.CV_8UC3);
 ;mat.put(0, 0, data);

-(use 'bejeweled-bot.pixel-sampler)
-(use 'bejeweled-bot.gem-classifier)
+(use '[bejeweled-bot.pixel-sampler :only [sample-pixels]])
+(use '[bejeweled-bot.gem-classifier :only [rgb-to-gems]])

 (defn -main
   "I'm a doc string"
@@ -30,13 +30,14 @@
   (.copyTo sourceImg displayImg)
   (Imgproc/matchTemplate sourceImg diamond result Imgproc/TM_CCOEFF_NORMED)
   ;(Imgproc/matchTemplate sourceImg diamond result Imgproc/TM_CCORR_NORMED)
-  (def threshold 0.8)
+  ;(def threshold 0.8)
   (Core/normalize result result 0 255 Core/NORM_MINMAX -1 (Mat.))
   ;(Highgui/imwrite "resources/output.png" result)

   (def floatArr (make-array Float/TYPE (.total result)))
   (.get result 0 0 floatArr)

+  ;please refactor
   (def derp
     (reduce
     (fn [acc x]
@@ -53,7 +54,7 @@
   (def col (mod (:idx derp) cols))

   (def seees (sample-pixels col row (+ col targetCols) (+ row targetRows) displayImg))
-  (rgb-to-gems seees)
+  (println (rgb-to-gems seees)))

@@ -61,6 +62,4 @@
   ;(Core/rectangle result (Point. col row) (Point. (+ col targetCols) (+ row targetRows)) (Scalar. 0 0 255))
   ;;(Highgui/imwrite "resources/output.png" displayImg)
   ;(Highgui/imwrite "resources/output2.png" result)
-)
-
-(time (-main))
+;(time (-main))


Move constants to top of page.

Move constants to top of page.

--- src/videotest/coral/coral.clj
+++ src/videotest/coral/coral.clj
@@ -12,6 +12,13 @@
 (def CORAL-STROKE-WEIGHT 2.0)

 (def CORAL-ROT-CYCLE 120)
+
+(def BOTTOM-ATTACH-PCT 0.1)
+
+;; 127.5 = 180 degress (max on 0-255 scale)
+;; 21.25 = 30 degrees (on 0-255 scale)
+(def HUE-DIFF-CLIQUEY-THRESH-MAX 21.25)
+

 (defn coral-size [display-w display-h]
   (let [col-bins NUM-CORAL-COL-BINS
@@ -87,12 +94,6 @@

 (defn is-leaf? [odd-col-lower coral [col row :as coords]]
   (not (seq (occupied-coral-above odd-col-lower coral coords))))
-
-(def BOTTOM-ATTACH-PCT 0.1)
-
-;; 127.5 = 180 degress (max on 0-255 scale)
-;; 21.25 = 30 degrees (on 0-255 scale)
-(def HUE-DIFF-CLIQUEY-THRESH-MAX 21.25)

 (defn is-cliquey? [odd-col-lower coral coords this-hue]
   (if-let [occupied-under (seq


start-debug mode, clean up later

start-debug mode, clean up later

--- src/bitsplit_cli/core.cljs
+++ src/bitsplit_cli/core.cljs
@@ -46,9 +46,12 @@
   (let [storage (->File splits-location)
         client (->Client (str base-directory "seed"))
         system {:storage storage :client client}]
-    (if (start? cmd)
+    (if  (or (= "start-debug" cmd) (start? cmd))
       (do
-        (set! *print-fn* (open-log (str base-directory "logfile")))
+        (set! *print-fn*
+              (if (start? cmd)
+                (open-log (str base-directory "logfile"))
+                #(.log js/console %)))
         (handle-unspents! grab-percentages system))
       (let [build-cmd (partial assoc system :command)
             exec-cmd (comp execute build-cmd)]


add errors vector to result for future use / reminder

--- src/clj/ephemeris/core.clj
+++ src/clj/ephemeris/core.clj
@@ -70,7 +70,7 @@
   ([] (calc {}))
   ([stuff]
    (let [want (merge defaults stuff)
-         re (atom {})
+         re (atom {:errors []})
          sw (SwissEph.)
          jd (result re :jd (utc-to-jd (:utc want)))
          flag (. SweConst SEFLG_SPEED)]
@@ -108,3 +108,7 @@
             (nice-houses cusps (:houses want)))))
       (if (:meta want) {:wanted (dissoc want :meta)
                         :result @re})))))
+
+(comment
+  (calc {:utc "1974-06-30T21:45:00Z"
+         :geo {:lat 43.217 :lon 27.917}}))


:ephemeris in :result will show which ephemeris was used

--- src/clj/ephemeris/core.clj
+++ src/clj/ephemeris/core.clj
@@ -73,6 +73,7 @@
          re (atom {:errors []})
          sw (SwissEph.)
          jd (result re :jd (utc-to-jd (:utc want)))
+         eph (result re :ephemeris :MOSEPH) ;; can become :SWIEPH or :JPLEPH
          flag (. SweConst SEFLG_SPEED)]
     (merge
       {:points


Mingor bug fixed on configuration loading inside core ns

--- src/clj/hellhound/core.clj
+++ src/clj/hellhound/core.clj
@@ -1,7 +1,8 @@
 (ns hellhound.core
   "This namespace contains core functions which are required
   by the whole framework in order to operate."
-  (:require [hellhound.config :refer [read-config]]))
+  (:require [hellhound.config :refer [read-config]]
+            [clojure.java.io :as io]))

 ;; Definitions ---------------------------------------------
 (def environment-configuration (atom {}))
@@ -33,11 +34,15 @@

 ;;;; Runtime Environment Configuration Loaders -------------
+(defn- config-file
+  []
+  (format "environments/%s.edn" (name (env))))
+
 (defn load-runtime-configuration
   "Read and parse the configuration file related to the current runtime
   environment."
   []
-  (let [config (read-config (format "environments/%s.edn" (env)))]
+  (let [config (read-config (config-file))]
     (reset! environment-configuration config)
     config))


Preserve the system path if needed

Preserve the system path if needed

--- src/clj/runbld/process.clj
+++ src/clj/runbld/process.clj
@@ -157,7 +157,13 @@
                      (if (io/windows?) :Path :PATH))
         java-bin (str (:JAVA_HOME env) File/separator "bin")]
     (io/log "Adding" java-bin "to the path.")
-    (update env path-key #(str java-bin File/pathSeparator %))))
+    (if (empty? (get env path-key))
+      ;; If the path wasn't specified in the config the process will
+      ;; inherit the system path.  We need to preserve this behavior
+      ;; as we add the PATH here.
+      (assoc env path-key
+             (str java-bin File/pathSeparator (get (env/get-env) path-key)))
+      (update env path-key #(str java-bin File/pathSeparator %)))))

 (defn exec
   [program args scriptfile cwd


switch agent to distribution api as well

--- src/clj/swarmpit/agent.clj
+++ src/clj/swarmpit/agent.clj
@@ -12,9 +12,9 @@
     (doseq [service services]
       (let [id (:id service)
             repository (:repository service)
-            registry (:registry service)
+            distribution (:distribution service)
             current-image-id (api/service-image-id repository)
-            latest-image-id (api/service-image-latest-id repository registry)]
+            latest-image-id (api/service-image-latest-id distribution repository)]
         (when (not= current-image-id
                     latest-image-id)
           (api/update-service id service true)


handle timestamps in seconds

handle timestamps in seconds

--- src/clj_blueflood/core.clj
+++ src/clj_blueflood/core.clj
@@ -55,9 +55,13 @@
 (defn cass-prepared-insert-full [metric-name timestamp metric-value]
   (mark! metrics-inserted)
   (cass-execute (:prepared-insert-full @cass-state)
-                {:values [metric-name timestamp (if (instance? ByteBuffer metric-value)
+                {:values [metric-name
+                          (if (> 2000000000 timestamp)
+                            (* 1000 timestamp)
+                            timestamp)
+                          (if (instance? ByteBuffer metric-value)
                                                   metric-value
-                                                  (metric->blob metric-value))]}))
+                                                  (metric->blob metric-value)) ]}))

 (defn cass-prepared-insert-locator [shard metric-name]
   (cass-execute (:prepared-insert-locator @cass-state) {:values [shard metric-name]}))


remove reflection warning in producer code

--- src/clj_kafka/producer.clj
+++ src/clj_kafka/producer.clj
@@ -16,7 +16,7 @@
   "Creates a Producer. m is the configuration
    metadata.broker.list : \"server:port,server:port\""
   [m]
-  ^Producer (Producer. (ProducerConfig. (as-properties m))))
+  (Producer. (ProducerConfig. (as-properties m))))

 (defn keyed-message
   ([topic value] (keyed-message topic nil value))
@@ -24,4 +24,4 @@

 (defn send-message
   [^Producer producer ^String topic value]
-  (.send producer (keyed-message topic (message-payload value))))
+  (.send producer ^KeyedMessage (keyed-message topic (message-payload value))))


small fix on starting db state and schema #3

--- src/cljs/go_client/db.cljs
+++ src/cljs/go_client/db.cljs
@@ -12,7 +12,7 @@
                          :empty-vertices  #{go-schema/vertex}
                          :playable-stones #{go-schema/move}}}
    :server       {:open? s/Bool
-                  :uid   (s/maybe (s/either js/Object s/Str))}})
+                  :uid   (s/either (s/eq :taoensso.sente/nil-uid) s/Str)}})

 (def default-db
   (let [ear-reddening-game [[:black [16 17]]
@@ -43,4 +43,4 @@
                              :empty-vertices  (set (game/empty-vertices ear-reddening-game))
                              :playable-stones (set [[:black [1 1]]])}}
      :server      {:open? false
-                   :uid   nil}}))
+                   :uid   :taoensso.sente/nil-uid}}))


Changing browsing route when the thread window is closed

This might not be the best way to do it, assuming we can display the
thread window from elsewhere, but for now it'll do.

https://app.asana.com/0/17212341701456/170280594619412

--- src/cljs/memento/core.cljs
+++ src/cljs/memento/core.cljs
@@ -475,6 +475,7 @@
 (register-handler
   :state-show-thread
   (fn [app-state [_ show?]]
+    (when-not show? (dispatch [:state-browser-token :remember]))
     (assoc-in app-state [:ui-state :show-thread?] show?)))


Handling paginated requests on the front end

--- src/cljs/memento/core.cljs
+++ src/cljs/memento/core.cljs
@@ -167,6 +167,7 @@
   :load-memories-success
   (fn [app-state [_ memories]]
     (-> app-state
+        (assoc-in [:ui-state :results-page] (:current-page memories))
         (assoc-in [:ui-state :memories] memories)
         (assoc-in [:ui-state :is-searching?] false))
     ))
@@ -184,8 +185,11 @@
 (register-handler
   :page-memories
   (fn [app-state [_ i]]
-    (let [max (dec (get-in app-state [:ui-state :memories :pages]))
-          idx (Math/max 0 (Math/min max i))]
+    (let [max          (dec (get-in app-state [:ui-state :memories :pages]))
+          idx          (Math/max 0 (Math/min max i))
+          current-page (get-in app-state [:ui-state :memories :current-page])]
+      (if (not= current-page idx)
+        (dispatch [:load-memories idx]))
       (assoc-in app-state [:ui-state :results-page] idx))
     ))

@@ -319,9 +323,9 @@
                   :id           "input-search"
                   :value        @query
                   :on-change    #(dispatch-sync [:update-query (-> % .-target .-value)])
-                  :on-key-press #(dispatch-on-press-enter % [:load-memories])}]]
+                  :on-key-press #(dispatch-on-press-enter % [:load-memories 0])}]]
         [:div {:class "col-lg-1"}
-         [:button {:type "submit" :class "btn btn-primary" :on-click #(dispatch [:load-memories])} "Search"]]
+         [:button {:type "submit" :class "btn btn-primary" :on-click #(dispatch [:load-memories 0])} "Search"]]
         ]])))

 (defn memory-pager []
@@ -341,7 +345,7 @@
                     :on-click #(dispatch [:page-memories i])}
                [:a (str (inc i))]]
               ))
-          [:li {:class (if (>= @current @pages) "disabled")}
+          [:li {:class (if (>= @current (dec @pages)) "disabled")}
            [:a {:on-click #(dispatch [:page-memories (inc @current)])} "»"]]]]
         ))
     )


exclude core partition-by

exclude core partition-by

--- src/clojure/flambo/sql.clj
+++ src/clojure/flambo/sql.clj
@@ -2,7 +2,7 @@
 ;; SparkSQL & DataFrame wrapper
 ;;
 (ns flambo.sql
-  (:refer-clojure :exclude [load group-by])
+  (:refer-clojure :exclude [load group-by partition-by])
   (:require [flambo.api :as f :refer [defsparkfn]]
             [flambo.sql-functions :as sqlf])
   (:import [org.apache.spark.api.java JavaSparkContext]


Add some missing `do-copy` coercions.

Add some missing `do-copy` coercions.

--- src/clojure/parkour/fs.clj
+++ src/clojure/parkour/fs.clj
@@ -192,6 +192,21 @@
   (with-open [output (io/writer output)]
     (do-copy input output opts)))
 (defmethod do-copy [File Path]
+  [input output opts]
+  (with-open [output (io/output-stream output)]
+    (do-copy input output opts)))
+(defmethod do-copy [URL Path]
+  [input output opts]
+  (with-open [input (io/input-stream input)
+              output (io/output-stream output)]
+    (do-copy input output opts)))
+(defmethod do-copy [URI Path]
+  [input output opts]
+  (with-open [input (io/input-stream input)
+              output (io/output-stream output)]
+    (do-copy input output opts)))
+
+(defmethod do-copy [Path Path]
   [input output opts]
   (with-open [output (io/output-stream output)]
     (do-copy input output opts)))


Fix linkifying of mentions at begin of line.

Fixes #96.

--- src/statuses/views/common.clj
+++ src/statuses/views/common.clj
@@ -48,13 +48,13 @@
 (def email #"([a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)")

 (defn linkify [text]
-  (let [handle  (fn [[_ m]] (str " @" m ""))
+  (let [handle  (fn [[_ m]] (str "@" m ""))
         hashtag (fn [[_ m]] (str "#" m ""))
         anchor  (fn [[m _]] (str "" m ""))
         mailto  (fn [[m _]] (str "" m ""))]
     (-> text
         escape-html
-        (clojure.string/replace #" @(\w+)" handle)
+        (clojure.string/replace #"(?:^|(?<=\s))@(\S+)" handle)
         (clojure.string/replace uri anchor)
         (clojure.string/replace email mailto)
         (clojure.string/replace #"(?:^|(?<=\s))#(\S+)" hashtag))))


handle policy as map case

handle policy as map case

--- src/crucible/resources.clj
+++ src/crucible/resources.clj
@@ -17,7 +17,9 @@

 (defn encode-policy
   [policy]
-  (if policy (encode-key policy)))
+  (if policy
+    (if (map? policy) (reduce-kv (fn [m k v] (assoc m (encode-key k) v)) {} policy)
+        (encode-key policy))))

 (declare encode-resource-properties)


removed unnecessary print

removed unnecessary print

--- src/frontend/renderer.cljs
+++ src/frontend/renderer.cljs
@@ -296,7 +296,6 @@
       {:position 0})
     om/IWillReceiveProps
     (will-receive-props [ _ _]
-      (println "A")
       (om/set-state! owner {:position (* 100 (/ (player/get-position)
                                                 (player/get-duration)))}))
     om/IRenderState


Reflect the fact that some of the text describing a room is automatic.

--- src/tryclojure/views/home.clj
+++ src/tryclojure/views/home.clj
@@ -58,7 +58,7 @@

            hallway summary
            is
-           'You are in a hallway.  A candle burns on a table.  You can see a door.'
+           'A candle burns on a table.'
           "]
          [:p "
            Then, play through your adventure:


Fix reading RDF language tags.

Fix reading RDF language tags.

--- src/grafter/rdf/sesame.clj
+++ src/grafter/rdf/sesame.clj
@@ -60,7 +60,7 @@
        (->sesame-rdf-type [this]
          (LiteralImpl. str))))
   ([str lang-or-uri]
-     {:pre [(string? str) (or (string? lang-or-uri) (keyword? lang-or-uri) (instance? URI lang-or-uri))]}
+     {:pre [(string? str) (or (string? lang-or-uri) (keyword? lang-or-uri) (nil? lang-or-uri) (instance? URI lang-or-uri))]}
      (reify Object
        (toString [_] str)
        ISesameRDFConverter
@@ -75,7 +75,7 @@
                                      (str datatype))))

 (defmethod literal-datatype->type nil [literal]
-  (s (.stringValue literal)))
+  (s (.stringValue literal) (.getLanguage literal)))

 (defmethod literal-datatype->type "http://www.w3.org/2001/XMLSchema#byte" [literal]
   (.byteValue literal))
@@ -99,7 +99,7 @@
   (.intValue literal))

 (defmethod literal-datatype->type "http://www.w3.org/TR/xmlschema11-2/#string" [literal]
-  (s (.stringValue literal)))
+  (s (.stringValue literal) (.getLanguage literal)))

 (defmethod literal-datatype->type "http://www.w3.org/2001/XMLSchema#dateTime" [literal]
   (-> literal .calendarValue .toGregorianCalendar .getTime))
@@ -201,7 +201,8 @@
     (ContextStatementImpl. (->sesame-rdf-type (pr/subject this))
                            (->sesame-rdf-type (pr/predicate this))
                            (->sesame-rdf-type (pr/object this))
-                           (->sesame-rdf-type (pr/context this))))
+                           (when-let [context (pr/context this)]
+                             (->sesame-rdf-type (pr/context context)))))

   Value
   (->sesame-rdf-type [this]
@@ -224,7 +225,6 @@

   (sesame-rdf-type->type [this]
     (str this))
-

   java.net.URI
   (->sesame-rdf-type [this]


RR: listen to page change event

RR: listen to page change event

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -138,6 +138,12 @@
                   (let [rank (aget (.getItem dataview (aget args "row"))
                                    _rank)]
                     (put! shared/event-chan {:submission-to-rank rank}))))
+    (.subscribe (.-onRowsChanged dataview)
+                (fn [e args]
+                  (put! shared/event-chan
+                        {:page
+                         (inc (aget (.getPagingInfo dataview) "pageNum"))})))
+
     ;; page, filter, and data set-up on the dataview
     (init-sg-pager grid dataview)
     (.setPagingOptions dataview #js


RR/ME: fix actions column

RR/ME: fix actions column

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -140,6 +140,23 @@
        :enableTextSelectionOnCells true
        :rowHeight 40
        :syncColumnCellResize false})
+
+(defn freeze-action-column!
+  "Fixes the first column on slick table on horizontal scroll"
+  []
+  (let [actions (.getElementsByClassName js/document "record-actions")
+        sg-viewport (first (.getElementsByClassName js/document
+                                                    "slick-viewport"))]
+
+    (doseq [action actions]
+      (let [leftOffset (js/parseInt (.-offsetLeft action))]
+        (.addEventListener sg-viewport "scroll"
+                           (fn []
+                             (set! (.-left (.-style action))
+
+                                   (str (+ (.-scrollLeft  sg-viewport)
+                                           leftOffset)
+                                        "px"))))))))

 (defn bind-external-sg-grid-event-handlers
   [grid event-handlers]
@@ -340,6 +357,7 @@
                                    slick-grid-event-handlers)]
       (om/set-state! owner :grid grid)
       (om/set-state! owner :dataview dataview)
+      (freeze-action-column!)
       [grid dataview])))

 (defmethod table-page :default


More documentation improvements

More documentation improvements

--- src/io/aviso/rook/core.clj
+++ src/io/aviso/rook/core.clj
@@ -9,7 +9,10 @@

 (def
   DEFAULT-MAPPINGS
-  "Default mappings for route specs to functions. We use keyword for function name for increased readability."
+  "Default mappings for route specs to functions. We use keyword for function name for increased readability.
+  If a public method whose name matches a default mapping exists, then it will be added using the
+  default mapping; for example, a method named \"index\" will automatically be matched against \"GET /\".
+  This can be overriden by providing meta-data on the functions."
   [[[:get "/new"] :new]
    [[:get "/:id"] :show]
    [[:put "/:id"] :update]
@@ -56,6 +59,7 @@
       f)))

 (defn- success?
+  "Passed a resonse map, determines if the status indicates success."
   [{:keys [status]}]
   (<= 200 status 399))

@@ -186,8 +190,8 @@
         (handler request)))))

 (defn rook-handler
-  "Handler that uses information from :rook entry in request map to invoke proper function
-  and resolve arguments with arg-resolvers."
+  "Handler that uses information from :rook entry in the request map to invoke the previously
+  identified functionm, after resolving the function's arguments."
   [request]
   (let [rook-data (-> request :rook)
         arg-resolvers (concat (-> rook-data :default-arg-resolvers)


Added basic rendering test.

Added basic rendering test.

(Kind of a cheap way to bump the test coverage up dramatically!)

--- test/com/lemondronor/leaflet_gorilla_test.clj
+++ test/com/lemondronor/leaflet_gorilla_test.clj
@@ -94,3 +94,9 @@
     (is (= (json/read-str
             "{\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[2,1]]}}]}")
            (json/read-str (geojson [[[1 2]]]))))))
+
+
+(deftest test-render
+  (testing "rendering"
+    (let [v (render/render (lg/leaflet [[1 2]]))]
+      (is (= :html (:type v))))))


Remove unused import.

Remove unused import.

--- src/klangmeister/core.cljs
+++ src/klangmeister/core.cljs
@@ -7,9 +7,7 @@
     [reagent.core :as reagent]
     [reagent.session :as session]
     [accountant.core :as accountant]
-    [secretary.core :as secretary :include-macros true])
-  (:require-macros
-    [klangmeister.compile.macros :as macro]))
+    [secretary.core :as secretary :include-macros true]))

 (defn empty-state []
   (reagent/atom


Default war-exclusions to exclude hidden files

--- src/leiningen/ring/war.clj
+++ src/leiningen/ring/war.clj
@@ -25,7 +25,7 @@
   (or (re-find #"^\.?#" (.getName file))
       (re-find #"~$" (.getName file))
       (some #(re-find % war-path)
-            (get-in project [:ring :war-exclusions]))))
+            (get-in project [:ring :war-exclusions] [#"(^|/)\."]))))

 (defn- to-byte-stream [^String s]
   (ByteArrayInputStream. (.getBytes s)))


Fixed servlet compilation step

Fixed servlet compilation step

--- src/leiningen/ring/war.clj
+++ src/leiningen/ring/war.clj
@@ -47,21 +47,29 @@
           [:servlet-name "war-servlet"]
           [:url-pattern "/*"]]])))

-(defn compile-ns [project forms]
+
+(defn source-file [project namespace]
+  (io/file (:compile-path project)
+           (-> (str namespace)
+               (.replace "-" "_")
+               (.replace "." java.io.File/separator)
+               (str ".clj"))))
+
+(defn compile-form [project namespace form]
+  (let [out-file (source-file project namespace)]
+    (.mkdirs (.getParentFile out-file))
+    (with-open [out (io/writer out-file)]
+      (binding [*out* out] (prn form))))
   (compile/eval-in-project project
-    `(binding [*compile-files* true]
-       (load-string (pr-str '~forms)))))
+    `(clojure.core/compile '~namespace)))

 (defn compile-servlet [project]
-  (let [handler-sym (get-in project [:ring :handler])]
-    (compile-ns project
+  (let [handler-sym (get-in project [:ring :handler])
+        handler-ns  (symbol (namespace handler-sym))]
+    (compile-form project 'deploy.servlet
       `(do (ns deploy.servlet
-             (:require
-               ~(symbol (namespace handler-sym))
-               ring.util.servlet)
-             (:gen-class
-                :name "deploy.servlet"
-                :extends javax.servlet.http.HttpServlet))
+             (:require ring.util.servlet ~handler-ns)
+             (:gen-class :extends javax.servlet.http.HttpServlet))
            (ring.util.servlet/defservice ~handler-sym)))))

 (defn create-war [project file-path]
@@ -76,18 +84,22 @@
 (defn str-entry [war war-path content]
   (write-entry war war-path (to-byte-stream content)))

-(defn- in-war-path [war-path root file]
+(defn in-war-path [war-path root file]
   (str war-path "/"
        (-> (.toURI (io/file root))
            (.relativize (.toURI file))
            (.getPath))))

+(defn file-entry [war project war-path file]
+  (when (and (.exists file)
+             (.isFile file)
+             (not (skip-file? project war-path file)))
+    (write-entry war war-path file)))
+
 (defn dir-entry [war project war-root dir-path]
   (doseq [file (file-seq (io/file dir-path))]
-    (if (and (.exists file) (.isFile file))
-      (let [war-path (in-war-path war-root dir-path file)]
-        (if-not (skip-file? project war-path file)
-          (write-entry war war-path file))))))
+    (let [war-path (in-war-path war-root dir-path file)]
+      (file-entry war project war-path file))))

 (defn write-war [project war-path]
   (with-open [war-stream (create-war project war-path)]


Wrap dialog content in element so it can accept a plain string argument (#473)

--- src/cljs/org/broadinstitute/firecloud_ui/common/dialog.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/dialog.cljs
@@ -96,10 +96,9 @@
           {:content
            (react/create-element
              [OKCancelForm
-              (merge (select-keys props [:header :dismiss-self :ok-button :show-cancel? :cancel-text])
-                     {:content
-                      (react/create-element
-                        (:content props))})])})])
+              (merge
+               (select-keys props [:header :dismiss-self :ok-button :show-cancel? :cancel-text])
+               {:content (react/create-element [:div {} (:content props)])})])})])

 (react/defc GCSFilePreviewLink


Removed redundant TODO.

Removed redundant TODO.

--- test/plugboard/demos/main.clj
+++ test/plugboard/demos/main.clj
@@ -43,7 +43,6 @@
   (GET "/links/*" []
        (create-handler (plugboard.demos.links.configuration/create-plugboard)))
   (ANY "/forms/*" []
-       ;; TODO: Ring just doesn't seem to be working - have to debug it.
        (ring.middleware.params/wrap-params
         (create-handler (plugboard.demos.forms.configuration/create-plugboard))))
   (GET "/status-views/*" []
@@ -53,5 +52,3 @@
   (GET "/custom-auth/*" []
        (create-handler (plugboard.demos.custom-auth.configuration/create-plugboard)))
   (route/not-found "
Page not found
"))
-
-


More perf tests

More perf tests

--- test/spec_tools/perf_test.clj
+++ test/spec_tools/perf_test.clj
@@ -70,7 +70,7 @@

 (defn conform-test []

-  (suite "conform")
+  (suite "no-op conform")

   ; 1315ns
   (title "spec: integer?")
@@ -101,6 +101,29 @@
     (cc/quick-bench
       (call))))

+(defn conform-test2 []
+
+  (suite "conforming list of keywords")
+
+  (let [sizes-spec (spec/cat :sizes (spec/* #{:L :M :S}))
+        sizes-schema [(schema/enum :L :M :S)]]
+
+    ; 16900ns
+    (title "spec: conform keyword enum")
+    (let [call #(spec/unform sizes-spec (spec/conform sizes-spec [:L :M]))]
+      (assert (= (call) [:L :M]))
+      (cc/quick-bench
+        (call)))
+
+    ; 325ns
+    (title "schema: conform keyword enum")
+    (let [coercer (coerce/coercer sizes-schema (constantly nil))
+          call #(coercer [:L :M])]
+      (assert (= (call) [:L :M]))
+      (cc/quick-bench
+        (call)))))
+
 (comment
   (valid-test)
-  (conform-test))
+  (conform-test)
+  (conform-test2))


task execution result record

task execution result record

--- src/matross/tasks/core.clj
+++ src/matross/tasks/core.clj
@@ -2,6 +2,11 @@

 (defmulti get-module :type)

+(defrecord TaskResult [conf succeeded? changed? data])
+
 (defprotocol ITask
   "How to run tasks"
   (exec [self conn]))
+
+(defn task-result [conf succeeded? changed? data]
+  (TaskResult. conf succeeded? changed? data))


GET /table/:id/fks shouldn't return inactive FK fields

--- src/metabase/api/table.clj
+++ src/metabase/api/table.clj
@@ -76,15 +76,14 @@
   "Get all foreign keys whose destination is a `Field` that belongs to this `Table`."
   [id]
   (read-check Table id)
-  (let [field-ids (db/select-ids Field, :table_id id, :visibility_type [:not= "retired"])]
-    (when (seq field-ids)
-      (for [origin-field (db/select Field, :fk_target_field_id [:in field-ids])]
-        ;; it's silly to be hydrating some of these tables/dbs
-        {:relationship   :Mt1
-         :origin_id      (:id origin-field)
-         :origin         (hydrate origin-field [:table :db])
-         :destination_id (:fk_target_field_id origin-field)
-         :destination    (hydrate (Field (:fk_target_field_id origin-field)) :table)}))))
+  (when-let [field-ids (seq (db/select-ids Field, :table_id id, :visibility_type [:not= "retired"], :active true))]
+    (for [origin-field (db/select Field, :fk_target_field_id [:in field-ids], :active true)]
+      ;; it's silly to be hydrating some of these tables/dbs
+      {:relationship   :Mt1
+       :origin_id      (:id origin-field)
+       :origin         (hydrate origin-field [:table :db])
+       :destination_id (:fk_target_field_id origin-field)
+       :destination    (hydrate (Field (:fk_target_field_id origin-field)) :table)})))

 (define-routes)


Serve internal server error responses in JSON with CORS header

--- src/nhl_score_api/core.clj
+++ src/nhl_score_api/core.clj
@@ -53,9 +53,16 @@

 (defn app [request]
   (println "Received request" request)
-  (let [success-response (get-response (:uri request) api/fetch-latest-scores cache/get-value cache/set-value)
-        response (or success-response {})]
-    {:status (if success-response 200 404)
-     :headers {"Access-Control-Allow-Origin" "*"
-               "Content-Type" "application/json; charset=utf-8"}
-     :body (json/write-str response :key-fn json-key-transformer)}))
+  (let [headers {"Access-Control-Allow-Origin" "*"
+                 "Content-Type" "application/json; charset=utf-8"}]
+    (try
+      (let [success-response (get-response (:uri request) api/fetch-latest-scores cache/get-value cache/set-value)
+            response (or success-response {})]
+        {:status (if success-response 200 404)
+         :headers headers
+         :body (json/write-str response :key-fn json-key-transformer)})
+      (catch Exception e
+        (println "Caught exception" e)
+        {:status 500
+         :headers headers
+         :body (json/write-str {:error "Server error"})}))))


Change mode to window-crop-fixed.

Change mode to window-crop-fixed.

--- src/vignette/http/routes.clj
+++ src/vignette/http/routes.clj
@@ -59,7 +59,7 @@
                   :window-height size-regex}))

 (def window-crop-fixed-route
-  (route-compile "/:wikia:image-type/:top-dir/:middle-dir/:original/revision/:revision/window-crop/width/:width/height/:height/x-offset/:x-offset/y-offset/:y-offset/window-width/:window-width/window-height/:window-height"
+  (route-compile "/:wikia:image-type/:top-dir/:middle-dir/:original/revision/:revision/window-crop-fixed/width/:width/height/:height/x-offset/:x-offset/y-offset/:y-offset/window-width/:window-width/window-height/:window-height"
                  {:wikia wikia-regex
                   :image-type image-type-regex
                   :top-dir top-dir-regex


handle the case where user tries to delete last wish

--- src/wishlistd/cljs/main.cljs
+++ src/wishlistd/cljs/main.cljs
@@ -144,8 +144,10 @@
   (delegate $content ".delete" :click
     (fn [e]
       (this-as me
-        (remove (.parent ($ me)))
-        (update-wishlist-rem)))))
+        (let [$me ($ me)]
+          (when-not (.hasClass (.parent $me) "last")
+            (remove (.parent $me))
+            (delete-wish-rem (.parent $me))))))))

 ; START IT UP


allow longs as buffer ids

allow longs as buffer ids

--- src/overtone/sc/buffer.clj
+++ src/overtone/sc/buffer.clj
@@ -161,6 +161,7 @@

 (defmulti buffer-id type)
 (defmethod buffer-id java.lang.Integer [id] id)
+(defmethod buffer-id java.lang.Long [id] id)
 (defmethod buffer-id ::buffer [buf] (:id buf))
 (defmethod buffer-id ::buffer-info [buf-info] (:id buf-info))


fix minor mistake introduced in previous merge commit

--- src/overtone/sc/sample.clj
+++ src/overtone/sc/sample.clj
@@ -45,7 +45,7 @@
     (defsynth stereo-stream-player
       "Plays a dual channel streaming buffer-cue. Must be freed manually when
       done."
-      [buf 0 rate 1 loop? 0 vol 1 amp 0 out-bus 0]
+      [buf 0 rate 1 loop? 0 amp 1 pan 0 out-bus 0]
       (let [s (scaled-v-disk-in 2 buf rate loop?)]
         (out out-bus (* amp (balance2 (first s) (second s) pan)))))))