cleaned up javascript reloading, in prep for compiled foreign lib reloading

--- sidecar/src/figwheel_sidecar/build_middleware/javascript_reloading.clj
+++ sidecar/src/figwheel_sidecar/build_middleware/javascript_reloading.clj
@@ -2,7 +2,8 @@
   (:require
    [clojure.java.io :as io]
    [cljs.build.api :as bapi]
-   [cljs.closure]))
+   [figwheel-sidecar.utils :as utils]
+   [clojure.pprint :as pp]))

 ;; live javascript reloading

@@ -14,49 +15,46 @@
                           (.getCanonicalPath file)))
                      foreign-libs)))))

-(defn js-file->namespaces [{:keys [foreign-libs] :as state} js-file-path]
-  (if-let [foreign (get-foreign-lib state js-file-path)]
-    (:provides foreign)
-    (:provides (bapi/parse-js-ns js-file-path))))
-
+;; extremely tenuous relationship, this could break easily
+;; file-path is a string and it is an absolute path
 (defn cljs-target-file-from-foreign [output-dir file-path]
-  (io/file (str output-dir java.io.File/separator (.getName (io/file file-path)))))
+  (first (filter #(.exists %)
+                 ;; try the projected location
+                 [(io/file output-dir (utils/relativize-local file-path))
+                  (io/file output-dir (.getName (io/file file-path)))])))

 (defn closure-lib-target-file-for-ns [output-dir namesp]
   (let [path (cljs.closure/lib-rel-path {:provides [namesp]})]
     (io/file output-dir path)))

-(defn get-js-copies [{:keys [output-dir] :as state} changed-js]
-  (keep
-   (fn [f]
-     (if-let [foreign (get-foreign-lib state f)]
-       {:output-file (cljs-target-file-from-foreign output-dir f)
-        :file f}
-       (when-let [namesp (first (js-file->namespaces state f))]
-         {:output-file (closure-lib-target-file-for-ns output-dir namesp)
-          :file f})))
-   changed-js))
+(defn safe-js->ns [file-path]
+  (:provides
+   (try (bapi/parse-js-ns file-path)
+        (catch Throwable e
+          ;; couldn't parse js for namespace
+          {}))))

-(defn make-copies [copies]
-  (doseq [{:keys [file output-file]} copies]
-    (spit output-file (slurp file))))
+(defn best-try-js-ns [state js-file-path]
+  (let [provs (and (.exists (io/file js-file-path))
+                   (safe-js->ns js-file-path))]
+    (if-not (empty? provs)
+      provs
+      (let [out-file (cljs-target-file-from-foreign (:output-dir state) js-file-path)]
+        (and (.exists out-file)
+             (safe-js->ns out-file))))))

-(defn copy-changed-js [state changed-js]
-  ;; TODO there is an easy way to do this built into the clojurescript
-  ;; compiler source
-  ;; the idea here is we are only copying files that make sense to
-  ;; copy i.e. they have a provide
-  (when-not (empty? changed-js)
-    (make-copies (get-js-copies state changed-js))))
+(defn js-file->namespaces [{:keys [foreign-libs output-dir] :as state} js-file-path]
+  (if-let [foreign (get-foreign-lib state js-file-path)]
+    (best-try-js-ns state js-file-path)
+    (safe-js->ns js-file-path)))

 (defn hook [build-fn]
   (fn [{:keys [figwheel-server build-config changed-files] :as build-state}]
     (if-let [changed-js-files (filter #(.endsWith % ".js") changed-files)]
       (let [build-options (or (:build-options build-config) (:compiler build-config))
-            additional-changed-ns   ;; add in js namespaces
+            additional-changed-ns ;; add in js namespaces
             (mapcat (partial js-file->namespaces build-options)
                     changed-js-files)]
-        (copy-changed-js build-options changed-js-files)
         (build-fn (update-in
                    build-state [:additional-changed-ns] concat additional-changed-ns)))
       (build-fn build-state))))


Refactor to use single serving image route

--- src/silly_image_store/handler.clj
+++ src/silly_image_store/handler.clj
@@ -32,11 +32,7 @@
       (json-list-response image-names)
       (not-found bucket))))

-(defn- serve-image-route [{{image :image} :params}]
-  (let [image-file (store/load-image images-dir image)]
-    (or image-file (not-found image))))
-
-(defn- serve-image-from-bucket-route [{{bucket :bucket, image :image} :params}]
+(defn- serve-image-route [bucket image]
   (let [image-file (store/load-image images-dir bucket image)]
     (or image-file (not-found image))))

@@ -56,11 +52,11 @@

 (defroutes app-routes
   (GET "/images" request (list-images-route request ""))
-  (GET "/images/:image" request serve-image-route)
+  (GET "/images/:image" [image] (serve-image-route "" image))
   (GET "/random" request serve-random-image-route)
   (GET "/buckets" request list-buckets-route)
   (GET "/buckets/:bucket/images" [bucket :as request] (list-images-route request bucket))
-  (GET "/buckets/:bucket/images/:image" request serve-image-from-bucket-route)
+  (GET "/buckets/:bucket/images/:image" [bucket image] (serve-image-route bucket image))
   (GET "/buckets/:bucket/random" request serve-random-image-from-bucket-route)
   (route/resources "/")
   (route/not-found "Not Found"))


Additional tests and test TODOs

Additional tests and test TODOs

--- test/uruk/core_test.clj
+++ test/uruk/core_test.clj
@@ -2,7 +2,6 @@
   (:require [clojure.test :refer :all]
             [uruk.core :refer :all])
   (:import [java.util.logging Logger]
-           [java.util Locale]
            [com.marklogic.xcc RequestOptions]))

 ;; FIXME You'll have to fill in database credentials that work for
@@ -47,78 +46,31 @@
                                                  "\"Hello world\""))
                  .asString))))))

-;;;;
+;;;; Request options

 ;; TODO check that (request-options {:cache-result nil}) doesn't silently get ignored just because the answer might be false!
+
+;; (deftest default-request-options
+;;   (testing "A Request with no explicitly-set options must have default options"
+;;     (let [req-opts (request-options {})]
+;;       (describe-request-options req-opts))))

 (deftest sample-request-options
   (testing "Set sample option on request"
     (is (= 6000
            (.getTimeoutMillis (request-options {:timeout-millis 6000}))))))

-;; TODO more
-
-(deftest options-roundtrip
-  (testing "Round-trip options through creation and description"
-    (is (let [opts {:buffer-size 400
-                    :collections ["my-collection" "another-collection"]
-                    :encoding "ASCII"
-                    :format :text
-                    :graph "my-graph"
-                    :language "fr"
-                    :locale (Locale. "ru")
-                    :namespace "my-ns"
-                    :permissions [{"such-and-such-role" :insert}
-                                  {"such-and-such-role" :update}]
-                    ;; :placement-keys
-                    :quality 20
-                    :repair-level :full
-                    :resolve-buffer-size 20
-                    :resolve-entities true ;; TODO also test false, since we know boolean keys can be funny
-                    :temporal-collection "my-temp"}]
-          (= opts
-             (describe-content-creation-options (content-creation-options opts)))))))
-
-;;;;
-
-(deftest non-string-variables
-  (testing "Non-string variables passed to request object are not converted to strings"
-    (is (instance? com.marklogic.xcc.types.impl.DocumentImpl
-                   (-> (with-open [session (create-session db)]
-                         (.getVariables (#'uruk.core/request-obj (.newAdhocQuery session "hello world")
-                                                                 nil {:derp {:value "<foo/>"
-                                                                             :type :document}})))
-                       first
-                       .getValue)))))
-
-(deftest as-is-boolean-variable
-  (testing "Clojure booleans automatically convert to correct XdmVariable type"
-    (is (false? (with-open [session (create-session db)]
-                  (execute-xquery session "xquery version \"1.0-ml\";
-                                declare variable $my-variable as boolean-node() external;
-                                $my-variable"
-                                  {:variables {"my-variable" {:value false
-                                                              :type :boolean-node}}
-                                   :shape :single!}))))))
-
-;; TODO more
-
-;;;;
-
-(deftest accept-only-valid-options
+(deftest accept-only-valid-request-options
   (testing "Options that don't exist must raise an error"
     (is (thrown? java.lang.IllegalArgumentException
                  (with-open [sess (create-session db)]
                    (execute-xquery sess "\"hello world\"" {:options {:reuqest-time-limt 500}}))))))

-(deftest error-on-invalid-query
-  (testing "An error must be thrown if MarkLogic is passed an invalid query."
-    (is (thrown? com.marklogic.xcc.exceptions.XQueryException
-                 (with-open [sess (create-session db)]
-                   (execute-xquery sess "let $uri := xdmp:get-request-field(\"uri\")returnif"))))))

-;;;;

+;; TODO a full end-to-end test of all request options
+
+;;;; Session options
 (deftest default-session-options
   (testing "A session with no explicitly-set options must have default options"
     (let [sess-opts (session-options (create-session db))]
@@ -148,5 +100,74 @@
            (is (= 56 (:transaction-timeout sess-opts)))
            (is (= :query (:transaction-mode sess-opts)))))))

-;; TODO complete end-to-end test of all request options
-;; TODO complete end-to-end test of all content creation options
+;; TODO accept-only-valid-session-options
+
+
+;;;; Content creation options
+
+;; TODO content creation options default
+
+(deftest content-options-roundtrip
+  (testing "Round-trip options through creation and description"
+    (is (let [opts {:buffer-size 400
+                    :collections ["my-collection" "another-collection"]
+                    :encoding "ASCII"
+                    :format :text
+                    :graph "my-graph"
+                    :language "fr"
+                    ;; :locale
+                    :namespace "my-ns"
+                    :permissions [{"such-and-such-role" :insert}
+                                  {"such-and-such-role" :update}]
+                    ;; :placement-keys
+                    :quality 20
+                    :repair-level :full
+                    :resolve-buffer-size 20
+                    :resolve-entities true
+                    :temporal-collection "my-temp"}]
+          (= opts
+             (describe-content-creation-options (content-creation-options opts)))))))
+
+;; TODO accept-only-valid-content-options
+
+;;;; Variables
+
+(deftest non-string-variables
+  (testing "Non-string variables passed to request object are not converted to strings"
+    (is (instance? com.marklogic.xcc.types.impl.DocumentImpl
+                   (-> (with-open [session (create-session db)]
+                         (.getVariables (#'uruk.core/request-obj (.newAdhocQuery session "hello world")
+                                                                 nil {:derp {:value "<foo/>"
+                                                                             :type :document}})))
+                       first
+                       .getValue)))))
+
+(deftest as-is-boolean-variable
+  (testing "Clojure booleans automatically convert to correct XdmVariable type"
+    (is (false? (with-open [session (create-session db)]
+                  (execute-xquery session "xquery version \"1.0-ml\";
+                                declare variable $my-variable as boolean-node() external;
+                                $my-variable"
+                                  {:variables {"my-variable" {:value false
+                                                              :type :boolean-node}}
+                                   :shape :single!}))))))
+
+;; TODO more variable testing
+
+;;;; TODO Type conversion
+
+;;;; Invalid query
+
+(deftest error-on-invalid-query
+  (testing "An error must be thrown if MarkLogic is passed an invalid query."
+    (is (thrown? java.lang.Exception
+                 ;; FIXME I'd love to get the original error type
+                 ;; here, e.g. XqueryException
+                 (with-open [sess (create-session db)]
+                   (execute-xquery sess "let $uri := xdmp:get-request-field(\"uri\")returnif"))))))
+
+;;;; TODO Shape
+
+;;;; TODO Transactions
+
+;;;; TODO element insertion


add the project-builds-stopped event into the correct scope

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -578,11 +578,11 @@
                  (api-path/project-enable vcs-type project)
                  :stop-building-project
                  api-ch
-                 :context (select-keys args [:project-id :on-success]))
-    :events {:success #(analytics/track {:event-type :project-builds-stopped
-                                         :current-state current-state
-                                         :properties {:org org-name
-                                                      :repo repo-name}})}))
+                 :context (select-keys args [:project-id :on-success])
+                 :events {:success #(analytics/track {:event-type :project-builds-stopped
+                                                      :current-state current-state
+                                                      :properties {:org org-name
+                                                                   :repo repo-name}})})))

 ;; XXX: clean this up
 (defmethod post-control-event! :container-parent-scroll


fix text closing out when you open radial menu

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -471,22 +471,27 @@
   [browser-state message [x y {:keys [button ctrl?]}] previous-state current-state]
   (let [cast! (fn [msg & [payload]]
                 (put! (get-in current-state [:comms :controls]) [msg payload]))]
+    ;; If you click while writing text, you probably wanted to place it there
+    ;; You also want the right-click menu to open
+    (when (and (= (get-in current-state state/current-tool-path) :text)
+               (get-in current-state [:drawing :in-progress?]))
+      (cast! :text-layer-finished [x y]))
     (cond
-     (= button 2) (cast! :menu-opened)
-     (and (= button 0) ctrl?) (cast! :menu-opened)
-     ;; turning off Cmd+click for opening the menu
-     ;; (get-in current-state [:keyboard :meta?]) (cast! :menu-opened)
-     (get-in current-state [:layer-properties-menu :opened?]) (cast! :layer-properties-submitted)
-     (= (get-in current-state state/current-tool-path) :pen) (cast! :drawing-started [x y])
-     (= (get-in current-state state/current-tool-path) :text) (if (get-in current-state [:drawing :in-progress?])
-                                                                ;; if you click while writing text, you probably wanted to place it there
-                                                                (cast! :text-layer-finished [x y])
-                                                                (cast! :drawing-started [x y]))
-     (= (get-in current-state state/current-tool-path) :rect) (cast! :drawing-started [x y])
-     (= (get-in current-state state/current-tool-path) :circle) (cast! :drawing-started [x y])
-     (= (get-in current-state state/current-tool-path) :line)  (cast! :drawing-started [x y])
-     (= (get-in current-state state/current-tool-path) :select)  (cast! :drawing-started [x y])
-     :else                                             nil)))
+      (= button 2) (cast! :menu-opened)
+      (and (= button 0) ctrl?) (cast! :menu-opened)
+      ;; turning off Cmd+click for opening the menu
+      ;; (get-in current-state [:keyboard :meta?]) (cast! :menu-opened)
+      (get-in current-state [:layer-properties-menu :opened?]) (cast! :layer-properties-submitted)
+      (= (get-in current-state state/current-tool-path) :pen) (cast! :drawing-started [x y])
+      (= (get-in current-state state/current-tool-path) :text) (if (get-in current-state [:drawing :in-progress?])
+
+                                                                 (cast! :text-layer-finished [x y])
+                                                                 (cast! :drawing-started [x y]))
+      (= (get-in current-state state/current-tool-path) :rect) (cast! :drawing-started [x y])
+      (= (get-in current-state state/current-tool-path) :circle) (cast! :drawing-started [x y])
+      (= (get-in current-state state/current-tool-path) :line)  (cast! :drawing-started [x y])
+      (= (get-in current-state state/current-tool-path) :select)  (cast! :drawing-started [x y])
+      :else                                             nil)))

 (defn detectable-movement?
   "Checks to make sure we moved the layer from its starting position"


do less work when we look for eids in bounding box

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -313,8 +313,6 @@
   (-> state
       (assoc-in [:drawing :layers 0 :layer/text] value)))

-(defn selectable? [db e]
-  (not= :layer.type/group (:layer/type (d/entity db e))))

 (defn eids-in-bounding-box [db {:keys [start-x end-x start-y end-y] :as box}]
   (let [x0 (min start-x end-x)
@@ -325,11 +323,10 @@
         has-x1 (set (map :e (d/index-range db :layer/end-x x0 x1)))
         has-y0 (set (map :e (d/index-range db :layer/start-y y0 y1)))
         has-y1 (set (map :e (d/index-range db :layer/end-y y0 y1)))]
-    (set (filter (partial selectable? db)
-                 (set/union (set/intersection has-x0 has-y0)
-                            (set/intersection has-x0 has-y1)
-                            (set/intersection has-x1 has-y0)
-                            (set/intersection has-x1 has-y1))))))
+    (set/union (set/intersection has-x0 has-y0)
+               (set/intersection has-x0 has-y1)
+               (set/intersection has-x1 has-y0)
+               (set/intersection has-x1 has-y1))))

 (defn draw-in-progress-drawing [state x y {:keys [force-even?]}]
   (let [[rx ry] (cameras/screen->point (:camera state) x y)


Explicitly call `System/exit` after tests are run to ensure JVM exit

--- src/main/resources/clojuresque/tasks/test.clj
+++ src/main/resources/clojuresque/tasks/test.clj
@@ -42,12 +42,18 @@

 (deftask main
   [{:keys [junit tests] :as options}]
-  (try
-    (cond
-      junit       (test-junit/test-namespaces options)
-      (seq tests) (test-vars options)
-      :else       (test-namespaces options))
-  ;; Some stray non-daemon threads may cause the JVM to hang on exit.
-  ;; Call this after all tests have run to allow proper shutdown.
-  (finally
-    (shutdown-agents))))
+  (let [exit-code (atom 0)]
+    (try
+      (cond
+        junit (test-junit/test-namespaces options)
+        (seq tests) (test-vars options)
+        :else (test-namespaces options))
+      (catch Throwable _t
+        (reset! exit-code -1))
+      ;; Some stray non-daemon threads may cause the JVM to hang on exit.
+      ;; Call this after all tests have run to allow proper shutdown.
+      (finally
+        (shutdown-agents)
+        (.awaitTermination (clojure.lang.Agent/soloExecutor) 0 java.util.concurrent.TimeUnit/MILLISECONDS)
+        (.awaitTermination (clojure.lang.Agent/pooledExecutor) 0 java.util.concurrent.TimeUnit/MILLISECONDS)
+        (System/exit @exit-code)))))


Adds all clients to the query

Adds all clients to the query

Adds all clients to the query

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -656,7 +656,7 @@
                 realtime " "
                 ))
   (println "************************************************************************************")
-
+  (println "     data-session-id: " data-session-id)

@@ -682,8 +682,8 @@
        nil
        (do
          (update-query-in-cache  query-key)
-         (add-client-to-query  query-key  data-session-id)
          ))
+     (add-client-to-query  query-key  data-session-id)

      (do-real   :table-name db-table)


Moved generic fn to right place

Moved generic fn to right place

Moved generic fn to right place

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -465,91 +465,7 @@
 )

-(defn !get-query-results-v2 [{:keys [
-                                     db-table
-                          		       where
-                                     start
-                                     end
-                                     params
-                                     order
-                                     realtime
-                                     data-session-id
-                          		   ]}]
-
-  (println "************************************************************************************")
-  (println "!get-query-results-v2*   REALTIME = " realtime)
-  (println (str "!get-query-results-v2: "
-                db-table
-                where " "
-                start  " "
-                end " "
-                params " "
-                order " "
-                data-session-id " "
-                realtime " "
-                ))
-  (println "************************************************************************************")
-
-  (cond
-       realtime
-
-       (let [
-             query-key   (create-query-key
-                            :db-table  db-table
-                            :where     where
-                            :start     start
-                            :end       end
-                            :params    params
-                            :order     order)
-             ]
-
-           (if (get @cached-queries  query-key)
-               nil
-               (update-query-in-cache  query-key)
-
-           )
-
-          (do-real   :table-name db-table)
-
-          (println "-------------------------------")
-          (println "@cached-queries     " @cached-queries)
-          (println query-key)
-          (println (get @cached-queries  query-key))
-          (println "-------------------------------")
-
-           (get @cached-queries  query-key)
-      )
-
-
-
-      :else
-
-      (do
-          (let [
-                 record-count      (get-count   db-table  where   params)
-
-
-
-        results
-
-       (get-results   :db-table db-table
-                      :where    where
-                      :order    order
-                      :start    start
-                      :end      end
-                      :params   params
-        )
-
-		result-id-vector
-		(into [] (map :id results))
-		]
-
-    ;(println result-id-vector)
-    {
-     :records      result-id-vector
-      :count       record-count
-     }
-    ))))
+

@@ -678,6 +594,117 @@

+
+
+
+
+
+(defn !get-query-results-v2 [{:keys [
+                                     db-table
+                          		       where
+                                     start
+                                     end
+                                     params
+                                     order
+                                     realtime
+                                     data-session-id
+                          		   ]}]
+
+  (println "************************************************************************************")
+  (println "!get-query-results-v2*   REALTIME = " realtime)
+  (println (str "!get-query-results-v2: "
+                db-table
+                where " "
+                start  " "
+                end " "
+                params " "
+                order " "
+                data-session-id " "
+                realtime " "
+                ))
+  (println "************************************************************************************")
+
+  (cond
+       realtime
+
+       (let [
+             query-key   (create-query-key
+                            :db-table  db-table
+                            :where     where
+                            :start     start
+                            :end       end
+                            :params    params
+                            :order     order)
+             ]
+
+           (if (get @cached-queries  query-key)
+               nil
+               (update-query-in-cache  query-key)
+
+           )
+
+          (do-real   :table-name db-table)
+
+          (println "-------------------------------")
+          (println "@cached-queries     " @cached-queries)
+          (println query-key)
+          (println (get @cached-queries  query-key))
+          (println "-------------------------------")
+
+           (get @cached-queries  query-key)
+      )
+
+
+
+      :else
+
+      (do
+          (let [
+                 record-count      (get-count   db-table  where   params)
+
+
+
+        results
+
+       (get-results   :db-table db-table
+                      :where    where
+                      :order    order
+                      :start    start
+                      :end      end
+                      :params   params
+        )
+
+		result-id-vector
+		(into [] (map :id results))
+		]
+
+    ;(println result-id-vector)
+    {
+     :records      result-id-vector
+      :count       record-count
+     }
+    ))))
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 ; ----------------------------------------------------------------
 ; Whenever a database record changes it get processed here on the
 ; server


JS cannot support unicode

JS cannot support unicode

--- src/wireframes/shapes/platonic_solids.clj
+++ src/wireframes/shapes/platonic_solids.clj
@@ -2,17 +2,17 @@
   (:require [wireframes.shapes.primitives :as p]
             [wireframes.transform :as t]))

-(def √2 (Math/sqrt 2))
-(def √5 (Math/sqrt 5))
+(def sqrt-2 (Math/sqrt 2))
+(def sqrt-5 (Math/sqrt 5))

-(def φ (/ (inc √5) 2))
-(def -φ (- φ))
+(def rho (/ (inc sqrt-5) 2))
+(def -rho (- rho))

 (def tetrahedron
-  {:points [(t/point  1  0 (/ -1 √2))
-            (t/point -1  0 (/ -1 √2))
-            (t/point  0  1 (/  1 √2))
-            (t/point  0 -1 (/  1 √2))]
+  {:points [(t/point  1  0 (/ -1 sqrt-2))
+            (t/point -1  0 (/ -1 sqrt-2))
+            (t/point  0  1 (/  1 sqrt-2))
+            (t/point  0 -1 (/  1 sqrt-2))]
    :polygons [[0 1 2] [0 2 3] [0 1 3] [1 2 3]]})

@@ -35,10 +35,11 @@
   "A 20-sided polyhedron"
   (let [points (vec
                  (apply concat
-                   (for [one [-1 1] rho [φ -φ]]
-                     [(t/point 0 one rho)
-                      (t/point one rho 0)
-                      (t/point rho 0 one)])))
+                   (for [x [-1 1]
+                         y [rho -rho]]
+                     [(t/point 0 x y)
+                      (t/point x y 0)
+                      (t/point y 0 x)])))
         polygons (vec
                 (for [a (range (count points))
                       b (range a)


fix typos

fix typos

--- src/vip/data_processor/errors.clj
+++ src/vip/data_processor/errors.clj
@@ -15,9 +15,9 @@

   NOTE: if you call this function when processing a v5 feed, then keep
   in mind that, *unless your identifier is `:global` or
-  `:post-process-street-segments`*, then at the time the validation
-  (error is stored in the database, it will attempt to look up a path
-  for the identifier value. A bad or nonexistent identifier can break
+  `:post-process-street-segments`*, at the time the validation error
+  is stored in the database, it will attempt to look up a path for the
+  identifier value. A bad or nonexistent identifier can break
   statistic generation so this is important to be aware of."
   [{:keys [errors-chan] :as ctx}
    severity scope identifier error-type


Add TODO re: eval of ns arg resolvers

Add TODO re: eval of ns arg resolvers

--- spec/fred.clj
+++ spec/fred.clj
@@ -1,4 +1,7 @@
 (ns fred
+  ;; TODO: pattern dispatcher doesn't eval at all, make it eval or
+  ;; update the comment below
+  ;;
   ;; Used a non-standard prefix for rook, to demonstrate that the eval occurs
   ;; in the fred namespace, not somewhere where there's a rook alias already.
   {:arg-resolvers [(io.aviso.rook/build-map-arg-resolver {:partner :barney})]}


adding more validations

adding more validations

--- src/docker/validations.clj
+++ src/docker/validations.clj
@@ -30,14 +30,23 @@

 (def machine-common
   {:machine
-    {:cpus #{:required :Integer}
+    {:cpus #{:required :Integer} :hostname #{:required :String}
      :memory #{:required :Integer}}})

 (defn validate-entity [spec]
   (validate! spec (combine machine-common)))

+;; (validation :quota* (every-kv {:limit #{:required :Integer}}))
+
+(def start-v
+ {:port-bindings #{:required :Map} :binds #{:required :Map}})
+
+(def create-v
+ {:image #{:required :String} :cpu-shares #{:required :Integer}
+  :memory #{:required :Integer} :exposed-ports #{:Map} :volumes #{:Map}})
+
 (defn validate-provider [start-spec create-spec]
-   true
-  )
+  (validate! start-spec start-v)
+  (validate! create-spec create-v))


Sieve of Sundaram

Sieve of Sundaram

--- src/clojureplayground/prime_numbers_fun.clj
+++ src/clojureplayground/prime_numbers_fun.clj
@@ -18,7 +18,7 @@

 (defn sieve-of-sundaram [n]
   (let [top (inc n)]
-    (map #(inc (* 2 %))
+    (map (comp inc (partial * 2))
          (sort
            (cs/difference (set (range 1 top))
                           (set (for [i (range 1 top) j (range i top)


Revise docstring on VALUES binding behaviour

--- src/grafter/rdf/sparql.clj
+++ src/grafter/rdf/sparql.clj
@@ -131,10 +131,22 @@
   Which should be maps binding identifiable limits/offsets from your
   query to new values.

-  VALUES clause bindings are supported. Nil values for keys in the VALUES
-  bindings map are not allowed. However, it's possible to explicitly set
-  a value of ::undef that will be translated to a value of UNDEF in the
-  bound SPARQL VALUES clause.
+  VALUES clause bindings are supported like normal ?var bindings when
+  there is just one VALUES binding.  When there are more than one, you
+  should provide a vector containing the component var names as the
+  key in the map, with a sequence of sequences as the values
+  themselves.  e.g. to override a clause like this:
+
+  VALUES ?a ?b { (1 2) (3 4) }
+
+  You would provide a map that looked like this:
+
+  {[:a :b] [[1 1] [2 2] [3 3]]}
+
+  nil's inside the VALUES row's themselves will raise an error.
+
+  The clojure keyword :grafter.rdf.sparql/undef can be used to
+  represent a SPARQL UNDEF, in the bound VALUES data.

   The final argument `repo` should be the repository to query.


Revert "Make card border thinner"

Revert "Make card border thinner"

This reverts commit 260bc6e929c18ffd2c8a316ec7573f4a85b903cb.

--- src/braid/core/client/ui/styles/thread.cljs
+++ src/braid/core/client/ui/styles/thread.cljs
@@ -160,7 +160,7 @@
      :overflow "hidden"}

     [:>.border
-     (mixins/card-border "3px")]
+     (mixins/card-border "4px")]

     (drag-and-drop pad)
     (head pad)


add compile time

add compile time

--- src/bzzz/queries/term_payload_clj_score.clj
+++ src/bzzz/queries/term_payload_clj_score.clj
@@ -1,5 +1,6 @@
 (ns bzzz.queries.term-payload-clj-score
   (use bzzz.util)
+  (:require [bzzz.index-stat :as index-stat])
   (:import (org.apache.lucene.index Term)
            (org.apache.lucene.search MatchAllDocsQuery)
            (com.googlecode.concurrentlinkedhashmap ConcurrentLinkedHashMap ConcurrentLinkedHashMap$Builder)
@@ -24,10 +25,14 @@
     (.build b)))

 (defn get-or-eval [expr]
-  (if-let [v (.get expr-cache expr)]
+  (if-let [v (.get ^java.util.Map expr-cache expr)]
     v
-    (let [evaluated-expr (eval (read-string expr))]
-      (.put expr-cache expr evaluated-expr)
+    (let [t0 (time-ms)
+          evaluated-expr (eval (read-string expr))]
+      (index-stat/update-took-count index-stat/total
+                                    "eval"
+                                    (time-took t0))
+      (.put ^java.util.Map expr-cache expr evaluated-expr)
       evaluated-expr)))

 (defn parse


Fix planner lint

Fix planner lint

--- src/com/wsscode/pathom/connect/planner.cljc
+++ src/com/wsscode/pathom/connect/planner.cljc
@@ -913,7 +913,7 @@
         (not= sym source-sym)
         (assoc ::source-sym source-sym)))))

-(defn include-node [graph env {::keys [node-id] :as node}]
+(defn include-node [graph _env {::keys [node-id] :as node}]
   (let [sym (pc-sym node)]
     (-> graph
         (assoc-in [::nodes node-id] node)
@@ -1055,19 +1055,18 @@
                 (dissoc pc-attr)
                 (update ::run-next-trail p.misc/sconj (::root graph))
                 (update ::attr-deps-trail p.misc/sconj (pc-attr env))
-                (assoc ast-node (eql/query->ast (vec missing)))))]
-
-      (let [still-missing (remove (or index-attrs {}) missing)
-            all-provided? (not (seq still-missing))]
-        (if all-provided?
-          (let [ancestor (find-missing-ancestor graph' missing)]
-            (assert ancestor "Error finding ancestor during missing chain computation")
-            (cond-> (merge-nodes-run-next graph' env ancestor {::run-next (::root graph)})
-              (::run-and (get-root-node graph'))
-              (merge-node-requires (::root graph') {::requires (zipmap missing (repeat {}))})))
-          (let [{::keys [unreachable-syms] :as out'} (mark-node-unreachable graph-before-missing-chain graph graph' env)
-                unreachable-attrs (filter #(set/subset? (all-attribute-resolvers env %) unreachable-syms) still-missing)]
-            (update out' ::unreachable-attrs into unreachable-attrs)))))
+                (assoc ast-node (eql/query->ast (vec missing)))))
+          still-missing (remove (or index-attrs {}) missing)
+          all-provided? (not (seq still-missing))]
+      (if all-provided?
+        (let [ancestor (find-missing-ancestor graph' missing)]
+          (assert ancestor "Error finding ancestor during missing chain computation")
+          (cond-> (merge-nodes-run-next graph' env ancestor {::run-next (::root graph)})
+            (::run-and (get-root-node graph'))
+            (merge-node-requires (::root graph') {::requires (zipmap missing (repeat {}))})))
+        (let [{::keys [unreachable-syms] :as out'} (mark-node-unreachable graph-before-missing-chain graph graph' env)
+              unreachable-attrs (filter #(set/subset? (all-attribute-resolvers env %) unreachable-syms) still-missing)]
+          (update out' ::unreachable-attrs into unreachable-attrs))))
     graph))

 (defn runner-node-sym


change executor-id of job fn

change executor-id of job fn

--- src/riak_mesos/scheduler.clj
+++ src/riak_mesos/scheduler.clj
@@ -20,7 +20,7 @@
                         (when-let [[executor-id slave-id] (first @active-executors)]
                           (future
                             (Thread/sleep 30000)
-                            (let [command ["riak-admin" "join" "-f" (get executor-id->hostname executor-id)]]
+                            (let [command ["riak-admin" "join" "-f" (get executor-id->hostname (:executor-id status))]]
                               (println "sending command" command)
                               (clj-mesos.scheduler/send-framework-message driver executor-id slave-id (.getBytes (pr-str command))))))
                         (when (= :task-running (:state status))


fix linux/osx pricing tabs on org-settings page

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -567,22 +567,29 @@
   (reify
     om/IRender
     (render[_]
-      (html [:div {:data-component `pricing-tabs}
-             [:ul.nav.nav-tabs
-              [:li {:class (when (= selected-tab :linux) "active")}
-               [:a {:href (routes/v1-org-settings-path {:org (:org_name plan) :_fragment "linux-pricing"})}
-                [:i.fa.fa-linux.fa-lg] "Build on Linux"]]
-              [:li {:class (when (= selected-tab :osx) "active")}
-               [:a {:href (routes/v1-org-settings-path {:org (:org_name plan) :_fragment "osx-pricing"})}
-                [:i.fa.fa-apple.fa-lg] "Build on OS X"]]]
-             (condp = selected-tab
-               :linux [:div.card
-                       (om/build linux-plan {:app app :checkout-loaded? checkout-loaded?})
-                       (om/build faq linux-faq-items)]
-
-               :osx [:div.card
-                     (om/build osx-plans-list plan)
-                     (om/build faq osx-faq-items)])]))))
+      (let [{{org-name :name
+              vcs-type :vcs_type} :org} plan]
+        (html
+         [:div {:data-component `pricing-tabs}
+          [:ul.nav.nav-tabs
+           [:li {:class (when (= selected-tab :linux) "active")}
+            [:a {:href (routes/v1-org-settings-path {:org org-name
+                                                     :vcs_type vcs-type
+                                                     :_fragment "linux-pricing"})}
+             [:i.fa.fa-linux.fa-lg] "Build on Linux"]]
+           [:li {:class (when (= selected-tab :osx) "active")}
+            [:a {:href (routes/v1-org-settings-path {:org org-name
+                                                     :vcs_type vcs-type
+                                                     :_fragment "osx-pricing"})}
+             [:i.fa.fa-apple.fa-lg] "Build on OS X"]]]
+          (condp = selected-tab
+            :linux [:div.card
+                    (om/build linux-plan {:app app :checkout-loaded? checkout-loaded?})
+                    (om/build faq linux-faq-items)]
+
+            :osx [:div.card
+                  (om/build osx-plans-list plan)
+                  (om/build faq osx-faq-items)])])))))

 (defn pricing-starting-tab [subpage]
   (get {:osx-pricing :osx


AW & NE | 118 | Added logging for okta sign in journey

--- src/objective8/front_end/workflows/okta.clj
+++ src/objective8/front_end/workflows/okta.clj
@@ -3,7 +3,8 @@
             [ring.util.response :as response]
             [objective8.front-end.api.http :as http]
             [bidi.ring :refer [make-handler]]
-            [cheshire.core :as json]))
+            [cheshire.core :as json]
+            [clojure.tools.logging :as log]))

 (def redirect-uri (str utils/host-url "/okta-callback"))

@@ -31,18 +32,19 @@
          (> expiry-time (utils/unix-current-time))
          (= issuer-url auth-url))))

-(defn check-token-info [request access-token]
-  (let [auth-url (get-in request [:okta-config :auth-url])
+(defn check-token-info [{:keys [okta-config session] :as request} access-token]
+  (let [auth-url (:auth-url okta-config)
         user-info (get-user-info access-token auth-url)
         user-info-body (response->json user-info)
         user-id (:sub user-info-body)
-        updated-session (assoc (:session request) :auth-provider-user-id (str "okta-" user-id)
-                                                  :auth-provider-user-email (:email user-info-body))]
+        updated-session (assoc session :auth-provider-user-id (str "okta-" user-id)
+                                       :auth-provider-user-email (:email user-info-body))]

     (if (user-info-valid? user-info user-info-body auth-url)
       (into (response/redirect (str utils/host-url "/sign-up"))
             {:session updated-session})
-      (response/redirect (str utils/host-url "/error/log-in")))))
+      (do (log/error (str "OKTA user info error with status code: " (:status user-info) " as " (get-in user-info [:headers "WWW-Authenticate"])))
+          (response/redirect (str utils/host-url "/error/log-in"))))))

 (defn get-access-token [{:keys [params okta-config] :as request}]
   (let [code (:code params)
@@ -54,17 +56,20 @@
                                                                                :redirect_uri  redirect-uri
                                                                                :client_secret client-secret
                                                                                :code          code}})]
-    (response->json response)))
+    response))

 (defn check-access-token [request]
-  (let [access-token-response (get-access-token request)]
-    (if (:error access-token-response)
-      (response/redirect (str utils/host-url "/error/log-in"))
-      (check-token-info request (:access_token access-token-response)))))
+  (let [access-token-response (get-access-token request)
+        access-token-body (response->json access-token-response)]
+    (if (:error access-token-body)
+      (do (log/error (str "OKTA access token error with status code: " (:status access-token-response) " as " (:error access-token-body)))
+          (response/redirect (str utils/host-url "/error/log-in")))
+      (check-token-info request (:access_token access-token-body)))))

 (defn okta-callback [{:keys [params] :as request}]
   (if (:error params)
-    (response/redirect (str utils/host-url "/error/log-in"))
+    (do (log/error (str "OKTA callback error: " (:error params) ", " (:error_description params)))
+        (response/redirect (str utils/host-url "/error/log-in")))
     (check-access-token request)))

 (defn wrap-handler [handler okta-config]


Fixed issue with licenses directory causing jar task to barf

--- src/leiningen/amp/impl.clj
+++ src/leiningen/amp/impl.clj
@@ -31,33 +31,35 @@
           (.closeEntry zip-stream-out)))))
   nil)

+(defn- mkdir-p
+  [directory]
+  (io/make-parents (io/file directory ".")))   ; make-parents won't create the last path element of the file

 (defn package-amp!
   [project args]
-  (let [project-home       (io/file (:root project))
-        web-resources      (io/file project-home "web-resources")
-        module-properties  (io/file project-home "amp-resources/module.properties")
-        file-mappings      (io/file project-home "amp-resources/file-mapping.properties")
-        config             (io/file project-home "config")
-        licenses           (io/file project-home "licenses")
-        target             (io/file (:target-path project))
-        uberjar-file       (io/file (uj/uberjar project))
-        amp                (io/file target "amp/.")
-        amp-lib            (io/file target "amp/lib/.")
-        amp-config         (io/file target "amp/config/.")
-        amp-licenses       (io/file target "amp/licenses/.")
-        amp-web            (io/file target "amp/web/.")
-        amp-file           (io/file target
-                                    (or (get-in project [:amp-name])
-                                        (str (:name project) "-" (:version project) ".amp")))]
+  (let [project-home      (io/file (:root project))
+        web-resources     (io/file project-home "web-resources")
+        module-properties (io/file project-home "amp-resources/module.properties")
+        file-mappings     (io/file project-home "amp-resources/file-mapping.properties")
+        config            (io/file project-home "amp-config")
+        licenses          (io/file project-home "amp-licenses")
+        target            (io/file (:target-path project))
+        uberjar-file      (io/file (uj/uberjar project))
+        amp               (io/file target "amp")
+        amp-lib           (io/file target "amp/lib")
+        amp-config        (io/file target "amp/config")
+        amp-licenses      (io/file target "amp/licenses")
+        amp-web           (io/file target "amp/web")
+        amp-file          (io/file target
+                                   (or (get-in project [:amp-name])
+                                       (str (:name project) "-" (:version project) ".amp")))]
     ; Make some directories
-    (io/make-parents amp)
-    (io/make-parents amp-lib)
+    (mkdir-p amp)
+    (mkdir-p amp-lib)

     ; Copy module.properties, blowing up if it doesn't exist
     (if (.exists ^java.io.File module-properties)
       (io/copy module-properties (io/file amp (.getName ^java.io.File module-properties)))
-      ;(println "################### ROT ROH!!!"))
       (throw (RuntimeException. "Project isn't valid - it doesn't have a module.properties file.")))   ;####TODO: Make this more pleasant

     ; Copy file-mapping.properties
@@ -72,17 +74,19 @@
     (if (.exists ^java.io.File web-resources)
       (do
         (fs/copy-dir web-resources amp)
-        (.renameTo ^java.io.File (io/file target "amp/web-resources") amp-web)))
+        (.renameTo (io/file target "amp/web-resources") amp-web)))

     ; Copy all "config" files
     (if (.exists ^java.io.File config)
       (do
-        (fs/copy-dir config amp)))
+        (fs/copy-dir config amp)
+        (.renameTo (io/file target "amp/amp-config") amp-config)))

     ; Copy all licenses
     (if (.exists ^java.io.File licenses)
       (do
-        (fs/copy-dir licenses amp)))
+        (fs/copy-dir licenses amp)
+        (.renameTo (io/file target "amp/amp-licenses") amp-licenses)))

     ; Zip everything up into an AMP
     (zip-directory! amp-file amp)


Marg bug in def form (string as last elem without docstring) is no longer and issue.

--- src/leiningen/git_deps.clj
+++ src/leiningen/git_deps.clj
@@ -5,14 +5,9 @@
             [clojure.java.io :as io]
             [clojure.string :as string]))

-;; Why, you might ask, are we using str here instead of simply def'ing
-;; the var to a string directly? The answer is that we are working
-;; around a bug in marginalia where it can't tell the difference
-;; between the string that's the value for a def and a docstring. It
-;; will hopefully be fixed RSN, because this makes us feel dirty.
 (def ^{:private true
        :doc "The directory into which dependencies will be cloned."}
-  git-deps-dir (str ".lein-git-deps"))
+  git-deps-dir ".lein-git-deps")

 (defn- directory-exists?
   "Return true if the specified directory exists."


defscreen Om Next: Update example integration into Om Next to sections

--- src/main/workflo/macros/screen/om_next.cljs
+++ src/main/workflo/macros/screen/om_next.cljs
@@ -47,16 +47,15 @@
   [_ {:keys [screen]} _ _]
   {:value (:forms screen)})

-(defn read-layout
-  "Executes all queries for views in the layout of the
+(defn read-sections
+  "Executes all queries for views in the sections of the
    active screen."
   [_ {:keys [parser query screen] :as env} _ _]
   {:value
-   (reduce (fn [res layout-item]
-             (let [[section query] (first layout-item)]
+   (reduce (fn [res section-item]
+             (let [[section query] (first section-item)]
                (assoc res section
-                      {:view  (-> screen :layout section
-                                  resolve-view :factory)
+                      {:view  (-> screen :sections section resolve-view :factory)
                        :props (parser (dissoc env :path) query nil)})))
            {} query)})

@@ -64,12 +63,12 @@
   "Wraps a user-provided parser read function for Om Next by
    special-casing queries for screen-based routing information
    (such as :workflo/screen, :workflo/forms and
-   :workflo/layout.)"
+   :workflo/sections.)"
   [read env key params]
   (case key
-    :workflo/screen (read-screen read env key params)
-    :workflo/forms  (read-forms read env key params)
-    :workflo/layout (read-layout read env key params)
+    :workflo/screen   (read-screen read env key params)
+    :workflo/forms    (read-forms read env key params)
+    :workflo/sections (read-sections read env key params)
     (read env key params)))

 (defn parser
@@ -98,15 +97,14 @@

 ;;;; Wrapping application

-(defn- realize-layout
-  "Realizes the results of a layout query by instantiating
+(defn- realize-sections
+  "Realizes the results of a sections query by instantiating
    all returned views with their props / query results."
-  [layout]
-  (zipmap (keys layout)
+  [sections]
+  (zipmap (keys sections)
           (map (fn [{:keys [view props] :as item}]
-                 (view (vary-meta props assoc :om-path
-                                  (-> item meta :om-path))))
-               (vals layout))))
+                 (view (vary-meta props assoc :om-path (-> item meta :om-path))))
+               (vals sections))))

 (defn camel-cased-prop-map
   "Convert a Clojure map with Om Next properties to a map
@@ -120,34 +118,33 @@
         m))

 (defview RootWrapper
-  (query [{workflo/screen [workflo [forms layout]]}])
+  (query [{workflo/screen [workflo [forms sections]]}])
   (render
    (let [forms      (:workflo/forms screen)
-         layout     (realize-layout (:workflo/layout screen))
+         sections   (realize-sections (:workflo/sections screen))
          root-info  (root-component)]
      ((:factory root-info)
       (if (:js? root-info)
         (do
-          (clj->js (merge {:layout (camel-cased-prop-map layout)}
+          (clj->js (merge {:sections (camel-cased-prop-map sections)}
                           (camel-cased-prop-map forms))))
-        (merge {:layout layout} forms))))))
+        (merge {:sections sections} forms))))))

 ;;;; Routing

 (defn mount-screen
   "Mounts a screen with parameters by setting it as the active
    screen and updating the root wrapper's component query
-   according to the screen's layout."
+   according to the screen's sections."
   [app screen params]
   (let [c     (om/app-root (:reconciler (:config app)))
         query [{:workflo/screen
                 [:workflo/forms
-                 {:workflo/layout
+                 {:workflo/sections
                   (mapv (fn [[section view-name]]
-                          {section (or (some-> view-name resolve-view
-                                               :view om/get-query)
+                          {section (or (some-> view-name resolve-view :view om/get-query)
                                        [])})
-                        (:layout screen))}]}]]
+                        (:sections screen))}]}]]
     (set-active-screen! screen params)
     (some-> app :config :screen-mounted
             (apply [app screen params]))
@@ -192,14 +189,14 @@
    or not the root component is a JS component.

    The root component is expected to accept the properties
-   defined for screens, so `:layout` and arbitrary other forms.
-   `:layout` is a map of layout keys to instantiated components.
+   defined for screens, so `:sections` and arbitrary other forms.
+   `:sections` is a map of section keys to instantiated components.
    The root component can then decide which of these components
-   to render where based on these layout keys.
+   to render where based on these section keys.

    During rendering, the provided root component is wrapped
    in an application component that handles the screen routing
-   logic and generates the `:layout` and other form props
+   logic and generates the `:sections` and other form props
    based on the active screen."
   [{:keys [default-screen reconciler root
            root-js? target screen-mounted]


Fixing broken build

Fixing broken build

--- test/ctia/test_helpers/generators/schemas.clj
+++ test/ctia/test_helpers/generators/schemas.clj
@@ -4,7 +4,6 @@
             [ctia.properties :refer [properties]]
             [ctim.schemas
              [common :refer [Observable]]
-             [identity :refer [Identity]]
              [verdict :refer [Verdict]]]
             [ctia.test-helpers.generators.common :refer [generate-entity]]
             [ctia.test-helpers.generators.schemas
@@ -57,7 +56,6 @@
    :new-exploit-target eg/gen-new-exploit-target
    :new-feedback   fg/gen-new-feedback
    :feedback       fg/gen-feedback
-   :identity       (generate-entity Identity)
    :incident       ig/gen-incident
    :new-incident   ig/gen-new-incident
    :indicator      ng/gen-indicator


sample problem added, a couple pointers

sample problem added, a couple pointers

--- test/lein_fore_prob/test/core.clj
+++ test/lein_fore_prob/test/core.clj
@@ -73,9 +73,21 @@
   (testing "quotes"
     (is (= (#'fp/enquote "\"foo\"") "\\\"foo\\\""))))

+(def sample-prob1
+  {:title "Foo Bar"
+   :description "write a foo bar"
+   :difficulty "Medium"
+   :restricted []
+   :times-solved 42
+   :scores {}
+   :user "foo"
+   :tags ["bar"]
+   :tests ["(= (__ 42) 21)" "(= (__ 21) 42)"]})
+
 (deftest expand-prob) ; TODO

 ;; TODO we need to use sample and/or temporary files for these ones
+;; http://my.safaribooksonline.com/book/programming/clojure/9781449366384/4dot-local-io/_using_temporary_files_html

 (deftest drop-replace-me)
 (deftest add-stub)
@@ -83,9 +95,11 @@
 (deftest write-tests)

 ;; TODO we need to mock clj-http for this one
+;; https://github.com/myfreeweb/clj-http-fake

 (deftest get-prob)

 ;; TODO we need both requirements for this one
+;; or use with-redefs

 (deftest fore-prob)


Merging?

Merging?

--- test/tensorflow_clj/core_test.clj
+++ test/tensorflow_clj/core_test.clj
@@ -82,10 +82,13 @@

 (deftest linreg-graph
   (testing "Linear regression"
-    (with-graph-file "misc/linreg.pb"
-      (let [[v] (run-graph {:x [1. 2. 3. 4.]
-                            :y [0. -1. -2. -3.]
-                            :W [-1.]
-                            :b [1.]}
-                  :loss)]
-        (is (= v 0.0))))))
+    (let [x-train [1. 2. 3. 4.]
+          y-train [0. -1. -2. -3.]]
+      (with-graph-file "misc/linreg.pb"
+        (let [[v] (run-graph {:x x-train :y y-train :W [-1.] :b [1.]}
+                    :loss)]
+          (is (= v 0.0))))
+      (with-graph-file "misc/linreg.pb"
+        (dotimes [i 1000]
+          (run-graph {:x x-train :y y-train :train nil :W [-1.] :b [1.]}
+            :loss))))))


Fix failing test - entry-id was causing an issue

--- system-int-test/test/cmr/system_int_test/bootstrap/bulk_index_test.clj
+++ system-int-test/test/cmr/system_int_test/bootstrap/bulk_index_test.clj
@@ -44,7 +44,7 @@
                                       :metadata xml3
                                       :extra-fields {:short-name "coll3"
                                                      :entry-title "coll3"
-                                                     :entry-id "coll1"
+                                                     :entry-id "coll3"
                                                      :version-id "v1"
                                                      :delete-time "2000-01-01T12:00:00Z"}
                                       :provider-id "PROV1"
@@ -61,6 +61,11 @@
                                       :extra-fields {:parent-collection-id (:concept-id umm1)}})]
       (ingest/tombstone-concept coll2-tombstone)

+      ;; Verify that all of the ingest requests completed successfully
+      (doseq [concept [coll1 coll3 gran1]] (is (= 201 (:status concept))))
+      ;; tombstone should return 200
+      (is (= 200 (:status coll2)))
+
       (bootstrap/bulk-index-provider "PROV1")
       (index/wait-until-indexed)

@@ -70,7 +75,7 @@
                     (d/refs-match? expected (search/find-refs concept-type search))
                     {:concept-id (:concept-id coll1)} :collection [umm1]
                     {:concept-id (:concept-id coll2)} :collection []
-                    {:concept-id (:concept-id umm1)} :granule [])))))
+                    {:concept-id (:concept-id ummg1)} :granule [])))))

 ;; This test verifies that the bulk indexer can run concurrently with ingest and indexing of items.
 ;; This test performs the following steps:


Fix crash when passcode disabled

Fix crash when passcode disabled

Signed-off-by: Volodymyr Kozieiev <f2778d839d9f3ad586693b057b494a6ec3a7ca24@gmail.com>

--- src/status_im/multiaccounts/login/core.cljs
+++ src/status_im/multiaccounts/login/core.cljs
@@ -224,7 +224,7 @@
                  :on-success #(re-frame/dispatch [::get-settings-callback %])}]}
               (when save-password?
                 (keychain/save-user-password key-uid password))
-              (keychain/save-auth-method key-uid (or new-auth-method auth-method)))))
+              (keychain/save-auth-method key-uid (or new-auth-method auth-method keychain/auth-method-none)))))

 (fx/defn create-only-events
   [{:keys [db] :as cofx}]


added an api function to get the new user-plans endpoint

--- src-cljs/frontend/api.cljs
+++ src-cljs/frontend/api.cljs
@@ -21,6 +21,11 @@
 (defn get-orgs [api-ch & [{:keys [include-user?]}]]
   (ajax/ajax :get (str "/api/v1/user/organizations" (when include-user? "?include-user=true"))
              :organizations
+             api-ch))
+
+(defn get-user-plans [api-ch]
+  (ajax/ajax :get "/api/v1/user/organizations/plans"
+             :user-plans
              api-ch))

 (defn get-usage-queue [build api-ch]


get the converted template changes I need


CMR-3488: Adding comment to test.

CMR-3488: Adding comment to test.

--- system-int-test/test/cmr/system_int_test/search/paging_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/paging_search_test.clj
@@ -64,6 +64,7 @@
       (search/find-refs :granule {:page-size 500 :page-num 22})))
   (testing "Within page depth"
     (are3 [resp]
+      ;; This means the query was successful.
       (is (= 0 (:hits resp)))

       "Collection query with page_size and page_num"


Attempt at making a generic range slider om component; WIP.

--- frontend/components/shared.cljs
+++ frontend/components/shared.cljs
@@ -2,6 +2,7 @@
   (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer close!]]
             [dommy.attrs :as attrs]
             [frontend.async :refer [raise!]]
+            [frontend.state :as state]
             [frontend.stefon :refer (data-uri)]
             [frontend.utils.ajax :as ajax]
             [frontend.utils :as utils :include-macros true]
@@ -215,3 +216,52 @@
         [:div.light-background
          (om/build contact-form app)
          [:span "Or, check out our " [:a {:target "_blank", :href "https://www.hipchat.com/gjwkHcrD5"} "live support!"]]]]))))
+
+;; Since we can't reliably make an html5 range element look like we
+;; want, fake it with divs for the bar, the knob and a highlight div
+;;
+;; Work in progress. Remaining issues:
+;; * still hardcoded state/selected-containers-path to update state
+;;   value
+;; * the mouse event handlers are only on the slider div itself, so
+;;   it doesn't behave right if you mousedown in it, start dragging,
+;;   drag out of it, and release. dragging? is still set, and when you
+;;   mouse back over, it starts moving it again.
+;; * doesn't display min and max; good? bad? some other way?
+(defn styled-range-slider [data owner]
+  (reify
+    om/IInitState (init-state [_] {:dragging? false :node-ref (str "pricing-range-" (Math.random))})
+    om/IRenderState
+    (render-state [_ {:keys [dragging? node-ref]}]
+      (let [min-val (get-in data [:min-val])
+            max-val (get-in data [:max-val])
+            value (or (get-in data state/selected-containers-path)
+                      (get-in data [:start-value]))
+            increment (/ 100.0 max-val)
+            calculate-drag-fraction (fn [owner event]
+                                      (let [slider (om/get-node owner node-ref)
+                                            width (.-width (goog.style/getSize slider))
+                                            slider-left (goog.style/getPageOffsetLeft slider)
+                                            event-left (.-pageX event)]
+                                        (min 1.0 (max 0.0 (/ (- event-left slider-left) width)))))
+            calculate-value (fn [owner event]
+                              (let [drag-fraction (calculate-drag-fraction owner event)]
+                                (Math.round (+ min-val (* drag-fraction (- max-val min-val))))))]
+        (html
+         [:div.range-slider {:on-click      #(utils/edit-input owner state/selected-containers-path %
+                                                               :value (calculate-value owner %))
+                             :on-mouse-down #(do (om/set-state! owner :dragging? true)
+                                                 (utils/edit-input owner state/selected-containers-path %
+                                                                   :value (calculate-value owner %)))
+                             :on-mouse-up   #(om/set-state! owner :dragging? false)
+                             :on-mouse-move #(when dragging?
+                                               (utils/edit-input owner state/selected-containers-path %
+                                                                 :value (calculate-value owner %)))
+                             :ref node-ref}
+          ;[:span min-val]
+          [:figure.range-back]
+          [:figure.range-highlight {:style {:width (str (* value increment) "%")}}]
+          [:button.range-knob {:style {:left (str (* value increment) "%")}
+                               :data-count value}]
+          ;[:span max-val]
+          ])))))


fix lines

fix lines

--- frontend/components/shared.cljs
+++ frontend/components/shared.cljs
@@ -99,14 +99,8 @@
                                 :title "Sign up with GitHub"}
    [:i.fa.fa-github-alt]
    (if button_copy
-     [:span
-      " Begin "
-      [:strong.white "Free Trial"]
-      ]
-     [:span
-      " Sign up with "
-      [:strong.white "GitHub"]
-      ]
+     [:span " Begin " [:strong.white "Free Trial"]]
+     [:span " Sign up with " [:strong.white "GitHub"]]
      )])


removed duplicate call

removed duplicate call

--- src-cljs/libre/sketch.cljs
+++ src-cljs/libre/sketch.cljs
@@ -20,7 +20,6 @@

     (-add-sketch-handler processing sketch :mouse-clicked "mouseClicked")
     (-add-sketch-handler processing sketch :mouse-dragged "mouseDragged")
-    (-add-sketch-handler processing sketch :mouse-moved "mouseMoved")
     (-add-sketch-handler processing sketch :mouse-moved "mouseMoved")
     (-add-sketch-handler processing sketch :mouse-out "mouseOut")
     (-add-sketch-handler processing sketch :mouse-over "mouseOver")


wish-from-elem cljs

wish-from-elem cljs

--- src/wishlistd/cljs/main.cljs
+++ src/wishlistd/cljs/main.cljs
@@ -53,6 +53,11 @@
 (defn title-from-html []
   (val (find $header ".title")))

+(defn wish-from-elem [$elem]
+  {:id (data $elem :id)
+   :description (val (find $elem ".description"))
+   :url (val (find $elem ".url"))
+   :wishlist_code (get-path)})

 (defn value-changed?! [$this]
   (if (= (data $this :old-val) (val $this))


Fixing test for changing state, and actually adding it to git, finally

--- web-client/test/test_burgerboard/huh.cljs
+++ web-client/test/test_burgerboard/huh.cljs
@@ -31,15 +31,17 @@
     )
   )

-(defn rendered-component [component value]
-  (let [state (om/setup
-               (if (satisfies? IAtom value)
-                 value
-                 (atom value))
-               (gensym) nil)]
-    (binding [om/*state* state]
-      (.render (om/build* component (om/to-cursor @state state [])))
-      )
+(defn setup-state [value]
+  (om/setup
+   (if (satisfies? IAtom value)
+     value
+     (atom value))
+   (gensym) nil)
+  )
+
+(defn rendered-component [component state]
+  (binding [om/*state* state]
+    (.render (om/build* component (om/to-cursor @state state [])))
     )
   )

@@ -56,10 +58,12 @@
   (reduce get-child component accessors)
   )

-(defn rendered [component state & tests]
-  (binding [om/*instrument* -instrument]
-    (let [rendered-comp (rendered-component component state)]
-      (test-predicates tests rendered-comp {:in "rendered component"})
+(defn rendered [component value & tests]
+  (let [state (setup-state value)]
+    (binding [om/*instrument* -instrument]
+      (let [rendered-comp (rendered-component component state)]
+        (test-predicates tests rendered-comp {:in "rendered component"})
+        )
       )
     )
   )


Use delay to delay all realization of data

So we can build this on a system that has no datasources defined

--- src/mdr2/abacus/import.clj
+++ src/mdr2/abacus/import.clj
@@ -33,13 +33,14 @@

 ;; production id to library signature mapping
 (def production-id-to-library-signature-map
-  (reduce (fn [m {:keys [production_id library_signature]}]
-            (let [k (production-id? production_id)
-                  v (library-signature? library_signature)]
-              (if (and k v) (assoc m k v) m)))
-          {}
-          (jdbc/query archive-db
-                      "SELECT m.value AS production_id, m2.value AS library_signature FROM meta m, meta m2 WHERE m.id_container = m2.id_container AND m.element='idMaster' AND m2.element='idAusleihe'")))
+  (delay
+   (reduce (fn [m {:keys [production_id library_signature]}]
+             (let [k (production-id? production_id)
+                   v (library-signature? library_signature)]
+               (if (and k v) (assoc m k v) m)))
+           {}
+           (jdbc/query archive-db
+                       "SELECT m.value AS production_id, m2.value AS library_signature FROM meta m, meta m2 WHERE m.id_container = m2.id_container AND m.element='idMaster' AND m2.element='idAusleihe'"))))

 (defn fix-date [s]
   (when (not (string/blank? s))
@@ -60,7 +61,7 @@
         (update-in [:depth] parse-int)
         (assoc :periodical_number
                (when-not (string/blank? periodical_number) periodical_number))
-        (assoc :library_signature (get production-id-to-library-signature-map id))
+        (assoc :library_signature (get @production-id-to-library-signature-map id))
         (dissoc :Produktestatus))))

 (defn productions
@@ -93,8 +94,8 @@
 (defn smil-file? [f] (re-matches #".*\.smil$" f))
 (defn ncc-file? [f] (re-matches #".*ncc\.html$" f))

-(def all-productions (-> abacus-csv io/file productions))
-(def all-files-by-id (-> file-dump io/file files-by-id))
+(def all-productions (delay (-> abacus-csv io/file productions)))
+(def all-files-by-id (delay (-> file-dump io/file files-by-id)))

 (defn to-millis
   "Convert a string `s` of the form \"31:28:47\" to milliseconds"
@@ -128,32 +129,33 @@
         (assoc :language language)
         (assoc :volumes volumes)
         (assoc :total_time total_time)
-        (assoc :library_signature (get production-id-to-library-signature-map (:id m)))
+        (assoc :library_signature (get @production-id-to-library-signature-map (:id m)))
         (select-keys [:id :creator :date :depth :language :library_number :library_signature
                         :narrator :state :produced_date :production_type
                         :revision_date :source :source_date :source_publisher
                         :subject :title :total_time :volumes]))))

 (def all-commercial-productions
-  (let [statement (string/join
-                   "\n"
-                   ["SELECT d.tm, d.identifier AS id, d.title, d.process_status, m.element, m.value"
-                    "FROM madras.document d, madras.meta m"
-                    "WHERE d.id IN (SELECT id_document FROM madras.meta WHERE element='idVorstufe' AND value regexp '^PNX [2-9][0-9][0-9][0-9]')"
-                    "AND d.id = m.id_document"])]
-    (->> (jdbc/query old-db statement)
-         (map normalize-commercial-production)
-         (group-by :id)
-         (map (fn [[k v]] [k (apply merge v)]))
-         (map second)
-         (map cleanup-commercial-production)
-         (map prod/parse)
-         (map #(merge (prod/default-meta-data) %)))))
+  (delay
+   (let [statement (string/join
+                    "\n"
+                    ["SELECT d.tm, d.identifier AS id, d.title, d.process_status, m.element, m.value"
+                     "FROM madras.document d, madras.meta m"
+                     "WHERE d.id IN (SELECT id_document FROM madras.meta WHERE element='idVorstufe' AND value regexp '^PNX [2-9][0-9][0-9][0-9]')"
+                     "AND d.id = m.id_document"])]
+     (->> (jdbc/query old-db statement)
+          (map normalize-commercial-production)
+          (group-by :id)
+          (map (fn [[k v]] [k (apply merge v)]))
+          (map second)
+          (map cleanup-commercial-production)
+          (map prod/parse)
+          (map #(merge (prod/default-meta-data) %))))))

 (defn get-all-files
   "Get all files for a `production`"
   [{id :id}]
-  (get all-files-by-id id))
+  (get @all-files-by-id id))

 (defn ready? [production] (= (:state production) "ready"))
 (defn archived? [production] (= (:state production) "archived"))
@@ -296,81 +298,81 @@
   (println)
   (println "## Importing from ABACUS")
   (println)
-  (println "### Ready:" (count (filter ready? all-productions)))
-  (println)
-  (println (string/join ", " (sort (map :id (filter ready? all-productions)))))
-  (println)
-  (println "### Archived:" (count (filter archived? all-productions)))
-  (println)
-  (println "### Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) all-productions)))
-  (println)
-  (println (string/join ", " (sort (map :id (filter #(recording-no-wav-with-struct? %) all-productions)))))
-  (println)
-  (println "### Recording with wav and an obi project:" (count (filter recording-with-obi? all-productions)))
-  (println)
-  (println (string/join ", " (sort (map :id (filter recording-with-obi? all-productions)))))
+  (println "### Ready:" (count (filter ready? @all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter ready? @all-productions)))))
+  (println)
+  (println "### Archived:" (count (filter archived? @all-productions)))
+  (println)
+  (println "### Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) @all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter #(recording-no-wav-with-struct? %) @all-productions)))))
+  (println)
+  (println "### Recording with wav and an obi project:" (count (filter recording-with-obi? @all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter recording-with-obi? @all-productions)))))
   (println)
   (println "## Manual migration:")
   (println)
-  (println "### Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? all-productions)))
-  (println)
-  (println (string/join ", " (sort (map :id (filter recording-with-wav-no-obi? all-productions)))))
-  (println)
-  (let [weird (filter #(and (not-any? struct-file? (get-all-files %)) (recording-no-wav? %)) all-productions)]
+  (println "### Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? @all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter recording-with-wav-no-obi? @all-productions)))))
+  (println)
+  (let [weird (filter #(and (not-any? struct-file? (get-all-files %)) (recording-no-wav? %)) @all-productions)]
     (println "### Recording with no wav and no struct.html:" (count weird))
     (println)
     (println (string/join ", " (sort (map :id weird)))))
   (println)
   (print "### The rest: ")
-  (let [freqs (-> (map :state all-productions)
+  (let [freqs (-> (map :state @all-productions)
                   frequencies
                   (dissoc "archived" "recording" "ready"))]
     (println freqs)
     (println)
     (doseq [state (keys freqs)]
-      (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) all-productions))))))
+      (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) @all-productions))))))
     (println ))
   (println "# Importing commercial audio books")
   (println)
-  (println "## Ready:" (count (filter ready? all-commercial-productions)))
-  (println)
-  (let [ready (sort (map :id (filter ready? all-commercial-productions)))]
+  (println "## Ready:" (count (filter ready? @all-commercial-productions)))
+  (println)
+  (let [ready (sort (map :id (filter ready? @all-commercial-productions)))]
     (when (seq ready)
       (println (string/join ", " ready))
       (println)))
-  (println "## Archived:" (count (filter archived? all-commercial-productions)))
-  (println)
-  (let [ps (filter #(recording-no-wav-with-struct? %) all-commercial-productions)]
+  (println "## Archived:" (count (filter archived? @all-commercial-productions)))
+  (println)
+  (let [ps (filter #(recording-no-wav-with-struct? %) @all-commercial-productions)]
     (println "## Recording with no wav and a struct.html:" (count ps))
     (println)
     (when (seq ps)
       (println (string/join ", " (sort (map :id ps))))
       (println)))
-  (let [ps (filter #(and (recording-no-wav? %)) all-commercial-productions)]
+  (let [ps (filter #(and (recording-no-wav? %)) @all-commercial-productions)]
     (println "## Recording with no wav:" (count ps))
     (println)
     (when (seq ps)
       (println (string/join ", " (sort (map :id ps))))
       (println)))
-  (let [ps (filter recording-with-obi? all-commercial-productions)]
+  (let [ps (filter recording-with-obi? @all-commercial-productions)]
     (println "## Recording with wav and an obi project:" (count ps))
     (println)
     (when (seq ps)
       (println (string/join ", " (sort (map :id ps))))
       (println)))
-  (let [ps (filter recording-with-wav-no-obi? all-commercial-productions)]
+  (let [ps (filter recording-with-wav-no-obi? @all-commercial-productions)]
     (println "## Recording with wav and no obi project:" (count ps))
     (println)
     (when (seq ps)
       (println (string/join ", " (sort (map :id ps))))
       (println)))
   (print "## Ignoring the rest: ")
-  (let [freqs (-> (map :state all-commercial-productions)
+  (let [freqs (-> (map :state @all-commercial-productions)
                   frequencies
                   (dissoc "archived" "recording" "ready"))]
     (println freqs)
     (println)
     (doseq [state (keys freqs)]
-      (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) all-commercial-productions))))))
+      (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) @all-commercial-productions))))))
     (println ))
 )


:hankey: Comment some code that needs to be refactored (undo related).

--- frontend/src/uxbox/main/data/undo.cljs
+++ frontend/src/uxbox/main/data/undo.cljs
@@ -21,7 +21,8 @@
 (deftype WatchPageChanges [id]
   ptk/WatchEvent
   (watch [_ state stream]
-    (let [stopper (->> stream
+    nil
+    #_(let [stopper (->> stream
                        (rx/filter #(= % ::udp/stop-page-watcher))
                        (rx/take 1))]
       (->> stream
@@ -41,7 +42,8 @@
 (defrecord SaveUndoEntry [id]
   ptk/UpdateEvent
   (update [_ state]
-    (let [page (udp/pack-page state id)
+    state
+    #_(let [page (udp/pack-page state id)
           undo {:data (:data page)
                 :metadata (:metadata page)}]
       (-> state
@@ -88,7 +90,7 @@
   udp/IPageUpdate
   ptk/UpdateEvent
   (update [_ state]
-    (let [page-id (get-in state [:workspace :page])
+    #_(let [page-id (get-in state [:workspace :page])
           undo-state (get-in state [:undo page-id])
           stack (:stack undo-state)
           selected (:selected undo-state 0)]
@@ -123,7 +125,7 @@
   udp/IPageUpdate
   ptk/UpdateEvent
   (update [_ state]
-    (let [page-id (get-in state [:workspace :page])
+    #_(let [page-id (get-in state [:workspace :page])
           undo-state (get-in state [:undo page-id])
           stack (:stack undo-state)
           selected (:selected undo-state)]


Reduce clojurescript optimisation levels for production builds

--- web-app/project.clj
+++ web-app/project.clj
@@ -11,13 +11,13 @@
                  [http-kit "2.1.8"]
                  [weasel "0.7.0"]
                  [com.cemerick/piggieback "0.2.1"]
-                 [org.clojure/clojurescript "1.7.170" :scope "provided"]
-                 [org.omcljs/om             "0.8.8"]    ; ClojureScript interface to Facebook's React
-                 [cljs-http                 "0.1.30"]   ; A ClojureScript HTTP library
-                 [cljs-hash                 "0.0.2"]    ; SHA1 and MD5 wrapper library
+                 [org.clojure/clojurescript "1.7.189" :exclusions [org.apache.ant/ant]]
+                 [org.omcljs/om             "0.8.8"] ; ClojureScript interface to Facebook's React
+                 [cljs-http                 "0.1.30"] ; A ClojureScript HTTP library
+                 [cljs-hash                 "0.0.2"] ; SHA1 and MD5 wrapper library
                  [cljsjs/moment             "2.9.0-0"]] ; Moment.js

-  :plugins      [[lein-cljsbuild            "1.1.1"]    ; Leiningen plugin to make ClojureScript development easy
+  :plugins      [[lein-cljsbuild            "1.1.2"] ; Leiningen plugin to make ClojureScript development easy
                  [lein-figwheel             "0.5.0-1"]
                  [cider/cider-nrepl         "0.11.0-SNAPSHOT"]]

@@ -67,10 +67,12 @@
                 :source-paths ["src/cljs" "env/prod/cljs"]
                 :compiler {:main          potato.main
                            :output-to     "resources/public/js/potato.js"
-                           :optimizations :advanced
+                           :optimizations :simple
                            :externs       ["externs-input.js"]
-                           :elide-asserts true
-                           :pretty-print  false}}
+                           :elide-asserts false
+                           :pseudo-names true
+                           :print-input-delimiter true
+                           :pretty-print  true}}

                {:id "admin-dev"
                 :source-paths ["admin/cljs" "env/admin-dev/cljs"]


fix worker launching bug with space in topology names

--- src/clj/backtype/storm/daemon/supervisor.clj
+++ src/clj/backtype/storm/daemon/supervisor.clj
@@ -378,8 +378,8 @@
                        " -Dlogfile.name=" logfilename
                        " -Dstorm.home=" (System/getProperty "storm.home")
                        " -Dlog4j.configuration=storm.log.properties"
-                       " -cp " classpath " backtype.storm.daemon.worker "
-                       storm-id " " supervisor-id " " port " " worker-id)]
+                       " -cp " classpath " backtype.storm.daemon.worker \""
+                       storm-id "\" " supervisor-id " " port " " worker-id)]
       (log-message "Launching worker with command: " command)
       (launch-process command :environment {"LD_LIBRARY_PATH" (conf JAVA-LIBRARY-PATH)})
       ))


Temporarily increase hour between jobs.

Temporarily increase hour between jobs.

--- src/clj/clj_templates/config/main_config.clj
+++ src/clj/clj_templates/config/main_config.clj
@@ -9,7 +9,7 @@
    :db/postgres         {:jdbc-url          (env :db-url)
                          :driver-class-name "org.postgresql.Driver"}
    :logger/timbre       {:appenders {:println {:stream :auto}}}
-   :jobs/scheduled-jobs {:hours-between-jobs 1
+   :jobs/scheduled-jobs {:hours-between-jobs 10
                          :db                 (ig/ref :db/postgres)
                          :es-client          (ig/ref :search/elastic)}
    :search/elastic      {:hosts           [(env :bonsai-url)]


Remove let

Remove let

--- src/clj/collect_earth_online/db/projects.clj
+++ src/clj/collect_earth_online/db/projects.clj
@@ -767,26 +767,25 @@
 (defn- get-value-distribution
   "Count the answers given, and return a map of {'question:answers' count}"
   [survey-questions samples]
-  (let [inverse-samples (/ (count samples))]
-    (->> samples
-         ;; Flatten answers from multiple samples into a single sequence.
-         (mapcat (fn [sample]
-                   (map (fn [[question-id {:keys [answerId answer]}]]
-                          {:question-id question-id
-                           :answer-id answerId
-                           :answer-text answer})
-                        (:saved_answers sample))))
-         (group-by (juxt :question-id :answer-id))
-         ;; Count number of answers in each group, or join free text answers.
-         (u/mapm (fn [[[question-id answer-id] answer-group]]
-                   (let [{:keys [question answers componentType]} (get survey-questions question-id)]
-                     [(str question ":" (get-in answers [(str answer-id) :answer]))
-                      (if (= "input" componentType)
-                        (->> answer-group
-                             (map :answer-text)
-                             (distinct)
-                             (str/join ";"))
-                        (format "%.2f" (* 100.0 (count answer-group) inverse-samples)))]))))))
+  (->> samples
+       ;; Flatten answers from multiple samples into a single sequence.
+       (mapcat (fn [sample]
+                 (map (fn [[question-id {:keys [answerId answer]}]]
+                        {:question-id question-id
+                         :answer-id answerId
+                         :answer-text answer})
+                      (:saved_answers sample))))
+       (group-by (juxt :question-id :answer-id))
+       ;; Count number of answers in each group, or join free text answers.
+       (u/mapm (fn [[[question-id answer-id] answer-group]]
+                 (let [{:keys [question answers componentType]} (get survey-questions question-id)]
+                   [(str question ":" (get-in answers [(str answer-id) :answer]))
+                    (if (= "input" componentType)
+                      (->> answer-group
+                           (map :answer-text)
+                           (distinct)
+                           (str/join ";"))
+                      (format "%.2f" (* 100.0 (count answer-group) (/ (count samples)))))])))))

 (def plot-base-headers [:plotid
                         :center_lon


tz covnerter rules

tz covnerter rules

--- src/cljs/re_form/inputs/date_input_impl.cljs
+++ src/cljs/re_form/inputs/date_input_impl.cljs
@@ -81,10 +81,9 @@
                  :groups [:y :m :d]}})

 (defn to-utc [timezone local-datetime]
-  (let [converted (.. js/moment (tz local-datetime timezone) utc format)]
-    (subs converted 0 19)))
-
-(defn from-utc [timezone utc-datetime]
+  (.. js/moment (tz local-datetime timezone) utc format))
+
+(defn to-local [timezone utc-datetime]
   (let [converted (.. js/moment (tz utc-datetime "utc") (tz timezone) format)]
     (subs converted 0 19)))

@@ -339,8 +338,8 @@
         fmt-date (or (:format-date opts) "iso")
         fmt-date-obj (get formats fmt-date)
         timezone (:timezone opts)
-        to-utc-fn (if timezone (partial to-utc timezone) identity)
-        from-utc-fn (if timezone (partial from-utc timezone) identity)
+        to-utc-fn (partial to-utc (or timezone "utc"))
+        to-local-fn (if timezone (partial to-local timezone) identity)
         plc-time {"24h" "hh:mm" "12h" "hh:mm AM|PM"}
         placeholder (str (:placeholder fmt-date-obj) " " (get plc-time fmt-time))
         state (r/atom {:lastValue (:value opts) :value
@@ -365,7 +364,7 @@
      {:component-will-receive-props
       (fn [_ nextprops]
         (when-let [{utc-v :value} (second nextprops)]
-          (let [v (from-utc-fn utc-v)]
+          (let [v (to-local-fn utc-v)]
             (when-not (= v (:lastValue @state))
               (swap! state assoc
                      :value (date-time-unparse fmt-date fmt-time v)


Never allow more than one service per user per root

--- src/clojure/staircase/resources/services.clj
+++ src/clojure/staircase/resources/services.clj
@@ -60,8 +60,11 @@

   (create [_ doc]
     (let [id (new-id)
-          service (-> (dissoc doc :id "id") (assoc "id" id "owner" (:user staircase.resources/context)))]
-      (sql/insert! (:connection db) :services service)
+          owner (:user staircase.resources/context)
+          service (-> (dissoc doc :id "id") (assoc "id" id "owner" owner))]
+      (sql/with-db-transaction [trs (:connection db)]
+        (sql/delete! trs :services ["root=? and owner=?" (:root service) owner]) ;; Preserve invariant.
+        (sql/insert! trs :services service))
       id))

   Searchable


No need for complicated overlay; swap works.

--- src/afterglow/controllers/ableton_push_2.clj
+++ src/afterglow/controllers/ableton_push_2.clj
@@ -1346,26 +1346,14 @@
   [controller]
   (when-let [remaining (seq (update-cue-grid-chunk controller (cue-grid-updates controller)))]
     (let [updates (atom remaining)]
-      (controllers/add-overlay (:overlays controller)
-                               (reify controllers/IOverlay
-                                 (captured-controls [this] #{})
-                                 (captured-notes [this] #{})
-                                 (adjust-interface [this _]
-                                   (when (seq @updates)
-                                     (reset! grid-batch-update-fn nil)
-                                     (reset! updates nil)
-                                     (timbre/warn "Reached next Push 2 frame while still updating cue grid!")))
-                                 (handle-control-change [this _])
-                                 (handle-note-on [this _])
-                                 (handle-note-off [this _])
-                                 (handle-aftertouch [this _])
-                                 (handle-pitch-bend [this _])))
-      (reset! grid-batch-update-fn
-              (fn []
-                (swap! updates #(update-cue-grid-chunk controller %))
-                (if (seq @updates)
-                  (send-sysex controller [0x09])  ; Response will trigger next chunk
-                  (reset! grid-batch-update-fn nil)))))  ; We are done
+      (swap! grid-batch-update-fn
+             (fn [existing-fn]
+               (when (some? existing-fn) (timbre/warn "Reached next Push 2 frame while still updating cue grid!"))
+               (fn []
+                 (swap! updates #(update-cue-grid-chunk controller %))
+                 (if (seq @updates)
+                   (send-sysex controller [0x09])  ; Response will trigger next chunk
+                   (reset! grid-batch-update-fn nil))))))  ; We are done
     (send-sysex controller [0x09])))

 (defn- ^:deprecated update-cue-grid-unbatched


Slightly simplify Aldous-Broder implementation.

Also removed a TODO, having decided it's a WONTFIX instead.

--- src/cljc/mazes/algorithms/aldous_broder.cljc
+++ src/cljc/mazes/algorithms/aldous_broder.cljc
@@ -12,11 +12,9 @@
           next-cell (g/move grid cell direction)]
       (if (contains? unvisited (g/coordinates next-cell))
         ; link from current cell to next, and move in the random direction
+        ; NOTE: we need an updated next-cell, since the grid changes
         (let [grid (g/link grid cell direction)
-              next-cell (g/find-cell grid [(::g/x next-cell) (::g/y next-cell)])]
-              ;; TODO: since grid is updated, we need the updated version of
-              ;; next-cell as well. Come up with a better solution for this
-              ;; kind of situation, since it will keep coming up.
+              next-cell (g/find-cell grid (g/coordinates next-cell))]
           (recur grid next-cell (disj unvisited (g/coordinates next-cell))))
         ; already visited the next cell; move without linking
         (recur grid (g/move grid cell direction) unvisited)))))


Use when-seq instead of when not-empty

Use when-seq instead of when not-empty

--- src/github_changelog/formatters/markdown.clj
+++ src/github_changelog/formatters/markdown.clj
@@ -20,7 +20,7 @@
 (defmethod translate-type :default [x] x)

 (defn- format-scope [scope]
-  (when (not-empty scope)
+  (when (seq scope)
     (markdown/emphasis (str scope ":"))))

 (defn- format-pull-request [{:keys [number html_url]}]


Update manufracturer.clj

Update manufracturer.clj

--- src/clojure_car_price/models/manufracturer.clj
+++ src/clojure_car_price/models/manufracturer.clj
@@ -1,13 +1,13 @@
 (ns clojure_car_price.models.manufracturer
   (:refer-clojure :exclude [get])
   (:require [clojure.java.jdbc :as j]
-				[clojure.java.jdbc.sql :as s]))
+	    [clojure.java.jdbc.sql :as s]))

 (def mysql-db {:subprotocol "mysql"
-					 :subname "//localhost:3306/carsdb"
-					 :user "root"
-					 :pass " "
-					 :zeroDateTimeBehaviour "convertToNull"})
+	       :subname "//localhost:3306/carsdb"
+	       :user "root"
+	       :pass " "
+	       :zeroDateTimeBehaviour "convertToNull"})

 (defn get [id]
   (first (j/query mysql-db
@@ -25,4 +25,4 @@
   (j/insert! mysql-db :manufracturer params))

 (defn removeMan [id]
-  (j/delete! mysql-db :manufracturer (s/where {:id id})))+  (j/delete! mysql-db :manufracturer (s/where {:id id})))


remove unused method

remove unused method

--- src/hu/ssh/github_changelog/conventional.clj
+++ src/hu/ssh/github_changelog/conventional.clj
@@ -24,10 +24,6 @@
 (defn- parse-issues [config pull]
   (apply concat ((juxt jira-issues github-issues) config pull)))

-(defn- parse-body [config pull]
-  {:pre [(:base pull)]}
-  (assoc pull :jira-issues (jira-issues config pull)))
-
 (defn- parse-pull [config pull]
   {:pre  [(:title pull)]
    :post [(every? % [:type :scope :subject])]}


No need for mapv, use for instead

No need for mapv, use for instead

--- src/javascript_externs_generator/extern.cljs
+++ src/javascript_externs_generator/extern.cljs
@@ -13,13 +13,14 @@
 (defn build-tree [obj name]
   {:name name
    :type (get-type obj)
-   :props (mapv #(let [child (aget obj %)]
-                   (if (and (parent-type? child)
-                            (not (identical? obj child)))
-                     (build-tree child %)
-                     {:name % :type (get-type child)}))
-                (js-keys obj))
-   :prototype (mapv #(identity {:name % :type :function}) (js-keys (.-prototype obj)))})
+   :props (for [k (js-keys obj)
+                :let [child (aget obj k)]]
+            (if (and (parent-type? child)
+                     (not (identical? obj child)))
+              (build-tree child k)
+              {:name k :type (get-type child)}))
+   :prototype (for [k (js-keys (.-prototype obj))]
+                {:name k :type :function})})

 (defn build-function [name]
   (str (quote-string name) ": function () {}"))
@@ -40,7 +41,7 @@

       :else
       (let [props-extern (str "{" (string/join "," (for [p props]
-                                                             (build-props-extern p))) "}")]
+                                                     (build-props-extern p))) "}")]
         (if (get obj :top)
           (str "var " name "=" props-extern ";")
           (str (quote-string name) ":" props-extern))))))
@@ -48,7 +49,7 @@
 (defn build-prototype [namespace prototype]
   (when (seq prototype)
     (str namespace ".prototype = {" (string/join "," (for [p prototype]
-                                                               (build-function (:name p)))) "};")))
+                                                       (build-function (:name p)))) "};")))

 (defn build-prototype-extern [obj namespace]
   (let [{:keys [name props prototype]} obj


more robust reporting after error.

more robust reporting after error.

--- src/kixi/hecuba/data/measurements/upload.clj
+++ src/kixi/hecuba/data/measurements/upload.clj
@@ -244,4 +244,4 @@
       (write-status store (assoc (update-in item [:uuid] #(str username "/" % "/status")) :status "SUCCESS"))
       (catch Throwable t
         (log/error t "failed")
-        (write-status store (assoc (update-in item [:uuid] #(str username "/" % "/status")) :status "FAILURE" :data (ex-data t)))))))
+        (write-status store (assoc (update-in item [:uuid] #(str username "/" % "/status")) :status "FAILURE" :data (str (ex-data t))))))))


Finish up the temp backend implementation

--- src/doctopus/storage/storage_impls/temp_fs.clj
+++ src/doctopus/storage/storage_impls/temp_fs.clj
@@ -40,4 +40,4 @@
   2. We wrap that html in a function that returns itself, so we can Bidi"
   [key]
   (let [rel-path-html-pairs (files/read-html key)]
-    (into [] (map #([rel-path (fn [_] html)]) rel-path-html-pairs))))
+    (into [] (map (fn [[rel-path html]] [rel-path (fn [_] html)]) rel-path-html-pairs))))


allow for interpolation between maps with different keys. IBirth protocol

--- src/bardo/interpolate.cljx
+++ src/bardo/interpolate.cljx
@@ -1,24 +1,50 @@
-(ns bardo.interpolate)
+(ns bardo.interpolate
+  (:require [clojure.set :refer [union]]))

-(defprotocol IInterpolate (interpolate [this target]))
+;; a protocol for birthing new values from nil
+(defprotocol IBirth (birth [x]))

-#+cljs
+(extend-protocol IBirth
+
+    #+clj java.lang.Number
+    #+cljs number
+    (birth [x]
+      0))
+
+(defprotocol IInterpolate (interpolate [start end]))
+
 (extend-protocol IInterpolate
-  number
-  (interpolate [this target]
+
+  nil
+  (interpolate [start end]
+    (interpolate (birth end) end))
+
+  #+clj java.lang.Number
+  #+cljs number
+  (interpolate [start end]
+    (cond
+       (nil? end) (interpolate start (birth start))
+       :else (fn [t]
+               (+ start (* t (- end start))))))
+
+  #+clj clojure.lang.PersistentVector
+  #+cljs PersistentVector
+  (interpolate [start end]
     (fn [t]
-      (+ this (* t (- target this)))))
-  PersistentVector
-  (interpolate [this target]
+      (mapv (comp #(% t) interpolate) start end)))
+
+  #+clj clojure.lang.PersistentList
+  #+cljs List
+  (interpolate [start end]
     (fn [t]
-      (mapv (comp #(% t) interpolate) this target)))
-  List
-  (interpolate [this target]
+      (map (comp #(% t) interpolate) start end)))
+
+  #+clj clojure.lang.PersistentArrayMap
+  #+cljs PersistentArrayMap
+  (interpolate [start end]
     (fn [t]
-      (map (comp #(% t) interpolate) this target)))
-  PersistentArrayMap
-  (interpolate [this target]
-    (fn [t]
-      (reduce-kv (fn [ret k v]
-                   (let [prev (or (get ret k) v)]
-                     (merge ret (hash-map k ((interpolate prev v) t)) ))) this target))))
+      (into {} (for [k (->> [start end]
+                            (map keys)
+                            (map set)
+                            (apply union))]
+                 [k (apply (comp #(% t) interpolate) (map k [start end]))])))))


Add info-page html

Add info-page html

--- src/beebster_clj/views.clj
+++ src/beebster_clj/views.clj
@@ -1,5 +1,5 @@
 (ns beebster-clj.views
-  (:use hiccup.core hiccup.util hiccup.page hiccup.form beebster-clj.core))
+  (:use hiccup.core hiccup.element hiccup.util hiccup.page hiccup.form beebster-clj.core))

 (def categories
   '("popular" "highlights" "films" "nature"
@@ -116,3 +116,19 @@
    (header '(("/" "Index") ("/about" "about")))
    [:h2.header "Search Results"]
    (display-results (iplayer-search searchterm))))
+
+
+
+(defn info-page
+  [index]
+  (let [[thumb desc title] (load-thumbandinfo-for-index index)]
+    (html
+     (base-template "Info")
+     (header '(("/" "search") ("/about" "about")))
+     [:h2.header "Info"]
+     [:div.infotitle
+      [:p (first title)]]
+     [:div.infothumb
+      [:img {:src (first thumb)}]]
+     [:div.iplayerinfo
+      [:p (first desc)]])))


Fix long-tail percentage and add specs

Fix long-tail percentage and add specs

--- src/matchmaker_sparql/evaluation/metrics.clj
+++ src/matchmaker_sparql/evaluation/metrics.clj
@@ -1,7 +1,36 @@
 (ns matchmaker-sparql.evaluation.metrics
   (:require [clojure.set :refer [union]]
+            [clojure.spec :as s]
+            [sparclj.core :as sparql]
             [taoensso.timbre :as timbre]))

+; ----- Specs -----
+
+; ----- Generic specs -----
+
+(s/def ::fraction (s/and number? #(<= 0 % 1)))
+
+(s/def ::positive-integer (s/and integer? pos?))
+
+; ----- Concrete specs -----
+
+(s/def ::empty? boolean?)
+
+(s/def ::empties (s/coll-of ::empty?))
+
+(s/def ::matches (s/map-of ::sparql/iri ::positive-integer))
+
+(s/def ::rank (s/or :position ::positive-integer
+                    :not-found #{:not-found}))
+
+(s/def ::ranks (s/coll-of ::rank))
+
+(s/def ::metrics (s/keys :req-un [::rank ::empty? ::matches]))
+
+(s/fdef compute-metrics
+        :args (s/cat :match ::sparql/iri
+                     :matches (s/coll-of ::sparql/iri :distinct true))
+        :ret ::metrics)
 (defn compute-metrics
   "Compute metrics of `matches` given correct `match`."
   [match matches]
@@ -10,11 +39,17 @@
      :empty? (not (seq matches))
      :matches (zipmap matches (repeat 1))}))

+(s/fdef union-matches
+        :args (s/cat :metrics (s/coll-of ::metrics))
+        :ret ::matches)
 (defn- union-matches
   "Set union matches."
   [metrics]
   (transduce (map :matches) (partial merge-with +) metrics))

+(s/fdef aggregate-fold-metrics
+        :args (s/cat :metrics (s/coll-of ::metrics))
+        :ret (s/keys :req-un [::matches ::empties ::ranks]))
 (defn aggregate-fold-metrics
   "Compute aggregate metrics for an evaluation fold."
   [metrics]
@@ -22,15 +57,32 @@
    :empties (sequence (map :empty?) metrics) ; FIXME: Needless double iteration.
    :ranks (sequence (map :rank) metrics)})

+(s/def ::bidder-count ::positive-integer)
+
+(s/def ::contract-count ::positive-integer)
+
+(s/def ::long-tail? (s/fspec :args (s/cat :bidder ::sparql/iri)
+                             :ret boolean?))
+
+(s/def ::evaluation (s/keys :req-un [::bidder-count ::contract-count ::long-tail?]))
+
+(s/def ::catalog-coverage ::fraction)
+
+(s/fdef aggregate-evaluation-metrics
+        :args (s/cat :evaluation ::evaluation
+                     :metrics (s/coll-of ::metrics))
+        :ret (s/keys :req-un [::catalog-coverage ::long-tail-coverage
+                              ::predication-coverage ::ranks]))
 (defn aggregate-evaluation-metrics
   "Compute aggregate metrics for the whole evaluation."
   [{:keys [bidder-count contract-count long-tail?]}
    metrics]
   (let [matches (union-matches metrics)
+        matches-count (transduce (map val) + matches)
         long-tail-matches-count (->> matches
                                      (filter (comp long-tail? key))
                                      (transduce (map val) +))]
     {:catalog-coverage (/ (count matches) bidder-count)
-     :long-tail-percentage (/ long-tail-matches-count contract-count)
+     :long-tail-percentage (/ long-tail-matches-count matches-count)
      :prediction-coverage (/ (count (filter false? (mapcat :empties metrics))) contract-count)
      :ranks (mapcat :ranks metrics)}))


update chsk/state handler for new sente

update chsk/state handler for new sente

--- src/braid/client/sync.cljs
+++ src/braid/client/sync.cljs
@@ -32,15 +32,15 @@
   (debugf "Unhandled event: %s" event))

 (defmethod event-msg-handler :chsk/state
-  [{:as ev-msg :keys [?data]}]
-  (if (?data :first-open?)
-    (debugf "Channel socket successfully established!")
-    (do
-      (debugf "Channel socket state change: %s" ?data)
-      (if (not (:open? ?data))
-        (store/display-error! :disconnected "Disconnected" :warn)
-        (store/clear-error! :disconnected))))
-  (event-handler [:socket/connected ?data]))
+  [{:as ev-msg [old-state new-state] :?data}]
+  (if (new-state :first-open?)
+      (debugf "Channel socket successfully established!")
+      (do
+        (debugf "Channel socket state change: %s" new-state)
+        (if (not (:open? new-state))
+          (store/display-error! :disconnected "Disconnected" :warn)
+          (store/clear-error! :disconnected))))
+  (event-handler [:socket/connected new-state]))

 (defmethod event-msg-handler :chsk/recv
   [{:as ev-msg :keys [event ?data]}]