delete commented out functions

delete commented out functions

--- sidecar/src/figwheel_sidecar/build_middleware/injection.clj
+++ sidecar/src/figwheel_sidecar/build_middleware/injection.clj
@@ -1,135 +1,11 @@
 (ns figwheel-sidecar.build-middleware.injection
   (:require
    [figwheel-sidecar.config :as config]
-   [figwheel-sidecar.utils :refer [name-like?]]
    [clojure.java.io :as io]
-   [clojure.string :as string]
    [cljs.env :as env]
-   [cljs.compiler :as compiler]
    [cljs.analyzer.api :as ana-api]))

 #_(remove-ns 'figwheel-sidecar.build-middleware.injection)
-
-#_(def figwheel-client-hook-keys [:on-jsload
-                                :before-jsload
-                                :on-cssload
-                                :on-message
-                                :on-compile-fail
-                                :on-compile-warning])
-
-#_(defn figwheel-connect-ns-parts [{:keys [id]}]
-  (cond-> ["figwheel" "connect"]
-    (and id (name-like? id)) (conj (str "build-" (name id)))))
-
-#_(defn underscore [cljs-path-name]
-  (string/replace cljs-path-name "-" "_"))
-
-#_(defn un-underscore [cljs-path-name]
-  (string/replace cljs-path-name "_" "-"))
-
-#_(defn apply-last [f parts]
-  (if (= (count parts) 3)
-    (update-in parts [2] f)
-    parts))
-
-#_(def figwheel-connect-ns-name
-  (comp (partial string/join ".")
-        (partial apply-last un-underscore)
-        figwheel-connect-ns-parts))
-
-#_(def figwheel-connect-ns-path
-  (comp #(str % ".cljs")
-        (partial string/join "/")
-        (partial apply-last underscore)
-        figwheel-connect-ns-parts))
-
-#_(figwheel-connect-ns-path {:id :build-it})
-
-#_(defn connect-script-temp-dir [build]
-  (assert (:id build) (str "Following build needs an id: " build))
-  (str "target/figwheel_temp/" (underscore (name (:id build)))))
-
-#_(defn connect-script-path [build]
-  (io/file (connect-script-temp-dir build) (figwheel-connect-ns-path build)))
-
-#_(defn delete-connect-scripts! [builds]
-  (doseq [b builds]
-    (when (config/figwheel-build? b)
-      (let [f (connect-script-path b)]
-        (when (.exists f) (.delete f))))))
-
-#_(defn extract-connection-requires [{:keys [figwheel] :as build}]
-  (let [names (set
-               (map #(symbol (namespace (symbol %)))
-                    (vals (select-keys figwheel figwheel-client-hook-keys))))
-        ;; if there is a main defined then add it
-        main-ns  (get-in build [:build-options :main])
-        names (if main-ns
-                (conj names (symbol (str main-ns)))
-                names)
-        names (map vector (conj names 'figwheel.client 'figwheel.client.utils))
-        names (if (:devcards figwheel)
-                (conj names '[devcards.core :include-macros true])
-                names)]
-    names))
-
-#_(figwheel-connect-ns-name {:id :asdf-asdf})
-
-#_(defn extract-connection-script-required-ns [{:keys [figwheel] :as build}]
-  (list 'ns (symbol (figwheel-connect-ns-name build))
-        (cons :require
-              (extract-connection-requires build))))
-
-#_(defn hook-name-to-js [hook-name]
-  (symbol
-   (str "js/"
-        (string/join "." (string/split (str hook-name) #"/")))))
-
-#_(defn try-jsreload-hook [k hook-name]
-  ;; change hook to js form to avoid compile warnings when it doesn't
-  ;; exist, these compile warnings are confusing and prevent code loading
-  (let [hook-name' (hook-name-to-js hook-name)]
-    (list 'fn '[& x]
-          (list 'if hook-name'
-                (list 'apply hook-name' 'x)
-                (list 'figwheel.client.utils/log :debug (str "Figwheel: " k " hook '" hook-name "' is missing"))))))
-
-#_(defn extract-connection-script-figwheel-start [{:keys [figwheel]}]
-  (let [func-map (select-keys figwheel figwheel-client-hook-keys)
-        func-map (into {} (map (fn [[k v]] [k (try-jsreload-hook k v)]) func-map))
-        res (merge figwheel func-map)]
-    (list 'figwheel.client/start res)))
-
-#_(defn extract-connection-devcards-start [{:keys [figwheel]}]
-  (when (:devcards figwheel)
-      (list 'devcards.core/start-devcard-ui!)))
-
-#_(defn generate-connect-script [build]
-  (vec (keep
-        identity
-        (list (extract-connection-script-required-ns build)
-              (extract-connection-script-figwheel-start build)
-              (extract-connection-devcards-start build)))))
-
-#_(generate-connect-script {:id :asdf :build-options {:main 'example.core }})
-
-#_(defn create-connect-script! [build]
-  ;;; consider doing this is the system temp dir
-  (let [temp-file (connect-script-path build)]
-    (.mkdirs (.getParentFile temp-file))
-    (.deleteOnExit temp-file)
-    (with-open [file (io/writer temp-file)]
-      (binding [*out* file]
-        (println
-         (apply str (mapcat
-                     prn-str
-                     (generate-connect-script build))))))
-    temp-file))
-
-#_(defn create-connect-script-if-needed! [build]
-  (when (config/figwheel-build? build)
-    (when-not (.exists (connect-script-path build))
-      (create-connect-script! build))))

 (defn- node? [build]
   (when-let [target (get-in build [:build-options :target])]
@@ -143,22 +19,6 @@

 (defn- has-output-to? [build]
   (get-in build [:build-options :output-to]))
-
-#_(defn- modules-output-to [build]
-  (when (get-in build [:build-options :modules])
-    (get-in build [:build-options :modules :cljs-base :output-to]
-            (str (io/file (get-in build [:build-options :output-dir]
-                                  "out") "cljs_base.js" )))))
-
-#_(defn- build-output-to [build]
-  (or (modules-output-to build)
-      (get-in build [:build-options :output-to])))
-
-
-#_(build-output-to {:build-options {:output-to "resources/public/asdf.js"
-                                  :output-dir "resources/public/js"
-                                  :modules {:cljs-base {:output-to "baser.js"}}}})
-

 (defn add-connect-script! [figwheel-server build]
   ;; cannot just supply arbitrary connection code to the compiler because of the following issues
@@ -199,23 +59,10 @@
                                                    bo)))))
     build))

-
 ;; continuing to append require for the html document case to enable
 ;; document.onload callbacks to work
 (defn esc-fmt [a & args]
   (apply format a (map pr-str args)))
-
-#_(defn document-write-require-lib [munged-ns]
-  (esc-fmt "\ndocument.write(%s);"
-           (esc-fmt "<script>goog.require(%s);</script>" (name munged-ns))))
-
-#_(defn append-require-to-output-to [build munged-ns]
-  (let [output-to (has-output-to? build)
-        line (if (and (has-main? build) (not (node? build)))
-               (str (document-write-require-lib munged-ns))
-               (esc-fmt "\ngoog.require(%s);"   munged-ns))]
-    (when (and output-to (.exists (io/file output-to)))
-      (spit output-to line :append true))))

 (defn document-write-src-script [src]
   (esc-fmt "\ndocument.write(%s);"
@@ -241,4 +88,7 @@
     (build-fn
      (assoc build-state
             :build-config (add-connect-script! figwheel-server build-config)))
+    ;; this will probably not be needed sometime in the future but for
+    ;; now it is safer to let goog.base to do all the loading in an HTML
+    ;; environment before figwheel gets loaded
     (append-connection-init! build-config)))


Meta stuff

Meta stuff

--- src/skidskytte/views.clj
+++ src/skidskytte/views.clj
@@ -31,6 +31,9 @@
 (defn main [name]
   (hp/html5
     [:head
+     [:meta {:charset "utf-8"}]
+     [:title "Skidskytteroulette"]
+     [:meta {:name "viewport" :content "width=device-width" :initial-scale "1"}]
      (hp/include-css "/css/pure-base-min.css")
      (hp/include-css "/css/custom.css")]
     [:body


- impl. and partially use new animation api

--- src/app/cljs/one/sample/animation.cljs
+++ src/app/cljs/one/sample/animation.cljs
@@ -54,6 +54,27 @@
      [:rotate [:from 0 :to rotation-strength :time rotation-time]]
      [:rotate [:from rotation-strength :to 0 :time rotation-time]])))

+(def pathspec-kw->applyable-fn
+     {:linear (fn [path x y] (do (log/info logger (str "Adding path to " x "," y)) (.addLineTo path x y)))
+      :quadric (fn [path cpx cpy x y] (.addQuadricTo path cpx cpy x y))
+      :cubic (fn [path cpx1 cpy1 cpx2 cpy2 x y] (.addCubicTo path cpx1 cpy1 cpx2 cpy2 x y))
+      ;; TODO:
+      ;; :catmull (fn [path cpx1 cpy1 cpx2 cpy2 x y] (.addCubicTo path cpx1 cpy1 cpx2 cpy2 x y))
+      })
+
+(defn- apply-pathspec-to-path
+  ([path]
+     path)
+  ([path [kind & args]]
+     (if (number? kind)
+       (apply (pathspec-kw->applyable-fn :linear) path kind args)
+       (apply (pathspec-kw->applyable-fn kind) path args)))
+  ([path spec1 spec2 & more]
+     (doto path
+       (apply-pathspec-to-path spec1)
+       (apply-pathspec-to-path spec2))
+     (apply apply-pathspec-to-path path more)))
+
 (defn move-behavior
   "Generate & return a move behavior for the target. Still must be added by calling .addBehavior.
    Examples:
@@ -73,25 +94,41 @@
   ;; (move-behavior target :from [0 0] :up 5) ;; initial absolute position & relative movement upwards
   ;; (move-behavior target :to [[10 10] [10 20]]) ;; multiple absolute positions
   ;; (move-behavior target :to [[:quadric 10 10 5 5]] ;; support for non-linear paths
-  [& {:keys [from to time auto-rotate?]
+  [& {:keys [from to time dur auto-rotate? target up down left right]
+      ;; TODO: remove :time
       :or {time 120 auto-rotate? false}}]
+  (assert (or (vector? to) (nil? to)) ":to must be a vector or nil.")
   (let [nr (fn [n] (or n 0))
-        [to-x to-y] (if (vector? to) to)
-        [from-x from-y] (if (vector? from) from)
-        [start-time time] (if (vector? time) time [0 time])]
-    ;; (log/info logger
-    ;;           (str (+ (nr (:right from)) (- (nr (:left from)))) " " (+ (nr (:down from)) (- (nr (:up from)))) " -> "
-    ;;                (+ (nr (:right to)) (- (nr (:left to)))) " " (+ (nr (:down to)) (- (nr (:up to))))))
-    ;; (log/info logger (str start-time " " time))
+        dur (or dur time)
+        [from-x from-y] (if (vector? from)
+                          from
+                          [(or (and target (.x target)) 0)
+                           (or (and target (.y target)) 0)])
+        [start-time time] (if (vector? time)
+                            time
+                            [(or (and target (.time target)) 0) ;; maybe instead of 0, use (.time (->director nil)) ?
+                             time])
+        path (CAAT/Path.)]
+    (cond
+     ;; :to [x y] or any of :up :down :left :right specified
+     (or (nil? to) (every? number? to))
+     (let [[to-x to-y] (if (vector? to) to)]
+       (.setLinear path from-x from-y
+                   (or to-x (+ from-x (nr right) (- (nr left))))
+                   (or to-y (+ from-y (nr down) (- (nr up))))))
+     ;; :to an array
+     :else (do (. path (beginPath from-x from-y))
+               (apply apply-pathspec-to-path path to)
+               (. path (endPath))))
     (doto (CAAT/PathBehavior.)
-      (.setFrameTime start-time time)
+      (.setFrameTime start-time dur)
       (.setAutoRotate (if auto-rotate? true false) (if (fn? auto-rotate?) auto-rotate? nil))
-      (.setPath
-       (doto (CAAT/Path.)
-         (.setLinear (or from-x (+ (nr (:right from)) (- (nr (:left from)))))
-                     (or from-y (+ (nr (:down from)) (- (nr (:up from)))))
-                     (or to-x (+ (nr (:right to)) (- (nr (:left to)))))
-                     (or to-y (+ (nr (:down to)) (- (nr (:up to)))))))))))
+      (.setValues path)
+      (.addListener
+       (clj->js
+        {:behaviorExpired
+         (fn [bh t a]
+           (log/info logger (str "Finished with (x,y):" (.x a) "," (.y a))))})))))

 (defn deg->rad [deg]
   (* (* 2 Math/PI) (/ deg 360)))
@@ -143,9 +180,10 @@
   CAAT.Behavior
   (behavior [s] s)
   cljs.core.Vector
-  (behavior [v]
-                (let [[kind & args] v]
-                  (apply (kind kw->behavior-fn) args))))
+  (behavior
+   [v]
+   (let [[kind & args] v]
+     (apply (kind kw->behavior-fn) args))))

 (defn animation-specs->behavior
   "Given a TARGET and any number of animation SPECS, create & return a
@@ -185,6 +223,65 @@
                       last-caat-behavior)))))
        container)))

+(def kw->behavior-fn2
+     {:move move-behavior
+      :rotate rotate-behavior
+      :scale scale-behavior
+      :alpha alpha-behavior})
+
+(defn- behavior-spec->behavior
+  "Given a behavior spec like [:move ...], transform that into an actual CAAT.Behavior."
+  [spec target]
+  (let [[kind & args] spec]
+    (apply (kw->behavior-fn2 kind) :target target args)))
+
+
+(defn create-animation
+  "Create an animation. This will return a function which can be
+applied to a target to animate it."
+  ([] (fn [target & {:keys [on-finish]}]
+        (when (fn? on-finish)
+         (on-finish target))))
+  ([spec]
+     (if (fn? spec)
+       (fn [target & {:keys [on-finish] :or {on-finish nil}}]
+         (spec target)
+         (when (fn? on-finish)
+           (on-finish target)))
+       (let [director *director*]
+         (fn [target & {:keys [on-finish] :or {on-finish nil}}]
+           (log/info logger (str "Running animation spec: " spec "; Current (x,y):" (.x target) "," (.y target)))
+           (let [bh (behavior-spec->behavior spec target)
+                 dur (. bh (getDuration))]
+             (when (fn? on-finish)
+               (.addListener
+                bh
+                (clj->js
+                 {:behaviorExpired
+                  (fn [bh time actor]
+                    (binding [*director* director]
+                      (on-finish actor)))})))
+             (.addBehavior target bh))))))
+  ([spec1 spec2 & more]
+     (fn [target & {:keys [on-finish]}]
+       ((create-animation spec1)
+        target
+        :on-finish
+        (fn [target]
+          ((create-animation spec2)
+           target
+           :on-finish
+           (fn [target]
+             ((apply create-animation more)
+              target
+              :on-finish
+              on-finish))))))))
+
+(defn animate!
+  ([target & specs]
+     ((apply create-animation specs) target)))
+
+
 (defn animation
   [target & animations]
   {:pre [(actor? target)]}
@@ -281,10 +378,11 @@
             (when (not this.isOpened)
               ;; (log/info logger "Opening basket")
               (animate basket-head (shaky-behavior basket-head))
-              (animate basket-head
-                       (move-behavior :to {:up 30})
-                       (fn [t] (on-finish)))
-              (animate basket-body [:scale [:from 1 :to scale-factor :time 120]])
+              (animate!
+               basket-head
+               [:move :up 30]
+               (fn [t] (on-finish)))
+              (animate! basket-body [:scale :from 1 :to scale-factor :time 120])
               (set! this.isOpened true))))

     (set! basket-container.doClose
@@ -294,9 +392,8 @@
               (doto basket-head
                 (. (emptyBehaviorList))
                 (.setRotation 0)
-                (animate [:move [:from {:up 30}]]
-                         (fn [t] (on-finish))))
-              (animate basket-body [:scale [:from scale-factor :to 1 :time 120]])
+                (animate! [:move :to [0 0]] (fn [t] (on-finish))))
+              (animate! basket-body [:scale :to 1 :time 120])
               (set! this.isOpened false))))
     ;; make sure the sprite changes when the mouse hovers over the basket
     (listen basket-body :mouse-enter (fn [mouseEvent] (. basket-container (doOpen))))
@@ -349,9 +446,9 @@
     (doto target
       (.enableDrag false)
       (.enableEvents false)
-      (animate [:move [:from [(.x source) (.y source)] :to [(.x destination) (.y destination)] :time 100]])
-      (animate [:scale [:from 1 :to 0.1 :time total-animation-time]])
-      (animate [:rotate [:from 0 :to 360 :time total-animation-time]]))))
+      (animate! [:move :from [(.x source) (.y source)] :to [(.x destination) (.y destination)] :dur 100])
+      (animate! [:scale :from 1 :to 0.1 :time total-animation-time])
+      (animate! [:rotate :from 0 :to 360 :time total-animation-time]))))

 (defn draw-bubble
   "Draw a speech bubble. With given width, height & corner radius."
@@ -910,56 +1007,65 @@
                ])
      (fn [director]
        (binding [*director* director]
-        (log/info logger " Images loaded. Creating scene.")
-        (doto director
-          (.addAudio "chime" "sounds/22267__zeuss__the-chime.ogg" ;; "sounds/22267__zeuss__the-chime.mp3"
-                     )
-          (.addAudio "doppp" "sounds/8001__cfork__cf-fx-doppp-01.ogg" ;; "sounds/8001__cfork__cf-fx-doppp-01.wav"
-                     )
-          (.addAudio "flopp" "sounds/8006__cfork__cf-fx-flopp-03-dry.ogg" ;; "sounds/8006__cfork__cf-fx-flopp-03-dry.wav"
-                     )
-          (.addAudio "munching" "sounds/27877__inequation__munching.ogg" ;; "sounds/27877__inequation__munching.wav"
-                     )
-          (.addAudio "song" "sounds/448614_Happiness_Alone.ogg"))
-        (let [scene (. director (createScene))
-              background (actor :image "room")
-              basket (basket scene :x 440 :y 240)
-              bookshelf (bookshelf scene)
-              counter (count-actor 6 :on-total-reached (fn [e] (add! scene (winning-screen scene))))
-              basket-objects (map
-                              #(let [actor (apply animated-actor (apply concat %))]
-                                 (make-draggable-into
-                                  actor
-                                  basket scene
-                                  (fn [] (throw-into-basket director scene basket actor counter))
-                                  :valid-fn (fn [] (and (not (.isOpened basket)) (not (.eating basket))))))
-                              [{:image "football" :animation-indices [0] :draggable? true :thumbnail [60 60]}
-                               {:image "car" :animation-indices [0] :draggable? true :thumbnail [60 60]}
-                               {:image "blocks" :animation-indices [0] :draggable? true}
-                               {:image "teddy" :animation-indices [0 1 0 2] :draggable? true}])
-              bookshelf-objects (map
-                                 #(let [actor (apply animated-actor (apply concat %))]
-                                    (make-draggable-into
-                                     actor bookshelf scene
-                                     (fn []
-                                       (.setExpired actor true)
-                                       (. bookshelf (inc-book-count))
-                                       (. counter (inc)))))
-                                 [{:image "book" :animation-indices [2] :default-index 2 :key-frames 3 :draggable? true}
-                                  {:image "book" :animation-indices [0] :default-index 0 :key-frames 3 :draggable? true}])
-              objects (concat basket-objects bookshelf-objects)]
-          (log/info logger " Displaying scene")
-          (add! scene background)
-          (add! scene basket)
-          (add! scene counter)
-          (add! scene bookshelf)
+         (log/info logger " Images loaded. Creating scene.")
+         (doto director
+           (.addAudio "chime" "sounds/22267__zeuss__the-chime.ogg" ;; "sounds/22267__zeuss__the-chime.mp3"
+                      )
+           (.addAudio "doppp" "sounds/8001__cfork__cf-fx-doppp-01.ogg" ;; "sounds/8001__cfork__cf-fx-doppp-01.wav"
+                      )
+           (.addAudio "flopp" "sounds/8006__cfork__cf-fx-flopp-03-dry.ogg" ;; "sounds/8006__cfork__cf-fx-flopp-03-dry.wav"
+                      )
+           (.addAudio "munching" "sounds/27877__inequation__munching.ogg" ;; "sounds/27877__inequation__munching.wav"
+                      )
+           (.addAudio "song" "sounds/448614_Happiness_Alone.ogg"))
+         (let [scene (. director (createScene))
+               background (actor :image "room")
+               basket (basket scene :x 440 :y 240)
+               bookshelf (bookshelf scene)
+               counter (count-actor 6 :on-total-reached (fn [e] (add! scene (winning-screen scene))))
+               basket-objects (map
+                               #(let [actor (apply animated-actor (apply concat %))]
+                                  (make-draggable-into
+                                   actor
+                                   basket scene
+                                   (fn [] (throw-into-basket director scene basket actor counter))
+                                   :valid-fn (fn [] (and (not (.isOpened basket)) (not (.eating basket))))))
+                               [{:image "football" :animation-indices [0] :draggable? true :thumbnail [60 60]}
+                                {:image "car" :animation-indices [0] :draggable? true :thumbnail [60 60]}
+                                {:image "blocks" :animation-indices [0] :draggable? true}
+                                {:image "teddy" :animation-indices [0 1 0 2] :draggable? true}])
+               bookshelf-objects (map
+                                  #(let [actor (apply animated-actor (apply concat %))]
+                                     (make-draggable-into
+                                      actor bookshelf scene
+                                      (fn []
+                                        (.setExpired actor true)
+                                        (. bookshelf (inc-book-count))
+                                        (. counter (inc)))))
+                                  [{:image "book" :animation-indices [2] :default-index 2 :key-frames 3 :draggable? true}
+                                   {:image "book" :animation-indices [0] :default-index 0 :key-frames 3 :draggable? true}])
+               objects (concat basket-objects bookshelf-objects)]
+           (log/info logger " Displaying scene")
+           (add! scene background)
+           (add! scene basket)
+           (add! scene counter)
+           (add! scene bookshelf)
+           ;; (let [actor (actor :fill-style "black" :size [50 50])]
+           ;;   (add! scene actor)
+           ;;   ;; BUG: (create-animation [:move :to [[400 300] [500 200]] :dur 6000])
+           ;;   ;; NO BUG: (create-animation [:move :to [[400 300] [500 250]] :dur 6000])  ;; what is the difference?
+           ;;   ((create-animation [:move :to [[400 300] [500 250]] :dur 2000]
+           ;;                      (fn [target] (log/info logger "first stage finished!"))
+           ;;                      [:move :up 100 :dur 3000]
+           ;;                      (fn [target] (log/info logger "second stage finished!")))
+           ;;    :on-finish (fn [actor] (log/info logger "Finished!"))))

-          (dotimes [index (count objects)]
-            (let [object (nth objects index)]
-              (add!
-               scene
-               object
-               :position [(+ (rand-int 30) (* (/ 600 (count objects)) index) 100)
-                          (+ (rand-int 50) 360)])))
-          (add! scene (winning-screen scene))
-          ))))))
+           (dotimes [index (count objects)]
+             (let [object (nth objects index)]
+               (add!
+                scene
+                object
+                :position [(+ (rand-int 30) (* (/ 600 (count objects)) index) 100)
+                           (+ (rand-int 50) 360)])))
+           ;; (add! scene (winning-screen scene))
+           ))))))


Fixes typo in xpath.

Fixes typo in xpath.

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
@@ -71,7 +71,7 @@
                                              :DurationValue (value-of pdt "Duration_Value")
                                              :PeriodCycleDurationUnit (value-of pdt "Period_Cycle_Duration_Unit")
                                              :PeriodCycleDurationValue (value-of pdt "Period_Cycle_Duration_Value")})})
-   :Distributions (for [dist (select doc "/DIF/:Distribution")]
+   :Distributions (for [dist (select doc "/DIF/Distribution")]
                     {:DistributionMedia (value-of dist "Distribution_Media")
                      :DistributionSize (value-of dist "Distribution_Size")
                      :DistributionFormat (value-of dist "Distribution_Format")


Add aesthetic change

Add aesthetic change

--- src/spectrace/trace.cljc
+++ src/spectrace/trace.cljc
@@ -21,11 +21,11 @@
   :ret ::state)

 (defmulti step* (fn [state succ fail] (get-in state [:spec :s])))
-(defmethod step* :default [state _ _]
-  (let [spec (:spec state)]
-    (throw (ex-info (str "spec macro " spec
-                         " must have its own method implementation for spectrace.trace/step*")
-                    {:spec spec}))))
+(defmethod step* :default [{:keys [spec]} _ _]
+  (throw
+    (ex-info (str "spec macro " spec
+                  " must have its own method implementation for spectrace.trace/step*")
+             {:spec spec})))

 (defn- with-cont [succ fail f]
   (if-let [ret (f)]


Support errors reporting lack of required keys for s/keys

--- src/spectrace/trace.cljc
+++ src/spectrace/trace.cljc
@@ -121,18 +121,22 @@
         (into (map (fn [k] [(keyword (name k)) k]))
               (collect-keys (set (:opt-un args)) (:req-un args))))))

-(defn- step-for-keys [{:keys [spec path val in]} succ fail val-fn]
-  (with-cont succ fail
-    (let [[segment & path] path
-          [key & in] in
-          keys (possible-keys spec)]
-      (when (and (contains? keys segment)
-                 (map? val)
-                 (contains? val key))
-        {:spec (get keys segment)
-         :path path
-         :val (val-fn val key)
-         :in in}))))
+(defn- step-for-keys [{:keys [path val pred] :as state} succ fail val-fn]
+  (with-cont succ fail
+    (let [keys (possible-keys (:spec state))]
+      (if (empty? path)
+        (when (and (seq? pred) (= (first pred) 'contains?)
+                   (contains? keys (nth pred 2)))
+          (assoc state :spec pred))
+        (let [[segment & path] path
+              [key & in] (:in state)]
+          (when (and (contains? keys segment)
+                     (map? val)
+                     (contains? val key))
+            {:spec (get keys segment)
+             :path path
+             :val (val-fn val key)
+             :in in}))))))

 (defmethod step* `s/keys [state succ fail]
   (step-for-keys state succ fail get))
@@ -202,7 +206,7 @@
               ret
               (step (assoc state :pred pred)
                     (fn [{:keys [spec skip?] :as state'} fail]
-                      (let [spec (if (keyword? spec) spec (second spec))
+                      (let [spec (if (vector? spec) (second spec) spec)
                             state' (normalize (assoc state' :spec spec))
                             ret' (if skip? ret (conj ret state'))]
                         #(rec state' fail ret')))


Drop duplicate indexes by careful reordering of table declarations.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -93,10 +93,9 @@
   ["CREATE TABLE IF NOT EXISTS `probes` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `eid` INT NOT NULL,
-   FOREIGN KEY (eid) REFERENCES `experiments` (`id`),
-   `name` VARCHAR(255))"
-   "ALTER TABLE `probes` ADD CONSTRAINT IF NOT EXISTS `eid_name` UNIQUE(`eid`, `name`)"
-   "CREATE INDEX IF NOT EXISTS probe_name ON probes (eid, name)"])
+   `name` VARCHAR(255),
+   UNIQUE(`eid`, `name`),
+   FOREIGN KEY (`eid`) REFERENCES `experiments` (`id`))"])

 (def scores-table
   [(format "CREATE TABLE IF NOT EXISTS `scores` (
@@ -107,16 +106,16 @@
   ["CREATE TABLE IF NOT EXISTS `joins` (
    `pid` INT,
    `i` INT,
-   `sid` INT)"
-   "CREATE INDEX IF NOT EXISTS index_pid ON joins (`pid`, `i`)"])
+   `sid` INT,
+   UNIQUE (`pid`, `i`))"])

 (def cohorts-table
   ["CREATE TABLE IF NOT EXISTS `cohorts` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-   `name` VARCHAR(2000) NOT NULL UNIQUE)"
-   "CREATE INDEX IF NOT EXISTS index_name ON cohorts (`name`)"])
+   `name` VARCHAR(2000) NOT NULL UNIQUE)"])

 ; XXX What should max file name length be?
+; XXX Unique columns? Indexes?
 (def sources-table
   ["CREATE TABLE IF NOT EXISTS `sources` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@@ -128,7 +127,7 @@
 ; XXX Include original json
 (def experiments-table
   ["CREATE TABLE IF NOT EXISTS `experiments` (
-   `id` INT NOT NULL AUTO_INCREMENT,
+   `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` varchar(255) NOT NULL UNIQUE,
    `probeMap` varchar(255),
    `shortTitle` varchar(255),
@@ -138,8 +137,7 @@
    `security` varchar(255),
    `gain` double DEFAULT NULL,
    `text` varchar (65535),
-   `dataSubType` varchar (255))"
-   "ALTER TABLE `experiments` ADD CONSTRAINT IF NOT EXISTS `experiments_id` PRIMARY KEY (`id`)"])
+   `dataSubType` varchar (255))"])

 ;
 ; experiments in making a macro for metadata tables
@@ -206,11 +204,9 @@
 (def experiment-sources-table
   ["CREATE TABLE IF NOT EXISTS `experiment_sources` (
    `experiments_id` INT NOT NULL,
+   `sources_id` INT NOT NULL,
    FOREIGN KEY (experiments_id) REFERENCES `experiments` (`id`),
-   `sources_id` INT NOT NULL,
-   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"
-   "CREATE INDEX IF NOT EXISTS experiment ON `experiment_sources` (`experiments_id`)"
-   "CREATE INDEX IF NOT EXISTS source ON `experiment_sources` (`sources_id`)"])
+   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"])

 (defentity experiment_sources)

@@ -263,11 +259,9 @@
 (def probemap-sources-table
   ["CREATE TABLE IF NOT EXISTS `probemap_sources` (
    `probemaps_id` INT NOT NULL,
+   `sources_id` INT NOT NULL,
    FOREIGN KEY (probemaps_id) REFERENCES `probemaps` (`id`),
-   `sources_id` INT NOT NULL,
-   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"
-   "CREATE INDEX IF NOT EXISTS probemap ON `probemap_sources` (`probemaps_id`)"
-   "CREATE INDEX IF NOT EXISTS source ON `probemap_sources` (`sources_id`)"])
+   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"])

 (def ^:private probemaps-columns
   #{:name
@@ -290,33 +284,31 @@
   ["CREATE TABLE IF NOT EXISTS `probemap_probes` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `probemaps_id` INT NOT NULL,
-   FOREIGN KEY (probemaps_id) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
-   `probe` VARCHAR(1000) NOT NULL)"])
+   `probe` VARCHAR(1000) NOT NULL,
+   FOREIGN KEY (probemaps_id) REFERENCES `probemaps` (`id`) ON DELETE CASCADE)"])

 ; XXX CASCADE might perform badly. Might need to do this incrementally in application code.
 (def probemap-positions-table
   ["CREATE TABLE IF NOT EXISTS `probemap_positions` (
    `probemaps_id` INT NOT NULL,
-   FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
    `probemap_probes_id` INT NOT NULL,
-   FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE,
    `bin` INT,
    `chrom` VARCHAR(255) NOT NULL,
    `chromStart` INT NOT NULL,
    `chromEnd` INT NOT NULL,
    `strand` CHAR(1))"
-   "CREATE INDEX IF NOT EXISTS chrom_bin ON probemap_positions
-   (`probemaps_id`, `chrom`, `bin`)"])
+   "CREATE INDEX IF NOT EXISTS chrom_bin ON probemap_positions (`probemaps_id`, `chrom`, `bin`)"
+   "ALTER TABLE `probemap_positions` ADD FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE"
+   "ALTER TABLE `probemap_positions` ADD FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE"])

 (def probemap-genes-table
   ["CREATE TABLE IF NOT EXISTS `probemap_genes` (
    `probemaps_id` INT NOT NULL,
-   FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
    `probemap_probes_id` INT NOT NULL,
-   FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE,
    `gene` VARCHAR(255))"
-   "CREATE INDEX IF NOT EXISTS gene ON probemap_genes
-   (`probemaps_id`, `gene`)"])
+   "CREATE INDEX IF NOT EXISTS probemap_gene ON `probemap_genes` (`probemaps_id`, `gene`)"
+   "ALTER TABLE `probemap_genes` ADD FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE"
+   "ALTER TABLE `probemap_genes` ADD FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE"])

 ;
 ; feature tables
@@ -326,12 +318,12 @@
   ["CREATE TABLE IF NOT EXISTS `features` (
   `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `probes_id` int(11) NOT NULL,
-   FOREIGN KEY (`probes_id`) REFERENCES `probes` (`id`) ON DELETE CASCADE,
   `shortTitle` varchar(255),
   `longTitle` varchar(255),
   `priority` double DEFAULT NULL,
   `valueType` varchar(255) NOT NULL,
-  `visibility` varchar(255))"])
+  `visibility` varchar(255),
+  FOREIGN KEY (`probes_id`) REFERENCES `probes` (`id`) ON DELETE CASCADE)"])

 (declare codes)
 (defentity features
@@ -354,14 +346,17 @@
    :defaults features-defaults
    :columns features-columns})

+; Order is important to avoid creating duplicate indexes. A foreign
+; key constraint creates an index if one doesn't exist, so create our
+; index before adding the constraint.
 (def codes-table
   ["CREATE TABLE IF NOT EXISTS `codes` (
-  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  `features_id` int(11) NOT NULL,
-   FOREIGN KEY (`features_id`) REFERENCES `features` (`id`) ON DELETE CASCADE,
+   `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
+   `features_id` int(11) NOT NULL,
    `ordering` int(10) unsigned NOT NULL,
-   `value` varchar(255) NOT NULL)"
-   "CREATE INDEX IF NOT EXISTS `feature` ON `codes` (`features_id`, `ordering`)"])
+   `value` varchar(255) NOT NULL,
+   UNIQUE (`features_id`, `ordering`),
+   FOREIGN KEY (`features_id`) REFERENCES `features` (`id`) ON DELETE CASCADE)"])

 (defentity codes
   (belongs-to features))


(maint) Add logging for JRuby instance borrow

--- src/clj/puppetlabs/services/request_handler/request_handler_core.clj
+++ src/clj/puppetlabs/services/request_handler/request_handler_core.clj
@@ -279,7 +279,9 @@
   it available in the request as `:jruby-instance`"
   [f jruby-service]
   (fn [request]
+    (log/debug "Borrowing a JRuby instance ...")
     (jruby/with-jruby-puppet jruby-instance jruby-service
+      (log/debug "JRuby instance borrowed")
       (f (assoc request :jruby-instance jruby-instance)))))

 (defn jruby-request-handler


[GAWB-1597] Switch position of name, namespace columns (#722)

Switch location of name, namespace columns [GAWB-1597]

--- src/cljs/main/broadfcui/page/method_repo/method_config_importer.cljs
+++ src/cljs/main/broadfcui/page/method_repo/method_config_importer.cljs
@@ -259,6 +259,14 @@
       :else
       [table/Table
        {:columns [{:header "Type" :starting-width 100}
+                  {:header "Name" :starting-width 350
+                   :sort-by (fn [m]  [(clojure.string/lower-case (m "name")) (int (m "snapshotId"))])
+                   :filter-by (fn [m] [(m "name") (str (m "snapshotId"))])
+                   :as-text (fn [item] (str (item "namespace") "\n" (item "name") "\nSnapshot ID: " (item "snapshotId")))
+                   :content-renderer
+                   (fn [item]
+                     (style/create-link {:text (style/render-name-id (item "name") (item "snapshotId"))
+                                         :onClick #((:on-item-selected props) item)}))}
                   {:header "Namespace" :starting-width 160
                    :sort-by (fn [m] (clojure.string/lower-case (m "namespace")))
                    :sort-initial :asc
@@ -274,14 +282,6 @@
                                                           :load-endpoint (endpoints/get-agora-namespace-acl (item "namespace") (= :config (:type item)))
                                                           :entityType "Namespace" :entityName (item "namespace")
                                                           :title (str "Namespace " (item "namespace"))}])})))}
-                  {:header "Name" :starting-width 350
-                   :sort-by (fn [m]  [(clojure.string/lower-case (m "name")) (int (m "snapshotId"))])
-                   :filter-by (fn [m] [(m "name") (str (m "snapshotId"))])
-                   :as-text (fn [item] (str (item "namespace") "\n" (item "name") "\nSnapshot ID: " (item "snapshotId")))
-                   :content-renderer
-                   (fn [item]
-                     (style/create-link {:text (style/render-name-id (item "name") (item "snapshotId"))
-                                         :onClick #((:on-item-selected props) item)}))}
                   {:header "Synopsis" :starting-width 160}
                   (table/date-column {:header "Created"})
                   {:header "Referenced Method" :starting-width 250


Refactor style of backend service

Refactor style of backend service

--- src/clj/pva_parrot/backend/service.clj
+++ src/clj/pva_parrot/backend/service.clj
@@ -7,8 +7,7 @@
             [taoensso.timbre                :as timbre :refer (tracef debugf infof warnf errorf)]
             [clojure.data.csv               :as csv]
             [pva-parrot.calc.pca            :as pca]
-            [pva-parrot.io                  :as io]
-            ))
+            [pva-parrot.io                  :as io]))

 (let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn connected-uids]}
       (sente/make-channel-socket! sente-web-server-adapter {})]
@@ -25,8 +24,6 @@
   (when ?reply-fn
     (?reply-fn {:unmatched-event-as-echoed-from-server event})))

-(sente/start-chsk-router! ch-chsk event-msg-handler)
-
 (defmethod event-msg-handler :data-import/csv-sent
   [{:as event-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
   (when ?data
@@ -38,12 +35,12 @@
           num-samples    (count csv-body)
           csv-matrix     (io/csv-to-matrix (:file-body ?data))
           summary-variables (->> csv-matrix
-                              (pca/transpose)
-                              (pca/summarize (rest csv-headings)))
+                                 (pca/transpose)
+                                 (pca/summarize (rest csv-headings)))
           normalized-data (pca/normalize-compos csv-matrix)
           summary-normalized (->> normalized-data
-                              (pca/transpose)
-                              (pca/summarize (rest csv-headings)))
+                                  (pca/transpose)
+                                  (pca/summarize (rest csv-headings)))
           pca-data       (pca/components csv-matrix)
           pca-std-devs   (:std-dev pca-data)
           eigen-values   (:eigen-values pca-data)
@@ -58,16 +55,15 @@
                            :eigen-values  {:headings nil :body [eigen-values]}
                            :eigen-vectors {:headings nil :body eigen-vectors}
                            }]]
+      (chsk-send! uid reply-msg))))

-      (chsk-send! uid reply-msg))))
+(sente/start-chsk-router! ch-chsk event-msg-handler)

 (defroutes api-handlers
   (GET "/" [] "You found the PVA Parrot backend service!")
   (GET  "/chsk" request (ring-ajax-get-or-ws-handshake request))
-  (POST "/chsk" request (ring-ajax-post                request))
-  )
-
+  (POST "/chsk" request (ring-ajax-post request)))

 (def api (-> api-handlers
-           (keyword-params/wrap-keyword-params)
-           (params/wrap-params)))
+             (keyword-params/wrap-keyword-params)
+             (params/wrap-params)))


add text to pages view

add text to pages view

--- src/cljs/salava/badge/ui/evidence.cljs
+++ src/cljs/salava/badge/ui/evidence.cljs
@@ -248,7 +248,9 @@
     [:div.col-md-12.resource-container
      (reduce (fn [r resource]
                (conj r [grid-element resource state :page_input])
-               ) [:div] pages)]))
+               ) [:div
+                  [:label {:style {:margin "5px"}} (t :badge/Clickpagebelow)]
+                  ] pages)]))

 (defn resource-input [data state init-data]


debug js error

debug js error

--- src/cljs/salava/badge/ui/evidence.cljs
+++ src/cljs/salava/badge/ui/evidence.cljs
@@ -337,7 +337,7 @@
   (let [evidence-name-atom (cursor state [:evidence :name])
         evidence-narrative-atom (cursor state [:evidence :narrative])
         visibility-atom (cursor state [:evidence :properties :hidden])]
-    (fn []
+    [:div
     (reduce (fn [r evidence]
               (let [{:keys [narrative description name id url mtime ctime properties]} evidence
                     {:keys [resource_id resource_type mime_type hidden]} properties
@@ -417,10 +417,9 @@
                                       :data-target (str "#collapse" id)}
                              (t :badge/Save)]]
                            ]]])))
-              )[:div {:id "accordion" :class "panel-group evidence-list" :role "tablist" :aria-multiselectable "true"}] @(cursor state [:badge-settings :evidences])))))
+              )[:div {:id "accordion" :class "panel-group evidence-list" :role "tablist" :aria-multiselectable "true"}] @(cursor state [:badge-settings :evidences]))]))

 (defn evidenceblock [data state init-data]
-  (fn []
     [:div#badge-settings
      [:div.form-group
       [:div.col-md-9 {:class "new-evidence"}
@@ -434,8 +433,8 @@
                                 :tab [evidence-form data state init-data]
                                 :tab-no 2)
                          #_(swap! state assoc :tab [evidence-form data state init-data] :tab-no 2))} (t :badge/Addnewevidence)]]]
-     #_(when-not (empty? (:evidences data)) [:div.form-group
-                                           [:div.col-md-12 [evidence-list data state init-data]]])]))
+     (when-not (empty? (:evidences data)) [:div.form-group
+                                           [:div.col-md-12 [evidence-list data state init-data]]])])

 (defn evidence [data state init-data]
- (fn [] [evidenceblock data state init-data]))
+ (fn [] (evidenceblock data state init-data)))


improve share functionality

improve share functionality

--- src/cljs/salava/badge/ui/settings.cljs
+++ src/cljs/salava/badge/ui/settings.cljs
@@ -13,6 +13,7 @@
             [salava.core.ui.rate-it :as r]
             [salava.badge.ui.my :as my]))

+
 (defn set-visibility [visibility state]
   (swap! state assoc-in [:badge-settings :visibility] visibility))

@@ -38,7 +39,14 @@
      :handler (fn []
                 (init-data state id (:tab-no @state)))}))

-(defn save-settings [state init-data]
+(defn update-settings [badge-id state]
+  (ajax/GET
+    (path-for (str "/obpv1/badge/settings/" badge-id) true)
+    {:handler (fn [data]
+                (swap! state assoc :badge-settings data (assoc data :new-tag "")))}))
+
+
+(defn save-settings [state init-data context]
   (let [{:keys [id visibility tags rating evidence_url]} (:badge-settings @state)]
     (ajax/POST
       (path-for (str "/obpv1/badge/save_settings/" id))
@@ -47,7 +55,10 @@
                  :rating       (if (pos? rating) rating nil)
                  :evidence-url evidence_url}
        :handler (fn []
-                  (init-data state id (if (= 3 (:tab-no @state))(:tab-no @state) nil)))})))
+                  (if (= "share" context)
+                    (update-settings id state)
+                    (init-data state id nil)))})))
+

 (defn toggle-recipient-name [id show-recipient-name-atom]
   (let [new-value (not @show-recipient-name-atom)]
@@ -89,7 +100,7 @@
                        :type            "radio"
                        :on-change       #(do
                                            (set-visibility "public" state)
-                                           (save-settings state init-data))
+                                           (save-settings state init-data "share"))
                        :default-checked (= "public" (get-in @state [:badge-settings :visibility]))}]
          [:i {:class "fa fa-globe" }]
          [:label {:for "visibility-public"}
@@ -100,7 +111,7 @@
                      :type            "radio"
                      :on-change       #(do
                                          (set-visibility "internal" state)
-                                         (save-settings state init-data))
+                                         (save-settings state init-data "share"))
                      :default-checked (= "internal" (get-in @state [:badge-settings :visibility]))}]
        [:i {:class "fa fa-group" }]
        [:label {:for "visibility-internal"}
@@ -111,7 +122,7 @@
                      :type            "radio"
                      :on-change       #(do
                                          (set-visibility "private" state)
-                                         (save-settings state init-data))
+                                         (save-settings state init-data "share"))
                      :default-checked (= "private" (get-in @state [:badge-settings :visibility]))}]
        [:i {:class "fa fa-lock" }]
        [:label {:for "visibility-private"}
@@ -136,22 +147,22 @@
                :on-click     #(delete-badge state)}
       (t :badge/Delete)]]]])

-(defn share-tab-content [{:keys [id name image_file issued_on expires_on show_evidence revoked visibility issuer_content_name]} state init-data]
+(defn share-tab-content [{:keys [id name image_file issued_on expires_on show_evidence revoked issuer_content_name]} state init-data]
   (let [expired? (bh/badge-expired? expires_on)
-        revoked (pos? revoked)]
+        revoked (pos? revoked)
+        visibility (cursor state [:badge-settings :visibility])]
     [:div {:id "badge-settings" :class "row flip"}
      [:div {:class "col-md-3 badge-image modal-left"}
       [:img {:src (str "/" image_file) :alt name}]]
      [:div {:class "col-md-9 settings-content"}
       (if (and (not expired?) (not revoked))
         [visibility-form state init-data])
-      (if (= "public" visibility)
         [:div
          [:hr]
          [s/share-buttons-badge
           (str (session/get :site-url) (path-for (str "/badge/info/" id)))
           name
-          (= "public" visibility)
+          (= "public" @visibility)
           true
           (cursor state [:show-link-or-embed])
           image_file
@@ -160,9 +171,10 @@
            :licence  (str (upper-case (replace (session/get :site-name) #"\s" "")) "-" id)
            :url      (str (session/get :site-url) (path-for (str "/badge/info/" id)))
            :datefrom issued_on
-           :dateto   expires_on}]])]]))
-
-(defn settings-tab-content [{:keys [id name image_file issued_on expires_on show_evidence revoked rating]} state init-data badgeinfo?]
+           :dateto   expires_on}]]
+      ]]))
+
+(defn settings-tab-content [{:keys [id name image_file issued_on expires_on show_evidence revoked rating]} state init-data]
   (let [expired? (bh/badge-expired? expires_on)
         show-recipient-name-atom (cursor state [:show_recipient_name])
         notifications-atom (cursor state [:receive-notifications])
@@ -237,7 +249,7 @@
                                             [:div.modal-footer
                                              [:button {:type         "button"
                                                        :class        "btn btn-primary"
-                                                       :on-click     #(save-settings state init-data)}
+                                                       :on-click     #(save-settings state init-data nil)}
                                               (t :badge/Save)]]])]]))

 (defn download-tab-content [{:keys [name image_file obf_url assertion_url]} state]


Remove logcat image

Remove logcat image

--- src/clojure/nightcode/file_browser.clj
+++ src/clojure/nightcode/file_browser.clj
@@ -133,7 +133,7 @@
       "cljs" "file-clojure.png"
       "java" "file-java.png"
       "git" "git.png"
-      "logcat" "android2.png"
+      "logcat" nil
       "file.png")))

 (defn protect-file?


Updating in-memory database to set a revision date on a concept revision when it is saved.

--- src/cmr/metadata_db/data/memory_db.clj
+++ src/cmr/metadata_db/data/memory_db.clj
@@ -4,6 +4,8 @@
             [cmr.metadata-db.data.providers :as providers]
             [cmr.common.concepts :as cc]
             [cmr.common.lifecycle :as lifecycle]
+            [clj-time.core :as t]
+            [clj-time.format :as f]
             [cmr.metadata-db.data.oracle.concepts]))

@@ -111,7 +113,8 @@
     [this concept]
     {:pre [(:revision-id concept)]}

-    (let [{:keys [concept-type provider-id concept-id revision-id]} concept]
+    (let [{:keys [concept-type provider-id concept-id revision-id]} concept
+          concept (assoc concept :revision-date (f/unparse (f/formatters :date-time) (t/now)))]
       (if (or (nil? revision-id)
               (concepts/get-concept this concept-type provider-id concept-id revision-id))
         {:error :revision-id-conflict}


CMR-273: Adding concept-id for searching granules to help verify they are deleted. Will test properly when the issue is taken.

--- src/cmr/search/services/parameters.clj
+++ src/cmr/search/services/parameters.clj
@@ -37,7 +37,8 @@
              :short_name :collection-query
              :version :collection-query
              :temporal :temporal
-             :project :string}})
+             :project :string
+             :concept-id :string}})

 (defn- param-name->type
   "Returns the query condition type based on the given concept-type and param-name."


Remove trailing newline.

Remove trailing newline.

--- project/scrape-summitpost-data/src/scrape_summitpost_data/extract_from_item.clj
+++ project/scrape-summitpost-data/src/scrape_summitpost_data/extract_from_item.clj
@@ -45,4 +45,3 @@
        (drop 1)
        (take-while #(nil? (extract-left-box-heading %)))
        (keep extract-left-box-link)))
-


convert funcs

convert funcs

--- datomic-dsl/src/datomic_dsl/add_nested.clj
+++ datomic-dsl/src/datomic_dsl/add_nested.clj
@@ -81,3 +81,36 @@
   [schema-name dsl]
   (reduce add-matching-dbids-to-nested-child
           dsl (key-sequence dsl)))
+
+(defn convert-key-sequence-fn
+  "For a given dsl entry with dbids - convert it to Datomic syntax - add append it to the results"
+  [nested-dsl]
+  (fn [key-sequence]
+    (let [local-datom (get-in nested-dsl key-sequence)
+          db-if-ref (:db/id local-datom)
+          local-datom-minus-dbid (dissoc local-datom :db/id)
+          local-datom-minus-children (into {} (map replace-children
+                                                   local-datom-minus-dbid))
+          parent-name (take-last 1 key-sequence)
+          last-two (take-last 2 key-sequence)
+          last-one (first (take-last 1 key-sequence))
+          parent-keyword (case (count last-two)
+                           2 (keyword (first last-two) (second last-two))
+                           1 (keyword (first last-two)))
+          new-keys (into () (map (fn [[k v]] [k (keyword (str last-one "/" k))]) local-datom-minus-children))
+          new-map (clojure.set/rename-keys local-datom-minus-children new-keys)
+          new-map-with-dbid (merge new-map {:db/id db-id-ref})]
+      new-map-with-dbid)))
+
+(defn key-sequences-rev
+  "Given a dsl - return the key-sequences to each node of the nested structure in reverse order"
+  [dsl]
+  (map reverse (key-sequences dsl)))
+
+(defn convert-dsl-to-datomic-syntax
+  "Map over the key-sequences to step through the dsl with dbids and return datomic syntax."
+  [schema-name dsl]
+  (let [dsl-with-dbids (nested-insert-dsl schema-name dsl)]
+    (let [convert-key-sequence (convert-key-sequence-fn dsl-with-dbids)]
+      (map convert-key-sequence (key-sequences-rev dsl)))))
+


CMR-3195: One more try...

CMR-3195: One more try...

--- system-int-test/test/cmr/system_int_test/ingest/collection_validation_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/collection_validation_test.clj
@@ -359,30 +359,30 @@
                                                  (dc/psa {:name "bool2" :data-type :boolean :value true})]}))

   ;; testing enabling umm json schema validation through Cmr-Validation-Umm-C header
+  (testing "Enabling UMM-C JSON-Schema validation through Cmr-Validate-Umm-C header being true"
+    ;; create collection valid against echo10 but invalid against schema
+    (let [response (d/ingest "PROV1" (dc/collection {:product-specific-attributes
+                                                     [(dc/psa {:name "bool1" :data-type :boolean :value true})
+                                                      (dc/psa {:name "bool2" :data-type :boolean :value true})]})
+                             {:allow-failure? true :validate-umm-c true})]
+      (is (= {:status 422
+              :errors ["object has missing required properties ([\"ProcessingLevel\",\"RelatedUrls\",\"ScienceKeywords\",\"SpatialExtent\"])"]}
+             (select-keys response [:status :errors])))))
+
   (let [coll-attr {:product-specific-attributes
                    [(dc/psa {:name "bool1" :data-type :boolean :value true})
                     (dc/psa {:name "bool2" :data-type :boolean :value true})]}]
     (side/eval-form `(icfg/set-return-umm-json-validation-errors! false))
-    (do (are3 [coll-attributes error options]
-              (do (assert-invalid-schema coll-attributes error options)
-                  (assert-valid coll-attributes))
-
-              "Set Cmr-Validate-Umm-C header to true - schema validation error is returned"
-              coll-attr
-              "object has missing required properties ([\"ProcessingLevel\",\"RelatedUrls\",\"ScienceKeywords\",\"SpatialExtent\"])"
-              {:validate-umm-c true})
-
-        (are3 [coll-attributes options]
-              (do (assert-valid coll-attributes options)
-                  (assert-valid coll-attributes))
-
-              "Set Cmr-Validate-Umm-C header to false - schema validation error is not returned"
-              coll-attr
-              {:allow-failure? true :validate-umm-c false}
-
-              "Do not set Cmr-Validate-Umm-C header - schema validation error is not returned"
-              coll-attr
-              {:allow-failure? true})))
+    (are3 [coll-attributes options]
+          (assert-valid coll-attributes options)
+
+          "Set Cmr-Validate-Umm-C header to false - schema validation error is not returned"
+          coll-attr
+          {:allow-failure? true :validate-umm-c false}
+
+          "Do not set Cmr-Validate-Umm-C header - schema validation error is not returned"
+          coll-attr
+          {:allow-failure? true}))

   ;; testing enabling umm-spec validation through Cmr-Validation-Umm-C header
   (let [coll-attr {:processing-level-id "1"


Correct test config

Correct test config

--- plugin/project.clj
+++ plugin/project.clj
@@ -13,6 +13,8 @@

   :dependencies [[org.clojure/clojure "1.7.0"]
                  [doo "0.1.6-SNAPSHOT"]]
+
+  :test-paths ["test/clj" "test/cljs"]

   :clean-targets ^{:protect false} [:target-path "resources/public/js/" "out"]


Add comments

Add comments

--- src/try_clojure/core.clj
+++ src/try_clojure/core.clj
@@ -1,11 +1,14 @@
+; Namespace
 (ns try-clojure.core
   (:use compojure.core)
   (:require
     [ring.adapter.jetty :as jetty]))

+; Routing
 (defroutes main-routes
   (GET "/" [] "Hello World"))

+; Main
 (defn -main []
   (jetty/run-jetty main-routes {:port 5000}))


replace early vote site list fn with election detail

--- src/cljs/early_vote_site/early_vote_site_detail/events.cljs
+++ src/cljs/early_vote_site/early_vote_site_detail/events.cljs
@@ -1,14 +1,14 @@
 (ns early-vote-site.early-vote-site-detail.events
   (:require [ajax.core :as ajax]
+            [early-vote-site.election-detail.events :as election-detail]
             [early-vote-site.server :as server]
-            [early-vote-site.utils :as utils]
-            [early-vote-site.early-vote-site-list.events :as list-events]))
+            [early-vote-site.utils :as utils]))

 (defn navigate
   [{:keys [db]} [_ early-vote-site-id]]
   {:db (-> db
         (assoc :selected-early-vote-site-id early-vote-site-id)
-        (assoc :active-panel :early-vote-site/detail))
+        (assoc :active-panel :early-vote-site-detail/main))
    :dispatch-n [[:early-vote-site/get]
                 [:schedules-list/get]]})

@@ -27,7 +27,7 @@
 (defn get-early-vote-site-success
   [db [_ result]]
   (assoc db :selected-early-vote-site
-         (first (map list-events/early-vote-site-json->clj result))))
+         (first (map election-detail/early-vote-site-json->clj result))))

 (defn list-schedules
   [{:keys [db]} _]


Update builtins.clj

Update builtins.clj

--- src/iyye/subcon/knowledge/builtins.clj
+++ src/iyye/subcon/knowledge/builtins.clj
@@ -18,8 +18,7 @@
                                      [clojure.tools.logging :as log]
                                      [iyye.bios.persistence :as persistence]
                                      ;[iyye.subcon.knowledge.relation :as relation]
-                                     [iyye.subcon.knowledge.words :as words]
-                                     ))
+                                     [iyye.subcon.knowledge.words :as words]))

 ; Builtin types
 (def iyye_actor (ref 0))
@@ -33,47 +32,41 @@
 (def iyye_consists_type (ref 0))
 (def iyye_create_instance (ref 0))

-(defn iyye_is_type_predicate_function [p1-types p2-types]
-  (when (and (not(empty? p1-types))
-             (not(empty? p2-types)))
-    (let [p1-type (first p1-types)                        ; FIXME Yumzya first
-          p2-type (first p2-types)
-          p1-name (:Name (:atom p1-type))
+(defn iyye_is_type_predicate_function [params]
+  (when (= 2 (count params))
+    (let [[p1-type p2-type] params
           p2-name (:Name (:atom p2-type))
-          p1-data (:Data p1-type)
-          p2-data (:Data p2-type)]
-      (and (= p1-name (:super p2-data))                     ; FIXME Yumzia modal logic
-           (= p2-name (:sub p1-data))))))
+          rels1 (:Relations p1-type)]
+      (some true?
+            (for [rel rels1]
+              (= (:super (:Data rel)) p2-name)))))) ; FIXME Yumzia modal logic, FIXME 0 recursive

-(defn iyye_is_type_function [p1-type p2-type]
-  (when (and p1-type p2-type)
-    (let [is_type #(words/action-words @iyye_is_type)]
-      (let [p1-supertype (assoc (is_type) :Data {:super (:Name (:atom p2-type))})
-            p2-subtype (assoc (is_type) :Data {:sub (:Name (:atom p1-type))})
-            new-p1-type (assoc p1-type :Relations
-                                       (conj (:Relations p1-type) p1-supertype))
-            new-p2-type (assoc p2-type :Relations
-                                       (conj (:Relations p2-type) p2-subtype))]
+(defn- iyye_add_relation [p1-type p2-type relation]
+  (let [is_type #(words/action-words relation)]
+    (let [p1-supertype (assoc (is_type) :Data {:super (:Name (:atom p2-type))})
+          p2-subtype (assoc (is_type) :Data {:sub (:Name (:atom p1-type))})
+          new-p1-type (assoc p1-type :Relations
+                                     (conj (:Relations p1-type) p1-supertype))
+          new-p2-type (assoc p2-type :Relations
+                                     (conj (:Relations p2-type) p2-subtype))]
       (do
         (words/set-iyye-type! new-p1-type)
-        (words/set-iyye-type! new-p2-type))))))
+        (words/set-iyye-type! new-p2-type)))))

-(defn iyye_is_type_create_function [p1-name p2-type]
-  (let [p1-type (words/create-iyye-type p1-name)]
+(defn iyye_is_type_function [params]
+  (let [[p1-type p2-type] params]
     (when (and p1-type p2-type)
-      (let [is_type #(words/action-words @iyye_is_type)]
-        (let [new-p1-type (assoc p1-type :Relations
-                                       (conj (:Relations p1-type)))
-            p2-subtypes (assoc (is_type) :Data
-                                             {:sub (:Name (:atom p1-type))})
-            new-p2-type (assoc p2-type :Relations p2-subtypes)]
-      (do
-        (words/set-iyye-type! new-p1-type)
-        (words/set-iyye-type! new-p2-type)))))))
+      (iyye_add_relation p1-type p2-type @iyye_is_type))))

-(defn iyye_consists_function [p1 p2]
-  (let [])
-  )
+(defn iyye_is_type_create_function [params]
+  (let [[p1-name p2-type] params
+        p1-type (words/create-iyye-type p1-name)]
+    (iyye_is_type_function [p1-type p2-type])))
+
+(defn iyye_consists_function [params]
+  (let [[p1-type p2-type] params]
+    (when (and p1-type p2-type)
+      (iyye_add_relation p1-type p2-type @iyye_consists_type))))

 (defn iyye_instance_function [p1 name]
   (let [])
@@ -126,10 +119,10 @@
   (let [get-type #(words/noun-words %)
         get-function #(:Function (words/action-words %))]
     (do
-      ((get-function @iyye_is_type) (get-type @iyye_ai) (get-type @iyye_actor))
-      ((get-function @iyye_is_type) (get-type @iyye_human) (get-type @iyye_actor))
-      ((get-function @iyye_is_type) (get-type @iyye_iyye) (get-type @iyye_ai))
-      ((get-function @iyye_is_type) (get-type @iyye_yumzya) (get-type @iyye_human)))))
+      ((get-function @iyye_is_type) [(get-type @iyye_ai) (get-type @iyye_actor)])
+      ((get-function @iyye_is_type) [(get-type @iyye_human) (get-type @iyye_actor)])
+      ((get-function @iyye_is_type) [(get-type @iyye_iyye) (get-type @iyye_ai)])
+      ((get-function @iyye_is_type) [(get-type @iyye_yumzya) (get-type @iyye_human)]))))

 (defn- init-builtins-kb []
   (init-builtin-words)


Add piggieback middleware to repl

Add piggieback middleware to repl

--- src/leiningen/new/chestnut/project.clj
+++ src/leiningen/new/chestnut/project.clj
@@ -33,7 +33,8 @@
                                         :optimizations :none
                                         :pretty-print  true}}}}

-  :profiles {:dev {:repl-options {:init-ns {{name}}.server}
+  :profiles {:dev {:repl-options {:init-ns {{name}}.server
+                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
                    :plugins [[lein-figwheel "0.1.4-SNAPSHOT"]]
                    :figwheel {:http-server-root "public"
                               :port 3449 }


Clarify resolve-schema docstring

Clarify resolve-schema docstring

--- src/main/cljc/mikron/runtime/core.cljc
+++ src/main/cljc/mikron/runtime/core.cljc
@@ -26,7 +26,7 @@
   schema-name)

 (defn resolve-schema
-  "Returns a resolved schema for the given argument."
+  "Returns a reified schema for the given argument."
   ^Schema [arg]
   (or (and (schema? arg) arg)
       (@registry-ref arg)


'Remember me' field behavior is different in different modes

--- src/zg/html_renderer.clj
+++ src/zg/html_renderer.clj
@@ -65,15 +65,32 @@
                 (form/submit-button {:class "btn btn-default"} "Remember me")]]))

 (defn tab-class
+    "In the tab menu on top, only one item could be actived."
     [active mode]
     (if (= active mode)
-    {:class "active"}))
+        {:class "active"}))
+
+(defn user-href
+    "Generator for href to the page containing user info."
+    [user-name mode]
+    (let [destination (if (= mode :whitelist)
+                          "user-whitelist"
+                          "user-blacklist")]
+        [:a {:href (str destination "?name=" user-name)} user-name]))

 (defn users-href
+    "Generator for URL used by 'Users' menu item."
     [url-prefix mode]
     (if (= mode :whitelist)
         (str url-prefix "users-whitelist")
         (str url-prefix "users-blacklist")))
+
+(defn remember-me-href
+    "Generator for URL used by 'remember me' button."
+    [url-prefix mode]
+    (if (= mode :whitelist)
+        (str url-prefix "whitelist")
+        (str url-prefix "blacklist")))

 (defn render-navigation-bar-section
     "Renders whole navigation bar."
@@ -93,7 +110,7 @@
                     ]
                 ] ; col-md-7 ends
                 [:div {:class "col-md-3"}
-                    (render-name-field user-name url-prefix)
+                    (render-name-field user-name (remember-me-href url-prefix mode))
                 ]
                 [:div {:class "col-md-2"}
                     [:div {:class "navbar-header"}
@@ -101,7 +118,7 @@
                     ] ; ./navbar-header
                 ] ; col ends
             ] ; row ends
-        ] ; /.container-fluid
+        ] ; </div .container-fluid>
 ]); </nav>

 (defn render-error-page


Entities are not created when projectId is not found.

--- src/kixi/hecuba/amon.clj
+++ src/kixi/hecuba/amon.clj
@@ -252,16 +252,20 @@

   :post!
   (fn [{{body :body} :request}]
-    (let [entity (-> body read-json-body ->shallow-kebab-map)]
-      {:entity-id (upsert! commander :entity entity)}))
+    (let [entity     (-> body read-json-body ->shallow-kebab-map)
+          project-id (-> entity :project-id)]
+      (when-not (empty? (item querier :project project-id))
+        {:entity-id (upsert! commander :entity entity)})))

   :handle-created
   (fn [{{routes :modular.bidi/routes} :request id :entity-id}]
-    (let [location (path-for routes (:entity @handlers) :entity-id id)]
-      (when-not location
-        (throw (ex-info "No path resolved for Location header"
-                        {:entity-id id})))
-      (ring-response {:headers {"Location" location}}))))
+    (if-not (empty? id)
+      (let [location (path-for routes (:entity @handlers) :entity-id id)]
+        (when-not location
+          (throw (ex-info "No path resolved for Location header"
+                          {:entity-id id})))
+        (ring-response {:headers {"Location" location}}))
+      (ring-response {:status 404 :body "Provided projectId not found."}))))

 (defresource entity [{:keys [commander querier]} handlers]
   :allowed-methods #{:get :delete}


refactor binary write and read

refactor binary write and read

--- src/konserve/nodejs.cljs
+++ src/konserve/nodejs.cljs
@@ -2,11 +2,13 @@
   (:require [cljs.nodejs :as node]
             [konserve.core :as k]
             [hasch.core :refer [uuid]]
+            [fressian-cljs.core :as fress]
             [konserve.serializers :as ser]
             [konserve.protocols :refer [PEDNAsyncKeyValueStore -exists? -get-in -update-in -assoc-in -dissoc
                                         PJSONAsyncKeyValueStore -jget-in -jassoc-in -jupdate-in
                                         PBinaryAsyncKeyValueStore -bget -bassoc
                                         -serialize -deserialize]]
+            [cljs-node-io.core :as io :refer [slurp spit]]
             [cljs.core.async :as async :refer (take! <! >! put! close! chan poll!)])
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]))

@@ -47,45 +49,110 @@
         (println err)))))

 (defn write-edn-key [folder {:keys [key] :as meta}]
-  (let [key       (uuid key)
+  (let [key       (uuid (first key))
         temp-file (str folder "/meta/" key ".new")
         new-file  (str folder "/meta/" key)
         fd        (.openSync fs new-file "w+")
         _         (.closeSync fs fd)
-        ws        (.createWriteStream fs temp-file)]
-    (.on ws "close" #(try (.renameSync fs temp-file new-file) (catch js/Object err (println err))))
-    (.on ws "error" (fn [err] (println "error: " err)))
-    (.write ws (prn-str meta))
-    (.end ws)))
+        ws        (.createWriteStream fs temp-file)
+        res-ch (chan)]
+    (.on ws "close" #(try (.renameSync fs temp-file new-file)
+                          (catch js/Object err
+                            (put! res-ch (ex-info "Could not write edn key."
+                                                  {:type      :write-edn-key-error
+                                                   :key       key
+                                                   :exception err}))
+                            (close! res-ch))
+                          (finally (close! res-ch))))
+    (.on ws "error"
+         (fn [err]
+           (put! res-ch (ex-info "Could not write edn key."
+                                 {:type      :write-edn-key-error
+                                  :key       key
+                                  :exception err}))
+           (close! res-ch)))
+    (.write ws (js/Uint8Array. (fress/write meta)))
+    (.end ws)
+    res-ch))

 (defn write-edn [folder key up-fn]
-  (let [key       (uuid key)
+  (let [key       (uuid (first key))
         temp-file (str folder "/data/" key ".new")
         new-file  (str folder "/data/" key)
         res-ch    (chan)]
     (if (.existsSync fs new-file)
       (let [rs (.createReadStream fs new-file)]
-        (println "file exist")
         (.on rs "data" (fn [chunk]
-                         (let [old (cljs.reader/read-string (.toString chunk))
+                         (let [old (fress/read (. chunk -buffer))
                                ws  (.createWriteStream fs temp-file)
                                value     (up-fn old)]
                            (.on ws "finish" #(put! res-ch [old value]))
-                           (.on ws "error" (fn [err] (close! res-ch) (println "error: " err)))
-                           (.write ws (prn-str value))
+                           (.on ws "error"
+                                (fn [err]
+                                  (put! res-ch (ex-info "Could not write edn."
+                                                        {:type      :write-edn-error
+                                                         :key       key
+                                                         :exception err}))
+                                  (close! res-ch)))
+                           (.write ws (js/Uint8Array. (fress/write value)))
                            (.close ws))))
         (.on rs "close" (fn [] (.renameSync fs temp-file new-file) (close! res-ch)))
-        (.on rs "error" (fn [err] (close! res-ch) (println "error: " err))))
+        (.on rs "error" (fn [err]
+                          (put! res-ch (ex-info "Could not write edn."
+                                                {:type      :write-edn-error
+                                                 :key       key
+                                                 :exception err}))
+                          (close! res-ch))))
       (let [fd        (.openSync fs new-file "w+")
             _         (.closeSync fs fd)
             ws        (.createWriteStream fs temp-file)
-            value     (up-fn)]
-        (println "file not exist")
+            value     (up-fn nil)]
+        (.on ws "finish" #(put! res-ch [nil value]))
         (.on ws "close" #(try
                            (.renameSync fs temp-file new-file)
-                           (catch js/Object err (println err))))
-        (.write ws (prn-str value))
+                           (catch js/Object err
+                             (put! res-ch (ex-info "Could not write edn."
+                                                   {:type      :write-edn-error
+                                                    :key       key
+                                                    :exception err}))
+                             (close! res-ch))))
+        (.write ws (js/Uint8Array. (fress/write value)))
         (.end ws)))
+    res-ch))
+
+(defn write-binary [folder key input]
+  (let [res-ch (chan)]
+    (try
+      (let [fn        (uuid key)
+            temp-file (str folder "/data/" fn ".new")
+            new-file  (str folder "/data/" fn)
+            ws        (.createWriteStream fs temp-file)
+            input     (if (js/Buffer.isBuffer input)
+                        (let [stream (stream.PassThrough)
+                              _      (.end stream input)]
+                          stream)
+                        (if (instance? stream input)
+                          input
+                          (throw (js/Error. "Invalid input type"))))]
+        (.on ws "finish" #(println "tempfile writing done"))
+        (.on ws "close" #(try
+                           (.renameSync fs temp-file new-file)
+                           (catch js/Object err
+                             (put! res-ch (ex-info "Could not write binary."
+                                                   {:type      :write-binary-error
+                                                    :key       key
+                                                    :exception err})))
+                           (finally
+                             (.unpipe input ws)
+                             (put! res-ch true)
+                             (close! res-ch))))
+        (.pipe input ws))
+      (catch js/Object err
+        (put! res-ch (ex-info "Could not write binary."
+                              {:type      :write-binary-error
+                               :key       key
+                               :exception err}))
+        (close! res-ch)))
     res-ch))

 (defn read-edn [path key]
@@ -93,12 +160,59 @@
         res-ch    (chan)]
     (if (.existsSync fs file-name)
       (let [rs      (.createReadStream fs file-name)]
-        (.on rs "data" (fn [chunk] (put! res-ch  (cljs.reader/read-string (.toString chunk)))))
+        (.on rs "data" (fn [chunk] (put! res-ch  (fress/read (. chunk -buffer)))))
         (.on rs "close" #(close! res-ch))
-        (.on rs "error" (fn [err] (close! res-ch) (println "error: " err))))
+        (.on rs "error" (fn [err]
+                          (put! res-ch (ex-info "Could not read edn."
+                                                {:type      :read-edn-error
+                                                 :key       key
+                                                 :exception err}))
+                          (close! res-ch))))
       (do (put! res-ch "File not exist")
           (close! res-ch)))
     res-ch))
+
+(defn read-edn-key [path key]
+  (let [file-name (str path "/meta/" key)
+        res-ch    (chan)]
+    (if (.existsSync fs file-name)
+      (let [rs      (.createReadStream fs file-name)]
+        (.on rs "data" (fn [chunk] (put! res-ch  (fress/read (. chunk -buffer)))))
+        (.on rs "close" #(close! res-ch))
+        (.on rs "error" (fn [err]
+                          (put! res-ch (ex-info "Could not read edn key."
+                                                {:type      :read-edn-key-error
+                                                 :key       key
+                                                 :exception err}))
+                          (close! res-ch))))
+      (do (put! res-ch "File not exist")
+          (close! res-ch)))
+    res-ch))
+
+(defn read-binary
+  "return read stream"
+  [folder key locked-cb]
+  (let [res       (chan)
+        file-id   (uuid key)
+        file-name (str folder "/data/" file-id)]
+    (if (.existsSync fs file-name)
+      (let [rs (.createReadStream fs file-name)]
+        (.on rs "close" #(close! res))
+        (.on rs "error" (fn [err]
+                          (put! res (ex-info "Could not read binary."
+                                                {:type      :read-binary-error
+                                                 :key       key
+                                                 :exception err}))
+                          (close! res)))
+        (go
+          (<! (locked-cb {:read-stream rs}))
+          (put! res "File not exist")
+          (close! res))))
+    res))
+
+(defn list-keys [{:keys [folder]}]
+  (doseq [id (filter #(re-matches #"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" %) (js->clj (.readdirSync fs "/tmp/mystore/meta")))]
+    (go (println (<! (read-edn-key folder id))))))

 (defn delete-entry [folder file-name res-ch]
   (let [key-file (str folder "/meta/" file-name)
@@ -108,7 +222,7 @@
                (if err
                  (if (= (aget err "code") "ENOENT")
                    (do (put! res-ch "File not exist")
-                       (close! res-ch err))
+                       (close! res-ch))
                    (throw err))
                  (do (.unlink fs data-file
                               (fn [err]
@@ -130,14 +244,18 @@
   (-get-in [this key-vec]
     (read-edn folder (first key-vec)))
   (-update-in [this key-vec up-fn]
-    (go (write-edn-key folder {:key (first key-vec) :format :edn}))
-        (write-edn folder (first key-vec) up-fn))
+    (go (<! (write-edn-key folder {:key key-vec :format :edn}))
+        (<! (write-edn folder key-vec up-fn))))
   (-assoc-in [this key-vec val] (-update-in this key-vec (fn [_] val)))
-  (-dissoc [this key]
-    (let [fn (uuid key)
-          res-ch (chan)]
-      (delete-entry folder fn res-ch)
-      res-ch)))
+  (-dissoc [this key] (let [fn (uuid key)
+                            res-ch (chan)]
+                        (delete-entry folder fn res-ch)
+                        res-ch))
+  PBinaryAsyncKeyValueStore
+  (-bget [this key locked-cb] (read-binary folder key locked-cb))
+  (-bassoc [this key input] (do (write-edn-key folder {:key key :format :binary})
+                                (println "start write binary")
+                                (write-binary folder (first key) input))))

 (defn new-fs-store
   "Filestore contains a Key and a Data Folder"
@@ -158,69 +276,146 @@
                                      :locks          (atom {})
                                      :config         config}))))

+
 (comment
-  ;create store
+                                        ;create store
   (go (def store (<! (new-fs-store "/tmp/mystore"))))

-  (delete-store "mystore")
-  ;exists?
-
+  (delete-store "/tmp/mystore")
+
+  ;;EDN read/write functionality
   (go (println (<! (-assoc-in store [:new] 43))))
-  (go (println (<! (-exists? store :new))))
+
+  (go (println (<! (-exists? store :new))))
   (go (println (<! (-update-in store [:new] inc))))
-  (go (println (<! (-get-in store [:new]))))
+  (go (def x (<! (-get-in store [:new]))))
   (go (println (<! (-dissoc store :new))))
-
-
-;;Input, Outputstream
-
-(def my-obj (clj->js {:key "123" :format :edn}))
-
-(defn- read-key
-  [filename key]
-  (when (.existsSync fs path)
-    (let [rs (.createReadStream fs path)]
-      (.on rs "data" (fn [chunk] (set! scope (.toString chunk))))
-      (.on rs "close" #(println "Reading done"))
-      (.on rs "error" (fn [err] (println "error: " err))))))
-
-
-
-
-
-
-
-
-
-
-(write-edn-key "/tmp" {:key "123" :format :edn})
-
-
-
-
-
-
-(def rc (chan))
-
-(go (println (<! (read-edn "/tmp" "123"))))
-
-(defn read-my-key []
-  (let [value (js-obj)]
-    (go (set! (.-var value) (<! (read-edn "/tmp" "123"))))
-    value))
-
-(read-my-key)
-
-(write-edn "myfile.txt" "Hello World")
-
-(take! (read-edn "/tmp" "123") #(println %))
-
-(def myatom (atom {}))
-
-(poll! (read-edn "/tmp" "123"))
-
-(async/reduce (<! (read-edn "/tmp" "123")))
-
-;read back use -> cljs.reader/read-string
-(cljs.reader/read-string (prn-str {:x "123" :y "123"}))
-
+  (doseq [i (range 1 10)]
+    (go (<! (-assoc-in store [i] (+ i i)))))
+  ;;Binary read/write functionality
+  (go (println (<! (-bassoc store [:bin1ary] (js/Buffer.from #js [1 2 3 4])))))
+
+  ;,invalid input for write binary
+
+  (go (println (<! (-bassoc store [:binary] (.createReadStream fs "/tmp/mystore/data/2d081fba-8060-59dd-aa19-7b61d4a2d504")))))
+
+
+  (go (println (<! (-bassoc store [:binary] "123"))))
+
+
+  (go (<! (-bget store [:binary] #(println %))))
+
+
+  (prn "123")
+
+  (ex-info "Write binary input is not a stream or buffer."
+           {:type      :write-binary-error
+            :key       key
+            :exception err})
+
+
+
+  (instance? #object[ReadStream] "123")
+
+  (type (.createReadStream fs "/tmp/mystore/data/2d081fba-8060-59dd-aa19-7b61d4a2d504"))
+
+  (type (.createReadStream fs "/tmp/mystore/data/2d081fba-8060-59dd-aa19-7b61d4a2d504"))
+
+  (def inMemory (atom nil))
+
+  (go (.pipe (<! (-bget store :binary #())) (.createWriteStream fs "temp1234")))
+
+
+  ;; TODO no vector for key
+  (go (<! (-bget store [:binary] #(.pipe (:read-stream %)
+                                         (.createWriteStream fs "temp1234")))))
+
+  (go (<! (-bget store [:binary] #(-bassoc store [:other-binary] (:read-stream %)))))
+
+  ;;Copy binary
+
+(def mybuf (js/Buffer.from #js [1 2 3 4]))
+
+(def ymstream (stream.PassThrough))
+
+(.end ymstream mybuf)
+
+(type ymstream)
+
+(time (spit "xwerqwer" "qwerqwerqwer"))
+
+(time )
+
+(time (write-binary "/tmp/mystore" "12341234" "1234123412341234"))
+
+
+(slurp "myfile")
+
+
+
+
+
+
+
+
+
+(go
+  (let [[err] (<! (io/aspit "data.edn" data))]
+            (if-not err
+              (println "you've successfully written to 'data.edn'")
+              (println "there was an error writing: " err))))
+
+(go
+  (let [[err datastring] (<! (io/aslurp "data.edn"))]
+    (if-not err
+      (handle-data (read-string datastring))
+      (handle-error err))))
+
+
+
+
+(type ymstream)
+
+(if (js/Buffer.isBuffer mybuf)
+  (println "i a m buffer")
+  false)
+
+(def new-array (apply vector (range 1 10)))
+
+new-array
+
+(def myarray )
+
+myarray
+
+
+(go (println (<! (-bassoc store :testy ))))
+
+(uuid :testy)
+
+(go (.pipe (<! (-bget store :testy)) (.createWriteStream fs "/tmp/1234")))
+
+
+(list-keys store)
+
+(go (<! (write-binary-new "/tmp/mystore" "123" mybuf)))
+
+
+(write-binary-new "/tmp/mystore" "123" mybuf)
+
+
+
+
+(def mychan (chan))
+
+(put! mychan (ex-info "Could not write binary."
+                      {:type      :write-binary-error
+                       :key       "123"
+                       :exception "123"}))
+
+(take! mychan #(prn %))
+
+
+)
+
+


focussing url bar highlights url

focussing url bar highlights url

--- src/lt/objs/browser.cljs
+++ src/lt/objs/browser.cljs
@@ -168,7 +168,9 @@
 (behavior ::url-focus!
                   :triggers #{:url.focus!}
                   :reaction (fn [this]
-                              (dom/focus (dom/$ :input (object/->content this)))))
+                              (let [url-input (dom/$ :input (object/->content this))]
+                                (dom/focus url-input)
+                                (.select url-input))))

 (behavior ::focus!
                   :triggers #{:focus!}


Add home page content

Add home page content

--- src/micro_logic/core.clj
+++ src/micro_logic/core.clj
@@ -1,3 +1,53 @@
+;; # microLogic
+;; A literate Clojure implementation of microKanren.
+;;
+;; It may also be a suitable base for experimenting with new logic
+;; programming ideas, because of its simplicity.
+;;
+;; ## Differences from microKanren
+;; Polymorphic dispatch via protocols is used in place of `(cond)` with
+;; type checks, where possible.
+;;
+;; Clojure-native datatypes are used where appropriate
+;; - The substitution map is a clojure map instead of an alist
+;; - There is an LVar defrecrord, instead of using a vector of c
+;; - We have an explicit StreamNode data type, rather building on the
+;;   built-in list type
+;; - Clojure doesn't allow improper lists; LListCell is a linked list
+;;   which does.
+;;
+;; Many names have changed to be more clojure-like:
+;;
+;;     |uKanren | microLogic          |
+;;     |--------|---------------------|
+;;     |mplus   | merge-streams       |
+;;     |bind    | mapcat-stream       |
+;;     |pull    | realize-stream-head |
+;;     |mzero   | empty-stream        |
+;;     |unit    | stream              |
+;;     |Zzz     | delay-goal          |
+;;     |conj    | lconj               |
+;;     |disj    | ldisj               |
+;;     |==      | ===                 |
+;;
+;; ## Differences from core.logic
+;;     |core.logic | microLogic           |
+;;     |-----------|----------------------|
+;;     |mplus      | merge-streams        |
+;;     |bind       | mapcat-stream        |
+;;     |pull       | realize-stream-head  |
+;;     |mzero      | empty-stream         |
+;;     |unit       | stream               |
+;;     |==         | ===                  |
+;;     |LCons      | LListCell            |
+;;
+;; ## References
+;; - This is largely based on [microKanren](http://webyrd.net/scheme-2013/papers/HemannMuKanren2013.pdf), a minimal version of miniKanren
+;; - The microKanren [scheme implementation](https://github.com/jasonhemann/microKanren)
+;; - [core.logic](https://github.com/clojure/core.logic), Clojure's real miniKanren implementation
+;; - Will Byrd's [dissertation on miniKanren](https://github.com/webyrd/dissertation-single-spaced/raw/master/thesis.pdf)
+
+
 (ns micro-logic.core
   (:require [micro-logic.protocols :refer :all]))


Add more tests

Add more tests

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -1,5 +1,6 @@
 (ns clojurewerkz.cassaforte.new-query-api-test
   (:refer-clojure :exclude [update])
+  (:import [com.datastax.driver.core.utils Bytes])
   (:require [clojure.test                          :refer :all]
             [clojurewerkz.cassaforte.new-query-api :refer :all]
             ))
@@ -17,6 +18,11 @@
          (select "table-name"
                  (columns "first" "second"))))

+  (is (= "SELECT * FROM foo WHERE foo=1 AND bar=2;"
+         (select :foo
+                 ;; Normally, hashmap can be used. Array map is used here to guarantee order.
+                 (where (array-map :foo 1
+                                   :bar 2)))))
   (is (=  "SELECT * FROM foo WHERE foo='bar' AND moo>3 AND meh>4 AND baz IN (5,6,7);"
           (select :foo
                   (where [[:= :foo "bar"]
@@ -118,34 +124,51 @@
                         (cname "b")))))

+  (is (= "SELECT * FROM foo WHERE k>42 LIMIT 42;";
+         (select :foo
+                 (where [[:> :k 42]])
+                 (limit 42))))
+
+  (is (= "SELECT * FROM foo WHERE token(k)>token(42);"
+         (select :foo
+                 (where [[:> (token "k") (function-call "token" 42)]]))))
+
+  (is (= "SELECT * FROM foo2 WHERE token(a,b)>token(42,101);";
+         (select :foo2
+                 (where [[:> (token "a" "b") (function-call "token" 42 101)]]))))
+
+  (is (= "SELECT * FROM words WHERE w='):,ydL ;O,D';"
+         (select :words
+                 (where {:w "):,ydL ;O,D"}))))
+
+  (is (= "SELECT * FROM words WHERE w='WA(!:gS)r(UfW';"
+         (select :words
+                 (where {:w "WA(!:gS)r(UfW"}))))
+
+  (is (= "SELECT * FROM foo WHERE d=1234325;"
+         (select :foo
+                 (where {:d (java.util.Date. 1234325)}))))
+
+  (is (= "SELECT * FROM foo WHERE b=0xcafebabe;"
+         (select :foo
+                 (where {:b (Bytes/fromHexString "0xCAFEBABE")}))))
+
+  (is (thrown? java.lang.IllegalStateException
+       (select :foo
+               (count-all)
+               (order-by (asc "a") (desc "b"))
+               (order-by (asc "a") (desc "b")))))
+
+  (is (thrown? java.lang.IllegalArgumentException
+               (select :foo
+                       (limit -42))))
+
+  (is (thrown? java.lang.IllegalStateException
+               (select :foo
+                       (limit 42)
+                       (limit 42))))
   )

-
-;;
-;; select().fcall("intToBlob", column("b")).from("foo");
-
-;; "SELECT * FROM foo WHERE k>42 LIMIT 42;";
-;; select().all().from("foo").where(gt("k", 42)).limit(42);
-
-;; "SELECT * FROM foo WHERE token(k)>token(42);";
-;; select().all().from("foo").where(gt(token("k"), fcall("token", 42)));
-
-;; "SELECT * FROM foo2 WHERE token(a,b)>token(42,101);";
-;; select().all().from("foo2").where(gt(token("a", "b"), fcall("token", 42, 101)));
-
-;; "SELECT * FROM words WHERE w='):,ydL ;O,D';";
-;; select().all().from("words").where(eq("w", "):,ydL ;O,D"));
-
-;; "SELECT * FROM words WHERE w='WA(!:gS)r(UfW';";
-;; select().all().from("words").where(eq("w", "WA(!:gS)r(UfW"));
-
-;; Date date = new Date();
-;; date.setTime(1234325);
-;; "SELECT * FROM foo where d=1234325";
-;; select().all().from("foo").where(eq("d", date));
-
-;; "SELECT * FROM foo where b=0xCAFEBABE";
-;; select().all().from("foo").where(eq("b", Bytes.fromHexString("0xCAFEBABE")));

 ;; select().countAll().from("foo").orderBy(asc("a"), desc("b")).orderBy(asc("a"), desc("b"));
 ;; select().column("a").all().from("foo");


Remove title repeatition from email preheader. Increase the whitespaces after that.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -357,11 +357,11 @@
       (format digest-title-daily "at" org-name)
       (format digest-title-daily "in" "Carrot"))))

-(defn- hidden-digest-headline [digest-data]
+(defn- digest-preheader [digest-data]
   (let [org-name (:org-name digest-data)
         weekly? (weekly-digest? digest-data)]
     [:span.hidden
-      (str (digest-title org-name weekly?) ". See the latest updates from your team." (s/join (repeat 100 " ")))]))
+      (str "See the latest updates from your team." (s/join (repeat 120 " ")))]))

 (defn- get-digest-url [digest-data]
   (s/join "/" [config/web-url (:org-slug digest-data) "all-posts"]))
@@ -636,7 +636,7 @@
       (when (= (:type data) :digest)
         (go-to-posts-script data))
       (when (= type :digest)
-        (hidden-digest-headline data))
+        (digest-preheader data))
       [:table {:class "body"
                :with "100%"}
         [:tr


s/POSITION/NODE-POSITION

s/POSITION/NODE-POSITION

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -14,7 +14,7 @@
 ;; and group zero is the root of the graph.  Nodes can be added to a group in
 ;; one of these 5 positions relative to either the full list, or a specified node.

-(def POSITION
+(def NODE-POSITION
   {:head         0
    :tail         1
    :before       2
@@ -99,7 +99,7 @@
      (if (not (server-connected?))
        (throw (Exception. "Not connected to synthesis engine.  Please boot or connect server.")))
      (let [id       (alloc-id :node)
-           position (or ((get location :position :tail) POSITION) 1)
+           position (or ((get location :position :tail) NODE-POSITION) 1)
            target   (to-synth-id (get location :target 0))
            arg-map  (map-and-check-node-args arg-map)
            args     (flatten (seq arg-map))
@@ -185,11 +185,12 @@
   ([] (group :tail (root-group)))
   ([position target] (group (alloc-id :node) position target))
   ([id position target]
-     (let [pos (if (keyword? position) (get POSITION position) position)
+     (let [pos    (if (keyword? position) (get NODE-POSITION position) position)
            target (to-synth-id target)
-           pos (or pos 1)
-           snode    (SynthGroup. id target position (atom :loading))]
-       (snd "/g_new" id pos target)
+           pos    (or pos 1)
+           snode  (SynthGroup. id target position (atom :loading))]
+       (if (server-connected?)
+         (snd "/g_new" id pos target))
        (swap! active-synth-nodes* assoc id snode)
        snode)))


use allocation handler-fns

use allocation handler-fns

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -100,14 +100,12 @@
   "Remove a synth node."
   [& node-ids]
   {:pre [(connected?)]}
-  (apply snd "/n_free" node-ids)
-  (doseq [id node-ids] (free-id :node id)))
+  (doseq [id node-ids] (free-id :node id 1 #(snd "/n_free" id))))

 (defn- node-destroyed
   "Frees up a synth node to keep in sync with the server."
   [id]
-  (log/debug (format "node-destroyed: %d" id))
-  (free-id :node id))
+  (free-id :node id 1 #(log/debug (format "node-destroyed: %d" id))))

 (defn- node-created
   "Called when a node is created on the synth."


Fixed bug in comment vote counting

Fixed bug in comment vote counting

--- src/polismath/export.clj
+++ src/polismath/export.clj
@@ -92,7 +92,7 @@
 (defn get-conversation-votes
   [& args]
   ;; Flip the signs on the votes XXX (remove when we switch)
-  (map  #(update-in % [:vote] (partial * -1))
+  (map #(update-in % [:vote] (partial * -1))
        (apply get-conversation-votes* args)))

 (defn get-conversation-data
@@ -302,8 +302,8 @@
   "Just adds vote counts to the comments data"
   [comments votes]
   (map
-    (fn [{:keys [pid] :as comment-data}]
-      (let [comment-votes (filter #(= pid (:pid %)) votes)
+    (fn [{:keys [tid] :as comment-data}]
+      (let [comment-votes (filter #(= tid (:tid %)) votes)
             ;; Fixed this upstream, for now; so should be good to go once we've fixed it at the source. But
             ;; keep an eye on it for now... XXX
             aggrees (filter #(= 1 (:vote %)) comment-votes)


Fixes invariants for scheduler test.

Fixes invariants for scheduler test.

--- test/onyx/scheduler/scheduler_test.clj
+++ test/onyx/scheduler/scheduler_test.clj
@@ -17,6 +17,10 @@
           {:jobs [:j1 :j2]
            :allocations initial-allocations
            :peers [:p1 :p2 :p3 :p4 :p5 :p6 :p7 :p8 :p9 :p10]
+           :peer-state {:p1 :active :p2 :active :p3 :active
+                        :p4 :active :p5 :active :p6 :active
+                        :p7 :active :p8 :active :p9 :active
+                        :p10 :active}
            :tasks {:j1 [:t1 :t2 :t3]
                    :j2 [:t4 :t5]}
            :saturation {:j1 5 :j2 5}
@@ -35,6 +39,9 @@
          :allocations {:j1 {:t1 [:p4] :t2 [:p2] :t3 [:p7]}
                        :j2 {:t4 [:p6] :t5 [:p3] :t6 [:p1]}}
          :peers [:p1 :p2 :p3 :p4 :p5 :p6 :p7]
+         :peer-state {:p1 :active :p2 :active :p3 :active
+                      :p4 :active :p5 :idle :p6 :active
+                      :p7 :active}
          :tasks {:j1 [:t1 :t2 :t3] :j2 [:t4 :t5 :t6]}
          :task-schedulers {:j1 :onyx.task-scheduler/balanced
                            :j2 :onyx.task-scheduler/balanced}
@@ -153,6 +160,8 @@
                             :t2 [:p2 :p3 :p4]
                             :t3 [:p5]}}
          :peers [:p1 :p2 :p3 :p4 :p5 :p6]
+         :peer-state {:p1 :active :p2 :active :p3 :active
+                      :p4 :active :p5 :active :p6 :idle}
          :tasks {:j1 [:t1 :t2 :t3]}
          :flux-policies {:j1 {:t2 :kill}}
          :task-saturation {:j1 {:t1 100 :t2 100 :t3 100}}
@@ -170,6 +179,8 @@
                             :t2 [:p2 :p3]
                             :t3 [:p4]}}
          :peers [:p1 :p2 :p3 :p4 :p5]
+         :peer-state {:p1 :active :p2 :active :p3 :active
+                      :p4 :active :p5 :idle}
          :tasks {:j1 [:t1 :t2 :t3]}
          :flux-policies {:j1 {:t2 :recover}}
          :task-saturation {:j1 {:t1 100 :t2 3 :t3 100}}
@@ -205,6 +216,7 @@
          :allocations {:j1 {:t1 [:p1]
                             :t2 [:p2 :p3]}}
          :peers [:p1 :p2 :p3]
+         :peer-state {:p1 :active :p2 :active :p3 :active}
          :tasks {:j1 [:t1 :t2]}
          :task-schedulers {:j1 :onyx.task-scheduler/balanced}
          :job-scheduler :onyx.job-scheduler/balanced


Remove unused href

Remove unused href

--- src/app/core.cljs
+++ src/app/core.cljs
@@ -112,8 +112,7 @@
              [:ul
               (map (fn [[key text]]
                      [:li (if (= selected [key]) {:class "selected"} {})
-                      [:a {:href "#"
-                           :onClick #(do (reset-all! owner)
+                      [:a {:onClick #(do (reset-all! owner)
                                          (om/update! selected 0 key))}
                        text]])
                    (partition 2 [:details       "Details"


fixes unverified SSL certificate problem, makes the mp3 links work again

--- src/qcast/infoq/site.clj
+++ src/qcast/infoq/site.clj
@@ -23,6 +23,7 @@

 (def ^:private http-options
   {:headers {"User-Agent" ios-user-agent}
+   :insecure? true
    :as      :stream})


Test argument should be an integer

Test argument should be an integer

--- test/desdemona/cli_test.clj
+++ test/desdemona/cli_test.clj
@@ -1,6 +1,7 @@
 (ns desdemona.cli-test
   (:require
    [desdemona.launcher.aeron-media-driver :as aeron]
+   [desdemona.launcher.launch-prod-peers :as peers]
    [desdemona.launcher.utils :as utils]
    [clojure.test :refer [deftest testing is]]
    [clojure.string :as s]
@@ -88,3 +89,8 @@
         (is (thrown-with-msg?
              Exception (re-pattern @#'aeron/aeron-launch-error-message)
              (with-fake-launcher-side-effects (aeron/-main))))))))
+
+(deftest peers-main-tests
+  (testing "first argument must be an integer"
+    (is (thrown-with-msg? NumberFormatException #"BOGUS"
+         (peers/-main "BOGUS")))))