Use html form in statement-form

Use html form in statement-form

--- src/discuss/views/add.cljs
+++ src/discuss/views/add.cljs
@@ -28,24 +28,26 @@
                [:h5.text-center (:text (last bubbles))]
                (valerts/error-alert (om/props this))

-               [:div.input-group
-                [:span.input-group-addon.input-group-addon-left "... " (t :common :because)]
-                [:input.form-control {:style {:backgroundColor (when-not (nil? selected-search) "rgb(250,250,250)")}
-                                      :onChange #(do (om/update-state! this assoc :statement (.. % -target -value))
-                                                     (search/search statement))
-                                      :value (or (:text selected-search) statement "")
-                                      :placeholder (t :discussion :add-reason-placeholder)}]
-                (when-not (nil? selected-search)
-                  [:span.input-group-addon.pointer {:onClick search/remove-selected-search-result!}
-                   (vlib/fa-icon "fa-times")])]
+               [:form {:onSubmit #(do (.preventDefault %)
+                                      (com/post-statement {:statement statement
+                                                           :reference current-selection
+                                                           :search/selected selected-search}))}
+                [:div.input-group
+                 [:span.input-group-addon.input-group-addon-left "... " (t :common :because)]
+                 [:input.form-control {:style {:backgroundColor (when-not (nil? selected-search) "rgb(250,250,250)")}
+                                       :onChange #(do (om/update-state! this assoc :statement (.. % -target -value))
+                                                      (search/search statement))
+                                       :value (or (:text selected-search) statement "")
+                                       :placeholder (t :discussion :add-reason-placeholder)}]
+                 (when-not (nil? selected-search)
+                   [:span.input-group-addon.pointer {:onClick search/remove-selected-search-result!}
+                    (vlib/fa-icon "fa-times")])]

-               (vlib/show-selection)
-               [:button.btn.btn-default
-                {:onClick #(com/post-statement {:statement statement
-                                                :reference current-selection
-                                                :search/selected selected-search})
-                 :disabled (when (nil? selected-search) (> 10 (count statement)))}
-                (vlib/remaining-characters statement selected-search)]]])))
+                (vlib/show-selection)
+                [:button.btn.btn-default
+                 {:type :submit
+                  :disabled (when (nil? selected-search) (> 10 (count statement)))}
+                 (vlib/remaining-characters statement selected-search)]]]])))
   (componentDidMount [this] (search/remove-all-search-related-results-and-selections)))
 (def statement-form (om/factory StatementForm))


shifted scale and shape for gdp

shifted scale and shape for gdp

--- src/distributions/core.clj
+++ src/distributions/core.clj
@@ -39,7 +39,7 @@
 (defn gamma
   [shape rate]
   (new GammaDistribution shape (/ 1 rate)))
-(defrecord GeneralizedDoubleParetoDistribution [shape scale])
+(defrecord GeneralizedDoubleParetoDistribution [scale shape])
 (defn gdp
   [scale shape]
   (GeneralizedDoubleParetoDistribution. scale shape))


better protocols

better protocols

--- src/distributions/core.clj
+++ src/distributions/core.clj
@@ -43,7 +43,7 @@
   (new GumbelDistribution location scale))
 (defn hypergeometric
   [population-size number-successes sample-size]
-  (new hypergeometric population-size number-successes sample-size))
+  (new HypergeometricDistribution population-size number-successes sample-size))
 (defn laplace
   [location scale]
   (new LaplaceDistribution location scale))
@@ -97,82 +97,36 @@
   [number-of-elements exponent]
   (new ZipfDistribution number-of-elements exponent))

-
-(defprotocol univariate-real
-  (cdf [d] [d x])
+(defprotocol probability-function
+  (P [d] [d x]))
+(extend-protocol probability-function
+  IntegerDistribution
+  (P
+    ([d] (fn [x] (.probability d x)))
+    ([d x] (.probability d x)))
+  RealDistribution
+  (P
+    ([d] (fn [x] (.probability d x)))
+    ([d x] (.probability d x)))
+  )
+
+(defprotocol density-function
   (pdf [d] [d x])
-  (log-pdf [d] [d x])
-  (mean [d])
-  (variance [d])
-  (support-lower-bound [d])
-  (support-upper-bound [d])
-  (icdf [d] [d x])
-  (support-connected [d])
-  (sample [d] [d n]))
-
-(extend-type RealDistribution
-  univariate-real
-  (cdf
-    ([d x] (.cumulativeProbability d x))
-    ([d] (fn [x] (cdf d x))))
+  (log-pdf [d] [d x]))
+(extend-protocol density-function
+  RealDistribution
   (pdf
     ([d x] (.density d x))
     ([d] (fn [x] (pdf d x))))
   (log-pdf
     ([d x] (.logDensity d x))
-    ([d] (fn [x] (log-pdf d x))))
-  (mean [d] (.getNumericalMean d))
-  (variance [d] (.getNumericalVariance d))
-  (support-lower-bound [d] (.getSupportLowerBound d))
-  (support-upper-bound [d] (.getSupportUpperBound d))
-  (icdf
-    ([d x] (.inverseCumulativeProbability d x))
-    ([d] (fn [x] (icdf d x))))
-  (sample
-    ([d] (.sample d))
-    ([d n] (take n (repeatedly #(sample d)))))
-  )
-
-(extend-type AbstractRealDistribution
-  univariate-real
-  (cdf
-    ([d x] (.cumulativeProbability d x))
-    ([d] (fn [x] (cdf d x))))
-  (pdf
-    ([d x] (.density d x))
-    ([d] (fn [x] (pdf d x))))
-  (log-pdf
-    ([d x] (.logDensity d x))
-    ([d] (fn [x] (log-pdf d x))))
-  (mean [d] (.getNumericalMean d))
-  (variance [d] (.getNumericalVariance d))
-  (support-lower-bound [d] (.getSupportLowerBound d))
-  (support-upper-bound [d] (.getSupportUpperBound d))
-  (icdf
-    ([d x] (.inverseCumulativeProbability d x))
-    ([d] (fn [x] (icdf d x))))
-  (sample
-    ([d] (.sample d))
-    ([d n] (take n (repeatedly #(sample d)))))
-  )
-
-(defprotocol univariate-integer
-  (cdf [d] [d x])
+    ([d] (fn [x] (log-pdf d x)))))
+
+(defprotocol mass-function
   (pmf [d] [d x])
-  (log-pmf [d] [d x])
-  (mean [d])
-  (variance [d])
-  (support-lower-bound [d])
-  (support-upper-bound [d])
-  (icdf [d] [d x])
-  (support-connected [d])
-  (sample [d] [d n]))
-
-(extend-type IntegerDistribution
-  univariate-integer
-  (cdf
-    ([d x] (.cumulativeProbability d x))
-    ([d] (fn [x] (cdf d x))))
+  (log-pmf [d] [d x]))
+(extend-protocol mass-function
+  IntegerDistribution
   (pmf
     ([d x] (if (integer? x)
              (.probability d x)
@@ -182,46 +136,111 @@
     ([d x] (if (integer? x)
              (.logProbability d x)
              Double/NEGATIVE_INFINITY))
-    ([d] (fn [x] (log-pdf d x))))
+    ([d] (fn [x] (log-pmf d x))))
+  )
+
+(defprotocol distribution-function
+  (cdf [d] [d x]))
+(extend-protocol distribution-function
+  IntegerDistribution
+  (cdf
+    ([d] (fn [x] (.cumulativeProbability d x)))
+    ([d x] (.cumulativeProbability d x)))
+  RealDistribution
+  (cdf
+    ([d] (fn [x] (.cumulativeProbability d x)))
+    ([d x] (.cumulativeProbability d x)))
+  )
+
+(defprotocol inverse-distribution-function
+  (icdf [d] [d x]))
+(extend-protocol inverse-distribution-function
+  IntegerDistribution
+  (icdf
+    ([d] (fn [x] (.inverseCumulativeProbability d x)))
+    ([d x] (.inverseCumulativeProbability d x)))
+  RealDistribution
+  (icdf
+    ([d] (fn [x] (.inverseCumulativeProbability d x)))
+    ([d x] (.inverseCumulativeProbability d x)))
+  )
+
+(defprotocol support
+  (support [d])
+  (support-lower [d])
+  (support-upper [d])
+  )
+(extend-protocol support
+  IntegerDistribution
+  (support [d] [(support-lower d) (support-upper d)])
+  (support-lower [d] (.getSupportLowerBound d))
+  (support-upper [d] (.getSupportUpperBound d))
+  RealDistribution
+  (support [d] [(support-lower d) (support-upper d)])
+  (support-lower [d] (.getSupportLowerBound d))
+  (support-upper [d] (.getSupportUpperBound d))
+  )
+
+(defprotocol first-moment
+  (mean [d]))
+(extend-protocol first-moment
+  IntegerDistribution
   (mean [d] (.getNumericalMean d))
+  RealDistribution
+  (mean [d] (.getNumericalMean d))
+  )
+
+(defprotocol second-central-moment
+  (variance [d]))
+(extend-protocol second-central-moment
+  IntegerDistribution
   (variance [d] (.getNumericalVariance d))
-  (support-lower-bound [d] (.getSupportLowerBound d))
-  (support-upper-bound [d] (.getSupportUpperBound d))
-  (icdf
-    ([d x] (.inverseCumulativeProbability d x))
-    ([d] (fn [x] (icdf d x))))
+  RealDistribution
+  (variance [d] (.getNumericalVariance d))
+  )
+
+(defprotocol random
+  (sample [d] [d n]))
+(extend-protocol random
+  IntegerDistribution
   (sample
     ([d] (.sample d))
     ([d n] (take n (repeatedly #(sample d)))))
-  )
-
-(extend-type AbstractIntegerDistribution
-  univariate-integer
-  (cdf
-    ([d x] (.cumulativeProbability d x))
-    ([d] (fn [x] (cdf d x))))
-  (pmf
-    ([d x] (if (integer? x)
-             (.probability d x)
-             0))
-    ([d] (fn [x] (pdf d x))))
-  (log-pmf
-    ([d x] (if (integer? x)
-             (.logProbability d x)
-             Double/NEGATIVE_INFINITY))
-    ([d] (fn [x] (log-pdf d x))))
-  (mean [d] (.getNumericalMean d))
-  (variance [d] (.getNumericalVariance d))
-  (support-lower-bound [d] (.getSupportLowerBound d))
-  (support-upper-bound [d] (.getSupportUpperBound d))
-  (icdf
-    ([d x] (.inverseCumulativeProbability d x))
-    ([d] (fn [x] (icdf d x))))
+  RealDistribution
   (sample
     ([d] (.sample d))
     ([d n] (take n (repeatedly #(sample d)))))
   )

+
+
 (defprotocol exponential-family
   (natural-parameters [dist] )
   (play [dist] (.getMean dist)))
+
+(defn arithmetic-mean [coll]
+  (if (empty? coll)
+    nil
+    (let [sum (reduce + 0 coll)
+          n (count coll)]
+      (/ sum n))))
+
+
+(Math/exp 3)
+(defn quantile-integrate
+  ([f d n]
+   (let [delta (/ 1.0 n)
+         grid (map (icdf d) (range delta 1 delta))
+         f_i (map f grid)]
+     (/ (reduce + 0 f_i) n))))
+
+(sample (normal 0 1))
+
+(def N (normal 0 1))
+(def sample-size 10000)
+(def draws (sort (sample N sample-size)))
+(def cdfs (map (cdf N) draws))
+(def zips (map vector (drop 1 cdfs) cdfs))
+(def deltas (map (fn [x] (- (first x) (second x))) zips))
+
+(sample (normal 0 1))


[scamp] remove old println in 'receive-msg-node-unsubscription-test

--- modules/scamp/test/world/main_test.clj
+++ modules/scamp/test/world/main_test.clj
@@ -122,7 +122,6 @@
                     main/world-do-all-comms
                     (main/world-instruct-node-to-unsubscribe "node-id19")
                     main/world-do-comm)]
-      (clojure.pprint/pprint (:message-envelopes world))
       (is (= (:message-envelopes world)
              [[:message-envelope
                "node-id16"


[FLINK-9892][tests] Disable local recovery in Jepsen tests.

This closes #6369.

--- flink-jepsen/src/jepsen/flink/db.clj
+++ flink-jepsen/src/jepsen/flink/db.clj
@@ -56,7 +56,7 @@
    :taskmanager.numberOfTaskSlots      taskmanager-slots
    :yarn.application-attempts          99999
    :slotmanager.taskmanager-timeout    10000
-   :state.backend.local-recovery       "true"
+   :state.backend.local-recovery       "false"
    :taskmanager.registration.timeout   "30 s"})

 (defn master-nodes


Add a constructor for alists

Add a constructor for alists

--- src/useful/deftype.clj
+++ src/useful/deftype.clj
@@ -114,3 +114,6 @@
         meta)
   (withMeta [this meta]
             (AList. entries meta)))
+
+(defn alist [& kvs]
+  (AList. (apply list (map vec (partition 2 kvs))) nil))


Make NativeWrapper thinner

Make NativeWrapper thinner

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -14,7 +14,7 @@
              from a tag name."}
   re-tag #"([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?")

-(deftype NativeWrapper [comp])
+(deftype NativeWrapper [])

 ;;; Common utilities
@@ -221,9 +221,10 @@
     (.' js/React createElement c jsprops)))

 (defn adapt-react-class [c]
-  (NativeWrapper. #js{:name c
-                      :id nil
-                      :class nil}))
+  (doto (NativeWrapper.)
+    (.! :name c)
+    (.! :id nil)
+    (.! :class nil)))

 (def tag-name-cache #js{})

@@ -283,7 +284,7 @@
                   (assoc v 0 (subs n (inc pos)))])))

       (instance? NativeWrapper tag)
-      (native-element (.-comp tag) v 1)
+      (native-element tag v 1)

       :else (reag-element tag v))))


Reduce unnecessary evaluation of synthetic properties

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -343,9 +343,7 @@

 (defn native-element [parsed argv first]
   (let [comp ($ parsed :name)
-        synthetic-input ($ parsed :syntheticInput)
-        synthetic-on-update ($ parsed :syntheticOnUpdate)
-        synthetic-on-change ($ parsed :syntheticOnChange)]
+        synthetic-input ($ parsed :syntheticInput)]
     (let [props (nth argv first nil)
           hasprops (or (nil? props) (map? props))
           jsprops (convert-props (if hasprops props) parsed)
@@ -353,7 +351,13 @@
       (if (or synthetic-input (input-component? comp))
         (-> (if synthetic-input
               ;; If we are dealing with a synthetic input, use the synthetic-input-spec form:
-              [(reagent-synthetic-input) synthetic-on-update synthetic-on-change argv comp jsprops first-child]
+              [(reagent-synthetic-input)
+               ($ parsed :syntheticOnUpdate)
+               ($ parsed :syntheticOnChange)
+               argv
+               comp
+               jsprops
+               first-child]
               ;; Else use the regular input-spec form:
               [(reagent-input) argv comp jsprops first-child])
             (with-meta (meta argv))


Logelei 2 checked

Logelei 2 checked

--- src/examples/logelei_2.clj
+++ src/examples/logelei_2.clj
@@ -69,4 +69,10 @@
     (retransform-tseitin result tseit)))

 (filter literal? solution)
-; Ergebnis kontrollieren
+; eigenartiges Ergebnis
+
+; Ergebnis kontrollieren:
+
+(def evals ['beutelaffen-kratzen false 'fiedertiger-pfeifen false 'fiedertiger-surren false 'fiedertiger-zischen true 'nagekühe-kratzen false 'nagekühe-miauen false 'nagekühe-oinken false 'nagekühe-pfeifen false 'nagekühe-surren false 'nagekühe-zischen true 'ohrhörner-kratzen true 'beutelaffen-miauen false 'ohrhörner-miauen false 'ohrhörner-oinken false 'ohrhörner-pfeifen false 'ohrhörner-surren false 'ohrhörner-zischen false 'rüsselratten-kratzen true 'rüsselratten-miauen false 'rüsselratten-oinken false 'rüsselratten-pfeifen false 'rüsselratten-surren false 'beutelaffen-oinken false 'rüsselratten-zischen false 'tentakelläufer-kratzen true 'tentakelläufer-miauen false 'tentakelläufer-oinken false 'tentakelläufer-pfeifen false 'tentakelläufer-surren false 'tentakelläufer-zischen false 'beutelaffen-pfeifen false 'beutelaffen-surren true 'beutelaffen-zischen false 'fiedertiger-kratzen false 'fiedertiger-miauen false 'fiedertiger-oinken false])
+(eval-formula fml evals)
+; true


That should've been inside the let

That should've been inside the let

--- src/exploud/deployment.clj
+++ src/exploud/deployment.clj
@@ -170,9 +170,8 @@
                                    :oldAutoScalingGroupName])]
     (asgard/delete-asg
      environment region asg deployment-id task task-finished task-timed-out)
-    (do
-      (let [task (assoc (util/append-to-task-log "No old ASG to delete")
-                   :status "skipped")])
+    (let [task (assoc (util/append-to-task-log "No old ASG to delete")
+                 :status "skipped")]
       (task-finished deployment-id task))))

 (defn start-task


CMR-5037: Modify DIF10 temporal validation.

* Use date-at-str and dates-at-str to expose dates to temporal
validation.

--- umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
+++ umm-spec-lib/src/cmr/umm_spec/xml_to_umm_mappings/dif10.clj
@@ -117,11 +117,11 @@
                (cond
                  (and bdt-valid?
                       edt-valid?)
-                 {:BeginningDateTime (date/with-default bdt sanitize?)
+                 {:BeginningDateTime (date/with-default (str (dtp/parse-datetime bdt)) sanitize?)
                   :EndingDateTime (parse-dif-end-date edt)}
                  (and bdt-valid?
                       (not edt-valid?))
-                 {:BeginningDateTime (date/with-default bdt sanitize?)}
+                 {:BeginningDateTime (date/with-default (str (dtp/parse-datetime bdt)) sanitize?)}
                  (and (not bdt-valid?)
                       edt-valid?)
                  nil
@@ -140,10 +140,10 @@
                               {:PrecisionOfSeconds (value-of temporal "Precision_Of_Seconds")
                                :EndsAtPresentFlag (value-of temporal "Ends_At_Present_Flag")
                                :RangeDateTimes (parse-range-date-times temporal sanitize?)
-                               :SingleDateTimes (values-at temporal "Single_DateTime")
+                               :SingleDateTimes (dates-at-str temporal "Single_DateTime")
                                :PeriodicDateTimes (for [pdt (select temporal "Periodic_DateTime")]
                                                     {:Name (value-of pdt "Name")
-                                                     :StartDate (value-of pdt "Start_Date")
+                                                     :StartDate (date-at pdt "Start_Date")
                                                      :EndDate (parse-dif-end-date (value-of pdt "End_Date"))
                                                      :DurationUnit (value-of pdt "Duration_Unit")
                                                      :DurationValue (value-of pdt "Duration_Value")


Fix mistake in previous language fix.

Fix mistake in previous language fix.

--- src/grafter/rdf/sesame.clj
+++ src/grafter/rdf/sesame.clj
@@ -177,7 +177,7 @@
                            (->sesame-rdf-type (pr/predicate this))
                            (->sesame-rdf-type (pr/object this))
                            (when-let [context (pr/context this)]
-                             (->sesame-rdf-type (pr/context context)))))
+                             (->sesame-rdf-type context))))

   Value
   (->sesame-rdf-type [this]


update arguments

update arguments

--- src/graphql_clj/parser.clj
+++ src/graphql_clj/parser.clj
@@ -51,7 +51,10 @@
                 [:arguments (into {} args)])
    :Argument (fn argument [& args]
                (log/debug "Argument: " args)
-               (into {} args))
+               (let [m (into {} args)
+                     name (:name m)
+                     value (:value m)]
+                 [name value]))
    :IntValue (fn int-value [v]
                (log/debug "IntValue: " v)
                (Integer/parseInt v))
@@ -60,7 +63,10 @@
                  (Double. v))
    :Name (fn name [v]
            (log/debug "Name: " v)
-           [:name v])})
+           [:name v])
+   :Value (fn value [v]
+            (log/debug "Value: " v)
+            [:value v])})

 (defn transformer
   [parse-tree]


Add form.

Add form.

--- src/lab_notebook/core.cljs
+++ src/lab_notebook/core.cljs
@@ -17,9 +17,23 @@
   (reify
     om/IRender
     (render [this]
-      (apply dom/div nil
-        (for [entry (:entries cursor)]
-          (om/build item-view entry))))))
+      (dom/div nil
+        (apply dom/div nil
+          (for [entry (:entries cursor)]
+            (om/build item-view entry)))
+        (dom/div nil
+          (dom/h3 nil "New entry")
+          (dom/form #js {:className "form-horizontal"}
+            (dom/input #js {:type "text"
+                            :className "form-control"
+                            :placeholder "Summary"})
+            (dom/input #js {:type "text"
+                            :className "form-control"
+                            :placeholder "Time"})
+            (dom/textarea #js {:className "form-control":placeholder "Notes"
+                               :rows "5"})
+            (dom/button #js {:className "btn btn-primary"}
+              "Save")))))))

 (defn app-container [cursor component]
   (reify


include the project name in the project creation output

--- src/leiningen/new/yawt.clj
+++ src/leiningen/new/yawt.clj
@@ -72,7 +72,7 @@
   [["src/{{path}}/db.clj" (render "src/root_ns/db_couchdb.clj" data)]])

 (defn make-project! [options data]
-  (main/info "Generating a new YAWT project using options:" (str/join ", " options))
+  (main/info "Generating a new YAWT project called" (:name data) "using options:" (str/join ", " options))
   (apply ->files data
          (concat
            (get-base-files data)


fix typo

fix typo

--- labs/architecture-examples/om/src/todomvc/app.cljs
+++ labs/architecture-examples/om/src/todomvc/app.cljs
@@ -39,7 +39,7 @@
 (defn footer [{:keys [todos] :as app} opts]
   (let [{:keys [active completed showing chans]} opts
         clear-button (when (pos? completed)
-                       (dom/buttton
+                       (dom/button
                          #js {:id "clear-completed"
                               :onClick #(put! (:clear chans) (now))}
                          (str "Clear completed " completed)))


make :node-test :main configurable

make :node-test :main configurable

defaults to shadow.test.node/main

--- src/main/shadow/build/targets/node_test.clj
+++ src/main/shadow/build/targets/node_test.clj
@@ -1,92 +1,86 @@
-(ns shadow.build.targets.node-test
-  (:refer-clojure :exclude (compile flush resolve))
-  (:require [clojure.string :as str]
-            [shadow.build :as build]
-            [shadow.build.modules :as modules]
-            [shadow.build.classpath :as cp]
-            [shadow.build.targets.node-script :as node-script]
-            [shadow.cljs.util :as util]
-            [shadow.cljs.devtools.server.util :refer (pipe)]
-            [hiccup.page :refer (html5)]
-            [clojure.java.io :as io]
-            [cljs.compiler :as cljs-comp]
-            [shadow.build.api :as build-api]
-            [shadow.build.output :as output]
-            [shadow.build.data :as data]
-            [shadow.build.async :as async])
-  (:import [java.lang ProcessBuilder$Redirect]))
-
-(defn configure [{::build/keys [config mode] :as state}]
-  (-> state
-      (assoc-in [:compiler-options :closure-defines 'cljs.core/*target*] "nodejs")
-      (update :build-options merge {:greedy true
-                                    :dynamic-resolve true})
-      ;; FIXME: allow custom :runner-ns?
-      (update ::build/config merge {:main 'shadow.test.node/main})
-      (update-in [::build/config :devtools] assoc :enabled false)))
-
-;; since :configure is only called once in :dev
-;; we delay setting the :entries until compile-prepare which is called every cycle
-;; need to come up with a cleaner API for this
-(defn test-resolve
-  [{:keys [classpath] ::build/keys [mode config] :as state}]
-  (let [{:keys [ns-regexp] :or {ns-regexp "-test$"}}
-        config
-
-        test-namespaces
-        (->> (cp/get-all-resources classpath)
-             (filter :file) ;; only test with files, ie. not tests in jars.
-             (filter #(= :cljs (:type %)))
-             (map :ns)
-             (filter (fn [ns]
-                       (re-find (re-pattern ns-regexp) (str ns))))
-             (into []))
-
-        entries
-        (-> '[shadow.test.env] ;; must be included before any deftest because of the cljs.test mod
-            (into test-namespaces)
-            (conj 'shadow.test.node))]
-
-    (-> state
-        (assoc-in [::modules/config :main :entries] entries)
-        ;; re-analyze modules since we modified the entries
-        (modules/analyze))))
-
-(defn autorun-test [{::build/keys [config] :as state}]
-  (util/with-logged-time
-    [state {:type ::autorun}]
-    (let [script-args
-          ["node" (:output-to config)]
-
-          proc
-          (-> (ProcessBuilder. (into-array script-args))
-              (.directory nil)
-              (.start))]
-
-      (println "========= Running Tests =======================")
-
-      (.start (Thread. (bound-fn [] (pipe proc (.getInputStream proc) *out*))))
-      (.start (Thread. (bound-fn [] (pipe proc (.getErrorStream proc) *err*))))
-
-      ;; FIXME: what if this doesn't terminate?
-      (let [exit-code (.waitFor proc)]
-        (println "===============================================")
-        (assoc state ::exit-code exit-code)))))
-
-(defn process
-  [{::build/keys [stage mode config] :as state}]
-  (-> state
-      (cond->
-        (= stage :configure)
-        (configure)
-
-        (= stage :resolve)
-        (test-resolve))
-
-      (node-script/process)
-      (cond->
-        (and (= stage :flush)
-             (:autorun config))
-        (-> (async/wait-for-pending-tasks!)
-            (autorun-test))
+(ns shadow.build.targets.node-test
+  (:refer-clojure :exclude (compile flush resolve))
+  (:require [clojure.string :as str]
+            [shadow.build :as build]
+            [shadow.build.modules :as modules]
+            [shadow.build.classpath :as cp]
+            [shadow.build.targets.node-script :as node-script]
+            [shadow.cljs.util :as util]
+            [shadow.cljs.devtools.server.util :refer (pipe)]
+            [shadow.build.async :as async]))
+
+(defn configure [{::build/keys [config mode] :as state}]
+  (-> state
+      (assoc-in [:compiler-options :closure-defines 'cljs.core/*target*] "nodejs")
+      (update :build-options merge {:greedy true
+                                    :dynamic-resolve true})
+      (update ::build/config merge {:main (get config :main 'shadow.test.node/main)})
+      (update-in [::build/config :devtools] assoc :enabled false)))
+
+;; since :configure is only called once in :dev
+;; we delay setting the :entries until compile-prepare which is called every cycle
+;; need to come up with a cleaner API for this
+(defn test-resolve
+  [{:keys [classpath] ::build/keys [mode config] :as state}]
+  (let [{:keys [ns-regexp] :or {ns-regexp "-test$"}}
+        config
+
+        test-namespaces
+        (->> (cp/get-all-resources classpath)
+             (filter :file) ;; only test with files, ie. not tests in jars.
+             (filter #(= :cljs (:type %)))
+             (map :ns)
+             (filter (fn [ns]
+                       (re-find (re-pattern ns-regexp) (str ns))))
+             (into []))
+
+        entries
+        (-> '[shadow.test.env] ;; must be included before any deftest because of the cljs.test mod
+            (into test-namespaces)
+            (conj (or (when-let [main (:main config)]
+                        (-> main namespace symbol))
+                      'shadow.test.node)))]
+
+    (-> state
+        (assoc-in [::modules/config :main :entries] entries)
+        ;; re-analyze modules since we modified the entries
+        (modules/analyze))))
+
+(defn autorun-test [{::build/keys [config] :as state}]
+  (util/with-logged-time
+    [state {:type ::autorun}]
+    (let [script-args
+          ["node" (:output-to config)]
+
+          proc
+          (-> (ProcessBuilder. (into-array script-args))
+              (.directory nil)
+              (.start))]
+
+      (println "========= Running Tests =======================")
+
+      (.start (Thread. (bound-fn [] (pipe proc (.getInputStream proc) *out*))))
+      (.start (Thread. (bound-fn [] (pipe proc (.getErrorStream proc) *err*))))
+
+      ;; FIXME: what if this doesn't terminate?
+      (let [exit-code (.waitFor proc)]
+        (println "===============================================")
+        (assoc state ::exit-code exit-code)))))
+
+(defn process
+  [{::build/keys [stage mode config] :as state}]
+  (-> state
+      (cond->
+        (= stage :configure)
+        (configure)
+
+        (= stage :resolve)
+        (test-resolve))
+
+      (node-script/process)
+      (cond->
+        (and (= stage :flush)
+             (:autorun config))
+        (-> (async/wait-for-pending-tasks!)
+            (autorun-test))
         )))


disable protected workspace checkbox when appropriate in clone dialog

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/workspace_cloner.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/summary/workspace_cloner.cljs
@@ -46,7 +46,14 @@
                                        :defaultValue (:description props)})
               (if (:is-protected? props)
                 [:div {} "Cloned workspace will automatically be protected because this workspace is protected."]
-                [comps/Checkbox {:ref "protected-check" :label "Workspace intended to contain NIH protected data"}])
+                [comps/Checkbox
+                 {:ref "protected-check"
+                  :label "Workspace intended to contain NIH protected data"
+                  :disabled? (not= (:protected-option @state) :enabled)
+                  :disabled-text (case (:protected-option @state)
+                                       :not-loaded "Account status has not finished loading."
+                                       :not-available "This option is not available for your account."
+                                       nil)}])
               (style/create-validation-error-message (:validation-error @state))
               [comps/ErrorViewer {:error (:error @state)
                                   :expect {409 "A workspace with this name already exists in this project"}}]])
@@ -57,8 +64,14 @@
        :get-first-element-dom-node #(@refs "project")
        :get-last-element-dom-node #(react/find-dom-node (@refs "okButton"))}])
    :component-did-mount
-   (fn []
-     (common/scroll-to-top 100))
+   (fn [{:keys [state]}]
+     (common/scroll-to-top 100)
+     (utils/ajax-orch
+       "/nih/status"
+       {:on-done (fn [{:keys [success? get-parsed-response]}]
+                     (if (and success? (get (get-parsed-response) "isDbgapAuthorized"))
+                       (swap! state assoc :protected-option :enabled)
+                       (swap! state assoc :protected-option :not-available)))}))
    :do-clone
    (fn [{:keys [props refs state]}]
      (if-let [fails (input/validate refs "name")]


tile fixes so far

tile fixes so far

--- src/metabase/api/tiles.clj
+++ src/metabase/api/tiles.clj
@@ -1,5 +1,6 @@
 (ns metabase.api.tiles
-  (:require [clojure.data.json :as json]
+  (:require [clojure.core.match :refer [match]]
+            [clojure.data.json :as json]
             [clojure.tools.logging :as log]
             [compojure.core :refer [GET]]
             [metabase.api.common :refer :all]
@@ -7,10 +8,10 @@
             [metabase.driver :as driver]))

-(def tile-size 256)
-(def pixel-origin (float (/ tile-size 2)))
-(def pixel-per-lon-degree (float (/ tile-size 360.0)))
-(def pixel-per-lon-radian (float (/ tile-size (* 2 java.lang.Math/PI))))
+(def ^:const tile-size 256)
+(def ^:const pixel-origin (float (/ tile-size 2)))
+(def ^:const pixel-per-lon-degree (float (/ tile-size 360.0)))
+(def ^:const pixel-per-lon-radian (float (/ tile-size (* 2 java.lang.Math/PI))))

 (defn- radians->degrees [rad]
   (/ rad (float (/ java.lang.Math/PI 180))))
@@ -18,13 +19,13 @@
 (defn- tile-lat-lon
   "Get the Latitude & Longitude of the upper left corner of a given tile"
   [x y zoom]
-  (let [num-tiles (bit-shift-left 1 zoom)
-        corner-x (float (/ (* x tile-size) num-tiles))
-        corner-y (float (/ (* y tile-size) num-tiles))
-        lon (float (/ (- corner-x pixel-origin) pixel-per-lon-degree))
+  (let [num-tiles   (bit-shift-left 1 zoom)
+        corner-x    (float (/ (* x tile-size) num-tiles))
+        corner-y    (float (/ (* y tile-size) num-tiles))
+        lon         (float (/ (- corner-x pixel-origin) pixel-per-lon-degree))
         lat-radians (/ (- corner-y pixel-origin) (* pixel-per-lon-radian -1))
-        lat (radians->degrees (- (* 2 (java.lang.Math/atan (java.lang.Math/exp lat-radians)))
-                                   (/ java.lang.Math/PI 2)))]
+        lat          (radians->degrees (- (* 2 (java.lang.Math/atan (java.lang.Math/exp lat-radians)))
+                                          (/ java.lang.Math/PI 2)))]
     {:lat lat
      :lon lon}))

@@ -36,44 +37,46 @@
         {bot-rt-lat :lat bot-rt-lon :lon} (tile-lat-lon (+ x 1) (+ y 1) zoom)
         inside-filter ["INSIDE", lat-field-id, lon-field-id, top-lt-lat, top-lt-lon, bot-rt-lat, bot-rt-lon]]
     (update-in details [:filter]
-      #(clojure.core.match/match %
-        nil         inside-filter
-        ["AND" & _] (conj % inside-filter)
-        [& _]       (conj ["AND"] % inside-filter)))))
+      #(match %
+        ["AND" & _]              (conj % inside-filter)
+        [(_ :guard string?) & _] (conj ["AND"] % inside-filter)
+        :else                    inside-filter))))

 (defn- extract-points
   "Takes in a dataset query result object and pulls out the Latitude/Longitude pairs into nested `java.util.ArrayLists`.
    This is specific to the way we plan to feed data into `com.metabase.corvus.api.tiles.GoogleMapPinsOverlay`."
   [{{:keys [rows cols]} :data}]
-  (if-not (> (count rows) 0)
-    ;; if we have no rows then return an empty list of points
-    (java.util.ArrayList. [])
-    ;; otherwise we go over the data, pull out the lat/lon columns, and convert them to ArrayLists
-    (let [find-col-idx (fn [special-type]
-                         (->> (map-indexed (fn [idx itm] (when (= special-type (:special_type itm)) idx)) cols)
-                              (filter identity)
-                              (first)))
-          lat-col-idx (find-col-idx "latitude")
-          lon-col-idx (find-col-idx "longitude")]
-      (->> (map (fn [row] (java.util.ArrayList. [(nth row lat-col-idx) (nth row lon-col-idx)])) rows)
-           (java.util.ArrayList.)))))
+  (try
+    (if-not (> (count rows) 0)
+      ;; if we have no rows then return an empty list of points
+      (java.util.ArrayList. [])
+      ;; otherwise we go over the data, pull out the lat/lon columns, and convert them to ArrayLists
+      (let [find-col-idx (fn [special-type]
+                           (->> (map-indexed (fn [idx itm] (when (= special-type (:special_type itm)) idx)) cols)
+                                (filter identity)
+                                first))
+            lat-col-idx (find-col-idx "latitude")
+            lon-col-idx (find-col-idx "longitude")]
+        (->> (map (fn [row] (java.util.ArrayList. [(nth row lat-col-idx) (nth row lon-col-idx)])) rows)
+             (java.util.ArrayList.))))
+    (catch Throwable e
+      (log/debug "CAUGHT EXCEPTION IN EXTRACT-POINTS (WHY?): " e))))

-;; This endpoints provides an image with the appropriate pins rendered given a json query
-;; We evaluate the query and find the set of lat/lon pairs which are relevant and then render the appropriate ones
-;; It's expected that to render a full map view several calls will be made to this endpoint in parallel
 (defendpoint GET "/:zoom/:x/:y/:lat-field/:lon-field/:lat-col-idx/:lon-col-idx/"
+  "This endpoints provides an image with the appropriate pins rendered given a json query.
+   We evaluate the query and find the set of lat/lon pairs which are relevant and then render the appropriate ones.
+   It's expected that to render a full map view several calls will be made to this endpoint in parallel."
   [zoom x y lat-field lon-field lat-col-idx lon-col-idx query :as request]
-  {zoom String->Integer
-   x String->Integer
-   y String->Integer
-   lat-field String->Integer
-   lon-field String->Integer
+  {zoom        String->Integer
+   x           String->Integer
+   y           String->Integer
+   lat-field   String->Integer
+   lon-field   String->Integer
    lat-col-idx String->Integer
    lon-col-idx String->Integer
-   query String->Dict}
-  ;; TODO - tried to use `query String->Dict` above, but got errors with json parsing for some reason
+   query       String->Dict}
   (let [updated-query (assoc query :query (query-with-inside-filter (:query query) lat-field lon-field x y zoom))
         result (driver/dataset-query updated-query {:executed_by *current-user-id*
                                                     :synchronously true})


working on secondary view

working on secondary view

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

--- plugins/SlideExplorer2/src/slide_explorer/view.clj
+++ plugins/SlideExplorer2/src/slide_explorer/view.clj
@@ -245,27 +245,34 @@
     .show
     (.setBounds 10 10 500 500)))

-(defn show [memory-tiles acquired-images]
+(defn view-panel [memory-tiles acquired-images]
   (let [screen-state (atom (sorted-map :x 0 :y 0 :z 0 :zoom 1
                                        :width 100 :height 10
                                        :keys (sorted-set)
                                        :channels (sorted-map))
                                        :update 0)
         overlay-tiles (atom (cache/empty-lru-map 100))
-        panel (main-panel screen-state overlay-tiles)
-        frame (main-frame)]
-    (def mt memory-tiles)
-    (def ss screen-state)
-    (def f frame)
-    (def pnl panel)
-    (def ot overlay-tiles)
-    (def ai acquired-images)
-    (.add (.getContentPane frame) panel)
-    (setup-fullscreen frame)
+        panel (main-panel screen-state overlay-tiles)]
     (load-visible-only screen-state memory-tiles
                        overlay-tiles acquired-images)
     (repaint-on-change panel [screen-state memory-tiles overlay-tiles])
+    [panel screen-state]))
+
+(defn show [memory-tiles acquired-images]
+  (let [frame (main-frame)
+        frame2 (doto (JFrame. "test") .show)
+        [panel screen-state] (view-panel memory-tiles acquired-images)
+        [panel2 screen-state2] (view-panel memory-tiles acquired-images)]
+    (def ss screen-state)
+    (def pnl panel)
+    (def mt memory-tiles)
+    (def f frame)
+    (def ai acquired-images)
+    (.add (.getContentPane frame) panel)
+    (.add (.getContentPane frame2) panel2)
+    (setup-fullscreen frame)
     (make-view-controllable panel screen-state)
+    (make-view-controllable panel2 screen-state2)
     ;(handle-open frame)
     screen-state))


[#8123] Show fetch more messages only after sync

--- src/status_im/chat/db.cljs
+++ src/status_im/chat/db.cljs
@@ -160,6 +160,8 @@
         (if (and
              public?
              all-loaded?
+             (not (nil? highest-request-to))
+             (not (nil? lowest-request-from))
              (< (- highest-request-to lowest-request-from)
                 mailserver/max-gaps-range))
           (update acc :messages conj {:type       :gap


(TK-5) Add dummy assertions

(TK-5) Add dummy assertions

Add dummy assertions to the end of added test cases, as these
test cases simply run a function and fail if an exception
was generated.

--- test/puppetlabs/trapperkeeper/core_test.clj
+++ test/puppetlabs/trapperkeeper/core_test.clj
@@ -79,11 +79,13 @@

   (testing "TK should allow the user to omit the --config arg"
     ;; Make sure args will be parsed if no --config arg is provided; will throw an exception if not
-    (parse-cli-args! []))
+    (parse-cli-args! [])
+    (is (true? true)))

   (testing "TK should use an empty config if none is specified"
     ;; Make sure data will be parsed if no path is provided; will throw an exception if not.
-    (config/parse-config-data {})))
+    (config/parse-config-data {})
+    (is (true? true))))

 (deftest test-cli-args
   (testing "debug mode is off by default"


cleanup

cleanup

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/state/comm.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/state/comm.cljs
@@ -12,10 +12,11 @@
   "Process messages from the stats channel and update application state accordingly."
   [stats-chan app]
   (go-loop []
-           (let [[msg-type msg] (<! stats-chan)]
-             (match [msg-type msg]
+           (let [msg (<! stats-chan)]
+             (match msg
                     [:stats/users-count       n] (swap! app assoc :users-count n)
-                    [:stats/total-tweet-count n] (swap! app assoc :total-tweet-count n))
+                    [:stats/total-tweet-count n] (swap! app assoc :total-tweet-count n)
+                    :else (prn "unknown msg in stats-loop" msg))
              (recur))))

 (defn- prev-chunks-loop
@@ -37,31 +38,31 @@
   (let [prev-chunks-chan (chan)]
     (prev-chunks-loop prev-chunks-chan app)
     (go-loop []
-             (let [[msg-type msg] (<! data-chan)]
-               (match [msg-type msg]
+             (let [msg (<! data-chan)]
+               (match msg
                       [:tweet/new             tweet] (p/add-tweet! tweet app)
                       [:tweet/missing-tweet   tweet] (p/add-to-tweets-map! app :tweets-map tweet)
                       [:tweet/prev-chunk prev-chunk] (do
                                                        (put! prev-chunks-chan prev-chunk)
                                                        (s/load-prev app qry-chan))
-                      :else ())
+                      :else (prn "unknown msg in data-loop" msg))
                (recur)))))

 (defn- cmd-loop
   "Process command messages, e.g. those that alter application state."
   [cmd-chan pub-chan qry-chan app]
   (go-loop []
-           (let [[msg-type msg] (<! cmd-chan)]
-             (match [msg-type msg]
-                    [:toggle-live           _] (swap! app update :live #(not %))
+           (let [msg (<! cmd-chan)]
+             (match msg
+                    [:toggle-live            ] (swap! app update :live not)
                     [:set-search-text    text] (swap! app assoc :search-text text)
                     [:set-current-page   page] (swap! app assoc :page page)
                     [:set-page-size         n] (swap! app assoc :n n)
-                    [:start-search          _] (s/start-search app (i/initial-state) qry-chan)
+                    [:start-search           ] (s/start-search app (i/initial-state) qry-chan)
                     [:set-sort-order by-order] (swap! app assoc :sorted by-order)
                     [:retrieve-missing id-str] (put! qry-chan [:cmd/missing {:id_str id-str}])
                     [:append-search-text text] (s/append-search-text text app)
-                    :else ())
+                    :else (prn "unknown msg in cmd-loop" msg))
              (recur))))

 (defn- broadcast-state


Remove state related tests.

Remove state related tests.

--- test/cats/labs/state_spec.cljc
+++ test/cats/labs/state_spec.cljc
@@ -1,110 +0,0 @@
-(ns cats.labs.state-spec
-  #?(:cljs
-     (:require [cljs.test :as t]
-               [cats.builtin :as b]
-               [cats.protocols :as p]
-               [cats.data :as d]
-               [cats.labs.state :as state]
-               [cats.monad.maybe :as maybe]
-               [cats.context :as ctx :include-macros true]
-               [cats.core :as m :include-macros true])
-     :clj
-     (:require [clojure.test :as t]
-               [cats.builtin :as b]
-               [cats.protocols :as p]
-               [cats.data :as d]
-               [cats.labs.state :as state]
-               [cats.monad.maybe :as maybe]
-               [cats.context :as ctx]
-               [cats.core :as m])))
-
-(t/deftest get-state-should-return-the-identity-test
-  (let [computation (state/get-state)]
-    (t/is (= :foo (state/exec-state computation :foo)))))
-
-(t/deftest swap-state-should-apply-function-to-state-and-return-it-test
-  (let [computation (state/swap-state inc)]
-    (t/is (= 2 (state/exec-state computation 1)))))
-
-(t/deftest put-state-should-override-the-state
-  (let [computation (state/put-state 42)]
-    (t/is (= 42 (state/exec-state computation 0)))))
-
-(t/deftest state-monad-in-mlet-composition
-  ;; State monad composition with mlet should return state
-  (let [res (m/mlet [s (state/get-state)]
-              (m/return (inc s)))]
-    (t/is (state/state? res))
-    (let [res (state/run-state res 1)]
-      (t/is (d/pair? res))
-      (t/is (= 2 (first res)))
-      (t/is (= 1 (second res))))))
-
-(t/deftest state-monad-can-be-mapped-over
-  ;; State monad computations can be mapped over
-  (let [res (m/mlet [s (state/get-state)]
-              (m/return (inc s)))
-        res (m/fmap inc res)]
-    (t/is (state/state? res))
-    (let [res (state/run-state res 1)]
-      (t/is (d/pair? res))
-      (t/is (= 3 (first res)))
-      (t/is (= 1 (second res))))))
-
-
-(def state-maybe-t
-  (state/state-t maybe/context))
-
-(t/deftest state-t-tests
-  ;; get-state should return the identity wrapped in the inner monad's context.
-  (t/is (= (maybe/just (d/pair :foo :foo))
-           (ctx/with-context state-maybe-t
-             (state/run-state (state/get-state) :foo))))
-
-  ;; swap-state should should apply function to state and return it.
-  (t/is (= (maybe/just (d/pair 1 2))
-           (ctx/with-context state-maybe-t
-             (state/run-state (state/swap-state inc) 1))))
-
-  ;; put-state should override the state
-  (t/is (= (maybe/just (d/pair 0 42))
-           (ctx/with-context state-maybe-t
-             (state/run-state (state/put-state 42) 0))))
-
-  ;; State monad composition with mlet should return state
-  (let [res (m/mlet [s (state/get-state)]
-              (m/return (inc s)))]
-    (t/is (state/state? res))
-    (let [mres (ctx/with-context state-maybe-t
-                 (state/run-state res 1))
-          res  (maybe/from-maybe mres)]
-      (t/is (maybe/maybe? mres))
-      (t/is (d/pair? res))
-      (t/is (= 2 (first res)))
-      (t/is (= 1 (second res)))))
-
-  ;; State monad computations can be mapped over
-  (let [res (m/mlet [s (state/get-state)]
-              (m/return (inc s)))]
-    (t/is (state/state? res))
-    (let [mres (ctx/with-context state-maybe-t
-                 (state/run-state (m/fmap inc res) 1))
-          res (maybe/from-maybe mres)]
-      (t/is (maybe/maybe? mres))
-      (t/is (d/pair? res))
-      (t/is (= 3 (first res)))
-      (t/is (= 1 (second res)))))
-
-  ;; Inner monad values can be lifted into the transformer
-  (let [lifted-just (m/mlet [s (state/get-state)
-                             i (m/lift (maybe/just 3))]
-                      (m/return (+ i s)))
-        lifted-nothing (m/mlet [s (state/get-state)
-                                i (m/lift (maybe/nothing))]
-                         (m/return (+ s i)))]
-    (t/is (= (maybe/just (d/pair 45 42))
-             (ctx/with-context state-maybe-t
-               (state/run-state lifted-just 42))))
-    (t/is (= (maybe/nothing)
-             (ctx/with-context state-maybe-t
-               (state/run-state lifted-nothing nil))))))


exposed port and volumes match docker input

--- test/celestial/test/docker.clj
+++ test/celestial/test/docker.clj
@@ -16,6 +16,8 @@
          (contains {:binds ["/vagrant:/vagrant"]
                     :port-bindings {"22/tcp" [{:host-ip "0.0.0.0" :host-port "2222"}]}})
       create-spec =>
-         (contains {:image "narkisr:latest" :exposed-ports ["22/tcp"] :volumes ["/tmp"]})
+         (contains
+          {:exposed-ports {"22/tcp"  {}} :image "narkisr:latest" :memory
+           4294967296 :volumes  {"/tmp"  {}}})
       )))


[test/scrabble] Fix preprocessor directive.

--- test/cortex/scrabble_test.cljc
+++ test/cortex/scrabble_test.cljc
@@ -19,8 +19,8 @@
 #?(:cljs (enable-console-print!))

 (defn- parse-int2 [string]
-  #?(:clj (Integer/parseInt string 2))
-  :cljs (js/parseInt string 2))
+  #?(:clj (Integer/parseInt string 2)
+     :cljs (js/parseInt string 2)))

 (defn- charval [character]
   (.indexOf "abcdefghijklmnopqrstuvwxyz" #?(:clj (str character) :cljs character)))


Update routing test

Update routing test

--- re_view/test/re_view/routing_test.cljs
+++ re_view/test/re_view/routing_test.cljs
@@ -1,6 +1,5 @@
 (ns re-view.routing-test
-  (:require [cljsjs.react.dom]
-            [goog.dom :as gdom]
+  (:require [goog.dom :as gdom]
             [cljs.test :refer [deftest is are testing]]
             [re-db.d :as d]
             [re-view.routing :as routing]
@@ -22,60 +21,57 @@
 (defonce _
          ;; set up listener for route changes
          (routing/listen (fn [{:keys [segments] :as location}]
-                                       ;; log segments
-                                       (swap! segments-log conj segments)
-                                       ;; write location to re-db
-                                       ;; (triggers render of views that reference this data)
-                                       (d/transact! [(assoc location :db/id :router/location)]))))
+                           ;; log segments
+                           (swap! segments-log conj segments)
+                           ;; write location to re-db
+                           ;; (triggers render of views that reference this data)
+                           (d/transact! [(assoc location :db/id :router/location)]))))

 (defview index
-         [{:keys [view/props]}]
-         ;; side effect: log view name & props
-         (swap! view-log conj [:index props])
-         [:div])
+  [this]
+  (swap! view-log conj :index)
+  [:div])

-(defview not-found [{:keys [view/props]}]
-         (swap! view-log conj [:not-found props])
-         [:div])
+(defview not-found [this]
+  (swap! view-log conj :not-found)
+  [:div])

-(defview page [{:keys [view/props]}]
-         (swap! view-log conj [:page props])
-         [:div])
+(defview page [{:keys [page-id]}]
+  (swap! view-log conj [:page page-id])
+  [:div])

 (defview root [_]
-         ;; using core.match to pattern-match on location segments.
-         (match (d/get :router/location :segments)
-                [] (index)
-                ["page" page-id] (page {:page-id page-id})
-                :else (not-found)))
+  ;; using core.match to pattern-match on location segments.
+  (match (d/get :router/location :segments)
+         [] (index)
+         ["page" page-id] (page {:page-id page-id})
+         :else (not-found)))

 (deftest routing-test
   (testing "Basic routing"
-    (let [render #(view/render-to-dom % test-element)]
+    (let [render #(v/render-to-dom % test-element)]

       ;; set initial route to root
       (routing/nav! "/")
-      (view/flush!)
-
       ;; first render
       (render (root))

       ;; route changes should trigger re-render
       (routing/nav! "/non-existing-route")
-      (view/flush!)
+      (v/flush!)
       (routing/nav! "/page/1")
-      (view/flush!)
+      (v/flush!)
       (routing/nav! "/page/2")
-      (view/flush!)
+      (v/flush!)

-      (is (= @segments-log [[]
-                            ["non-existing-route"]
-                            ["page" "1"]
-                            ["page" "2"]]))
+      (is (= (drop 1 @segments-log) '([]
+                                       ["non-existing-route"]
+                                       ["page" "1"]
+                                       ["page" "2"])))

-      (is (= @view-log [[:index nil]
-                        [:not-found nil]
-                        [:page {:page-id "1"}]
-                        [:page {:page-id "2"}]])
+      (is (= @view-log [:index
+                        :not-found
+                        [:page "1"]
+                        [:page "2"]])
           "Views render on route change"))))


Question about extended-= embedded as a question

--- test/midje/checking/t_core.clj
+++ test/midje/checking/t_core.clj
@@ -28,7 +28,7 @@

-
+(future-fact "should extended-= return strictly true or false?")

 (facts "about extended equality"
   (extended-= 1 2) => falsey


Fix test subscriber.

Fix test subscriber.

--- test/onyx/log/one_job_test.clj
+++ test/onyx/log/one_job_test.clj
@@ -31,11 +31,13 @@
     :onyx/type :input
     :onyx/medium :core.async
     :onyx/batch-size batch-size
+    :onyx/batch-timeout 2000
     :onyx/doc "Reads segments from a core.async channel"}

    {:onyx/name :b
     :onyx/fn :onyx.log.one-job-test/my-inc
     :onyx/type :function
+    :onyx/batch-timeout 2000
     :onyx/batch-size batch-size}

    {:onyx/name :c
@@ -43,6 +45,7 @@
     :onyx/type :output
     :onyx/medium :core.async
     :onyx/batch-size batch-size
+    :onyx/batch-timeout 2000
     :onyx/doc "Writes segments to a core.async channel"}])

 (def in-chan (chan 100))
@@ -66,19 +69,15 @@

 (def ch (chan n-peers))

-(def subscription (onyx.api/subscribe-to-log peer-config ch))
-
-(def log (:log (:env subscription)))
-
 (def replica
   (playback-log (:log env) (extensions/subscribe-to-log (:log env) ch) ch 2000))

-(onyx.api/shutdown-env (:env subscription))
-
-(fact "peers balanced on 1 jobs"
+(fact "peers balanced on 1 job"
       (into #{} (map count (mapcat vals (vals (:allocations replica)))))
       =>
       #{1 2})
+
+(onyx.api/shutdown-env (:env subscription))

 (doseq [v-peer v-peers]
   (onyx.api/shutdown-peer v-peer))


Clean up tests

Clean up tests

--- test/spec_tools/core_test.cljc
+++ test/spec_tools/core_test.cljc
@@ -12,39 +12,40 @@
 (s/def ::uuid st/x-uuid?)
 (s/def ::birthdate st/x-inst?)

-(defmacro invalid? [value]
-  `(= st/+error-code+ ~value))
+(deftest spec-tools-conform-test
+  (testing "in default mode"
+    (testing "nothing is conformed"
+      (is (= ::s/invalid (st/conform ::age "12")))
+      (is (= ::s/invalid (st/conform ::over-a-million "1234567")))
+      (is (= ::s/invalid (st/conform ::lat "23,1234")))
+      (is (= ::s/invalid (st/conform ::language "clojure")))
+      (is (= ::s/invalid (st/conform ::truth "false")))
+      (is (= ::s/invalid (st/conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
+      (is (= ::s/invalid (st/conform ::birthdate "2006-01-02T15:04:05.999999-07:00")))))

-(deftest spec-tools-conform-test
-  (testing "normally"
-    (is (invalid? (st/conform ::age "12")))
-    (is (invalid? (st/conform ::over-a-million "1234567")))
-    (is (invalid? (st/conform ::lat "23,1234")))
-    (is (invalid? (st/conform ::language "clojure")))
-    (is (invalid? (st/conform ::truth "false")))
-    (is (invalid? (st/conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
-    (is (invalid? (st/conform ::birthdate "2006-01-02T15:04:05.999999-07:00"))))
-
-  (testing ":string mode"
+  (testing "in :string mode"
     (let [conform (partial st/conform :string)]
-      (is (= 12 (conform ::age "12")))
-      (is (= 1234567 (conform ::over-a-million "1234567")))
-      (is (= 23.1234 (conform ::lat "23.1234")))
-      (is (= false (conform ::truth "false")))
-      (is (= :clojure (conform ::language "clojure")))
-      (is (= #uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e"
-             (conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
-      (is (= #inst "2006-01-02T15:04:05.999999-07:00"
-             (conform ::birthdate "2006-01-02T15:04:05.999999-07:00")))))
+      (testing "everything gets conformed"
+        (is (= 12 (conform ::age "12")))
+        (is (= 1234567 (conform ::over-a-million "1234567")))
+        (is (= 23.1234 (conform ::lat "23.1234")))
+        (is (= false (conform ::truth "false")))
+        (is (= :clojure (conform ::language "clojure")))
+        (is (= #uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e"
+               (conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
+        (is (= #inst "2006-01-02T15:04:05.999999-07:00"
+               (conform ::birthdate "2006-01-02T15:04:05.999999-07:00"))))))

   (testing ":json mode"
     (let [conform (partial st/conform :json)]
-      (is (invalid? (conform ::age "12")))
-      (is (invalid? (conform ::over-a-million "1234567")))
-      (is (invalid? (conform ::lat "23.1234")))
-      (is (invalid? (conform ::truth "false")))
-      (is (= :clojure (conform ::language "clojure")))
-      (is (= #uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e"
-             (conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
-      (is (= #inst "2006-01-02T15:04:05.999999-07:00"
-             (conform ::birthdate "2006-01-02T15:04:05.999999-07:00"))))))
+      (testing "some are not conformed"
+        (is (= ::s/invalid (conform ::age "12")))
+        (is (= ::s/invalid (conform ::over-a-million "1234567")))
+        (is (= ::s/invalid (conform ::lat "23.1234")))
+        (is (= ::s/invalid (conform ::truth "false"))))
+      (testing "some are conformed"
+        (is (= :clojure (conform ::language "clojure")))
+        (is (= #uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e"
+               (conform ::uuid "07dbf30f-c99e-4e5d-b76e-5cbdac3b381e")))
+        (is (= #inst "2006-01-02T15:04:05.999999-07:00"
+               (conform ::birthdate "2006-01-02T15:04:05.999999-07:00")))))))


Update core_test.clj

Update core_test.clj

--- test/swagger_gen/core_test.clj
+++ test/swagger_gen/core_test.clj
@@ -29,4 +29,3 @@
   (testing "should add name to definition and flatten into vector"
     (let [definitions (:definitions petstore)]
       (println (first definitions)))))
-


Some additional integration tests.

Some additional integration tests.

--- test/tyranitar/integration.clj
+++ test/tyranitar/integration.clj
@@ -69,4 +69,18 @@
                body (read-body response)
                first-commit-id (:hash (first (:commits body)))]
            response => (contains {:status 200})
-           first-commit-id => latest-commit-id)))
+           first-commit-id => latest-commit-id))
+
+   (fact "Can list applications and this list has the right format"
+         (let [list (client/get (url+ "/applications"))
+               list-body (read-body list)
+               tyranitar (:tyranitar (:applications list-body))
+               tyranitar-dev-repo-name (:name (first (:repositories tyranitar)))]
+           tyranitar-dev-repo-name => "tyranitar-dev"))
+
+   (fact "Can list applications in particular environment with right format"
+         (let [list (client/get (url+ "/applications/prod"))
+               list-body (read-body list)
+               tyranitar (:tyranitar (:applications list-body))
+               tyranitar-prod-repo-name (:name (first (:repositories tyranitar)))]
+           tyranitar-prod-repo-name => "tyranitar-prod")))


Update dependency versions

Update dependency versions

--- resources/leiningen/new/kraken_works/project.clj
+++ resources/leiningen/new/kraken_works/project.clj
@@ -3,23 +3,22 @@
   :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[org.clojure/clojure "1.8.0"]
-                 [org.clojure/tools.logging "0.3.1"]
+  :dependencies [[org.clojure/clojure "1.9.0"]
+                 [org.clojure/tools.logging "0.4.1"]
                  [turbovote.resource-config "0.2.1"]
 {{#datomic?}}
-                 [democracyworks/datomic-toolbox "2.0.4"
+                 [democracyworks/datomic-toolbox "2.0.5"
                   :exclusions [com.datomic/datomic-pro]]
-                 [prismatic/schema "1.1.6"]
-                 [com.datomic/datomic-pro "0.9.5561"
+                 [com.datomic/datomic-pro "0.9.5703"
                   :exclusions [org.slf4j/slf4j-nop
                                org.slf4j/slf4j-log4j12]]
-                 [com.amazonaws/aws-java-sdk-dynamodb "1.11.128"
+                 [com.amazonaws/aws-java-sdk-dynamodb "1.11.402"
                   :exclusions [commons-codec commons-logging]]
 {{/datomic?}}
-                 [ch.qos.logback/logback-classic "1.2.2"]
-                 [democracyworks/kehaar "0.11.2"]]
+                 [ch.qos.logback/logback-classic "1.2.3"]
+                 [democracyworks/kehaar "0.11.4"]]
   :plugins [[com.pupeno/jar-copier "0.4.0"]]
-  :java-agents [[com.newrelic.agent.java/newrelic-agent "3.35.1"]]
+  :java-agents [[com.newrelic.agent.java/newrelic-agent "4.5.0"]]
   :jar-copier {:java-agents true
                :destination "resources/jars"}
   :prep-tasks ["javac" "compile" "jar-copier"]


Draw npc health bars without re-drawing the map

--- dungeon-crawler/desktop/src-common/dungeon_crawler/core.clj
+++ dungeon-crawler/desktop/src-common/dungeon_crawler/core.clj
@@ -116,7 +116,7 @@
                     :set-color (color :green)
                     :rect bar-x bar-y (* bar-w pct) u/npc-bar-h)
              vector
-             (render! screen))))))
+             (draw! screen))))))

 (defscreen overlay-screen
   :on-show


added ds

added ds

--- src/data_structures.clj
+++ src/data_structures.clj
@@ -1,25 +1,30 @@
 (ns data-structures
   (require [clojure.set :refer :all]))
-
-

 ;;;;;;;;;
 ;; Vectors

+(def my-vec (vector 1 2 3))

-
-
-
+(let [[first-element & the-rest] my-vec]
+  (str "first=" first-element " - " the-rest))

 ;;;;;;;;;
 ;; Maps

+(def a-map {:one 1
+            :two 2})

+(merge
+ {:five 1 :two 22}
+ {:four 4}
+ {:one 1 :two 2 :three 3})

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Sets & Relational Algebra

-;;;;;;;;;;
-;; Sets
+(def a-set #{"one" "two"})

 (defrecord Supplier [number name status city])
 (defrecord Part [number name colour weight city])
@@ -29,10 +34,12 @@
   #{(Supplier. "S1" "Smith" 20 "London")
     (Supplier. "S2" "Jones" 10 "Paris")
     (Supplier. "S3" "Blake" 30 "Paris")})
+
 (def parts
   #{(Part. "P1" "Nut" "Red" 12.0 "London")
     (Part. "P2" "Bolt" "Green" 17.0 "Paris")
     (Part. "P3" "Screw" "Blue" 17.0 "Oslo")})
+
 (def shipments
   #{(Shipment. "S1" "P1" 300)
     (Shipment. "S2" "P2" 200)
@@ -47,6 +54,7 @@

 (project
  (join
-  (select #(= (:city %) "Paris")
-          suppliers) shipments {:number :supplier})
+  (select #(= (:city %) "Paris") suppliers)
+  shipments
+  {:number :supplier})
  [:name])


Be nice.

Be nice.

--- src/defragment/core.clj
+++ src/defragment/core.clj
@@ -164,7 +164,7 @@
   Returns the string shell command to concatenate all the filenames,
   to the output dir, named properly with name and date."
   [cmd-path path {:keys [name date filenames]}]
-  (let [cmd (format "ogg123 -q -d wav -f - %s | oggenc -Q - > %s"
+  (let [cmd (format "nice -n 15 ogg123 -q -d wav -f - %s | nice -n 15 oggenc -Q - > %s"
                     (umisc/inter-str " " filenames)
                     (format-show-save path name date))]
     (format "echo \"%s\"\n%s\n" cmd cmd)))


Support for new CLI options: -c and --config

--- src/arachnida/core.clj
+++ src/arachnida/core.clj
@@ -18,23 +18,31 @@
 (require '[arachnida.db-interface     :as db-interface])
 (require '[arachnida.git-data-fetcher :as git-data-fetcher])
 (require '[arachnida.server           :as server])
+(require '[arachnida.config           :as config])

 (def cli-options
-  [["-h" "--help"    "help"                   :id :help]
-   ["-g" "--git"     "fetch GIT statistic"    :id :git]
-   ["-s" "--server"  "run as HTTP server"     :id :server]])
+  [["-h" "--help"    "help"                          :id :help]
+   ["-g" "--git"     "fetch GIT statistic"           :id :git]
+   ["-s" "--server"  "run as HTTP server"            :id :server]
+   ["-c" "--config"  "display current configuration" :id :config]])

 (defn show-help
     []
     (println "Usage:")
     (println "-h" "--help      help")
     (println "-g" "--git       fetch GIT statistic")
-    (println "-s" "--server    run as HTTP server"))
+    (println "-s" "--server    run as HTTP server")
+    (println "-c" "--config    display current configuration"))

 (defn show-error
     []
     (println "Unknown command line option!")
     (show-help))
+
+(defn display-configuration
+    []
+    (config/load-configuration)
+    (config/print-configuration))

 (defn -main
     [& args]
@@ -42,9 +50,11 @@
           options        (all-options :options)
           show-help?     (options :help)
           git?           (options :git)
-          server?        (options :server)]
+          server?        (options :server)
+          config?        (options :config)]
         (cond show-help? (show-help)
               git?       (git-data-fetcher/process)
               server?    (server/start-server)
+              config?    (display-configuration)
               :else      (show-error))))


ignore views as we test state

ignore views as we test state

--- dada-core/src/test/clojure/org/dada/core/test_JoinModel.clj
+++ dada-core/src/test/clojure/org/dada/core/test_JoinModel.clj
@@ -10,7 +10,7 @@
    )
   )

-(defn get-mutable [^JoinModel model] @(first (.state model)))
+(defn get-mutable [^JoinModel model] (rest @(first (.state model))))

 ;; problem - rhs indeces will be arranged in an indeterminate order...


Ship engine fires when accelerating

Ship engine fires when accelerating

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -58,6 +58,15 @@
                                     :explosion    {:size      3
                                                    :color     (Color. 220 180 180)
                                                    :life-time 400}}
+                       :fire       {:size           (/ ship-size 2.5)
+                                    :shape          [[-1.0 -1.0] [1.0 -1.0] [0.0 1.0]]
+                                    :color          (fn [] (Color. (random-int 230 256) (random-int 60 220) (random-int 0 50)))
+                                    :spread         0.2
+                                    :speed          -0.7
+                                    :acceleration   0
+                                    :rotation-speed (fn [] (random -5 5))
+                                    :cooldown       30
+                                    :life-time      400}
                        :missile    {:size         (/ ship-size 3)
                                     :shape        [[0.0 1.0] [0.5 -1.0] [0.5 -3.5] [1.0 -4.5] [0.5 -4.5] [0.25 -4.25]
                                                    [-0.25 -4.25] [-0.5 -4.5] [-1.0 -4.5] [-0.5 -3.5] [-0.5 -1.0]]
@@ -114,7 +123,8 @@
    :cockpit-shape  [[-0.143 0.714] [0.143 0.714] [0.286 -0.143] [-0.286 -0.143]]
    :cockpit-color  (Color. 0 0 80)

-   :weapons        {:machinegun (create-weapon :projectile)
+   :weapons        {:engine     (create-weapon :fire)
+                    :machinegun (create-weapon :projectile)
                     :launcher   (create-weapon :missile)}
    :shots          []

@@ -396,6 +406,16 @@
 (defmethod move :missile [missile]
   (basic-move missile false))

+(defmethod move :fire [{:keys [life-time color] :as fire}]
+  (if (< life-time turn-millis)
+    nil
+    (let [fire (basic-move fire false)
+          alpha (int (* (.getAlpha color) (- 1 (/ turn-millis life-time))))
+          color (Color. (.getRed color) (.getGreen color) (.getBlue color) alpha)
+          life-time (- life-time turn-millis)]
+      (assoc fire :life-time life-time
+                  :color color))))
+
 (defmethod move :asteroid [asteroid]
   (basic-move asteroid))

@@ -450,7 +470,8 @@

 (defn do-action!
   ([ship {:keys [acceleration rotation fire-weapon] :as action} activate?]
-   (when acceleration (dosync (alter ship assoc :acceleration (if activate? acceleration 0) :collidable? ship-damage)))
+   (when acceleration (dosync (alter ship assoc :acceleration (if activate? acceleration 0) :collidable? ship-damage)
+                              (alter ship toggle-shooting :engine activate?)))
    (when rotation (dosync (alter ship set-rotation rotation activate?)))
    (when fire-weapon (dosync (alter ship toggle-shooting fire-weapon activate?))))
   ([ship action]


added basic regex check on find by isbn endpoint

--- src/granger/handler.clj
+++ src/granger/handler.clj
@@ -7,7 +7,7 @@
 (defroutes app-routes
   (GET "/" [] "Welcome to my book reviews site!")
   (GET "/books" [] (books/find-books))
-  (GET "/books/:isbn" [isbn] (books/find-book isbn))
+  (GET ["/books/:isbn", :isbn #"[-0-9]*"] [isbn] (books/find-book isbn))
   (POST "/books" [body] (books/add-book! body))
   (PUT "/books/:isbn" [isbn] (books/update-book! isbn))
   (route/not-found "Not Found"))


one liner

one liner

--- src/aws/networking.clj
+++ src/aws/networking.clj
@@ -41,9 +41,7 @@
   "Sets up hostname under /etc/sysconfig/network in redhat based systems"
   [fqdn remote]
   (execute
-    (<< "grep -q '^HOSTNAME=' /etc/sysconfig/network &&
-        sudo sed -i 's/^HOSTNAME=.*/HOSTNAME=~{fqdn}' /etc/sysconfig/network
-        || sudo sed -i '$ a\\HOSTNAME=~{fqdn}' /etc/sysconfig/network") remote )
+    (<< "grep -q '^HOSTNAME=' /etc/sysconfig/network && sudo sed -i 's/^HOSTNAME=.*/HOSTNAME=~{fqdn}' /etc/sysconfig/network || sudo sed -i '$ a\\HOSTNAME=~{fqdn}' /etc/sysconfig/network") remote )
   )

 (defn set-hostname [{:keys [aws machine] :as spec} endpoint instance-id user]


+(fo-ps)

+(fo-ps)

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -23,6 +23,9 @@

 (def lexicon (:lexicon medium))
 (def grammar (:grammar-map medium))
+
+(defn fo-ps [expr]
+  (parse/fo-ps expr fo))

 (defn analyze
   ([surface-form]