CMR-4239 - Addressed review feedback.

CMR-4239 - Addressed review feedback.

--- system-int-test/test/cmr/system_int_test/search/granule_sorting_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/granule_sorting_search_test.clj
@@ -39,7 +39,8 @@
   (let [coll (d/ingest-umm-spec-collection "PROV1" (data-umm-c/collection {}))
         make-gran (fn [granule-ur producer-gran-id]
                     (d/ingest "PROV1"
-                              (dg/granule-with-umm-spec-collection coll
+                              (dg/granule-with-umm-spec-collection
+                               coll
                                (:concept-id coll)
                                {:granule-ur granule-ur
                                 :producer-gran-id producer-gran-id})))
@@ -91,8 +92,10 @@
 (deftest granule-numeric-sorting-test
   (let [coll (d/ingest-umm-spec-collection "PROV1" (data-umm-c/collection {}))
         make-gran (fn [number]
-                    (d/ingest "PROV1" (dg/granule-with-umm-spec-collection coll (:concept-id coll) {:size number
-                                                        :cloud-cover number})))
+                    (d/ingest "PROV1" (dg/granule-with-umm-spec-collection
+                                       coll
+                                       (:concept-id coll)
+                                       {:size number :cloud-cover number})))
         g1 (make-gran 20)
         g2 (make-gran 30)
         g3 (make-gran 10)
@@ -110,9 +113,10 @@

 (deftest coll-identifier-sorting-test
   (let [make-gran (fn [provider entry-title short-name version]
-                    (let [coll (d/ingest-umm-spec-collection provider (data-umm-c/collection {:EntryTitle entry-title
-                                                         :ShortName short-name
-                                                         :Version version}))]
+                    (let [coll (d/ingest-umm-spec-collection provider
+                                (data-umm-c/collection {:EntryTitle entry-title
+                                                        :ShortName short-name
+                                                        :Version version}))]
                       (d/ingest provider (dg/granule-with-umm-spec-collection coll (:concept-id coll) {}))))
         g1 (make-gran "PROV1" "et10" "SN45" "v10")
         g2 (make-gran "PROV1" "et20" "sn35" "v20")
@@ -144,14 +148,20 @@

 (deftest temporal-sorting-test
   (let [make-coll (fn [n provider begin end]
-                    (d/ingest-umm-spec-collection provider (data-umm-c/collection n {:TemporalExtents [(data-umm-cmn/temporal-extent {
-                                                :beginning-date-time (d/make-datetime begin)
-                                                :ending-date-time (d/make-datetime end)
-                                                :ends-at-present? true})]})))
+                    (d/ingest-umm-spec-collection
+                     provider (data-umm-c/collection
+                     n
+                     {:TemporalExtents [(data-umm-cmn/temporal-extent {
+                      :beginning-date-time (d/make-datetime begin)
+                      :ending-date-time (d/make-datetime end)
+                      :ends-at-present? true})]})))
         make-gran (fn [coll begin end]
                     (d/ingest (:provider-id coll)
-                              (dg/granule-with-umm-spec-collection coll (:concept-id coll) {:beginning-date-time (d/make-datetime begin)
-                                                :ending-date-time (d/make-datetime end)})))
+                              (dg/granule-with-umm-spec-collection
+                               coll
+                               (:concept-id coll)
+                               {:beginning-date-time (d/make-datetime begin)
+                                :ending-date-time (d/make-datetime end)})))
         c1 (make-coll 1 "PROV1" 1 200)
         c2 (make-coll 2 "PROV2" 1 200)

@@ -193,9 +203,11 @@
                                     ["c10" "c41" "c20" "c51" "c30" "c40" "c50"])}))
         make-gran (fn [& platforms]
                     (d/ingest "PROV1"
-                              (dg/granule-with-umm-spec-collection coll (:concept-id coll)
-                                          {:platform-refs (map #(dg/platform-ref {:short-name %})
-                                                               platforms)})))
+                              (dg/granule-with-umm-spec-collection
+                               coll
+                               (:concept-id coll)
+                               {:platform-refs (map #(dg/platform-ref {:short-name %})
+                                                    platforms)})))
         g1 (make-gran "c10" "c41")
         g2 (make-gran "c20" "c51")
         g3 (make-gran "c30")
@@ -217,12 +229,14 @@
                                                      ["c10" "c41" "c20" "c51" "c30" "c40" "c50"])})]}))
         make-gran (fn [& instruments]
                     (d/ingest "PROV1"
-                              (dg/granule-with-umm-spec-collection coll (:concept-id coll)
-                                {:platform-refs
-                                 [(dg/platform-ref
-                                    {:short-name "platform"
-                                     :instrument-refs (map #(dg/instrument-ref {:short-name %})
-                                                           instruments)})]})))
+                              (dg/granule-with-umm-spec-collection
+                               coll
+                               (:concept-id coll)
+                               {:platform-refs
+                                [(dg/platform-ref
+                                  {:short-name "platform"
+                                   :instrument-refs (map #(dg/instrument-ref {:short-name %})
+                                                         instruments)})]})))
         g1 (make-gran "c10" "c41")
         g2 (make-gran "c20" "c51")
         g3 (make-gran "c30")
@@ -249,14 +263,16 @@
                                                      ["c10" "c41" "c20" "c51" "c30" "c40" "c50"])})]})]}))
         make-gran (fn [& sensors]
                     (d/ingest "PROV1"
-                              (dg/granule-with-umm-spec-collection coll (:concept-id coll)
-                                {:platform-refs
-                                 [(dg/platform-ref
-                                    {:short-name "platform"
-                                     :instrument-refs [(dg/instrument-ref
-                                                         {:short-name "instrument"
-                                                          :sensor-refs (map #(dg/sensor-ref {:short-name %})
-                                                                            sensors)})]})]})))
+                              (dg/granule-with-umm-spec-collection
+                               coll
+                               (:concept-id coll)
+                               {:platform-refs
+                                [(dg/platform-ref
+                                  {:short-name "platform"
+                                   :instrument-refs [(dg/instrument-ref
+                                                      {:short-name "instrument"
+                                                       :sensor-refs (map #(dg/sensor-ref {:short-name %})
+                                                                         sensors)})]})]})))
         g1 (make-gran "c10" "c41")
         g2 (make-gran "c20" "c51")
         g3 (make-gran "c30")


Remove ratom state and centralise it in re-frame's app-db

--- src/day8/re_frame/trace/events.cljs
+++ src/day8/re_frame/trace/events.cljs
@@ -17,9 +17,6 @@
 (def default-number-of-epochs-to-retain 5)

 (defonce traces (r/atom []))
-(defonce total-traces (r/atom 0))
-(defonce number-of-epochs-to-retain (atom default-number-of-epochs-to-retain))
-(defonce events-to-ignore (atom #{}))

 (defn log-trace? [trace]
   (let [render-operation? (or (= (:op-type trace) :render)
@@ -33,33 +30,7 @@
   (re-frame.trace/remove-trace-cb ::cb))

 (defn enable-tracing! []
-  (re-frame.trace/register-trace-cb ::cb (fn [new-traces]
-                                           (when-let [new-traces (->> (filter log-trace? new-traces)
-                                                                      (sort-by :id))]
-                                             (swap! total-traces + (count new-traces))
-                                             (swap! traces
-                                                    (fn [existing]
-                                                      (let [new  (reduce conj existing new-traces)
-                                                            size (count new)]
-                                                        (if (< 8000 size)
-                                                          (let [new2 (subvec new (- size 4000))]
-                                                            (if (< @total-traces 40000) ;; Create a new vector to avoid structurally sharing all traces forever
-                                                              (do (reset! total-traces 0)
-                                                                  (into [] new2))))
-                                                          new))))
-                                             ;; TODO: there is a bit of double handling here with retaining the last n epochs,
-                                             ;; that will be cleaned up when the epoch parsing is refactored.
-                                             (let [matches            (:matches (metam/parse-traces @traces))
-                                                   matches            (remove (fn [match]
-                                                                                (let [event (get-in (metam/matched-event match) [:tags :event])]
-                                                                                (contains? @events-to-ignore (first event)))) matches)
-                                                   retained-epochs    (take-last @number-of-epochs-to-retain matches)
-                                                   first-id-to-retain (:id (ffirst retained-epochs))
-                                                   new-traces         (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
-                                               (reset! traces new-traces)
-                                               (reset! total-traces (count new-traces))
-                                               (rf/dispatch [:traces/update-traces new-traces])
-                                               (rf/dispatch [:epochs/update-epochs {:matches retained-epochs}]))))))
+  (re-frame.trace/register-trace-cb ::cb #(rf/dispatch [:epochs/receive-new-traces %])))

 (defn dissoc-in
   "Dissociates an entry from a nested associative structure returning a new
@@ -108,13 +79,6 @@
   (fn [db _]
     (localstorage/delete-all-keys!)
     (js/location.reload)
-    db))
-
-(rf/reg-event-db
-  :settings/clear-epochs
-  (fn [db _]
-    (reset! traces [])
-    (reset! total-traces 0)
     db))

 (rf/reg-event-db
@@ -158,12 +122,11 @@
           num (if (and (not (js/isNaN num)) (pos-int? num))
                 num
                 default-number-of-epochs-to-retain)]
-      (reset! number-of-epochs-to-retain num)
       (localstorage/save! "retained-epochs" num)
       (assoc-in db [:settings :number-of-epochs] num))))

 (def ignored-event-mw
-  [(rf/path [:settings :ignored-events]) (rf/after #(localstorage/save! "ignored-events" %)) (rf/after #(reset! events-to-ignore (->> % vals (map :event-id) set)))])
+  [(rf/path [:settings :ignored-events]) (rf/after #(localstorage/save! "ignored-events" %))])

 (rf/reg-event-db
   :settings/add-ignored-event
@@ -524,6 +487,46 @@
   (-> m first :id))

 (rf/reg-event-db
+  :epochs/receive-new-traces
+  (fn [db [_ new-traces]]
+    (when-let [new-traces (->> (filter log-trace? new-traces)
+                               (sort-by :id))]
+      (let [number-of-epochs-to-retain (get-in db [:settings :number-of-epochs])
+            events-to-ignore           (->> (get-in db [:settings :ignored-events]) vals (map :event-id) set)
+
+
+            #_ #_ total-traces               (get-in db [:traces :total-traces])
+            #_ #_ new-total-traces (+ total-traces (count new-traces))]
+        #_(swap! total-traces + (count new-traces))
+        ;; TODO: add this back in once the algorithm is better defined
+        #_(swap! traces
+               (fn [existing]
+                 (let [new  (reduce conj existing new-traces)
+                       size (count new)]
+                   (if (< 8000 size)
+                     (let [new2 (subvec new (- size 4000))]
+                       (if (< new-total-traces 40000)          ;; Create a new vector to avoid structurally sharing all traces forever
+                         (do (comment "Total traces set to 0")                               ;(reset! total-traces 0)
+                             (into [] new2))))
+                     new))))
+        (swap! traces (fn [existing] (reduce conj existing new-traces)))
+        ;; TODO: there is a bit of double handling here with retaining the last n epochs,
+        ;; that will be cleaned up when the epoch parsing is refactored.
+        (let [matches            (:matches (metam/parse-traces @traces))
+              matches            (remove (fn [match]
+                                           (let [event (get-in (metam/matched-event match) [:tags :event])]
+                                             (contains? events-to-ignore (first event)))) matches)
+              retained-epochs    (take-last number-of-epochs-to-retain matches)
+              first-id-to-retain (:id (ffirst retained-epochs))
+              new-traces         (into [] (drop-while #(< (:id %) first-id-to-retain)) @traces)]
+          (reset! traces new-traces)
+          ;; Reset total-traces count to new traces
+          #_(reset! total-traces (count new-traces))
+          (rf/dispatch [:traces/update-traces new-traces])
+          (rf/dispatch [:epochs/update-epochs {:matches retained-epochs}]))))
+    db))
+
+(rf/reg-event-db
   :epochs/update-epochs
   [(rf/path [:epochs])]
   (fn [epochs [_ rt]]
@@ -564,7 +567,6 @@
   (fn [db]
     (re-frame.trace/reset-tracing!)
     (reset! traces [])
-    (reset! total-traces 0)
     (dissoc db :epochs :traces)))

 (rf/reg-event-db


refactor control flow in dual-op :ADD method

--- src/emm_ess_pee/instruction_set.clj
+++ src/emm_ess_pee/instruction_set.clj
@@ -145,11 +145,12 @@
   [_ computer byte? source-mode source-reg dest-mode dest-reg]
   (let [[src computer] (get-value computer source-mode byte? source-reg)
         [dst computer] (get-value computer dest-mode byte? dest-reg)
-        result (+ src dst)
-        computer (-> (set-ZCN computer result byte?)
-                     (set-V-add dst src result byte?))
-        result (make-bw result byte?)]
-    (set-value computer dest-mode byte? dest-reg result)))
+        result-word (+ src dst)
+        result (make-bw result-word byte?)]
+    (-> computer
+      (set-ZCN result-word byte?)
+      (set-V-add dst src result-word byte?)
+      (set-value dest-mode byte? dest-reg result))))

 (defmethod dual-op :ADDC
   [_ computer byte? source-mode source-reg dest-mode dest-reg]


Refactor

Refactor

--- src/refactor_nrepl/plugin.clj
+++ src/refactor_nrepl/plugin.clj
@@ -12,35 +12,42 @@
                (when (= id 'org.clojure/clojure)
                  version)))))

+(defn- enable-middleware-if-clj-version-ok
+  [{:keys [dependencies managed-dependencies exclusions] :as project}]
+  (let [clojure-excluded? (some #(= % 'org.clojure/clojure) exclusions)
+        clojure-version (when-not clojure-excluded?
+                          (or (find-clojure-version dependencies)
+                              (find-clojure-version managed-dependencies)))
+        clojure-version-ok?
+        (cond clojure-excluded? true ; up to the user
+
+              (nil? clojure-version)
+              ;; Lein 2.5.2+ uses Clojure 1.7 by default
+              (lein/version-satisfies? (lein/leiningen-version) "2.5.2")
+
+              :else
+              (lein/version-satisfies? clojure-version min-clojure-version))]
+    (if clojure-version-ok?
+      (-> project
+          (update-in [:dependencies]
+                     (fnil into [])
+                     [['refactor-nrepl (core/version)]])
+          (update-in [:repl-options :nrepl-middleware]
+                     (fnil into [])
+                     '[refactor-nrepl.middleware/wrap-refactor]))
+      (do
+        (lein/warn "Warning: refactor-nrepl requires Clojure version"
+                   min-clojure-version "or later.")
+        (lein/warn "Warning: refactor-nrepl middleware won't be activated.")
+        project))))
+
+(defn- warn-no-project []
+  (do
+    (lein/warn "Warning: refactor-nrepl needs to run in the context of a project.")
+    (lein/warn "Warning: refactor-nrepl middleware won't be activated." )))
+
 (defn middleware
-  [{:keys [dependencies managed-dependencies exclusions] :as project}]
+  [project]
   (if (core/project-root)
-    (let [clojure-excluded? (some #(= % 'org.clojure/clojure) exclusions)
-          clojure-version (when-not clojure-excluded?
-                            (or (find-clojure-version dependencies)
-                                (find-clojure-version managed-dependencies)))
-          clojure-version-ok?
-          (cond clojure-excluded? true ; up to the user
-
-                (nil? clojure-version)
-                ;; Lein 2.5.2+ uses Clojure 1.7 by default
-                (lein/version-satisfies? (lein/leiningen-version) "2.5.2")
-
-                :else
-                (lein/version-satisfies? clojure-version min-clojure-version))]
-      (if clojure-version-ok?
-        (-> project
-            (update-in [:dependencies]
-                       (fnil into [])
-                       [['refactor-nrepl (core/version)]])
-            (update-in [:repl-options :nrepl-middleware]
-                       (fnil into [])
-                       '[refactor-nrepl.middleware/wrap-refactor]))
-        (do
-          (lein/warn "Warning: refactor-nrepl requires Clojure version"
-                     min-clojure-version "or later.")
-          (lein/warn "Warning: refactor-nrepl middleware won't be activated." )
-          project)))
-    (do
-      (lein/warn "Warning: refactor-nrepl needs to run in the context of a project.")
-      (lein/warn "Warning: refactor-nrepl middleware won't be activated." ))))
+    (enable-middleware-if-clj-version-ok project)
+    (warn-no-project)))


Add a comment (#1258)

Add a comment (#1258)

--- scheduler/src/cook/mesos.clj
+++ scheduler/src/cook/mesos.clj
@@ -208,6 +208,8 @@
                                                                                optimizer-trigger-chan))
                                     (when (:update-data-local-costs-trigger-chan trigger-chans)
                                       (dl/start-update-cycles! mesos-datomic-conn (:update-data-local-costs-trigger-chan trigger-chans)))
+                                    ; This counter exists so that the cook leader has a '1' and the others have a '0'.
+                                    ; So we can see who the leader is in the graphs by graphing the value.
                                     (counters/inc! mesos-leader)
                                     (async/tap mesos-datomic-mult datomic-report-chan)
                                     (cook.scheduler.scheduler/monitor-tx-report-queue datomic-report-chan mesos-datomic-conn)


A few more comments about error-handling

--- test/such/f_relational.clj
+++ test/such/f_relational.clj
@@ -300,6 +300,8 @@

-(future-fact "error handling")
+(future-fact "error handling"
+  (fact "bad keyword passed in `:using`, etc.")
+  (fact "try to `extend-map` through a :key that doesn't exist"))

 ) ; when>=1-7


CMR-4537: Resolved jar file conflicts for virtual-product app.

--- virtual-product-app/project.clj
+++ virtual-product-app/project.clj
@@ -1,16 +1,20 @@
 (defproject nasa-cmr/cmr-virtual-product-app "0.1.0-SNAPSHOT"
   :description "Adds virtual products to the CMR."
   :url "https://github.com/nasa/Common-Metadata-Repository/tree/master/virtual-product-app"
-  :dependencies [[org.clojure/clojure "1.8.0"]
-                 [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]
-                 [nasa-cmr/cmr-common-app-lib "0.1.0-SNAPSHOT"]
-                 [nasa-cmr/cmr-message-queue-lib "0.1.0-SNAPSHOT"]
-                 [nasa-cmr/cmr-umm-lib "0.1.0-SNAPSHOT"]
-                 [nasa-cmr/cmr-transmit-lib "0.1.0-SNAPSHOT"]
-                 [org.clojure/tools.nrepl "0.2.12"]
-                 [compojure "1.5.1"]
-                 [ring/ring-core "1.5.0"]
-                 [ring/ring-json "0.4.0"]]
+  :exclusions [
+    [commons-logging]]
+  :dependencies [
+    [commons-logging "1.2"]
+    [compojure "1.5.1"]
+    [nasa-cmr/cmr-common-app-lib "0.1.0-SNAPSHOT"]
+    [nasa-cmr/cmr-common-lib "0.1.1-SNAPSHOT"]
+    [nasa-cmr/cmr-message-queue-lib "0.1.0-SNAPSHOT"]
+    [nasa-cmr/cmr-transmit-lib "0.1.0-SNAPSHOT"]
+    [nasa-cmr/cmr-umm-lib "0.1.0-SNAPSHOT"]
+    [org.clojure/clojure "1.8.0"]
+    [org.clojure/tools.nrepl "0.2.12"]
+    [ring/ring-core "1.5.0"]
+    [ring/ring-json "0.4.0"]]
   :plugins [[lein-shell "0.4.0"]
             [test2junit "1.2.1"]]
   :jvm-opts ^:replace ["-server"


use ->> thread operation

use ->> thread operation

--- ch06-assembler/clj-hackasm/hackasm/src/hackasm/core.clj
+++ ch06-assembler/clj-hackasm/hackasm/src/hackasm/core.clj
@@ -1,6 +1,7 @@
 (ns hackasm.core
   (:use [hackasm.inst :only [gen-ainst gen-cinst]]
-        [hackasm.symbol-table :only [init-symbol-table insert-symbol-table]])
+        [hackasm.symbol-table :only [init-symbol-table
+                                     insert-symbol-table]])
   (:require [clojure.string :as string]))

 (defn remove-blank
@@ -9,7 +10,7 @@

 (defn remove-comment
   [s]
-  (string/replace s #"//\S+" ""))
+  (string/replace s #"\s*//.*" ""))

 (defn parse-ainst
   [expr]
@@ -48,9 +49,12 @@

 (defn parse
   [lines]
-  (let
-    [exprs (filter (fn [l] (< 0 (count l)))
-                   (map remove-comment (map remove-blank lines)))]
+  (do
     (init-symbol-table)
-    (map parse-line (preprocess exprs))))
+    (->> lines
+         (map remove-comment)
+         (map remove-blank)
+         (filter (fn [l] (< 0 (count l))))
+         (preprocess)
+         (map parse-line))))


day 5

day 5

--- advent/src/advent/core.clj
+++ advent/src/advent/core.clj
@@ -120,3 +120,92 @@
 (.startsWith (md5 (str "bgvyzdsv" 0)) "0")

+;;day 5
+(def input5 (slurp "inputs/5"))
+(def strings (clojure.string/split-lines input5))
+
+(defn isVowel [x]
+  (not= nil (re-find #"a|e|i|o|u" x)))
+
+(defn has3Vowels [str]
+  (> (count
+       (filter isVowel (clojure.string/split str #"")))
+  2))
+(has3Vowels "asdfasdfasdf")
+
+(defn hasRepeat [str]
+  (true? (reduce
+    (fn [p v]
+      (cond (= p true) true (= p v) true :else v))
+    (clojure.string/split str #""))))
+(hasRepeat "asdfasdf")
+
+(defn hasNoBadSubstr [str]
+  (= nil (re-find #"ab|cd|pq|xy" str)))
+(hasNoBadSubstr "asdfasdfadab")
+
+;;part 1
+(->>
+  (slurp "inputs/5")
+  (clojure.string/split-lines)
+  (filter hasRepeat)
+  (filter has3Vowels)
+  (filter hasNoBadSubstr)
+  count)
+
+(def testStr "haegwjzuvuyypxyu")
+(hasRepeat testStr)
+(has3Vowels testStr)
+(hasNoBadSubstr testStr)
+
+(defn noOverlap [clist]
+  (cond
+    (< (count clist) 3) true
+    (= (first clist) (first (rest clist)) (first (rest (rest clist)))) false
+    :else (noOverlap (rest clist))))
+
+(defn hasPair [clist]
+  (let [slist (sort clist)]
+    (cond
+      (< (count slist) 2) false
+      (= (first slist) (first (rest slist))) true
+      :else (hasPair (rest slist)))))
+
+(hasPair clist)
+(def slist (sort clist))
+(= (first slist) (first (rest slist)))
+(first slist)
+(first (rest slist))
+(< (count slist) 2)
+
+(defn hasSpacedPair [clist]
+  (let [slist (sort clist)]
+    (cond
+      (< (count slist) 3) false
+      (= (first slist) (first (rest (rest clist)))) true
+      :else (hasSpacedPair (rest slist)))))
+(hasSpacedPair clist)
+
+(defn strToList [str]
+  (clojure.string/split  str #""))
+
+;;part 2
+(->>
+  (slurp "inputs/5")
+  (clojure.string/split-lines)
+  (map strToList)
+  (filter hasPair)
+  (filter hasSpacedPair)
+  (filter noOverlap)
+  count)
+
+
+
+(noOverlap (clojure.string/split  "aaaasdfasd" #""))
+(noOverlap (clojure.string/split  "aasdfasd" #""))
+
+
+(def clist (clojure.string/split  "uurcxstgmygtbstg" #""))
+(hasPair clist)
+(hasSpacedPair clist)
+(noOverlap clist)


Autocompute x axis label spacing.

Autocompute x axis label spacing.

--- metlog-vault/src-client/metlog_client/tsplot.cljs
+++ metlog-vault/src-client/metlog_client/tsplot.cljs
@@ -18,6 +18,7 @@
 (def tsplot-right-margin 5)
 (def y-axis-space 40)

+(def pixels-per-x-label 100)
 (def pixels-per-y-label 20)

 (def y-line-intervals
@@ -28,9 +29,9 @@

 (def x-line-intervals
   (mapcat (fn [ scale ]
-            (map #(* % scale)
-                 [ 1 2 3 4 5 6 ]))
-          [1 60 3600 86400 604800]))
+            (map #(* % scale 1000)
+                 [ 1 2 3 6 12 ]))
+          [ 1 60 3600 86400 ]))

 (def stroke-styles
   {:grid
@@ -175,16 +176,30 @@
                         (range (/ (range-magnitude y-range) y-interval))))]
         (draw-y-grid-line ctx w (pixel-snap (ty y)) y (= y 0))))))

-
+(defn draw-x-grid-line [ ctx h x value ]
+  (with-preserved-ctx ctx
+    (draw-xlabel ctx (format-xlabel value) x h false)
+    (set-stroke-style ctx :grid)
+    (draw-line ctx [ x 0 ] [ x h ])))
+
+(defn find-x-grid-interval [ w x-range ]
+  (let [magnitude (range-magnitude x-range)
+        max-label-count (floor (/ w pixels-per-x-label))]
+    (first
+     (first-that #(< (second %) max-label-count)
+                 (map #(vector % (/ magnitude %))
+                      x-line-intervals)))))

 (defn draw-x-grid [ ctx w h x-range ]
-  (draw-xlabel ctx (format-xlabel (:min x-range)) 0 h true)
-  (draw-xlabel ctx (format-xlabel (:max x-range)) w h false))
+  (let [x-interval (find-x-grid-interval w x-range)
+        tx (translate-fn x-range w)]
+    (doseq [ x (map #(- (:max x-range) (* % x-interval))
+                    (range 0 (/ (range-magnitude x-range) x-interval)))]
+      (draw-x-grid-line ctx h (tx x) x))))

 (defn draw-series [ ctx w h data x-range ]
   (with-preserved-ctx ctx
     (set-stroke-style ctx :series-line)
-
     (aset ctx "font" "12px Arial")
     (let [y-range (rescale-range (s-yrange data) 1.1)]
       (unless (empty? data)


Resolve merge conflict.

Resolve merge conflict.

--- src/oc/storage/resources/common.clj
+++ src/oc/storage/resources/common.clj
@@ -21,16 +21,6 @@

 (def Slug "Valid slug used to uniquely identify a resource in a visible URL." (schema/pred slug/valid-slug?))

-<<<<<<< HEAD
-=======
-(def Attachment {
-  :file-name lib-schema/NonBlankStr
-  :file-type lib-schema/NonBlankStr
-  :file-size schema/Num
-  :file-url lib-schema/NonBlankStr
-  :created-at lib-schema/ISO8601})
-
->>>>>>> 9d66260... Require new board's to have an entry sequence with an entry.
 (def ContributingAuthor
   "An author in a sequence of Authors involved in creating content."
   (merge lib-schema/Author {:updated-at lib-schema/ISO8601}))


change comment to reflect rename

change comment to reflect rename

--- src/parinfer/format/paren_mode.cljc
+++ src/parinfer/format/paren_mode.cljc
@@ -124,7 +124,7 @@
                   :cursor-in-comment? false
                   :delim-trail {:start nil :end nil}

-                  ;; different from process-line in parinfer.format.infer
+                  ;; different from process-line in parinfer.format.indent-mode
                   ;; (even if the stack is empty, we still have to track indentation)
                   :track-indent? (not (in-str? stack))


only turn instrumentation on in development for now

breaking b/c of missing react-ids

--- frontend/core.cljs
+++ frontend/core.cljs
@@ -249,7 +249,7 @@
   (let [state (app-state)
         top-level-node (find-top-level-node)
         history-imp (history/new-history-imp top-level-node)
-        instrument? (or (env/development?) (get-in @state [:current-user :admin]))]
+        instrument? (env/development?)]
     ;; globally define the state so that we can get to it for debugging
     (def debug-state state)
     (when instrument? (instrumentation/setup-component-stats!))


fix(mesh): re-add fix #59 in new source file

--- src/thi/ng/geom/meshface.cljc
+++ src/thi/ng/geom/meshface.cljc
@@ -12,7 +12,9 @@
          :cljs [^:mutable _hash])]

   g/IVertexAccess
-  (vertices [_ _] vertices)
+  (vertices
+    ([_] vertices)
+    ([_ _] vertices))

   g/IAttributeAccess
   (attribs [_ _] nil)
@@ -28,7 +30,7 @@
         [_ o]
         (and (instance? MeshFace o)
              (clojure.lang.Util/equals vertices (.-vertices ^MeshFace o))))
-
+
        Comparable
        (compareTo [_ o] (compare vertices (.-vertices ^MeshFace o)))

@@ -85,7 +87,7 @@
         (and (instance? IndexedMeshFace o)
              (clojure.lang.Util/equals vertices (.-vertices ^IndexedMeshFace o))
              (clojure.lang.Util/equals attribs (.-attribs ^IndexedMeshFace o))))
-
+
        Comparable
        (compareTo
         [_ o]


utils/log-pr

utils/log-pr

--- src-cljs/frontend/utils.cljs
+++ src-cljs/frontend/utils.cljs
@@ -56,6 +56,12 @@
   (when logging-enabled?
     (.apply (.-error js/console) js/console (clj->js messages))))

+(defn log-pr [& args]
+  (apply print (map #(if (= (type %) (type ""))
+                     %
+                     (subs (pr-str %) 0 1000))
+                  args)))
+
 (defn uuid
   "returns a type 4 random UUID: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
   []


fix remote url

fix remote url

--- src/cljs/wombats_web_client/constants/urls.cljs
+++ src/cljs/wombats_web_client/constants/urls.cljs
@@ -6,10 +6,10 @@
                            :config-panel "config"})

 ;; Remote Dev
-#_(def base-api-url "//dev.api.wombats.io")
+(def base-api-url "//dev.api.wombats.io")

 ;; Local Dev
-(def base-api-url "//localhost:8888")
+#_(def base-api-url "//localhost:8888")

 (def self-url (str base-api-url "/api/v1/self"))
 (def github-signout-url (str base-api-url "/api/v1/auth/github/signout"))


Updating counterexample message in EL_gfp exploration

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/contrib/dl/languages/interaction.clj
+++ src/conexp/contrib/dl/languages/interaction.clj
@@ -60,7 +60,7 @@
                            (let [next-object (first objects),
                                  new-attributes
                                  (loop []
-                                   (println (str "Please enter concept- and role-names which are satisfied by " next-object ":"))
+                                   (println (str "Please enter concept-names and role-relations which are satisfied by " next-object ":"))
                                    (let [new-attributes (read-string (str "(" (read-line) ")"))]
                                      (if-let [invalid (first (filter #(not (or (symbol? %)
                                                                                (and (seq? %) (= 2 (count %)))))


Reduce presence change logging in Slack

Reduce presence change logging in Slack

--- src/yetibot/core/adapters/slack.clj
+++ src/yetibot/core/adapters/slack.clj
@@ -174,11 +174,10 @@
   (let [active? (= "active" (:presence e))
         id (:user e)
         source (select-keys (base-chat-source) [:adapter])]
-    (log/debug id "presence change active?=" active?)
+    #_(log/trace id "presence change active?=" active?)
     (users/update-user source id {:active? active?})))

 (defn on-presence-change [e]
-  (log/debug "presence changed" e)
   (handle-presence-change e))

 (defn on-manual-presence-change [e]


Fix image list service.

Fix image list service.

--- src/uxbox/services/images.clj
+++ src/uxbox/services/images.clj
@@ -187,7 +187,9 @@

 (defn get-images-by-user
   [conn user collection]
-  (let [sqlv (sql/get-images-by-collection {:user user :collection collection})]
+  (let [sqlv (if collection
+               (sql/get-images-by-collection {:user user :collection collection})
+               (sql/get-images {:user user}))]
     (->> (sc/fetch conn sqlv)
          (map data/normalize-attrs))))


Don't save poster url

Don't save poster url

--- src/video_server/metadata.clj
+++ src/video_server/metadata.clj
@@ -112,7 +112,7 @@
   (let [video (video-for-key (-> title :videos first))
         info (fetch-metadata (or video title))
         poster (:poster info)]
-    (save-metadata title info)
+    (save-metadata title (dissoc info :poster))
     (when (and (not (:poster title)) poster)
       (save-poster title poster))
     info))


Make coral hollow.

Make coral hollow.

--- src/videotest/coral/coral.clj
+++ src/videotest/coral/coral.clj
@@ -128,7 +128,8 @@
                           hex-y-offset] :as coral-size}
                   [[col row :as coords]
                    {:keys [color-rgba] :as polyp}]]
-  (apply q/fill color-rgba)
+  #_(apply q/fill color-rgba)
+  (apply q/stroke color-rgba)
   (hex/draw-hex-cell cell-w cell-half-w
                      hex-w hex-half-w
                      hex-y-offset
@@ -136,8 +137,9 @@

 (defn draw-coral [{:keys [coral-size coral]}]
   (q/push-style)
-  (q/stroke-weight 1.0)
-  (q/stroke 255)
+  (q/no-fill)
+  (q/stroke-weight 4.0)
+  #_(q/stroke 255)
   (dorun
    (map (partial draw-polyp coral-size)
         coral))


spec voke.system.movement

spec voke.system.movement

--- src/voke/system/movement.cljs
+++ src/voke/system/movement.cljs
@@ -1,9 +1,7 @@
 (ns voke.system.movement
-  (:require [schema.core :as s]
+  (:require [cljs.spec :as s]
             [voke.events :refer [publish-event]]
-            [voke.schemas :refer [Axis Direction Entity GameState System]]
-            [voke.system.collision.system :refer [attempt-to-move!]])
-  (:require-macros [schema.core :as sm]))
+            [voke.system.collision.system :refer [attempt-to-move!]]))

 ; A dumb-as-rocks velocity/acceleration system.
 ; Based on http://www.randygaul.net/2012/02/22/basic-2d-vector-physics-acceleration-orientation-and-friction/ .
@@ -18,89 +16,128 @@
 (def friction-value 0.80)
 (def min-velocity 0.05)

-(sm/defn should-update-velocity? :- s/Bool
+; TODO namespace keywords
+
+(defn should-update-velocity?
   "Entities' velocity should be updated if they're intending to move somewhere
   or if they're currently moving and affected by friction."
-  [entity :- Entity]
-  (or (get-in entity [:motion :direction])
+  [entity]
+  (or (get-in entity [:component/motion :motion/direction])
       (and
-        (get-in entity [:motion :affected-by-friction])
+        (get-in entity [:component/motion :motion/affected-by-friction])
         (or
-          (not= (get-in entity [:motion :velocity :x]) 0)
-          (not= (get-in entity [:motion :velocity :y]) 0)))))
+          (not= (get-in entity [:component/motion :motion/velocity :geometry/x]) 0)
+          (not= (get-in entity [:component/motion :motion/velocity :geometry/y]) 0)))))

-(sm/defn get-acceleration :- s/Num
-  [entity :- Entity]
-  (if (get-in entity [:motion :direction])
-    (get-in entity [:motion :max-acceleration])
+(s/fdef should-update-velocity?
+  :args (s/cat :entity :entity/entity)
+  :ret boolean?)
+
+(defn get-acceleration
+  [entity]
+  (if (get-in entity [:component/motion :motion/direction])
+    (get-in entity [:component/motion :motion/max-acceleration])
     0))

-(sm/defn -update-axis-velocity :- Entity
-  [entity :- Entity
-   axis :- Axis
-   trig-fn :- (s/enum Math/cos Math/sin)]
-  (let [axis-velocity (get-in entity [:motion :velocity axis])
+(s/fdef get-acceleration
+  :args (s/cat :entity :entity/entity)
+  :ret number?)
+
+(defn -update-axis-velocity
+  [entity axis trig-fn]
+  (let [axis-velocity (get-in entity [:component/motion :motion/velocity axis])
         new-velocity (+ axis-velocity
                         (* (get-acceleration entity)
-                           (trig-fn (get-in entity [:motion :direction]))))]
+                           (trig-fn (get-in entity [:component/motion :motion/direction]))))]
     (if (> (Math/abs new-velocity) min-velocity)
-      (assoc-in entity [:motion :velocity axis] new-velocity)
-      (assoc-in entity [:motion :velocity axis] 0))))
+      (assoc-in entity [:component/motion :motion/velocity axis] new-velocity)
+      (assoc-in entity [:component/motion :motion/velocity axis] 0))))

-(sm/defn cap-velocity :- Entity
-  [entity :- Entity]
-  (let [velocity (get-in entity [:motion :velocity])
-        x-velocity (velocity :x)
-        y-velocity (velocity :y)
-        max-speed (get-in entity [:motion :max-speed])
+(s/fdef -update-axis-velocity
+  :args (s/cat :entity (s/and :entity/entity
+                              #(contains? (% :entity) :component/motion))
+               :axis #{:geometry/x :geometry/y}
+               :trig-fn #{Math/cos Math/sin})
+  :ret :entity/entity)
+
+(defn cap-velocity
+  [entity]
+  (let [velocity (get-in entity [:component/motion :motion/velocity])
+        x-velocity (velocity :geometry/x)
+        y-velocity (velocity :geometry/y)
+        max-speed (get-in entity [:component/motion :max-speed])
         amplitude (Math/sqrt (+ (* x-velocity x-velocity)
                                 (* y-velocity y-velocity)))
         multiplier (if (> amplitude max-speed)
                      (/ max-speed amplitude)
                      1)]
     (assoc-in entity
-              [:motion :velocity]
+              [:component/motion :motion/velocity]
               {:x (* x-velocity multiplier)
                :y (* y-velocity multiplier)})))

-(sm/defn update-velocity :- Entity
-  [entity :- Entity]
+(s/fdef cap-velocity
+  :args (s/and (s/cat :entity :entity/entity)
+               #(contains? (% :entity) :component/motion))
+  :ret :entity/entity)
+
+(defn update-velocity
+  [entity]
   (if (should-update-velocity? entity)
     (-> entity
-        (-update-axis-velocity :x Math/cos)
-        (-update-axis-velocity :y Math/sin)
+        (-update-axis-velocity :geometry/x Math/cos)
+        (-update-axis-velocity :geometry/y Math/sin)
         cap-velocity)
     entity))

-(sm/defn apply-friction :- Entity
-  [entity :- Entity]
-  (if (get-in entity [:motion :affected-by-friction])
+(s/fdef update-velocity
+  :args (s/cat :entity :entity/entity)
+  :ret :entity/entity)
+
+(defn apply-friction
+  [entity]
+  (if (get-in entity [:component/motion :motion/affected-by-friction])
     (reduce
       (fn [entity axis]
-        (update-in entity [:motion :velocity axis] #(* % friction-value)))
+        (update-in entity [:component/motion :motion/velocity axis] #(* % friction-value)))
       entity
-      [:x :y])
+      [:geometry/x :geometry/y])
     entity))

-(sm/defn update-position :- Entity
-  [entity :- Entity]
-  (let [velocity (-> entity :motion :velocity)
-        center (-> entity :shape :center)]
+(s/fdef apply-friction
+  :args (s/and (s/cat :entity :entity/entity)
+               #(contains? (% :entity) :component/motion))
+  :ret :entity/entity)
+
+(defn update-position
+  [entity]
+  (let [velocity (-> entity :component/motion :motion/velocity)
+        center (-> entity :component/shape :shape/center)]
     (assoc-in entity
-              [:shape :center]
-              {:x (+ (velocity :x) (center :x))
-               :y (+ (velocity :y) (center :y))})))
+              [:component/shape :shape/center]
+              {:geometry/x (+ (velocity :x) (center :x))
+               :geometry/y (+ (velocity :y) (center :y))})))

-(sm/defn relevant-to-movement-system? :- s/Bool
-  [entity :- Entity]
+(s/fdef update-position
+  :args (s/and (s/cat :entity :entity/entity)
+               #(contains? (% :entity) :component/motion)
+               #(contains? (% :entity) :component/shape))
+  :ret :entity/entity)
+
+(defn relevant-to-movement-system?
+  [entity]
   (or
-    (get-in entity [:motion :direction])
-    (not= (get-in entity [:motion :velocity :x] 0) 0)
-    (not= (get-in entity [:motion :velocity :y] 0) 0)))
+    (get-in entity [:component/motion :motion/direction])
+    (not= (get-in entity [:component/motion :motion/velocity :geometry/x] 0) 0)
+    (not= (get-in entity [:component/motion :motion/velocity :geometry/y] 0) 0)))
+
+(s/fdef relevant-to-movement-system?
+  :args (s/cat :entity :entity/entity)
+  :ret boolean?)

 ;; System definition

-(sm/def move-system :- System
+(def move-system
   {:tick-fn (fn move-system-tick [entities]
               (doseq [entity (filter relevant-to-movement-system? entities)]
                 (let [moved-entity (-> entity
@@ -110,6 +147,6 @@

                   (when (not= moved-entity entity)
                     (attempt-to-move! entity
-                                      (-> moved-entity :shape :center)
-                                      (-> moved-entity :motion :velocity)
+                                      (-> moved-entity :component/shape :shape/center)
+                                      (-> moved-entity :component/motion :motion/velocity)
                                       entities)))))})


fix reflection warnings

fix reflection warnings

--- src/yeller/clojure/client.clj
+++ src/yeller/clojure/client.clj
@@ -11,19 +11,22 @@
              JsonSerializer
              ObjectMapper
              module.SimpleModule)
-           (com.fasterxml.jackson.core Version)))
+           (com.fasterxml.jackson.core Version JsonGenerator)
+           (java.io PrintWriter)))

 (def client-version "yeller-clojure-client: 1.3.2")

-(defn default-io-error-handler [backend error]
-  (.println *err* (str "Yeller: an io error ocurred whilst talking to yeller: "))
-  (.printStackTrace error *err*))
-
-(defn default-auth-error-handler [backend error]
-  (.println *err* (str "Yeller: an authentication error ocurred whilst talking to yeller: " error))
-  (.printStackTrace error *err*))
-
-(defn set-error-handlers! [client options]
+(defn default-io-error-handler [backend ^Throwable error]
+  (.println ^PrintWriter *err* (str "Yeller: an io error ocurred whilst talking to yeller: "))
+  (if error
+    (.printStackTrace error ^PrintWriter *err*)))
+
+(defn default-auth-error-handler [backend ^Throwable error]
+  (.println ^PrintWriter *err* (str "Yeller: an authentication error ocurred whilst talking to yeller: " error))
+  (if error
+    (.printStackTrace error ^PrintWriter *err*)))
+
+(defn set-error-handlers! [^YellerHTTPClient client options]
   (if (or (:auth-error-handler options)
           (:io-error-handler options))
     (let [auth (:auth-error-handler options default-auth-error-handler)
@@ -41,7 +44,7 @@
   "turns a seq of endpoints into
   an array of endpoints"
   [endpoints]
-  (let [a (make-array String (count endpoints))]
+  (let [^"[Ljava.lang.String;" a (make-array String (count endpoints))]
     (loop  [i 0]
       (if (<= (count endpoints) i)
         a
@@ -58,7 +61,7 @@
   "turns a seq of application packages into
   an array of application packages"
   [app-packages]
-  (let [a (make-array String (count app-packages))]
+  (let [^"[Ljava.lang.String;" a (make-array String (count app-packages))]
     (loop  [i 0]
       (if (<= (count app-packages) i)
         a
@@ -66,7 +69,7 @@
           (aset a i (named->string (nth app-packages i)))
           (recur (inc i)))))))

-(defn set-urls! [client options]
+(defn set-urls! [^YellerHTTPClient client options]
   (when-let [endpoints (:endpoints options)]
     (assert (every? string? endpoints) (str "was given endpoints that weren't strings under :endpoints, got: " (pr-str endpoints)))
     (.setUrls client (make-endpoint-array (:endpoints options)))))
@@ -103,15 +106,15 @@
   (proxy [JsonSerializer] []
     (serialize [named generator provider]
       (if (namespace named)
-        (.writeString generator (str (namespace named) "/" (name named)))
-        (.writeString generator (name named))))))
+        (.writeString ^JsonGenerator generator (str (namespace named) "/" (name named)))
+        (.writeString ^JsonGenerator generator (name named))))))

 (def var-serializer
   (proxy [JsonSerializer] []
     (serialize [v generator provider]
       (if-let [n (:ns (meta v))]
-        (.writeString generator (str n "/" (:name (meta v))))
-        (.writeString generator (:name (meta v)))))))
+        (.writeString ^JsonGenerator generator ^String (str n "/" (:name (meta v))))
+        (.writeString ^JsonGenerator generator ^String (:name (meta v)))))))

 (defn ^ObjectMapper object-mapper
   "a Jackson ObjectMapper that serializes symbols, keywords and vars 'correctly'"
@@ -199,7 +202,7 @@
    {:params ...}
    "
   ([client exception] (report client exception {}))
-  ([client exception extra]
+  ([^YellerHTTPClient client ^Throwable exception extra]
    (if (or (:environment extra)
            (:location extra)
            (:url extra))
@@ -210,6 +213,6 @@
                 (stringify-keys (add-ex-data exception (:custom-data extra {})))))
      (.report client
               exception
-              (stringify-keys (add-ex-data
+              ^java.util.Map (stringify-keys (add-ex-data
                                 exception
                                 (:custom-data extra {})))))))


indent view

indent view

--- src/ca_recipe/tnywb/view.clj
+++ src/ca_recipe/tnywb/view.clj
@@ -1,8 +1,16 @@
 (ns mbfpp.oo.tinyweb.steptwo
   (:import (com.mblinn.oo.tinyweb RenderingException)))
-(defn test-controller [http-request] {:name (http-request :body)})
-(defn test-view [model]
+
+(defn test-controller
+  [http-request]
+  {:name (http-request :body)})
+
+(defn test-view
+  [model]
   (str "
Hello, " (model :name) "
"))
-(defn- render [view model] (try
-                             (view model)
-                             (catch Exception e (throw (RenderingException. e)))))
+
+(defn- render
+  [view model]
+  (try
+    (view model)
+    (catch Exception e (throw (RenderingException. e)))))


Make fps label bigger

Make fps label bigger

--- minicraft/desktop/src-common/minicraft/core.clj
+++ minicraft/desktop/src-common/minicraft/core.clj
@@ -78,15 +78,24 @@
 (defscreen text-screen
   :on-show
   (fn [screen entities]
-    (update! screen :renderer (stage))
-    (conj entities (assoc (ui/label "0" (color :white)) :id :fps)))
+    (update! screen
+             :renderer (stage)
+             :camera (orthographic-camera))
+    (assoc (ui/label "0" (color :white))
+           :id :fps
+           :x 5))
   :on-render
   (fn [screen entities]
+    (render! screen)
     (->> (for [entity entities]
            (case (:id entity)
              :fps (doto entity (ui/label! :set-text (str (game :fps))))
              entity))
-         (draw! screen))))
+         (draw! screen)))
+  :on-resize
+  (fn [screen entities]
+    (height! screen 300)
+    nil))

 (defgame minicraft
   :on-create


don't throw exception, but merely log/warn, if no complements are found for a given bolt.

--- src/babel/forest.cljc
+++ src/babel/forest.cljc
@@ -300,7 +300,7 @@
               ;; else, no complements could be added to this bolt: Throw an exception
               (let [log-limit 1000
                     log-fn (fn [message] (log/warn message))
-                    throw-exception-if-no-complements-found true
+                    throw-exception-if-no-complements-found false
                     message
                     (str " add-complement to " (get-in bolt [:rule]) " at path: " path
                          " took " run-time " msec, but found neither phrasal nor lexical complements for "


Grab more info from the vubis export

Grab more info from the vubis export

--- src/catalog/vubis.clj
+++ src/catalog/vubis.clj
@@ -19,7 +19,14 @@
    :source_date [:datafield (attr= :tag "534") :subfield (attr= :code "d")]
    :language [:datafield (attr= :tag "041") :subfield (attr= :code "a")]
    :general-note [:datafield (attr= :tag "500") :subfield (attr= :code "a")]
+   :personel-name [:datafield (attr= :tag "700") :subfield (attr= :code "a")]
+   :personel-relator-term [:datafield (attr= :tag "700") :subfield (attr= :code "e")]
+   :narrator [:datafield (attr= :tag "709") :subfield (attr= :code "a")]
    :duration [:datafield (attr= :tag "391") :subfield (attr= :code "a")]
+   :producer [:datafield (attr= :tag "260") :subfield (attr= :code "b")]
+   :producer_place [:datafield (attr= :tag "260") :subfield (attr= :code "a")]
+   :produced_date [:datafield (attr= :tag "260") :subfield (attr= :code "c")]
+   :produced_commercially [:datafield (attr= :tag "260") :subfield (attr= :code "d")]
    :format-raw [:datafield (attr= :tag "091") :subfield (attr= :code "c")]
    :genre-raw [:datafield (attr= :tag "099") :subfield (attr= :code "b")]
    :price [:datafield (attr= :tag "024") :subfield (attr= :code "c")]})


disable codemirror autofocus

disable codemirror autofocus

--- src/main/shadow/cljs/ui/components/inspect.cljs
+++ src/main/shadow/cljs/ui/components/inspect.cljs
@@ -28,7 +28,7 @@
         :disabled (not= :ready loading-state)}
        "COPY"]
     (if (= :ready loading-state)
-      (codemirror {:value val :cm-opts #js {:readOnly true}})
+      (codemirror {:value val :cm-opts #js {:readOnly true :autofocus false}})
       ;; not using codemirror initially since it wants to treat "Loading ..." as clojure code
       (<< [:div.w-full.h-full.font-mono.border-t.p-4
            "Loading ..."]))))


make search case insensitive

make search case insensitive

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

--- plugins/DataBrowser/src/org/micromanager/browser/core.clj
+++ plugins/DataBrowser/src/org/micromanager/browser/core.clj
@@ -103,7 +103,7 @@
         column-indices
           (int-array (map #(.getModelIndex %) (get-table-columns table)))
         filters
-          (map #(RowFilter/regexFilter (str "\\Q" % "\\E") column-indices)
+          (map #(RowFilter/regexFilter (str "(?i)\\Q" % "\\E") column-indices)
                chunks)]
     (do (.setRowFilter sorter
           (RowFilter/andFilter filters)))))


Fix index creation

Fix index creation

--- src/clj/clojuredocs/main.clj
+++ src/clj/clojuredocs/main.clj
@@ -29,30 +29,42 @@
     (println)
     (System/exit -1)))

-(defn add-indexes! []
-  (mon/add-index! :examples [:var
-                             :deleted-at
-                             :author.login :author.account-source
-                             :editors.login :editors.account-source])
-  (mon/add-index! :namespaces [:name])
-  (mon/add-index! :see-alsos [:from-var.name :from-var.ns :from-var.library-url
-                              :to-var.ns :to-var.name :to-var.library-url
-                              :account.login :account.account-source])
-  (mon/add-index! :libraries [:namespaces])
-  (mon/add-index! :notes [:var.ns :var.name :var.library-url
-                          :account.login :account.account-source])
+(defn add-indexes-to-coll! [coll ks]
+  (doseq [k ks]
+    (mon/add-index! :examples [k])))

-  (mon/add-index! :legacy-var-redirects [:function-id
-                                         :editor.login :editor.account-source])
+(defn add-all-indexes! []
+  (add-indexes-to-coll!
+    :examples [:var :deleted-at
+               :author.login :author.account-source
+               :editors.login :editors.account-source])

-  (mon/add-index! :users [:login :account-source])
+  (add-indexes-to-coll! :namespaces [:name])

-  (mon/add-index! :migrate-users [:email :migraion-key]))
+  (add-indexes-to-coll!
+    :see-alsos [:from-var.name :from-var.ns :from-var.library-url
+                :to-var.ns :to-var.name :to-var.library-url
+                :account.login :account.account-source])
+
+  (add-indexes-to-coll! :libraries [:namespaces])
+
+  (add-indexes-to-coll!
+    :notes [:var.ns :var.name :var.library-url
+            :account.login :account.account-source])
+
+  (add-indexes-to-coll!
+    :legacy-var-redirects [:function-id
+                           :editor.login :editor.account-source])
+
+  (add-indexes-to-coll! :users [:login :account-source])
+
+  (add-indexes-to-coll! :migrate-users [:email :migraion-key]))
+

 (defn start [{:keys [port mongo-url entry] :as opts}]
   (report-and-exit-on-missing-env-vars!)
   (mon/set-connection! (mon/make-connection mongo-url))
-  #_(add-indexes!)
+  (add-all-indexes!)
   (let [stop-server (start-http-server entry
                       {:port port :join? false})]
     (println (format "Server running on port %d" port))


added map values func #115

added map values func
#115

--- src/cljc/swarmpit/utils.cljc
+++ src/cljc/swarmpit/utils.cljc
@@ -7,16 +7,31 @@
          (subvec vector 0 index)
          (subvec vector (inc index)))))

-(defn select-keys* [m paths]
+(defn select-keys*
   "Better select-keys supporting also nested maps. E.g. [[:name] [:node :nodeName]]"
+  [m paths]
   (->> paths
        (map (fn [p]
               [(last p) (get-in m p)]))
        (into {})))

 (defn merge-data
-  "Recursively merge delta to current json map structure."
-  [data delta]
-  (cond (and (map? data)
-             (map? delta)) (merge-with merge-data data delta)
-        :else delta))+  "Recursively merge map delta to current data structure."
+  [m delta]
+  (cond (and (map? m)
+             (map? delta)) (merge-with merge-data m delta)
+        :else delta))
+
+(defn map-values
+  "Walk the map and return all values as set"
+  [m]
+  (remove nil?
+          (set
+            (flatten
+              (clojure.walk/prewalk
+                (fn [x]
+                  (cond
+                    (map? x) (vals x)
+                    (integer? x) (str x)
+                    (boolean? x) (str x)
+                    :else (identity x))) m)))))


Improve implementation of clojure.string/blank?

--- src/cljs/clojure/string.cljs
+++ src/cljs/clojure/string.cljs
@@ -133,13 +133,7 @@
 (defn blank?
   "True is s is nil, empty, or contains only whitespace."
   [s]
-  (let [s (str s)]
-    (if (or
-         (not s)
-         (= "" s)
-         (re-matches #"\s+" s))
-      true
-      false)))
+  (gstring/isEmptySafe s))

 (defn escape
   "Return a new string, using cmap to escape each character ch


Add card counter to page

Add card counter to page

--- src/cljs/decktouch/core.cljs
+++ src/cljs/decktouch/core.cljs
@@ -23,9 +23,14 @@
      (for [card cards]
        ^{:key card} (card-in-list (get card "name")))]))

+
+(defn card-counter [cards]
+  [:h3 (count cards) " cards"])
+
 (defn home-page []
   [:div [:h2 "Welcome to decktouch"]
-   [:div [card-input/component card-data/card-list]]
+   [:div [card-input/component card-data/card-list]
+         [card-counter @card-data/card-list]]
    [:div [card-list @card-data/card-list]]
    [:div [:a {:href "#/about"} "go to about page"]]])


Add simple Cljs to HTML helpers

Add simple Cljs to HTML helpers

--- src/cljs/mathom/toolbar.cljs
+++ src/cljs/mathom/toolbar.cljs
@@ -29,8 +29,8 @@
     (.setAttribute tb "id" "mathom_toolbar")
     (.appendChild body tb)
     (set-content content)
-    (swap! tool #(assoc @tool :bar tb)) ; To get access to generated node
-    ))
+    (swap! tool #(assoc @tool :bar tb)))) ; To get access to generated node
+

 (defn handle-event
   [eib])
@@ -40,3 +40,23 @@
   (.addEventListener (:bar @tool)
                      "click"
                      #(handle-event (aget (.-target %) "id"))))
+
+
+(defn d-to-s
+  "Returns stringified version
+  of given map in HTML/XML
+  attribute style"
+  [d]
+  (clojure.string/join " "
+                       (for [[k v] d]
+                         (str (name k) "=\"" v "\""))))
+
+
+(defn h
+  "Returns a string resembling
+  HTML tag, attributes and children"
+  [tag attrs children]
+  (str "<" tag
+       (if (not(empty? attrs)) (str " " (d-to-s attrs))) ">"
+       (if (not(empty? children)) (clojure.string/join " " children))
+       "</" tag ">"))


In 'in-ns special fn emit a goog.provide if the namespace doesn't already exist

--- src/clj/cljs/repl.clj
+++ src/clj/cljs/repl.clj
@@ -180,11 +180,13 @@
             (load-file repl-env file opts)))]
     {'in-ns
      (fn self
-       ([_ form]
-         (self _ form nil))
-       ([_ [_ [quote ns-name] :as form] _]
+       ([repl-env form]
+         (self repl-env form nil))
+       ([repl-env [_ [quote ns-name] :as form] _]
          (when-not (ana/get-namespace ns-name)
-           (swap! env/*compiler* assoc-in [::ana/namespaces ns-name] {:name ns-name}))
+           (swap! env/*compiler* assoc-in [::ana/namespaces ns-name] {:name ns-name})
+           (-evaluate repl-env "<cljs repl>" 1
+             (str "goog.provide('" (comp/munge ns-name) "');")))
          (set! ana/*cljs-ns* ns-name)))
      'load-file load-file-fn
      'clojure.core/load-file load-file-fn


Fix for Kate discount when installing Parasite.

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -997,26 +997,28 @@
   ([state side card] (runner-install state side card nil))
   ([state side {:keys [title type cost memoryunits uniqueness] :as card}
     {:keys [extra-cost no-cost host-card] :as params}]
-    (trigger-event state side :pre-install card)
-    (if-let [hosting (and (not host-card) (:hosting (card-def card)))]
-      (resolve-ability state side
-                       {:choices hosting
-                        :effect (effect (runner-install card (assoc params :host-card target)))} card nil)
-      (let [cost (if no-cost 0 (install-cost state side card))]
-        (when (and (or (not uniqueness) (not (in-play? state card)))
-                   (if-let [req (:req (card-def card))]
-                     (req state side card nil) true)
-                   (pay state side card :credit cost (when memoryunits [:memory memoryunits]) extra-cost))
-          (let [c (if host-card
-                    (host state side host-card card)
-                    (move state side card [:rig (to-keyword type)]))
-                installed-card (card-init state side (assoc c :installed true))]
-            (system-msg state side (str "installs " title
-                                        (when host-card (str " on " (:title host-card)))
-                                        (when no-cost " at no cost")))
-            (trigger-event state side :runner-install installed-card)
-            (when (has? c :subtype "Icebreaker") (update-breaker-strength state side c))))))
-    (swap! state update-in [:bonus] dissoc :install-cost)))
+
+   (if-let [hosting (and (not host-card) (:hosting (card-def card)))]
+     (resolve-ability state side
+                      {:choices hosting
+                       :effect (effect (runner-install card (assoc params :host-card target)))} card nil)
+     (do
+       (trigger-event state side :pre-install card)
+       (let [cost (if no-cost 0 (install-cost state side card))]
+         (when (and (or (not uniqueness) (not (in-play? state card)))
+                    (if-let [req (:req (card-def card))]
+                      (req state side card nil) true)
+                    (pay state side card :credit cost (when memoryunits [:memory memoryunits]) extra-cost))
+           (let [c (if host-card
+                     (host state side host-card card)
+                     (move state side card [:rig (to-keyword type)]))
+                 installed-card (card-init state side (assoc c :installed true))]
+             (system-msg state side (str "installs " title
+                                         (when host-card (str " on " (:title host-card)))
+                                         (when no-cost " at no cost")))
+             (trigger-event state side :runner-install installed-card)
+             (when (has? c :subtype "Icebreaker") (update-breaker-strength state side c)))))))
+   (swap! state update-in [:bonus] dissoc :install-cost)))

 (defn server-list [state card]
   (let [remotes (cons "New remote" (for [i (range (count (get-in @state [:corp :servers :remote])))]


Show turn number

Show turn number

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -726,7 +726,7 @@
         runner-identity (assoc (or (get-in runner [:deck :identity]) {:side "Runner" :type "Identity"}) :cid (make-cid))
         state (atom
                {:gameid gameid :log [] :active-player :runner :end-turn true
-                :rid 0
+                :rid 0 :turn 0
                 :corp {:user (:user corp) :identity corp-identity
                        :deck (zone :deck (drop 5 corp-deck))
                        :hand (zone :hand (take 5 corp-deck))
@@ -1346,16 +1346,20 @@
         hand (if (= side :runner) "their Grip" "HQ")
         cards (count (get-in @state [side :hand]))
         credits (get-in @state [side :credit])
-        text (str pre " their turn with " credits " [Credit] and " cards " cards in " hand)]
+        text (str pre " their turn " (:turn @state) " with " credits " [Credit] and " cards " cards in " hand)]
     (system-msg state side text {:hr (not start-of-turn)})))

 (defn start-turn [state side args]
+  (when (= side :corp)
+    (swap! state update-in [:turn] inc))
   (turn-message state side true)
   (swap! state assoc :active-player side :per-turn nil :end-turn false)
   (swap! state assoc-in [side :register] nil)
   (swap! state assoc-in [side :click] (get-in @state [side :click-per-turn]))
   (trigger-event state side (if (= side :corp) :corp-turn-begins :runner-turn-begins))
-  (when (= side :corp) (do (draw state :corp) (update-all-advancement-costs state side))))
+  (when (= side :corp)
+    (do (draw state :corp)
+        (update-all-advancement-costs state side))))

 (defn end-turn [state side args]
   (let [max-hand-size (get-in @state [side :max-hand-size])]


added dave ex examples

added dave ex examples

--- src/devcards/daveconservatoire/site/ui/vexflow_cards.cljs
+++ src/devcards/daveconservatoire/site/ui/vexflow_cards.cljs
@@ -1,7 +1,8 @@
 (ns daveconservatoire.site.ui.vexflow-cards
   (:require [devcards.core :refer [defcard deftest dom-node]]
             [cljs.test :refer [is are run-tests async testing]]
-            [daveconservatoire.site.ui.vexflow :as v]))
+            [daveconservatoire.site.ui.vexflow :as v]
+            [om.dom :as dom]))

 (defcard blank-score
   (fn [_ _]
@@ -31,16 +32,53 @@
                                     {::v/keys ["f/5"] ::v/duration "q"}]}]}))
   {})

-(defcard multi-bar2
+(defcard dave-ex
   (fn [_ _]
-    (v/score {::v/width 500 ::v/height 150
-              ::v/clef ::v/treble
-              ::v/bars [{::v/notes [{::v/keys ["c/5"] ::v/duration "q"}
-                                    {::v/keys ["d/5"] ::v/duration "q"}
-                                    {::v/keys ["e/5"] ::v/duration "q"}
-                                    {::v/keys ["c/4"] ::v/duration "q"}]}
-                        {::v/notes [{::v/keys ["c/5"] ::v/duration "q"}
-                                    {::v/keys ["d/5"] ::v/duration "q"}
-                                    {::v/keys ["e/5"] ::v/duration "q"}
-                                    {::v/keys ["c/4"] ::v/duration "q"}]}]}))
+    (dom/div nil
+      (v/score {::v/width 500 ::v/height 150
+                ::v/clef  ::v/treble
+                ::v/bars  [{::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "h"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "w"}]}]})
+      (v/score {::v/width 500 ::v/height 150
+                ::v/clef  ::v/treble
+                ::v/bars  [{::v/notes [{::v/keys ["b/4"] ::v/duration "w"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "h"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "w"}]}]})
+      (v/score {::v/width 500 ::v/height 150
+                ::v/clef  ::v/treble
+                ::v/bars  [{::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "h"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}]})
+      (v/score {::v/width 500 ::v/height 150
+                ::v/clef  ::v/treble
+                ::v/bars  [{::v/notes [{::v/keys ["b/4"] ::v/duration "w"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "h"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "h"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}
+                                       {::v/keys ["b/4"] ::v/duration "q"}]}
+                           {::v/notes [{::v/keys ["b/4"] ::v/duration "w"}]}]})))
   {})


restore indent change

restore indent change

--- storm-core/src/clj/org/apache/storm/testing.clj
+++ storm-core/src/clj/org/apache/storm/testing.clj
@@ -691,8 +691,8 @@
                 (increment-global! id# "transferred" 1)
                 (apply transferrer# args2#)))))]
        (with-simulated-time-local-cluster [~cluster-sym ~@cluster-args]
-                                          (let [~cluster-sym (assoc-track-id ~cluster-sym id#)]
-                                            ~@body)))
+                           (let [~cluster-sym (assoc-track-id ~cluster-sym id#)]
+                             ~@body)))
      (RegisteredGlobalState/clearState id#)))

 (defn tracked-wait


added glossary to xml formatted result

added glossary to xml formatted result

--- src/distillery/xmlresult.clj
+++ src/distillery/xmlresult.clj
@@ -77,6 +77,23 @@
    [:Source {} (:video-file video)]
    (speech-recognition-tag job video)])

+(defn- occurrence-tag
+  [job word {:keys [video-id result-no word-no] :as occurrence}]
+  (let [video (first (filter #(= video-id (:id %)) (:videos job)))
+        phrase-start (get-in video [:results result-no :start])]
+    [:Occurrence {:video video-id
+                  :phrase result-no
+                  :no word-no
+                  :phrase-start phrase-start}]))
+
+(defn- word-tag
+  [job {:keys [lexical-form pronunciation occurrence-count occurrences] :as word}]
+  [:Word {:lexical-form lexical-form
+          :pronunciation pronunciation}
+   (tag-list :OccurrenceList
+             (partial occurrence-tag job word)
+             occurrences)])
+
 (defn- job-result-tags
   [job]
   (xml/sexp-as-element
@@ -89,7 +106,10 @@
               (:categories job))
     (tag-list :MediaList
               (partial video-tag job)
-              (:videos job))]))
+              (:videos job))
+    (tag-list :Glossary
+              (partial word-tag job)
+              (map val (:words job)))]))

 (defn save-result
   [path job]


Une solution au puzzle Medium "Shadows of the Knight" en Clojure assez inélégante et peu idiosyncratique... mais qui fonctionne... je n'en suis pas fier et j'en ai bavé à la faire... à analyser pour plus tard

--- clojure/codingame/practice/medium/shadows-of-the-knight-ep1/src/shadows_of_the_knight_ep1/core.clj
+++ clojure/codingame/practice/medium/shadows-of-the-knight-ep1/src/shadows_of_the_knight_ep1/core.clj
@@ -4,30 +4,70 @@
 ; Auto-generated code below aims at helping you parse
 ; the standard input according to the problem statement.

-(defn compute-middle [start end]
-  (quot (- end start) 2))
+(defn difference [current-value to-substract]
+  (Math/abs(- current-value to-substract)))

-(defn compute-jump-coord [width height current-x current-y bomb-dir]
+(defn compute-middle [value]
+  (quot value 2))
+
+(defn move-forward [curr-pos delta max-val]
+  (min max-val (+ curr-pos delta)))
+
+
+(defn compute-jump-coord [width height current-x current-y min-x min-y max-x max-y bomb-dir]
+  (let [direction (str bomb-dir)]
   (cond
-    (= "UR" bomb-dir) (do
-                        (reset! current-x (compute-middle (min (inc @current-x) (dec width)) (max (inc @current-x) (dec width))))
-                        (reset! current-y (compute-middle (min (dec @current-y) 0) (max (dec @current-y) 0))))
-    (= "R"  bomb-dir) (reset! current-x (compute-middle (min (inc @current-x) (dec width)) (max (inc @current-x) (dec width))))
-    (= "DR" bomb-dir) (do
-                        (reset! current-x (compute-middle (min (inc @current-x) (dec width)) (max (inc @current-x) (dec width))))
-                        (reset! current-y (compute-middle (min (inc @current-y) (dec height)) (max (inc @current-y) (dec height)))))
-    (= "D"  bomb-dir) (reset! current-y (compute-middle (min (inc @current-y) (dec height)) (max (inc @current-y) (dec height))))
-    (= "DL" bomb-dir) (do
-                        (reset! current-x (compute-middle (min (dec @current-x) 0) (max (dec @current-x) 0)))
-                        (reset! current-y (compute-middle (min (inc @current-y) (dec height)) (max (inc @current-y) (dec height)))))
-    (= "L"  bomb-dir) (reset! current-x (compute-middle (min (dec @current-x) 0) (max (dec @current-x) 0)))
-    (= "UL" bomb-dir) (do
-                        (reset! current-x (compute-middle (min (dec @current-x) 0) (max (dec @current-x) 0)))
-                        (reset! current-y (compute-middle (min (dec @current-y) 0) (max (dec @current-y) 0))))
-    (= "U"  bomb-dir) (reset! current-y (compute-middle (min (dec @current-y) 0) (max (dec @current-y) 0)))))
+    (= "UR" direction) (do
+                          (reset! min-x (inc @current-x))
+                          (reset! max-y (dec @current-y))
+                          (reset! width (- @max-x @min-x))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-x (+ @min-x (compute-middle @width)))
+                          (reset! current-y (- @max-y (compute-middle @height ))))
+    (= "R"  direction) (do
+                          (reset! min-x (inc @current-x))
+                          (reset! width (- @max-x @min-x))
+                          (reset! current-x (+ @min-x (compute-middle @width) )))
+    (= "DR" direction) (do
+                          (reset! min-x (inc @current-x))
+                          (reset! min-y (inc @current-y))
+                          (reset! width (- @max-x @min-x))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-x (+ @min-x (compute-middle @width)))
+                          (reset! current-y (+ @min-y (compute-middle @height))))
+    (= "D"  direction) (do
+                          (reset! min-y (inc @current-y))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-y (+ @min-y (compute-middle @height))))
+    (= "DL" direction) (do
+                          (reset! max-x (dec @current-x))
+                          (reset! min-y (inc @current-y))
+                          (reset! width (- @max-x @min-x))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-x (- @max-x (compute-middle @width)))
+                          (reset! current-y (+ @min-y (compute-middle @height))))
+    (= "L"  direction) (do
+                          (reset! max-x (dec @current-x))
+                          (reset! width (- @max-x @min-x))
+                          (reset! current-x (- @max-x (compute-middle @width))))
+    (= "UL" direction) (do
+                          (reset! max-x (dec @current-x))
+                          (reset! max-y (dec @current-y))
+                          (reset! width (- @max-x @min-x))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-x (- @max-x (compute-middle @width)))
+                          (reset! current-y (- @max-y (compute-middle @height ))))
+    (= "U"  direction) (do
+                          (reset! max-y (dec @current-y))
+                          (reset! height (- @max-y @min-y))
+                          (reset! current-y (- @max-y (compute-middle @height )))))))

 (defn -main [& args]
-  (let [W (read) H (read) N (read) X0 (read) Y0 (read) current-x (atom X0) current-y (atom Y0)]
+  (let [W (read) H (read) N (read) X0 (read) Y0 (read)
+        current-width (atom (Integer/valueOf W)) current-height (atom (Integer/valueOf H))
+        current-x (atom (Integer/valueOf X0)) current-y (atom (Integer/valueOf Y0))
+        min-x (atom 0) min-y (atom 0)
+        max-x (atom (dec @current-width)) max-y (atom(dec @current-height))]
     ; W: width of the building.
     ; H: height of the building.
     ; N: maximum number of turns before game over.
@@ -37,7 +77,10 @@

         ; (binding [*out* *err*]
         ;   (println "Debug messages..."))
+        (binding [*out* *err*]
+           (println (str "width : " @current-width " height : " @current-height " current-x : " @current-x " current-y : " @current-y)))
         (compute-jump-coord
-          (Integer/valueOf W) (Integer/valueOf H) current-x current-y bombDir)
+          current-width current-height current-x current-y min-x min-y max-x max-y bombDir)
         ; the location of the next window Batman should jump to.
         (println (str @current-x " " @current-y))))))
+


update natal-shell version

update natal-shell version

--- resources/project.clj
+++ resources/project.clj
@@ -7,7 +7,7 @@
                  [org.clojure/clojurescript "1.7.170"]
                  [$REACT_INTERFACE$]
                  [org.omcljs/ambly "0.6.0"]
-                 [natal-shell "0.1.0"]]
+                 [natal-shell "0.1.2"]]
  :plugins [[lein-cljsbuild "1.1.1"]]
  :cljsbuild {:builds {:dev {:source-paths ["src"]
                             :compiler {:output-to "target/out/main.js"


Separate dot generation part on planner test

--- test/com/wsscode/pathom/connect/planner_test.cljc
+++ test/com/wsscode/pathom/connect/planner_test.cljc
@@ -35,47 +35,50 @@
           (str prefix "-" n ".png"))
         file-name))))

+(defn plan->dot [env {::pcp/keys [nodes root]}]
+  (let [edges (into []
+                    (mapcat
+                      (fn [{::pcp/keys [run-next node-id] :as node}]
+                        (let [branches (pcp/node-branches node)]
+                          (cond-> (into []
+                                        (map #(vector node-id % {:color "orange"}))
+                                        branches)
+                            run-next
+                            (conj [node-id run-next])))))
+                    (vals nodes))]
+    (tangle/graph->dot (mapv ::pcp/node-id (vals nodes)) edges
+      {:graph            {:rankdir :LR}
+       :node             {:shape :circle}
+       :directed?        true
+       :node->id         identity
+       :node->descriptor (fn [node-id]
+                           (let [node  (get nodes node-id)
+                                 attrs (::pcp/source-for-attrs node)]
+                             (cond-> {:id    (str node-id)
+                                      :style "filled"
+                                      :color (if (= node-id root) "blue" "#F3F3F3")
+                                      :label (str
+                                               (str node-id " | ")
+                                               #_(if attrs
+                                                   (str (str/join "" attrs) " | "))
+                                               (pcp/node->label node))}
+                               (get-in env [::pc/index-resolvers (::pc/sym node) ::pc/dynamic-resolver?])
+                               (assoc
+                                 :fontcolor "white"
+                                 :fillcolor "black")
+
+                               (::pcp/run-and node)
+                               (assoc
+                                 :fillcolor "yellow")
+
+                               (::pcp/run-or node)
+                               (assoc
+                                 :fillcolor "cyan"))))})))
+
 (defn render-graph [{::pcp/keys [nodes root] :as graph} {::keys [file-name] :as env}]
   #?(:clj
      (if (not (System/getenv "PATHOM_TEST"))
-       (let [edges (into []
-                         (mapcat
-                           (fn [{::pcp/keys [run-next node-id] :as node}]
-                             (let [branches (pcp/node-branches node)]
-                               (cond-> (into []
-                                             (map #(vector node-id % {:color "orange"}))
-                                             branches)
-                                 run-next
-                                 (conj [node-id run-next])))))
-                         (vals nodes))
-             dot   (tangle/graph->dot (mapv ::pcp/node-id (vals nodes)) edges
-                     {:graph            {:rankdir :LR}
-                      :node             {:shape :circle}
-                      :directed?        true
-                      :node->id         identity
-                      :node->descriptor (fn [node-id]
-                                          (let [node  (get nodes node-id)
-                                                attrs (::pcp/source-for-attrs node)]
-                                            (cond-> {:id    (str node-id)
-                                                     :style "filled"
-                                                     :color (if (= node-id root) "blue" "#F3F3F3")
-                                                     :label (str
-                                                              (str node-id " | ")
-                                                              #_(if attrs
-                                                                  (str (str/join "" attrs) " | "))
-                                                              (pcp/node->label node))}
-                                              (get-in env [::pc/index-resolvers (::pc/sym node) ::pc/dynamic-resolver?])
-                                              (assoc
-                                                :fontcolor "white"
-                                                :fillcolor "black")
-
-                                              (::pcp/run-and node)
-                                              (assoc
-                                                :fillcolor "yellow")
-
-                                              (::pcp/run-or node)
-                                              (assoc
-                                                :fillcolor "cyan"))))})]
+       (let [dot (plan->dot env graph)]
          (io/copy (tangle/dot->svg dot) (io/file (or file-name "out.svg")))
          #_(io/copy (tangle/dot->image dot "png") (io/file (or file-name "out.png"))))))
   graph)


Add missing `resolve` method to stroages.util ns.

--- backend/vendor/storages/util.clj
+++ backend/vendor/storages/util.clj
@@ -108,6 +108,14 @@
   [path]
   (first (split-ext path)))

+(defn resolve
+  "Resolve path on top of an other path."
+  [base path]
+  (let [^Path base (pt/-path base)
+        ^Path path (pt/-path path)]
+    (-> (.resolve base path)
+        (.normalize))))
+
 (defn list-directory
   [path]
   (let [path (pt/-path path)]


(MAINT) change fns to seq of seq

(MAINT) change fns to seq of seq

--- src/puppetlabs/trapperkeeper/services_internal.clj
+++ src/puppetlabs/trapperkeeper/services_internal.clj
@@ -61,7 +61,7 @@
 (def ProtocolandDependenciesMap
   "Schema defining the map used to represent the protocol and dependencies
   of a service."
-  {:fns (schema/pred seq?)
+  {:fns [(schema/pred seq?)]
    :dependencies (schema/pred vector?)
    :service-protocol-sym (schema/maybe Symbol)})


Fix test since we changed db:create:all to just db:create.

--- test/circle/backend/build/inference/test_rails.clj
+++ test/circle/backend/build/inference/test_rails.clj
@@ -73,4 +73,4 @@
   ;; repo with database.example.yml
   (let [example-repo (test-repo "database_yml_1")]
     (->> (spec example-repo) (map :name)) => (and (contains "copy database.yml")
-                                                  (contains "rake db:create:all --trace"))))+                                                  (contains "rake db:create --trace"))))


Eliminate unnecessary workaround for loading

Former-commit-id: 92267fb2b361e44a64223ce0f4d6a77db027a0a6

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -310,10 +310,8 @@
                 (when (and precompiled-js cache-json)
                   (when (:verbose @app-env)
                     (println-verbose "Loading precompiled JS and analysis cache for" full-path))
-                  ; cljs.js won't load dependent namespaces, so instead we let Closure do it
-                  (js/goog.require (s/replace path #"/" "."))
                   {:lang   :js
-                   :source ""                               ; Intentionally pass empty source
+                   :source precompiled-js
                    :cache  (transit-json->cljs cache-json)})))))
       :loaded)))


Limit the transducers usage when publisher is build from other publisher.

--- src/futura/stream.clj
+++ src/futura/stream.clj
@@ -32,44 +32,36 @@
   "Coerce a core.async channel to an instance
   of subscription interface."
   {:no-doc true}
-  ([subscriber source xform]
-   (chan->subscription subscriber source xform false))
-  ([subscriber source xform close]
+  ([subscriber source]
+   (chan->subscription subscriber source false))
+  ([subscriber source close]
    (let [completed (atomic/boolean false)
          requests (async/chan)
-         xform (or xform (map identity))
-         rf (xform (fn
-                     ([s] s)
-                     ([s v] (.onNext s v))))]
-     (letfn [(pipeline [n]
-               (go-loop [n n]
-                 (when (and (pos? n) (not @completed))
-                   (if-let [value (<! source)]
-                     (let [res (rf subscriber value)]
-                       (if (reduced? res)
-                         (do
-                           (.onComplete (rf subscriber))
-                           (async/close! requests)
-                           (when close (async/close! source))
-                           (atomic/compare-and-set! completed false true))
-                         (recur (dec n))))
-                     (do
-                       (.onComplete subscriber)
-                       (async/close! requests)
-                       (atomic/compare-and-set! completed false true))))))]
-       (go-loop []
-         (when-let [n (<! requests)]
-           (when-not @completed
-             (<! (pipeline n))
-             (recur))))
-       (reify Subscription
-         (^void request [_ ^long n]
-           (when-not @completed
-             (async/put! requests n)))
-         (^void cancel [_]
-           (atomic/set! completed true)
-           (when close (async/close! source))
-           (async/close! requests)))))))
+         pipeline (fn [n]
+                    (go-loop [n n]
+                      (when (and (pos? n) (not @completed))
+                        (if-let [value (<! source)]
+                          (do
+                            (.onNext subscriber value)
+                            (recur (dec n)))
+                          (do
+                            (.onComplete subscriber)
+                            (async/close! requests)
+                            (when close (async/close! source))
+                            (atomic/compare-and-set! completed false true))))))]
+     (go-loop []
+       (when-let [n (<! requests)]
+         (when-not @completed
+           (<! (pipeline n))
+           (recur))))
+     (reify Subscription
+       (^void request [_ ^long n]
+         (when-not @completed
+           (async/put! requests n)))
+       (^void cancel [_]
+         (atomic/set! completed true)
+         (when close (async/close! source))
+         (async/close! requests))))))

 (defn- promise->subscription
   "Coerce a promise instance to an instance
@@ -162,7 +154,7 @@

 (defn- promise->publisher
   "Create a publisher with promise as source."
-  [source xform]
+  [source]
   (reify Publisher
     (^void subscribe [_ ^Subscriber subscriber]
       (let [subscription (promise->subscription subscriber source)]
@@ -170,6 +162,23 @@

 (defn- channel->publisher
   "Create a publisher with core.async channel as source."
+  [source]
+  (reify
+    Seqable
+    (seq [p]
+      (publisher->seq p))
+
+    IPullStream
+    (pull [p]
+      (p/promise #(subscribe-once p %)))
+
+    Publisher
+    (^void subscribe [_ ^Subscriber subscriber]
+      (let [subscription (chan->subscription subscriber source)]
+        (.onSubscribe subscriber subscription)))))
+
+(defn- publisher->publisher
+  "Create a publisher from an other publisher."
   [source xform]
   (reify
     Seqable
@@ -182,30 +191,14 @@

     Publisher
     (^void subscribe [_ ^Subscriber subscriber]
-      (let [subscription (chan->subscription subscriber source xform)]
-        (.onSubscribe subscriber subscription)))))
-
-(defn- publisher->publisher
-  "Create a publisher from an other publisher."
-  [source xform]
-  (reify Publisher
-    Seqable
-    (seq [p]
-      (publisher->seq p))
-
-    IPullStream
-    (pull [p]
-      (p/promise #(subscribe-once p %)))
-
-    (^void subscribe [_ ^Subscriber subscriber]
       (let [subscriber (proxy-subscriber source xform subscriber)]
         (.subscribe source subscriber)))))

 (defn- iterable->publisher
   "Create a publisher with iterable as source."
-  [source xform]
-  (let [source' (async/chan)
-        _       (async/onto-chan source' (seq source))]
+  [source]
+  (let [source' (async/chan)]
+    (async/onto-chan source' (seq source))
     (reify
       IPullStream
       (pull [p]
@@ -217,32 +210,32 @@

       Publisher
       (^void subscribe [_ ^Subscriber subscriber]
-        (let [subscription (chan->subscription subscriber source' xform)]
+        (let [subscription (chan->subscription subscriber source')]
           (.onSubscribe subscriber subscription))))))

 (defn- stream->publisher
   "Create a publisher with manifold stream as source."
-  [source xform]
-  (reify
-    IPullStream
-    (pull [p]
-      (p/promise #(subscribe-once p %)))
-
-    Seqable
-    (seq [p]
-      (publisher->seq p))
-
-    Publisher
-    (^void subscribe [_ ^Subscriber subscriber]
-      (let [source' (async/chan)
-            subscription (chan->subscription subscriber source' xform true)]
-        (ms/connect source source')
-        (.onSubscribe subscriber subscription)))))
+  [source]
+  (let [source' (async/chan)]
+    (ms/connect source source')
+    (reify
+      IPullStream
+      (pull [p]
+        (p/promise #(subscribe-once p %)))
+
+      Seqable
+      (seq [p]
+        (publisher->seq p))
+
+      Publisher
+      (^void subscribe [_ ^Subscriber subscriber]
+        (let [subscription (chan->subscription subscriber source')]
+          (.onSubscribe subscriber subscription))))))

 (defn- empty->publisher
   "Creates an empty publisher that implements the
   push stream protocol."
-  [bufflen xform]
+  [bufflen]
   (let [source (async/chan bufflen)]
     (reify
       IPushStream
@@ -266,29 +259,34 @@

       Publisher
       (^void subscribe [_ ^Subscriber subscriber]
-        (let [subscription (chan->subscription subscriber source xform)]
+        (let [subscription (chan->subscription subscriber source)]
           (.onSubscribe subscriber subscription))))))

 (extend-protocol IPublisher
   nil
   (publisher* [source xform]
+    (assert (nil? xform) "not supported operation.")
     (empty->publisher source xform))

   java.lang.Long
   (publisher* [source xform]
-    (empty->publisher source xform))
+    (assert (nil? xform) "not supported operation.")
+    (empty->publisher source))

   java.lang.Iterable
   (publisher* [source xform]
-    (iterable->publisher source xform))
+    (assert (nil? xform) "not supported operation.")
+    (iterable->publisher source))

   manifold.stream.default.Stream
   (publisher* [source xform]
-    (stream->publisher source xform))
+    (assert (nil? xform) "not supported operation.")
+    (stream->publisher source))

   clojure.core.async.impl.channels.ManyToManyChannel
   (publisher* [source xform]
-    (channel->publisher source xform))
+    (assert (nil? xform) "not supported operation.")
+    (channel->publisher source))

   manifold.deferred.IDeferred
   (publisher* [source xform]
@@ -300,7 +298,8 @@

   futura.promise.Promise
   (publisher* [source xform]
-    (promise->publisher source xform))
+    (assert (nil? xform) "not supported operation.")
+    (promise->publisher source))

   Publisher
   (publisher* [source xform]


Added deterioration level to walls.

Added deterioration level to walls.

--- src/cljs/wombats_web_client/components/arena.cljs
+++ src/cljs/wombats_web_client/components/arena.cljs
@@ -46,20 +46,36 @@
                   "images/smoke.png"
                   x y width height)

+      :explosion
+      (draw-image canvas-element
+                  "images/explosion.png"
+                  x y width height)
+
       (js/console.log type))))

 (defn- draw-wood-barrier
   [canvas-element contents meta x y width height]
-  (let [{hp :hp} contents]
-    (draw-image canvas-element
-                "images/wood-barrier/woodwall_1.png"
+  (let [{deterioration-level :deterioration-level} contents]
+    (draw-image canvas-element
+                (str "images/wood-barrier/woodwall_"
+                     (case deterioration-level
+                       :high "3"
+                       :medium "2"
+                       "1")
+                     ".png")
                 x y width height)))

 (defn- draw-steel-barrier
   [canvas-element contents meta x y width height]
-  (draw-image canvas-element
-              "images/steel-barrier/wall.png"
-              x y width height))
+  (let [{deterioration-level :deterioration-level} contents]
+    (draw-image canvas-element
+                (str "images/steel-barrier/wall"
+                     (case deterioration-level
+                       :high "3"
+                       :medium "2"
+                       "")
+                     ".png")
+                x y width height)))

 (defn- draw-food
   [canvas-element contents meta x y width height]
@@ -104,10 +120,7 @@
         :shot
         (draw-image canvas-element
                     (str "images/zakano/zakano_" direction "_fire.png")
-                    x
-                    y
-                    width
-                    height)
+                    x y width height)

         :explosion
         (draw-image canvas-element


Remove unnecessary latency removal function

--- test/beehive/service_test.clj
+++ test/beehive/service_test.clj
@@ -92,17 +92,6 @@
       (is (= :rejected (:status f)))
       (.countDown latch))))

-(defn remove-latency [^Map snapshot]
-  (doto snapshot
-    (.remove "latency-max")
-    (.remove "latency-mean")
-    (.remove "latency-50")
-    (.remove "latency-90")
-    (.remove "latency-99")
-    (.remove "latency-99.9")
-    (.remove "latency-99.99")
-    (.remove "latency-99.999")))
-
 (deftest metrics-test
   (testing "Testing that metrics are updated with result of action"
     (let [metrics-service (beehive/service "test" 1 100)
@@ -146,7 +135,7 @@
               "total-successes" 1
               "total-timeouts" 1
               "total-total" 3}
-             (-> metrics-service :metrics :snapshot remove-latency)))))
+             (-> metrics-service :metrics :snapshot)))))
   (testing "Testing that rejection reasons are updated"
     (let [metrics-service (beehive/service "test" 1 1)
           latch (CountDownLatch. 1)]


bump version

bump version

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.58.10"
+(defproject cook "1.58.11-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.10.3"]


Add a bunch of documentation for the tests

--- test/icecap/e2e/http_test.clj
+++ test/icecap/e2e/http_test.clj
@@ -6,10 +6,22 @@
             [manifold.deferred :refer [let-flow]]
             [taoensso.timbre :refer [info spy]]))

-(def http-server)
-(def recvd-reqs)
+(def http-server
+  "A test HTTP server, serving requests.
+
+  This var gets assigned in a test fixture, so that we can clean up
+  when the test is over.")
+
+(def recvd-reqs
+  "The requests received by the test HTTP server.
+
+  This var gets reset in an :each test fixture, so that we can clean
+  up between tests.")

 (defn handler
+  "The implementation of the test HTTP server.
+
+  Keeps track of all requests, and always returns a simple 200 OK."
   [req]
   (swap! recvd-reqs conj req)
   {:status 200
@@ -17,12 +29,15 @@
    :body "xyzzy"})

 (def http-server-port
+  "The port the test HTTP server will listen on."
   8378) ;; 8378 => TEST

 (def http-server-base-url
+  "The base URL of the test HTTP server."
   (str "http://localhost:" http-server-port))

 (defn ^:private http-server-fixture
+  "A fixture that listens on `http-server-port` and cleans up afterwards."
   [f]
   (let [server (http/start-server handler {:port http-server-port})]
     (with-redefs [http-server server]
@@ -30,6 +45,7 @@
            (finally (.close http-server))))))

 (defn ^:private store-reqs-fixture
+  "A fixture that resets the request store."
   [f]
   (with-redefs [recvd-reqs (atom [])]
     (f)))


Bug: namespaces scanned on every request

Move the call to namespace-middleware out of the compojure/context macro, to prevent it from executing on each request

--- src/io/aviso/rook.clj
+++ src/io/aviso/rook.clj
@@ -228,9 +228,8 @@
   ([namespace]
    (namespace-middleware rook-handler namespace))
   ([path namespace & handlers]
-   (compojure/context path []
-                      (namespace-middleware
-                        (if (empty? handlers)
-                          rook-handler
-                          (apply compojure/routes (concat handlers [rook-handler])))
-                        namespace))))+   (let [handler (if (empty? handlers)
+                   rook-handler
+                   (apply compojure/routes (concat handlers [rook-handler])))
+         handler' (namespace-middleware handler namespace)]
+     (compojure/context path [] handler'))))


updated to remove println

updated to remove println

--- src/hivewing_core/worker.clj
+++ src/hivewing_core/worker.clj
@@ -20,7 +20,6 @@
         per-page (if (> (:per-page params) 100) 100 (:per-page params))
         page     (:page params)
         ]
-    (println per-page hive-uuid page)
     (jdbc/query sql-db [
                         (str "SELECT "
                              "uuid, created_at, updated_at "


Use manually set uuid for Atom id

Use manually set uuid for Atom id

I don't think there is a easy way to have real UUIDs for posts other
than manually setting them. Permlink might change etc.

--- src/io/perun/atom.clj
+++ src/io/perun/atom.clj
@@ -28,10 +28,9 @@
                       reverse
                       first)]
        [:id base-url]
-       (for [{:keys [permalink canonical-url content name author author-email] :as post} (take 10 posts)]
-         ; FIXME: permalink is required
+       (for [{:keys [uuid canonical-url content name author author-email] :as post} (take 10 posts)]
          [:entry
-          [:id permalink]
+          [:id (str "urn:uuid:" uuid)]
           [:title name]
           (if canonical-url
             [:link {:href canonical-url}])