parallelize bccwj importer and fixed title handling

--- src/corpus_utils/bccwj.clj
+++ src/corpus_utils/bccwj.clj
@@ -8,6 +8,7 @@
     [clojure.core.reducers :as r]
     ;;[org.httpkit.client :as http]
     [net.cgrand.xforms :as x]
+    [parallel.xf :as xf]
     [clojure.spec.alpha :as s]
     [corpus-utils.ndc :as ndc]
     [corpus-utils.c-code :refer [c-code]]
@@ -147,14 +148,14 @@
                       xml/parse
                       (walk-and-emit p-tags))]
     (into []
-          (comp (map #(hash-map                             ; Remove nils/empty strings from :tags and :sentences.
-                        :paragraph/tags (into #{} (filter identity) (:tags %))
-                        :paragraph/sentences (into [] (remove empty?) (:paragraph/sentences %))))
+          (comp (map (fn [doc]                              ; Remove nils/empty strings from :tags and :sentences.
+                       {:paragraph/tags      (into #{} (filter identity) (:paragraph/tags doc))
+                        :paragraph/sentences (into [] (remove empty?) (:paragraph/sentences doc))}))
                 (remove #(empty? (:paragraph/sentences %)))) ; Remove paragraphs with no sentences.
           document)))

 (s/fdef parse-document
-  :args (s/cat :stream #(instance? InputStream %) :corpus string?)
+  :args (s/cat :stream any? #_#(instance? InputStream %) :corpus string?)
   :ret :document/paragraphs)

 ;; ## Metadata
@@ -220,7 +221,9 @@
                  [basename _ title subtitle _ _ publisher year isbn _
                   genre-1 genre-2 genre-3 genre-4 _ _
                   author author-year author-gender corpus-name]]
-              (let [metadata-patch? (if-let [v (get ndc-metadata basename)] v false)
+              (let [title (string/trim title)
+                    subtitle (string/trim subtitle)
+                    metadata-patch? (if-let [v (get ndc-metadata basename)] v false)
                     [genre-1 genre-2 genre-3 genre-4] (if metadata-patch? metadata-patch? [genre-1 genre-2 genre-3 genre-4])
                     category (->> (condp re-seq corpus-name
                                     #"(L|O|P)B" (->> [genre-1 genre-2]
@@ -252,11 +255,12 @@
                                   (r/reduce (fn             ;; Remove repeated categories.
                                               ([] [])
                                               ([a b] (if (= (peek a) b) a (conj a b)))))
-                                  (concat [(name-map corpus-name)])
-                                  (into []))]
+                                  (into [(name-map corpus-name)]))]
                 (assoc m basename
                          #:metadata{:permission  true
-                                    :title       (str title (if-not (= "" (string/trim subtitle)) ": " subtitle))
+                                    :title       (str title (if-not (empty? subtitle)
+                                                              (str ": " subtitle)
+                                                              ""))
                                     :author      author
                                     :gender      (let [authors (string/split author-gender #"/")]
                                                    (if (every? #(= (first authors) %) authors)
@@ -351,14 +355,19 @@
                                   (if (= ".zip" (fs/extension file))
                                     (fs/file root file))))
                               (:corpus-dir options)))]
-    (mapcat
-      (partial utils/walk-zip-file
-               (fn [basename text]
-                 (if-let [meta (get metadata basename)]
-                   #:document{:metadata   meta
-                              :paragraphs (parse-document text (:metadata/subcorpus meta))}
-                   (throw (ex-info "Missing metadata for BCCWJ basename" {:basename basename})))))
-      corpus-zips)))
+    (sequence (comp (mapcat utils/zipfile-cached-files)
+                    (xf/pmap (fn [cf]
+                               (let [basename (-> cf (fs/base-name true) (fs/base-name true) (string/replace #"-.+$" ""))
+                                     cache-dir-path (fs/parent cf)]
+                                 (if-let [doc (utils/get-processed-file cache-dir-path basename)]
+                                   doc
+                                   (let [meta (get metadata basename)
+                                         doc #:document{:metadata   meta
+                                                        :paragraphs (parse-document (utils/zstd-input-stream cf)
+                                                                                (:metadata/subcorpus meta))}]
+                                     (future (utils/cache-processed-file! cache-dir-path basename doc))
+                                     doc))))))
+              corpus-zips)))

 (s/fdef document-seq
   :args (s/cat :options (s/keys :req-un [::corpus-dir string? ::metadata-dir string?]))


Slider - fixed stack overflow when resizing

--- flatguiwidgets/src/flatgui/widgets/slider.clj
+++ flatguiwidgets/src/flatgui/widgets/slider.clj
@@ -72,7 +72,9 @@
   flatgui.widgets.component/component)

 (fg/defevolverfn slider-position-evolver :position
-  (if (keyboard/key-event? component)
+  (cond
+
+    (keyboard/key-event? component)
     (let [ticksize (get-property component [:this] :ticksize)
           key (keyboard/get-key component)]
       (condp = key
@@ -83,13 +85,18 @@
          KeyEvent/VK_HOME 0.0
          KeyEvent/VK_END 1.0
         old-position))
+
+    (= (fg/get-reason) [:this :base :handle])
     (let [orientation (get-property component [:this] :orientation)
           bar-width (get-property component [:this] :bar-width)
           clip-size (get-property component [:this] :clip-size)
           handlepm (get-property component [:this :base :handle] :position-matrix)
           handlecoord (if (= :horizontal orientation) (m/mx-x handlepm) (m/mx-y handlepm))
           handlespace (- (if (= :horizontal orientation) (m/x clip-size) (m/y clip-size)) bar-width)]
-      (/ handlecoord handlespace))))
+      (/ handlecoord handlespace))
+
+    :else
+    old-position))

 ;;
 ;; TODO Invert position for vertical slider


avoid mouse

avoid mouse

--- src/critter_cljs/core.cljs
+++ src/critter_cljs/core.cljs
@@ -68,18 +68,16 @@
             diff        (polar->cartesian velocity)]
         (subtract-point with-v diff)))

-(defn critter-collision? [c1 c2]
+(defn near-points? [c1 c2 radius]
     (let [  diff            (abs-point (subtract-point c1 c2))
-            space           {:x 40 :y 40}
+            space           {:x radius :y radius}
             {:keys [x y]}   (gt-point space diff)]
         (and (not= c1 c2) (and x y))))

 (defn exclude [x xs] (filter #(not= % x) xs))

 (defn rule-to-center [c cs]
-    (let [  other-critters  (exclude c cs)
-            other-center    (center-of-points other-critters)]
-        (move-towards 5 c other-center)))
+   (move-towards 5 c (center-of-points cs)))

 (defn rule-avoid-walls [c width height]
     (let [  {:keys [x y]}   c]
@@ -90,7 +88,7 @@
                 :else c)))

 (defn rule-avoid-collisions [c cs]
-    (let [  collisions      (filter #(critter-collision? % c) cs)
+    (let [  collisions      (filter #(near-points? c % 20) cs)
             collision-area  (center-of-points collisions)
             no-collision?   (empty? collisions)]
         (cond
@@ -98,21 +96,25 @@
             :else   (move-towards -10 c collision-area))))

 (defn rule-match-velocity [c cs]
-    (let [  other-critters  (exclude c cs)
-            avg-velocity    (average-velocity other-critters)
+    (let [  avg-velocity    (average-velocity cs)
             r               (:r avg-velocity)
-            velocity        (assoc avg-velocity :r (/ r 4))
+            velocity        (assoc avg-velocity :r (/ r 2))
             with-v          (assoc c :velocity velocity)
             diff            (polar->cartesian velocity)]
         (subtract-point with-v diff)))

+(defn rule-avoid-mouse [c mouse]
+    (let [ near-mouse?  (near-points? c mouse 100)]
+        (cond near-mouse? (move-towards -50 c mouse) :else c)))
+
 (defn critter-destination [c state]
-    (let [  cs  (:critters state)]
+    (let [  other-critters  (exclude c (:critters state))]
         (-> c
-            (rule-to-center cs)
+            (rule-to-center other-critters)
             (rule-avoid-walls (:width state) (:height state))
-            (rule-avoid-collisions cs)
-            (rule-match-velocity cs)
+            (rule-avoid-collisions other-critters)
+            (rule-match-velocity other-critters)
+            (rule-avoid-mouse (:mouse state))
             )))

@@ -131,24 +133,32 @@

 (defn translate [x y] (str "translate(" x "px," y "px)"))
-(defn wrap-map [f xs]
-    (map-indexed (fn [idx it] [:g {:key idx} [f it]]) xs))
+(defn wrap-map [f xs & args]
+    (map-indexed (fn [idx it] [:g {:key idx} [apply f it args]]) xs))
+
+(defn on-mouse-move [e]
+    (let [  x   (.-clientX e)
+            y   (.-clientY e)]
+        ; (println x y)
+        (swap! app-state assoc :mouse { :x x :y y})))

-(defn module-critter [critter]
+(defn module-critter [critter width height]
     (let [{:keys [x y]} critter]
         [:g.module-critter
             {:style {:transition "transform 500ms"
                      :transform (translate x y)}}
-            [:circle {:r 20 :style {:fill "brown"}}]]))
+            [:circle {:r 5 :style {:fill "brown"}}]]))

 (defn module-critter-pen []
     (let [{:keys [width height critters]} @app-state]
         [:svg.module-critter-pen
-            {:width width :height height}
+            {:width width
+             :height height
+             :on-mouse-move on-mouse-move}
             [:rect {:width width :height height
                 :style {:fill "gray"}}]
-            [:g.critters (wrap-map module-critter critters)]]))
+            [:g.critters (wrap-map module-critter critters width height)]]))

 (defn module-app-root []
     [:section.module-app-root


more TODO

more TODO

--- test/com/billpiel/mem_tracer/core_test.clj
+++ test/com/billpiel/mem_tracer/core_test.clj
@@ -553,20 +553,22 @@

 (comment "
 TODO
-- tree query sibliings
+x tree query sibliings
+- save recordings
+- save/load workspaces
+- preserve arglists and other meta in core fns
+  - use defn and docstring in core
+- optional print func log before and after children
+- bisect recording trees to find bugs
+- trace individual fns
+- deep trace (inside fn)
 - query syntax??
-- nice query result printing
-- diff entries
-- save/load workspaces
-- save recordings
 - wrap args that are funcs
  - and deep search values for funcs?
 - wrap returns that are funcs
  - and deep search values for funcs?
 - re-exec traces
-- deep trace (inside fn)
-- bisect recording trees to find bugs
+- diff entries
 - search fn syntax for dynamic vars to capture
-- use defn and docstring in core
 - tag vals w meta data and track?
 ")


Github avatars for followers in org settings

--- frontend/components/org_settings.cljs
+++ frontend/components/org_settings.cljs
@@ -104,9 +104,7 @@
                          "fail"
                          "success")}

-               [:img.gravatar {:src (gh-utils/gravatar-url {:size 45 :login login
-                                                            :github-id (:github_id user)
-                                                            :gravatar_id (:gravatar_id user)})}]
+               [:img.gravatar {:src (str (:avatar_url user) "&s=45")}]
                [:div.om-org-user-projects-container
                 [:h4
                  (if (seq followed-projects)
@@ -148,8 +146,7 @@
            [:span.follower-container
             {:style {:display "inline-block"}}
             [:img.gravatar
-             {:src (gh-utils/gravatar-url {:size 30 :login (:login follower)
-                                           :gravatar_id (:gravatar_id follower)})}]
+             {:src (str (:avatar_url follower) "&s=30")}]
             " "
             [:span (:login follower)]])]]))))


update docs

update docs

--- kafka-clj/src/kafka_clj/consumer/consumer.clj
+++ kafka-clj/src/kafka_clj/consumer/consumer.clj
@@ -12,9 +12,25 @@
     [kafka_clj.fetch Message FetchError]
     [io.netty.buffer Unpooled]))

+;;; This namespace requires a running redis and kafka cluster
+;;;;;;;;;;;;;;;;;; USAGE ;;;;;;;;;;;;;;;
+;(use 'kafka-clj.consumer.consumer :reload)
+;(def consumer (consumer-start {:redis-conf {:host "localhost" :max-active 5 :timeout 1000} :working-queue "working" :complete-queue "complete" :work-queue "work" :conf {}}))
+;
+;
+;
+;(publish-work consumer {:producer {:host "localhost" :port 9092} :topic "ping" :partition 0 :offset 0 :len 10})
+;
+;
+;(def res (do-work-unit! consumer))
+;
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(def byte_array_class (Class/forName "[B"))
-(defn byte-array? [arr] (instance? byte_array_class arr))
+
+
+(def- byte_array_class (Class/forName "[B"))
+(defn- byte-array? [arr] (instance? byte_array_class arr))

 (defn read-fetch-message
   "read-fetch will return the result of fn which is [resp-vec error-vec]"
@@ -122,8 +138,9 @@
     :work-queue = the queue name from which work units will be taken, the data must be a map with keys :producer :topic :partition :offset :len
     :working-queue = when a work item is taken from the work-queue its placed on the working-queue
     :complete-queue = when an item has been processed the result is placed on the complete-queue
-    :conf = any configuration that will be passed when creating producers"
-
+    :conf = any configuration that will be passed when creating producers
+   Returns the state map with the :status and :producers updated
+  "
   [{:keys [redis-conn producers work-queue working-queue complete-queue conf] :as state}]
   (try
 	  (let [{:keys [producer topic partition offset len] :as work-unit} (wait-on-work-unit! redis-conn work-queue working-queue)
@@ -140,10 +157,22 @@
    (catch Throwable t (assoc state :status :fail :throwable t))))

-(defn publish-work [{:keys [redis-conn work-queue]} work-unit]
+(defn publish-work
+  "Publish a work-unit to the working queue for a consumer connection"
+  [{:keys [redis-conn work-queue]} work-unit]
   {:pre [(and (:producer work-unit) (:topic work-unit) (:partition work-unit) (:offset work-unit) (:len work-unit)
            (let [{:keys [host port]} (:producer work-unit)] (and host port)))]}
   (car/wcar redis-conn
     (car/lpush work-queue work-unit)))
+
+
+(comment
+
+(use 'kafka-clj.consumer.consumer :reload)
+(def consumer (consumer-start {:redis-conf {:host "localhost" :max-active 5 :timeout 1000} :working-queue "working" :complete-queue "complete" :work-queue "work" :conf {}}))
+(publish-work consumer {:producer {:host "localhost" :port 9092} :topic "ping" :partition 0 :offset 0 :len 10})
+(def res (do-work-unit! consumer))
+
+)


New test: test-new-file-negative

New test: test-new-file-negative

--- test/clj_fileutils/fileutils_test.clj
+++ test/clj_fileutils/fileutils_test.clj
@@ -108,3 +108,11 @@
             "abc/def"         (.toString (new-file "abc" "def"))
             "abc/abc.def"     (.toString (new-file "abc" "abc.def")))))

+(deftest test-new-file-negative
+    "Check the function clj-fileutils.fileutils/new-file."
+    (testing "Check the function clj-fileutils.fileutils/new-file."
+        (is (thrown? NullPointerException (new-file nil)))
+        (is (thrown? NullPointerException (new-file "" nil)))
+        (is (thrown? NullPointerException (new-file "abc" nil)))
+        (is (thrown? NullPointerException (new-file nil nil)))))
+


New test: test-new-file-2

New test: test-new-file-2

--- test/clj_fileutils/fileutils_test.clj
+++ test/clj_fileutils/fileutils_test.clj
@@ -81,3 +81,13 @@
             "abc/def"     (.toString (new-file "abc/def"))
             "abc/def/xyz" (.toString (new-file "abc/def/xyz")))))

+(deftest test-new-file-2
+    "Check the function clj-fileutils.fileutils/new-file."
+    (testing "Check the function clj-fileutils.fileutils/new-file."
+        (are [x y] (= x y)
+            "/"           (.toString (new-file "" ""))
+            "abc"         (.toString (new-file "abc" ""))
+            "abc.def"     (.toString (new-file "abc.def" ""))
+            "abc/def"     (.toString (new-file "abc/def" ""))
+            "abc/def/xyz" (.toString (new-file "abc/def/xyz" "")))))
+


Fix test.

Fix test.

--- test/onyx/metrics/throughput_test.clj
+++ test/onyx/metrics/throughput_test.clj
@@ -3,8 +3,8 @@
             [midje.sweet :refer :all]
             [onyx.peer.task-lifecycle-extensions :as l-ext]
             [onyx.plugin.core-async :refer [take-segments!]]
-            [onyx.metrics.throughput]
-            [onyx.metrics.timbre]
+            [onyx.lifecycle.metrics.throughput]
+            [onyx.lifecycle.metrics.timbre]
             [onyx.api]))

 (def id (java.util.UUID/randomUUID))
@@ -63,17 +63,17 @@

 (def lifecycles
   [{:lifecycle/task :inc
-    :lifecycle/pre :onyx.metrics.throughput/pre
-    :lifecycle/post-batch :onyx.metrics.throughput/post-batch
-    :lifecycle/post :onyx.metrics.throughput/post
-    :onyx.metrics.throughput/retention-ms 60000
+    :lifecycle/pre :onyx.lifecycle.metrics.throughput/pre
+    :lifecycle/post-batch :onyx.lifecycle.metrics.throughput/post-batch
+    :lifecycle/post :onyx.lifecycle.metrics.throughput/post
+    :throughput/retention-ms 60000
     :lifecycle/doc "Instruments a tasks throughput metrics"}

    {:lifecycle/task :inc
-    :lifecycle/pre :onyx.metrics.timbre/pre
-    :lifecycle/post :onyx.metrics.timbre/post
-    :onyx.metrics.throughput/interval-ms 2000
-    :lifecycle/doc "Prints task metrics to Timbre every 5000 ms"}])
+    :lifecycle/pre :onyx.lifecycle.metrics.timbre/pre
+    :lifecycle/post :onyx.lifecycle.metrics.timbre/post
+    :timbre/interval-ms 2000
+    :lifecycle/doc "Prints task metrics to Timbre every 2000 ms"}])

 (def in-chan (chan (inc n-messages)))


fix armstrong reference impl

fix armstrong reference impl

--- exercises/armstrong-numbers/src/example.clj
+++ exercises/armstrong-numbers/src/example.clj
@@ -1,6 +1,9 @@
 (ns armstrong-numbers)
+
+(defn expt [base pow]
+  (reduce * 1 (repeat pow base)))

 (defn armstrong? [n]
   (let [digits (map (comp read-string str) (str n))
         l      (count digits)]
-    (== n (reduce + (map #(Math/pow % l) digits)))))
+    (= n (reduce + (map #(expt % l) digits)))))


Fix minor typos (#542)

Fix minor typos (#542)

--- sidecar/src/figwheel_sidecar/components/cljs_autobuild.clj
+++ sidecar/src/figwheel_sidecar/components/cljs_autobuild.clj
@@ -158,7 +158,7 @@
  */")

 (defn create-deadman-app-js [build-config output-to-filepath exception]
-  (println (color-text (str "Figwheel: inital compile failed - outputing temporary helper application to "
+  (println (color-text (str "Figwheel: initial compile failed - outputting temporary helper application to "
                             output-to-filepath)
                        :magenta))
   (let [data (pr-str (pr-str (extract-data-for-deadman-app build-config exception)))]


Undo is added to the task. Not the deployment

--- src/exploud/deployment.clj
+++ src/exploud/deployment.clj
@@ -200,7 +200,7 @@
       (health/wait-until-asg-healthy
        environment
        region
-       (get-in deployment [:parameters (new-asg-name-key deployment)])
+       (get-in deployment [:parameters (new-asg-name-key task)])
        (or (get-in deployment [:parameters :min]) asgard/default-minimum)
        port healthcheck deployment-id task
        task-finished task-timed-out))
@@ -212,7 +212,7 @@
   :enable-asg
   [{:keys [environment region] deployment-id :id :as deployment} task]
   (asgard/enable-asg environment region
-                     (get-in deployment [:parameters (new-asg-name-key deployment)])
+                     (get-in deployment [:parameters (new-asg-name-key task)])
                      deployment-id task task-finished task-timed-out))

 (defmethod start-task*
@@ -223,7 +223,7 @@
                      (get-in deployment
                              [:parameters :selectedLoadBalancers]))
           asg-name (get-in deployment
-                           [:parameters (new-asg-name-key deployment)])]
+                           [:parameters (new-asg-name-key task)])]
       (health/wait-until-elb-healthy environment region elb-names asg-name
                                      deployment-id task task-finished
                                      task-timed-out))
@@ -235,7 +235,7 @@
   :disable-asg
   [{:keys [environment region] deployment-id :id :as deployment} task]
   (if-let [asg (get-in deployment [:parameters
-                                   (old-asg-name-key deployment)])]
+                                   (old-asg-name-key task)])]
     (asgard/disable-asg environment region asg deployment-id task
                         task-finished task-timed-out)
     (let [task (assoc (util/append-to-task-log "No old ASG to disable" task)
@@ -246,7 +246,7 @@
   :delete-asg
   [{:keys [environment region] deployment-id :id :as deployment} task]
   (if-let [asg (get-in deployment [:parameters
-                                   (old-asg-name-key deployment)])]
+                                   (old-asg-name-key task)])]
     (asgard/delete-asg
      environment region asg deployment-id task task-finished task-timed-out)
     (let [task (assoc (util/append-to-task-log "No old ASG to delete" task)


fixed broken test

fixed broken test

--- hyrax/test/hyrax/dist/rabbit_test.clj
+++ hyrax/test/hyrax/dist/rabbit_test.clj
@@ -197,6 +197,10 @@

 (fact "start, acquire, release and stop distributor"
    (with-conn [conn rabbit-info]
+
+      (with-chan [ch conn]
+        (lq/delete ch "bucket-too.bucket"))
+
      (let [scheduler (Executors/newScheduledThreadPool 1)
            buckets (->> (range 100) (map str) (into []))
            dist (start-bucket-distributor! conn "bucket-too" buckets scheduler {})]
@@ -205,7 +209,7 @@
          (api/release-buckets! dist buckets)
          (stop-bucket-distributor! dist)
          buckets)))
-   => #{"1"})
+   => #{"0"})

 (comment
   "stuff I used for manual testing"


Update to latest ClojureScript

Update to latest ClojureScript


RR|OO: bind dataview events externally

RR|OO: bind dataview events externally

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -104,7 +104,7 @@
        :rowHeight 40
        :syncColumnCellResize true})

-(defn bind-external-slick-grid-event-handlers
+(defn bind-external-sg-grid-event-handlers
   [grid event-handlers]
   (doall
    (for [[handler-key handler-function] event-handlers
@@ -112,14 +112,22 @@
                event (aget grid handler-name)]]
      (.subscribe event handler-function))))

-(defn sg-init [data form is-filtered-dataview?
-               & {:keys [page-count]}]
+(defn bind-external-sg-grid-dataview-handlers
+  [dataview event-handlers]
+  (doall
+    (for [[handler-key handler-function] event-handlers
+          :let [handler-name (hyphen->camel-case (name handler-key))
+                event (aget dataview handler-name)]]
+      (.subscribe event handler-function))))
+
+(defn sg-init
   "Creates a Slick.Grid backed by Slick.Data.DataView from data and fields.
    Most events are handled by slickgrid. On double-click, event is put on chan.
    Returns [grid dataview]."
-  [data form is-filtered-dataview? external-event-handlers]
+  [data form is-filtered-dataview? {:keys [grid-event-handlers
+                                           dataview-event-handlers]}]
   (let [columns (flat-form->sg-columns
-                 form true nil :is-filtered-dataview? is-filtered-dataview?)
+                  form true nil :is-filtered-dataview? is-filtered-dataview?)
         SlickGrid (.. js/Slick -Grid)
         DataView (.. js/Slick -Data -DataView)
         dataview (DataView.)
@@ -127,7 +135,9 @@
         {{{:keys [num-displayed-records total-page-count]} :paging} :table-page}
         @shared/app-state]
     ;; dataview / grid hookup
-    (bind-external-slick-grid-event-handlers grid external-event-handlers)
+    (bind-external-sg-grid-event-handlers grid grid-event-handlers)
+    (bind-external-sg-grid-dataview-handlers dataview dataview-event-handlers)
+
     (.subscribe (.-onRowCountChanged dataview)
                 (fn [e args]
                   (.updateRowCount grid)
@@ -151,11 +161,6 @@
                   (let [rank (aget (.getItem dataview (aget args "row"))
                                    _rank)]
                     (put! shared/event-chan {:submission-to-rank rank}))))
-    (.subscribe (.-onRowsChanged dataview)
-                (fn [e args]
-                  (put! shared/event-chan
-                        {:page
-                         (inc (aget (.getPagingInfo dataview) "pageNum"))})))

     ;; page, filter, and data set-up on the dataview
     (init-sg-pager grid dataview :page-count total-page-count)


Redirect output to lein

Redirect output to lein

--- src/leiningen/postgres.clj
+++ src/leiningen/postgres.clj
@@ -1,7 +1,8 @@
 (ns leiningen.postgres
   (:require [leiningen.core.main :as main])
   (:import [com.opentable.db.postgres.embedded EmbeddedPostgres]
-           [java.io File]))
+           [java.io File]
+           (java.lang ProcessBuilder$Redirect)))

 (defn- config-value
   "Get a value from project config or, optionally, use a default value."
@@ -32,10 +33,14 @@
                      (.setCleanDataDirectory clean-data-directory?)

                      data-directory
-                     (.setDataDirectory (File. data-directory))
+                     (.setDataDirectory (File. ^String data-directory))

                      server-config
-                     (apply-server-config server-config)))]
+                     (apply-server-config server-config)
+
+                     :always (doto
+                               (.setErrorRedirector ProcessBuilder$Redirect/INHERIT)
+                               (.setOutputRedirector ProcessBuilder$Redirect/INHERIT))))]
     (let [conn (.getConnection (.getPostgresDatabase db))
           statement (.createStatement conn)]
       (doseq [database databases]


Create an obi config file after copying the obi project

--- src/mdr2/abacus/import.clj
+++ src/mdr2/abacus/import.clj
@@ -13,6 +13,7 @@
             [environ.core :refer [env]]
             [mdr2.production :as prod]
             [mdr2.dtbook :as dtbook]
+            [mdr2.obi :as obi]
             [mdr2.production.path :as path]
             [immutant.transactions.jdbc :refer [factory]]))

@@ -202,6 +203,11 @@
         :append true)
   production)

+(defn create-obi-config-file! [production]
+  (let [config-file-name (io/file (path/recording-path production) "obiconfig.xml")]
+    (spit config-file-name (obi/config production))
+    production))
+
 (defn create-recording-productions-with-obi!
   "Create all productions with state \"recording\" with wav files that
   contain an obi project. Add to the db and create the directories.
@@ -212,9 +218,8 @@
     (-> p
         prod/create!
         prod/set-state-structured!
-        copy-obi-project!))
-    (comment
-      (create-obi-config-file!)))
+        copy-obi-project!
+        create-obi-config-file!)))

 (defn copy-sigtuna-project! [production]
   ;; FIXME: do we actually copy theses projects or do we do this manually?


Cosmetic changes to the report

Cosmetic changes to the report

--- src/mdr2/abacus/import.clj
+++ src/mdr2/abacus/import.clj
@@ -22,7 +22,7 @@
 (def ^:private archive-db {:factory factory :name "java:jboss/datasources/archive"})

 (def abacus-csv "/home/eglic/src/mdr2/samples/ABACUS_export_Books_27032015.csv")
-(def file-dump "/home/eglic/src/mdr2/samples/miloun_files.txt")
+(def file-dump "/home/eglic/src/mdr2/samples/miloun_files2.txt")
 (def move-script "/home/eglic/src/mdr2/samples/move-productions.sh")
 (def old-production-root "/path/to/old/productions")

@@ -256,72 +256,78 @@
 (defn print-stats
   "Print a summary of all the productions that are about to be migrated"
   []
-  (println "Migrating productions from old to new Madras")
-  (println "============================================")
-  (println)
-  (println "Importing from ABACUS")
-  (println "~~~~~~~~~~~~~~~~~~~~~")
-  (println)
-  (println "Ready:" (count (filter ready? all-productions)))
-  (println "------")
+  (println "# Migrating productions from old to new Madras")
+  (println)
+  (println "## Importing from ABACUS")
+  (println)
+  (println "### Ready:" (count (filter ready? all-productions)))
+  (println)
   (println (string/join ", " (sort (map :id (filter ready? all-productions)))))
   (println)
-  (println "Archived:" (count (filter archived? all-productions)))
-  (println "---------")
-  (println)
-  (println "Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) all-productions)))
-  (println "----------------------------------------")
+  (println "### Archived:" (count (filter archived? all-productions)))
+  (println)
+  (println "### Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) all-productions)))
+  (println)
   (println (string/join ", " (sort (map :id (filter #(recording-no-wav-with-struct? %) all-productions)))))
   (println)
+  (println "### Recording with wav and an obi project:" (count (filter recording-with-obi? all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter recording-with-obi? all-productions)))))
+  (println)
+  (println "## Manual migration:")
+  (println)
+  (println "### Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? all-productions)))
+  (println)
+  (println (string/join ", " (sort (map :id (filter recording-with-wav-no-obi? all-productions)))))
+  (println)
   (let [weird (filter #(and (not-any? struct-file? (get-all-files %)) (recording-no-wav? %)) all-productions)]
-    (println "Recording with no wav and no struct.html:" (count weird))
-    (println "-----------------------------------------")
+    (println "### Recording with no wav and no struct.html:" (count weird))
+    (println)
     (println (string/join ", " (sort (map :id weird)))))
   (println)
-  (println "Recording with wav and an obi project:" (count (filter recording-with-obi? all-productions)))
-  (println "--------------------------------------")
-  (println (string/join ", " (sort (map :id (filter recording-with-obi? all-productions)))))
-  (println)
-  (println "Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? all-productions)))
-  (println "--------------------------------------")
-  (println (string/join ", " (sort (map :id (filter recording-with-wav-no-obi? all-productions)))))
-  (println)
-  (print "Ignoring the rest: ")
+  (print "### The rest: ")
   (println (dissoc (frequencies (map :state all-productions)) "archived" "recording" "ready"))
-  (println "------------------")
+  (println)
   (doseq [state ["repairing" "finishing" "recorded" "pre_ready"]]
     (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) all-productions))))))
   (println )
-  (println "Importing commercial audio books")
-  (println "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
-  (println)
-  (println "Ready:" (count (filter ready? all-commercial-productions)))
-  (println "------")
-  (println (string/join ", " (sort (map :id (filter ready? all-commercial-productions)))))
-  (println)
-  (println "Archived:" (count (filter archived? all-commercial-productions)))
-  (println "---------")
-  (println)
-  (println "Recording with no wav and a struct.html:" (count (filter #(recording-no-wav-with-struct? %) all-commercial-productions)))
-  (println "----------------------------------------")
-  (println (string/join ", " (sort (map :id (filter #(recording-no-wav-with-struct? %) all-commercial-productions)))))
-  (println)
-  (let [weird (filter #(and (recording-no-wav? %)) all-commercial-productions)]
-    (println "Recording with no wav:" (count weird))
-    (println "----------------------")
-    (println (string/join ", " (sort (map :id weird)))))
-  (println)
-  (println "Recording with wav and an obi project:" (count (filter recording-with-obi? all-commercial-productions)))
-  (println "--------------------------------------")
-  (println (string/join ", " (sort (map :id (filter recording-with-obi? all-commercial-productions)))))
-  (println)
-  (println "Recording with wav and no obi project:" (count (filter recording-with-wav-no-obi? all-commercial-productions)))
-  (println "--------------------------------------")
-  (println (string/join ", " (sort (map :id (filter recording-with-wav-no-obi? all-commercial-productions)))))
-  (println)
-  (print "Ignoring the rest: ")
+  (println "# Importing commercial audio books")
+  (println)
+  (println "## Ready:" (count (filter ready? all-commercial-productions)))
+  (println)
+  (let [ready (sort (map :id (filter ready? all-commercial-productions)))]
+    (when (seq ready)
+      (println (string/join ", " ready))
+      (println)))
+  (println "## Archived:" (count (filter archived? all-commercial-productions)))
+  (println)
+  (let [ps (filter #(recording-no-wav-with-struct? %) all-commercial-productions)]
+    (println "## Recording with no wav and a struct.html:" (count ps))
+    (println)
+    (when (seq ps)
+      (println (string/join ", " (sort (map :id ps))))
+      (println)))
+  (let [ps (filter #(and (recording-no-wav? %)) all-commercial-productions)]
+    (println "## Recording with no wav:" (count ps))
+    (println)
+    (when (seq ps)
+      (println (string/join ", " (sort (map :id ps))))
+      (println)))
+  (let [ps (filter recording-with-obi? all-commercial-productions)]
+    (println "## Recording with wav and an obi project:" (count ps))
+    (println)
+    (when (seq ps)
+      (println (string/join ", " (sort (map :id ps))))
+      (println)))
+  (let [ps (filter recording-with-wav-no-obi? all-commercial-productions)]
+    (println "## Recording with wav and no obi project:" (count ps))
+    (println)
+    (when (seq ps)
+      (println (string/join ", " (sort (map :id ps))))
+      (println)))
+  (print "## Ignoring the rest: ")
   (println (dissoc (frequencies (map :state all-commercial-productions)) "archived" "recording" "ready"))
-  (println "------------------")
+  (println)
   (doseq [state ["structuring" "wipsing"]]
     (println (str (string/capitalize state) ":") (string/join ", " (sort (map :id (filter #(= (:state %) state) all-commercial-productions))))))
   (println )


Default local load limit to infinity

Default local load limit to infinity

--- pigpen-core/src/main/clojure/pigpen/local.clj
+++ pigpen-core/src/main/clojure/pigpen/local.clj
@@ -173,7 +173,7 @@

 ;; unsubscribe doesn't seem to work with this version of rx
 ;; This caps the maximum number of records read from a file/stream
-(def ^:dynamic *max-load-records* 1000)
+(def ^:dynamic *max-load-records* nil)

 (defmethod graph->local :load
   [{:keys [location], :as command} _]
@@ -188,11 +188,11 @@
                 (println "Start reading from " location)
                 (doseq [file (locations local-loader)
                         :while (not @cancel)
-                        :while (< @read-count *max-load-records*)]
+                        :while (< @read-count (or *max-load-records* Double/POSITIVE_INFINITY))]
                   (let [reader (init-reader local-loader file)]
                     (doseq [value (read local-loader reader)
                             :while (not @cancel)
-                            :while (< @read-count *max-load-records*)]
+                            :while (< @read-count (or *max-load-records* Double/POSITIVE_INFINITY))]
                       (swap! read-count inc)
                       (.onNext o value))
                     (close-reader local-loader reader)))


Fixed map.

Fixed map.

--- src/benjals/model/team.clj
+++ src/benjals/model/team.clj
@@ -18,7 +18,6 @@

 (defn create [{players "players", :as team}]
   (let [team (dissoc team "players")]
-    (map user/create players)
-    ;(user/create (nth players 0))
+    (doall (map user/create players))
     (sql/with-connection (System/getenv "DATABASE_URL")
-      (sql/insert-values :teams [:name] (vals team)))))+      (sql/insert-values :teams (keys team) (vals team)))))


formatting and code style

formatting and code style

--- src/clj/cljs/repl/nashorn.clj
+++ src/clj/cljs/repl/nashorn.clj
@@ -35,8 +35,10 @@
     (:require [cljs.repl]
               [cljs.repl.nashorn]))

-  (cljs.repl/repl (cljs.repl.nashorn/repl-env) :output-dir "resources/public/compiled"
-                  :cache-analysis true))
+  (cljs.repl/repl (cljs.repl.nashorn/repl-env)
+    :output-dir "resources/public/compiled"
+    :cache-analysis true)
+  )

 ;;
 ;; Invoke it with:
@@ -51,9 +53,11 @@
     (:require [cljs.repl.nashorn]
               [cemerick.piggieback]))

-  (cemerick.piggieback/cljs-repl :repl-env (cljs.repl.nashorn/repl-env)
-                                 :output-dir "resources/public/compiled"
-                                 :cache-analysis true))
+  (cemerick.piggieback/cljs-repl
+    :repl-env (cljs.repl.nashorn/repl-env)
+    :output-dir "resources/public/compiled"
+    :cache-analysis true)
+  )

 ;; Implementation

@@ -79,17 +83,20 @@
 (defn init-engine [engine output-dir debug]
   (eval-resource engine "goog/base.js" debug)
   (eval-resource engine "goog/deps.js" debug)
-  (eval-str engine "var global = this")  ; required by React
-  (eval-str engine (format (str "var nashorn_load = function(path) {"
-                             "  var outputPath = \"%s\" + \"/\" + path;"
-                             (when debug "  print(\"loading: \" + outputPath) ; ")
-                             "  load(outputPath);"
-                             "};")
-                        output-dir))
-  (eval-str engine (str "goog.global.CLOSURE_IMPORT_SCRIPT = function(path) {"
-                     " nashorn_load(\"goog/\" + path);"
-                     " return true;"
-                     "};"))
+  (eval-str engine "var global = this") ; required by React
+  (eval-str engine
+    (format
+      (str "var nashorn_load = function(path) {"
+           "  var outputPath = \"%s\" + \"/\" + path;"
+           (when debug "  print(\"loading: \" + outputPath) ; ")
+           "  load(outputPath);"
+           "};")
+      output-dir))
+  (eval-str engine
+    (str "goog.global.CLOSURE_IMPORT_SCRIPT = function(path) {"
+         " nashorn_load(\"goog/\" + path);"
+         " return true;"
+         "};"))
   (eval-str engine "goog.global.isProvided_ = function(name) { return false; };")
   engine)

@@ -97,28 +104,30 @@
   (eval-str engine (format "nashorn_load(\"%s\");" file)))

 ;; Create a minimal build of Clojurescript from the core library.
-;;
-;; Copied rom clj.cljs.repl.node.
+;; Copied from clj.cljs.repl.node.
 (defn bootstrap-repl [engine output-dir opts]
   (env/ensure
-   (let [deps-file ".nashorn_repl_deps.js"
-         core (io/resource "cljs/core.cljs")
-         core-js (closure/compile core
-                                  (assoc opts :output-file (closure/src-file->target-file core)))
-         deps (closure/add-dependencies opts core-js)]
-     ;; output unoptimized code and the deps file
-     ;; for all compiled namespaces
-     (apply closure/output-unoptimized
-            (assoc opts :output-to (.getPath (io/file output-dir deps-file)))
-            deps)
-     ;; load the deps file so we can goog.require cljs.core etc.
-     (load-js-file engine deps-file))))
+    (let [deps-file ".nashorn_repl_deps.js"
+          core (io/resource "cljs/core.cljs")
+          core-js (closure/compile core
+                    (assoc opts
+                      :output-file (closure/src-file->target-file core)))
+          deps (closure/add-dependencies opts core-js)]
+      ;; output unoptimized code and the deps file
+      ;; for all compiled namespaces
+      (apply closure/output-unoptimized
+        (assoc opts :output-to (.getPath (io/file output-dir deps-file)))
+        deps)
+      ;; load the deps file so we can goog.require cljs.core etc.
+      (load-js-file engine deps-file))))

 (defn load-ns [engine ns]
-  (eval-str engine (format "goog.require(\"%s\");" (comp/munge (first ns)))))
+  (eval-str engine
+    (format "goog.require(\"%s\");" (comp/munge (first ns)))))

 (defn- stacktrace  [^Exception e]
-  (apply str (interpose "\n" (map #(str " " (.toString %)) (.getStackTrace e)))))
+  (apply str
+    (interpose "\n" (map #(str " " (.toString %)) (.getStackTrace e)))))

 (def repl-filename "<cljs repl>")

@@ -132,19 +141,19 @@
       (if output-to
         (load-js-file engine output-to)
         (bootstrap-repl engine output-dir opts))
-      (repl/evaluate-form this env repl-filename
-                          '(do
-                             (.require js/goog "cljs.core")
-                             (set! cljs.core/*print-fn* js/print)))))
-
+      (repl/evaluate-form this env repl-filename
+        '(do
+           (.require js/goog "cljs.core")
+           (set! cljs.core/*print-fn* js/print)))))
   (-evaluate [{engine :engine :as this} filename line js]
     (when debug (println "Evaluating: " js))
-    (try {:status :success
-          :value (if-let [r (eval-str engine js)] (.toString r) "")}
-         (catch Throwable e
-           {:status :exception
-            :value (.toString e)
-            :stacktrace (stacktrace e)})))
+    (try
+      {:status :success
+       :value (if-let [r (eval-str engine js)] (.toString r) "")}
+      (catch Throwable e
+        {:status :exception
+         :value (.toString e)
+         :stacktrace (stacktrace e)})))
   (-load [{engine :engine :as this} ns url]
     (load-ns engine ns))
   (-tear-down [this]))
@@ -157,12 +166,8 @@
    :output-to   load this file initially into Nashorn, relative to output-dir.
                 Use a minimal bootstrapped cljs.core environment if not specified."
   [& {debug :debug :as opts}]
-
   (let [engine (create-engine)
-        compiler-env (env/default-compiler-env)
-        env (merge (NashornEnv. engine debug)
-                   {:cljs.env/compiler compiler-env}  ; required by cider middleware ?
-                   opts)]
-    env))
-
-
+        compiler-env (env/default-compiler-env)]
+    (merge (NashornEnv. engine debug)
+      {:cljs.env/compiler compiler-env}  ; required by cider middleware ?
+      opts)))


fix News Team typo

fix News Team typo

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -307,7 +307,7 @@

    "News Team"
    {:access {:req (req (not= (first (:zone card)) :deck))
-             :msg (msg "giver the runner 2 tags or -1 agenda points")
+             :msg (msg "give the Runner 2 tags or -1 agenda points")
              :effect (effect (resolve-ability
                                {:player :runner
                                 :prompt "Take 2 tags or take News Team as -1 agenda points?"


Even more time for drip..

Even more time for drip..

--- src/clj/mokkameister/mqtt.clj
+++ src/clj/mokkameister/mqtt.clj
@@ -15,10 +15,11 @@
        (= [false false true])))

 (defn- brew-finished? [history]
-  (->> history
-       (take-last 7)
-       (mapv #(<= THRESHOLD_WATT %))
-       (= [true true false false false false false])))
+  (let [pattern (vec (concat (repeat 2 true) (repeat 7 false)))]
+    (->> history
+         (take-last (count pattern))
+         (mapv #(<= THRESHOLD_WATT %))
+         (= pattern))))

 (defn- connect! []
   (let [


sanity check

sanity check

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -1488,8 +1488,17 @@

           :ready-to-compile
           (try
-            (let [{:keys [provides] :as compiled-src}
+            (let [expected-provides
+                  (:provides src)
+
+                  {:keys [provides] :as compiled-src}
                   (generate-output-for-source state src)]
+
+              (when (not= expected-provides provides)
+                (throw (ex-info "generated output did not produce expected provides"
+                         {:expected expected-provides
+                          :provides provides
+                          :source-name source-name})))

               (swap! ready-ref set/union provides)
               compiled-src)


fix required *unchecked-if* binding

fix required *unchecked-if* binding

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -688,7 +688,8 @@
    should not touch global state"
   [{:keys [static-fns] :as state} {:keys [name input cljc] :as rc}]

-  (binding [ana/*cljs-static-fns* static-fns]
+  (binding [ana/*cljs-static-fns* static-fns
+            ana/*unchecked-if* false]
     (let [source @input]
       (with-logged-time
         [(:logger state) (format "Compile CLJS: \"%s\"" name)]


fix 2 issues

fix 2 issues

fix deps.cljs handling when :foreign-libs is a list (not a vector)
fix resource still being used while having the wrong name

while this is technically not required other tools might not handle
this properly in same cases leading to missing files.

this mostly affects file names with dashes
(eg. src/cljs/my-ns.cljs instead of my_ns.cljs)

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -264,11 +264,20 @@
     (fn [^String name]
       (str/replace name File/separatorChar \/))))

-(defn normalize-foreign-libs [{:keys [foreign-libs externs] :as deps}]
-  (if (seq externs)
-    ;; FIXME: :externs at top level
-    (update-in foreign-libs [0 :externs] #(into (or % []) externs))
-    foreign-libs))
+(defn extract-foreign-libs [{:keys [foreign-libs externs] :as deps} source-path]
+  (let [foreign-libs (cond
+                       (vector? foreign-libs)
+                       foreign-libs
+                       (map? foreign-libs)
+                       [foreign-libs]
+                       (list? foreign-libs)
+                       (into [] foreign-libs)
+                       :else
+                       (throw (ex-info (format "invalid :foreign-libs in deps.cljs of %s" source-path) {:deps deps})))]
+    (if (seq externs)
+      ;; FIXME: :externs at top level
+      (update-in foreign-libs [0 :externs] #(into (or % []) externs))
+      foreign-libs)))

 (defn should-ignore-resource?
   [{:keys [ignore-patterns] :as state} name]
@@ -331,7 +340,7 @@
       entries)))

 (defn process-deps-cljs
-  [{:keys [use-file-min] :as state} manifest]
+  [{:keys [use-file-min] :as state} manifest source-path]
   {:pre [(compiler-state? state)
          (map? manifest)]}
   (let [deps (get manifest "deps.cljs")]
@@ -339,7 +348,7 @@
       manifest
       (let [foreign-libs (-> @(:input deps)
                              (edn/read-string)
-                             (normalize-foreign-libs))]
+                             (extract-foreign-libs source-path))]

         (reduce
           (fn [result {:keys [externs provides requires] :as foreign-lib}]
@@ -396,7 +405,7 @@
                      (io/make-parents mfile)
                      (write-jar-manifest mfile manifest)
                      manifest))]
-    (-> (process-deps-cljs state manifest)
+    (-> (process-deps-cljs state manifest path)
         (vals))))

 (defn make-fs-resource [state source-path rc-name ^File rc-file]
@@ -415,23 +424,25 @@
          (seq path)]}
   (let [root (io/file path)
         root-path (.getCanonicalPath root)
-        root-len (inc (count root-path))]
-    (->> (for [^File file (file-seq root)
-               :let [file (.getCanonicalFile file)
-                     abs-path (.getCanonicalPath file)]
-               :when (and (is-cljs-resource? abs-path)
-                          (not (.isHidden file)))
-               :let [name (-> abs-path
-                              (.substring root-len)
-                              (normalize-resource-name))]
-               :when (not (should-ignore-resource? state name))]
-
-           (make-fs-resource state path name file))
-         (map (juxt :name identity))
-         (into {})
-         (process-deps-cljs state)
-         (vals)
-         )))
+        root-len (inc (count root-path))
+
+        manifest
+        (->> (for [^File file (file-seq root)
+                   :let [file (.getCanonicalFile file)
+                         abs-path (.getCanonicalPath file)]
+                   :when (and (is-cljs-resource? abs-path)
+                              (not (.isHidden file)))
+                   :let [name (-> abs-path
+                                  (.substring root-len)
+                                  (normalize-resource-name))]
+                   :when (not (should-ignore-resource? state name))]
+
+               (make-fs-resource state path name file))
+             (map (juxt :name identity))
+             (into {}))]
+
+    (-> (process-deps-cljs state manifest path)
+        (vals))))

 (defn get-resource-for-provide [state ns-sym]
   {:pre [(compiler-state? state)
@@ -874,9 +885,21 @@
            (not (or (= name expected-name)
                     (= name expected-cljc)
                     ))))
-    (do (log-warning logger (format "ns did not match file-path: %s -> \"%s\" (via \"%s\")" (:ns src) name url))
+
+    (do (log-warning logger (format "NS \"%s\" did not match expected file-path, expected A got B%nURL: %s%nA: %s%nB: %s"
+                              (:ns src)
+                              url
+                              (str (ns->cljs-file (:ns src)) " (or .cljc)")
+                              name
+                              ))
         ;; still want to remember the resource so it doesn't get detected as new all the time
-        (assoc-in state [:sources name] src))
+        ;; remove all provides, otherwise it might end up being used despite the invalid name
+        ;; enforce this behavior since the warning might get overlooked easily
+        (let [invalid-src (assoc src
+                            :provides #{}
+                            :requires #{}
+                            :require-order [])]
+          (assoc-in state [:sources name] invalid-src)))

     ;; do not merge files that are already present from a different source path
     (let [existing (get-in state [:sources name])]


select period in budget edit

select period in budget edit

--- src/clj_money/web/budgets.clj
+++ src/clj_money/web/budgets.clj
@@ -73,7 +73,8 @@
   (html
     (text-input-field budget :name {:autofocus true})
     (select-field budget :period (map #(vector :option
-                                               {:value %}
+                                               {:value %
+                                                :selected (= (:period budget) %)}
                                                (humanize %))
                                       [:week :month :quarter]))
     (number-input-field budget :period-count {:step "1"


Fix non-potable water message

Fix non-potable water message

--- src/cljc/robinson/update.cljc
+++ src/cljc/robinson/update.cljc
@@ -1412,7 +1412,7 @@
     (update-in state [:world :player :thirst] (fn [thirst] (min 0 (- thirst water))))))

 (def quaff-popover-message
-  "This water is not potable. Are you sure?\n \n[<color fg=\"highlight\">y</color>]/[<color fg=\"highlight\">n</color>]")
+  "This water is not potable. Are you sure?\n \n[<color fg=\"highlight\">y</color>/<color fg=\"highlight\">n</color>]")

 (defn quaff-select
   "Select the next state depending on what quaffable items are available."


Refactor parser.cljs

Refactor parser.cljs

--- src/cljs/koeeoadi/parser.cljs
+++ src/cljs/koeeoadi/parser.cljs
@@ -82,10 +82,9 @@
   [{:keys [state]} _ {:keys [new-name prev-name]}]
   {:action
    (fn []
-     (let [st   @state
-           st'  (assoc st :theme/name new-name :theme/name-temp nil)
-           st'' (update-in st' [:theme/map] clojure.set/rename-keys {prev-name new-name})]
-       (reset! state st'')))})
+     (reset! state (-> @state
+                     (assoc :theme/name new-name :theme/name-temp nil)
+                     (update :theme/map clojure.set/rename-keys {prev-name new-name}))))})

 (defn current-theme [state]
   "Extracts current theme data from the current state"
@@ -157,7 +156,7 @@
    (fn []
      (let [st      @state
            new-id  (new-color-id (:colors/list st))
-           state'  (update-in st [:colors/by-id] merge {new-id {:color/id new-id}})
+           state'  (update st :colors/by-id merge {new-id {:color/id new-id}})
            state'' (update state' :colors/list conj [:colors/by-id new-id])]
        (reset! state state'')))})

@@ -166,15 +165,15 @@
   {:action
    (fn []
      (reset! state (-> @state
-                     (update-in [:colors/by-id] dissoc (last ref))
-                     (update-in [:colors/list] #(filterv (partial not= ref) %)))))})
+                     (update :colors/by-id dissoc (last ref))
+                     (update :colors/list #(filterv (partial not= ref) %)))))})

 (defmethod mutate 'color/update
   [{:keys [state]} _ {:keys [id rgb] :as props}]
   {:value {:keys [:faces/list]}
    :action
    (fn []
-     (swap! state update-in [:colors/by-id id] assoc :color/rgb rgb))})
+     (swap! state assoc-in [:colors/by-id id :color/rgb] rgb))})

 (defmethod mutate 'face/update
   [{:keys [state]} _ {:keys [:face/name] :as props}]
@@ -202,13 +201,13 @@
   [{:keys [state]} _ props]
   {:action
    (fn []
-     (swap! state update-in [:custom-faces/map] merge props))})
+     (swap! state update :custom-faces/map merge props))})

 (defmethod mutate 'custom-face/remove
   [{:keys [state]} _ {:keys [face/name]}]
   {:action
    (fn []
-     (swap! state update-in [:custom-faces/map] dissoc name))})
+     (swap! state update :custom-faces/map dissoc name))})

 (defmethod mutate 'custom-face/edit-name
   [{:keys [state]} _ {:keys [face/name] :as props}]


what gives?

what gives?

--- src/cljs/moon/components.cljs
+++ src/cljs/moon/components.cljs
@@ -129,9 +129,7 @@
                                                      :class "total-workout"
                                                      :min 0
                                                      :max 1
-                                                     :now 1  #_(/ (- (:total-duration data)
-                                                                (:remaining data))
-                                                             (:total-duration data))}))))
+                                                     :now 1  }))))

                    (->go-button (:running-workout data))


db/data.clj: fix get-data def syntax

db/data.clj: fix get-data def syntax

--- src/org/altlaw/db/data.clj
+++ src/org/altlaw/db/data.clj
@@ -17,8 +17,8 @@
     [(read-string (s3/get-object-string object))
      {:etag (metadata "ETag")}]))

-(def get-data
-     "Returns a ref to the data object with the given name."
+(def #^{:doc "Returns a ref to the data object with the given name."}
+     get-data
      (memoize
       (fn [name]
         (let [[data meta] (fetch-data name)]


formatting

formatting

--- src/overtone/libs/deps.clj
+++ src/overtone/libs/deps.clj
@@ -14,8 +14,8 @@
 ;; :done       - a list of functions with associated dependencies which have
 ;;               already been executed as their dependencies have been met
 (defonce dep-state* (agent {:satisfied #{}
-                            :todo []
-                            :done []}))
+                            :todo      []
+                            :done      []}))

 (defn- process-handler
   "Returns a new deps map containing either processed handler or it


use #'buffer-alloc-read instead of #'buffer in #'buffer-cue so that the buffer is allocated with the right number channels.

--- src/overtone/sc/buffer.clj
+++ src/overtone/sc/buffer.clj
@@ -266,24 +266,21 @@

   Options:

-  :n-chans     - Number of channels for the buffer
-                 Default 2
   :start       - Start frame in file.
                  Default 0
   :size        - Buffer size
                  Default 65536

   Example usage:
-  (buffer-cue \"~/Desktop/foo.wav\" :n-chans 1)"
+  (buffer-cue \"~/Desktop/foo.wav\" :start (* 3 44100))"

   [path & args]
   (let [path (resolve-tilde-path path)
-        arg-map (merge {:n-chans 2
-                        :start 0
+        arg-map (merge {:start 0
                         :size 65536}
                        (apply hash-map args))
-        {:keys [n-chans start size]} arg-map
-        buf (buffer size n-chans)]
+        {:keys [start size]} arg-map
+        buf (buffer-alloc-read path start size)]
     (snd "/b_read" (:id buf) path start -1 0 1)
     (with-meta
       (assoc buf


Add genre to tactile book entries

Add genre to tactile book entries

--- src/catalog/layout/fop.clj
+++ src/catalog/layout/fop.clj
@@ -314,9 +314,10 @@
    (verkauf product-number price)))

 (defmethod entry-sexp :taktilesbuch
-  [{:keys [description producer-brief library-signature product-number price] :as item}]
-  (list-item
-   (entry-heading-sexp item)
+  [{:keys [genre-text description producer-brief library-signature product-number price] :as item}]
+  (list-item
+   (entry-heading-sexp item)
+   (block (wrap genre-text "Genre: "))
    (block (wrap description))
    (block (wrap producer-brief))
    (ausleihe-multi library-signature)


Generate valid dtbook even if there are no recommendations

--- src/catalog/layout/obi.clj
+++ src/catalog/layout/obi.clj
@@ -21,14 +21,19 @@
 (defn- md-to-obi [markdown path path-to-numbers]
   (let [level (inc (count path))
         headers (layout/md-extract-headings markdown)]
-    (for [h headers]
-      [(level-keyword level)
-       [(heading-keyword level)
-        (format "%s%s" (layout/section-numbers (get path-to-numbers (conj path h))) h)]
-       [:p]])))
+    (if (seq headers)
+      (for [h headers]
+        [(level-keyword level)
+         [(heading-keyword level)
+          (format "%s%s" (layout/section-numbers (get path-to-numbers (conj path h))) h)]
+         [:p]])
+      ;; if there are no headers then just emit an empty <p/> to make
+      ;; sure the generated dtbook is valid
+      [:p])))

 (defn- level-sexp [items path path-to-numbers]
   (let [level (count path)]
+    (println level (last path))
     [(level-keyword level)
      [(heading-keyword level)
       (format "%s%s"


adding fields

adding fields

--- src/celestial/api/jobs.clj
+++ src/celestial/api/jobs.clj
@@ -33,7 +33,7 @@
 (defn tid-link [tid]
   (let [{:keys [host type]} (get! :celestial :log :gelf)]
     (case type
-     :kibana (<< "http://~{host}/index.html#/dashboard/script/logstash.js?query=tid:~{tid}")
+     :kibana (<< "http://~{host}/index.html#/dashboard/script/logstash.js?query=tid:~{tid}&fields=@timestamp,message,tid,")
      :gralog2 "TBD"
      :logstash "Nan"
      (warn (<< "no matching tid link found for ~{type}")))))


function used also in proxmox so no need to mention vmware

--- src/celestial/provider.clj
+++ src/celestial/provider.clj
@@ -52,7 +52,7 @@
         (apply hypervisor ks)
         (catch [:type :celestial.common/missing-conf] e
           (throw+ {:type :missing-template}
-                  (<< "no matching vmware template found for ~{os} add one to configuration under ~{ks}")))))))
+                  (<< "no matching template found for ~{os} add one to configuration under ~{ks}")))))))

 (defn transform
   "specific model transformations"


Increase the wait time for EC2 to become ready

--- src/circle/backend/ec2.clj
+++ src/circle/backend/ec2.clj
@@ -149,7 +149,7 @@
 (defn block-until-running
   "Blocks until AWS claims the instance is running"
   [instance-id & {:keys [timeout]
-                  :or {timeout 120}}]
+                  :or {timeout 300}}]
     (println "waiting for instance to start")
   (loop [timeout timeout]
     (let [inst (try


load basket returns the url again for qr code

--- src/eatme/controllers/api.clj
+++ src/eatme/controllers/api.clj
@@ -12,11 +12,11 @@
 (defn ping-the-api [pingback]
   (str "You have hit the API with: " pingback))

-(defn load-basket [id]
-  (store/load-basket id))
-
 (defn- url-for [basket-id]
   (str (config :eatme-url) "/%23" basket-id))
+
+(defn load-basket [id]
+  (assoc (store/load-basket id) :url (url-for id)))

 (defn save-basket [basket]
   (let [{:keys [id]} (store/save-basket (with-owner basket))]


Use http-fx in events with http requests

--- src/elfeed_cljsrn/events.cljs
+++ src/elfeed_cljsrn/events.cljs
@@ -1,8 +1,9 @@
 (ns elfeed-cljsrn.events
-  (:require [cljs.reader :as reader]
-            [re-frame.core :refer [reg-event-db after dispatch]]
+  (:require [ajax.core :as ajax]
+            [cljs.reader :as reader]
+            [day8.re-frame.http-fx]
+            [re-frame.core :refer [reg-event-db after dispatch reg-event-fx]]
             [cljs.spec :as s]
-            [ajax.core :refer [GET POST]]
             [elfeed-cljsrn.local-storage :as ls]
             [elfeed-cljsrn.rn :as rn]
             [elfeed-cljsrn.db :as db :refer [app-db db->ls! ls-db-key]]))
@@ -59,21 +60,19 @@
        (assoc :loading-remotely? false)
        (assoc :remote-error error))))

-(reg-event-db
+(reg-event-fx
  :fetch-entries
- (fn [db _]
-   (let [url (str (:server db) "/elfeed/search?q=" "@15-days-old %2bunread")]
-     (POST
-         url
-         {:handler (fn [data]
-                     (dispatch [:process-remote-entries data]))
-          :error-handler (fn [error]
-                           (dispatch [:process-remote-entries-error error]))
-          :response-format :json
-          :keywords? true}))
-   (-> db
-       (assoc :error-entries false)
-       (assoc :fetching-entries? true))))
+ (fn [{db :db} _]
+   {:http-xhrio {:method :post
+                 :uri (str (:server db) "/elfeed/search?q=" "@15-days-old %2bunread")
+                 :format :text
+                 :response-format (ajax/json-response-format {:keywords? true})
+                 :keywords? true
+                 :on-success [:process-remote-entries]
+                 :on-failure [:process-remote-entries-error]}
+    :db (assoc db
+               :error-entries false
+               :fetching-entries? true)}))

 (reg-event-db
  :process-remote-entries
@@ -92,44 +91,50 @@
        (assoc :fetching-entries? false)
        (assoc :error-entries error))))

-(reg-event-db
+(reg-event-fx
  :mark-entry-as-read
- (fn [db [_ entry]]
-   (let [url (str (:server db) "/elfeed/mark-read" "?webid=" (js/encodeURIComponent (:webid entry)))]
-     (POST
-         url
-         {:handler (fn [data]
-                     )
-          :format :json
-          :error-handler (fn [error]
-
-                           )}))
-   (-> db
-       (update :recent-reads (fn [coll]
-                               (if coll
-                                 (conj coll (:webid entry))
-                                 #{(:webid entry)}))))))
-
-(reg-event-db
+ (fn [{db :db} [_ entry]]
+   {:http-xhrio {:method :post
+                 :uri (str (:server db) "/elfeed/mark-read" "?webid=" (js/encodeURIComponent (:webid entry)))
+                 :format :json
+                 :response-format (ajax/json-response-format)
+                 :on-success [:process-mark-entry-as-read]
+                 :on-failure [:process-mark-entry-as-read-error]}
+    :db (update db :recent-reads (fn [coll]
+                                   (if coll
+                                     (conj coll (:webid entry))
+                                     #{(:webid entry)})))}))
+
+(reg-event-db
+ :process-mark-entry-as-read
+ (fn [db [_ response]]
+   db))
+
+(reg-event-db
+ :process-mark-entry-as-read-error
+ (fn [db [_ error]]
+   db))
+
+(reg-event-fx
  :fetch-entry-content
- (fn [db [_ entry]]
-   (let [url (str (:server db) "/elfeed/content/" (:content entry))]
-     (POST url
-         {:handler (fn [data]
-                     (dispatch [:process-remote-entry entry data])
-                     (dispatch [:mark-entry-as-read entry]))
-          :error-handler (fn [error]
-                           (dispatch [:process-remote-entry-error error]))}))
-   (-> db
-       (assoc :error-entry false)
-       (assoc :current-entry (:webid entry))
-       (assoc-in [:entries-m (:webid entry)] entry)
-       (assoc :fetching-entry? true))))
+ (fn [{db :db} [_ entry]]
+   {:http-xhrio {:method :post
+                 :uri (str (:server db) "/elfeed/content/" (:content entry))
+                 :format :json
+                 :response-format (ajax/text-response-format)
+                 :on-success [:process-remote-entry entry]
+                 :on-failure [:process-remote-entry-error]}
+    :db (-> db
+            (assoc :error-entry false
+                   :current-entry (:webid entry)
+                   :fetching-entry? true)
+            (assoc-in [:entries-m (:webid entry)] entry))}))

 (reg-event-db
  :process-remote-entry
  ->ls
  (fn [db [_ entry response]]
+   (dispatch [:mark-entry-as-read entry])
    (-> db
        (assoc :fetching-entry? false)
        (assoc-in [:entries-m (:webid entry) :content-body] response))))
@@ -141,18 +146,17 @@
        (assoc :fetching-entry? false)
        (assoc :error-entry error))))

-(reg-event-db
+(reg-event-fx
  :fetch-update-time
- (fn [db [_ _]]
-   (let [url (str (:server db) "/elfeed/update")]
-     (POST
-         url
-         {:params {:time (:update-time db)}
-          :handler (fn [data]
-                     (dispatch [:process-remote-update-time data]))
-          :error-handler (fn [error]
-                           (dispatch [:process-remote-update-time-error error]))}))
-   (assoc db :fetching-update-time true)))
+ (fn [{db :db} _]
+   {:http-xhrio {:method :post
+                 :uri (str (:server db) "/elfeed/update")
+                 :params {:time (:update-time db)}
+                 :format :json
+                 :response-format (ajax/json-response-format {:keywords? true})
+                 :on-success [:process-remote-update-time]
+                 :on-failure [:process-remote-update-time-error]}
+    :db (assoc db :fetching-update-time true)}))

 (reg-event-db
  :process-remote-update-time


add fx canvas code for later reference (unused)

--- src/client/game/paint.cljs
+++ src/client/game/paint.cljs
@@ -125,3 +125,36 @@
         canvas (dom/by-id id)]
     (if-not (nil? canvas)
       (.removeChild arena canvas))))
+
+;;------------------------------------------------------------
+;; FX Canvas
+;;------------------------------------------------------------
+
+(def fx-source nil)
+(def fx-canvas nil)
+(def fx-texture nil)
+(def fx-w nil)
+(def fx-h nil)
+
+(defn init-fx-canvas!
+  []
+  (set! fx-source   (.. js/document (getElementById "game-canvas")))
+  (set! fx-w        (.. fx-source -width))
+  (set! fx-h        (.. fx-source -height))
+  (set! fx-canvas   (.. js/fx canvas))
+  (set! fx-texture  (.. fx-canvas (texture fx-source)))
+
+  (.. fx-source -parentNode (insertBefore fx-canvas fx-source))
+
+  )
+
+(defn draw-fx-canvas!
+  []
+  (.. fx-texture (loadContentsOf fx-source))
+  (.. fx-canvas
+      (draw fx-texture)
+      (bulgePinch (/ fx-w 2) (/ fx-h 2) (* fx-h 0.75) 0.12)
+      (vignette 0.25 0.74)
+      (update))
+  )
+


Generalize transit response generation code

--- src/clj/cglossa/server.clj
+++ src/clj/cglossa/server.clj
@@ -26,6 +26,23 @@
       (uncaughtException [_ thread ex]
         (log/error ex "Uncaught exception on" (.getName thread))))))

+(defn- transit-response* [body]
+  (let [baos   (ByteArrayOutputStream. 2000)
+        writer (transit/writer baos :json)
+        _      (transit/write writer body)
+        res    (.toString baos)]
+    (.reset baos)
+    (-> (response/response res)
+        (response/content-type "application/transit+json")
+        (response/charset "utf-8"))))
+
+(defmacro transit-response [db-call]
+  `(try (let [res# ~db-call]
+          (transit-response* res#))
+        (catch Exception e#
+          {:status 500
+           :body   (.toString e#)})))
+
 (deftemplate page (io/resource "index.html") [])

 (defroutes app-routes
@@ -34,16 +51,7 @@
            (GET "/" req (page)))

 (defroutes db-routes
-           (GET "/corpus" [code]
-             (let [baos   (ByteArrayOutputStream. 2000)
-                   writer (transit/writer baos :json)
-                   body   (db/get-corpus code)
-                   _      (transit/write writer body)
-                   res    (.toString baos)]
-               (.reset baos)
-               (-> (response/response res)
-                   (response/content-type "application/transit+json")
-                   (response/charset "utf-8")))))
+           (GET "/corpus" [code] (transit-response (db/get-corpus code))))

 (def http-handler
   (let [r (routes #'db-routes #'app-routes)


add some more fun

add some more fun

--- src/cljs/cezanne/core.cljs
+++ src/cljs/cezanne/core.cljs
@@ -14,7 +14,7 @@
                     0.1
                     1000)
         renderer (js/THREE.WebGLRenderer.)
-        geometry (js/THREE.CubeGeometry. 1 1 1)
+        geometry (js/THREE.CubeGeometry. 2 2 0.3 )
         material (js/THREE.MeshNormalMaterial. )
         cube (js/THREE.Mesh. geometry material)]
     (.setSize renderer (.-innerWidth js/window) (.-innerHeight js/window))
@@ -32,8 +32,8 @@
 (defn render []
   (js/requestAnimationFrame render)
   (.render (:renderer @state) (:scene @state) (:camera @state))
-  (set! (.. (:cube @state) -rotation -x) (+ (.. (:cube @state) -rotation -x) 0.02))
-  (set! (.. (:cube @state) -rotation -y) (+ (.. (:cube @state) -rotation -y) 0.08)))
+  #_(set! (.. (:cube @state) -rotation -x) (+ (.. (:cube @state) -rotation -x) 0.05))
+  (set! (.. (:cube @state) -rotation -y) (+ (.. (:cube @state) -rotation -y) 0.15)))

 (init-all)


Noise

Noise

--- src/cljs/ufo/handlers.cljs
+++ src/cljs/ufo/handlers.cljs
@@ -30,7 +30,7 @@
                        (fn [e]
                          (on-error {:error
                                     (.getResponseText xhr)})))
-        (println "Sending request" reqprm "...")
+        (println "Requesting" reqprm "...")
         (let [url
               #_"http://10.90.20.167:3450/req"
               "req" ;; for localhost


when search, update visible items

when search, update visible items

--- src/cljs/unfolds/core.cljs
+++ src/cljs/unfolds/core.cljs
@@ -91,9 +91,10 @@
 ;; TODO: Move this too.
 ;; Old with link "Foobar [[foo|blitz]] lolophone hoptigoff."

-(defonce app-state (atom {:search "Foobar"
-                          :word-map {"Ogden" [0]}
-                          :visible [0]
+(defonce app-state (atom {:search ""
+                          :word-map {"Ogden" [0]
+                                     "Foo" [1]}
+                          :visible []
                           :items [[0 "Basic English is an English-based controlled language created by linguist and philosopher Charles Kay Ogden as an international auxiliary language, and as an aid for teaching English as a second language. Basic English is, in essence, a simplified subset of regular English. It was presented in Ogden's book Basic English: A General Introduction with Rules and Grammar (1930).

 Ogden's Basic, and the concept of a simplified English, gained its greatest publicity just after the Allied victory in World War II as a means for world peace. Although Basic English was not built into a program, similar simplifications have been devised for various international uses. Ogden's associate I. A. Richards promoted its use in schools in China. More recently, it has influenced the creation of Voice of America's Special English for news broadcasting, and Simplified English, another English-based controlled language designed to write technical manuals."]
@@ -103,9 +104,10 @@
 ;; before items looked like this
 ;; :items [{:id "foo" :text "bar"}] ;; dammit!

-(def id-atom (atom 0))
-(swap! id-atom inc) ;; first item
-(swap! id-atom inc) ;; second item
+(def id-atom (atom -1))
+(swap! id-atom inc) ;; first item, 0
+(swap! id-atom inc) ;; second item, 1
+(swap! id-atom inc) ;; third item, 2

 (defn add-item [app owner]
   (let [new-item-text (-> (om/get-node owner "new-item")
@@ -120,9 +122,8 @@
   (let [search (-> (om/get-node owner "search")
                    .-value)]
     (when search
-      (om/transact! app :search (fn [] search)))))
-
-;; also filter views?
+      (om/transact! app :search (fn [] search))
+      (om/transact! app :visible (fn [] (get (:word-map @app) search))))))

 ;; TODO: when adding note, add/merge words-item to word-map


Refactoring

Refactoring


fix docstring typo for `congitect.transit/writer` pointed out by Brandon Bloom. No JavaScript arrays involved only nested maps.

--- src/cognitect/transit.cljs
+++ src/cognitect/transit.cljs
@@ -168,9 +168,8 @@

 (defn writer
   "Return a transit writer. type maybe either :json or :json-verbose.
-   opts is a map containing a :handlers entry. :handlers is a JavaScript
-   array of interleaved type constructors and handler instances for those
-   type constructors."
+  opts is a map containing a :handlers entry. :handlers is a map of
+  type constructors to handler instances."
   ([type] (writer type nil))
   ([type opts]
      (let [keyword-handler (KeywordHandler.)


Rename in test.

Rename in test.

--- test/onyx/coordinator/simulation_tests/coordinator_simulant_tests.clj
+++ test/onyx/coordinator/simulation_tests/coordinator_simulant_tests.clj
@@ -48,7 +48,7 @@
   [conn model test]
   (u/require-keys test :db/id :test/duration)
   (-> @(d/transact conn [(assoc test
-                           :test/type :test.type/coordinator
+                           :test/type :test.type/stubbed-peer
                            :model/_tests (e model))])
       (tx-ent (:db/id test))))

@@ -81,14 +81,14 @@
    (fn [peer] (generate-peer-executions test peer peers))
    peers))

-(defmethod sim/create-test :model.type/coordinator
+(defmethod sim/create-test :model.type/stubbed-peer
   [conn model test]
   (let [test (create-test conn model test)
         peers (create-peers conn test)]
     (u/transact-batch conn (generate-all-executions test peers) 1000)
     (d/entity (d/db conn) (e test))))

-(defmethod sim/create-sim :test.type/coordinator
+(defmethod sim/create-sim :test.type/stubbed-peer
   [sim-conn test sim]
   (let [model (-> test :model/_tests u/solo)]

@@ -110,7 +110,7 @@

 (def coordinator-model-data
   [{:db/id model-id
-    :model/type :model.type/coordinator
+    :model/type :model.type/stubbed-peer
     :model/peer-count 10}])

 (def coordinator-model


fixing focus on input field after button is clicked

--- src/eatme/client/main.cljs
+++ src/eatme/client/main.cljs
@@ -53,7 +53,7 @@
   (d/append! items-list (render/shopping-list-item item)))

 (defn focus-item-input [& args]
-  (.-focus item-name-field))
+  (.focus item-name-field))

 (defn clear-item-input [& args]
   (d/set-value! item-name-field ""))


remove "--debug-mode" from "aapt package" unless dev-build

--- src/leiningen/droid/build.clj
+++ src/leiningen/droid/build.clj
@@ -185,6 +185,7 @@
   (let [aapt-bin (sdk-binary sdk-path :aapt)
         android-jar (get-sdk-android-jar sdk-path target-version)
         dev-build (dev-build? project)
+        debug-mode (if dev-build ["--debug-mode"] [])
         manifest-file (io/file manifest-path)
         backup-file (io/file (str manifest-path ".backup"))
         ;; Only add `assets` directory if it is present.
@@ -193,7 +194,7 @@
     (when dev-build
       (io/copy manifest-file backup-file)
       (write-manifest-with-internet-permission manifest-path))
-    (sh aapt-bin "package" "--no-crunch" "-f" "--debug-mode" "--auto-add-overlay"
+    (sh aapt-bin "package" "--no-crunch" "-f" debug-mode "--auto-add-overlay"
         "-M" manifest-path
         "-S" out-res-path
         "-S" res-path


Added 'recompute' attr to profile records

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -150,6 +150,7 @@
       (try
         (-> prof
             (assoc :n-ptps (:n conv))
+            (assoc :recompute recompute)
             (merge (hash-map-subset conv #{:n-cmts :zid :last-vote-timestamp})
                    extra-data)
             ((partial mongo-insert-results (db/mongo-collection-name "profile"))))
@@ -167,9 +168,11 @@
     (try
       (let [updated-conv   (conv/conv-update conv votes)
             zid            (:zid updated-conv)
-            finish-time    (System/currentTimeMillis)]
+            finish-time    (System/currentTimeMillis)
+            ; If this is a recompute, we'll have either :full or :reboot, ow/ want to send false
+            recompute      (if-let [rc (:recompute conv)] rc false)]
         (log/info "Finished computng conv-update for zid" zid "in" (- finish-time start-time) "ms")
-        (handle-profile-data updated-conv :n-votes (count votes))
+        (handle-profile-data updated-conv :recompute recompute :n-votes (count votes))
         ; Format and upload main results
         (doseq [[col-name prep-fn] [["main" prep-main] ; main math results, for client
                                     ["bidtopid" prep-bidToPid]]] ; bidtopid mapping, for server
@@ -233,10 +236,12 @@
     (-> conv
         (hash-map-subset #{:rating-mat :lastVoteTimestamp :zid :pca :in-conv :n :n-cmts})
         ; Make sure there is an empty named matrix to operate on
-        (assoc :rating-mat (nm/named-matrix))
+        (assoc :rating-mat (nm/named-matrix)
+               :recompute :reboot)
         ; Make sure in-conv is a set
         (update-in [:in-conv] set))
-    (assoc (conv/new-conv) :zid zid)))
+    ; would be nice to have :recompute :initial
+    (assoc (conv/new-conv) :zid zid :recompute :full)))

 (defmacro take-all! [c]


Defaulting to 'actual' as first argument to clojure.test's '='.

--- src/flare/clojure_test.clj
+++ src/flare/clojure_test.clj
@@ -26,8 +26,8 @@
        [args]
        (when (= 2 (count args))
          (let [args (if (= (:expected opts) :first)
-                      (reverse args)
-                      args)]
+                      args
+                      (reverse args))]
            (apply flare/diff args))))

      (defmethod ct/assert-expr '=


working?

working?

--- src/hack_the_drive/web.clj
+++ src/hack_the_drive/web.clj
@@ -74,7 +74,7 @@
             (resp/redirect "/grid")
           ; {:status 200 :headers {"Content-Type" "text/plain"} :body (pr-str data)})
         ;  {:status 200 :headers {"Content-Type" "text/plain"} :body (pr-str content)})
-        )
+        ))
         {:store (byte-array-store)})
   (GET "/media/:id" [id]
     (render-media-response


Update hatti.views.table namespace

Update hatti.views.table namespace

- Added utility function to set review status text; the default status is a number
- Rename function mock-onadata-tasking-fields to submission-review-fields

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -19,7 +19,12 @@
                                  label-changer submission-view]]
             [hatti.views.record]
             [hatti.shared :as shared]
-            [hatti.utils :refer [click-fn generate-html hyphen->camel-case]]
+            [hatti.utils :refer [click-fn
+                                 generate-html
+                                 hyphen->camel-case
+                                 review-status-map
+                                 get-submission-review-text
+                                 pending-status]]
             [chimera.core :refer [any?]]
             [cljsjs.slickgrid-with-deps]))

@@ -125,9 +130,13 @@
   (str "<input type=\"checkbox\" id=\"" select-unselect-all-records-id "\">"))
 (def delete-record-class "delete-record")

-(defn mock-onadata-tasking-fields
-  [cols] (let [[actions data] (split-at 1 cols)]
-            (vec (flatten (conj data forms/comment-field forms/review-status-field actions)))))
+(defn submission-review-fields
+  [cols]
+  (let [[actions data] (split-at 1 cols)]
+    (vec
+     (flatten
+      (conj
+       data forms/comment-field forms/review-status-field actions)))))

 (defmethod actions-column :default
   [owner has-hxl?]
@@ -171,7 +180,7 @@
     (clj->js (cond-> columns
                (not hide-actions-column?)
                (conj (actions-column owner has-hxl?))
-               true  mock-onadata-tasking-fields))))
+               true  submission-review-fields))))

 (defn init-sg-pager [grid dataview]
   (let [Pager (.. js/Slick -Controls -Pager)]
@@ -258,6 +267,14 @@
                [:selected-table-rows]
                #(identity indexes-of-selected-checkboxes))
     (.setSelectedRows grid (clj->js indexes-of-selected-checkboxes))))
+
+(defn replace-review-num-status-with-text-status
+  [data]
+  (map (fn [row-map]
+         (assoc row-map
+                "_review_status"
+                (get-submission-review-text row-map)))
+       data))

 (defn sg-init
   "Creates a Slick.Grid backed by Slick.Data.DataView from data and fields.
@@ -371,7 +388,9 @@
                                           default-num-displayed-records)
                             :totalPages total-page-count})
     (.setFilter dataview (partial filterfn form))
-    (.setItems dataview (clj->js (map #(assoc % :_review_status "Pending" :_review_comment "A comment!") data)) _id)
+    (.setItems dataview
+               (clj->js (replace-review-num-status-with-text-status data))
+               _id)
     (resizeColumns grid)
     [grid dataview]))

@@ -617,5 +636,9 @@
                   (handle-table-events cursor grid dataview))
                 (do ; data has changed
                   (.invalidateAllRows grid)
-                  (.setItems dataview (clj->js new-data) _id)
+                  (.setItems dataview
+                             (clj->js
+                              (replace-review-num-status-with-text-status
+                               new-data))
+                             _id)
                   (.render grid))))))))))


Improvements in clickhouse plugin (#1031)

- Add username/password authentication support for clickhouse.
- Add support to first create the required table.

Signed-off-by: Pradeep Chhetri <da29e79783ce5c0cfdb09fdec3d4e94d1f4520ad@gmail.com>

Signed-off-by: Pradeep Chhetri <da29e79783ce5c0cfdb09fdec3d4e94d1f4520ad@gmail.com>

--- src/riemann/clickhouse.clj
+++ src/riemann/clickhouse.clj
@@ -24,15 +24,45 @@
   (let [processed-events (map generate-datapoint events)]
     (str/join "" processed-events)))

-(defn generate-url
+(defn generate-create-query
+  "ClickHouse query for creating table"
+  [opts]
+  (let [database (:database opts)
+        table    (:table opts)]
+    (str "CREATE TABLE IF NOT EXISTS " database "." table "(
+            `timestamp` DateTime,
+            `host` String,
+            `service` String,
+            `metric` Float32,
+            `tags` Array(String)
+         )
+         ENGINE = MergeTree
+         PARTITION BY toYYYYMM(timestamp)
+         ORDER BY (timestamp, host, service)
+         SETTINGS index_granularity = 8192;")))
+
+(defn generate-create-url
+  "Generates the URL to which create table query should be posted."
+  [opts]
+  (let [scheme   (:scheme opts)
+        host     (:host opts)
+        port     (:port opts)
+        username (:username opts)
+        password (:password opts)]
+    (str scheme username ":" password "@" host ":" port)))
+
+(defn generate-insert-url
   "Generates the URL to which datapoint should be posted."
   [opts]
   (let [scheme   (:scheme opts)
         host     (:host opts)
         port     (:port opts)
         database (:database opts)
-        table    (:table opts)]
-    (str scheme host ":" port "/?query=INSERT%20INTO%20" database "." table "%20FORMAT%20CSV")))
+        table    (:table opts)
+        username (:username opts)
+        password (:password opts)
+        param    (str "INSERT INTO " database "." table " FORMAT CSV")]
+    (str scheme username ":" password "@" host ":" port "/?query=" param)))

 (defn post-datapoint
   "Post the riemann event as clickhouse datapoint."
@@ -58,10 +88,12 @@
    - `:port`           ClickHouse Server Port (default: 8123)
    - `:database`       ClickHouse Database Name (default: \"default\")
    - `:table`          ClickHouse Table Name (default: \"riemann\")
+   - `:username`       ClickHouse User Name (default: \"default\")
+   - `:password`       ClickHouse Password (default: \"\")

-   You need to first create a clickhouse table:
+   It will create the clickhouse table using the following query:

-   CREATE TABLE default.riemann
+   CREATE TABLE IF NOT EXISTS default.riemann
    (
       `timestamp` DateTime,
       `host` String,
@@ -79,10 +111,13 @@
                      :host "localhost"
                      :port 8123
                      :database "default"
-                     :table "riemann"}
-                    opts)]
+                     :table "riemann"
+                     :username "default"
+                     :password ""}
+                    opts)
+        _ (post-datapoint (generate-create-url opts) (generate-create-query opts))]
     (fn [events]
-      (let [url (generate-url opts)
+      (let [insert-url (generate-insert-url opts)
             datapoint (generate-datapoint-batch events)]
         (if-not (nil? datapoint)
-          (post-datapoint url datapoint))))))+          (post-datapoint insert-url datapoint))))))


Update repl-code to simpler set

Update repl-code to simpler set

Goes with new init logic

--- repl-code.clj
+++ repl-code.clj
@@ -1,46 +1,10 @@
-;; For repl.
+;; For repl, to get working with db.

-;; Sample arb doc in edn
-;;
-;; [{:arb/metadata [{:html-tag :body}]
-;;   :arb/value [{:arb/metadata [{:html-tag :h1}]
-;;                :arb/value [{:text "Title"}]}
-;;               {:arb/metadata [{:html-tag :p}]
-;;                :arb/value [{:text "This is a paragraph."}]}]}]
+(require '[datomic.client.api :as d])
+(use 'datemo.db)
+(init-client)
+(connect "development") ;; can also connect "production"
+
+;; At this point you can use the fns in datemo.db to work with the db.

-;; for client api
-(require '[clojure.core.async :refer [<!!]]
-         '[datomic.client :as client])
-
-(def conn
-  (<!! (client/connect
-        {:db-name "datemo"
-         :account-id client/PRO_ACCOUNT
-         :secret "datemo"
-         :region "none"
-         :endpoint "localhost:8998"
-         :service "peer-server"
-         :access-key "datemo"})))
-
-(def db (client/db conn))
-
-;;
-(d/delete-database "datomic:dev://localhost:4334/datemo")
-(d/create-database "datomic:dev://localhost:4334/datemo")
-
-
-;; for datomic api
-(require '[datomic.api :as d])
-
-(def conn (d/connect "datomic:dev://localhost:4334/datemo"))
-(def db-now (d/db conn))
-
-;; for installing the schema
-;; run lein-repl, then:
-(use 'datemo.db)
-(require '[datomic.api :as d])
-(init-db)
-(-> (load-schema "schemas/arb.edn")
-    (install-schema (get-conn)))
-


wip on om ui

wip on om ui

--- src/tango/cljs/client.cljs
+++ src/tango/cljs/client.cljs
@@ -43,18 +43,24 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Server message handling

+(declare reconciler)
 (defn handle-query-result [d]
   (let [clean-data (uidb/sanitize d)]
+    (log "Handle Q R")
      ;(log clean-data)
     ;(log (apply str (map :competition/name clean-data)))
                                         ;(d/transact! (d/db conn) )
-    (d/transact! conn [clean-data])
-    (log (d/q '[:find [(pull ?c [:class/name]) ...]
-                :where
-                [?e :competition/name "Rikstävling disco"]
-                [?e :competition/classes ?c]]
-              (d/db conn)))
+    ;;(d/transact! conn [clean-data])
+    ;; (log (d/q '[:find [(pull ?c [:class/name]) ...]
+    ;;             :where
+    ;;             [?e :competition/name "Rikstävling disco"]
+    ;;             [?e :competition/classes ?c]]
+    ;;           (d/db conn)))
     ;(d/transact! conn [{:db/id 1 :competition/name (apply str (map :competition/name clean-data))}])
+    ;(om/transact! reconciler `[(app/add-competition `{:X "X"}) :app/competitions])
+    ;(log clean-data)
+    (om/transact! reconciler `[(app/add-competition ~clean-data) :app/competitions
+                               ])
     ))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -117,17 +123,30 @@
   [{:keys [state query] :as env} key params]
   {:value (do
             ;(log (str "Env: " env " --- Key : " key " --- Params" params))
-            (log "Read app/competitions")
-            (d/q '[:find [(pull ?e ?selector) ...]
-                   :in $ ?selector
-                   :where [?e :competition/name]]
-                 (d/db state) query)) ;(log (str "Read Comp, state " state " , query" query))
+            (log (str "Read app/competitions with query " query))
+            (log (str "Key " key))
+            (log (str "Env " env))
+            (if query
+              (d/q '[:find [(pull ?e ?selector) ...]
+                     :in $ ?selector
+                     :where [?e :competition/name]]
+                   (d/db state) query))
+            ) ;(log (str "Read Comp, state " state " , query" query))
    :remote true})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Mutate

 (defmulti mutate om/dispatch)
+
+(defmethod mutate 'app/add-competition
+  [{:keys [state]} key params]
+  (do
+    {:value {:keys [:app/competitions]}
+     :action (fn []
+               (do
+                 (log "Add Competition")
+                 (d/transact! state [params])))}))

 (defmethod mutate 'app/increment
   [{:keys [state]} _ entity]
@@ -206,8 +225,28 @@
   (render
    [this]
    (dom/div nil (dom/button #js {:onClick #(log "T'vlingar")} "Tävlingar")
-            (dom/div nil ((om/factory CompetitionsView))))))
-
+            (dom/div nil ((om/factory CompetitionsView)))
+
+            (dom/div
+             nil
+             (dom/h3 nil (:competition/name (om/props this)))
+             (dom/button #js {:onClick #(log "Properties")} "Properties")
+             (dom/button #js {:onClick #(log "Classes")} "Classes")
+             (dom/button #js {:onClick #(log "Time Schedule")} "Time Schedule")
+             (dom/button #js {:onClick #(log "Adjudicators")} "Adjudicators")
+             (dom/button #js {:onClick #(log "Adjudicator Panels")} "Adjudicator Panels")))))
+
+ ;; [:input.btn.btn-default {:type "button" :value "Classes"
+ ;;                               :on-click #(dispatch [:select-page :classes])}]
+ ;;      [:input.btn.btn-default {:type "button" :value "Time Schedule"
+ ;;                               :on-click #(dispatch [:select-page :events])}]
+ ;;      [:input.btn.btn-default {:type "button" :value "Adjudicators"
+ ;;                               :on-click #(dispatch [:select-page :adjudicators])}]
+ ;;      [:input.btn.btn-default {:type "button" :value "Adjudicator panels"
+ ;;                               :on-click #(dispatch [:select-page :adjudicator-panels])}]])])
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Posts

 (defn transit-post [url]
   (fn [{:keys [remote]} cb]
@@ -231,13 +270,16 @@
       (log (str "Sent to Tango Backend => " remote))
       (chsk-send! [:event-manager/query [[:competition/name :competition/location]]]))))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Application
+
 ;; TODO - since conn is set the read query will be run twice at start up - delay read or something..
 (def reconciler
   (om/reconciler
     {:state conn
      :remotes [:remote]
      :parser (om/parser {:read read :mutate mutate})
-     :send (sente-post) ;(fn [x y] (log (str "Sending to server: x" x " y: " y)))
+     :send sente-post ;(fn [x y] (log (str "Sending to server: x" x " y: " y)))
      }))

 ;; (om/add-root! reconciler


Ensure folder is fsynced.

Ensure folder is fsynced.

--- src/konserve/filestore.clj
+++ src/konserve/filestore.clj
@@ -116,7 +116,8 @@
                 (.sync fd))
               (.renameTo new-file f)
               (when (:fsync config)
-                (.sync fd))
+                (.sync fd)
+                (.sync (.getFD (io/file folder))))
               [(get-in old rkey)
                (get-in new rkey)]
               (catch Exception e


Update jshint version

Update jshint version

--- src/lein_jshint/plugin.clj
+++ src/lein_jshint/plugin.clj
@@ -8,7 +8,7 @@
 ; Internal API: Configuration

 (def ^:private DEF_JSHINT_DEP "jshint")
-(def ^:private DEF_JSHINT_VER ">=2.5.0")
+(def ^:private DEF_JSHINT_VER ">=2.5.5")

 ; Internal API: Middlewares


test cli-opts threshold

test cli-opts threshold

--- test/app/test/cli.clj
+++ test/app/test/cli.clj
@@ -85,3 +85,31 @@
     (is (= false (:help (:options res))))
     (is (= "FOO" (:dir (:options res))))
     (is (= nil (:errors res)))))
+
+(deftest cli-opts-threshold-not-a-number
+  (let [args ["-t" "2a"]
+        res (parse-opts args cliOpts)]
+    (is (= [] (:arguments res)))
+    (is (= false (:linter (:options res))))
+    (is (= false (:interactive (:options res))))
+    (is (= false (:help (:options res))))
+    (is (:errors res))))
+
+(deftest cli-opts-threshold-negative
+  (let [args ["-t" "-2"]
+        res (parse-opts args cliOpts)]
+    (is (= [] (:arguments res)))
+    (is (= false (:linter (:options res))))
+    (is (= false (:interactive (:options res))))
+    (is (= false (:help (:options res))))
+    (is (:errors res))))
+
+(deftest cli-opts-threshold-positive
+  (let [args ["-t" "2"]
+        res (parse-opts args cliOpts)]
+    (is (= [] (:arguments res)))
+    (is (= false (:linter (:options res))))
+    (is (= false (:interactive (:options res))))
+    (is (= false (:help (:options res))))
+    (is (= 2 (:threshold (:options res))))
+    (is (= nil (:errors res)))))


Progress on transforming entries, but not done. Should add some tests for the transforms functions too?

--- src/wealthpulse/parser.clj
+++ src/wealthpulse/parser.clj
@@ -4,12 +4,15 @@

 ; Journal records
 (defrecord Header [date status code payee note])
+(defrecord Amount [quantity commodity])
+(defrecord Entry [header account account-lineage entry-type amount note])
+

 (defn transform-header
 	"Transform a header from the parse tree into a Header record."
 	[[_ & values]]
 	(let [collect-values
-			(fn [coll [key value]]
+			(fn [coll [key value]]
 				(cond
 					(= key :date) (assoc coll :date (.parse (java.text.SimpleDateFormat. "yyyy/MM/dd") value))
 					(= key :status) (assoc coll :status (if (= value \!) :uncleared :cleared))
@@ -20,10 +23,22 @@
 		(->Header (:date header-map) (:status header-map) (:code header-map) (:payee header-map) (:note header-map))))

+(defn transform-entry
+  "Transform a parse-tree entry into an Entry record."
+  [[_ & values]]
+  (let [collect-values
+          (fn [coll [key value & rest]]
+            (cond
+               (= key :account) (assoc coll :account (string/trim value))  ; should to handle account-lineage and entry-type here
+               (= key :amount) () ; need to handle quantity, quantity * commodity, commodity * quantity (and negative quantities)
+               (= key :note) (assoc coll :note (string/trim value))))])
+  (map println values))
+
 (defn transform-entries
 	"Transform a list of parse-tree entries into entries."
 	[[_ & entries] header]
-	(map println entries))
+	(map transform-entry entries))
+

 (defn transform-transaction
 	"Transform a parse-tree transaction into entries."
@@ -35,7 +50,7 @@
 (defn transform-transactionZ
 	"Transform a parsed transaction into a more usable form."
 	[transaction]
-	(insta/transform
+	(insta/transform
 		{:date (fn [x] [:date (.parse (java.text.SimpleDateFormat. "yyyy/MM/dd") x)])
 		 :status (fn [x] [:status (if (= x \!) :uncleared :cleared)])
 		 :code (fn [x] [:code (string/trim x)])


cleaning up mad2 and adding pause example.

--- test/example/mad2.clj
+++ test/example/mad2.clj
@@ -76,6 +76,9 @@
 ;in an aeolian scale, starting on E4.
 (def _ nil)
 (def derez [[:i :iii :i] [:i* :v :iii :vii :iv. :i :iii :iv]])
+(def pitches (i2p derez :aeolian e4))

-;(play tone (i2p derez :aeolian e4) metro)
+;(play tone pitches metro)

+;(play ks1-demo (i2p [[:i _ :i] [:i :i :i _ :v _ :i]] :diatonic f4) metro)
+


add note for at least class on viewers list

--- src-cljs/frontend/components/hud.cljs
+++ src-cljs/frontend/components/hud.cljs
@@ -142,7 +142,7 @@
             [:div.viewers
              {:class (concat
                        (when chat-opened? ["chat-open"])
-                       [(str "atleast" viewers-count)])}
+                       [(str "atleast" viewers-count)])} ; TODO use this to clean up messy nth-childs in hud.less
              (when show-viewers?
                [:div.viewers-list
                 [:div.viewers-list-frame


made :oss? :oss to match the new backend

--- src-cljs/frontend/models/project.cljs
+++ src-cljs/frontend/models/project.cljs
@@ -170,5 +170,5 @@
                            (:plans)
                            (apply max-key :containers))]
     (assoc project :show-insights? (or (config/enterprise?)
-                                       (:oss? project)
+                                       (:oss project)
                                        (> (:containers org-best-plan) 1)))))


fix copy URL

fix copy URL

whitesapce

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_config_importer.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/method_config_importer.cljs
@@ -7,6 +7,7 @@
     [org.broadinstitute.firecloud-ui.common.style :as style]
     [org.broadinstitute.firecloud-ui.common.table :as table]
     [org.broadinstitute.firecloud-ui.common.components :as comps]
+    [org.broadinstitute.firecloud-ui.paths :as paths]
     [org.broadinstitute.firecloud-ui.utils :as utils]))

@@ -68,11 +69,10 @@
                                                selected-conf-namespace
                                                selected-conf-snapshotId
                                                dest-conf-name
-                                               dest-conf-namespace)]
+                                               dest-conf-namespace)
+                                   copy_URL (paths/copy-method-config-to-workspace-path workspace)]
                                (utils/ajax-orch
-                                 (str "/" dest-workspace-namespace "/"
-                                   dest-workspace-name
-                                   "/method_configs/copyFromMethodRepo")
+                                 copy_URL
                                  {:canned-response {:responseText
                                                       (utils/->json-string (create-mock-methodconfs-import))
                                                     :status 200