Make test assertions more explicit

Make test assertions more explicit

--- test/clj_gatling/simulation_test.clj
+++ test/clj_gatling/simulation_test.clj
@@ -63,17 +63,17 @@
   (let [result (simulation/run-simulation [scenario] 1)]
     (is (equal? result [{:name "Test scenario"
                          :id 0
-                         :start anything
-                         :end anything
+                         :start number?
+                         :end number?
                          :requests [{:name "Request1"
                                      :id 0
-                                     :start anything
-                                     :end anything
+                                     :start number?
+                                     :end number?
                                      :result true}
                                     {:name "Request2"
                                      :id 0
-                                     :start anything
-                                     :end anything
+                                     :start number?
+                                     :end number?
                                      :result false}]}]))))

 (deftest simulation-passes-context-through-requests-in-scenario
@@ -91,13 +91,13 @@
   (let [result (simulation/run-simulation [scenario scenario2] 1)]
     (is (equal? result [{:name "Test scenario"
                          :id 0
-                         :start anything
-                         :end anything
+                         :start number?
+                         :end number?
                          :requests anything}
                         {:name "Test scenario2"
                          :id 0
-                         :start anything
-                         :end anything
+                         :start number?
+                         :end number?
                          :requests anything}]))))

 (deftest with-given-number-of-requests


To ensure proper rendering and touch zooming, add the viewport meta tag

--- src/anyviz/views.clj
+++ src/anyviz/views.clj
@@ -5,6 +5,7 @@
 (defn common-head [& extras]
   [:head
     [:title @g/display-name]
+    [:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
     [:link {:href "/static/bootstrap/css/bootstrap.min.css" :rel "stylesheet" :media "screen"}]
     [:script {:src "http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"}]
     [:script {:src "/static/bootstrap/js/bootstrap.min.js"}]
@@ -91,40 +92,31 @@
         [:div.container
           (breadcrumbs [["home" "/"] (linkify-db db) (linkify-coll db coll)])
           [:div.panel.panel-primary
-
             [:div.panel-heading
               [:h3.panel-title "Builder"]]
-
             [:div.panel-body
-
               [:form.form-horizontal {:role "form"}
-
                 (group
                   (label "Over the range" "date-period")
                   (ctl (dropdown date-periods "date-period"))
                   (label "Group time by" "group-times")
                   (ctl (dropdown group-times "group-times")))
-
                 (group
                   (label "Match where" "match-entities")
                   (ctl (dropdown segments "none" "match-entities"))
                   (ctl (dropdown match-operators "none" "match-ops") 2)
                   (ctl (input "value")))
-
                 (group
                   (label "Group results by" "group-entities")
                   (ctl (dropdown segments "none" "group-entities")))
-
                 (group
                   (label "Aggregate" "reduce-entities")
                   (ctl (dropdown segments "reduce-entities"))
                   (label "Over the statistic" "reduce-ops")
                   (ctl (dropdown reduce-operators "reduce-ops")))
-
                 (group
                   (label "Display results as" "graph-type")
                   (ctl (dropdown graph-types "graph-type")))
-
                 [:div.form-group
                   [:div.col-sm-10.col-sm-offset-2
                     [:button#go-btn.btn.btn-primary {:type "button"} "Run Query"]


Cleaned up.

Cleaned up.

--- src/api_test/xml.clj
+++ src/api_test/xml.clj
@@ -65,24 +65,24 @@
             <c>
               <d>CLIP</d>
             </c>
-            <!--FeatureApiInfo>
-              <featureCode>HLT</featureCode>
-            </FeatureApiInfo>
-            <FeatureApiInfo>
-              <featureCode>INT</featureCode>
-            </FeatureApiInfo>
-            <FeatureApiInfo>
-              <featureCode>SMS</featureCode>
-            </FeatureApiInfo>
-            <FeatureApiInfo>
-              <featureCode>STD</featureCode>
-            </FeatureApiInfo>
-            <FeatureApiInfo>
-              <featureCode>TWAYR</featureCode>
-            </FeatureApiInfo>
-            <FeatureApiInfo>
-              <featureCode>UNTETH</featureCode>
-            </FeatureApiInfo-->
+            <c>
+              <d>HLT</d>
+            </c>
+            <c>
+              <d>INT</d>
+            </c>
+            <c>
+              <d>SMS</d>
+            </c>
+            <c>
+              <d>STD</d>
+            </c>
+            <c>
+              <d>TWAYR</d>
+            </c>
+            <c>
+              <d>UNTETH</d>
+            </c>
           </b>
         </e>
 ")
@@ -93,10 +93,10 @@
 (def fmatch (map #(zx/tag= %) '(:x)))
 (def match (map #(zx/tag= %) '(:b :c :d)))

-(def content '("CHSDA" "foo"))
+(def content '("UNTETH" "foo"))

 (def big-match (concat match (map #(zx/text= %) (list (first content)))))
-;(println (apply zx/xml-> zipper fmatch))
+(println (apply zx/xml-> zipper big-match))

@@ -107,7 +107,7 @@
     (if (= () line)
       (xml/indent-str (zip/root zipper))
       (do
-        (println "ziper=" zipper)
+        ;(println "ziper=" zipper)
         (let [paths (str/split (:tag (first line)) #">")
               m (map #(zx/tag= (keyword %)) paths)
               c (str/split (:content (first line)) #">")
@@ -119,9 +119,9 @@
                         m)
               edit { :tag (keyword (last paths)) :content content }
               new-loc (apply zx/xml1-> zipper matches)]
-          (if (= nil new-loc)
+          (if (nil? new-loc)
             (println "WARNING: " (first line) " NOT FOUND"))
-          (let [loc (if (not= nil new-loc)
+          (let [loc (if-not (nil? new-loc)
                       (do
                         (zip/root (zip/replace new-loc edit)))
                       (do
@@ -129,10 +129,11 @@
             (recur (zip/xml-zip loc) (rest line))))))))

-(comment (test-set-values  (lazy-seq '({:tag "a" :content "arglebargle" }
+(println (set-values  (lazy-seq '({:tag "a" :content "arglebargle" }
                                   {:tag "b>c>d" :content "CHSDA>foo" }
                                   {:tag "b>c>d" :content "CLIP>bar" }
-                                  {:tag "x" :content "y"})) test-request))
+                                  {:tag "x" :content "y"}
+                                  {:tag "b>c>d" :content "UNTETH>baz"})) test-request))


reorganize SQL parsing API lower in the namespace for better dependency resolution

--- src/asphalt/core.clj
+++ src/asphalt/core.clj
@@ -108,42 +108,6 @@
     (DataSourceWrapper. ds i/jdbc-event-factory stmt-creation-listener sql-execution-listener)))

-;; ----- parse SQL for named parameters and types -----
-
-
-(defn parse-sql
-  "Given a SQL statement with embedded parameter names return a three-element vector:
-  [SQL-template-string
-   param-pairs           (each pair is a two-element vector of param key and type)
-   result-column-types]
-  that can be used later to extract param values from maps."
-  ([^String sql]
-    (parse-sql sql {}))
-  ([^String sql {:keys [sql-name escape-char param-start-char type-start-char name-encoder]
-                 :or {sql-name sql escape-char \\ param-start-char \$ type-start-char \^}
-                 :as options}]
-    (let [[sql named-params return-col-types]  (i/parse-sql-str sql escape-char param-start-char type-start-char)]
-      (i/make-sql-template
-        sql-name
-        sql
-        (mapv #(let [[p-name p-type] %]
-                 [(i/encode-name p-name) (i/encode-type p-type sql)])
-          named-params)
-        (mapv #(i/encode-type % sql) return-col-types)))))
-
-
-(defmacro defsql
-  "Define a parsed SQL template that can be used to execute it later."
-  ([var-symbol sql]
-    (when-not (symbol? var-symbol)
-      (i/expected "a symbol" var-symbol))
-    `(defsql ~var-symbol ~sql {}))
-  ([var-symbol sql options]
-    (when-not (symbol? var-symbol)
-      (i/expected "a symbol" var-symbol))
-    `(def ~var-symbol (parse-sql ~sql (merge {:sql-name ~(name var-symbol)} ~options)))))
-
-
 ;; ----- java.sql.ResultSet operations -----

@@ -362,6 +326,42 @@
         (vec (.executeBatch pstmt))))))

+;; ----- parse SQL for named parameters and types -----
+
+
+(defn parse-sql
+  "Given a SQL statement with embedded parameter names return a three-element vector:
+  [SQL-template-string
+   param-pairs           (each pair is a two-element vector of param key and type)
+   result-column-types]
+  that can be used later to extract param values from maps."
+  ([^String sql]
+    (parse-sql sql {}))
+  ([^String sql {:keys [sql-name escape-char param-start-char type-start-char name-encoder]
+                 :or {sql-name sql escape-char \\ param-start-char \$ type-start-char \^}
+                 :as options}]
+    (let [[sql named-params return-col-types]  (i/parse-sql-str sql escape-char param-start-char type-start-char)]
+      (i/make-sql-template
+        sql-name
+        sql
+        (mapv #(let [[p-name p-type] %]
+                 [(i/encode-name p-name) (i/encode-type p-type sql)])
+          named-params)
+        (mapv #(i/encode-type % sql) return-col-types)))))
+
+
+(defmacro defsql
+  "Define a parsed SQL template that can be used to execute it later."
+  ([var-symbol sql]
+    (when-not (symbol? var-symbol)
+      (i/expected "a symbol" var-symbol))
+    `(defsql ~var-symbol ~sql {}))
+  ([var-symbol sql options]
+    (when-not (symbol? var-symbol)
+      (i/expected "a symbol" var-symbol))
+    `(def ~var-symbol (parse-sql ~sql (merge {:sql-name ~(name var-symbol)} ~options)))))
+
+
 ;; ----- convenience functions and macros -----


add some docstrings, rename some vars

add some docstrings, rename some vars

--- src/blx/sortable.clj
+++ src/blx/sortable.clj
@@ -23,76 +23,80 @@
 ; Result :: {:product_name str
 ;            :listings [Listing]}

-(defn- parse-json [s]
+(defn- parse-json
+  "Parses a JSON string, keywordizing keys."
+  [s]
   (json/parse-string s true))

-(defn load-input [path]
+(defn load-input
+  "Parses the file at `path` as a vector of JSON objects."
+  [path]
   (with-open [rdr (io/reader path)]
     (->> (line-seq rdr)
+         ; We need to return a vector (mapv), because otherwise with-open will
+         ; close the stream before the lazy sequence is realized.
          (mapv parse-json))))

-(defn remove-chars [s]
-  (-> s
-      ((fnil str/replace "") #"[ _-]+" "")
+(defn normalize-str [s]
+  (-> (or s "")
+      (str/replace #"[ _-]+" "")
       str/lower-case))

 (defn prepare-product [product]
   (-> product
-      (update :product_name remove-chars)
-      (update :model remove-chars)))
-
+      (update :product_name normalize-str)
+      (update :model normalize-str)))

 (defn common-prefix-length
-  "Returns the length of the longest common prefix between a and b."
+  "Returns the length of the longest common prefix between sequences a and b."
   [a b]
-  (reduce (fn [match-len [a b]]
-            (if (= a b)
-              (inc match-len)
-              (reduced match-len)))
-          0
-          (map vector a b)))
+  (->> (map = a b)
+       (take-while true?)
+       count))

-
-
-(defn match-manufacturer [mproducts listing]
-  (->> (keys mproducts)
-       (map remove-chars)
-       (some #(when (.startsWith (remove-chars (:manufacturer listing)) %)
-                %))))
+(comment
+  (defn match-manufacturer [mproducts listing]
+    (->> (keys mproducts)
+         (map remove-chars)
+         (some #(when (.startsWith (normalize-str (:manufacturer listing)) %)
+                  %))))
+)

 (defn match-title
   "Attempts to match listing to a product in products, returning a vector
-  [score matching-product] if successful, else nil."
+  [listing matching-product] if successful, else nil."
   [products listing]
+  (let [listing-title (normalize-str (:title listing))
         ; Longer than just manufacturer name
-  (let [min-match-len (max 3 (count (:manufacturer listing)))
+        min-match-len (max 3 (count (:manufacturer listing)))
+                     ; This is fairly fast. Combining the map and filter
+                     ; as one reduce into a (transient []) didn't help much
+                     ; and was harder to read.
         matches (->> products
-                     (map #(vector (common-prefix-length (:title listing)
+                     (map #(vector (common-prefix-length listing-title
                                                          (:product_name %))
                                    %))
                      (filter (fn [[score prod]]
                                (and (> score min-match-len)
                                     (if-let [model (:model prod)]
-                                      (.contains (:title listing) model)
+                                      (.contains listing-title model)
                                       true))))
                      (sort-by first >))]
     ; Do not allow ties
     (when (and matches
                (not= (first (first matches))
                      (first (second matches))))
-      (first matches))))
+      (let [[_ match] (first matches)]
+       [listing match]))))

-(defn match [products listing]
-  (let [listing' (update listing :title remove-chars)]
-    (when-let [[_ match] (match-title products listing')]
-      [listing match])))
-
-(defn domatch
+(defn match-all
   "Returns the sequence of Result maps produced by matching the
   listings to the products."
+  ; We take in all the listings, as opposed to doing (pmap match-listing listings),
+  ; because we need to group the results by Product after matching.
   [products listings]
   (let [matches (->> listings
-                     (pmap #(match products %))  ; pmap was a 4x speedup
+                     (pmap #(match-title products %))  ; pmap was a 4x speedup
                      (filter some?))]
     (->> matches
          (group-by second)
@@ -103,20 +107,23 @@

 (defn test-random [products listings]
-  ((juxt #(match products %) identity)
-   (rand-nth listings)))
+  (let [listing (rand-nth listings)]
+    (or (match-title products listing)
+        [nil listing])))

 (defn -main
   [& args]
-  ; We need to read all products into memory, but we
+  ; We need to read all products into memory at once, but we
   ; can process listings lazily / line-by-line.
-  (let [products (mapv prepare-product (load-input (:products-uri conf)))]
+  (let [products (map prepare-product (load-input (:products-uri conf)))]
     (with-open [listings (io/reader (:listings-uri conf))
-                out (io/writer (:out-uri conf))]
+                out      (io/writer (:out-uri conf))]
       (doseq [item (->> (line-seq listings)
                         (map parse-json)
-                        (domatch products))]
+                        (match-all products))]
         (json/generate-stream item out)
-        (.write out "\n")))))
+        (.write out "\n"))))
+  ; Put pmap to bed
+  (shutdown-agents))


Add domain group

Add domain group

--- src/bolt/config.cljs
+++ src/bolt/config.cljs
@@ -22,7 +22,8 @@
     :flickr {:alias "fl" :url "http://www.flickr.com/search/?q=%s"}
     :imdb {:url "http://www.imdb.com/find?q=%s&s=all"}
     :rotten {:url "http://www.rottentomatoes.com/search/?search=%s"}
-    :domain {:url "https://domai.nr/?q=%s"}
+    :domainr {:url "https://domai.nr/?q=%s"}
+    :google-domain {:url "https://domains.google.com/registrar?s=%s"}
     :freebase {:alias "fb" :url "http://www.freebase.com/search?query=%s"}
     :twitter {:url "https://twitter.com/search?q=%s"}
     :urbandictionary {:alias "urban" :url "http://www.urbandictionary.com/define.php?term=%s"}
@@ -36,6 +37,7 @@
     :film {:names ["fandango" "imdb" "rotten"]}
     :find {:names ["google" "wikipedia" "wikidata" "freebase"]}
     :buy {:names ["amazon" "google-shopping"]}
+    :domain {:names ["domainr" "google-domain"]}

     ;; not used on phone
     :google-group {:alias "ggs" :url "http://groups.google.com/groups/dir?q=%s"}


Tight event-loop (move handlers out).

Tight event-loop (move handlers out).

--- src/canvas/main.cljs
+++ src/canvas/main.cljs
@@ -315,21 +315,25 @@
     (.scale ctx (/ w SCALE-W) (/ h SCALE-H))
     (draw-phase! state ctx)))

+(defn- pause-or-abort!
+  [state]
+  (swap! state #(if (:pause? %)
+                  (assoc % :pause? false)
+                  (assoc % :mode :game-start))))
+
+(defn- pause-or-next!
+  [state]
+  (swap! state #(case (:mode %)
+                  :game-start (merge % objects {:mode :playing})
+                  :game-over (assoc % :mode :game-start)
+                  (assoc % :pause? (not (:pause? %))))))
 (defn- event-loop!
   [state ch]
   (go-loop []
     (when-let [event (<! ch)]
-      (cond
-        (= :abort event)
-        (swap! state #(if (:pause? %)
-                        (assoc % :pause? false)
-                        (assoc % :mode :game-start)))
-        (= :space event)
-        (swap! state #(case (:mode %)
-                        :game-start (merge % objects {:mode :playing})
-                        :game-over (assoc % :mode :game-start)
-                        (assoc % :pause? (not (:pause? %)))))
-        :else
+      (case event
+        :abort (pause-or-abort! state)
+        :space (pause-or-next! state)
         (println "Unhandled event:" event))
       (recur))))


fixes freeze bug when trying modify the piece thats now nill

--- src/client/core.cljs
+++ src/client/core.cljs
@@ -168,13 +168,15 @@
   []
   (.addEventListener js/window "keydown"
      (fn [e]
-       (let [code (aget e "keyCode")]
-         (cond
-           (= code (:down key-codes))  (do (try-move!  0  1) (.preventDefault e))
-           (= code (:left key-codes))  (do (try-move! -1  0) (.preventDefault e))
-           (= code (:right key-codes)) (do (try-move!  1  0) (.preventDefault e))
-           (= code (:space key-codes)) (do (hard-drop!)      (.preventDefault e))
-           (= code (:up key-codes))    (do (try-rotate!)     (.preventDefault e))))))
+       (if (:piece @state)
+         (let [code (aget e "keyCode")]
+          (cond
+            (= code (:down key-codes))  (do (try-move!  0  1) (.preventDefault e))
+            (= code (:left key-codes))  (do (try-move! -1  0) (.preventDefault e))
+            (= code (:right key-codes)) (do (try-move!  1  0) (.preventDefault e))
+            (= code (:space key-codes)) (do (hard-drop!)      (.preventDefault e))
+            (= code (:up key-codes))    (do (try-rotate!)     (.preventDefault e))))))
+        )
   (.addEventListener js/window "keyup"
      (fn [e]
        (let [code (aget e "keyCode")]


Make functions return the conversation, rather than nil

--- src/clj_dde/core.clj
+++ src/clj_dde/core.clj
@@ -9,33 +9,33 @@

 (defn set-event-listener
   [conv]
-  (.setEventListener conv
-                     (reify DDEClientEventListener
-                       (onItemChanged [this topic item data]
-                         (prn (str "Item Changed: " topic  " , " item  " , " data )))
-                       (onDisconnect [this]
-                         (prn (str "onDisconnect() called."))))))
-
+  (doto conv
+    (.setEventListener
+      (reify DDEClientEventListener
+        (onItemChanged [this topic item data]
+          (prn (str "Item Changed: " topic  " , " item  " , " data )))
+        (onDisconnect [this]
+          (prn (str "onDisconnect() called.")))))))

 (defn listen
   [conv]
-  (.setEventListener conv
-                     (reify DDEClientEventListener
-                       (onItemChanged [this _ _ data]
-                         (data))
-                       (onDisconnect [this]
-                         (prn (str "onDisconnect() called."))))))
-
+  (doto conv
+    (.setEventListener
+      (reify DDEClientEventListener
+        (onItemChanged [this _ _ data]
+          (data))
+        (onDisconnect [this]
+          (prn (str "onDisconnect() called.")))))))

 (defn listen-and-print-data
   [conv]
-  (.setEventListener conv
-                     (reify DDEClientEventListener
-                       (onItemChanged [this _ _ data]
-                         (prn (str data)))
-                       (onDisconnect [this]
-                         (prn (str "onDisconnect() called."))))))
-
+  (doto conv
+    (.setEventListener
+      (reify DDEClientEventListener
+        (onItemChanged [this _ _ data]
+          (prn (str data)))
+        (onDisconnect [this]
+          (prn (str "onDisconnect() called.")))))))

 ;; instantiate a DDEClientConversation

@@ -49,7 +49,7 @@

 (defn set-timeout
   [conv ms]
-  (.setTimeout conv ms))
+  (doto conv (.setTimeout ms)))

 (defn get-timeout
   "returns timeout length in ms"
@@ -58,23 +58,23 @@

 (defn connect
   [conv app topic]
-  (.connect conv app topic))
+  (doto conv (.connect app topic)))

 (defn disconnect
   [conv]
-  (.disconnect conv))
+  (doto conv .disconnect))

 (defn start-advice
   [conv item]
-  (.startAdvice conv item))
+  (doto conv (.startAdvice item)))

 (defn stop-advice
   [conv item]
-  (.stopAdvice conv item))
+  (doto conv (.stopAdvice item)))

 (defn poke
   [conv topic input]
-  (.poke conv topic input))
+  (doto conv (.poke topic input)))

 (defn request
   [conv item]
@@ -82,7 +82,7 @@

 (defn execute
   [conv command]
-  (.execute conv command))
+  (doto conv (.execute command)))

 (defn get-service
   [conv]


Remove core.match from SVG helpers namespace until that library's AOT compilation issues are resolved.

--- src/cljx/c2/svg.cljx
+++ src/cljx/c2/svg.cljx
@@ -4,11 +4,9 @@
 ^:clj (ns c2.svg
         (:use [c2.core :only [unify]]
               [c2.maths :only [Pi Tau radians-per-degree
-                               sin cos mean]]
-              [clojure.core.match :only [match]]))
+                               sin cos mean]]))

 ^:cljs (ns c2.svg
-         (:use-macros [clojure.core.match.js :only [match]])
          (:use [c2.core :only [unify]]
                [c2.maths :only [Pi Tau radians-per-degree
                                 sin cos mean]])
@@ -18,19 +16,19 @@
 (defn ->xy
   "Convert coordinates (potentially map of `{:x :y}`) to 2-vector."
   [coordinates]
-  (match [coordinates]
-         [[x y]] [x y]
-         [{:x x :y y}] [x y]))
+  (cond
+   (and (vector? coordinates) (= 2 (count count))) coordinates
+   (map? coordinates) [(:x coordinates) (:y coordinates)]))

 (defn translate [coordinates]
   (let [[x y] (->xy coordinates)]
     (str "translate(" x "," y ")")))

 (defn scale [coordinates]
-  (match [coordinates]
-         [[x y]] (str "scale(" x "," y ")")
-         [{:x x :y y}] (recur [x y])
-         [s] (str "scale(" s ")")))
+  (cond
+   (number? coordinates) (str "scale(" coordinates ")")
+   (map? coordinates) [(:x coordinates) (:y coordinates)]
+   (and (vector? coordinates) (= 2 (count count))) coordinates))

 (defn rotate
   ([angle] (rotate angle [0 0]))


rms_amplitude

--- src/clojure/core.clj
+++ src/clojure/core.clj
@@ -48,6 +48,10 @@
   (with-result
     (double-array [0])
     (fn [r] (xtract/xtract_spectral_inharmonicity peaks-data block-size (apply xtract-args args) r))))
+
+(defn wavelet_f0 []
+
+  )

 (defn mean [vs]
   (let [result (double-array 1)
@@ -116,14 +120,12 @@

 (defn peek-inside [sample-path]
-  (let [path sample-path ;;             "test/fixtures/the_nature_of_sound.wav"
+  (let [path sample-path
         s    (sample/read-sound path)
         MFCC_FREQ_BANDS (double 13)
-        MFCC_FREQ_MIN (double 20)
-        MFCC_FREQ_MAX (double 20000)
-
-        NUM_HARMONICS  10
-
+        MFCC_FREQ_MIN   (double 20)
+        MFCC_FREQ_MAX   (double 20000)
+        NUM_HARMONICS   10
         MFCC_FREQ_BANDS 13
         SAMPLERATE 44100
         data   (sample/chunks s SAMPLERATE)
@@ -184,13 +186,23 @@

                             (xtract/xtract_peak_spectrum spectrum (double (/ block-size 2)) (xtract/doublea_to_voidp argv) peaks)

-                            (let [spectral-inharmonicity (spectral-inharmonicity
+;;                            public static int xtract_rms_amplitude(SWIGTYPE_p_double data, int N, SWIGTYPE_p_void argv, double[] result)
+
+                            (let [rms (double-array [0])
+                                  argv [(/ SAMPLERATE block-size)]
+
+                                  spectral-inharmonicity (spectral-inharmonicity
                                                           peaks block-size
-                                                          f0 0.5 NUM_HARMONICS 0)
-                                  r {:spectral-inharmonicity spectral-inharmonicity
-                                     :midi midi
-                                     :f0 f0}]
-                              {(* idx SAMPLERATE) r}))
+                                                          f0 0.5 NUM_HARMONICS 0)]
+
+                              (xtract/xtract_rms_amplitude ds block-size (apply xtract-args argv) rms)
+
+                              {(* idx SAMPLERATE)
+                               {:spectral-inharmonicity spectral-inharmonicity
+                                :rms_amplitude (first rms)
+                                :midi midi
+                                :f0 f0}
+                               }))
                               ;;(println "Magnitude Spectrum: " (pr-str (double->clojure spectrum block-size)))
                           )))))
                 s))
@@ -203,17 +215,6 @@
         (vec (flatten stats))
         ))))

-(println
- (doseq [r (peek-inside "test/fixtures/test.wav")]
-   (println r)))
-
-;;f0: 167.04545454545453
-;;f0: 196.875
-;;f0: 303.440366972477
-;;f0: 263.54581673306774
-;;f0: 263.44086021505376
-;;f0: 264.86486486486484
-;;f0: 266.0633484162896
-;;f0: 263.54581673306774
-;;f0: 263.2835820895522
-;;f0: 258.3984375
+(println "" )
+(doseq [r (peek-inside "test/fixtures/test.wav")]
+  (println r))


Make ensure-list really always return a non-lazy list.

--- src/clojush/util.clj
+++ src/clojush/util.clj
@@ -44,10 +44,17 @@
           (fn [node children] (with-meta children (meta node)))
           root))

-(defn ensure-list ;; really make-list-if-not-seq, but close enough for here
+(defn not-lazy
+  "Returns lst if it is not a list, or a non-lazy version of lst if it is."
+  [lst]
+  (if (seq? lst)
+    (apply list lst)
+    lst))
+
+(defn ensure-list
   [thing]
   (if (seq? thing)
-    thing
+    (not-lazy thing)
     (list thing)))

 (defn print-return
@@ -234,13 +241,6 @@
   (cons lst (if (seq? lst)
               (apply concat (doall (map all-items lst)))
               ())))
-
-(defn not-lazy
-  "Returns lst if it is not a list, or a non-lazy version of lst if it is."
-  [lst]
-  (if (seq? lst)
-    (apply list lst)
-    lst))

 (defn list-to-open-close-sequence
   [lst]


Task name do not must be a keyword

Task name do not must be a keyword

--- src/control/core.clj
+++ src/control/core.clj
@@ -194,12 +194,13 @@
     :arglists '([name doc-string? [params*] body])
     :added "0.1"}
   deftask [name & decl ]
-  (let [m (if (string? (first decl))
-            (next decl)
-            decl)
-        arguments (first m)
-        body (next m)
-        new-body (postwalk (fn [item]
+  (let [name (keyword name)
+          m (if (string? (first decl))
+              (next decl)
+              decl)
+          arguments (first m)
+          body (next m)
+          new-body (postwalk (fn [item]
                              (if (list? item)
                                (let [cmd (first item)]
                                  (if (cmd system-functions)


Don't warn that thing->prior-versions is shared

We don't really care. This is the obvious way to implement this
operation, and the various API specific duplications of this method will
get removed.

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -178,7 +178,6 @@
 ;;--------------------------------------------------------------------

 (defmethod thing->prior-versions :default [config thing]
-  ;; FIXME: this is entirely common to fs/read's thing->versions
   {:pre [(#{:version :platform :namespace :def} (:type thing))]}
   (let [thing    (t/ensure-thing thing)
         currentv (t/thing->version thing)               ; version handle


show how to parse a JS source file, visit all the nodes of the parse tree and extract comments

--- src/jsx_fun/core.clj
+++ src/jsx_fun/core.clj
@@ -1,14 +1,15 @@
 (ns jsx-fun.core
   (:require [clojure.java.io :as io]
             [cljs.closure :as cl])
-  (:import [javax.script ScriptEngineManager]
-           [java.util List]
-           [java.util.logging Level]
+  (:import [com.google.common.base Predicates]
+           [javax.script ScriptEngineManager]
            [com.google.javascript.jscomp
             ES6ModuleLoader ProcessCommonJSModules CompilerOptions SourceFile
-            Result JSModule JSError CompilerOptions$LanguageMode
-            AbstractCompiler]
-           [com.google.javascript.jscomp.Compiler]))
+            CompilerOptions$LanguageMode NodeUtil NodeUtil$Visitor]
+           [com.google.javascript.jscomp.parsing
+            Config Config$LanguageMode ParserRunner]
+           [com.google.javascript.rhino
+            Node Token ErrorReporter SimpleErrorReporter]))

 (defn set-options [opts ^CompilerOptions compiler-options]
   (doseq [[k v] opts]
@@ -54,6 +55,24 @@
       nil root)
     (.toSource comp root)))

+(defn transform-commonjs
+  [filename src]
+  (let [js      [(SourceFile/fromCode filename src)]
+        options (set-options {:lang-in :es5 :pretty-print true}
+                  (CompilerOptions.))
+        comp    (doto (cl/make-closure-compiler)
+                  (.init '() js options))
+        root    (.parse comp (first js))]
+    (.getJSDoc root)))
+
+(defn node-visitor []
+  (reify
+    NodeUtil$Visitor
+    (visit [_ node]
+      (println (Token/name (.getType node)))
+      (when-let [js-doc (.getJSDocInfo node)]
+        (println js-doc)))))
+
 ;(defn transform-commonjs
 ;  [filename src]
 ;  (let [^List externs '()
@@ -70,8 +89,24 @@
     (io/file "resources/ScrollResponder.out.js")
     (transform-jsx (slurp (io/file "resources/ScrollResponder.js"))))

+  ;; the file name is used as the module name
+  ;; we will have to extract this from @providesModule
   (println
     (transform-commonjs
       "ScrollResponder.js"
       (transform-jsx (slurp (io/file "resources/ScrollResponder.js")))))
+
+  (let [config       (ParserRunner/createConfig
+                       true Config$LanguageMode/ECMASCRIPT5 true nil)
+        err-reporter (SimpleErrorReporter.)
+        source-file  (SourceFile/fromFile
+                       (io/file "resources/ScrollResponder.js"))
+        parse-result (ParserRunner/parse
+                       source-file (.getCode source-file)
+                       config err-reporter)
+        visitor      (node-visitor)]
+    (println
+      (.comments parse-result))
+    (NodeUtil/visitPreOrder
+      (.ast parse-result) visitor (Predicates/alwaysTrue)))
   )


more tests

more tests

--- moebius/test/moebius/core_test.clj
+++ moebius/test/moebius/core_test.clj
@@ -53,6 +53,21 @@
        ;; if the enrichment function return nil
        ;; then the event is left unchanged
        ((enricher (stateless (fn [x] nil)))      1 {:a 1})    =>    [1 [{:a 1}]]
+
+       )
+
+
+
+(facts "about stateful `enricher`: results are normalised for the `cycler`"
+
+       ;; enricher accepts a function which optionally perform
+       ;; a transformation to the given event, if state is changed
+       ;; then the new state must be returned
+       ((enricher (fn [s e] [(inc s) e])) 1 {:a 1}) => [2  [{:a 1}]]
+
+       ;; if the function changes the event, the new event must
+       ;; be returned
+       ((enricher (fn [s e] [(inc s) (assoc e :b 2)])) 1 {:a 1}) => [2  [{:a 1 :b 2}]]

        )


Replace silly reduce = with dorun

Replace silly reduce = with dorun

--- src/mosaic/image.clj
+++ src/mosaic/image.clj
@@ -54,10 +54,10 @@
   "Insert image a into image b at coordinates dx dy."
   (let [da (.getRaster a)
 	db (.getRaster b)]
-    (reduce = nil
-	      (for [x (range 0 (.getWidth da))
-		    y (range 0 (.getHeight da))
-		    z (range 0 (.getNumBands da))]
-		(.setSample db (+ dx x) (+ dy y) z
-			    (.getSample da x y z))))))
+    (dorun
+     (for [x (range 0 (.getWidth da))
+	   y (range 0 (.getHeight da))
+	   z (range 0 (.getNumBands da))]
+       (.setSample db (+ dx x) (+ dy y) z
+		   (.getSample da x y z))))))


Fix backend.

Fix backend.

--- src/ontrail/core.clj
+++ src/ontrail/core.clj
@@ -31,13 +31,6 @@
       action
       (json-response {"error" "Authentication required"} 401))))

-(defn catch-exceptions [handler]
-  (fn [req]
-    (try
-      (handler req)
-      (catch Exception e
-        (.error logger (str "Exception in handler:\n%s" (strp/pst-str e)))))))
-
 (defn log-and-wrap-dir-index [handler]
   (fn [req]
     (.info request-logger (str "HTTP" (to-logline req)))
@@ -65,10 +58,10 @@
       (json-response {"error" "Authentication failed"} 401)))

   (POST "/rest/v1/ex/:user" {params :params cookies :cookies}
-        (is-authenticated? params cookies (json-response (create-ex params))))
+        (is-authenticated? params cookies #(json-response (create-ex params))))

   (POST "/rest/v1/ex/comment/:id" {params :params cookies :cookies}
-     (is-authenticated? params cookies (json-response (comment-ex params))))
+     (is-authenticated? params cookies #(json-response (comment-ex params))))

   (route/resources "/")
   (route/not-found "Page not found"))


Put back all enemies.

Put back all enemies.

--- src/player/core.cljs
+++ src/player/core.cljs
@@ -50,7 +50,7 @@
                  :now (:entry-time config))))

 (defn make-world []
-  (let [ids #{                                              ;:ga :gb :gc :gd :ge
+  (let [ids #{:ga :gb :gc :gd :ge
               :m
               }
         walls #{[0 0 256 8]
@@ -58,11 +58,11 @@
                 [96 8 8 16]
                 [160 8 8 16]}
         objects [
-                 ;(util/goomba :ga 8 8 16 :right ids walls)
-                 ;(util/goomba :gb 32 8 16 :right ids walls)
-                 ;(util/goomba :gc 12 35 16 :falling-right ids walls)
-                 ;(util/goomba :gd 64 8 16 :left ids walls)
-                 ;(util/goomba :ge 96 32 16 :right ids walls)
+                 (util/goomba :ga 8 8 16 :right ids walls)
+                 (util/goomba :gb 32 8 16 :right ids walls)
+                 (util/goomba :gc 12 35 16 :falling-right ids walls)
+                 (util/goomba :gd 64 8 16 :left ids walls)
+                 (util/goomba :ge 96 32 16 :right ids walls)
                  (util/mario :m {:x 200 :y 8 :v/x 0 :v/y 0} (kw :idle :right) ids walls)
                  ]
         obj-dict (heval/init-has objects)
@@ -193,9 +193,9 @@
               ; so we have to make one or the other choice.
               ; it's easier to add two than to remove one, so we do that.
               (and os-in-new? oe-in-new?) (do
-                                           #_ (println "split poly")
-                                           (assert (not= old-start-in-new-terms :no-solution))
-                                           (assert (not= old-end-in-new-terms :no-solution))
+                                            #_(println "split poly")
+                                            (assert (not= old-start-in-new-terms :no-solution))
+                                            (assert (not= old-end-in-new-terms :no-solution))
                                             [[nid
                                               nstate
                                               nv0
@@ -212,25 +212,25 @@
               ; overlapping (new start outside, new end inside)
               ; shrink new to just new-start...old-start
               (and (not ns-in-old?) ne-in-old? os-in-new?) (do #_(println "shrink end to" old-start-in-new-terms)
-                                                  (assert (not= old-start-in-new-terms :no-solutions))
-                                                    [[nid
-                                                      nstate
-                                                      nv0
-                                                      nflow
-                                                      old-start-in-new-terms]])
+                                                             (assert (not= old-start-in-new-terms :no-solutions))
+                                                             [[nid
+                                                               nstate
+                                                               nv0
+                                                               nflow
+                                                               old-start-in-new-terms]])
               ; overlapping (new start inside, new end outside)
               ; shrink new to just old-end...new-end
               (and ns-in-old? (not ne-in-old?) oe-in-new?) (do
-                                                  (println "shrink start to" old-end-in-new-terms)
-                                                  (assert (not= old-end-in-new-terms :no-solution))
-                                                  [[nid
-                                                    nstate
-                                                    (ha/extrapolate-flow
-                                                      nv0
-                                                      nflow
-                                                      old-end-in-new-terms)
-                                                    nflow
-                                                    (- nd old-end-in-new-terms)]])
+                                                             (println "shrink start to" old-end-in-new-terms)
+                                                             (assert (not= old-end-in-new-terms :no-solution))
+                                                             [[nid
+                                                               nstate
+                                                               (ha/extrapolate-flow
+                                                                 nv0
+                                                                 nflow
+                                                                 old-end-in-new-terms)
+                                                               nflow
+                                                               (- nd old-end-in-new-terms)]])
               ; otherwise, no overlap: just yield the new one unchanged
               :else [np]))))

@@ -275,7 +275,7 @@
                         #_(println "newest:" (count newest) (map :entry-time newest) (map :entry-time newest-plus))
                         (swap! seen-polys
                                (fn [seen]
-                                #_(println "merge-in")
+                                 #_(println "merge-in")
                                  (time (reduce
                                          (fn [seen [prev-config next-config]]
                                            (reduce


WIP Reinstated private-time-input. Displaying time range widget, but not working properly. Note one test is failing.

--- src/re_com/time.cljs
+++ src/re_com/time.cljs
@@ -178,6 +178,7 @@
 (defn- private-time-input
   [model min max & {:keys [on-change disabled style hide-border show-time-icon :as args]}]
   {:pre [(superset? time-api (keys args))]}
+  (println (str "Time input - model: " @model " min: " (deref-or-value min) " max: " (deref-or-value max)))
     (let [def-style {:margin-top "0px"
                      :padding-left "2px"
                      :padding-top "0px"
@@ -245,7 +246,7 @@
       [h-box
         :gap (if gap gap "4px")
         :children [(when from-label [:label from-label])
-                   [private-time-input from-model min to-model]
+                   [private-time-input from-model min (atom-on (string->time-integer @to-model) nil)]
                    (when to-label [:label to-label])
-                   [private-time-input to-model from-model max]
+                   [private-time-input to-model (atom-on (string->time-integer @from-model) nil) max]
                    ]])))


changed default heartbeat timeout

changed default heartbeat timeout

--- src/server/core.cljs
+++ src/server/core.cljs
@@ -16,7 +16,7 @@
 (defonce util (nodejs/require "util"))

 (client-interface/initialize! server #js {"heartbeat interval" 5
-                                          "heartbeat timeout"  30})
+                                          "heartbeat timeout"  15})

 (.set app "views" "src/frontend/views")
 (.set app "view engine" "jade")


test for form-encode and form-decode

test for form-encode and form-decode

--- ring-core/test/ring/util/test/codec.clj
+++ ring-core/test/ring/util/test/codec.clj
@@ -17,3 +17,11 @@
 (deftest test-base64-encoding
   (let [str-bytes (.getBytes "foo?/+" "UTF-8")]
     (is (Arrays/equals str-bytes (base64-decode (base64-encode str-bytes))))))
+
+(deftest form-encoding
+  (let [encoded-params "p%2F1=v%2F1&p%2F2=v%2F21&p%2F2=v%2F22"]
+    (is (= (form-decode encoded-params)
+           (-> encoded-params
+               form-decode
+               form-encode
+               form-decode)))))


example - switch to different photoset

example - switch to different photoset

--- src/showkr/form.cljs
+++ src/showkr/form.cljs
@@ -70,7 +70,7 @@

             (d/div {:className "controls"}
               "Or watch an "
-              (d/a {:href "#72157627590185596"} "example")))))
+              (d/a {:href "#72157629517765623"} "example")))))

       (d/fieldset {:className "span6"}
         (d/legend nil "Browse user albums")


Add more CLJS integration to Emacs

Add more CLJS integration to Emacs

These are taken from the minimal-webapp project [1], to avoid Emacs from
being as dependent on a properly configured project.clj. Ideally, the
:cljs profile would only be enabled for the ClojureScript REPL, and not
for regular Clojure REPLs, but there's not (yet) a built-in way to do
this in CIDER.

[1]: https://github.com/raxod502/minimal-webapp

--- profiles.clj
+++ profiles.clj
@@ -23,6 +23,10 @@
                       (alter-var-root
                         #'cider.inlined-deps.compliment.v0v3v0.compliment.sources.ns-mappings/var-symbol?
                         (constantly (constantly true)))]}
+
+ :cljs {:dependencies [;; ClojureScript REPL in Emacs
+                       [com.cemerick/piggieback "0.2.1"]
+                       [figwheel-sidecar "0.5.4-7"]]}

  :hide-app {;; Prevent the Clojure REPL from showing in the Mac app switcher.
             ;; See http://stackoverflow.com/questions/24619300/hide-clojure-repl-from-command-tab-application-switcher-via-lein-command-line
@@ -169,6 +173,7 @@
  ;; This is an easy way to have a custom subset of the above modular profiles enabled in your
  ;; REPL. To start an awesome REPL use 'lein with-profiles +awesome repl'.
  :awesome [:cider
+           :cljs
            :humane
            :inject
            :alembic


Added send-cmd which parses the response string

--- src/telldus/core.clj
+++ src/telldus/core.clj
@@ -10,7 +10,7 @@

 (defn send-request
-  "Sends an request to the specified host and port"
+  "Sends an request to the specified host and port, returns the response"
   [host port req]
   (with-open [sock (Socket. host port)
               writer (io/writer sock)
@@ -47,21 +47,34 @@
         )))

+(defn send-cmd
+  "Send command and return the response code or string depending on the format"
+  [conn cmd-str]
+  (println "------------------------------")
+  (println "cmd:" cmd-str)
+  (let [resp (send-request (:host conn) (:client-port conn) cmd-str)]
+
+    (println "resp:" resp)
+
+    ;; i<num>s or "<len>:<string>"
+    (if (.startsWith resp "i")
+      (last (re-find #"i([0-9-]+)s" resp))
+      (last (re-find #"(\d+):(.*)" resp))
+      )))
+
+
+
 (defn telldus
   ([conn cmd]
-   (send-request (:host conn) (:client-port conn) (telldus-cmd cmd)))
+   (send-cmd conn (telldus-cmd cmd)))
   ([conn cmd arg]
-   (send-request (:host conn) (:client-port conn) (telldus-cmd cmd arg)))
+   (send-cmd conn (telldus-cmd cmd arg)))
   ([conn cmd arg arg2]
-   (send-request (:host conn) (:client-port conn) (telldus-cmd cmd arg arg2)))
+   (send-cmd conn (telldus-cmd cmd arg arg2)))
   )

-(defn ival [res]
-  (Integer. (re-find #"\d+" res)))
-
-(defn- get-num-devices
+(defn get-num-devices
   "Get the number of defined devices"
   [conn]
-  (ival (telldus conn "tdGetNumberOfDevices")))
-
+  (telldus conn "tdGetNumberOfDevices"))


Fix some bugs in vault.crypto/print-key-info.

--- src/vault/crypto.clj
+++ src/vault/crypto.clj
@@ -125,26 +125,26 @@
 (defn print-key-info
   "Prints information about the given key."
   [k]
-  (println "Key id:" (Long/toHexString (key-id k))
-           (if (.isMasterKey k) "(master key)" "(subkey)"))
-  (when (instance? PGPSecretKey k)
-    (if (.isPrivateKeyEmpty k)
-      (println "    Private key is not available.")
-      (if (.isSigningKey k)
-        (println "    Private key is available for decryption and signing.")
-        (println "    Private key is available for decryption."))))
   (let [public-key (if (instance? PGPSecretKey k) (.getPublicKey k) k)
         strength (.getBitStrength public-key)
         algorithm (or (key-algorithm public-key) "UNKNOWN")
         fingerprint (->> (.getFingerprint public-key)
                          (map (partial format "%02X"))
                          string/join)]
+    (println (if (.isMasterKey k) "Master key:" "Subkey:")
+             (Long/toHexString (key-id k))
+             (str \( strength \/ algorithm \)))
+    (println "    Fingerprint:"
+             (str (subs fingerprint 0 (- (count fingerprint) 8)) \/
+                  (subs fingerprint (- (count fingerprint) 8))))
     (if (.isEncryptionKey public-key)
       (println "    Public key is available for encryption.")
       (println "    Public key is available."))
-    (println "    Algorithm:" algorithm (str \( strength " bits)"))
-    (println "    Fingerprint:"
-             (str (subs fingerprint 0 (- (count fingerprint) 8)) \/
-                  (subs fingerprint (- (count fingerprint) 8))))
-    (doseq [uid (.getUserIDs public-key)]
+    (when (instance? PGPSecretKey k)
+      (if (.isPrivateKeyEmpty k)
+        (println "    Private key is not available.")
+        (if (.isSigningKey k)
+          (println "    Private key is available for decryption and signing.")
+          (println "    Private key is available for decryption."))))
+    (doseq [uid (iterator-seq (.getUserIDs public-key))]
       (println "    User ID:" uid))))


Fix manifold error

Fix manifold error

--- src/yada/methods.clj
+++ src/yada/methods.clj
@@ -120,8 +120,8 @@
       (throw (ex-info "" {:status 404
                           :yada.core/http-response true})))

-    (when-not (:representation ctx)
-      (d/error-deferred
+    (when-not (-> ctx :response :representation)
+      (throw
        (ex-info "" {:status 406
                     :yada.core/http-response true})))


RR: recover some test from namespace `hatti.map.utils-test`

--- test/hatti/map/utils_test.cljs
+++ test/hatti/map/utils_test.cljs
@@ -1,101 +1,100 @@
-(ns hatti.map.utils-test)
-;(ns hatti.map.utils-test
-;  (:require-macros [cljs.test :refer (is deftest testing)]
-;                   [dommy.macros :refer [sel1 sel]]
-;                   [ona.utils.macros :refer [read-file]])
-;  (:require [cljs.test :as t]
-;            [cljs.core.async :refer [chan]]
-;            [clojure.string :as s]
-;            [dommy.core :as dommy]
-;            [hatti.test-utils :refer [new-container!]]
-;            [hatti.utils :refer [json->js->cljs json->cljs]]
-;            [ona.utils.forms :as f]
-;            [ona.dataview.shared :as shared]
-;            [ona.dataview.dommy-helpers :as dh]
-;            [hatti.map.utils :as mu]
-;            [ona.dataview.osm-utils-test :refer [osm-xml osm-form osm-data
-;                                                 osm-road-field osm-building-field]]))
-;
-;;; DATA GEN HELPERS
-;
-;(defn feature-gen [n]
-;  (for [i (range n)]
-;    (hash-map :geometry {:coordinates [(rand 10) (rand 10)]
-;                         :type "Point"}
-;              :properties {"_id" i "_rank" (inc i)}
-;              :type "Feature")))
-;
-;(defn test-geojson [n]
-;  {:type "FeatureCollection" :features (feature-gen n)})
-;
-;;; MAP HELPERS
-;
-;(defn equivalent-styles [ss ts]
-;  (every? #{true} (map mu/equivalent-style ss ts)))
-;(def map-id (new-container!))
-;(def m (mu/create-map map-id false))
-;
-;;; TESTS
-;
-;(deftest map-creation
-;  (testing "create map creates a leaflet map with zoom + layers control"
-;    (is (re-find #"leaflet-container" (dommy/attr map-id "class")))
-;    (is (not= nil (sel1 map-id :.leaflet-map-pane)))
-;    (is (not= nil (sel1 map-id :.leaflet-control-zoom)))
-;    (is (not= nil (sel1 map-id :.leaflet-control-layers))))
-;
-;  #_(testing "all mapbox-tile layers are loaded"
-;    (is (= (map :name mu/mapbox-tiles)
-;           (map (comp s/trim dommy/text)
-;                  (-> map-id (sel1 :.leaflet-control-layers) (sel :label)))))))
-;
-;(deftest loading-and-marker-actions
-;  (let [chan (chan)
-;        N 10
-;        geojson (test-geojson N)
-;        {:keys [markers feature-layer]} (mu/load-geo-json m geojson chan)
-;        m1 (first markers)
-;        fff #js {:fillColor "#fff"}
-;        normal-style (mu/get-ona-style :point :normal)]
-;    (testing "geojson loads markers into map"
-;      (is (= true (.hasLayer m feature-layer)))
-;      (is (= N (count markers))))
-;    (testing "marker defaults check out"
-;      (is (= (range N) (map mu/get-id markers)))
-;      (is (= (map inc (range N)) (map mu/get-rank markers)))
-;      (is (= (repeat N false)) (map mu/is-clicked? markers))
-;      (is (mu/equivalent-style normal-style
-;                            (first (map mu/get-style markers))))
-;      (is (equivalent-styles (repeat N normal-style)
-;                             (map mu/get-style markers))))
-;    (testing "clicking/unclicking reflect on is-clicked?"
-;      (let [_ (mu/apply-click-style m1)]
-;        (is (= (concat [true] (repeat (dec N) false))
-;               (map mu/is-clicked? markers))))
-;      (let [_ (mu/apply-unclick-style m1)]
-;        (is (= (repeat N false)) (map mu/is-clicked? markers))))
-;    (testing "restyle marker changes all un-clicked marker colors"
-;      ;; CLICK m1, and change color to #fff. Everything but m1 should change
-;      (let [_ (mu/apply-click-style m1)
-;            _ (doseq [m markers]
-;                (mu/re-style-marker #(hash-map :fillColor "#fff") m))]
-;        (is (mu/equivalent-style (mu/get-ona-style :point :clicked)
-;                                 (mu/get-style m1)))
-;        (is (mu/equivalent-style fff
-;                                 (mu/get-style m1 :reset)))
-;        (is (equivalent-styles (repeat (dec N) fff)
-;                               (map mu/get-style (rest markers)))))
-;      ;; UNCLICK m1, everything should be #fff, all reset styles also fff
-;      (let [_ (mu/apply-unclick-style m1)]
-;        (is (equivalent-styles (repeat N fff) (map mu/get-style markers)))
-;        (is (equivalent-styles (repeat N fff) (map #(mu/get-style % :reset) markers))))
-;      ;; CLEAR ALL STYLES
-;      (let [_ (mu/clear-all-styles markers)]
-;        (is (equivalent-styles (repeat N normal-style)
-;                               (map mu/get-style markers)))))))
-;
-;;; READ fixtures into data structures using the read-file macro
-;;; FORMS are keywordized
+(ns hatti.map.utils-test
+  (:require-macros [cljs.test :refer (is deftest testing)]
+                   [dommy.macros :refer [sel1 sel]]
+                   #_[ona.utils.macros :refer [read-file]])
+  (:require [cljs.test :as t]
+            [cljs.core.async :refer [chan]]
+            [clojure.string :as s]
+            [dommy.core :as dommy]
+            [hatti.test-utils :refer [new-container!]]
+            [hatti.utils :refer [json->js->cljs json->cljs]]
+            [hatti.ona.forms :as f]
+            [hatti.shared :as shared]
+            [hatti.map.utils :as mu]
+            #_[ona.dataview.osm-utils-test :refer [osm-xml osm-form osm-data
+                                                 osm-road-field osm-building-field]]))
+
+;; DATA GEN HELPERS
+
+(defn feature-gen [n]
+  (for [i (range n)]
+    (hash-map :geometry {:coordinates [(rand 10) (rand 10)]
+                         :type "Point"}
+              :properties {"_id" i "_rank" (inc i)}
+              :type "Feature")))
+
+(defn test-geojson [n]
+  {:type "FeatureCollection" :features (feature-gen n)})
+
+;; MAP HELPERS
+
+(defn equivalent-styles [ss ts]
+  (every? #{true} (map mu/equivalent-style ss ts)))
+(def map-id (new-container!))
+(def m (mu/create-map map-id false))
+
+;; TESTS
+
+(deftest map-creation
+  (testing "create map creates a leaflet map with zoom + layers control"
+    (is (re-find #"leaflet-container" (dommy/attr map-id "class")))
+    (is (not= nil (sel1 map-id :.leaflet-map-pane)))
+    (is (not= nil (sel1 map-id :.leaflet-control-zoom)))
+    (is (not= nil (sel1 map-id :.leaflet-control-layers))))
+
+  #_(testing "all mapbox-tile layers are loaded"
+    (is (= (map :name mu/mapbox-tiles)
+           (map (comp s/trim dommy/text)
+                  (-> map-id (sel1 :.leaflet-control-layers) (sel :label)))))))
+
+(deftest loading-and-marker-actions
+  (let [chan (chan)
+        N 10
+        geojson (test-geojson N)
+        {:keys [markers feature-layer]} (mu/load-geo-json m geojson chan)
+        m1 (first markers)
+        fff #js {:fillColor "#fff"}
+        normal-style (mu/get-ona-style :point :normal)]
+    (testing "geojson loads markers into map"
+      (is (= true (.hasLayer m feature-layer)))
+      (is (= N (count markers))))
+    (testing "marker defaults check out"
+      (is (= (range N) (map mu/get-id markers)))
+      (is (= (map inc (range N)) (map mu/get-rank markers)))
+      (is (= (repeat N false)) (map mu/is-clicked? markers))
+      (is (mu/equivalent-style normal-style
+                            (first (map mu/get-style markers))))
+      (is (equivalent-styles (repeat N normal-style)
+                             (map mu/get-style markers))))
+    (testing "clicking/unclicking reflect on is-clicked?"
+      (let [_ (mu/apply-click-style m1)]
+        (is (= (concat [true] (repeat (dec N) false))
+               (map mu/is-clicked? markers))))
+      (let [_ (mu/apply-unclick-style m1)]
+        (is (= (repeat N false)) (map mu/is-clicked? markers))))
+    (testing "restyle marker changes all un-clicked marker colors"
+      ;; CLICK m1, and change color to #fff. Everything but m1 should change
+      (let [_ (mu/apply-click-style m1)
+            _ (doseq [m markers]
+                (mu/re-style-marker #(hash-map :fillColor "#fff") m))]
+        (is (mu/equivalent-style (mu/get-ona-style :point :clicked)
+                                 (mu/get-style m1)))
+        (is (mu/equivalent-style fff
+                                 (mu/get-style m1 :reset)))
+        (is (equivalent-styles (repeat (dec N) fff)
+                               (map mu/get-style (rest markers)))))
+      ;; UNCLICK m1, everything should be #fff, all reset styles also fff
+      (let [_ (mu/apply-unclick-style m1)]
+        (is (equivalent-styles (repeat N fff) (map mu/get-style markers)))
+        (is (equivalent-styles (repeat N fff) (map #(mu/get-style % :reset) markers))))
+      ;; CLEAR ALL STYLES
+      (let [_ (mu/clear-all-styles markers)]
+        (is (equivalent-styles (repeat N normal-style)
+                               (map mu/get-style markers)))))))
+
+;; TODO Add fixturest reader functoin and FIX tests below
+;; READ fixtures into data structures using the read-file macro
+;; FORMS are keywordized
 ;(def geopoint-form (json->js->cljs
 ;                    (read-file "test/clj/ona/fixtures/geopoint-form.json")))
 ;(def geoshape-form (json->js->cljs
@@ -111,67 +110,67 @@
 ;                    (read-file "test/clj/ona/fixtures/geotrace-data.json")))
 ;
 ;(defn- two-num-array? [coll] (= [true true] (map number? coll)))
-;
-;;; TODO: Make these tests re-run.
-;;; The issue at the moment is that the previous tests were in clj, and were
-;;; running off of fixtures loading from the filesystem. It is not *easily*
-;;; possible to do this via cljs
-;;; (see https://github.com/cemerick/clojurescript.test/pull/58)
-;(deftest as-geojson-tests
-;  (testing "as-geojson returns nil if no geofield"
-;    (let [no-geo-form (remove f/geofield? (f/flatten-form geopoint-form))]
-;      (is (nil? (mu/as-geojson no-geo-form geopoint-data)))))
-;  (testing "as-geojson converts point data correctly"
-;    (let [ptform (f/flatten-form geopoint-form)
-;          ptfield (first (filter #(= "geopoint" (:type %)) ptform))
-;          ptgeojson (mu/as-geojson geopoint-data ptform ptfield)
-;          geoms (map :geometry (:features ptgeojson))
-;          all-coords (map :coordinates geoms)]
-;      (is (= (map :type geoms) (repeat (count geoms) "Point")))
-;      (is (every? #{true} (map two-num-array? all-coords)))
-;      (is (= (first all-coords) [-11.59225 7.937983]))
-;      (testing "as-geojson drops null point data correctly"
-;        (is (= (count geopoint-data) (inc (count (:features ptgeojson))))))))
-;  (testing "as-geojson converts geoshape data correctly"
-;    (let [shpform (f/flatten-form geoshape-form)
-;          shpgeojson (mu/as-geojson geoshape-data shpform)
-;          geoms (map :geometry (:features shpgeojson))
-;          all-coords (map first (map :coordinates geoms))]
-;      (is (= (map :type geoms) (repeat (count geoms) "Polygon")))
-;      (is (every? #{true}
-;                  (->> all-coords (map first) (map two-num-array?))))
-;      ;; polygon geom = list of polygons, polygon = list of lat/lng pairs
-;      (is (= (-> all-coords first first) [-11.59225 7.937983]))
-;      (is (= (testing "as-geojson drops null point data correctly"
-;        (count geoshape-data) (inc (count (:features shpgeojson))))))))
-;  (testing "as-geojson converts geotrace data correctly"
-;    (let [trcform (f/flatten-form geotrace-form)
-;          trcgeojson (mu/as-geojson geotrace-data trcform)
-;          ;; linestring geom = list of lat/lng pairs
-;          geoms (map :geometry (:features trcgeojson))
-;          all-coords (map :coordinates geoms)]
-;      (is (= (map :type geoms) (repeat (count geoms) "LineString")))
-;      (is (every? #{true}
-;                  (->> all-coords (map first) (map two-num-array?))))
-;      (is (= (-> all-coords first first) [-11.59225 7.937983]))
-;      (testing "as-geojson drops null point data correctly"
-;        (is (= (count geotrace-data) (inc (count (:features trcgeojson)))))))))
-;
-;(deftest geojson-from-osm-data
-;  "Tests that geojson can be produced from osm data.
-;   OSM fixtures from osm-utils-test, setup from dataview.shared."
-;  (shared/update-app-data! osm-data :re-rank? true)
-;  (shared/update-app-state-with-osm-data! osm-form osm-xml)
-;  (let [data-including-osm (get-in @shared/app-state [:map-page :data])
-;        field->geojson (partial mu/as-geojson data-including-osm osm-form)]
-;    (testing "geojson for osm_road field is null (there is no data for roads)"
-;      (is (= [] (:features (field->geojson osm-road-field)))))
-;    (testing "geojson for osm_building field has two polygons"
-;      (let [building-features (:features (field->geojson osm-building-field))]
-;        (is (= 2 (count building-features)))
-;        (is (= (repeat 2 #{:type :properties :geometry})
-;               (map #(-> % keys set) building-features)))
-;        (is (-> building-features first :geometry))
-;        (is (-> building-features second :geometry))
-;        (is (every? #{"Polygon"}
-;                    (map #(-> % :geometry :type) building-features)))))))
+
+;; TODO: Make these tests re-run.
+;; The issue at the moment is that the previous tests were in clj, and were
+;; running off of fixtures loading from the filesystem. It is not *easily*
+;; possible to do this via cljs
+;; (see https://github.com/cemerick/clojurescript.test/pull/58)
+#_(deftest as-geojson-tests
+  (testing "as-geojson returns nil if no geofield"
+    (let [no-geo-form (remove f/geofield? (f/flatten-form geopoint-form))]
+      (is (nil? (mu/as-geojson no-geo-form geopoint-data)))))
+  (testing "as-geojson converts point data correctly"
+    (let [ptform (f/flatten-form geopoint-form)
+          ptfield (first (filter #(= "geopoint" (:type %)) ptform))
+          ptgeojson (mu/as-geojson geopoint-data ptform ptfield)
+          geoms (map :geometry (:features ptgeojson))
+          all-coords (map :coordinates geoms)]
+      (is (= (map :type geoms) (repeat (count geoms) "Point")))
+      (is (every? #{true} (map two-num-array? all-coords)))
+      (is (= (first all-coords) [-11.59225 7.937983]))
+      (testing "as-geojson drops null point data correctly"
+        (is (= (count geopoint-data) (inc (count (:features ptgeojson))))))))
+  (testing "as-geojson converts geoshape data correctly"
+    (let [shpform (f/flatten-form geoshape-form)
+          shpgeojson (mu/as-geojson geoshape-data shpform)
+          geoms (map :geometry (:features shpgeojson))
+          all-coords (map first (map :coordinates geoms))]
+      (is (= (map :type geoms) (repeat (count geoms) "Polygon")))
+      (is (every? #{true}
+                  (->> all-coords (map first) (map two-num-array?))))
+      ;; polygon geom = list of polygons, polygon = list of lat/lng pairs
+      (is (= (-> all-coords first first) [-11.59225 7.937983]))
+      (is (= (testing "as-geojson drops null point data correctly"
+        (count geoshape-data) (inc (count (:features shpgeojson))))))))
+  (testing "as-geojson converts geotrace data correctly"
+    (let [trcform (f/flatten-form geotrace-form)
+          trcgeojson (mu/as-geojson geotrace-data trcform)
+          ;; linestring geom = list of lat/lng pairs
+          geoms (map :geometry (:features trcgeojson))
+          all-coords (map :coordinates geoms)]
+      (is (= (map :type geoms) (repeat (count geoms) "LineString")))
+      (is (every? #{true}
+                  (->> all-coords (map first) (map two-num-array?))))
+      (is (= (-> all-coords first first) [-11.59225 7.937983]))
+      (testing "as-geojson drops null point data correctly"
+        (is (= (count geotrace-data) (inc (count (:features trcgeojson)))))))))
+
+#_(deftest geojson-from-osm-data
+  "Tests that geojson can be produced from osm data.
+   OSM fixtures from osm-utils-test, setup from dataview.shared."
+  (shared/update-app-data! osm-data :re-rank? true)
+  (shared/update-app-state-with-osm-data! osm-form osm-xml)
+  (let [data-including-osm (get-in @shared/app-state [:map-page :data])
+        field->geojson (partial mu/as-geojson data-including-osm osm-form)]
+    (testing "geojson for osm_road field is null (there is no data for roads)"
+      (is (= [] (:features (field->geojson osm-road-field)))))
+    (testing "geojson for osm_building field has two polygons"
+      (let [building-features (:features (field->geojson osm-building-field))]
+        (is (= 2 (count building-features)))
+        (is (= (repeat 2 #{:type :properties :geometry})
+               (map #(-> % keys set) building-features)))
+        (is (-> building-features first :geometry))
+        (is (-> building-features second :geometry))
+        (is (every? #{"Polygon"}
+                    (map #(-> % :geometry :type) building-features)))))))


Style fixes

Style fixes

--- test/icecap/store/mem_test.clj
+++ test/icecap/store/mem_test.clj
@@ -1,11 +1,10 @@
 (ns icecap.store.mem-test
-  (:require [icecap.store.mem :refer [mem-store]]
-            [icecap.store.test-props :refer :all]
-            [clojure.test :refer :all]
+  (:require [icecap.store.mem :as mem]
+            [icecap.store.test-props :as props]
             [clojure.test.check.clojure-test :refer [defspec]]))

 (defspec mem-store-roundtrip
-  (roundtrip-prop (mem-store)))
+  (props/roundtrip-prop (mem/mem-store)))

 (defspec mem-store-delete
-  (delete-prop (mem-store)))
+  (props/delete-prop (mem/mem-store)))


Test for function users-href

Test for function users-href

--- test/zg/html_renderer_test.clj
+++ test/zg/html_renderer_test.clj
@@ -189,3 +189,10 @@
             [:a {:href "user-whitelist?name=other-user"} "other-user"] (user-href "other-user" :whitelist)
             [:a {:href "user-blacklist?name=other-user"} "other-user"] (user-href "other-user" :blacklist))))

+(deftest test-users-href
+    "Checking the function zg.html-renderer/users-href."
+    (testing "the function zg.html-renderer/users-href."
+        (are [x y] (= x y)
+            "url-prefix/users-whitelist" (users-href "url-prefix/" :whitelist)
+            "url-prefix/users-blacklist" (users-href "url-prefix/" :blacklist))))
+


Added five tests into html_renderer_test.clj

--- test/zg/html_renderer_test.clj
+++ test/zg/html_renderer_test.clj
@@ -57,3 +57,33 @@
         (is (callable? 'zg.html-renderer/render-name-field))))

+(deftest test-tab-class-existence
+    "Check that the zg.html-renderer/tab-class definition exists."
+    (testing "if the zg.html-renderer/tab-class definition exists."
+        (is (callable? 'zg.html-renderer/tab-class))))
+
+
+(deftest test-user-href-existence
+    "Check that the zg.html-renderer/user-href definition exists."
+    (testing "if the zg.html-renderer/user-href definition exists."
+        (is (callable? 'zg.html-renderer/user-href))))
+
+
+(deftest test-users-href-existence
+    "Check that the zg.html-renderer/users-href definition exists."
+    (testing "if the zg.html-renderer/users-href definition exists."
+        (is (callable? 'zg.html-renderer/users-href))))
+
+
+(deftest test-remember-me-href-existence
+    "Check that the zg.html-renderer/remember-me-href definition exists."
+    (testing "if the zg.html-renderer/remember-me-href definition exists."
+        (is (callable? 'zg.html-renderer/remember-me-href))))
+
+
+(deftest test-render-navigation-bar-section-existence
+    "Check that the zg.html-renderer/render-navigation-bar-section definition exists."
+    (testing "if the zg.html-renderer/render-navigation-bar-section definition exists."
+        (is (callable? 'zg.html-renderer/render-navigation-bar-section))))
+
+


:notify-command works after #'cljsbuild once

--- ext/chrome/project.clj
+++ ext/chrome/project.clj
@@ -13,7 +13,7 @@
             [lein-ring "0.9.0" #_ ("0.8.13")
              :exclusions [org.clojure/clojure]]
             [lein-packer "0.1.0"]]
-  :hooks [leiningen.cljsbuild]
+  :hooks [leiningen.cljsbuild leiningen.packer]
   :profiles {:dev {
                    :dependencies []
                    :ring {:handler owl.web.routes/app
@@ -27,7 +27,8 @@
                                             :output-to
                                             "resources/public/js/main.js"
                                             :optimizations :whitespace
-                                            :pretty-print true}}]}
+                                            :pretty-print true}
+                                 :notify-command ["lein" "packer" "once"]}]}
                    :pack {:mapping [{:source-paths ["manifest.json"
                                                     "resources/public"]
                                      :target-path "target/packed"


Fix merge error

Fix merge error

--- src/cljs/main/broadfcui/page/workspace/monitor/workflow_details.cljs
+++ src/cljs/main/broadfcui/page/workspace/monitor/workflow_details.cljs
@@ -7,7 +7,7 @@
     [broadfcui.common.codemirror :refer [CodeMirror]]
     [broadfcui.common.components :as comps]
     [broadfcui.common.gcs-file-preview :refer [GCSFilePreviewLink]]
-    [broadfcui.common.icons :as icons]
+    [broadfcui.common.modal :as modal]
     [broadfcui.common.style :as style]
     [broadfcui.common.table.table :refer [Table]]
     [broadfcui.common.table.style :as table-style]


Updated Public API URL

Updated Public API URL

--- src/alfresco_technical_validation/alfresco_public_api.clj
+++ src/alfresco_technical_validation/alfresco_public_api.clj
@@ -21,7 +21,7 @@
             [clojure.tools.logging :as log]))

-(def ^:private ^String api-page-url       "http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/concepts/java-public-api-list.html")
+(def ^:private ^String api-page-url       "http://docs.alfresco.com/4.2/concepts/java-public-api-list.html")
 (def ^:private ^String api-list-open-tag  "
")
 (def ^:private ^String api-list-close-tag "
")


Remove deleted tests

Remove deleted tests

--- test/aurora/btree_test.cljs
+++ test/aurora/btree_test.cljs
@@ -75,22 +75,6 @@
   5000
   (aurora.btree/iterator-prop 1))

-(defspec intersection-prop-test
-  1000
-  aurora.btree/intersection-prop)
-
-(defspec trie-tree-prop-test
-  5000
-  (aurora.btree/trie-tree-prop 1))
-
-(defspec trie-tree-prop-test
-  5000
-  (aurora.btree/trie-tree-prop 2))
-
-(defspec trie-tree-prop-test
-  5000
-  (aurora.btree/trie-tree-prop 3))
-
 (defspec self-join-prop-test
   5000
   (aurora.btree/self-join-prop 1))


Lazily load nrepl in the container.

Lazily load nrepl in the container.

We don't always need it, since we don't start a repl for an uberwar.

--- wildfly/src/immutant/wildfly.clj
+++ wildfly/src/immutant/wildfly.clj
@@ -15,7 +15,6 @@
 (ns immutant.wildfly
   "Utility functions only useful within a WildFly container."
   (:require [immutant.internal.util :as u]
-            [immutant.wildfly.repl  :as repl]
             [wunderboss.util        :as wu]
             [clojure.java.io        :as io])
   (:import java.net.URL))
@@ -78,7 +77,8 @@
   (extend-module-classloader-to-cjc)
   (extend-module-classloader-to-dynapath)
   ((u/require-resolve init-fn))
-  (if-let [nrepl (:nrepl opts)] (repl/start nrepl)))
+  (when-let [nrepl (:nrepl opts)]
+    ((u/require-resolve 'immutant.wildfly.repl/start) nrepl)))

 (defn get-from-service-registry [k]
   (if-let [registry (wu/service-registry)]


Fix gen-coll-ints to ensure same typed collections

--- test/deepfns/core_test.cljc
+++ test/deepfns/core_test.cljc
@@ -122,11 +122,24 @@
     (seq? m) (seq [f])
     (map? m) {:a f}))

+(def gen-vec-coll-ints
+  "Generates a vector of randomly typed collections of ints for testing.
+  Note that all the collections are of the same type."
+  (gen/one-of
+    [(gen/vector (gen/map (gen/return :a) gen/int {:min-elements 1}) 1 5)
+     (gen/vector (gen/vector gen/int 1) 1 5)
+     (gen/vector (gen/fmap list gen/int) 1 5)
+     (gen/vector (gen/set gen/int {:min-elements 1
+                                   :max-elements 1}) 1 5)
+     (gen/vector (gen/fmap (fn [n]
+                             (seq [n])) gen/int)
+       1 5)]))
+
 ;; check for functional composition (2)
 ;; Just checking top level for now, nested is covered by unit tests
 (defspec deepfapply-composition
   (prop/for-all [fs (gen/elements [+ *])
-                 arg (gen/vector gen-coll-ints 1 5)]
+                 arg gen-vec-coll-ints]
     (let [f1 (build-fn arg (partial fs 5))
           f2 (build-fn arg (partial fs 10))
           out1 (->> arg
@@ -151,7 +164,7 @@
 ;; test for homomorphism (3)
 (defspec deepfapply-homomorphism
   (prop/for-all [f (gen/elements [* +])
-                 args (gen/vector gen-coll-ints 1 5)]
+                 args gen-vec-coll-ints]
     (let [out (apply deepfapply (build-fn args f) args)
           expected (expected-val args f)]
       (true?
@@ -161,7 +174,7 @@
 ;; TODO: get some coverage for variadic interchange
 ;; test for interchange (4)
 (defspec deepfapply-interchange
-  (prop/for-all [args (vector gen-coll-ints 1 5)]
+  (prop/for-all [args gen-vec-coll-ints]
     (let [x (first args)
           f (pure (empty x) identity)
           out1 (deepfapply (pure (empty x) #(% x)) f)


Added a test to ensure that searching for a non-existent controlfield doesn't throw an exception.

--- test/marcgrep/test/core.clj
+++ test/marcgrep/test/core.clj
@@ -101,6 +101,13 @@
              :on test-dataset
              :matches ["12345" "23456"]))

+(deftest non-existent-control-field
+  (the-query {:operator "contains"
+              :field "007"
+              :value "hello"}
+             :on test-dataset
+             :does-not-match ["12345" "23456"]))
+
 (deftest all-fields-search
   (the-query {:operator "contains"
               :field "*"
@@ -108,3 +115,4 @@
              :on test-dataset
              :matches ["12345"]
              :does-not-match ["23456"]))
+


fix tests - i like that i don't have to update the c/complete tests when i added a :num-years field to Mortgage, nice

--- test/mortgage/core_test.clj
+++ test/mortgage/core_test.clj
@@ -10,17 +10,18 @@

 (deftest making-mortgage
   (testing "happy path"
-    (is (= (make-mortgage 500000 0.035 0.15)
+    (is (= (make-mortgage 500000 0.035 0.15 30)
            {:house-price             500000
             :apr                     0.035
-            :down-payment-percentage 0.15})))
+            :down-payment-percentage 0.15
+            :num-years 30})))

   (testing "garbage input"
     (is (thrown? Exception
-                 (make-mortgage "foo" "bar" "baz")))))
+                 (make-mortgage "foo" "bar" "baz" "quux")))))

 (deftest maths
-  (let [a-mortgage (make-mortgage 500000 0.035 0.15)]
+  (let [a-mortgage (make-mortgage 500000 0.035 0.15 30)]
     (testing "get-loan-amount"
       (is (== (get-loan-amount a-mortgage)
               425000)))


Tidy up benchmarks.

Tidy up benchmarks.

--- test/soy_clj/bench_test.clj
+++ test/soy_clj/bench_test.clj
@@ -4,34 +4,35 @@
             [criterium.core :as c]
             [soy-clj.core :as soy]))

+(defn- sep
+  [s]
+  (printf "\n\n######  %s  ######\n" s))
+
 (deftest ^:bench parse-uncached-bench
-  (println "\n\n=== Parsing (uncached)")
+  (sep "Parsing (uncached)")
   (soy/set-cache (cache/ttl-cache-factory {} :ttl 0))
   (c/bench (soy/parse "example.soy")))

 (deftest ^:bench parse-cached-bench
-  (println "\n\n=== Parsing (cached)")
+  (sep "Parsing (cached)")
   (soy/set-cache (cache/lu-cache-factory {}))
   (soy/parse "example.soy")
   (c/bench (soy/parse "example.soy")))

 (deftest ^:bench render-big-bench
-  (println "\n\n=== Rendering (big list)")
-  (soy/set-cache (cache/lu-cache-factory {}))
+  (sep "Rendering (big list)")
   (let [templates (soy/parse "example.soy")
         data {:items (vec (map str (range 1 1000)))}]
     (c/bench (soy/render templates "examples.simple.list" data))))

 (deftest ^:bench render-small-bench
-  (println "\n\n=== Rendering (small list)")
-  (soy/set-cache (cache/lu-cache-factory {}))
+  (sep "Rendering (small list)")
   (let [templates (soy/parse "example.soy")
         data {:items (vec (map str (range 1 50)))}]
     (c/bench (soy/render templates "examples.simple.list" data))))

 (deftest ^:bench render-simple-bench
-  (println "\n\n=== Rendering (simple)")
-  (soy/set-cache (cache/lu-cache-factory {}))
+  (sep "Rendering (simple)")
   (let [templates (soy/parse "example.soy")
         data {:bar "bar"}]
     (c/bench (soy/render templates "examples.simple.basic" data))))


GAWB-1288: generalizing log preview messages

--- src/cljs/org/broadinstitute/firecloud_ui/common/gcs_file_preview.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/gcs_file_preview.cljs
@@ -28,8 +28,9 @@
           (labeled "Google Bucket" (:bucket-name props))
           (labeled "Object" (:object props))
           [:div {:style {:marginTop "1em"}}
-           (if (> data-size preview-byte-count) (str "Last " (:preview-line-count @state)
-                                       " lines of log are shown. Use the link below to view the full log.") "Log:")
+           [:div {} "Previews for some filetypes may be unsupported. "]
+           (when (> data-size preview-byte-count) (str "Last " (:preview-line-count @state)
+                                                       " lines are shown. Use link below to view entire file.")))
            ;; The max-height of 206 looks random, but it's so that the top line of the log preview is half cut-off
            ;; to hint to the user that they should scroll up.
            (react/create-element


use 0.0-XXXX for tag instead or rXXXX, and included longer commit messages on autogen details

--- src/core.clj
+++ src/core.clj
@@ -118,6 +118,18 @@
     (str "https://github.com/clojure/" repo "/blob/" version "/" strip-path
          "#L" start-line "-L" end-line)))

+(defn clj-tag->version
+  [v]
+  (if-let [[_ semver] (re-find #"clojure-(.*)" v)]
+    semver
+    v))
+
+(defn cljs-tag->version
+  [v]
+  (if-let [[_ number] (re-find #"r(.*)"v )]
+    (str "0.0-" number)
+    v))
+
 ;;------------------------------------------------------------
 ;; Docs Repo
 ;;------------------------------------------------------------
@@ -151,7 +163,8 @@

 (defn docs-repo-has-version?
   [v]
-  (let [result (git-docs-repo! "rev-parse" v)
+  (let [version (cljs-tag->version v)
+        result (git-docs-repo! "rev-parse" version)
         present? (zero? (:exit result))]
     present?))

@@ -172,14 +185,26 @@
       (docs-repo-out-of-sync! (str version " already has tag")))))

 (defn clear-docs-repo!
-  [msg]
+  []
   (git-docs-repo! "rm" "-rf" "."))

 (defn commit-docs-repo!
-  [version]
-  (git-docs-repo! "add" ".")
-  (git-docs-repo! "commit" "-m" version)
-  (git-docs-repo! "tag" version))
+  []
+  (let [clj-t  (get *repo-version* "clojure")
+        cljs-t (get *repo-version* "clojurescript")
+        clj-v  (clj-tag->version clj-t)
+        cljs-v (cljs-tag->version cljs-t)
+        msg (str cljs-v "\n"
+                 "\n"
+                 "- auto-generated by cljs-api-parser\n"
+                 "  https://github.com/shaunlebron/cljs-api-parser\n"
+                 "\n"
+                 "- parsed from:\n"
+                 "  ClojureScript " cljs-v "\n"
+                 "  Clojure " clj-v "\n")]
+    (git-docs-repo! "add" ".")
+    (git-docs-repo! "commit" "-m" msg)
+    (git-docs-repo! "tag" cljs-v)))

 ;;------------------------------------------------------------
 ;; Repo Helpers
@@ -670,7 +695,7 @@
         (let [parsed (parse-all)
               symbols (set (map :full-name parsed))]

-          (clear-docs-repo! version)
+          (clear-docs-repo!)

           (println "\nWriting updated history to" history-filename "...")
           (mkdir *output-dir*)
@@ -681,8 +706,8 @@
           (let [parsed (attach-history-to-items parsed (:version-map @history))]
             (dump-api-docs! parsed))

-          (println "\nCommitting docs at tag" version "...")
-          (commit-docs-repo! version))
+          (println "\nCommitting docs at tag" (cljs-tag->version version) "...")
+          (commit-docs-repo!))

         (println "\nDone."))))


corrected indent issue

corrected indent issue

--- search-app/src/cmr/search/api/routes.clj
+++ search-app/src/cmr/search/api/routes.clj
@@ -174,10 +174,10 @@
 (defn process-params
   "Processes the parameters by removing unecessary keys and adding other keys like result format."
   [params path-w-extension headers default-mime-type]
-   (-> params
-       (dissoc :path-w-extension)
-       (dissoc :token)
-       (assoc :result-format (get-search-results-format path-w-extension headers default-mime-type))))
+  (-> params
+      (dissoc :path-w-extension)
+      (dissoc :token)
+      (assoc :result-format (get-search-results-format path-w-extension headers default-mime-type))))

 (defn- search-response
   "Generate the response map for finding concepts by params or AQL."


Show UI v2 opt out on account page

Show UI v2 opt out on account page

--- src-cljs/frontend/components/header.cljs
+++ src-cljs/frontend/components/header.cljs
@@ -69,7 +69,7 @@
               [:li
                [:a {:title "home", :href "/"} [:i.fa.fa-home] " "]])
             (crumbs/crumbs crumbs-data)]
-           (when (and (= :dashboard (:navigation-point app))
+           (when (and (#{:dashboard :account} (:navigation-point app))
                       (not (-> app :navigation-data :repo))
                       (not (-> app :navigation-data :org))
                       (feature/enabled? :ui-v2-opt-in-banner)


Fix launcher

Fix launcher

--- src/leiningen/new/onyx_app/src/onyx_app/launcher/launch_prod_peers.clj
+++ src/leiningen/new/onyx_app/src/onyx_app/launcher/launch_prod_peers.clj
@@ -21,12 +21,12 @@
         config (read-config (clojure.java.io/resource "config.edn") {:profile :default})
         peer-config (-> (:peer-config config)
                         {{#docker?}}(assoc :onyx.log/config {:appenders
-                                                             :rotor (-> (rotor/rotor-appender
-                                                                          {:path "onyx.log"
-                                                                           :max-size (* 512 102400)
-                                                                           :backlog 5})
-                                                                        (assoc :min-level :info))
-                                                             {:standard-out
+                                                             {:rotor (-> (rotor/rotor-appender
+                                                                           {:path "onyx.log"
+                                                                            :max-size (* 512 102400)
+                                                                            :backlog 5})
+                                                                         (assoc :min-level :info))
+                                                              :standard-out
                                                               {:enabled? true
                                                                :async? false
                                                                :output-fn t/default-output-fn


use defseq for persistent list

use defseq for persistent list

--- src/clj/clojure/lang/persistent_list.clj
+++ src/clj/clojure/lang/persistent_list.clj
@@ -1,6 +1,7 @@
 (ns clojure.lang.persistent-list
   (:refer-clojure :only [declare defn defn- deftype loop last butlast])
   (:require [clojure.next           :refer [empty? inc with-meta =]]
+            [clojure.lang.aseq      :refer [defseq]]
             [clojure.lang.protocols :refer [ICounted IMeta IPersistentCollection -cons
                                             IPersistentStack ISeq ISeqable]]))

@@ -8,7 +9,7 @@

 (declare EMPTY-LIST)

-(deftype PersistentList [-meta -first -rest -count]
+(defseq PersistentList [-meta -first -rest -count]
   ICounted
   (-count [this] -count)

@@ -36,9 +37,6 @@

   (-next [this]
     (if (= -count 1) nil -rest))
-
-  ISeqable
-  (-seq [this] this)
 )

 (defn- make-list [meta first rest count]


select by input

select by input

--- src/cljs/re_form/inputs/select_impl.cljs
+++ src/cljs/re_form/inputs/select_impl.cljs
@@ -87,7 +87,7 @@
            :on-click (fn [_] (on-change i))}
           (label-fn i)]))]))

-(defn select [{:keys [on-search debounce-interval on-blur on-change label-fn]}]
+(defn select [{:keys [on-search debounce-interval on-blur on-change label-fn search-by-enter]}]
   (let [state (r/atom {:active false})
         doc-click-listener (fn [e]
                              (when (or (and (not (cmn/has-ancestor
@@ -100,9 +100,10 @@
                                                      "cross")))
                                (on-blur e)
                                (swap! state assoc :active false)))
-        search-fn (if debounce-interval
-                    (debounce on-search debounce-interval)
-                    on-search)
+        search-fn (cond
+                    search-by-enter (fn [_] (swap! state dissoc :selected))
+                    debounce-interval (debounce on-search debounce-interval)
+                    :else on-search)
         arrow-handler (fn [e]
                         (if-let [s (:selected @state)]
                           (let [upd (fn [x direction]
@@ -117,14 +118,16 @@
                               40 (when-let [next-sibl (.-nextSibling s)]
                                    (upd next-sibl :down))
                               13 (do (.click (:selected @state))
-                                     (swap! state dissoc :selected)
-                                     #_(.blur (:node @state)))
+                                     (swap! state dissoc :selected))
                               (swap! state dissoc :selected)))
-                          (when-let [first-opt (cmn/f-child (:root-node @state) "option")]
-                            (.. first-opt -classList (add "active"))
-                            (swap! state assoc :selected first-opt
-                                   :suggestions-container
-                                   (cmn/f-child (:root-node @state) "options")))))
+                          (cond
+                            (and search-by-enter on-search (= 13 (.-keyCode e)))
+                            (on-search (.. e -target -value))
+                            :else (when-let [first-opt (cmn/f-child (:root-node @state) "option")]
+                              (.. first-opt -classList (add "active"))
+                              (swap! state assoc :selected first-opt
+                                     :suggestions-container
+                                     (cmn/f-child (:root-node @state) "options"))))))
         reset-input (fn [e]
                       (on-change nil)
                       (when search-fn
@@ -132,8 +135,7 @@
         label-fn (or label-fn identity)]

     (r/create-class
-     {
-      :component-did-mount
+     {:component-did-mount
       (fn [this]
         (let [root (r/dom-node this)]
           (swap! state assoc :root-node root)
@@ -174,5 +176,8 @@
              :on-change #(search-fn (.. % -target -value))}])
          (when (:active @state)
            [:div.options {:class (when-not search-fn :no-input)}
-            [options-list options label-fn (comp #(swap! state assoc :active false)
-                                                 on-change)]])])})))
+            (when search-by-enter [:div.no-results "Press enter for lookup"])
+            (if (= :loading options)
+              [:div.no-results "Loading..."]
+              [options-list options label-fn (comp #(swap! state assoc :active false)
+                                                   on-change)])])])})))


time/since, time/debounce

time/since, time/debounce

--- src/cljx/jamesmacaulay/zelkova/time.cljx
+++ src/cljx/jamesmacaulay/zelkova/time.cljx
@@ -88,3 +88,16 @@
             (impl/init sig)
             sig))

+#+cljs
+(defn since
+  [ms sig]
+  (let [start (z/map (constantly 1) sig)
+        stop (z/map (constantly -1) (delay ms sig))
+        delaydiff (z/foldp + 0 (z/merge start stop))]
+    (z/map (complement zero?) delaydiff)))
+
+#+cljs
+(defn debounce
+  [ms sig]
+  (let [timeouts (->> sig (since ms) (z/keep-if not false))]
+    (->> sig (z/sample-on timeouts))))


fix a indexing bug (wip)

fix a indexing bug (wip)

--- src/clojure/cljam/bam_indexer/writer.clj
+++ src/clojure/cljam/bam_indexer/writer.clj
@@ -1,6 +1,7 @@
 (ns cljam.bam-indexer.writer
   (:require [clojure.java.io :refer [file]]
             [clojure.tools.logging :as logging]
+            [clojure.pprint :refer [pprint]] ;; TODO for debug only
             [cljam.lsb :as lsb]
             [cljam.cigar :as cgr]
             [cljam.util :refer [gen-vec]]
@@ -227,6 +228,75 @@
                 (swap! lidx assoc win chunk-beg))
               (recur (inc win)))))))))

+(defn- make-index*
+  [ref alns]
+  ;; TODO
+  ;; meta data
+  (let [meta (:meta s)]
+    (if (zero? (:pos aln))
+      (swap! meta update-in [:no-coordinate-alns] inc)
+      (do (if-not (zero? (bit-and (:flag aln) 4))
+            (swap! meta update-in [:unaligned-alns] inc)
+            (swap! meta update-in [:aligned-alns] inc))
+          (if (or (< (bgzf-util/compare (:beg (:chunk (:meta aln)))
+                                        (:first-offset @meta)) 1)
+                  (= (:first-offset @meta) -1))
+            (swap! meta assoc :first-offset (:beg (:chunk (:meta aln)))))
+          (if (< (bgzf-util/compare (:last-offset @meta)
+                                    (:end (:chunk (:meta aln)))) 1)
+            (swap! meta assoc :last-offset (:end (:chunk (:meta aln))))))))
+  ;; bin, intv
+  (let [bins (:bins s)
+        bins-seen (:bins-seen s)
+        lidx (:lidx s)
+        largest-lidx-seen (:largest-lidx-seen s)
+        bin-num (sam-util/compute-bin aln)]
+    (when (nil? (nth @bins bin-num))
+      (swap! bins assoc bin-num {:bin-num bin-num, :chunks nil})
+      (swap! bins-seen inc))
+    (let [bin (nth @bins bin-num)
+          chunk-beg (:beg (:chunk (:meta aln)))
+          chunk-end (:end (:chunk (:meta aln)))]
+      ;; chunk
+      (if (seq (:chunks bin))
+        (if (bgzf-util/same-or-adjacent-blocks? (:end (last (:chunks bin)))
+                                                chunk-beg)
+          (let [last-idx (dec (count (:chunks bin)))
+                last-chunk (last (:chunks bin))
+                new-chunks (assoc (:chunks bin) last-idx (assoc last-chunk :end chunk-end))
+                new-bin (assoc bin :chunks new-chunks)]
+            (swap! bins assoc bin-num new-bin))
+          (let [new-bin (update-in bin [:chunks] conj (:chunk (:meta aln)))]
+            (swap! bins assoc bin-num new-bin)))
+        (let [new-bin (assoc bin :chunks (vector (:chunk (:meta aln))))]
+          (swap! bins assoc bin-num new-bin)))
+      ;; lenear index
+      (let [aln-beg (:pos aln)
+            aln-end (+ aln-beg (cgr/count-ref (:cigar aln)))
+            window-beg (if (zero? aln-end)
+                         (pos->lidx-offset (dec aln-beg))
+                         (pos->lidx-offset aln-beg))
+            window-end (if (zero? aln-end)
+                         window-beg
+                         (pos->lidx-offset aln-end))]
+        (if (> window-end @largest-lidx-seen)
+          (reset! largest-lidx-seen window-end))
+        (loop [win window-beg]
+          (when (<= win window-end)
+            (if (or (zero? (nth @lidx win))
+                    (< chunk-beg (nth @lidx win)))
+              (swap! lidx assoc win chunk-beg))
+            (recur (inc win)))))))
+  ;; TODO end
+  {:bins []
+   :intervals []
+   :length (:len ref)})
+
+(defn- make-index
+  [refs alns]
+  (zipmap (map #(:name %) refs)
+          (map #(make-index* % alns) refs)))
+
 ;;;
 ;;; public
 ;;;
@@ -246,6 +316,8 @@
       (lsb/write-bytes w (.getBytes bai-magic))
       ;; n_ref
       (lsb/write-int w (count (:refs s)))
+      ;; TODO this is new implementation
+      (pprint (make-index (:refs s) alns))
       (doseq [aln alns] (write-index* w s aln))
       ;; Write data about last ref
       (write-ref! w s)


Don't run shortcut if the cooresponding button is disabled

--- src/net/sekao/nightcode/shortcuts.clj
+++ src/net/sekao/nightcode/shortcuts.clj
@@ -120,9 +120,11 @@
 (defn ^:no-check run-shortcut! [^Scene scene actions ^String text shift?]
   (when-let [id (get reverse-mappings (if shift? (.toUpperCase text) text))]
     (when-let [action (get actions id)]
-      (Platform/runLater
-        (fn []
-          (action scene))))))
+      (let [fx-id (keyword->fx-id id)]
+        (when (-> scene (.lookup fx-id) .isDisabled not)
+          (Platform/runLater
+            (fn []
+              (action scene))))))))

 (fdef set-shortcut-listeners!
   :args (s/cat :stage spec/stage? :actions map?))


RS | #64 | Return correct project-status response

--- src/objective8/handlers/front_end.clj
+++ src/objective8/handlers/front_end.clj
@@ -53,7 +53,9 @@
     :session {}))

 (defn project-status [{:keys [t' locale] :as request}]
-  (views/project-status "project-status" request))
+  {:status 200
+   :header {"Content-Type" "text/html"}
+   :body (views/project-status "project-status" request)})

 (defn learn-more [request]
   {:status 200


s/:rule "complementizer-phrase"/:rule "complementizer-phrase-nonslash"/

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -248,10 +248,11 @@
    (unify-check h10
                 (let [semantics (atom :top)
                       comp-type (atom :top)]
-                  {:rule "complementizer-phrase"
+                  {:rule "complementizer-phrase-nonslash"
                    :synsem {:cat :comp
                             :comp-type comp-type
                             :sem semantics}
+                   :comp {:synsem {:slash false}}
                    :head {:synsem {:comp-type comp-type
                                    :sem semantics}}}))
    (unify-check c10


add :iobj (indirect object) to semantics of "be" (:pred :be-called)

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -189,9 +189,11 @@
                      :synsem {:agr subj-agr
                               :sem {:aspect :progressive
                                     :pred :be-called
+                                    :reflexive true
                                     :tense :present
                                     :subj the-real-subj
-                                    :obj the-obj}
+                                    :obj the-real-subj
+                                    :iobj the-obj}
                               :subcat {:1 {:cat :noun
                                            :case :nom ;; TODO: this should be a general lexical post-processing step -
                                            ;; call it subject-is-nominative or similar.
@@ -205,6 +207,7 @@
                                            :pronoun false
                                            :propernoun true ;; "John" in "My name is John"
                                            }
+                                       :3 '()
                                        } ;; subcat {
                               } ;; synsem {
                      } ;; end of map


add reflexive agreement lexical post-processing rule

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -1811,5 +1811,16 @@
                  ;; then the object is {:reflexive false}
                  (if-then {:synsem {:cat :verb
                                     :subcat {:2 {:reflexive false}}}}
-                          {:synsem {:subcat {:2 {:reflexive false}}}})))
-
+                          {:synsem {:subcat {:2 {:reflexive false}}}})
+
+                 ;; subject-and-reflexive-pronoun agreement
+                 (if-then {:synsem {:sem {:reflexive true}
+                                    :cat :verb
+                                    :subcat {:1 :top
+                                             :2 :top}}}
+
+                          (let [subject-agr (atom :top)]
+                            {:synsem {:subcat {:1 {:agr subject-agr}
+                                               :2 {:agr subject-agr}}}}))))
+
+


+city

+city

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -401,6 +401,10 @@
    "check" {:synsem {:cat :verb
                      :sem {:pred :check}}}

+   "city" {:synsem {:cat :noun
+                    :sem {:pred :city
+                          :city true}}}
+
    "close" {:synsem {:cat :verb
                      :sem {:pred :close}}}


music is singular always (cannot be plural)

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -1093,8 +1093,8 @@
    ;; TODO: should not need to provide an irregular plural form
    ;; [:sem :mass]=true should be sufficient.
    "music"
-   {:english {:plur "music"}
-    :synsem {:cat :noun
+   {:synsem {:agr {:number :sing}
+             :cat :noun
              :sem {:pred :music
                    :mass true}}}
    "my"


comment out 'frequentare' for now

comment out 'frequentare' for now

--- src/babel/italiano/lexicon.clj
+++ src/babel/italiano/lexicon.clj
@@ -981,8 +981,9 @@
       "fornire"  {:synsem {:cat :verb
                            :sem {:pred :furnish}}}

-      "frequentare"  {:synsem {:cat :verb
-                               :sem {:pred :frequentare}}}
+;; commenting out: no english equivalent
+;      "frequentare"  {:synsem {:cat :verb
+;                               :sem {:pred :frequentare}}}

       "funzionare" {:synsem {:cat :verb
                              :essere false