use partition maps instead of schematode defs

--- src/hatch.clj
+++ src/hatch.clj
@@ -18,11 +18,6 @@
   [m prefix]
   (into {} (for [[k v] m] [(slam prefix k) v])))

-(defn get-partition
-  "Get the db partition entity type is in from a schematode definition."
-  [schema entity-type]
-  (or (get-in schema [entity-type :part])
-      :db.part/user))

 (defn ensure-db-id
   "Ensure an entity has a db/id using tempid."
@@ -30,8 +25,8 @@
      (if (nil? (:db/id entity))
        (merge {:db/id (d/tempid part)} entity)
        entity))
-  ([schema entity-type entity]
-     (ensure-db-id (get-partition schema entity-type) entity)))
+  ([partitions entity-type entity]
+     (ensure-db-id (entity-type partitions) entity)))

 (defn prune-entity
   "Prune an entity using attr-map and entity-type."
@@ -45,33 +40,38 @@

 (defn tx-clean-entity!
   "Clean up an entity (ensure it has a db/id and prune it), then transact it."
-  [schema attr-map db-conn entity-type entity]
+  [partitions attr-map db-conn entity-type entity]
   (->> entity
-       (ensure-db-id schema entity-type)
+       (ensure-db-id partitions entity-type)
        (prune-entity attr-map entity-type)
        (conj [])
        (tx! db-conn)))

 (comment

-  ;; callers should def their own schema
+  ;; Callers should def their own schema
   (def schematode-def
     [[:person {:attrs [[:name :string :db.unique/identity]
                        [:favorite-dessert :ref]]}]
      [:dessert {:attrs [[:name :string :db.unique/identity]]
                 :part :desserts}]])

-  ;; callers should def their own valid-attrs
+  ;; Callers should def their own partition map
+  (def partitions {:person :db.part/user
+                   :dessert :db.part/desserts})
+
+  ;; Callers should def their own valid-attrs. Attributes not in this
+  ;; map will be pruned by tx-clean-entity!
   (def valid-attrs {:person [:person/name :person/favorite-dessert]
                     :dessert [:dessert/name]})

   ;; callers should def their own tx-entity! fns kinda like this
-  (def tx-entity! (partial hatch/tx-clean-entity! schematode-def valid-attrs))
+  (def tx-entity! (partial hatch/tx-clean-entity! partitions valid-attrs))

   ;; galleon will do this init stuff
   (schematode/init-schematode-constraints! (:db-conn ht-config/system))
   (schematode/load-schema! (:db-conn ht-config/system) schematode-def)
-
+
   ;; callers can then do stuff like this
   (tx-entity! (:db-conn ht-config/system) :dessert {:dessert/name "ice cream"})
   (tx-entity! (:db-conn ht-config/system)


Filter some tests to be exected only on clojure and not clojurescript.

--- test/cats/core_spec.cljc
+++ test/cats/core_spec.cljc
@@ -98,30 +98,33 @@
                            [(maybe/just 1) (maybe/just 2)]))))))))

 (t/deftest fixed-arity-lift-m-tests
-  (let [monad+ (m/lift-m add2)]
-    (t/testing "It can lift a function to the vector monad"
-      (t/is (= [1 2 3 4 5 6]
-               (monad+ [0 2 4] [1 2]))))
+  #?(:clj
+     (let [monad+ (m/lift-m add2)]
+       (t/testing "It can lift a function to the vector monad"
+         (t/is (= [1 2 3 4 5 6]
+                  (monad+ [0 2 4] [1 2]))))))

-    (t/testing "It can lift a function to the Maybe monad"
+  (t/testing "It can lift a function to the Maybe monad"
+    (let [monad+ (m/lift-m 2 add2)]
       (t/is (= (maybe/just 6)
                (monad+ (maybe/just 2) (maybe/just 4))))
       (t/is (= (maybe/nothing)
-               (monad+ (maybe/just 1) (maybe/nothing)))))
+               (monad+ (maybe/just 1) (maybe/nothing))))))

-    (t/testing "Currying and lifting can be combined"
-      (let [curry-monad+ (m/curry-lift-m 2 add2)]
-        (t/is (= (maybe/just 6)
-                 ((curry-monad+ (maybe/just 1)) (maybe/just 5))))))
+  (t/testing "Currying and lifting can be combined"
+    (let [curry-monad+ (m/curry-lift-m 2 add2)]
+      (t/is (= (maybe/just 6)
+               ((curry-monad+ (maybe/just 1)) (maybe/just 5))))))

     (t/testing "It can lift a function to a Monad Transformer"
-      (let [maybe-sequence-monad (maybe/maybe-transformer b/sequence-monad)]
+      (let [maybe-sequence-monad (maybe/maybe-transformer b/sequence-monad)
+            monad+ (m/lift-m 2 add2)]
         (t/is (= [(maybe/just 1) (maybe/just 2)
                   (maybe/just 3) (maybe/just 4)
                   (maybe/just 5) (maybe/just 6)]
                  (m/with-monad maybe-sequence-monad
                    (monad+ [(maybe/just 0) (maybe/just 2) (maybe/just 4)]
-                           [(maybe/just 1) (maybe/just 2)]))))))))
+                           [(maybe/just 1) (maybe/just 2)])))))))

 (t/deftest filter-tests
   (t/testing "It can filter Maybe monadic values"
@@ -144,14 +147,15 @@
              (m/when false [])))))

 (t/deftest curry-tests
-  (t/testing "It can curry single and fixed arity functions automatically"
-    (let [cadd2 (m/curry add2)]
-      (t/is (= ((cadd2 1) 2)
-               3))
-      (t/is (= (cadd2)
-               cadd2))
-      (t/is (= (cadd2 1 2)
-               3))))
+  #?(:clj
+     (t/testing "It can curry single and fixed arity functions automatically"
+       (let [cadd2 (m/curry add2)]
+         (t/is (= ((cadd2 1) 2)
+                  3))
+         (t/is (= (cadd2)
+                  cadd2))
+         (t/is (= (cadd2 1 2)
+                  3)))))

   (t/testing "It can curry anonymous functions when providing an arity"
     (let [csum (m/curry 3 (fn [x y z] (+ x y z)))]


update-stringified-lists now accepts a vector of selectors

--- src/kixi/hecuba/webutil.clj
+++ src/kixi/hecuba/webutil.clj
@@ -38,11 +38,14 @@
 (defn json-list [items]
   (map encode items))

-(defn update-stringified-lists [body [selector]]
+(defn update-stringified-list [body selector]
   (if
     (contains? body selector)
     (update-in body [selector] json-list)
     (assoc body selector nil)))
+
+(defn update-stringified-lists [body selectors]
+  (reduce update-stringified-list body selectors))

 (defn authorized? [querier typ]
   (fn [{{route-params :route-params :as req} :request}]


Added a mode-frame? predicate.

Added a mode-frame? predicate.

--- src/mode.cljs
+++ src/mode.cljs
@@ -18,3 +18,7 @@
   (repeat (model :model/count)
     {:mode px-blink :params params}))

+(defn mode-frame? [value]
+  (and (contains? value :mode)
+       (contains? value :params)))
+


fix command is unsupported return value

fix command is unsupported return value

--- src/clj/com/jd/magpie/daemon/nimbus.clj
+++ src/clj/com/jd/magpie/daemon/nimbus.clj
@@ -161,12 +161,15 @@

 (defn operate-task
   "returncode -1 : unknown error
-               1 : task id not exists
+               1 : command is unsupported
+               2 : task id not exists
                0 : task id exists and command submit success"
   [zk-handler id command assignment-path status-path command-path]
   (let [commands (hash-set "kill" "pause" "active" "reload")]
     (if (not (contains? commands command))
-      (str command " command is unsupported!")
+      (utils/object->jsonstring {"info" (str command " command is unsupported!")
+                                 "success" false
+                                 "returncode" 1})
       (let [result (atom (utils/object->jsonstring {"info" (str command " failure!")
                                                     "success" false
                                                     "returncode" -1}))]
@@ -187,7 +190,7 @@
                   (log/info @result))
               (do (reset! result (utils/object->jsonstring {"info" (str command "command submitted error! task is not running, (task id='" id "')")
                                                             "success" false
-                                                            "returncode" 1}))
+                                                            "returncode" 2}))
                   (log/error @result))))
           (catch Throwable e
             (reset! result (utils/object->jsonstring {"info" (str e "Task " command " exception. (task id='" id "')")


make the actual function on import

make the actual function on import

--- src/cljs/infinitelives/pixi/events.cljs
+++ src/cljs/infinitelives/pixi/events.cljs
@@ -29,6 +29,12 @@

    :else
    #(.setTimeout js/window % (/ 1000 fallback-fps))))
+
+;; build the actual function
+(def
+  ^{:arglist '([callback])
+    :doc "schedules the passed in callback to be fired once, next animation frame."}
+  request-animation-frame (make-request-animation-frame))

 ;;


Make table fill whole screen horizontally.

--- src/clojure/my/stuff/fitlogger/main.clj
+++ src/clojure/my/stuff/fitlogger/main.clj
@@ -57,11 +57,14 @@
 (defn format-measurements [m]
   (apply conj [:table-row {}]
          (map (fn [[_ v]]
-                [:text-view {:text (format "%s" v), :padding 20}])
+                [:text-view {:text (format "%s" v)}])
               m)))

 (defn format-listing [lst]
-  (apply conj [:table-layout {:id :table}]
+  (apply conj [:table-layout {:id :table,
+                              :layout-width :fill,
+                              :layout-weight 1
+                              :stretch-all-columns true}]
          (map (fn [[_ measurements]]
                 (format-measurements measurements))
               lst)))
@@ -175,7 +178,8 @@
    [:button {:text "Add log",
              :on-click (fn [_]
                          (add-event activity))}]
-   [:scroll-view {}
+   [:scroll-view {:layout-width :fill,
+                  :layout-weight 1}
     (format-listing @listing)]])

 ;; This is how an Activity is defined. We create one and specify its onCreate


working on inner trace loop bindings

working on inner trace loop bindings

--- src/com/billpiel/sayid/inner_trace3.clj
+++ src/com/billpiel/sayid/inner_trace3.clj
@@ -199,6 +199,15 @@
          conj
          node-atom))

+(defn find-closest-parent
+  [path path-parents]
+  (clojure.pprint/pprint path)
+  (if-let [parent (path-parents path)]
+    parent
+    (when-not (or (nil? path) (empty? path))
+      (recur (drop-last path)
+             path-parents))))
+
 (defn mk-recent-tree-at-inner-path
   [path path-parents tree-atom]
   (if (= (count path) 1) ;; TODO is this the right way to detect root?
@@ -206,7 +215,8 @@
       (push-to-tree-atom!  new-tree
                            tree-atom)
       new-tree)
-    (let [parent (produce-recent-tree-atom! (path-parents path)
+    (let [parent (produce-recent-tree-atom! (find-closest-parent path
+                                                                 path-parents)
                                             path-parents
                                             tree-atom)
           new-tree (-> (trace/mk-tree :parent @parent)
@@ -339,6 +349,27 @@
   (or (meta form)
       (-> form first meta)))

+(defn tr-loop-bind
+  [template tree-atom v bnd-frm val-frm]
+  (-> (produce-recent-tree-atom! (:inner-path template)
+                                 (:path-parents template)
+                                 tree-atom)
+      deref
+      (update-in [:let-binds] conj [v bnd-frm val-frm])
+      (update-tree! tree-atom))
+  v)
+
+(defn xpand-loop-binds
+  [xbinds orig-binds path-sym]
+  (vec (mapcat (fn [[xb xv] [ob ov]]
+                 `(~ob (tr-loop-bind ~path-sym
+                                    ~'$$
+                                    ~xv
+                                    '~ob
+                                    '~ov)))
+               (partition 2 xbinds)
+               (partition 2 orig-binds))))
+
 (defn tr-loop
   [template tree-atom v]
   (-> (produce-recent-tree-atom! (:inner-path template)
@@ -352,15 +383,15 @@
   v)

 (defn xpand-loop-form
-  [[_ binds & body] path-sym recur-arities]
+  [[_ binds & body] orig-binds path-sym recur-arities]
   `(tr-loop ~path-sym
             ~'$$
-            (loop ~binds
+            (loop ~(xpand-loop-binds binds orig-binds path-sym)
               (let [~'$$return ~@body]
                 ~(mk-recur-handler recur-arities)))))

 (defn xpand-loop
-  [form src-map fn-meta path path-parent]
+  [[_ binds :as form] src-map fn-meta path path-parent]
   (let [xmap (xpand-all form
                         src-map
                         fn-meta
@@ -373,6 +404,7 @@
                                                              fn-meta
                                                              path)}
                           :form (xpand-loop-form (:form xmap)
+                                                 binds
                                                  (path->sym path)
                                                  (:recur xmap))})))

@@ -647,7 +679,7 @@
 (defn f2
   [a]
   (inc a)
-  (loop [b a]
+  (loop [b (+ a 0)]
     (if (< b 2)
       (recur (inc b))
       b)))
@@ -667,8 +699,8 @@

 #_ (binding [trace/*trace-log-parent* @com.billpiel.sayid.core/workspace]
      (let [f2 (inner-tracer {:qual-sym 'com.billpiel.sayid.inner-trace3/f2
-                            :meta' {:ns 'com.billpiel.sayid.inner-trace3
-                          :name 'com.billpiel.sayid.inner-trace3/f2}
-                            :ns' 'com.billpiel.sayid.inner-trace3})]
+                             :meta' {:ns 'com.billpiel.sayid.inner-trace3
+                                     :name 'com.billpiel.sayid.inner-trace3/f2}
+                             :ns' 'com.billpiel.sayid.inner-trace3})]
        (f2 1)
-#_       (clojure.pprint/pprint trace/*trace-log-parent*)))
+       (clojure.pprint/pprint trace/*trace-log-parent*)))


Comments re: curvecp client

Comments re: curvecp client

--- src/com/frereth/common/curve/client.clj
+++ src/com/frereth/common/curve/client.clj
@@ -745,6 +745,27 @@
   (when-not child-spawner
     (assert child-spawner (str "No way to spawn child.\nAvailable keys:\n"
                                (keys this))))
+  ;;; This needs to return something that, at least in theory,
+  ;;; should use send/send-off to notify the agent about bytes
+  ;;; that are buffered and ready to transmit.
+  ;;; Or maybe that should happen over the stream that I'm
+  ;;; storing in reader.
+  ;;; This part definitely needs more work.
+  ;;; Here's what seems like the #1 detail about the reference
+  ;;; implementation:
+  ;;; It's designed to spawn a child (cpcurvemessage, I think),
+  ;;; that in turn spawns the "real" child.
+  ;;; The middleware child passes chunks of data (in blocks
+  ;;; of [(/ 16 length) data]) back and forth as fast as
+  ;;; possible.
+  ;;; It has to cope with those data streams interrupting at
+  ;;; the drop of a hat.
+  ;;; This was because the protocol was really designed as
+  ;;; a user-space replacement for TCP that would allow
+  ;;; existing servers to continue to operate without any
+  ;;; code modifications.
+  ;;; Which is really freaking cool.
+  ;;; But it does tend to muddy the waters.
   (let [{:keys [::child ::reader ::writer]} (child-spawner wrapper)]
     (assoc this
            (send-off set-up-initial-read! wrapper wrapper reader)


Some more updates to API

Some more updates to API

--- src-cljs/firebase/main.cljs
+++ src-cljs/firebase/main.cljs
@@ -8,6 +8,9 @@
   "Makes a root reference for firebase"
   (js/Firebase. url))

+(defn- clj-val [v]
+  (js->clj (.val v) :keywordize-keys true))
+
 ;; A utility function to traverse through korks and get ref to a child object
 ;; [:hello :world :bye ] refers to hello.world.bye
 ;;
@@ -17,61 +20,75 @@
     (sequential? korks) (reduce #(.child %1 (name %2)) root korks)
     :else (.child root (name korks))))

+(defn- firebase-call!
+  "Set the value at the given root"
+  ([push-fn root val]
+   (let [as-js (clj->js val)]
+     (push-fn root as-js)))
+
+  ([push-fn root korks val]
+   (firebase-call! push-fn (reduce-to-element root korks) val)))
+
 ;; A function set the value on a root [korks]
 ;;
 (defn firebase-set!
   "Set the value at the given root"
   ([root val]
-   (let [as-js (clj->js val)]
-     (.set root as-js)))
+   (firebase-call! #(.set %1 %2) root val))

   ([root korks val]
-   (firebase-set! (reduce-to-element root korks) val)))
+   (firebase-call! #(.set %1 %2) root korks val)))

-;; Bind a callback to a root [korks]
-;;
-(defn firebase-bind [root korks cb]
-  "Bind to change notifications"
-  (let [c (reduce-to-element root korks)]
-    (.on c "value" #(cb (.val %1)))))
+(defn firebase-push!
+  "Set the value at the given root"
+  ([root val]
+   (firebase-call! #(.push %1 %2) root val))

-;; Bind a chan to a root [korks]
-;;
-(defn firebase-bind-chan [root korks]
-  "Bind and return an async channel to which any value changes are posted"
-  (let [c (reduce-to-element root korks)
-        bind-chan (chan)]
-    (.on c "value" #(go (>! bind-chan (.val %1))))
-    bind-chan))
+  ([root korks val]
+   (firebase-call! #(.push %1 %2) root korks val)))
+
+(defn firebase-bind
+  "Bind to a certain property under the given root"
+  ([root type korks]
+   (let [c (reduce-to-element root korks)
+         bind-chan (chan)]
+     (.on c (name type) #(go (>! bind-chan [type (clj-val %1)])))
+     bind-chan))
+
+  ([root type korks cb]
+   (let [c (reduce-to-element root korks)]
+     (.on c (name type) #(cb type (clj-val %1))))))

 ;; ;;;;;;;;;;;;;;;;;;;
 ;; Example usage
 ;;
 ;; Create a root which represents a firebase root
-(def root (make-root "https://<your-app>.firebaseio.com/"))
+(def root (make-root "https://<your app>.firebaseio.com/"))

-;; A simple utility function that prints the value posted to it
-;;
-(defn- print-val [val]
-  (.log js/console "Value:" val))
+(defn print-val [& xs]
+  (.log js/console (pr-str xs)))

 ;; Bind a function to a few values inside our root, the binding is modeled after core/get-in
 ;;
-(firebase-bind root [:info :world] print-val)
-(firebase-bind root [:info :test] print-val)
-(firebase-bind root :age print-val)
+(firebase-bind root :value [:info :world] print-val)
+(firebase-bind root :value [:info :test] print-val)
+(firebase-bind root :value :age print-val)

 ;; get a channel instead of passing a callback
 ;;
-(let [my-chan (firebase-bind-chan root [:info :test])]
+(let [my-chan (firebase-bind root :value [:info :test])]
   (go-loop [val (<! my-chan)]
-           (.log js/console "Got new value inside go loop:" val)
+           (.log js/console "Got new value inside go loop:" (pr-str val))
            (recur (<! my-chan))))
+
+(firebase-bind root :value :messages print-val)
+(firebase-bind root :child_added :messages print-val)

 ;; Finally set a few values
 ;;
 (firebase-set! root {:name "James Bond"
                      :age 94
+                     :messages {}
                      :info {:test "hello"
                             :world "bye"}})

@@ -79,5 +96,7 @@
 (firebase-set! root [:info :test] {:another "object"})
 (firebase-set! root :age 100)

+(firebase-push! root :messages {:message "hello"})

+


move misplaced :figwheel keys

move misplaced :figwheel keys

thanks a lot @ericstewart, @bhauman

--- cljs/project.clj
+++ cljs/project.clj
@@ -36,8 +36,7 @@
    :nrepl-port       7777
    :server-logfile   ".tmp/figwheel_server.log"
    :http-server-root "devcards"                                                                                ;; this will be in resources/
-   :css-dirs         ["resources/devcards/css"]
-   }
+   :css-dirs         ["resources/devcards/css"]}

   :cljsbuild
   {:builds
@@ -54,6 +53,7 @@
                     "src/common"
                     "src/main"
                     "src/worker"]
+     :figwheel     true
      :compiler     {:main                  plastic.main
                     :closure-defines       {"plastic.env.run_worker_on_main_thread" true
                                             "plastic.env.need_loophole"             true
@@ -66,7 +66,6 @@
                     :anon-fn-naming-policy :unmapped
                     :compiler-stats        true
                     :cache-analysis        true
-                    :figwheel              true
                     :source-map            true
                     :source-map-timestamp  true}}
     :devcards
@@ -83,6 +82,7 @@
                     "src/common"
                     "src/main"
                     "src/worker"]
+     :figwheel     {:devcards true}
      :compiler     {:main                  plastic.devcards
                     :closure-defines       {"plastic.env.dont_run_loops"            true
                                             "plastic.env.run_worker_on_main_thread" true
@@ -95,7 +95,6 @@
                     :anon-fn-naming-policy :unmapped
                     :compiler-stats        true
                     :cache-analysis        true
-                    :figwheel              {:devcards true}
                     :source-map            true
                     :source-map-timestamp  true}}
     :main
@@ -107,6 +106,7 @@
                     "src/dev"
                     "src/common"
                     "src/main"]
+     :figwheel     true
      :compiler     {:main                  plastic.main
                     :closure-defines       {"plastic.env.need_loophole" true}
                     :output-to             "../lib/_build/main/plastic.js"
@@ -116,7 +116,6 @@
                     :anon-fn-naming-policy :unmapped
                     :compiler-stats        true
                     :cache-analysis        true
-                    :figwheel              true
                     :source-map            true
                     :source-map-timestamp  true}}
     :worker
@@ -129,6 +128,7 @@
                     "src/meld"
                     "src/common"
                     "src/worker"]
+     :figwheel     true
      :compiler     {:main                  plastic.worker
                     :closure-defines       {"plastic.env.need_loophole" true}
                     :output-to             "../lib/_build/worker/plastic.js"
@@ -138,6 +138,5 @@
                     :anon-fn-naming-policy :unmapped
                     :compiler-stats        true
                     :cache-analysis        true
-                    :figwheel              true
                     :source-map            true
                     :source-map-timestamp  true}}}})


Rewritten to use alter instead of ref-set

--- clojure/day3.clj
+++ clojure/day3.clj
@@ -12,9 +12,9 @@
     existing))

 (defn credit [accounts name amount]
-  ; I suppose this can be changed into 'alter' somehow
-  (ref-set accounts
-           (map #(adjust-if-name % {:name name, :balance amount}) @accounts)))
+  (alter accounts (fn [acc new]
+                    (map #(adjust-if-name % new) acc))
+         {:name name :balance amount}))

 (defn debit [accounts name amount]
   (credit accounts name (- amount)))


Fixed file type index to filter out non-files.

--- src/alfresco_technical_validation/indexer.clj
+++ src/alfresco_technical_validation/indexer.clj
@@ -28,7 +28,7 @@

 (defn- build-file-type-index
   [files file-type file-regex]
-  { file-type (filter #(re-matches file-regex (.getName ^java.io.File %)) files) })
+  { file-type (filter #(.isFile %) (filter #(re-matches file-regex (.getName ^java.io.File %)) files)) })

 (defn- build-file-types-index
   [files]


Use separate components for each CodeDeploy step.

Embed the AWS keys component as step 1

Move the CodeDeploy application settings out into its own component.

Trivial: the explainer text from the "step" headings now appears on its
own line.

--- frontend/components/project_settings.cljs
+++ frontend/components/project_settings.cljs
@@ -1057,7 +1057,7 @@
         "our deployment documentation"]
        " to set it up."]]])))

-(defn aws [project-data owner]
+(defn aws-keys-form [project-data owner]
   (reify
     om/IRender
     (render [_]
@@ -1071,9 +1071,7 @@
             project-id (project-model/id project)
             input-path (fn [& ks] (apply conj state/inputs-path :aws :keypair ks))]
         (html
-         [:div.aws-page
-          [:h2 "AWS keys for " (vcs-url/project-name (:vcs_url project))]
-          [:div.aws-page-inner
+          [:div
            [:p "Set the AWS keypair to be used for authenticating against AWS services during your builds. "
             "Credentials are installed on your containers into the " [:code "~/.aws/config"] " and "
             [:code "~/.aws/credentials"] " properties files. These are read by common AWS libraries such as "
@@ -1114,9 +1112,21 @@
                                 :on-click #(do
                                            (raise! owner [:edited-input {:path (input-path) :value nil}])
                                            (raise! owner [:saved-project-settings {:project-id project-id}])
-                                           false)}]))]]]])))))
-
-(defn aws-codedeploy [project-data owner]
+                                           false)}]))]]])))))
+
+(defn aws [project-data owner]
+  (reify
+    om/IRender
+    (render [_]
+      (let [project (:project project-data)]
+        (html
+         [:div.aws-page
+          [:h2 "AWS keys for " (vcs-url/project-name (:vcs_url project))]
+          [:div.aws-page-inner
+            (om/build aws-keys-form project-data)]])))))
+
+
+(defn aws-codedeploy-app-settings [project-data owner]
   (reify
     om/IRender
     (render [_]
@@ -1133,6 +1143,88 @@
             project-id (project-model/id project)
             controls-ch (om/get-shared owner [:comms :controls])
             input-path (fn [& ks] (apply conj state/inputs-path :aws :services :codedeploy ks))]
+        (html
+          (if (not (seq applications))
+            ;; No settings set, need to get the application name first
+            [:div
+             [:form
+              [:input#application-name
+                {:required true, :type "text"
+                 :on-change #(utils/edit-input controls-ch (conj state/inputs-path :project-settings-codedeploy-app-name) %)}]
+              [:label {:placeholder "Application Name"}]
+              [:input {:value "Add app settings",
+                       :type "submit"
+                       :on-click #(do
+                                   (put! controls-ch [:new-codedeploy-app-name-entered])
+                                   false)}]]]
+            ;; Once we have an application name we can accept the rest of the settings
+            [:form
+             [:legend (name app-name)]
+
+             [:div.styled-select
+               [:select {:class (when (not aws-region) "placeholder")
+                         :value (or aws-region "")
+                         ;; Updates the project cursor in order to trigger a re-render
+                         :on-change #(utils/edit-input controls-ch (conj state/project-path :aws :services :codedeploy app-name :region) %)}
+                 [:option {:value ""} "Choose AWS Region..."]
+                 [:option {:disabled "disabled"} "-----"]
+                 [:option {:value "us-east-1"} "us-east-1"]
+                 [:option {:value "us-west-2"} "us-west-2"]]
+               [:i.fa.fa-chevron-down]]
+
+             [:p "The directory in your repo to package up into an application revision. "
+                 "This is relative to your repo's root, " [:code "/"] " means the repo's root "
+                 "directory, " [:code "/app"] " means the app directory in your repo's root directory."]
+             [:input#application-root
+              {:required true, :type "text", :value (or application-root "")
+               :on-change #(utils/edit-input controls-ch (input-path app-name :application_root) %)}]
+             [:label {:placeholder "Application Root"}]
+
+             [:fieldset
+              [:h5 "Revision Location"]
+              [:p "The name of the bucket and key CircleCI should use to store application revisions for " (name app-name) ". "
+                  "You can use " [:a {:href "/docs/continuous-deployment-with-amazon-codedeploy#key-patterns"} "substitution variables"]
+                  " in the Key Pattern to generate a unique key for each build."]
+              [:input#s3-bucket
+               {:required true, :type "text", :value (or bucket "")
+                :on-change #(utils/edit-input controls-ch (input-path app-name :revision_location :bucket) %)}]
+              [:label {:placeholder "Bucket Name"}]
+
+              [:input#s3-key-prefix
+               {:required true, :type "text", :value (or key_pattern "")
+                :on-change #(utils/edit-input controls-ch (input-path app-name :revision_location :key_pattern) %)}]
+              [:label {:placeholder "Key Pattern"}]]
+
+             [:div.buttons
+               (forms/managed-button
+                [:input {:data-failed-text "Failed",
+                         :data-success-text "Saved",
+                         :data-loading-text "Saving...",
+                         :value "Save app",
+                         :type "submit"
+                         :on-click #(do
+                                      (put! controls-ch [:saved-project-settings {:project-id project-id
+                                                                                :merge-paths [[:aws :services :codedeploy]]}])
+                                      false)}])
+               (forms/managed-button
+                [:input.remove {:data-failed-text "Failed",
+                                :data-success-text "Removed",
+                                :data-loading-text "Removing...",
+                                :value "Remove app",
+                                :type "submit"
+                                :on-click #(do
+                                             (put! controls-ch [:edited-input {:path (input-path) :value nil}])
+                                             (put! controls-ch [:saved-project-settings {:project-id project-id}])
+                                             false)}])]]))))))
+
+
+(defn aws-codedeploy [project-data owner]
+  (reify
+    om/IRender
+    (render [_]
+      (let [project (:project project-data)
+            applications (get-in project [:aws :services :codedeploy])
+            app-name (some-> applications first key)]
         (html
          [:div.aws-codedeploy
           [:h2 "CodeDeploy application settings for " (vcs-url/project-name (:vcs_url project))]
@@ -1141,94 +1233,24 @@
               " guide for detailed information on getting set up."]
           [:div.aws-page-inner
             [:div.aws-codedeploy-step
-             [:h4 "Step 1: Add "
-               [:a {:href "#aws"} "AWS credentials"] " that can deploy to your Amazon CodeDeploy application."]
-             [:p "You can alternatively add AWS credentials as "
-               [:a {:href "#env-vars"} " secure environment variables"] "."]]
+             [:h4 "Step 1"]
+              (om/build aws-keys-form project-data)]
+
             [:div.aws-codedeploy-step
-             [:h4 "Step 2: (Optional): configure application-wide settings."]
+             [:h4 "Step 2"]
+             [:p "[Optional] Configure application-wide settings."]
              [:p "This is useful if you deploy the same app to multiple deployment groups "
                  "(e.g. staging, production) depending on which branch was built. "
                  "With application settings configured in the UI you only need to set the "
                  "deployment group and, optionally, deployment configuration, in each deployment "
                  "block in your " [:a {:href "/docs/configuration#deployment"} "circle.yml file"] ". "
                  "If you skip this step you will need to add all deployment settings into your circle.yml file."]
-             (if (not (seq applications))
-               ;; No settings set, need to get the application name first
-               [:div
-                [:form
-                 [:input#application-name
-                   {:required true, :type "text"
-                    :on-change #(utils/edit-input controls-ch (conj state/inputs-path :project-settings-codedeploy-app-name) %)}]
-                 [:label {:placeholder "Application Name"}]
-                 [:input {:value "Add app settings",
-                          :type "submit"
-                          :on-click #(do
-                                      (put! controls-ch [:new-codedeploy-app-name-entered])
-                                      false)}]]]
-               ;; Once we have an application name we can accept the rest of the settings
-               [:form
-                [:legend (name app-name)]
-
-                [:div.styled-select
-                  [:select {:class (when (not aws-region) "placeholder")
-                            :value (or aws-region "")
-                            ;; Updates the project cursor in order to trigger a re-render
-                            :on-change #(utils/edit-input controls-ch (conj state/project-path :aws :services :codedeploy app-name :region) %)}
-                    [:option {:value ""} "Choose AWS Region..."]
-                    [:option {:disabled "disabled"} "-----"]
-                    [:option {:value "us-east-1"} "us-east-1"]
-                    [:option {:value "us-west-2"} "us-west-2"]]
-                  [:i.fa.fa-chevron-down]]
-
-                [:p "The directory in your repo to package up into an application revision. "
-                    "This is relative to your repo's root, " [:code "/"] " means the repo's root "
-                    "directory, " [:code "/app"] " means the app directory in your repo's root directory."]
-                [:input#application-root
-                 {:required true, :type "text", :value (or application-root "")
-                  :on-change #(utils/edit-input controls-ch (input-path app-name :application_root) %)}]
-                [:label {:placeholder "Application Root"}]
-
-                [:fieldset
-                 [:h5 "Revision Location"]
-                 [:p "The name of the bucket and key CircleCI should use to store application revisions for " (name app-name) ". "
-                     "You can use " [:a {:href "/docs/continuous-deployment-with-amazon-codedeploy#key-patterns"} "substitution variables"]
-                     " in the Key Pattern to generate a unique key for each build."]
-                 [:input#s3-bucket
-                  {:required true, :type "text", :value (or bucket "")
-                   :on-change #(utils/edit-input controls-ch (input-path app-name :revision_location :bucket) %)}]
-                 [:label {:placeholder "Bucket Name"}]
-
-                 [:input#s3-key-prefix
-                  {:required true, :type "text", :value (or key_pattern "")
-                   :on-change #(utils/edit-input controls-ch (input-path app-name :revision_location :key_pattern) %)}]
-                 [:label {:placeholder "Key Pattern"}]]
-
-                [:div.buttons
-                  (forms/managed-button
-                   [:input {:data-failed-text "Failed",
-                            :data-success-text "Saved",
-                            :data-loading-text "Saving...",
-                            :value "Save app",
-                            :type "submit"
-                            :on-click #(do
-                                         (put! controls-ch [:saved-project-settings {:project-id project-id
-                                                                                :merge-paths [[:aws :services :codedeploy]]}])
-                                         false)}])
-                  (forms/managed-button
-                   [:input.remove {:data-failed-text "Failed",
-                                   :data-success-text "Removed",
-                                   :data-loading-text "Removing...",
-                                   :value "Remove app",
-                                   :type "submit"
-                                   :on-click #(do
-                                                (put! controls-ch [:edited-input {:path (input-path) :value nil}])
-                                                (put! controls-ch [:saved-project-settings {:project-id project-id}])
-                                                false)}])]])]
+             (om/build aws-codedeploy-app-settings project-data)]
             [:div.aws-codedeploy-step
-             [:h4 "Step 3: Add deployment settings to your "
-                   [:a {:href "/docs/configuration#deployment"} "circle.yml file"]
-                   " (example below)."]
+             [:h4 "Step 3"]
+             [:p "Add deployment settings to your "
+                 [:a {:href "/docs/configuration#deployment"} "circle.yml file"]
+                 " (example below)."]
              [:pre
               [:code
                "deployment:\n"


removing crossovers

removing crossovers

--- plugin/src/leiningen/figwheel.clj
+++ plugin/src/leiningen/figwheel.clj
@@ -7,7 +7,6 @@
    [leiningen.core.eval :as leval]
    [clojure.java.io :as io]
    [figwheel-sidecar.config :as fc]))
-

 (defn get-lib-version [proj-name]
   (let [[_ coords version]
@@ -27,11 +26,11 @@
 (def figwheel-version (get-lib-version "figwheel"))

 ;; well this is private in the leiningen.cljsbuild ns
-(defn- run-local-project [project crossover-path builds requires form]
+(defn- run-local-project [project builds requires form]
   (let [project' (-> project
                    (update-in [:dependencies] conj ['figwheel-sidecar figwheel-sidecar-version])
                    (update-in [:dependencies] conj ['figwheel figwheel-version])
-                   (subproject/make-subproject crossover-path builds)
+                   (subproject/make-subproject nil builds)
                    #_(update-in [:dependencies] #(filter (fn [[n _]] (not= n 'cljsbuild)) %)))]
     (leval/eval-in-project project'
      `(try
@@ -47,24 +46,10 @@
            (System/exit 1))))
      requires)))

-(defn run-compiler [project crossover-path crossovers
-                    {:keys [all-builds] :as autobuild-opts}]
-  ; If crossover-path does not exist before eval-in-project is called,
-  ; the files it contains won't be classloadable, for some reason.
-  (when (not-empty crossovers)
-    (println "\033[31mWARNING: lein-cljsbuild crossovers are deprecated, and will be removed in future versions.\n
-See https://github.com/emezeske/lein-cljsbuild/blob/master/doc/CROSSOVERS.md for details.\033[0m")
-    (.mkdirs (io/file crossover-path)))
-  (run-local-project project crossover-path all-builds
-     '(require 'cljsbuild.crossover 'cljsbuild.util 'figwheel-sidecar.repl)
-     `(letfn [(copy-crossovers# []
-                  (cljsbuild.crossover/copy-crossovers
-                   ~crossover-path
-                   '~crossovers))]
-          (when (not-empty '~crossovers)
-            (copy-crossovers#)
-            (cljsbuild.util/once-every-bg 1000 "copying crossovers" copy-crossovers#))
-          (figwheel-sidecar.repl/run-autobuilder ~autobuild-opts))))
+(defn run-compiler [project {:keys [all-builds] :as autobuild-opts}]
+  (run-local-project project all-builds
+     '(require 'cljsbuild.util 'figwheel-sidecar.repl)
+     `(figwheel-sidecar.repl/run-autobuilder ~autobuild-opts)))

 (defn get-unique-id [prj]
   (let [{:keys [name version]} prj]
@@ -74,7 +59,7 @@
 (defn figwheel
   "Autocompile ClojureScript and serve the changes over a websocket (+ plus static file server)."
   [project & build-ids]
-  (let [{:keys [crossover-path crossovers builds]} (config/extract-options project)
+  (let [{:keys [builds]} (config/extract-options project)
         all-builds       (fc/prep-builds
                           (mapv config/parse-notify-command
                                 (fc/map-to-vec-builds
@@ -93,9 +78,8 @@
                                            all-builds
                                            build-ids))]
     (if (empty? errors)
-      (run-compiler project crossover-path crossovers
+      (run-compiler project
                     { :figwheel-options figwheel-options
                       :all-builds all-builds
                       :build-ids  (vec build-ids)})
       (mapv println errors))))
-


Changed stacktrace css to resource

Changed stacktrace css to resource

--- ring-devel/src/ring/middleware/stacktrace.clj
+++ ring-devel/src/ring/middleware/stacktrace.clj
@@ -5,7 +5,8 @@
         hiccup.page
         clj-stacktrace.core
         clj-stacktrace.repl
-        ring.util.response))
+        ring.util.response
+        ring.util.request))

 (defn wrap-stacktrace-log
   "Wrap a handler such that exceptions are logged to *err* and then rethrown."
@@ -34,7 +35,7 @@
     (html5
       [:head
         [:title "Ring: Stacktrace"]
-        (style-resource "ring/css/stacktrace.css")]
+        (include-css "__ring/css/stacktrace.css")]
       [:body
         [:div#exception
           [:h1 (.getName (:class ex))]
@@ -66,10 +67,13 @@
    response is returned."
   [handler]
   (fn [request]
-    (try
-      (handler request)
-      (catch Exception ex
-        (ex-response request ex)))))
+    (case (path-info request)
+      "/__ring/css/stacktrace.css"
+      (resource-response "ring/css/stacktrace.css")
+      (try
+        (handler request)
+        (catch Exception ex
+          (ex-response request ex))))))

 (defn wrap-stacktrace
   "Wrap a handler such that exceptions are caught, a corresponding stacktrace is


typify...

typify...

--- src/leiningen/liquibase.clj
+++ src/leiningen/liquibase.clj
@@ -13,7 +13,9 @@
            (java.util List)
            (liquibase.database Database)
            (java.sql Connection)
-           (javax.sql DataSource)))
+           (javax.sql DataSource)
+           (java.lang.reflect Array)
+           (liquibase.change.core CreateTableChange)))

 (t/ann ^:no-check clj-liquibase.core/make-db-instance [Connection -> Database])
 (t/ann ^:no-check clj-dbcp.core/make-datasource [t/Any t/Any -> Connection])
@@ -29,6 +31,7 @@
     (assert conn)
     (lb/make-db-instance conn)))

+(t/ann ^:no-check change-sql [Change Database -> (t/HVec [String])])
 (defn ^List change-sql
   "Return a list of SQL statements (string) that would be required to execute
   the given Change object instantly for current database without versioning."
@@ -44,10 +47,14 @@
                         (.generateSql sgf stmt ds)))
                  (.generateStatements change ds))]
     (into [] (flatten sql))))
-;
-;(defn create-table [ent-description]
-;  (mu/! (ch/create-table (:name ent-description)
-;                         (:columns ent-description))))
+
+(t/ann create-table [(t/HMap :mandatory {:name String :columns String}) -> CreateTableChange])
+(defn create-table [ent-description]
+  (ch/create-table (:name ent-description)
+                         (:columns ent-description))
+  ;(mu/! (ch/create-table (:name ent-description)
+  ;                       (:columns ent-description)))
+  )
 ;
 ;(defn drop-table-sql [table1-definition]
 ;  (str "DROP TABLE " (:name table1-definition)))


CMR-1885 Dogfood concept-type->schemas to use established library.

--- umm-spec-lib/src/cmr/umm_spec/json_schema.clj
+++ umm-spec-lib/src/cmr/umm_spec/json_schema.clj
@@ -4,7 +4,8 @@
             [clojure.string :as str]
             [cmr.common.date-time-parser :as dtp]
             [cmr.common.validations.json-schema :as js-validations]
-            [cmr.umm-spec.util :as spec-util]))
+            [cmr.umm-spec.util :as spec-util]
+            [cmr.common.util :as cmn-util]))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Defined schema files
@@ -20,10 +21,10 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Validation

-(def concept-type->schemas
+(def concept-type->schemas
   "Maps a concept type to the parsed & validated schema file."
-  (into {} (for [[concept-type umm-schema-file] concept-type->schema-file]
-             [concept-type (js-validations/parse-json-schema-from-uri (str umm-schema-file))])))
+  (cmn-util/map-values #(js-validations/parse-json-schema-from-uri (str %))
+                   concept-type->schema-file))

 (defn validate-umm-json
   "Validates the UMM JSON and returns a list of errors if invalid."


fix trans

fix trans

--- src/cljs/just_married/home/accommodation.cljs
+++ src/cljs/just_married/home/accommodation.cljs
@@ -13,24 +13,26 @@
 (def email-hotel "info@villaimmacolata.it")

 (def ^:private accommodation-dict
-  {:en {:suggest  "We suggest booking at the Hotel Villa Immacolata."
+  {:en {:title    "Accommodation"
+        :suggest  "We suggest booking at the Hotel Villa Immacolata."
         :code     "The code to get a 10% discount is: \"matrimonio Verrucci\" and prices range from 58 € for the single to the 89 € for the triple room, breakfast included."
         :distance "As you can see from the map from Villa Immacolata you can even walk to the party venue, and we will organise a Bus from there to the place of the ceremony."
-        :contact "Contact the hotel at %s for booking and more information."}
+        :contact  "Contact the hotel at %s for booking and more information."}

-   :it {:suggest "Suggeriamo di pernottare all'Hotel Villa Immacolata."
+   :it {:title   "Dove Dormire"
+        :suggest "Suggeriamo di pernottare all'Hotel Villa Immacolata."
         ;;TODO: verify if the code can be used directly on booking.com or how else
         :code    "Il codice per ottenere uno sconto del 10% è: \"matrimonio Verrucci\", e i prezzi variano dai 58 € per la singola ai 89 € per la tripla, colazione inclusa."

         :distance "Come si puó vedere dalla mappa Villa Immacolata é a soli 5 minuti a piedi dal Parco dei Principi (dove si svolge la festa), e ci sarà un Pullman organizzato che porta dall'Hotel al luogo della cerimonia."
-        :contact "Potete contattare l'hotel alla mail %s per prenotare e per ulteriori informazioni"}})
+        :contact  "Potete contattare l'hotel alla mail %s per prenotare e per ulteriori informazioni"}})

 (def ^:private tr (partial translate accommodation-dict))

 (defn accommodation
   []
   [:div.accommodation {:id "accommodation"}
-   [:h3 "Accommodation"]
+   [:h3 (tr :title)]
    [:div.accommodation__villa-immacolata
     [:div (tr :suggest)]
     [:div (tr :code)]


Fixed the bug...

Fixed the bug...

--- src/cljs/ode_solver/components/dashboard.cljs
+++ src/cljs/ode_solver/components/dashboard.cljs
@@ -170,22 +170,29 @@

 (defn get-euclidian-distance [coord1 coord2]
   {:pre [(= (-> coord1 keys sort) (-> coord2 keys sort))]}
-  (js/Math.sqrt
    (reduce
     (fn [dist-sq coord-key]
       (js/Math.pow (- (coord-key coord1) (coord-key coord2)) 2))
      0
-     (keys coord1))))
+     (keys coord1)))

 (defn get-error [solver {:keys [diff-equations start-values start-time end timestep expected-values-equations]}]
-  (let [last-data (last (solver diff-equations start-values start-time end timestep))]
-    (get-euclidian-distance
-      (dissoc last-data :t)
-      (reduce
-        (fn [expected-values k]
-          (assoc expected-values k ((k expected-values-equations ) (:t last-data))))
-        {}
-        (keys expected-values-equations)))))
+  (let [data (solver diff-equations start-values start-time end timestep)]
+    (js/Math.sqrt
+      (/
+         (reduce
+           (fn [total-error next-data]
+             (+ total-error
+                (get-euclidian-distance
+                  (dissoc next-data :t)
+                  (reduce
+                    (fn [expected-values k]
+                      (assoc expected-values k ((k expected-values-equations) (:t next-data))))
+                    {}
+                    (keys expected-values-equations)))))
+           0
+           data)
+         (/ (- end start-time) timestep)))))

 (defn get-all-errors [solver {:keys [diff-equations start-values start-time end min-timestep max-timestep expected-values-equations]}]
   (reduce
@@ -237,10 +244,10 @@
                                 :start-values {:y1 1 :y2 0}
                                 :start-time 0
                                 :end 6.0
-                                :min-timestep 0.002
-                                :max-timestep 1
-                                :expected-values-equations {:y1 js/Math.cos
-                                                            :y2 js/Math.sin}})
+                                :min-timestep 0.001
+                                :max-timestep 0.1
+                                :expected-values-equations {:y1 #(js/Math.cos (- %))
+                                                            :y2 #(js/Math.sin (- %))}})
                              "dy/dt = 1"])

           ;(om/build plotter [["y" "t"] (forward-euler-integrate [dy-dt-1] {:y 0} 0 10 0.01) "dy/dt = 1"])


Fixed submatrix docstring.

Fixed submatrix docstring.

--- src/clojure/uncomplicate/neanderthal/core.clj
+++ src/clojure/uncomplicate/neanderthal/core.clj
@@ -714,7 +714,7 @@

 (defn submatrix
   "Returns a submatrix of the matrix `a` starting from row `i`, column `j`,
-  that has `k` kolumns and `l` rows.
+  that has `k` rows and `l` columns.

   The resulting submatrix has a live connection to `a`'s data. Any change to the subvector data
   will affect the original data. If you wish to disconnect the submatrix from the parent matrix,


CMR-5387: Updated comment.

CMR-5387: Updated comment.

--- ingest-app/src/cmr/ingest/api/translation.clj
+++ ingest-app/src/cmr/ingest/api/translation.clj
@@ -38,8 +38,7 @@

 (def xsl-transformer-cache-name
   "This is the name of the cache to use for XSLT transformer templates. Templates are thread
-  safe but transformer instances are not.
-  http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/?page=9"
+  safe but transformer instances are not."
   :xsl-transformer-templates)

 (def ^:private echo10-iso19115-xslt


remove old coupled tests

remove old coupled tests

--- clients/clojure/test/samsara/t_ring_buffer.clj
+++ clients/clojure/test/samsara/t_ring_buffer.clj
@@ -1,49 +0,0 @@
-(ns samsara.t-ring-buffer
-  (:use midje.sweet)
-  (:require [samsara.ring-buffer :refer :all]
-            [midje.sweet :refer :all]))
-
-(def ^{:dynamic true} buffer (atom (ring-buffer 5)))
-
-(defmacro with-empty-buffer [& body]
-  `(binding [buffer (atom (ring-buffer 5))]
-     ~@body))
-
-(defn enqueue-item
-  [item]
-  "Atomically adds an item to the ring buffer"
-  (swap! buffer enqueue item))
-
-(defn enqueue-items
-  [items]
-  "Atomically adds a list of items to the ring buffer"
-  (doall (map enqueue-item items)))
-
-
-(fact "enqueue function adds items to the ring buffer. Items are added as key value pairs with a unique id (auto incrementing number). (snapshot buffer) returns the current state of the ring buffer. (items) returns just the items without the id.  "
-      (with-empty-buffer
-        (enqueue-item "One")
-        (snapshot @buffer)  => (list [1 "One"])
-        (items @buffer) => (list "One")))
-
-(fact "enqueue function overwrites the oldest item if the buffer reaches capacity"
-      (with-empty-buffer
-        (enqueue-items ["One" "Two" "Three" "Four" "Five" "Six"])
-        (snapshot @buffer) => (list [2 "Two"] [3 "Three"] [4 "Four"] [5 "Five"] [6 "Six"])))
-
-(fact "dequeue removes items in the buffer with the corresponding ids if they exisit in the buffer"
-      (with-empty-buffer
-        (enqueue-items ["One" "Two" "Three" "Four" "Five"])
-        (let [clip (snapshot @buffer)]
-          ;; Test if snapshot returned all the items in the buffer
-          clip => (list [1 "One"] [2 "Two"] [3 "Three"] [4 "Four"] [5 "Five"])
-          ;; Add another item to the buffer. This should overwrite the oldest.ie "One"
-          (enqueue-item "Six")
-          ;; Test if "One" is no longer in the snapshot.
-          (snapshot @buffer) => (list [2 "Two"] [3 "Three"] [4 "Four"] [5 "Five"] [6 "Six"])
-          ;; dequeue using the first snapshot obtained.
-          (swap! buffer dequeue clip)
-          ;; Test if dequeue removed all items in the original snapshot
-          ;; and retains "Six"
-          (snapshot @buffer) => (list [6 "Six"]))
-        ))


Let background-view simply take the board order

--- src/literate_2048/core.cljs
+++ src/literate_2048/core.cljs
@@ -202,9 +202,9 @@
   (str "tile tile-" val))

 (defn background-view
-  [rows cols]
+  [order]
   (apply d/div {:className "background"}
-    (for [i (range rows) j (range cols)]
+    (for [i (range order) j (range order)]
       (d/div {:className (pos-classes [i j])}))))

 (defn tiles-view [s]
@@ -219,7 +219,7 @@
 (q/defcomponent SquareBoard
   [tiles order]
   (d/div {:className "square-board"}
-    (background-view order order)
+    (background-view order)
     (tiles-view tiles)))

 ;; # UI


More test coverage

More test coverage

--- jvm-runner/test/codewars/runner/java_test.clj
+++ jvm-runner/test/codewars/runner/java_test.clj
@@ -30,6 +30,19 @@
         :solution "public class Hello {public static void main() {System.out.print(\"Hellooo!\");}}"})
       (is (= "Hellooo!" (with-java-out-str (-main)))))))

+(deftest java-setup-code
+  (testing "-main can handle a java solution and setup code"
+    (with-in-str
+      (json/generate-string
+       {:language "java"
+        :setup "import java.lang.String;
+                public class Beatles {public static String sayHello() {
+                  return \"Hello, hello!\";}}"
+        :solution "public class HelloAgain {
+                     public static void main() {
+                         System.out.print(Beatles.sayHello());}}"})
+      (is (= "Hello, hello!" (with-java-out-str (-main)))))))
+
 (deftest java-test-fixture
   (testing "-main can handle a junit test"
     (with-in-str
@@ -51,3 +64,51 @@
         (is (.contains test-out-string "<DESCRIBE::>myTestFunction(TestFixture)"))
         (is (.contains test-out-string "test out"))
         (is (.contains test-out-string "<PASSED::>Test Passed<:LF:>"))))))
+
+(deftest java-sad-path
+  (testing "-main can handle a failing junit test"
+    (with-in-str
+      (json/generate-string
+       {:language "java"
+        :solution "public class Foo {
+                     public Foo(){}
+                     public int testthing(){return 3;}
+                     public static void main(String[] args){System.out.println(\"42\");}}"
+        :fixture "import static org.junit.Assert.assertEquals;
+                  import org.junit.Test;
+                  import org.junit.runners.JUnit4;
+                  public class TestForFailure {
+                    public TestForFailure(){}
+                    @Test public void sadPath(){
+                      Foo s = new Foo();
+                      assertEquals(\"Failed Message\", 5, s.testthing());
+                      System.out.println(\"Shouldn't get here\");}}"})
+      (let [test-out-string (with-java-out-str (-main))]
+        (is (.contains test-out-string "<DESCRIBE::>sadPath(TestForFailure)<:LF:>"))
+        (is (.contains test-out-string "<FAILED::>Failed Message expected:"))
+        (is (.contains test-out-string "<5> but was:<3>"))
+        (is (not (.contains test-out-string "Shouldn't get here")))
+        (is (not (.contains test-out-string "<PASSED::>Test Passed<:LF:>")))))))
+
+(deftest java-nine-yards
+  (testing "-main can setup, solution, and test fixture code for java"
+    (with-in-str
+      (json/generate-string
+       {:language "java"
+        :setup "public class Setupp { public static int three() {return 3;}}"
+        :solution "public class Sollution {
+                   public Sollution(){}
+                   public int testthingy(){return Setupp.three();}}",
+        :fixture "import static org.junit.Assert.assertEquals;
+                  import org.junit.Test;
+                  import org.junit.runners.JUnit4;
+                  public class NineYards {
+                     public NineYards(){}
+                     @Test public void solutionAndSetupAndFixture(){
+                         Sollution s = new Sollution();
+                         assertEquals(\"wow\", 3, s.testthingy());
+                         System.out.println(\"test out\");}}"})
+      (let [test-out-string (with-java-out-str (-main))]
+        (is (.contains test-out-string "<DESCRIBE::>solutionAndSetupAndFixture(NineYards)<:LF:>"))
+        (is (.contains test-out-string "test out"))
+        (is (.contains test-out-string "<PASSED::>Test Passed<:LF:>"))))))


fix marathon descriptor unit test

fix marathon descriptor unit test

--- waiter/test/waiter/scheduler/marathon_test.clj
+++ waiter/test/waiter/scheduler/marathon_test.clj
@@ -586,7 +586,8 @@

 (deftest test-marathon-descriptor
   (with-redefs [config/retrieve-cluster-name (constantly "test-cluster")]
-    (let [service-id->password-fn (fn [service-id] (str service-id "-password"))]
+    (let [service-id->password-fn (fn [service-id] (str service-id "-password"))
+          descriptor-builder-ctx {:container-init-commands ["waiter-mesos-init"]}]
       (testing "basic-test-with-defaults"
         (let [expected {:id "test-service-1"
                         :labels {:source "waiter"
@@ -635,7 +636,8 @@
                                           "BAZ" "quux"}}
               actual (default-marathon-descriptor-builder
                        home-path-prefix service-id->password-fn
-                       {:service-id service-id, :service-description service-description} nil)]
+                       {:service-id service-id, :service-description service-description}
+                       descriptor-builder-ctx)]
           (is (= expected actual))

           (testing "health-check-port-index of 2"
@@ -646,7 +648,7 @@
                      home-path-prefix service-id->password-fn
                      (->> (assoc service-description "health-check-port-index" 2 "ports" 3)
                           (assoc {:service-id service-id} :service-description))
-                     nil)))))))))
+                     descriptor-builder-ctx)))))))))

 (deftest test-kill-instance-last-force-kill-time-store
   (let [current-time (t/now)


Fix incorrect header text.

Fix incorrect header text.

--- src/cljs/clj_templates/components/header/component.cljs
+++ src/cljs/clj_templates/components/header/component.cljs
@@ -3,5 +3,5 @@
 (defn header []
   [:header.header
    [:div.content
-    [:a.main-logo {:href "#/"} "cljs-templates"]
+    [:a.main-logo {:href "#/"} "clj-templates"]
     [:a.nav-elem {:href "#/about"} "About"]]])


Added IFn and IFn$L to cl vectors and matrices.

--- src/clojure/uncomplicate/neanderthal/opencl/clblock.clj
+++ src/clojure/uncomplicate/neanderthal/opencl/clblock.clj
@@ -13,7 +13,8 @@
              :refer [->RealBlockVector ->RealGeneralMatrix]]
             [uncomplicate.neanderthal.impl.cblas :refer
              [cblas-single cblas-double]])
-  (:import [uncomplicate.clojurecl.core CLBuffer]
+  (:import [clojure.lang IFn IFn$L]
+           [uncomplicate.clojurecl.core CLBuffer]
            [uncomplicate.neanderthal.protocols
             BLAS Vector RealVector Matrix RealMatrix RealChangeable
             Block DataAccessor]
@@ -146,6 +147,12 @@
   (stride [_]
     strd)
   (count [_]
+    n)
+  IFn
+  (invoke [x]
+    n)
+  IFn$L
+  (invokePrim [x]
     n)
   RealChangeable
   (set [x val]
@@ -279,6 +286,12 @@
     ord)
   (count [_]
     (* m n))
+  IFn
+  (invoke [a]
+    n)
+  IFn$L
+  (invokePrim [a]
+    n)
   RealChangeable
   (set [a val]
     (if (and (= ld (if (column-major? a) m n))


Added update-in! and assoc-in! test.

Added update-in! and assoc-in! test.

--- test/useful/map_test.clj
+++ test/useful/map_test.clj
@@ -60,3 +60,11 @@
     (is (= '{b 1, c 11, d 92} (remove-vals zero? m)))
     (is (= '{a 0} (filter-keys '#{a} m)))
     (is (= '{b 1, c 11, d 92} (remove-keys '#{a} m)))))
+
+(deftest test-update-in
+  (is (= [1] (-> (update-in! {:foo (transient {:bar []})} [:foo :bar] conj 1)
+                 :foo :bar))))
+
+(deftest test-assoc-in
+  (is (= [1] (-> (assoc-in! {:foo {}} [:foo :bar] [1])
+                 :foo :bar))))


Removed future fact which is now irrelevant

--- test/yadic/core_test.clj
+++ test/yadic/core_test.clj
@@ -266,7 +266,6 @@

     @close-called-with => ["hello world" "hello"]))

-(future-fact "Destructors in parent container activator")

 ; Activation using IDeref
 ; ==================================


Added missing component dep.

Added missing component dep.

--- src/hxgm30/language/components/core.clj
+++ src/hxgm30/language/components/core.clj
@@ -67,7 +67,7 @@
 (def http-without-logging
   {:httpd (component/using
            (httpd/create-component)
-           [:config :random :lang])})
+           [:config :random :backend :lang])})

 (defn basic
   [cfg-data]


Function to exec another process

Function to exec another process

--- src/branch_handler/core.clj
+++ src/branch_handler/core.clj
@@ -41,6 +41,19 @@
     (let [body (read-request-body request)]
         (if body
             (json/read-str body :key-fn clojure.core/keyword))))
+
+(defn exec
+    "Execute external command and pass given number of parameters to it."
+    ; command called without parameters
+    ([command]
+     (doto (. (Runtime/getRuntime) exec command)
+           (.waitFor)
+           (.destroy)))
+    ; command called with one or more parameters
+    ([command & rest-parameters]
+     (doto (. (Runtime/getRuntime) exec (str command " " (clojure.string/join " " rest-parameters)))
+           (.waitFor)
+           (.destroy))))

 (defn clone-or-fetch-bare-repo
     [repository-url]


wrong call

wrong call

--- src/celestial/hosts_api.clj
+++ src/celestial/hosts_api.clj
@@ -122,9 +122,8 @@
   (DELETE- "/type/:type" [^:string type] {:nickname "deleteType" :summary "Delete type"
                                           :errorResponses (errors {:bad-req "Type does not exist"})}
            (if (p/type-exists? type)
-             (do (p/delete-system type)
+             (do (p/delete-type type)
                  (success {:msg "Type deleted"}))
              (bad-req {:msg "Type does not exist"})))
   )

-


quota integrated into api

quota integrated into api

--- src/celestial/hosts_api.clj
+++ src/celestial/hosts_api.clj
@@ -1,6 +1,19 @@
+(comment
+   Celestial, Copyright 2012 Ronen Narkis, narkisr.com
+   Licensed under the Apache License,
+   Version 2.0  (the "License") you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.)
+
 (ns celestial.hosts-api
   (:refer-clojure :exclude [type])
-  (:require [celestial.persistency :as p])
+  (:require
+    [cemerick.friend :as friend]
+    [celestial.persistency :as p])
   (:use
      [clojure.core.strint :only (<<)]
      [slingshot.slingshot :only  [throw+ try+]]
@@ -45,6 +58,8 @@

 (defc [:machine :os] (keyword v))

+(defn curr-user []
+  (:username (friend/current-authentication)))

 (defroutes- hosts {:path "/host" :description "Operations on hosts"}

@@ -56,11 +71,12 @@

         (success {:ids (p/get-system-index :type type)}))

-  (POST- "/host/system" [& ^:system props] {:nickname "addSystem" :summary "Add system"
+  (POST- "/host/system" [& ^:system spec] {:nickname "addSystem" :summary "Add system"
                                             :errorResponses (errors {:bad-req "Missing system type"})}
          (try+
-           (let [id (p/add-system props)]
-             (success {:msg "new system saved" :id id :props props}))
+           (do
+             (p/increase-use (curr-user) spec)
+             (success {:msg "new system saved" :id (p/add-system spec)}))
            (catch [:type :celestial.persistency/missing-type] e
              (bad-req {:msg (<< "Cannot create machine with missing type ~(e :t)}")}))))

@@ -68,8 +84,9 @@
                                          :errorResponses (errors {:bad-req "System missing"})}
          (if-not (p/system-exists? id)
            (conflict {:msg "System does not exists, use POST /host/system to create it first"})
-           (let [clone-id (p/clone-system id)]
-             (success {:msg "system cloned" :id clone-id}))))
+           (do
+             (p/increase-use (curr-user) (p/get-system id))
+             (success {:msg "system cloned" :id (p/clone-system id)}))))

   (PUT- "/host/system/:id" [^:int id & ^:system system] {:nickname "updateSystem" :summary "Update system"
                                                          :errorResponses (errors {:conflict "System does not exist"}) }
@@ -80,10 +97,13 @@

   (DELETE- "/host/system/:id" [^:int id] {:nickname "deleteSystem" :summary "Delete System"
                                           :errorResponses (errors {:bad-req "System does not exist"})}
-           (if (p/system-exists? id)
-             (do (p/delete-system id)
-                 (success {:msg "System deleted"}))
-             (bad-req {:msg "System does not exist"})))
+           (try+
+             (let [spec (p/get-system! id)]
+               (p/delete-system! id)
+               (p/decrease-use (curr-user) spec)
+               (success {:msg "System deleted"}))
+             (catch [:type :celestial.persistency/missing-system] e
+               (bad-req {:msg "System does not exist"}))))

   (GET- "/host/type/:id" [^:int id] {:nickname "getSystemType" :summary "Fetch type of provided system id"}
         (success (p/get-type (:type (p/get-system id))) ))


fix namespace for shared utils

fix namespace for shared utils

--- src/chat/server/handler.clj
+++ src/chat/server/handler.clj
@@ -9,7 +9,7 @@
             [clojure.tools.nrepl.server :as nrepl]
             [chat.server.sync :as sync :refer [sync-routes]]
             [environ.core :refer [env]]
-            [chat.server.util :refer [valid-nickname?]]
+            [chat.shared.util :refer [valid-nickname?]]
             [chat.server.db :as db]
             [chat.server.invite :as invites]))


refactor a bit, better handling of prev-info

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -77,33 +77,41 @@
            result)))))

 (defn info->segv [info state]
-  [(:gcol info) (:source-idx state) (:line state) (:col state)])
+  (let [segv [(:gcol info) (:source-idx state) (:line state) (:col state)]]
+    (if-let [name (:name info)]
+      (let [[idx state]
+            (if-let [idx (get-in state [:names->idx name])]
+              [idx state]
+              (let [cidx (:name-idx state)]
+                [cidx (-> state
+                          (assoc-in [:names->idx name] cidx)
+                          (assoc :name-idx (inc cidx)))]))]
+        [(conj segv idx) state])
+      [segv state])))
+
+(defn prev-info->segv [info state]
+  (let [segv [(:gcol info) (:source-idx state) (:line state) (:col state)]]
+    (if-let [name (:name info)]
+      (conj segv (get (:names->idx state) name))
+      segv)))

 (defn encode-cols [infos state]
   (loop [infos (seq infos) state state]
     (if infos
       (let [info (first infos)
+            [segv state] (info->segv info state)
             prev-info (:prev-info state)
-            segv (info->segv info state)
-            [segv state] (if-let [name (:name info)]
-                           (let [[idx state]
-                                 (if-let [idx (get-in state [:names->idx name])]
-                                   [idx state]
-                                   (let [cidx (:name-idx state)]
-                                     [cidx (-> state
-                                               (assoc-in [:names->idx name] cidx)
-                                               (assoc :name-idx (inc cidx)))]))]
-                             [(conj segv idx) state])
-                           [segv state])
             relsegv (if prev-info
-                      (into [] (map - segv (info->segv prev-info state)))
+                      (let [prev-segv (prev-info->segv prev-info state)]
+                        (if (not= (:gline info) (:gline prev-info))
+                          (into [] (cons (first segv) (map - (rest segv) (rest prev-segv))))
+                          (into [] (map - segv prev-segv))))
                       segv)]
         (recur (next infos)
           (let [lines (:lines state)
-                lines (conj (pop lines)
-                            (if (and prev-info (not= (:gline info) (:gline prev-info)))
-                              [(base64-vlq/encode relsegv)]
-                              (conj (peek lines) (base64-vlq/encode relsegv))))]
+                lines (if (and prev-info (not= (:gline info) (:gline prev-info)))
+                        (conj lines [(base64-vlq/encode relsegv)])
+                        (conj (pop lines) (conj (peek lines) (base64-vlq/encode relsegv))))]
             (-> state
                 (assoc :lines lines)
                 (assoc :prev-info


add todo, logic is incorrect, we need to pass lastseg into encode-cols, all segment fields are globally relative with the exception of :gcol

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -75,6 +75,9 @@
                        [result relseg])))]
              (recur (inc gline) (next lines) (assoc relseg 0 0) result))
            result)))))
+
+;; TODO: the lastseg needs to be passed into encode-cols - everything
+;; but :gcol is relative

 (defn encode-cols [vs source-idx line col names->idx name-idx]
   (loop [vs (seq vs) lastseg nil cols-segs []]


remove nippy coder proxy, one remains !!

--- src/clj/datasplash/core.clj
+++ src/clj/datasplash/core.clj
@@ -37,7 +37,7 @@
            [org.joda.time.format DateTimeFormat DateTimeFormatter]
            [org.apache.beam.sdk.transforms.windowing BoundedWindow Window FixedWindows SlidingWindows Sessions Trigger]
            [org.joda.time Duration Instant]
-           [datasplash.fns ClojureDoFn ClojureCombineFn]
+           [datasplash.fns ClojureDoFn ClojureCombineFn ClojureCustomCoder]
            [datasplash.pipelines PipelineWithOptions]))

 (def required-ns (atom #{}))
@@ -371,27 +371,15 @@
   {:doc "Returns an instance of a CustomCoder using nippy for serialization"
    :added "0.1.0"}
   []
-  (proxy [CustomCoder] []
-    (encode
-      ([obj ^OutputStream out ctx]
-       (safe-exec
-        (let [dos (DataOutputStream. out)]
-          (nippy/freeze-to-out! dos obj))))
-      ([obj ^OutputStream out]
-       (safe-exec
-        (let [dos (DataOutputStream. out)]
-          (nippy/freeze-to-out! dos obj)))))
-    (decode
-      ([^InputStream in ctx]
-       (safe-exec
-        (let [dis (DataInputStream. in)]
-          (nippy/thaw-from-in! dis))))
-      ([^InputStream in ]
-       (safe-exec
-        (let [dis (DataInputStream. in)]
-          (nippy/thaw-from-in! dis)))))
-    (verifyDeterministic [] nil)
-    (consistentWithEquals [] true)))
+  (let [encode-fn (fn [obj ^OutputStream out]
+                    (safe-exec
+                     (let [dos (DataOutputStream. out)]
+                       (nippy/freeze-to-out! dos obj))))
+        decode-fn (fn [^InputStream in]
+                    (safe-exec
+                     (let [dis (DataInputStream. in)]
+                       (nippy/thaw-from-in! dis))))]
+    (ClojureCustomCoder. {"decode-fn" decode-fn "encode-fn" encode-fn})))

 (defn make-kv-coder
   {:doc "Returns an instance of a KvCoder using by default nippy for serialization."


support functions for Genetics Pavilion

support functions for Genetics Pavilion

--- src/clj/game/core-rules.clj
+++ src/clj/game/core-rules.clj
@@ -2,7 +2,7 @@

 (declare card-init card-str deactivate enforce-msg gain-agenda-point get-agenda-points
          handle-end-run is-type? resolve-steal-events show-prompt untrashable-while-rezzed?
-         in-corp-scored? update-all-ice win)
+         in-corp-scored? update-all-ice win prevent-draw)

 ;;;; Functions for applying core Netrunner game rules.

@@ -39,20 +39,38 @@
                    (when-let [c (some #(when (= (:cid %) (:cid card)) %) (get-in @state [side :play-area]))]
                      (move state side c :discard)))))))))))

+(defn max-draw
+  "Put an upper limit on the number of cards that can be drawn in this turn."
+  [state side n]
+  (swap! state assoc-in [side :register :max-draw] n))
+
+(defn remaining-draws
+  "Calculate remaining number of cards that can be drawn this turn if a maximum exists"
+  [state side]
+  (let [active-player (get-in @state [:active-player])]
+    (when-let [max-draw (get-in @state [active-player :register :max-draw])]
+      (let [drawn-this-turn (get-in @state [active-player :register :drawn-this-turn] 0)]
+        (max (- max-draw drawn-this-turn) 0)))))
+
 (defn draw
   "Draw n cards from :deck to :hand."
   ([state side] (draw state side 1))
   ([state side n]
-   (when (and (= side :corp) (> n (count (get-in @state [:corp :deck]))))
-     (system-msg state side "is decked")
-     (win state :runner "Decked"))
    (let [active-player (get-in @state [:active-player])]
-     (when-not (get-in @state [active-player :register :cannot-draw])
-       (let [drawn (zone :hand (take n (get-in @state [side :deck])))]
-         (swap! state update-in [side :hand] #(concat % drawn)))
-       (swap! state update-in [side :deck] (partial drop n))
-       (trigger-event state side (if (= side :corp) :corp-draw :runner-draw) n)))))
-
+     (let [n (if (get-in @state [active-player :register :max-draw])
+               (min n (remaining-draws state side))
+               n)]
+       (when (and (= side :corp) (> n (count (get-in @state [:corp :deck]))))
+         (system-msg state side "is decked")
+         (win state :runner "Decked"))
+       (when-not (get-in @state [active-player :register :cannot-draw])
+         (let [drawn (zone :hand (take n (get-in @state [side :deck])))]
+           (swap! state update-in [side :hand] #(concat % drawn))
+           (swap! state update-in [side :deck] (partial drop n))
+           (swap! state update-in [active-player :register :drawn-this-turn] (fnil #(+ % n) 0))
+           (trigger-event state side (if (= side :corp) :corp-draw :runner-draw) n)
+           (when (= 0 (remaining-draws state side))
+             (prevent-draw state side))))))))

 ;;; Damage
 (defn flatline [state]


Ignore parsing errors when reading vubis xml files

Well, the xml has to be valid of course, but if the dates or numbers
are fishy then just ignore them.

--- src/clj/mdr2/production.clj
+++ src/clj/mdr2/production.clj
@@ -118,12 +118,14 @@
   [production]
   (reduce-kv
    (fn [m k v]
-     (assoc m k
+     (medley/assoc-some
+      m k
       (cond
-        (#{:date :produced_date :revision_date} k) (time/local-date v)
+        ;; ignore all parsing errors. If there are faulty values we simply do not use them
+        (#{:date :produced_date :revision_date} k) (try (time/local-date v) (catch Exception _ nil))
         ;; source_date is just a year string
-        (#{:source_date} k) (time/local-date (time/year v))
-        (#{:volumes :library_record_id} k) (Integer/parseInt v)
+        (#{:source_date} k) (try (time/local-date (time/year v)) (catch Exception _ nil))
+        (#{:volumes :library_record_id} k) (try (Integer/parseInt v) (catch Exception _ nil))
         :else v)))
    {} production))


forgot to apply transform to result output

--- src/cljs_api_gen/result.clj
+++ src/cljs_api_gen/result.clj
@@ -44,6 +44,7 @@

    ;; API-DATA for core library
    :library-api  {:symbols (->> parsed
+                                (map transform-item)
                                 (group-by :full-name)
                                 (mapmap last)) ;; remove possible duplicates (favoring the last symbol)
                   :changes []


Added printing of mean test error.

Added printing of mean test error.

--- src/clojush/examples/wc.clj
+++ src/clojush/examples/wc.clj
@@ -332,6 +332,7 @@
         best-total-test-error (apply +' best-test-errors)]
     (printf ";; -*- WC problem report generation %s\n" generation)(flush)
     (println "Test total error for best:" best-total-test-error)
+    (println (format "Test mean error for best: %.5f" (double (/ best-total-test-error (count best-test-errors)))))
     (when (zero? (:total-error best))
       (println "Test errors for best:" best-test-errors))
     (println ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n")


Define wrapper routines to access native C code

--- src/clopack_native/core.clj
+++ src/clopack_native/core.clj
@@ -2,7 +2,38 @@

 (require '[net.n01se.clojure-jna :as jna])

-(defn foo
-  "I don't do a whole lot."
-  [x]
-  (println x "Hello, World!"))
+; Refer to 'clopack_native' as 'cn'.
+(jna/to-ns cn clopack_native)
+
+(defn create-ctx [interface]
+  "Creates a new packet context with the given interface.
+   Returns a packet context on success, nil on errors."
+  (let [handle  jna/invoke Integer cn/dev_open interface
+        buf-len jna/invoke Integer cn/dev_buf_len]
+    (when-not (= handle -1)
+      {:handle  handle
+       :buf-len buf-len})))
+
+(defn read-frame [ctx]
+  "Reads a data frame as from a packet context.
+   Returns a byte-array on success, nil otherwise"
+  (let [handle    (:handle ctx)
+        buf-len   (:buf-len ctx)
+        buf       (byte-array buf-len)
+        num-read  (jna/invoke Integer cn/dev_read handle buf buf-len)]
+    (when-not (= num-read -1)
+      (take num-read buf))))
+
+(defn write-frame [ctx buf]
+  "Writes the given byte-array as a data frame through a packet context.
+   Returns the number of bytes written on success, nil otherwise."
+  (let [handle      (:handle ctx)
+        buf-len     (count buf)
+        num-written (jna/invoke Integer cn/dev_write handle buf buf-len)]
+    (when-not (= num-written -1)
+      num-written)))
+
+(defn destroy-ctx [ctx]
+  "Destroys a packet context."
+  (jna/invoke Integer cn/dev_close (:handle ctx))
+  nil)


Revert most of "New query functions (#732)" (#766)

The new query functions do very badly for long time ranges. Revert temporarily
and rework the patch with a hybrid of old and new query.

Keep the time out changes in the original patch.

This reverts commit 7844b2070475dab68c320e388c5083eb4879d1d2.

--- scheduler/src/cook/mesos/util.clj
+++ scheduler/src/cook/mesos/util.clj
@@ -337,7 +337,7 @@
 (def ^:const job-states #{"running" "waiting" "completed"})
 (def ^:const instance-states #{"success" "failed"})

-;; get-jobs-by-user-and-state-and-submit is a bit opaque because it is
+;; get-completed-jobs-by-user is a bit opaque because it is
 ;; reaching into datomic internals. Here is a quick explanation.
 ;; seek-datoms provides a pointer into the raw datomic indices
 ;; that we can then seek through. We set the pointer to look
@@ -348,57 +348,65 @@
 ;; are set at the same time, in "real" time. This means that
 ;; jobs submitted after `start` will have been created after
 ;; expanded start
-(defn get-jobs-by-user-and-state-and-submit
-  "Returns all jobs for a particular user in the specified timeframe, without a custom executor"
-  [db user start end state-keyword]
-  (let [;; Expand the time range so that clock skew between cook
-        ;; and datomic doesn't cause us to miss jobs
-        ;; 1 hour was picked because a skew larger than that would be
-        ;; suspicious
-        expanded-start (Date. (- (.getTime start)
-                                 (-> 1 t/hours t/in-millis)))
-        expanded-end (Date. (+ (.getTime end)
-                               (-> 1 t/hours t/in-millis)))
-        entid-start (d/entid-at db :db.part/user expanded-start)
-        entid-end (d/entid-at db :db.part/user expanded-end)
-        job-user-entid (d/entid db :job/user)]
-    (->> (d/seek-datoms db :avet :job/user user entid-start)
-         (take-while #(and (< (:e %) entid-end)
-                           (= (:a %) job-user-entid)
-                           (= (:v %) user)))
-         (map #(:e %))
-         (map (partial d/entity db))
-         (filter #(<= (.getTime start) (.getTime (:job/submit-time %))))
-         (filter #(< (.getTime (:job/submit-time %)) (.getTime end)))
-         (filter #(= state-keyword (:job/state %)))
-         (filter #(not (:job/custom-executor %))))))
-
-;; This differs from get-active-jobs-by-user-and-state as it is also looking up based on task state.
 (defn get-completed-jobs-by-user
   "Returns all completed job entities for a particular user
-   in the specified timeframe, without a custom executor. Supports looking up based
-   on task state 'success' and 'failed' if passed into 'state'"
+   in the specified timeframe, without a custom executor."
   [db user start end limit state name-filter-fn]
   (timers/time!
     get-completed-jobs-by-user-duration
-    (->>
-      (cond->> (get-jobs-by-user-and-state-and-submit db user start end :job.state/completed)
-               (instance-states state) (filter #(= state (job-ent->state %)))
-               name-filter-fn (filter #(name-filter-fn (:job/name %))))
-      (take limit))))
-
+    (let [;; Expand the time range so that clock skew between cook
+          ;; and datomic doesn't cause us to miss jobs
+          ;; 1 hour was picked because a skew larger than that would be
+          ;; suspicious
+          expanded-start (Date. (- (.getTime start)
+                                   (-> 1 t/hours t/in-millis)))
+          expanded-end (Date. (+ (.getTime end)
+                                 (-> 1 t/hours t/in-millis)))
+          jobs
+          (->> (d/seek-datoms db :avet :job/user user (d/entid-at db :db.part/user expanded-start))
+               (take-while #(and (< (.e %) (d/entid-at db :db.part/user expanded-end))
+                                 (= (.a %) (d/entid db :job/user))
+                                 (= (.v %) user)))
+               (map #(.e %))
+               (map (partial d/entity db))
+               (filter #(<= (.getTime start) (.getTime (:job/submit-time %))))
+               (filter #(< (.getTime (:job/submit-time %)) (.getTime end)))
+               (filter #(= :job.state/completed (:job/state %)))
+               (filter #(not (:job/custom-executor %))))]
+      (->>
+        (cond->> jobs
+                 (instance-states state) (filter #(= state (job-ent->state %)))
+                 name-filter-fn (filter #(name-filter-fn (:job/name %))))
+        (take limit)))))
+
+;; This is a separate query from completed jobs because most running/waiting jobs
+;; will be at the end of the time range, so the query is somewhat inefficent.
+;; The standard datomic query performs reasonably well on the smaller set of
+;; running and waiting jobs, so it's implemented that way to keep things simple.
 (defn get-active-jobs-by-user-and-state
   "Returns all jobs for a particular user in the specified state
-   and timeframe, without a custom executor. This query looks for all
-   jobs by job state only (i.e., no 'success' or 'failed')"
+   and timeframe, without a custom executor.
+   Note that this query is not performant for completed jobs, use
+   get-completed-jobs-by-user instead."
   [db user start end state name-filter-fn]
   (let [state-keyword (case state
                         "running" :job.state/running
-                        "waiting" :job.state/waiting)]
-    (timers/time!
-      (timers/timer ["cook-mesos" "scheduler" (str "get-" (name state) "-jobs-by-user-duration")])
-      (cond->> (get-jobs-by-user-and-state-and-submit db user start end state-keyword)
-               name-filter-fn (filter #(name-filter-fn (:job/name %)))))))
+                        "waiting" :job.state/waiting)
+        jobs
+        (timers/time!
+          (timers/timer ["cook-mesos" "scheduler" (str "get-" (name state) "-jobs-by-user-duration")])
+          (->> (q '[:find [?j ...]
+                    :in $ ?user ?state ?start ?end
+                    :where
+                    [?j :job/state ?state]
+                    [?j :job/user ?user]
+                    [?j :job/submit-time ?t]
+                    [(<= ?start ?t)]
+                    [(< ?t ?end)]
+                    [?j :job/custom-executor false]]
+                  db user state-keyword start end)
+               (map (partial d/entity db))))]
+    (cond->> jobs name-filter-fn (filter #(name-filter-fn (:job/name %))))))

 (defn get-jobs-by-user-and-states
   "Returns all jobs for a particular user in the specified states
@@ -409,11 +417,9 @@
                               (get-completed-jobs-by-user db user start end limit state name-filter-fn)
                               (get-active-jobs-by-user-and-state db user start end state name-filter-fn)))
         jobs-by-state (mapcat get-jobs-by-state states)]
-    (timers/time!
-      (timers/timer ["cook-mesos" "scheduler" "get-jobs-by-user-and-states-duration"])
-      (->> jobs-by-state
-           (sort-by :job/submit-time)
-           (take limit)))))
+    (->> jobs-by-state
+         (sort-by :job/submit-time)
+         (take limit))))

 (defn jobs-by-user-and-state


Add tests for CPS servlets

Add tests for CPS servlets

--- ring-servlet/test/ring/util/test/servlet.clj
+++ ring-servlet/test/ring/util/test/servlet.clj
@@ -54,11 +54,14 @@
   (proxy [javax.servlet.ServletConfig] []
     (getServletContext [] nil)))

-(defn- run-servlet [handler request response]
-  (doto (servlet handler)
-    (.init (servlet-config))
-    (.service (servlet-request request)
-              (servlet-response response))))
+(defn- run-servlet
+  ([handler request response]
+   (run-servlet handler request response {}))
+  ([handler request response options]
+   (doto (servlet handler options)
+     (.init (servlet-config))
+     (.service (servlet-request request)
+               (servlet-response response)))))

 (deftest servlet-test
   (let [body (proxy [javax.servlet.ServletInputStream] [])
@@ -119,6 +122,27 @@
         (is (= (take-while (complement zero?) (@response :body))
                (seq (.getBytes "Hello World"))))))))

+(deftest servlet-cps-test
+  (let [handler  (fn [req cont]
+                   (cont {:status  200
+                          :headers {"Content-Type" "text/plain"}
+                          :body    "Hello World"}))
+        request  {:server-port    8080
+                  :server-name    "foobar"
+                  :remote-addr    "127.0.0.1"
+                  :uri            "/foo"
+                  :scheme         :http
+                  :request-method :get
+                  :protocol       "HTTP/1.1"
+                  :headers        {}
+                  :body           nil}
+        response (atom {})]
+    (run-servlet handler request response {:async? true})
+    (is (= (@response :status) 200))
+    (is (= (@response :content-type) "text/plain"))
+    (is (= (take-while (complement zero?) (@response :body))
+           (seq (.getBytes "Hello World"))))))
+
 (defservice "foo-"
   (fn [_]
     {:status  200


Remove v1 build steps

Remove v1 build steps

--- src-cljs/frontend/components/build_steps.cljs
+++ src-cljs/frontend/components/build_steps.cljs
@@ -34,117 +34,6 @@
     "db" "You specified this command on the project settings page"
     "Unknown source"))

-(defn output [out owner]
-  (reify
-    om/IRender
-    (render [_]
-      (let [message-html (:converted-message out)]
-        (html
-         [:span.pre {:dangerouslySetInnerHTML
-                     #js {"__html" message-html}}])))))
-
-(defn trailing-output [converters-state owner]
-  (reify
-    om/IRender
-    (render [_]
-      (let [trailing-out (action-model/trailing-output converters-state)]
-        (html
-         [:span {:dangerouslySetInnerHTML
-                 #js {"__html" trailing-out}}])))))
-
-
-
-(defn action [action owner {:keys [uses-parallelism?] :as opts}]
-  (reify
-    om/IRender
-    (render [_]
-      (let [visible? (action-model/visible? action)
-            header-classes  (concat [(:status action)]
-                                    (when visible?
-                                      ["open"])
-                                    (when (action-model/has-content? action)
-                                      ["contents"])
-                                    (when (action-model/failed? action)
-                                      ["failed"]))]
-        (html
-         [:div {:class (str "type-" (or (:type action) "none"))}
-          [:div.type-divider
-           [:span (:type action)]]
-          [:div.build-output
-           [:div.action_header {:class header-classes}
-            [:div.ah_wrapper
-             [:div.header {:class (when (action-model/has-content? action)
-                                    header-classes)
-                           ;; TODO: figure out what to put here
-                           :on-click #(raise! owner [:action-log-output-toggled
-                                                     {:index (:index @action)
-                                                      :step (:step @action)
-                                                      :value (not visible?)}])}
-              [:div.button {:class (when (action-model/has-content? action)
-                                     header-classes)}
-               (when (action-model/has-content? action)
-                 [:i.fa.fa-chevron-down])]
-              [:div.command {:class header-classes}
-               [:span.command-text {:title (:bash_command action)}
-                (str (when (= (:bash_command action)
-                              (:name action))
-                       "$ ")
-                     (:name action)
-                     (when (and uses-parallelism? (:parallel action))
-                       (gstring/format " (%s)" (:index action))))]
-               [:span.time {:title (str (:start_time action) " to "
-                                        (:end_time action))}
-                (om/build common/updating-duration {:start (:start_time action)
-                                                    :stop (:end_time action)})
-                (when (:timedout action) " (timed out)")]
-               [:span.action-source
-                [:span.action-source-inner {:title (source-title (:source action))}
-                 (source-type (:source action))]]]]
-             [:div.detail-wrapper
-              (when (and visible? (action-model/has-content? action))
-                [:div.detail {:class header-classes}
-                 (if (and (:has_output action)
-                          (nil? (:output action)))
-                   [:div.loading-spinner common/spinner]
-
-                   [:div.action-log-messages
-                    (common/messages (:messages action))
-                    [:i.click-to-scroll.fa.fa-arrow-circle-o-down.pull-right
-                     {:on-click #(utils/scroll-to-node-bottom (.-parentNode (.-currentTarget %)))}]
-
-                    (when (:bash_command action)
-                      [:span
-                       (when (:exit_code action)
-                         [:span.exit-code.pull-right
-                          (str "Exit code: " (:exit_code action))])
-                       [:pre.bash-command
-                        {:title "The full bash command used to run this setup"}
-                        (:bash_command action)]])
-                    [:pre.output.solarized {:style {:white-space "normal"}}
-                     (when (:truncated action)
-                       [:span.truncated "(this output has been truncated)"])
-                     (om/build-all output (:output action) {:key :react-key})
-
-                     (om/build trailing-output (:converters-state action))
-
-                     (when (:truncated action)
-                       [:span.truncated "(this output has been truncated)"])]])])]]]]])))))
-
-(defn container-view [{:keys [container non-parallel-actions]} owner {:keys [uses-parallelism?] :as opts}]
-  (reify
-    om/IRender
-    (render [_]
-      (let [container-id (container-model/id container)
-            actions (remove :filler-action
-                            (map (fn [action]
-                                   (get non-parallel-actions (:step action) action))
-                                 (:actions container)))]
-        (html
-         [:div.container-view {:style {:left (str (* 100 (:index container)) "%")}
-                               :id (str "container_" (:index container))}
-          (om/build-all action actions {:key :step
-                                        :opts opts})])))))
-
 (defn mount-browser-resize
   "Handles scrolling the container on the build page to the correct position when
   the size of the browser window chagnes. Has to add an event listener at the top level."
@@ -178,53 +67,7 @@

    :else nil))

-(defn container-build-steps [{:keys [containers current-container-id]} owner]
-  (reify
-    om/IInitState
-    (init-state [_]
-      {:autoscroll? false})
-    om/IDidMount
-    (did-mount [_]
-      (mount-browser-resize owner))
-    om/IWillUnmount
-    (will-unmount [_]
-      (dispose (om/get-state owner [:browser-resize-key])))
-    om/IDidUpdate
-    (did-update [_ _ _]
-      (when (om/get-state owner [:autoscroll?])
-        (when-let [node (utils/sel1 "#container_scroll_parent")]
-          (utils/scroll-to-node-bottom node))))
-    om/IRender
-    (render [_]
-      (let [non-parallel-actions (->> containers
-                                      first
-                                      :actions
-                                      (remove :parallel)
-                                      (map (fn [action]
-                                             [(:step action) action]))
-                                      (into {}))]
-        (html
-         [:div#container_scroll_parent ;; hides horizontal scrollbar
-          [:div#container_parent {:on-wheel (fn [e]
-                                              (check-autoscroll owner (aget e "deltaY"))
-                                              (when (not= 0 (aget e "deltaX"))
-                                                (.preventDefault e)
-                                                (let [body (.-body js/document)]
-                                                  (set! (.-scrollTop body) (+ (.-scrollTop body) (aget e "deltaY"))))))
-                                  :on-scroll (fn [e]
-                                               ;; prevent handling scrolling if we're animating the
-                                               ;; transition to a new selected container
-                                               (let [scroller (.. e -target -scroll_handler)]
-                                                 (when (or (not scroller) (.isStopped scroller))
-                                                   (raise! owner [:container-parent-scroll]))))
-                                  :class (str "selected_" current-container-id)}
-           (for [container containers]
-             (om/build container-view
-                       {:container container
-                        :non-parallel-actions non-parallel-actions}
-                       {:opts {:uses-parallelism? (< 1 (count containers))}}))]])))))
-
-(defn output-v2 [out owner]
+(defn output [out owner]
   (reify
     om/IRender
     (render [_]
@@ -233,7 +76,7 @@
          [:span.pre {:dangerouslySetInnerHTML
                      #js {"__html" message-html}}])))))

-(defn trailing-output-v2 [converters-state owner]
+(defn trailing-output [converters-state owner]
   (reify
     om/IRender
     (render [_]
@@ -242,7 +85,7 @@
           [:span {:dangerouslySetInnerHTML
                   #js {"__html" trailing-out}}])))))

-(defn action-v2 [action owner {:keys [uses-parallelism?] :as opts}]
+(defn action [action owner {:keys [uses-parallelism?] :as opts}]
   (reify
     om/IRender
     (render [_]
@@ -311,14 +154,14 @@
                      (when (:truncated action)
                        [:span.truncated "(this output has been truncated)"])

-                     (om/build-all output-v2 (:output action) {:key :react-key})
-
-                     (om/build trailing-output-v2 (:converters-state action))
+                     (om/build-all output (:output action) {:key :react-key})
+
+                     (om/build trailing-output (:converters-state action))

                      (when (:truncated action)
                        [:span.truncated "(this output has been truncated)"])]])])]]]]])))))

-(defn container-view-v2 [{:keys [container non-parallel-actions]} owner {:keys [uses-parallelism?] :as opts}]
+(defn container-view [{:keys [container non-parallel-actions]} owner {:keys [uses-parallelism?] :as opts}]
   (reify
     om/IRender
     (render [_]
@@ -329,10 +172,10 @@
                                  (:actions container)))]
         (html
          [:div.container-view {:id (str "container_" (:index container))}
-          (om/build-all action-v2 actions {:key :step
-                                           :opts opts})])))))
-
-(defn container-build-steps-v2 [{:keys [containers current-container-id]} owner]
+          (om/build-all action actions {:key :step
+                                        :opts opts})])))))
+
+(defn container-build-steps [{:keys [containers current-container-id]} owner]
   (reify
     om/IInitState
     (init-state [_]
@@ -363,7 +206,7 @@
                              (let [body (.-body js/document)]
                                (set! (.-scrollTop body) (+ (.-scrollTop body) (aget e "deltaY")))))
                  :class (str "selected_" current-container-id)}
-           (om/build container-view-v2
+           (om/build container-view
                      {:container (containers current-container-id)
                       :non-parallel-actions non-parallel-actions}
                      {:opts {:uses-parallelism? (< 1 (count containers))}})])))))


1.2-isms

--- dada-core/src/test/clojure/org/dada/dtrace.clj
+++ dada-core/src/test/clojure/org/dada/dtrace.clj
@@ -1,7 +1,7 @@
 (ns
  #^{:author "Jules Gosnell" :doc "Demo domain for DADA"}
  org.dada.dtrace
- (:use [clojure.contrib repl-utils trace])
+ ;;(:use [clojure.contrib repl-utils trace])
  (:import (org.slf4j Logger LoggerFactory))
  )


rename project to hello-famous

rename project to hello-famous

--- examples/hello-famous/project.clj
+++ examples/hello-famous/project.clj
@@ -1,4 +1,4 @@
-(defproject famous-examples "0.1.0-SNAPSHOT"
+(defproject hello-famous "0.1.0-SNAPSHOT"
             :description "FIXME: write this!"
             :url "http://example.com/FIXME"
             :license {:name "Eclipse Public License"