migrate db.products tests (midje => clojure.test)

--- test/clojento/magento/db/t_products.clj
+++ test/clojento/magento/db/t_products.clj
@@ -1,6 +1,6 @@
 (ns clojento.magento.db.t_products
   (:require [clojure.test :refer :all]
-            ; [clojento.magento.db :as db]
+            [clojento.magento.db :as db]
             [clojento.magento.t_db :as t_db]
             [clojento.magento.db.products :as nut]
             [clj-time.core :as t]
@@ -8,109 +8,119 @@

 (use-fixtures :once t_db/ro-db-fixture)

-; (namespace-state-changes [(before :facts (t_db/setup-test-system-with-ro-db))])
-;
-; ; ------------------------------------------------------------------------------
-;
-; (facts "query product-entities"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product(s)"
-;           (product-entities conn {:product-ids [-1 -2]}) => [])
-;     (fact "get product with id 1"
-;           (first (product-entities conn {:product-ids [1]})) => (just {:id 1 :sku "sku-1" :type "simple" :attribute-set 4 :date-created anything :date-updated anything}))
-;     (fact "get multiple products"
-;           (product-entities conn {:product-ids [1 2]}) => (just [(contains {:id 1})
-;                                                                  (contains {:id 2})] :in-any-order)
-;           (product-entities conn {:product-ids [1 2 3]}) => (just [(contains {:id 1})
-;                                                                    (contains {:id 2})
-;                                                                    (contains {:id 3})] :in-any-order))
-;     (fact "type of date-created"
-;           (type (:date-created (first (product-entities conn {:product-ids [1]})))) => org.joda.time.DateTime)))
-;
-; (facts "query product-websites"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product(s)"
-;           (product-websites conn {:product-ids [-1 -2]}) => [])
-;     (fact "get product with id 1"
-;           (product-websites conn {:product-ids [1]}) => (just [{:id 1 :website-id 1}
-;                                                                {:id 1 :website-id 2}] :in-any-order))
-;     (fact "get multiple products"
-;           (product-websites conn {:product-ids [1 2]}) => (just [{:id 1 :website-id 1}
-;                                                                  {:id 1 :website-id 2}
-;                                                                  {:id 2 :website-id 1}] :in-any-order)
-;           (count (product-websites conn {:product-ids [3 2 1]})) => 4)))
-;
-; (facts "query product-stock"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product"
-;           (product-stock conn {:product-ids [-1]}) => [])
-;     (fact "get product with id 1"
-;           (product-stock conn {:product-ids [1]}) => (just [{:id 1 :website-id 1 :stock-id 1 :qty 2.0000M :stock-status 1}
-;                                                             {:id 1 :website-id 2 :stock-id 1 :qty 0.0000M :stock-status 0}] :in-any-order))))
-;
-; (facts "query product-attributes-varchar"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product"
-;           (product-attributes-varchar conn {:product-ids [-1]}) => [])
-;     (fact "get product with id 1"
-;           (product-attributes-varchar conn {:product-ids [1]}) => (just [{:id 1 :attribute-id 60 :store-id 0 :value "Simple Product 1"}
-;                                                                          {:id 1 :attribute-id 71 :store-id 0 :value nil}
-;                                                                          {:id 1 :attribute-id 73 :store-id 0 :value "This is the simple product with id 1"}] :in-any-order))))
-;
-; (facts "query product-attributes-text"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product"
-;           (product-attributes-text conn {:product-ids [-1]}) => [])
-;     (fact "get product with id 1"
-;           (product-attributes-text conn {:product-ids [1]}) => (just [(contains {:id 1 :attribute-id 61 :store-id 0 :value anything})                   ; TODO h2 returns a org.h2.jdbc.JdbcClob, .toString == "This is the long description for product 1"
-;                                                                       (contains {:id 1 :attribute-id 62 :store-id 0 :value anything})] :in-any-order)))) ; TODO h2 returns a org.h2.jdbc.JdbcClob, .toString == "This is the short description for product 1"
-;
-; (facts "query product-attributes-datetime"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product"
-;           (product-attributes-datetime conn {:product-ids [-1]}) => [])
-;     (fact "get product with id 1"
-;           (product-attributes-datetime conn {:product-ids [1]}) => (just [(contains {:id 1 :attribute-id 66 :store-id 1 :value anything})                   ; TODO checking dates
-;                                                                           (contains {:id 1 :attribute-id 67 :store-id 1 :value anything})] :in-any-order)))) ; TODO checking dates
-;
-; (facts "query variants"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "get missing product"
-;           (variants conn {:product-ids [-1]}) => [])
-;     (fact "get simple product"
-;           (variants conn {:product-ids [1]}) => [])
-;     (fact "get configurable product"
-;           (variants conn {:product-ids [2]}) => (just [{:product_id 2 :variant_id 3}
-;                                                        {:product_id 2 :variant_id 4}
-;                                                        {:product_id 2 :variant_id 5}] :in-any-order))
-;     (fact "get variant of configurable product"
-;           (variants conn {:product-ids [3]}) => [{:product_id 2 :variant_id 3}])
-;     (fact "get configurable product without variants"
-;           (variants conn {:product-ids [6]}) => [])
-;     (future-fact "get grouped product")
-;     (future-fact "get bundle product")
-;     (fact "get multiple products"
-;           (variants conn {:product-ids [1 2 3 6]}) => (just [{:product_id 2 :variant_id 3}
-;                                                              {:product_id 2 :variant_id 4}
-;                                                              {:product_id 2 :variant_id 5}] :in-any-order))))
-;
-; ; ------------------------------------------------------------------------------
-;
-; (facts "get-variants-info"
-;   (with-state-changes [(around :facts (with-open [conn (db/conn)] ?form))]
-;     (fact "not found"
-;           (get-variants-info conn -1) => {:found-variants false :is-variant false})
-;     (fact "simple product"
-;           (get-variants-info conn 1)  => {:found-variants false :is-variant false})
-;     (fact "configurable product"
-;           (get-variants-info conn 2)  => {:found-variants true  :is-variant false :variant-ids [3 4 5]})
-;     (fact "variant (child product)"
-;           (get-variants-info conn 3)  => {:found-variants false :is-variant true  :product-id 2})
-;     (fact "configurable product without children"
-;           (get-variants-info conn 6)  => {:found-variants false :is-variant false})
-;     (future-fact "has meta"
-;                  (meta (get-variants-info conn -1 :debug true)) => (contains {:hits 0}))))
-;
+; ------------------------------------------------------------------------------
+
+(deftest product-entities
+  (with-open [conn (db/conn)]
+    (testing "get missing product(s)"
+      (is (= [] (nut/product-entities conn {:product-ids [-1 -2]}))))
+    (testing "get product with id 1"
+      (is (= {:id 1 :sku "sku-1" :type "simple" :attribute-set 4 :date-created (t/date-time 2011 11 21 14 02 58) :date-updated (t/date-time 2013 11 14 10 17 49)}
+             (first (nut/product-entities conn {:product-ids [1]})))))
+    (testing "get multiple products"
+      ; TODO think about order
+      (is (= [1 2]   (map :id (nut/product-entities conn {:product-ids [1 2]}))))
+      (is (= [1 2]   (map :id (nut/product-entities conn {:product-ids [2 1]}))))
+      (is (= [1 2 3] (map :id (nut/product-entities conn {:product-ids [1 2 3]})))))
+    (testing "type of date-created"
+      (is (= org.joda.time.DateTime (type (:date-created (first (nut/product-entities conn {:product-ids [1]})))))))))
+
+(deftest product-websites
+  (with-open [conn (db/conn)]
+    (testing "get missing product(s)"
+      (is (= [] (nut/product-websites conn {:product-ids [-1 -2]}))))
+    (testing "get product with id 1"
+      (is (= [{:id 1 :website-id 1} {:id 1 :website-id 2}]
+             (nut/product-websites conn {:product-ids [1]}))))
+    (testing "get multiple products"
+      (is (= [{:id 1 :website-id 1} {:id 1 :website-id 2} {:id 2 :website-id 1}]
+             (nut/product-websites conn {:product-ids [1 2]})))
+      (is (= 4 (count (nut/product-websites conn {:product-ids [3 2 1]})))))))
+
+(deftest product-stock
+  (with-open [conn (db/conn)]
+    (testing "get missing product"
+      (is (= [] (nut/product-stock conn {:product-ids [-1]}))))
+    (testing "get product with id 1"
+      (is (= [{:id 1 :website-id 1 :stock-id 1 :qty 2.0000M :stock-status 1}
+              {:id 1 :website-id 2 :stock-id 1 :qty 0.0000M :stock-status 0}]
+             (nut/product-stock conn {:product-ids [1]}))))))
+
+
+(deftest product-attributes-varchar
+  (with-open [conn (db/conn)]
+    (testing "get missing product"
+      (is (= [] (nut/product-attributes-varchar conn {:product-ids [-1]}))))
+    (testing "get product with id 1"
+      (is (= [{:id 1 :attribute-id 60 :store-id 0 :value "Simple Product 1"}
+              {:id 1 :attribute-id 71 :store-id 0 :value nil}
+              {:id 1 :attribute-id 73 :store-id 0 :value "This is the simple product with id 1"}]
+             (nut/product-attributes-varchar conn {:product-ids [1]}))))))
+
+(deftest product-attributes-text
+  (with-open [conn (db/conn)]
+    (testing "get missing product"
+      (is (= [] (nut/product-attributes-text conn {:product-ids [-1]}))))
+    (testing "get product with id 1"
+      (is (= [{:id 1 :attribute-id 61 :store-id 0 :value ""}
+              {:id 1 :attribute-id 62 :store-id 0 :value ""}]
+             (map (fn [orig] (assoc orig :value "")) (nut/product-attributes-text conn {:product-ids [1]})))))))
+
+(deftest product-attributes-datetime
+  (with-open [conn (db/conn)]
+    (testing "get missing product"
+      (is (= [] (nut/product-attributes-datetime conn {:product-ids [-1]}))))
+    (testing "get product with id 1"
+      (is (= [{:id 1 :attribute-id 66 :store-id 1 :value ""}
+              {:id 1 :attribute-id 67 :store-id 1 :value ""}]
+             ; TODO checking dates
+             (map (fn [orig] (assoc orig :value "")) (nut/product-attributes-datetime conn {:product-ids [1]})))))))
+
+(deftest variants
+  (with-open [conn (db/conn)]
+    (testing "get missing product"
+      (is (= [] (nut/variants conn {:product-ids [-1]}))))
+    (testing "get simple product"
+      (is (= [] (nut/variants conn {:product-ids [1]}))))
+    (testing "get configurable product"
+      (is (= [{:product_id 2 :variant_id 3}
+              {:product_id 2 :variant_id 4}
+              {:product_id 2 :variant_id 5}]
+             (nut/variants conn {:product-ids [2]}))))
+    (testing "get variant of configurable product"
+      (is (= [{:product_id 2 :variant_id 3}]
+             (nut/variants conn {:product-ids [3]}))))
+    (testing "get configurable product without variants"
+      (is (= [] (nut/variants conn {:product-ids [6]}))))
+    (testing "get grouped product (TODO)")
+    (testing "get bundle product (TODO)")
+    (testing "get multiple products"
+      (is (= [{:product_id 2 :variant_id 3}
+              {:product_id 2 :variant_id 4}
+              {:product_id 2 :variant_id 5}]
+             (nut/variants conn {:product-ids [1 2 3 6]}))))))
+
+(deftest get-variants-info
+  (with-open [conn (db/conn)]
+    (testing "not found"
+      (is (= {:found-variants false :is-variant false}
+             (nut/get-variants-info conn -1))))
+    (testing "simple product"
+      (is (= {:found-variants false :is-variant false}
+             (nut/get-variants-info conn 1))))
+    (testing "configurable product"
+      (is (= {:found-variants true  :is-variant false :variant-ids [3 4 5]}
+             (nut/get-variants-info conn 2))))
+    (testing "variant (child product)"
+      (is (= {:found-variants false :is-variant true  :product-id 2}
+             (nut/get-variants-info conn 3))))
+    (testing "configurable product without children"
+      (is (= {:found-variants false :is-variant false}
+             (nut/get-variants-info conn 6))))
+    (testing "has meta (TODO)")))
+
+; ------------------------------------------------------------------------------
+
 ; (future-facts "get-product-data"
 ;               (fact "found"
 ;                     ; not found
@@ -186,5 +196,5 @@
 ;                     (meta (get-product-data (:db @test-system) -1 :debug true)) => (contains {:time pos? :total-time pos?}))
 ;               (fact "meta contains all queries"
 ;                     (count (:queries (meta (get-product-data (:db @test-system) -1 :debug true)))) => 3))
-;
-; (log/debug "end of 'with read-only database' facts")
+
+(log/debug "end of 'with read-only database' facts")


Use destructuring for more brevity

Use destructuring for more brevity

--- src/cljs/comic_reader/handlers.cljs
+++ src/cljs/comic_reader/handlers.cljs
@@ -10,11 +10,12 @@
                        {:keys [chapter]} :location
                        :as db}]
   (api/get-img-tag site (first url-list))
-  (let [db (assoc db :url-list (next url-list))
+  (let [{:keys [url-list] :as db} (assoc db :url-list
+                                         (next url-list))
         new-location (assoc location :chapter
                             (inc
                              (read-string chapter)))]
-    (when (not (:url-list db))
+    (when (not url-list)
       (api/get-comic-urls site new-location))
     db))


Removed preset fetching coed

Removed preset fetching coed

Not needed anymore. Default config will sit in the client code. Resources and actions will
come from the json schema (future work)

--- src/cljs/load_test_client/core.cljs
+++ src/cljs/load_test_client/core.cljs
@@ -13,22 +13,11 @@
   (atom {:api {:http-url "http://localhost:3000/"
                :ws-url "ws://localhost:3000/"}
          :text "GoCardless Enterprise API Load Tester"
-         :form {}
+         :form {:duration 5
+                :rate 3}
          :load-tests {}}))

 (enable-console-print!)
-
-(defn handle-preset-response [app e]
-  (let [json (js->clj (.. e -target getResponseJson))
-        initial-selected-resource (juxt (comp first first)
-                                        (comp first second first))]
-    (om/transact! app :form (fn [form]
-                              (assoc form
-                                     :resources         (get json "resources")
-                                     :url               (get json "url")
-                                     :duration          (get json "duration")
-                                     :rate              (get json "rate")
-                                     :selected-resource (initial-selected-resource (get json "resources")))))))

 (defn handle-new-or-updated-load-test [app data]
   (om/transact! app :load-tests
@@ -41,9 +30,7 @@
         om/IWillMount
         (will-mount [_]
           (let [ws (WebSocket.)
-                ws-endpoint (str (-> app :api :ws-url) "load-tests")
-                http-endpoint (str (-> app :api :http-url) "presets")]
-            (gxhr/send http-endpoint (partial handle-preset-response app))
+                ws-endpoint (str (-> app :api :ws-url) "load-tests")]
             (doto ws
               (events/listen WebSocket.EventType.MESSAGE #(handle-new-or-updated-load-test app (.-message %)))
               (.open ws-endpoint))


Fix sign-out button (#741)

Fix sign-out button (#741)

--- src/cljs/main/broadfcui/common.cljs
+++ src/cljs/main/broadfcui/common.cljs
@@ -310,8 +310,12 @@
                                        (when-not (:close-on-click props)
                                          (.is element$ (.-target e))
                                          (pos? (.-length (.find element$ (.-target e))))))
-                           (.foundation element$ "close")
-                           (.off (js/$ "body") "click.zf.dropdown"))))))))
+                           ;; Delaying this until the next tick allows React event handlers to fire.
+                           (js/setTimeout
+                            (fn []
+                              (.foundation element$ "close")
+                              (.off (js/$ "body") "click.zf.dropdown"))
+                            0))))))))
        :will-unmount
        (fn [element]
          (.off (js/$ (react/find-dom-node this)) "click")


fix follow button location

fix follow button location

--- src/cljs/salava/badge/ui/modal.cljs
+++ src/cljs/salava/badge/ui/modal.cljs
@@ -41,7 +41,7 @@
         {:keys [name description tags criteria_content image_file image_file issuer_content_name issuer_content_url issuer_contact issuer_image issuer_description criteria_url  creator_name creator_url creator_email creator_image creator_description message_count]} (content-setter @selected-language content)]
     [:div

-     [:div {:id "badge-contents"}
+     [:div
       [:div.pull-right
       [follow-badge badge_id]]]
      [:div {:id "badge-info"}


Function naming improvements on hmac ns (with proper backward compatibility)

--- src/clojure/buddy/core/mac/hmac.clj
+++ src/clojure/buddy/core/mac/hmac.clj
@@ -14,6 +14,7 @@

 (ns buddy.core.mac.hmac
   "Hash-based Message Authentication Codes (HMACs)"
+  (:refer-clojure :exclude [hash])
   (:require [buddy.core.codecs :refer :all]
             [buddy.core.mac.proto :as proto]
             [buddy.core.hash :as hash]
@@ -43,23 +44,26 @@
           (.doFinal mac buffer 0)
           buffer)))))

+(defprotocol IHMac
+  (hash* [data key alg] "Generate the hmac digest for provided data.")
+  (verify* [data signature key alg] "Virify the hmac digest for provided data."))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Low level private function with all logic for make
-;; hmac for distinct types.
+;; Implementation details for different data types.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn- make-hmac-for-plain-data
+(defn- hash-plain-data
   [^bytes input key ^Keyword alg]
   (let [engine (hmac-engine key alg)]
     (proto/update! engine input)
     (proto/end! engine)))

-(defn- verify-hmac-for-plain-data
+(defn- verify-plain-data
   [^bytes input, ^bytes signature, pkey, ^Keyword alg]
-  (let [sig (make-hmac-for-plain-data input pkey alg)]
+  (let [sig (hash-plain-data input pkey alg)]
     (Arrays/equals sig signature)))

-(defn- make-hmac-for-stream
+(defn- hash-stream-data
   [^java.io.InputStream input key ^Keyword alg]
   (let [engine (hmac-engine key alg)
         buffer (byte-array 5120)]
@@ -70,71 +74,65 @@
           (recur))))
     (proto/end! engine)))

-(defn- verify-hmac-for-stream
+(defn- verify-stream
   [^java.io.InputStream input, ^bytes signature, pkey, ^Keyword alg]
-  (let [sig (make-hmac-for-stream input pkey alg)]
+  (let [sig (hash-stream-data input pkey alg)]
     (Arrays/equals sig signature)))

-(defprotocol HMacType
-  "Unified protocol for calculate a keyed-hash message.
-  It comes with default implementations for bytes, String,
-  InputStream, File, URL and URI."
-  (make-hmac [data key alg] "Calculate hmac for input using key and alg.")
-  (verify-hmac [data signature key alg] "Verify hmac for input using key and alg."))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Implementation of IMac protocol
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(alter-meta! #'make-hmac assoc :no-doc true :private true)
-(alter-meta! #'verify-hmac assoc :no-doc true :private true)
-
-(extend-protocol HMacType
+(extend-protocol IHMac
   (Class/forName "[B")
-  (make-hmac [^bytes input key ^Keyword alg]
-    (make-hmac-for-plain-data input key alg))
-  (verify-hmac [^bytes input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-plain-data input signature key alg))
+  (hash* [^bytes input key ^Keyword alg]
+    (hash-plain-data input key alg))
+  (verify* [^bytes input ^bytes signature ^String key ^Keyword alg]
+    (verify-plain-data input signature key alg))

   java.lang.String
-  (make-hmac [^String input key ^Keyword alg]
-    (make-hmac-for-plain-data (->byte-array input) key alg))
-  (verify-hmac [^String input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-plain-data (->byte-array input) signature key alg))
+  (hash* [^String input key ^Keyword alg]
+    (hash-plain-data (->byte-array input) key alg))
+  (verify* [^String input ^bytes signature ^String key ^Keyword alg]
+    (verify-plain-data (->byte-array input) signature key alg))

   java.io.InputStream
-  (make-hmac [^java.io.InputStream input key ^Keyword alg]
-    (make-hmac-for-stream input key alg))
-  (verify-hmac [^java.io.InputStream input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-stream input signature key alg))
+  (hash* [^java.io.InputStream input key ^Keyword alg]
+    (hash-stream-data input key alg))
+  (verify* [^java.io.InputStream input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream input signature key alg))

   java.io.File
-  (make-hmac [^java.io.File input key ^Keyword alg]
-    (make-hmac-for-stream (io/input-stream input) key alg))
-  (verify-hmac [^java.io.File input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-stream (io/input-stream input) signature key alg))
+  (hash* [^java.io.File input key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.io.File input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream (io/input-stream input) signature key alg))

   java.net.URL
-  (make-hmac [^java.net.URL input key ^Keyword alg]
-    (make-hmac-for-stream (io/input-stream input) key alg))
-  (verify-hmac [^java.net.URL input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-stream (io/input-stream input) signature key alg))
+  (hash* [^java.net.URL input key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.net.URL input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream (io/input-stream input) signature key alg))

   java.net.URI
-  (make-hmac [^java.net.URI input key ^Keyword alg]
-    (make-hmac-for-stream (io/input-stream input) key alg))
-  (verify-hmac [^java.net.URI input ^bytes signature ^String key ^Keyword alg]
-    (verify-hmac-for-stream (io/input-stream input) signature key alg)))
+  (hash* [^java.net.URI input key ^Keyword alg]
+    (hash-stream-data (io/input-stream input) key alg))
+  (verify* [^java.net.URI input ^bytes signature ^String key ^Keyword alg]
+    (verify-stream (io/input-stream input) signature key alg)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; High level interface
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn hmac
-  "Make hmac for arbitrary input.
+(defn hash
+  "Generate hmac digest for arbitrary
+  input data, a secret key and hash algorithm.

-  Example:
-    (hmac \"foo bar\" \"secret\" :sha256)
-    ;; => #<byte[] [B@465d154e>
-  "
-  [input key ^Keyword alg]
-  (make-hmac input key alg))
+  If algorithm is not supplied, sha256
+  will be used as default value."
+  ([input key] (hash input key :sha256))
+  ([input key alg]
+   (hash* input key alg)))

 (defn verify
   "Verify hmac for artbitrary input and signature.
@@ -145,4 +143,8 @@
     ;; => true
   "
   [input ^bytes signature key ^Keyword alg]
-  (verify-hmac input signature key alg))
+  (verify* input signature key alg))
+
+(def ^{:doc "Deprecated alias for `hash` function.`"
+       :deprecated true}
+  hmac hash)


Support named destructuring on defresolver

--- src/com/wsscode/pathom/connect.cljc
+++ src/com/wsscode/pathom/connect.cljc
@@ -1557,6 +1557,7 @@
        (s/every
          (s/or :simple-keys-binding ::simple-keys-binding
                :qualified-keys-bindings ::qualified-keys-binding
+               :named-extract (s/tuple ::operation-argument keyword?)
                :as ::as-binding)
          :kind map?))

@@ -1583,13 +1584,16 @@
 (defn as-entry? [x] (= :as (first x)))

 (defn extract-destructure-map-keys-as-keywords [m]
-  (into #{}
+  (into []
         (comp
           (remove as-entry?)
           (mapcat
-            (fn [[k vals]]
-              (map #(keyword (or (namespace %)
-                                 (namespace k)) (name %)) vals))))
+            (fn [[k val]]
+              (if (and (keyword? k)
+                       (= "keys" (name k)))
+                (map #(keyword (or (namespace %)
+                                   (namespace k)) (name %)) val)
+                [val]))))
         m))

 (defn params->resolver-options [{:keys [arglist options body docstring]}]


position tiles at the right location

position tiles at the right location

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

--- plugins/SlideExplorer2/src/slide_explorer/display.clj
+++ plugins/SlideExplorer2/src/slide_explorer/display.clj
@@ -47,8 +47,9 @@

 ;; tile/pixels

-(defn tile-to-pixels [[nx ny] [tile-width tile-height]]
-  [(* nx tile-width) (* ny tile-height)])
+(defn tile-to-pixels [[nx ny] [tile-width tile-height] tile-zoom]
+  [(int (* (Math/pow 2.0 tile-zoom) nx tile-width))
+   (int (* (Math/pow 2.0 tile-zoom) ny tile-height))])

 (defn round-int
   "Round x to the nearest integer."
@@ -185,9 +186,10 @@
                            RenderingHints/VALUE_ANTIALIAS_ON
                            RenderingHints/VALUE_ANTIALIAS_OFF)))))

-(defn paint-tiles [^Graphics2D g available-tiles]
-  (doseq [[[nx ny nz nt nc nzoom] tagged-image] available-tiles]
-    (let [[x y] (tile-to-pixels [nx ny] [512 512])]
+(defn paint-tiles [^Graphics2D g available-tiles zoom]
+  (doseq [[[nx ny nz nt nc nzoom] tagged-image] available-tiles
+          :when (= nzoom zoom)]
+    (let [[x y] (tile-to-pixels [nx ny] [512 512] zoom)]
       (when tagged-image
         (.drawImage g (awt-image tagged-image)
                     x y nil)))))
@@ -197,7 +199,7 @@
     (doto g
       (.translate (:x @screen-state) (:y @screen-state))
       enable-anti-aliasing
-      (paint-tiles @available-tiles)
+      (paint-tiles @available-tiles (:zoom @screen-state))
       (.translate (- (:x @screen-state)) (- (:y @screen-state)))
       (.setColor (Color. 0x00A08F))
       (.fillOval (- (+ (/ (:width @screen-state) 2)


cleanup submit event

cleanup submit event

--- priv/ui/src/cljs/holiday_ping_ui/channels/events.cljs
+++ priv/ui/src/cljs/holiday_ping_ui/channels/events.cljs
@@ -59,7 +59,6 @@
            (fn [channels]
              (remove #(= (:name %) channel) channels)))))

-;; FIXME adapt this to new form
 (re-frame/reg-event-fx
  :channel-edit-submit
  (fn [{db :db} [_ {:keys [name type url targets username emoji days-before
@@ -74,19 +73,15 @@
                                       :url      url
                                       :username username
                                       :emoji    emoji}}]
-     (cond
-       (some string/blank? [name url])
-       {:dispatch [:error-message "Please fill required fields."]}
-
-       :else {:http-xhrio {:method          :put
-                           :uri             (str "/api/channels/" name)
-                           :headers         {:authorization (str "Bearer " (:access-token db))}
-                           :timeout         8000
-                           :format          (ajax/json-request-format)
-                           :params          params
-                           :response-format (ajax/text-response-format)
-                           :on-success      [:navigate :channel-list]
-                           :on-failure      [:error-message "Channel submission failed"]}}))))
+     {:http-xhrio {:method          :put
+                   :uri             (str "/api/channels/" name)
+                   :headers         {:authorization (str "Bearer " (:access-token db))}
+                   :timeout         8000
+                   :format          (ajax/json-request-format)
+                   :params          params
+                   :response-format (ajax/text-response-format)
+                   :on-success      [:navigate :channel-list]
+                   :on-failure      [:error-message "Channel submission failed"]}})))

 (re-frame/reg-event-fx
  :wizard-submit


Mostly complete but I still need to compile this beast.

--- src-cljs/app/main.cljs
+++ src-cljs/app/main.cljs
@@ -8,9 +8,10 @@
 ;; Atoms
 ;;------------------------------------------------------------------------------

-(def snapshots (atom nil))
+(def snapshot-list (atom nil))
+(def snapshot-index (atom nil)) ; can this be derived from current time, quickly?
 (def selected-time (atom nil))
-(def url-update-timout (atom nil)) ; This probably doesn't need to be atom, maybe be clojure feature that handles this
+(def url-update-timeout (atom nil)) ; This probably doesn't need to be atom, maybe be clojure feature that handles this

 ;;------------------------------------------------------------------------------
 ;; Timepicker
@@ -70,16 +71,30 @@
 (defn set-minutes! [new-mins]
   (swap! selected-time doto (.setMinutes new-mins)))

-(defn use-index-time! [index]
-  (swap! selected-time #(-> (@snapshot-list index) :time Date.)))
+(defn sync-time-with-snapshot! []
+  (swap! selected-time #(js/Date. (:time @snapshot-index))))
+
+; TODO: This could be improved. Probably need to rethink my data model
+(defn show-closest-snapshot! []
+  (let [timestamp (.getTime @selected-time)]
+        earlier-index (keep-indexed #(if (>= timestamp (:time %2)) %1) @snapshot-list)
+        later-index (dec earlier-index)
+        later (:time (@snapshot-list later-index))
+        earlier (:time (@snapshot-list earlier-index))
+        display-index (if (< (- later timestamp) (- timestamp earlier))
+                        later-index
+                        earlier-index))
+    (swap! selected-index #(display-index)))
+
+(defn set-url! [timestamp]
+  (let [base-url (.split js/document.URL "?")
+        new-url (str base-url "?time=" timestamp)])
+    (.replaceState js/history nil nil new-url))

 ;;------------------------------------------------------------------------------
 ;; Watchers
 ;;------------------------------------------------------------------------------

-(defn )
-
-; TODO: Find closest index
 (defn on-selected-time-change [_ _ _ new-time]
   (let [hour (.getHours new-time)
         meridian (if (> 11 hour) "PM" "AM")
@@ -87,20 +102,24 @@
     (val ($ "#hour") (pad hour))
     (val ($ "#minute") (pad (.getMinutes new-time)))
     (val ($ "#meridian") meridian)
-    (.datepicker ($ "#datepicker") "update" new-time))
-    )
-; CONTINUE HERE - REWORKING snapshots, selected-time atom
-
-  (let [snapshot (@snapshots new-index)
+    (.datepicker ($ "#datepicker") "update" new-time)))
+
+(add-watch timestamp :_ on-selected-time-change)
+
+(defn on-snapshot-index-change [_ _ _ new-index]
+  (let [snapshot (@snapshot-list new-index)
         time (Date. (:time snapshot))
         image (:image snapshot)
         time-display (str (.toDateString time) " " (.toLocaleTimeString time))]
     (attr ($ "#currentSnapshot") "src" image)
     (text ($ "#imageDateTime") time-display)
     (prop ($ "#earlier") "disabled" (= (inc new-index) (count @snapshot-list)))
-    (prop ($ "#later") "disabled" (zero? new-index))))
-
-(add-watch timestamp :_ on-selected-time-change)
+    (prop ($ "#later") "disabled" (zero? new-index))
+    ; delay updating the url in case user is rapidly switching times
+    (js/clearTimeout @url-update-timeout)
+    (swap! url-update-timeout #(js/setTimeout set-url time 200))))
+
+(add-watch snapshot-index :_ on-snapshot-index-change)

 ;;------------------------------------------------------------------------------
 ;; Events
@@ -126,27 +145,36 @@
 (defn click-toggle-meridian []
   (let [hours (+ (get-hours) 12)
         hours (if (>= 24 ) (- 24 hours) hours)]
-    (set-hours! hours)))
+    (set-hours! hours)
+    (show-closest-snapshot!)))

 (defn click-decrement-hour []
-  (set-hours! (dec (get-hours))))
+  (set-hours! (dec (get-hours)))
+  (show-closest-snapshot!))

 (defn click-increment-hour []
-  (set-hours! (inc (get-hours))))
+  (set-hours! (inc (get-hours)))
+  (show-closest-snapshot!))

 (defn click-decrement-Minute []
-  (set-minutes! (dec (get-minutes))))
+  (set-minutes! (dec (get-minutes)))
+  (show-closest-snapshot!))

 (defn click-increment-minute []
-  (set-minutes! (inc (get-minutes)))))
+  (set-minutes! (inc (get-minutes)))
+  (show-closest-snapshot!)))

 (defn click-later []
   (if (pos? @snapshot-index)
-    (use-index-time! (dec @snapshot-index))))
+    (do
+      (swap! snapshot-index dec)
+      (sync-time-with-snapshot!))))

 (defn click-earlier []
-  (if (>= @snapshot-index (count @snapshot-list)
-    (use-index-time! (inc @snapshot-index)))))
+  (if (>= @snapshot-index (count @snapshot-list))
+    (do
+      (swap! snapshot-index inc)
+      (sync-time-with-snapshot!))))

 (defn add-events []
   (aset js/window "onpopstate" on-popstate)


Fix call to `fetch-inbox!'

Fix call to `fetch-inbox!'

--- src-cljs/pepa/api.cljs
+++ src-cljs/pepa/api.cljs
@@ -292,7 +292,7 @@
     (let [page-ids (:inbox changes)
           pages (mapv fetch-page page-ids)]
       ;; Just overwrite the inbox-stuff for now
-      (fetch-inbox! (om/root-cursor data/state)))))
+      (fetch-inbox!))))

 (defmethod entities-changed* :tags [state _ changes]
   (when-let [tags (:tags changes)]


added some tests

added some tests

--- test/hydrofoil/expectations/model.clj
+++ test/hydrofoil/expectations/model.clj
@@ -72,3 +72,20 @@
         (round-double (camber-function (NACA-design 4.75 9 12) 0.9)))

 ;;; --------- gradient-function tests ------------
+; M = 0| P = 45| x = .5
+(expect 0.0
+        (round-double (gradient-function (NACA-design 0 45 12) 0.5)))
+
+; M = 4.75| P = 45| x =.32
+(expect 0.0196
+        (round-double (gradient-function (NACA-design 4.75 45 12) 0.32)))
+
+; M = 9.5| P = 45| x = .48
+(expect 0.0377
+        (round-double (gradient-function (NACA-design 9.5 45 12) 0.48)))
+
+; M = 4.5| P = .0001| x = .64
+
+
+; M = 4.5| P = 90| x = .8
+


Отладка галереи

Отладка галереи

--- radiolamp-6P3S/src/ixinfestor/omut.cljs
+++ radiolamp-6P3S/src/ixinfestor/omut.cljs
@@ -3127,23 +3127,26 @@
   (letfn [(img-setup []
                 (om/update-state!
                  own (fn [{:keys [div-id img-id deg] :as state}]
-                       (let [r?    (or (= deg 90) (= deg 270))
-                             div-w (-> div-id by-id .-clientWidth)
-                             div-h (-> div-id by-id .-clientHeight)
-                             img-w (-> img-id by-id .-clientWidth)
-                             img-h (-> img-id by-id .-clientHeight)
-                             fat?  (>= img-w img-h)]
-                         (assoc state
-                                :img-margin-top (when r?
+                       (let [div (by-id div-id)
+                             img (by-id img-id)]
+                         (when (and div img)
+                           (let [r?    (or (= deg 90) (= deg 270))
+                                 div-w (.-clientWidth  div)
+                                 div-h (.-clientHeight div)
+                                 img-w (.-clientWidth  img)
+                                 img-h (.-clientHeight img)
+                                 fat?  (>= img-w img-h)]
+                             (assoc state
+                                    :img-margin-top (when r?
+                                                      (if fat?
+                                                        (* 0.5 (- img-w img-h))
+                                                        nil))
+                                    :div-height (when r?
                                                   (if fat?
-                                                    (* 0.5 (- img-w img-h))
+                                                    (+ 12 img-w)
                                                     nil))
-                                :div-height (when r?
-                                              (if fat?
-                                                (+ 12 img-w)
-                                                nil))
-                                :img-height (when (and r? (not fat?))
-                                              div-w))))))]
+                                    :img-height (when (and r? (not fat?))
+                                                  div-w))))))))]
     (reify

       om/IInitState


add benchmark for getting first element of a vector

--- scripts/benchmarks.clj
+++ scripts/benchmarks.clj
@@ -164,6 +164,14 @@
     (map-vals-map-iterable-transient data inc)))

+(let [data [1 2 3 4 5 6 7 8 9 10]]
+  (run-benchmark "first value of a vector" 10000000
+    (first data)
+    (select-any ALL data)
+    (select-any FIRST data)
+    (select-first ALL data)
+    ))
+
 (let [data [1 2 3 4 5]]
   (run-benchmark "map a function over a vector" 1000000
     (vec (map inc data))


Add handling for Avros Utf8 type

Add handling for Avros Utf8 type

--- sherpa-clojure/src/main/clojure/sherpa/avro_utils.clj
+++ sherpa-clojure/src/main/clojure/sherpa/avro_utils.clj
@@ -3,7 +3,8 @@
   (:import [clojure.lang Keyword Associative]
            [org.apache.avro Schema$Type]
            [org.apache.avro.generic GenericData$Record GenericData$EnumSymbol
-            GenericRecord GenericEnumSymbol]))
+            GenericRecord GenericEnumSymbol]
+           [org.apache.avro.util Utf8]))

 (defmulti to-avro (fn [data protocol] (class data)))

@@ -75,6 +76,8 @@

 (defmethod from-avro :default [avro-data protocol] avro-data)

+(defmethod from-avro Utf8 [avro-data protocol] (.toString avro-data))
+
 (defn fqname-to-keyword [fqname]
   (let [parts (split fqname #"\.")]
     (if (> (count parts) 1)


Add ability to set custom embed timestamp

--- src/main/resources/sandbox-init.clj
+++ src/main/resources/sandbox-init.clj
@@ -29,7 +29,9 @@
         (doseq [[t d i] (partition 3 fields)] (embed-field builder t d i))
         builder)))

-  (defn embed-stamp [embed] (.timestamp embed (java.time.Instant/now) ) embed)
+  (defn embed-stamp
+    ([embed] (embed-stamp embed (java.time.Instant/now)))
+    ([embed timestamp] (.timestamp embed timestamp) embed))

   ;; Simple embed function bindings
   (def embed-color (memfn color r g b))


Clean up card output when no image is specified

--- src/main/untangled/ui/elements.cljc
+++ src/main/untangled/ui/elements.cljc
@@ -194,7 +194,7 @@
         legal-sizes  #{:expand :wide}
         id-class     (gensym "c-card--")
         className    (or className "")
-        classes      (cond-> (str "c-card " id-class className)
+        classes      (cond-> (str "c-card " (when image id-class) className)
                        (contains? legal-kinds kind) (str " c-card--" (name kind))
                        (contains? legal-colors color) (str " c-card--" (name color))
                        (contains? legal-sizes size) (str " c-card--" (name size)))
@@ -224,10 +224,9 @@
         (dom/div #js {:className "c-card__menu"}
           (menu/ui-menu menu :style :icon)
           ))
-      (dom/style nil
-        (str "." id-class" .c-card__title { background-image: url(" image "); }")
-        )
-      )))
+      (when image
+        (dom/style nil
+         (str "." id-class " .c-card__title { background-image: url(" image "); }"))))))

 (let [render-input (fn [{:keys [type id] :as props}]


Update user settings sidebar nav strings

--- src-cljs/frontend/components/pages/user_settings.cljs
+++ src-cljs/frontend/components/pages/user_settings.cljs
@@ -22,11 +22,11 @@
   (remove
     nil?
     [{:type :subpage :href (routes/v1-account) :title "Account Integrations" :subpage :integrations}
-     {:type :subpage :href (routes/v1-account-subpage {:subpage "notifications"}) :title "Notifications" :subpage :notifications}
-     {:type :subpage :href (routes/v1-account-subpage {:subpage "api"}) :title "API Tokens" :subpage :api}
-     {:type :subpage :href (routes/v1-account-subpage {:subpage "heroku"}) :title "Heroku" :subpage :heroku}
+     {:type :subpage :href (routes/v1-account-subpage {:subpage "notifications"}) :title "Notification Settings" :subpage :notifications}
+     {:type :subpage :href (routes/v1-account-subpage {:subpage "api"}) :title "Personal API Tokens" :subpage :api}
+     {:type :subpage :href (routes/v1-account-subpage {:subpage "heroku"}) :title "Heroku API Key" :subpage :heroku}
      (when-not (config/enterprise?)
-       {:type :subpage :href (routes/v1-account-subpage {:subpage "plans"}) :title "Plan Pricing" :subpage :plans})
+       {:type :subpage :href (routes/v1-account-subpage {:subpage "plans"}) :title "Organization Plans" :subpage :plans})
      (when-not (config/enterprise?)
        {:type :subpage :href (routes/v1-account-subpage {:subpage "beta"}) :title "Beta Program" :subpage :beta})]))


Add thread poll to Carbon service

Add thread poll to Carbon service

--- src/org/spootnik/cyanite/carbon.clj
+++ src/org/spootnik/cyanite/carbon.clj
@@ -5,6 +5,7 @@
             [org.spootnik.cyanite.store :as store]
             [org.spootnik.cyanite.path  :as path]
             [org.spootnik.cyanite.tcp   :as tc]
+            [com.climate.claypoole      :as cp]
             [org.spootnik.cyanite.util  :refer [partition-or-time get-aggregator-patterns
                                                 get-blacklist-patterns
                                                 counter-get counter-list
@@ -71,21 +72,25 @@
     (catch Exception e
       (info "Exception for metric [" input "] : " e))))

+(defn process-metrics
+  [rollups insertch indexch metrics]
+  (counter-inc! :metrics_received (count metrics))
+  (doseq [metric metrics]
+    (let [formed (remove nil? (formatter rollups metric))]
+      (doseq [f formed]
+        (>!! insertch f))
+      (doseq [p (distinct (map (juxt :path :tenant) formed))]
+        (>!! indexch p)))))
+
 (defn format-processor
   "Send each metric over to the cassandra store"
-  [chan indexch rollups insertch]
+  [chan indexch rollups insertch tpool]
   (go
     (let [input (partition-or-time 1000 chan 500 5)]
       (while true
         (let [metrics (<! input)]
           (try
-            (counter-inc! :metrics_received (count metrics))
-            (doseq [metric metrics]
-              (let [formed (remove nil? (formatter rollups metric))]
-                (doseq [f formed]
-                  (>! insertch f))
-                (doseq [p (distinct (map (juxt :path :tenant) formed))]
-                  (>! indexch p))))
+            (cp/future tpool (process-metrics rollups insertch indexch metrics))
             (catch Exception e
               (info "Exception for metric [" metrics "] : " e))))))))

@@ -95,7 +100,8 @@
   (let [indexch (path/channel-for index)
         insertch (store/channel-for store-middleware)
         chan (chan 100000)
-        handler (format-processor chan indexch (:rollups carbon) insertch)]
+        tpool (cp/threadpool (:threadpool_size carbon (cp/ncpus)))
+        handler (format-processor chan indexch (:rollups carbon) insertch tpool)]
     (info "starting carbon handler: " carbon)
     (go
       (let [{:keys [hostname tenant interval console]} stats]


CMR-7735 Addresses PR comments

CMR-7735 Addresses PR comments

--- transmit-lib/src/cmr/transmit/urs.clj
+++ transmit-lib/src/cmr/transmit/urs.clj
@@ -75,7 +75,7 @@
                                                           :method :get
                                                           :raw? true})]
     (when-not (= 200 status)
-      (info (format "Cannot get info for username [%s] in URS. Failed with status code [%d].
+      (error (format "Cannot get info for username [%s] in URS. Failed with status code [%d].
         EDL error message: [%s]" user status (pr-str body)))
       (errors/throw-service-error
         :unauthorized
@@ -98,11 +98,8 @@
                                                           :http-options {:query-params
                                                                          {:user_ids
                                                                           user-id}}})]
-    (info "DEBUGz1" status)
-    (info "DEBUGz2" (pr-str body))
-    (info "DEBUGz3" user-id)
     (when-not (= 200 status)
-      (info (format "Cannot get group info for username [%s] in URS. Failed with status code [%d].
+      (error (format "Cannot get group info for username [%s] in URS. Failed with status code [%d].
         EDL error message: [%s]" user-id status (pr-str body)))
       (errors/throw-service-error
         :unauthorized


Simplify reporting for flattened examples

--- src/main/clojure/com/stuartsierra/lazytest/report.clj
+++ src/main/clojure/com/stuartsierra/lazytest/report.clj
@@ -6,8 +6,8 @@
   (:import (java.io File)))

 (defn details
-  "Given a TestResult, returns the map of :name, :ns, :file, :line,
-  :generator, and :form."
+  "Given a TestResult, returns the map of :ns, :file, :line,
+  and :form."
   [r]
   (meta (:source r)))

@@ -24,9 +24,6 @@
     (when-let [n (:name m)] (println "Name:" n))
     (when-let [nn (:ns m)] (println "NS:  " (ns-name nn)))
     (when-let [d (:doc m)] (println "Doc: " d))
-    (when (and (:form m) (not (:name m)))
-      (print "Form: ")
-      (prn (:form m)))
     (when-let [f (:file m)] (println "File:" f))
     (when-let [l (:line m)] (println "Line:" l))
     (when (seq (:locals m))
@@ -63,7 +60,7 @@

 (defn print-summary [r]
   (let [{:keys [assertions pass fail error pending]} (summary r)]
-    (println (colorize (str "Ran " assertions " assertions.")
+    (println (colorize (str "Ran " assertions " examples.")
                        (if (zero? assertions) :fg-yellow :reset)))
     (print (colorize (str fail " failures")
                      (if (zero? fail) :fg-green :fg-red)))
@@ -76,36 +73,28 @@
     (newline)
     (flush)))

-(defn- spec-report* [r parents]
-  (if (and (container? r) (not (pending? r)))
-    (doseq [c (:children r)]
-      (spec-report* c (conj parents r)))
-    (if (and (success? r) (not (pending? r)))
-      (do (print (colorize "." :fg-green)) (flush))
-      (do (newline)
-          (print-details
-           (assoc r :source
-                  (vary-meta (:source r) assoc :doc
-                             (apply str (interpose " "
-                                                   (filter identity
-                                                           (map #(:doc (details %))
-                                                                (conj parents r))))))))))))
+(defn- dot-report [r]
+  (if (and (success? r) (not (pending? r)))
+    (do (print (colorize "." :fg-green))
+	(flush))
+    (do (newline)
+	(print-details r))))

-(defn spec-report
-  "Simple report of spec results.  Prints a dot for each passed
-  assertion; prints details for each failure or pending spec.
-  Concatenates :doc strings for nested specs.  Uses ANSI color if
-  com.stuartsierra.lazytest.color/colorize? is true."
+(defn report
+  "Simple report of test results.  Prints a dot for each passed
+  example; prints details for each failure or pending spec.  Uses ANSI
+  color if com.stuartsierra.lazytest.color/colorize? is true."
   [results]
   (newline)
   (doseq [r results]
-    (spec-report* r []))
-  (newline))
+    (dot-report r))
+  (newline)
+  (print-summary results))

 (defn report-and-exit
-  "Calls function f (defaults to spec-report) on test result r and
+  "Calls function f (defaults to report) on test result r and
   exits.  Exit status is 0 if all specs passed, -1 if some failed."
-  ([r] (report-and-exit spec-report r))
-  ([f r]
+  ([r] (report-and-exit r report))
+  ([r f]
      (f r)
      (System/exit (if (success? r) 0 -1))))


Missile cooldown on separate timer

Missile cooldown on separate timer

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -103,6 +103,7 @@
    :shots                  []
    :shooting?              false
    :millis-since-last-shot shot-millis
+   :millis-since-last-missile missile-millis

    :position               [(/ width 2) (/ height 2)]
    :speed                  [0 0]
@@ -353,15 +354,17 @@
 ; Actions
 ; ----------------------------------------------------------------------

-(defn shoot [{:keys [shooting? shots millis-since-last-shot firing?] :as ship}]
+(defn shoot [{:keys [shots shooting? millis-since-last-shot firing? millis-since-last-missile] :as ship}]
   (let [millis-since-last-shot (+ turn-millis millis-since-last-shot)
+        millis-since-last-missile (+ turn-millis millis-since-last-missile)
         shoots? (and shooting? (>= millis-since-last-shot shot-millis))
         shots (if shoots? (conj shots (create-shot ship)) shots)
-        fires? (and firing? (>= millis-since-last-shot shot-millis))
+        fires? (and firing? (>= millis-since-last-missile missile-millis))
         shots (if fires? (conj shots (create-missile ship)) shots)]
     (when shoots? (play-sound "shot"))
     (when fires? (play-sound "missile"))
-    (assoc ship :millis-since-last-shot (if (or shoots? fires?) 0 millis-since-last-shot)
+    (assoc ship :millis-since-last-shot (if shoots? 0 millis-since-last-shot)
+                :millis-since-last-missile (if fires? 0 millis-since-last-missile)
                 :shots shots)))

 (defn basic-move


Clean up resource loading

Clean up resource loading

Now you must run your jars like:
$ java -cp <additional_cp>:blogiseq.jar blogiseq.core

--- src/blogiseq/utils.clj
+++ src/blogiseq/utils.clj
@@ -20,19 +20,12 @@
     (slurp path)))

 (defn parse-resource
-  "Firstly parse path in the `resources/` dir.
-  If not successful, tries loading this from resources.
-  If even this is not succesful and default is provided, returns the provided
-  default.
-  Otherwise return nil."
+  "Loads resource from given path or default if the resource loading returned
+  nil."
   ([path default]
-   (first
-     (filter
-       some?
-       (list
-         (slurp-nil (str "resources/" path))
-         (slurp-nil (clojure.java.io/resource path))
-         default))))
+   (or
+     (slurp-nil (clojure.java.io/resource path))
+     default))
   ([path]
    (parse-resource path nil)))


hide description block from lesson video when description is blank

--- src/cljs/daveconservatoire/site/ui.cljs
+++ src/cljs/daveconservatoire/site/ui.cljs
@@ -12,7 +12,8 @@
             [untangled.client.data-fetch :as df]
             [untangled.client.impl.data-fetch :as dfi]
             [cljs.spec :as s]
-            [daveconservatoire.site.ui.listeners :as l])
+            [daveconservatoire.site.ui.listeners :as l]
+            [clojure.string :as str])
   (:import goog.i18n.DateTimeFormat))

 (defn ordinal-suffix [i]
@@ -746,8 +747,8 @@
               (dom/div #js {:className "vendor"}
                 (ytp/youtube-player (om/computed {:videoId id}
                                                  {:on-state-change #(if %2 (report-video-play this))})))
-              (dom/div #js {:className "well"}
-                description))
+              (if-not (str/blank? description)
+                (dom/div #js {:className "well"} description)))
             (lesson-pagination pagination)))))))

 (def lesson-video (om/factory LessonVideo))


cosmetics

cosmetics

--- src/clojure/ch/hood/odpg/impl/expdp.clj
+++ src/clojure/ch/hood/odpg/impl/expdp.clj
@@ -98,7 +98,7 @@
 				 (.get cal Calendar/MONTH) "_"
 				 (.get cal Calendar/DAY_OF_MONTH))))

-(defn header [ctx {:keys [remote-link file-prefix directory]}]
+(defn render-header [ctx {:keys [remote-link file-prefix directory]}]
 	(let [file-basename (str file-prefix "_" (render-today))]
 		(str/join "\n"
 							["declare"
@@ -108,10 +108,10 @@
 							 (str "handle := dbms_datapump.open('EXPORT', 'SCHEMA'"
 										(if (nil? remote-link) "" (str ", remote_link => " (single-quote remote-link))) ");")
 							 (render-add-file ctx directory :dump-file file-basename)
-							 (render-add-file ctx directory :log-file file-basename)
+							 (render-add-file ctx directory :log-file (str file-basename "_exp"))
 							 ])))

-(defn footer [ctx]
+(defn render-footer [ctx]
 	(str/join "\n"
 						["dbms_datapump.start_job(handle => handle);"
 						 "dbms_datapump.wait_for_job(handle => handle, job_state => job_state);"
@@ -133,9 +133,9 @@
 		(validate exp-data)
 		(let [ctx nil]
 			(str/join "\n"
-								[(header ctx exp-data)
+								[(render-header ctx exp-data)
 								 (render-schemas ctx exp-data)
-								 (footer ctx)])))
+								 (render-footer ctx)])))
 	([file exp-data :- ExpData]
 		(let [script (render-exp-script exp-data)]
 			(spit file script))))


Test having res-ch in change-reqs.

Test having res-ch in change-reqs.

--- src/cbfg/test/kvs.cljs
+++ src/cbfg/test/kvs.cljs
@@ -196,6 +196,22 @@
                          (dissoc (merge m4 {:status :ok})
                                  :change-reqs)
                          (atake tkvs res-ch4))))
+                   (let [res-ch4-1 (achan tkvs) ; Test different res-ch.
+                         m4 {:opaque @n
+                             :op :multi-change
+                             :kvs-ident (:kvs-ident open)
+                             :change-reqs [{:change-fn noop-change
+                                            :res-ch res-ch4-1}]}]
+                     (aput tkvs cmd-ch m4)
+                     (and
+                      (e n (atake tkvs res-ch4-1)
+                         (dissoc (merge m4 {:more true :status :ok})
+                                 :change-reqs)
+                         nil)
+                      (e n (atake tkvs res-ch4-1)
+                         (dissoc (merge m4 {:status :ok})
+                                 :change-reqs)
+                         (atake tkvs res-ch4-1))))
                    (let [res-ch5 (achan tkvs) ; Test several noop-changes.
                          m5 {:opaque @n
                              :res-ch res-ch5


Log configuration errors

Log configuration errors

--- src/clj/shale/core.clj
+++ src/clj/shale/core.clj
@@ -102,4 +102,5 @@
     (init)
     (start)
     (catch Exception e
+      (logging/error e)
       (stop))))


testing:use cookie-store for ring session testing

--- test/clojure/nginx/clojure/ring_handlers_for_test.clj
+++ test/clojure/nginx/clojure/ring_handlers_for_test.clj
@@ -5,6 +5,7 @@
         [ring.middleware.params]
         [ring.middleware.content-type]
         [ring.middleware.session.memory]
+        [ring.middleware.session.cookie]
         ;sadly ring.middleware.multipart-params is dependent on servlet api so we must comment it
         ;[ring.middleware.multipart-params]
         [compojure.core]
@@ -12,7 +13,7 @@
   (:require [compojure.route :as route])
   (:import [ring.middleware.session.memory.MemoryStore]))

-(def my-session-store (memory-store))
+(def my-session-store (cookie-store {:key "my-secrect-key!!"}))

 (defn- echo-handler [r]
   {:status 200
@@ -29,6 +30,7 @@
         (assoc :session session))))

 (defroutes ring-compojure-test-handler
+  (GET "/hello2" [] {:status 200, :headers {"content-type" "text/plain"}, :body "Hello World"})
   (GET "/hello" [] (-> (response "Hello World")
     (content-type "text/plain")))
   (GET "/redirect" [] (redirect "http://example.com"))


New tests: test-format-date-existence, test-format-date-time-existence and test-format-date-using-desired-format-existence

--- test/clj_calendar/calendar_test.clj
+++ test/clj_calendar/calendar_test.clj
@@ -55,3 +55,18 @@
     (testing "if the clj-calendar.calendar/get-day-of-week function definition exists."
         (is (callable? 'clj-calendar.calendar/get-day-of-week))))

+(deftest test-format-date-existence
+    "Check that the clj-calendar.calendar/format-date function definition exists."
+    (testing "if the clj-calendar.calendar/format-date function definition exists."
+        (is (callable? 'clj-calendar.calendar/format-date))))
+
+(deftest test-format-date-time-existence
+    "Check that the clj-calendar.calendar/format-date-time function definition exists."
+    (testing "if the clj-calendar.calendar/format-date-time function definition exists."
+        (is (callable? 'clj-calendar.calendar/format-date-time))))
+
+(deftest test-format-date-using-desired-format-existence
+    "Check that the clj-calendar.calendar/format-date-using-desired-format function definition exists."
+    (testing "if the clj-calendar.calendar/format-date-using-desired-format function definition exists."
+        (is (callable? 'clj-calendar.calendar/format-date-using-desired-format))))
+


Make tests work for both clj & cljs

Make tests work for both clj & cljs

--- test/cljc/spec_tools/core_test.cljc
+++ test/cljc/spec_tools/core_test.cljc
@@ -43,7 +43,7 @@

     (testing "wrapped spec does not work as a predicate"
       (let [my-spec (st/spec (s/keys :req [::age]))]
-        (is (thrown? RuntimeException (my-spec {::age 20})))))
+        (is (thrown? #?(:clj Exception, :cljs js/Error) (my-spec {::age 20})))))

     (testing "adding info"
       (let [info {:description "desc"
@@ -144,10 +144,10 @@
   (testing "suceess"
     (is (= 12 (st/conform! ::age "12" st/string-conformers))))
   (testing "failing"
-    (is (thrown? RuntimeException (st/conform! ::age "12")))
+    (is (thrown? #?(:clj Exception, :cljs js/Error) (st/conform! ::age "12")))
     (try
       (st/conform! ::age "12")
-      (catch Exception e
+      (catch #?(:clj Exception, :cljs js/Error) e
         (let [data (ex-data e)]
           (is (= {:type :spec/problems
                   :clojure.spec/problems [{:path [], :pred 'integer?, :val "12", :via [::age], :in []}]


added segment fixing codebase

added segment fixing codebase

--- src/crawler/corpus.clj
+++ src/crawler/corpus.clj
@@ -115,7 +115,7 @@
          (< (count yield-nodes)
             (count prev-nodes)))))

-(defn refine-action-seq
+(defn seqs-to-refine
   [action-seq corpus]
   (let [action-segments (reductions
                          (fn [acc x]
@@ -125,8 +125,14 @@
     ;; the first one is a nil action at a nil
     ;; point
     (filter
-     (fn [segment] (refine-segment? segment corpus))
-     action-segments)))
+     second
+     (map
+      (fn [segment]
+        [segment (try (nth action-seq (count segment))
+                      (catch IndexOutOfBoundsException e nil))])
+      (filter
+       (fn [segment] (refine-segment? segment corpus))
+       action-segments)))))

 (defn leaf-fix?
   [action-seq corpus]
@@ -140,8 +146,8 @@
                 (fn [[u x]]
                   (:leaf? x))
                 documents)]
-    [(count leaves)
-     (count documents)]))
+    (< (count leaves)
+       (count documents))))

 (defn repair-leaf-fuck-up
   "Try to repair the leaf node yield
@@ -177,6 +183,72 @@
        fat))
      src-docs)))

+(defn refine-segment
+  [segment action-to-take corpus]
+  (let [muscle (map
+                first
+                (filter
+                 (fn [[u x]]
+                   (and
+                    (if (:body x)
+                      (let [action-space (map
+                                          first
+                                          (:xpath-nav-info
+                                           (extractor/state-action
+                                            (:body x)
+                                            {:url u}
+                                            {})))]
+                        (some
+                         (fn [x]
+                           (= x action-to-take))
+                         action-space))
+                      false)
+                    (= (:src-xpath x)
+                       segment)))
+                 corpus))
+        fat     (filter
+                 (fn [[u x]]
+                   (and
+                    (if (:body x)
+                      (let [action-space (map
+                                          first
+                                          (:xpath-nav-info
+                                           (extractor/state-action
+                                            (:body x)
+                                            {:url u}
+                                            {})))]
+                        (not
+                         (some
+                          (fn [x]
+                            (= x action-to-take))
+                          action-space)))
+                      true)
+                    (= (:src-xpath x)
+                       segment)))
+                 corpus)
+
+        docs    (map
+                 (fn [[u x]]
+                   [u (:body x)])
+                 (filter
+                  (fn [[u x]]
+                    (= (:src-xpath x)
+                       segment))
+                  corpus))]
+    (first
+     (first
+      (max-key
+       second
+       (frequencies
+        (map
+         (fn [[u  b]]
+           (dom/refine-xpath-accuracy segment
+                                      b
+                                      u
+                                      muscle
+                                      fat))
+         docs)))))))
+
 (defn refine-model-with-positions
   "Try to maximize the model yield with position info"
   [model corpus]
@@ -214,27 +286,30 @@
            leaf-src-docs (map
                           (fn [u]
                             (:body (corpus u)))
-                          leaf-src-urls)]
+                          leaf-src-urls)
+
+           leaf-fix (first
+                     (first
+                      (max-key
+                       second
+                       (frequencies
+                        (map
+                         (fn [[u b]]
+                           (if leaf-fix-decision
+                             (dom/refine-xpath-accuracy (first action-seq)
+                                                        b
+                                                        u
+                                                        leaf-muscle
+                                                        leaf-fat)
+                             {}))
+                         (map vector leaf-src-urls leaf-src-docs))))))]
       [action-seq
-
        :segments-to-fix
-       (refine-action-seq action-seq
-                          corpus)
-
-       :leaf-fix
-       (first
-        (first
-         (max-key
-          second
-          (frequencies
-           (map
-            (fn [[u b]]
-              (if leaf-fix-decision
-                (dom/refine-xpath-accuracy (first action-seq)
-                                           b
-                                           u
-                                           leaf-muscle
-                                           leaf-fat)
-                {}))
-            (map vector leaf-src-urls leaf-src-docs))))))]))
+       (cons
+        [action-seq leaf-fix]
+        (map
+         (fn [[segment action]]
+           (refine-segment segment action corpus))
+         (seqs-to-refine action-seq
+                         corpus)))]))
    model))


Adding spec for rules

Adding spec for rules

--- src/org/libraryweasel/ligature/core.clj
+++ src/org/libraryweasel/ligature/core.clj
@@ -182,4 +182,8 @@

 (s/def ::statement (s/or ::triple ::triple ::quad ::quad))

+(s/def ::rule (s/or ::triple ::triple))
+
 (s/def ::statements (s/coll-of ::statement))
+
+(s/def ::rules (s/coll-of ::rule))


(PDB-4637) Return tables to analyze from index creators

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -1656,71 +1656,76 @@
     (analyze-if-exists (set/union small-tables requested))))

 (defn run-migrations
-  "Migrates database to the latest schema version. Does nothing if
-  database is already at the latest schema version.  Returns a set of
-  tables that should be analyzed if there were any migrations."
-  []
-  (require-valid-schema)
-  (let [tables (when-let [pending (seq (pending-migrations))]
-                 (->> pending
-                      (map (fn [[version migration]]
-                             (log/info (trs "Applying database migration version {0}"
-                                            version))
-                             (let [t0 (now)]
-                               (let [result (migration)]
-                                 (record-migration! version)
-                                 (log/info (trs "Applied database migration version {0} in {1} ms"
-                                                version (in-millis (interval t0 (now)))))
-                                 result))))
-                      (filter map?)
-                      (map ::vacuum-analyze)
-                      (apply set/union)))]
+  "Runs the requested migrations.  Returns a set of tables that should
+  be analyzed if there were any migrations."
+  [migrations]
+  (let [tables (->> migrations
+                    (map (fn [[version migration]]
+                           (log/info (trs "Applying database migration version {0}"
+                                          version))
+                           (let [t0 (now)]
+                             (let [result (migration)]
+                               (record-migration! version)
+                               (log/info (trs "Applied database migration version {0} in {1} ms"
+                                              version (in-millis (interval t0 (now)))))
+                               result))))
+                    (filter map?)
+                    (map ::vacuum-analyze)
+                    (apply set/union))]
     (when-not (empty? tables)
-      (log/info (trs "There are no pending migrations")))
-    tables))
+      (log/info (trs "There are no pending migrations"))
+      tables)))

 ;; SPECIAL INDEX HANDLING

-(defn trgm-indexes!
+(defn maybe-create-trgm-indexes
   "Create trgm indexes if they do not currently exist."
   []
-  (when-not (sutils/index-exists? "fact_paths_path_trgm")
-    (log/info (trs "Creating additional index `fact_paths_path_trgm`"))
-    (jdbc/do-commands
-     "CREATE INDEX fact_paths_path_trgm ON fact_paths USING gist (path gist_trgm_ops)"))
-
-  (when-not (sutils/index-exists? "packages_name_trgm")
-    (log/info (trs "Creating additional index `packages_name_trgm`"))
-    (jdbc/do-commands
-     ["create index packages_name_trgm on packages"
-      "  using gin (name gin_trgm_ops)"])))
+  (if-not (sutils/pg-extension? "pg_trgm")
+    (do
+      (log/warn
+       (str
+        (trs "PostgreSQL extension `pg_trgm` missing.")
+        (trs "  Unable to create the recommended pg_trgm indexes.\n")
+        (trs "To fix, run this on the PuppetDB database as the database super user:\n")
+        (trs "    CREATE EXTENSION pg_trgm;\n")
+        (trs "Then restart PuppetDB.\n")))
+      nil)
+    (do
+      (when-not (sutils/index-exists? "fact_paths_path_trgm")
+        (log/info (trs "Creating additional index `fact_paths_path_trgm`"))
+        (jdbc/do-commands
+         "CREATE INDEX fact_paths_path_trgm ON fact_paths USING gist (path gist_trgm_ops)"))
+      (when-not (sutils/index-exists? "packages_name_trgm")
+        (log/info (trs "Creating additional index `packages_name_trgm`"))
+        (jdbc/do-commands
+         ["create index packages_name_trgm on packages"
+          "  using gin (name gin_trgm_ops)"]))
+      nil)))

 (defn ensure-report-id-index []
   (when-not (sutils/index-exists? "idx_reports_compound_id")
     (log/info "Indexing reports for id queries")
-
     (jdbc/do-commands
      "create index idx_reports_compound_id on reports
         (producer_timestamp, certname, hash)
         where start_time is not null")
-
-    (jdbc/do-commands-outside-txn
-     "vacuum analyze reports")))
-
-(defn indexes!
+    #{"reports"}))
+
+(defn create-indexes
   "Create missing indexes for applicable database platforms."
   []
-  (if (sutils/pg-extension? "pg_trgm")
-    (trgm-indexes!)
-    (log/warn
-     (str
-      (trs "Missing PostgreSQL extension `pg_trgm`")
-      "\n\n"
-      (trs "We are unable to create the recommended pg_trgm indexes due to\nthe extension not being installed correctly.")
-      " "
-      (trs " Run the command:\n\n    CREATE EXTENSION pg_trgm;\n\nas the database super user on the PuppetDB database to correct\nthis, then restart PuppetDB.\n"))))
-  (ensure-report-id-index))
+  (set/union
+   (maybe-create-trgm-indexes)
+   (ensure-report-id-index)))
+
+(defn update-schema
+  []
+  (jdbc/with-db-transaction []
+    (require-valid-schema)
+    (set/union (run-migrations (pending-migrations))
+               (create-indexes))))

 (defn initialize-schema
   "Ensures the database is migrated to the latest version, and returns
@@ -1728,10 +1733,7 @@
   version, etc. has already been validated."
   []
   (try
-    (let [tables (jdbc/with-db-transaction []
-                   (let [result (run-migrations)]
-                     (indexes!)
-                     result))]
+    (let [tables (update-schema)]
       (analyze-tables tables)
       (not (empty? tables)))
     (catch java.sql.SQLException e


Added parse-first-line function.

Added parse-first-line function.

--- nav-obj-splitter.clj
+++ nav-obj-splitter.clj
@@ -1,26 +1,16 @@
 (ns clj-nav-obj-splitter (:use clojure.test))

-(ns clj-nav-obj-splitter (:use clojure.test System.Text.RegularExpressions))
+;;(clojure.test/is (= 4 (+ 2 2)))

-
-(clojure.test/is (= 4 (+ 2 2)))
-(clojure.test/is (= 5 (+ 2 2)))
-
-
-(re-find #"quick" "The quick brown fox jumps over the lazy dog")
-
-
-
-(re-pattern "^.+ \\d+ .+")
-
-
-(re-find (re-pattern #"^.+ \d+ .+") "Table 100 Test Table")
+(re-find (re-pattern #"^(.+) (\d+) (.+)") "Table 100 Test Table")

 (re-find (re-pattern "^Table|Form|Report|Dataport|XMLport|Page|Codeunit") "Table 100 Test Table")

-(re-find (re-pattern #"\d+") "Table 100 Test Table")
+(defn parse-first-line [line]
+	(let [matches (re-find (re-pattern #"^(.+) (\d+) (.+)") line)
+		  type (nth matches 1)
+		  id (nth matches 2)
+		  name (nth matches 3)]
+		{:type type :id id :name name}))

-(re-find (re-pattern #"\d+") "Table 100 Test Table")
-
-(def matcher (re-matcher #"^(\w+)" "Table 100 Test Table"))
-(re-groups matcher)+(parse-first-line "Table 100 Test Table")


Fix routing issue with docs link

Fix routing issue with docs link

--- src-cljs/frontend/components/account.cljs
+++ src-cljs/frontend/components/account.cljs
@@ -12,6 +12,7 @@
             [frontend.routes :as routes]
             [frontend.state :as state]
             [frontend.utils :as utils :include-macros true]
+            [frontend.utils.html :refer [open-ext]]
             [frontend.utils.github :as gh-utils]
             [frontend.utils.launchdarkly :as ld]
             [frontend.utils.seq :refer [select-in]]
@@ -354,7 +355,7 @@
           "denied" [:div.section
                     "It looks like you've denied CircleCI access to send you web notifications.
                     Before you can change your web notification preferences please "
-                    [:a {:href "https://circleci.com/docs/web-notifications/#turning-notifications-permissions-back-on"}
+                    [:a (open-ext {:href "https://circleci.com/docs/web-notifications/#turning-notifications-permissions-back-on"})
                      "turn on permissions for your browser."]]
           "default" [:div.section
                      "You haven't given CircleCI access to notify you through the browser — "


Add header to Shopify story

Add header to Shopify story

--- src-cljs/frontend/components/stories.cljs
+++ src-cljs/frontend/components/stories.cljs
@@ -144,6 +144,7 @@
        [:div.page.shopify.stories
         [:div.stories-head
          shopify-logo
+         [:h1 "Scalable Continuous Integration with CircleCI"]
          [:blockquote
           {:cite "http://www.shopify.com"}
           [:p "We were able to rapidly grow our team and code base without fear of outgrowing CircleCI."]


Count remaining characters

Count remaining characters

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -13,6 +13,16 @@
             [discuss.utils.common :as lib]
             [discuss.utils.extensions]
             [discuss.utils.views :as vlib]))
+
+;;;; Auxiliary
+(defn- remaining-characters
+  "Show remaining characters needed to submit a post."
+  [statement]
+  (let [remaining (- 10 (count statement))]
+    (if (pos? remaining)
+      (str "Noch " remaining " Zeichen")
+      "Abschicken")))
+

 ;;;; Elements
 (defn control-elements []
@@ -130,7 +140,7 @@
   "Shows selected text from website if available."
   []
   (let [selection (lib/get-selection)]
-    (when (> (count selection) 1)
+    (if (> (count selection) 1)
       (dom/div #js {:className "input-group"}
                (dom/span #js {:className "input-group-addon"}
                          (vlib/fa-icon "fa-quote-left"))
@@ -140,7 +150,8 @@
                          (vlib/fa-icon "fa-quote-right"))
                (dom/span #js {:className "input-group-addon pointer"
                               :onClick   lib/remove-selection}
-                         (vlib/fa-icon "fa-times"))))))
+                         (vlib/fa-icon "fa-times")))
+      (dom/p #js {:className "text-center"} "Möchtest du deine Aussage durch eine Referenz von dieser Seite stützen? Dann markiere einfach einen Teil des Textes mit der Maus."))))

 (defn add-element
   "Show form to add a new statement."
@@ -166,9 +177,12 @@
                                                  :onChange  #(vlib/commit-component-state :statement % owner)
                                                  :value     statement}))
                         (show-selection)
+
                         (dom/button #js {:className "btn btn-default"
-                                         :onClick   #(com/dispatch-add-action statement (lib/get-selection))}
-                                    "Submit"))))))
+                                         :onClick   #(com/dispatch-add-action statement (lib/get-selection))
+                                         :disabled  (> 10 (count statement))}
+                                    (remaining-characters statement))
+                        )))))

 (defn- build-with-buttons
   "Add navigation buttons to the provided view."


Use uplo field to encode whether band is either lower or upper.

--- src/clojure/uncomplicate/neanderthal/internal/navigation.clj
+++ src/clojure/uncomplicate/neanderthal/internal/navigation.clj
@@ -36,7 +36,7 @@
      :kl kl
      :ku ku
      :surface (.surface r)
-     :uplo (if (.isLower r) :lower :upper)
+     :uplo (dec-property (.uplo r))
      :diag (if (.isDiagUnit r) :unit :non-unit)})
   Region
   (accessible [_ i j]
@@ -50,9 +50,9 @@
   (rowEnd [_ i]
     (min n (inc (+ i ku))))
   (isLower [_]
-    (< ku 1))
+    (= 122 uplo))
   (isUpper [_]
-    (< kl 1))
+    (= 121 uplo))
   (isDiagUnit [_]
     (or (= -1 kl) (= -1 ku)))
   (uplo [_]
@@ -71,6 +71,13 @@
   (flip [_]
     (BandRegion. n m ku kl (case uplo 121 122 122 121 0) diag)))

+(defn square-band-region
+  [^long n ^long kl ^long ku ^Boolean lower?]
+  (let [kl (min (max 0 (dec n)) kl)
+        ku (min (max 0 (dec n)) ku)]
+    (BandRegion. n n kl ku (if-not lower? 121 122)
+                 (if (or (= -1 kl) (= -1 ku)) 132 131))))
+
 (defn band-region
   ([^long m ^long n ^long kl ^long ku]
    (let [kl (min (max 0 (dec m)) kl)
@@ -80,8 +87,8 @@
   ([^long n ^Boolean lower? ^Boolean diag-unit?]
    (let [diag-pad (if diag-unit? -1 0)]
      (if lower?
-       (band-region n n (max 0 (dec n)) diag-pad)
-       (band-region n n diag-pad (max 0 (dec n))))))
+       (square-band-region n (max 0 (dec n)) diag-pad lower?)
+       (square-band-region n diag-pad (max 0 (dec n)) lower?))))
   ([^long n lower?]
    (band-region n lower? false)))

@@ -89,14 +96,14 @@
   ([^long n ^long k lower? diag-unit?]
    (let [diag-pad (if diag-unit? -1 0)]
      (if lower?
-       (band-region n n (min (max 0 k) (dec n)) diag-pad)
-       (band-region n n diag-pad (min (max 0 k) (dec n)))))))
+       (square-band-region n (min (max 0 k) (max 0 (dec n))) diag-pad lower?)
+       (square-band-region n diag-pad (min (max 0 k) (max 0 (dec n))) lower?)))))

 (defn sb-region
   ([^long n ^long k lower?]
    (if lower?
-     (band-region n n (min (max 0 k) (dec n)) 0)
-     (band-region n n 0 (min (max 0 k) (dec n))))))
+     (square-band-region n (min (max 0 k) (max 0 (dec n))) 0 lower?)
+     (square-band-region n 0 (min (max 0 k) (max 0 (dec n))) lower?))))

 (deftype GERegion [^long m ^long n]
   Object
@@ -116,7 +123,7 @@
      :kl (.kl r)
      :ku (.ku r)
      :surface (.surface r)
-     :uplo (if (.isLower r) :lower :upper)
+     :uplo (dec-property (.uplo r))
      :diag (if (.isDiagUnit r) :unit :non-unit)})
   Region
   (accessible [_ _ _]


Fix error message and time stamp

Fix error message and time stamp

--- src/atom_finder/questions/bug_patches.clj
+++ src/atom_finder/questions/bug_patches.clj
@@ -63,13 +63,14 @@
    time-mins
    ))

+'((prn (now)))
 '((->>
    (commits-with
     gcc-repo
     (fn [rev-commit]
       (doseq [commit (:srcs rev-commit)]
         (prn
-         (log-err (str "atoms-added-removed-in-bugs" (:rev-str commit)) {} ;todo rev-str isn't working here?
+         (log-err (str "atoms-added-removed-in-bugs " (:rev-str commit)) {} ;todo rev-str isn't working here?
                   (merge (with-timeout 400 (added-removed-atoms-count commit))
                          {:n-bugs (->> commit :rev-commit bugzilla-ids count)}))))))
     (log-to "tmp/atoms-added-removed-in-bugs_gcc_2018-01-11_01.txt")


add missing app-context check

add missing app-context check

--- src/bract/core/dev.clj
+++ src/bract/core/dev.clj
@@ -137,6 +137,7 @@
   "Stop the started application."
   []
   (ensure-init)
+  (util/expected map? "app-context to be initialized as map using inducer bract.core.dev/record-context!" app-context)
   (let [stopper (config/ctx-stopper app-context)]
     (echo/with-latency-capture "Stopping the started application"
       (stopper))))


Remove text overflow

Remove text overflow

--- src/build_mon/html.clj
+++ src/build_mon/html.clj
@@ -22,9 +22,9 @@
                                     status-text state commit-message]}]
   [:a {:href (str "/build-definitions/" build-definition-id)}
    [:div {:id (str "build-definition-id-" build-definition-id) :class (str "build-panel " (name state))}
-    [:h1.status.hide-overflow status-text]
-    [:h1.build-definition-name.hide-overflow build-definition-name]
-    [:h1.build-number.hide-overflow build-number]
+    [:h1.status status-text]
+    [:h1.build-definition-name build-definition-name]
+    [:h1.build-number build-number]
     [:div.commit-message commit-message]]])

 (defn generate-build-monitor-html [build-info-maps refresh-info favicon-path]


Add wrap-anti-forgery middleware to server.

--- src/cadence/server.clj
+++ src/cadence/server.clj
@@ -11,6 +11,7 @@
                        [core :refer :all])
             (ring.middleware [params :refer [wrap-params]]
                              [refresh :refer [wrap-refresh]]
+                             [anti-forgery :refer [wrap-anti-forgery]]
                              [gzip :refer [wrap-gzip]]
                              [stacktrace :refer [wrap-stacktrace]]
                              [format-params :refer [wrap-restful-params]]
@@ -39,6 +40,7 @@
   "Create the application from its routes and middlewares."
   (-> app-routes
     (friend/authenticate friend-settings)
+    (wrap-anti-forgery)
     (wrap-noir-validation)
     (wrap-restful-response)
     (wrap-restful-params)


Add helper for building predicates

Add helper for building predicates

--- src/cddr/ksml/eval.clj
+++ src/cddr/ksml/eval.clj
@@ -45,6 +45,15 @@
   [_ & args]
   `(.. *builder* (merge (into-array KStream (vector ~@args)))))

+;; lamdas ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+
+(defn predicate
+  [f]
+  (reify Predicate
+    (test [_ k v]
+      (boolean (f k v)))))
+
 ;; kstream/ktable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
 ;; Lots of methods exist on both KStream and KTable classes. Clojure
@@ -56,23 +65,17 @@
   `(.. ~(eval stream)
        (branch (into-array Predicate
                            (vector ~@(for [p-fn# predicate-fns]
-                                       `(reify Predicate
-                                          (test [_ k# v#]
-                                            (boolean (~p-fn# k# v#))))))))))
+                                       `(predicate p-fn#)))))))

 (defmethod eval-op :filter
   [_ predicate-fn stream-or-table]
   `(.. ~(eval stream-or-table)
-       (filter (reify Predicate
-                 (test [_ k# v#]
-                   (boolean (~predicate-fn k# v#)))))))
+       (filter (predicate predicate-fn))))

 (defmethod eval-op :filter-not
   [_ predicate-fn stream-or-table]
   `(.. ~(eval stream-or-table)
-       (filterNot (reify Predicate
-                    (test [_ k# v#]
-                      (boolean (~predicate-fn k# v#)))))))
+       (filterNot (predicate predicate-fn))))

 (defmethod eval-op :flat-map
   [_ map-fn stream-or-table]


updated comments

updated comments

--- src/clj/think/image/data_augmentation.clj
+++ src/clj/think/image/data_augmentation.clj
@@ -117,6 +117,7 @@
     (imagez/set-pixels out-image pixels)
     out-image))

+;; From BenB
 (defn- rotate-img-emb-impl [img r x y]
   (let [w (.getWidth img)
         h (.getHeight img)


Reduce AWS log verbosity

Reduce AWS log verbosity

--- src/circle/logging.clj
+++ src/circle/logging.clj
@@ -45,7 +45,9 @@
   (set-level "org.apache.http.wire" Level/OFF)
   (set-level "org.apache.http.headers" Level/OFF)

-  (set-level "clj-ssh.ssh" Level/WARN))
+  (set-level "clj-ssh.ssh" Level/WARN)
+
+  (set-level "com.amazonaws" Level/WARN))

 (defn add-file-appender [loggername filename]
   (.addAppender (Logger/getLogger loggername)


update tsp dependency

update tsp dependency

--- src/clj/castra/api.clj
+++ src/clj/castra/api.clj
@@ -58,8 +58,7 @@
   (let [g       (graph/concurrent-google-graph stops  @cache)
         c       (ac/make-ant-colony-solver-config nil)
         sol     (ac/make-ant-colony-solution g c)
-        s       (select-keys (ac/ant-colonies sol 5)
-                             [:tour :distance :duration])
+        s       (ac/ant-colonies sol 10)
         ts      (tour-stops stops (:tour s))
         p       (tour-polylines ts)]
     (assoc {}


Accept a file argument to run on startup via -i

--- src/clj/reply/main.clj
+++ src/clj/reply/main.clj
@@ -46,8 +46,11 @@
   (loop [[option arg & more :as args] args
          arg-map {:custom-init '()}]
     (case option
-      "-i" (recur more (assoc arg-map :custom-init (read-string arg)))
-      "--init" (recur more (assoc arg-map :custom-init (read-string arg)))
+      "-e" (recur more (assoc arg-map :custom-init (read-string arg)))
+      "--eval" (recur more (assoc arg-map :custom-init (read-string arg)))
+
+      "-i" (recur more (assoc arg-map :custom-init (read-string (slurp arg))))
+      "--init" (recur more (assoc arg-map :custom-init (read-string (slurp arg))))

       "--attach" (recur more (assoc arg-map :attach arg))
       "--port" (recur more (assoc arg-map :port arg))
@@ -82,10 +85,12 @@
         :prompt (constantly false)
         :need-prompt (constantly false)))

+
 (defn -main
   "Launches a REPL. Customizations available:
   -h/--help:           Show this help screen
-  -i/--init:           Provide custom code to evaluate in the user ns
+  -i/--init:           Provide a Clojure file to evaluate in the user ns
+  -e/--eval:           Provide custom code to evaluate in the user ns
   --skip-default-init: Skip the default initialization code
   --nrepl:             Launch nREPL (clojure.tools.nrepl) in interactive mode"
   [& args]
@@ -102,6 +107,4 @@
       (when (not= (.getMessage e) "EOF while reading")
         (println "Oh noez!")
         (clj-stacktrace.repl/pst e))))
-
   (exit))
-