Remove debug

Remove debug

--- src/gin/lobby.clj
+++ src/gin/lobby.clj
@@ -236,8 +236,8 @@
                                                             [?e :game/player2 ?p]]]))]
                              (async/put! out
                                          (str "data: "
-                                              (spy (str {:type :game-created
-                                                         :url (str "/games/" game-id)}))
+                                              (str {:type :game-created
+                                                    :url (str "/games/" game-id)})
                                               "\r\n\r\n")))
                            (let [in (chan)
                                  report-to-msg (fn [report]
@@ -253,36 +253,36 @@
                                                             (not (contains? opps-e v)))
                                                        (let [opp (d/entity db v)]
                                                          (str "data: "
-                                                              (spy (str {:type :joined
-                                                                         :slug (:account/slug opp)
-                                                                         :username (:account/username opp)}))
+                                                              (str {:type :joined
+                                                                    :slug (:account/slug opp)
+                                                                    :username (:account/username opp)})
                                                               "\r\n\r\n"))
                                                        (and added
                                                             (= e (:db/id us))
                                                             (= a invites-attr))
                                                        (let [opp (d/entity db v)]
                                                          (str "data: "
-                                                              (spy (str {:type :invited
-                                                                         :slug (:account/slug opp)
-                                                                         :username (:account/username opp)}))
+                                                              (str {:type :invited
+                                                                    :slug (:account/slug opp)
+                                                                    :username (:account/username opp)})
                                                               "\r\n\r\n"))
                                                        (and added
                                                             (= a invites-attr)
                                                             (= v (:db/id us)))
                                                        (let [opp (d/entity db e)]
                                                          (str "data: "
-                                                              (spy (str {:type :available
-                                                                         :slug (:account/slug opp)
-                                                                         :username (:account/username opp)}))
+                                                              (str {:type :available
+                                                                    :slug (:account/slug opp)
+                                                                    :username (:account/username opp)})
                                                               "\r\n\r\n"))
                                                        (and added
                                                             (= a play-attr)
                                                             (= v (:db/id us)))
                                                        (let [opp (d/entity db e)]
                                                          (str "data: "
-                                                              (spy (str {:type :play
-                                                                         :slug (:account/slug opp)
-                                                                         :username (:account/username opp)}))
+                                                              (str {:type :play
+                                                                    :slug (:account/slug opp)
+                                                                    :username (:account/username opp)})
                                                               "\r\n\r\n"))
                                                        (and added
                                                             (or (= a player1-attr)
@@ -290,8 +290,8 @@
                                                             (= v (:db/id us)))
                                                        (let [game (d/entity db e)]
                                                          (str "data: "
-                                                              (spy (str {:type :game-created
-                                                                         :url (str "/games/" (:game/id game))}))
+                                                              (str {:type :game-created
+                                                                    :url (str "/games/" (:game/id game))})
                                                               "\r\n\r\n"))
                                                        ))
                                                     tx-data)))]


Clarify comment.

Clarify comment.

--- src/african_polyphony_and_polyrhythm/talk.clj
+++ src/african_polyphony_and_polyrhythm/talk.clj
@@ -21,7 +21,7 @@
       (with before (f note) after))))

 (defn split
-  "Split a new note off the note at time t."
+  "Split a note into two at time t."
   [t duration]
   (letfn [(f [note]
             [(-> note (assoc :duration duration))


Include namespace in condition type name.

--- src/active/clojure/condition.cljc
+++ src/active/clojure/condition.cljc
@@ -304,7 +304,7 @@
                                                (map (fn [[?field ?accessor]]
                                                       (str "\n`" ?field "`" (name-doc ?field) ": access via " (reference ?accessor)))
                                                     ?field-pairs))))))
-           (->ConditionType '~?condition-type ~?supertype
+           (->ConditionType '~(symbol (str *ns*) (name ?condition-type)) ~?supertype
                             '[~@(map first ?field-pairs)] total-field-count#))
          (def ~(document ?constructor
                          (str "Construct a " (reference ?condition-type) " condition."))


info service delete handler refactor

info service delete handler refactor

--- src/cljs/swarmpit/component/service/info.cljs
+++ src/cljs/swarmpit/component/service/info.cljs
@@ -8,6 +8,17 @@
             [ajax.core :refer [DELETE]]))

 (enable-console-print!)
+
+(defn- delete-service-handler
+  [service-id]
+  (DELETE (str "/services/" service-id)
+          {:handler       (fn [_]
+                            (let [message (str "Service " service-id " has been removed.")]
+                              (router/dispatch! "/#/services")
+                              (message/mount! message)))
+           :error-handler (fn [{:keys [status status-text]}]
+                            (let [message (str "Service " service-id " removing failed. Reason: " status-text)]
+                              (message/mount! message)))}))

 (rum/defc form < rum/static [item]
   (let [id (:id item)]
@@ -22,17 +33,7 @@
                 :style   #js {:marginRight "12px"}}))
        (material/theme
          (material/raised-button
-           #js {:onTouchTap (fn []
-                              (DELETE (str "/services/" id)
-                                      {:handler
-                                       (fn [_]
-                                         (router/dispatch! "/#/services")
-                                         (message/mount!
-                                           (str "Service " id " has been removed.")))
-                                       :error-handler
-                                       (fn [{:keys [status status-text]}]
-                                         (message/mount!
-                                           (str "Service " id " removing failed. Reason: " status-text)))}))
+           #js {:onTouchTap delete-service-handler
                 :label      "Delete"}))]]
      [:div.form-view
       [:div.form-view-group


Add support lib traits

Add support lib traits

--- src/clojure/org/bytopia/foreclojure/utils.clj
+++ src/clojure/org/bytopia/foreclojure/utils.clj
@@ -1,14 +1,137 @@
 (ns org.bytopia.foreclojure.utils
-  (:require [neko.notify :refer [toast]]
-            [neko.threading :refer [on-ui]])
-  (:import android.app.Activity))
+  (:require [neko.activity :as a]
+            [neko.listeners.view :refer [on-click-call]]
+            [neko.notify :refer [toast]]
+            [neko.resource :refer [get-string]]
+            [neko.threading :refer [on-ui]]
+            [neko.ui :as ui]
+            [neko.ui.mapping :refer [defelement]]
+            [neko.ui.traits :as traits]
+            [neko.-utils :as u])
+  (:import android.app.Activity
+           android.view.View
+           android.support.v4.widget.SwipeRefreshLayout$OnRefreshListener
+           android.support.design.widget.Snackbar))
+
+(defn ellipsize [s max-length]
+  (let [lng (count s)]
+    (if (> lng max-length)
+      (str (subs s 0 max-length) "…") s)))

 (defmacro long-running-job
-  "Runs body in a future, assumes activity instance is bound to `a`."
-  [& body]
+  "Runs body in a future, initializing progress with `progress-start`
+  expression, and ending it with `progress-stop`."
+  [progress-start progress-stop & body]
   (let [asym (with-meta 'a {:tag android.app.Activity})]
     `(future
-       (on-ui (.setProgressBarIndeterminateVisibility ~asym true))
+       (on-ui ~progress-start)
        (try ~@body
             (catch Exception ex# (on-ui (toast (str ex#))))
-            (finally (on-ui (.setProgressBarIndeterminateVisibility ~asym false)))))))
+            (finally (on-ui ~progress-stop))))))
+
+(defn on-refresh-listener-call
+  [callback swipe-layout]
+  (reify SwipeRefreshLayout$OnRefreshListener
+    (onRefresh [_]
+      (u/call-if-nnil callback swipe-layout))))
+
+(defn snackbar
+  ([view-or-activity text duration]
+   (snackbar view-or-activity text duration nil nil))
+  ([view-or-activity text duration action-text action-callback]
+   (let [sb (Snackbar/make ^View (if (instance? Activity view-or-activity)
+                                   (a/get-decor-view view-or-activity)
+                                   view-or-activity)
+                           (get-string text)
+                           duration)]
+     (when action-text
+       (.setAction sb action-text (on-click-call action-callback)))
+     (.show sb))))
+
+(neko.ui.mapping/defelement :drawer-layout
+  :classname android.support.v4.widget.DrawerLayout
+  :inherits :view-group
+  :traits [:drawer-toggle])
+
+(neko.ui.mapping/defelement :navigation-view
+  :classname android.support.design.widget.NavigationView
+  :inherits :frame-layout
+  :traits [:navbar-menu :navbar-header-view])
+
+(neko.ui.traits/deftrait :drawer-layout-params
+  "docs"
+  {:attributes (concat (deref #'neko.ui.traits/margin-attributes)
+                       [:layout-width :layout-height
+                        :layout-weight :layout-gravity])
+   :applies? (= container-type :drawer-layout)}
+  [^View wdg, {:keys [layout-width layout-height layout-weight layout-gravity]
+               :as attributes}
+   {:keys [container-type]}]
+  (let [^int width (->> (or layout-width :wrap)
+                        (neko.ui.mapping/value :layout-params)
+                        (neko.ui.traits/to-dimension (.getContext wdg)))
+        ^int height (->> (or layout-height :wrap)
+                         (neko.ui.mapping/value :layout-params)
+                         (neko.ui.traits/to-dimension (.getContext wdg)))
+        weight (or layout-weight 0)
+        params (android.support.v4.widget.DrawerLayout$LayoutParams. width height weight)]
+    (#'neko.ui.traits/apply-margins-to-layout-params (.getContext wdg) params attributes)
+    (when layout-gravity
+      (set! (. params gravity)
+            (neko.ui.mapping/value :layout-params layout-gravity :gravity)))
+    (.setLayoutParams wdg params)))
+
+(neko.ui.traits/deftrait :drawer-toggle
+  "docs"
+  {:attributes [:drawer-open-text :drawer-closed-text :drawer-indicator-enabled
+                :on-drawer-closed :on-drawer-opened]}
+  [^DrawerLayout wdg, {:keys [drawer-open-text drawer-closed-text
+                              drawer-indicator-enabled
+                              on-drawer-opened on-drawer-closed]}
+   {:keys [^View id-holder]}]
+  (let [toggle (proxy [ActionBarDrawerToggle DrawerLayout$DrawerListener]
+                   [^android.app.Activity (.getContext wdg)
+                    wdg
+                    ^int (or drawer-open-text android.R$string/untitled)
+                    ^int (or drawer-closed-text android.R$string/untitled)]
+                 (onDrawerOpened [view]
+                   (neko.-utils/call-if-nnil on-drawer-opened view))
+                 (onDrawerClosed [view]
+                   (neko.-utils/call-if-nnil on-drawer-closed view)))]
+    (.setDrawerIndicatorEnabled toggle (boolean drawer-indicator-enabled))
+    (.setDrawerListener wdg toggle)
+    (when id-holder
+      (.put ^HashMap (.getTag id-holder) :neko.ui/drawer-toggle toggle))))
+
+(neko.ui.mapping/defelement :swipe-refresh-layout
+  :classname android.support.v4.widget.SwipeRefreshLayout
+  :traits [:on-refresh])
+
+(neko.ui.traits/deftrait :on-refresh
+  "docs "
+  [^android.support.v4.widget.SwipeRefreshLayout wdg, {:keys [on-refresh]} _]
+  (.setOnRefreshListener wdg (on-refresh-listener-call on-refresh wdg)))
+
+(neko.ui.traits/deftrait :elevation
+  "docs "
+  [^View wdg, {:keys [elevation]} _]
+  (ViewCompat/setElevation wdg (neko.ui.traits/to-dimension
+                                (.getContext wdg) elevation)))
+
+(neko.ui.traits/deftrait :navbar-header-view
+  "docs "
+  {:attributes [:header]}
+  [^android.support.design.widget.NavigationView wdg, {:keys [header]} opts]
+  (.addHeaderView wdg (ui/make-ui-element (.getContext wdg) header opts)))
+
+(neko.ui.traits/deftrait :navbar-menu
+  "docs "
+  {:attributes [:menu]}
+  [^android.support.design.widget.NavigationView wdg, {:keys [menu]} _]
+  (menu/make-menu (.getMenu wdg) menu))
+
+(neko.ui.mapping/add-trait! :view :drawer-layout-params)
+(neko.ui.mapping/add-trait! :view :elevation)
+(neko.ui.mapping/add-trait! :swipe-refresh-layout :drawer-layout-params)
+
+(swap! (deref #'neko.ui.mapping/reverse-mapping) assoc android.widget.ProgressBar :progress-bar)


more map matchers

more map matchers

--- src/matcha.clj
+++ src/matcha.clj
@@ -239,7 +239,19 @@
    :description (str "a map with val " (pr-str v))
    :describe-mismatch
    (fn [m]
-     (str "vals: " (vals m) " (was " (pr-str m) ")"))})
+     (str "vals: " (string/join ", " (vals m)) " (was " (pr-str m) ")"))})
+
+(defn has-key
+  "passes if the map received has the given key
+
+  (matcha/run-match (matcha/has-key 1) {:a 1}) ; => passes
+  (matcha/run-match (matcha/has-key 1) {:a 2})  ; => fails"
+  [v]
+  {:match (fn [m] (core/some #{v} (keys m)))
+   :description (str "a map with key " (pr-str v))
+   :describe-mismatch
+   (fn [m]
+     (str "keys: " (string/join ", " (keys m)) " (was " (pr-str m) ")"))})

 (defn includes
   "passes if the sequence received includes the given item


cnf: not-atoms-only are implemented

cnf: not-atoms-only are implemented

 * This function solves all negated expressions in parenthesis and makes
   the negation in front of atoms only.

--- src/logic/cnf.clj
+++ src/logic/cnf.clj
@@ -3,19 +3,87 @@
 (declare only-and-or-not)

 (def cnf-trans-map
-  {:impl   (fn [a b] `(or (not ~(only-and-or-not a)) ~(only-and-or-not b)))
-   :nimpl  (fn [a b] `(not (or (not ~(only-and-or-not a)) ~(only-and-or-not b))))
-   :rimpl  (fn [a b] `(or ~(only-and-or-not a) (not ~(only-and-or-not b))))
-   :nrimpl (fn [a b] `(not (or ~(only-and-or-not a) (not ~(only-and-or-not b)))))
+  {:impl   (fn [a b] `(or
+                        (not ~(only-and-or-not a))
+                          ~(only-and-or-not b)))
+   :nimpl  (fn [a b] `(not
+                        (or
+                          (not ~(only-and-or-not a))
+                          ~(only-and-or-not b))))
+   :rimpl  (fn [a b] `(or
+                        ~(only-and-or-not a)
+                        (not ~(only-and-or-not b))))
+   :nrimpl (fn [a b] `(not
+                        (or
+                          ~(only-and-or-not a)
+                          (not ~(only-and-or-not b)))))
    :equiv  (fn [a b] `(and
-					              (or (not ~(only-and-or-not a)) ~(only-and-or-not b))
-					              (or ~(only-and-or-not a) (not ~(only-and-or-not b)))))
+					              (or
+                          (not ~(only-and-or-not a))
+                          ~(only-and-or-not b))
+					              (or
+                         ~(only-and-or-not a)
+                         (not ~(only-and-or-not b)))))
    :xor    (fn [a b] `(not (and
-			                  (or (not ~(only-and-or-not a)) ~(only-and-or-not b))
-			                  (or ~(only-and-or-not a) (not ~(only-and-or-not b))))))
-   :nor    (fn [a b] `(not (or ~(only-and-or-not a) ~(only-and-or-not b))))
-   :nand   (fn [a b] `(not (and ~(only-and-or-not a) ~(only-and-or-not b))))
+			                  (or
+                          (not ~(only-and-or-not a))
+                          ~(only-and-or-not b))
+			                  (or
+                          ~(only-and-or-not a)
+                          (not ~(only-and-or-not b))))))
+   :nor    (fn [a b] `(not
+                        (or
+                          ~(only-and-or-not a)
+                          ~(only-and-or-not b))))
+   :nand   (fn [a b] `(not
+                        (and
+                          ~(only-and-or-not a)
+                          ~(only-and-or-not b))))
+   :not    (fn [a]   `(not ~(only-and-or-not a)))
   })
+
+(defn not-atoms-only
+  "Takes a formula in clojure code (preferably only with and, or, not) and makes all
+   negations stand only in front of atoms."
+  [formula]
+  (if (and (not (boolean? formula)) (not (symbol? formula)))
+    (let [op (first formula)
+          a (second formula)]
+	    (if (and
+	          (= (name op) "not")
+            (not (boolean? a))
+            (not (symbol? a)))
+
+	      ; then: look ahead the child operator
+        (let [child-op (name (first a))
+              child-a (second a)]
+
+          (if (= child-op "not")
+
+            ; child operator is not - go one with recursion
+            (not-atoms-only child-a)
+
+            ; child operator is not 'not' - apply De Morgan rules
+            (case child-op
+              "and" `(or (not ~(not-atoms-only child-a))
+                         (not ~(not-atoms-only (nth a 2))))
+
+              "or" `(and (not ~(not-atoms-only child-a))
+                         (not ~(not-atoms-only (nth a 2))))
+
+              ;else
+              (throw (Exception. (str "Unimplmented for operation:" child-op)))
+              )))
+
+	      ; else: proceed recursively
+	      (remove nil? (list
+	                     op
+	                     (not-atoms-only a)
+	                     (when (not= (name op) "not")
+	                       (not-atoms-only (nth formula 2)))
+	                     )))
+	      )
+	    formula))

 (defn only-and-or-not
   "Takes a formula in clojure code and replaces all equivalents, implications and their
@@ -24,11 +92,12 @@
   (if (and (not (boolean? formula)) (not (symbol? formula)))

     (let [junctor (-> formula first name keyword)
-          a (second formula)
-          b (nth formula 2)]
+          a (second formula)]

       (if (contains? cnf-trans-map junctor)
-         ((cnf-trans-map junctor) a b)
+        (if (= junctor :not)
+	         ((cnf-trans-map junctor) a)
+	         ((cnf-trans-map junctor) a (nth formula 2)))
 	       formula))

     formula))
@@ -36,4 +105,4 @@
 (defn transform-cnf
   "Takes a formula in clojure code and produces the cnf of it"
   [formula]
-  (-> formula only-and-or-not))+  (-> formula only-and-or-not not-atoms-only))


fix check for parsing and emptyness

fix check for parsing and emptyness

--- src/babel/italiano/benchmark.cljc
+++ src/babel/italiano/benchmark.cljc
@@ -31,8 +31,8 @@
                                                          :synsem {:cat :verb}}))]
                                (println (str "generated: " (fo expr)))
                                (println (str "starting parsing.."))
-                               (let [parsed (time (take 1 (parse (fo expr))))
-                                     parses (reduce concat (map :parses parsed))]
+                               ;; take the first parse in order to force evaluation of parsing so that (time ..)'s return value is meaningful.
+                               (let [parses (time (take 1 (reduce concat (map :parses (parse (fo expr))))))]
                                  (if (empty? parses)
                                    (throw (exception (str "could not parse: " (fo expr) " with semantics:"
                                                           (strip-refs (get-in expr [:synsem :sem]))))))


Reduced calls to flatten.

Reduced calls to flatten.

--- src/blutwurst/tuple_generator.clj
+++ src/blutwurst/tuple_generator.clj
@@ -90,8 +90,9 @@
        (trace "Dependency selectors: " dependency-selectors)
     (fn []
      (apply hash-map
-      (concat (flatten (map #(%) dependency-selectors))
-              (flatten (map (fn [a] (list (-> a :column :name keyword) ((:generator a) (:column a)))) value-generators))))
+      (flatten (concat (map #(%) dependency-selectors)
+                       (map (fn [a] (list (-> a :column :name keyword) ((:generator a) (:column a)))) value-generators)
+              )))
     )
   ))


Allow script patches by applying deep-merge

--- src/cider_ci/dispatcher/trial.clj
+++ src/cider_ci/dispatcher/trial.clj
@@ -13,6 +13,7 @@
     [clj-logging-config.log4j :as logging-config]
     [clojure.java.jdbc :as jdbc]
     [clojure.tools.logging :as logging]
+    [cider-ci.utils.map :as map :refer [deep-merge]]
     ))

@@ -43,24 +44,32 @@
     (assert task-id)
     (task/evaluate-and-create-trials {:id task-id})))

+(defn compute-update-params [params id]
+  (conj {}
+        (select-keys params
+                     [:error :finished_at :result
+                      :started_at :state ])
+        (when-let [params-scripts (:scripts params)]
+          (let [trial (get-trial id)]
+            {:scripts (deep-merge (:scripts trial)
+                                  params-scripts)}))))
+
 (defn update [params]
   (catcher/wrap-with-suppress-and-log-warn
     (let [id (:id params)]
       (try
         (assert id)
-        (let [update-params (select-keys params
-                                         [:error :finished_at :result
-                                          :scripts :started_at :state ])]
+        (let [update-params (compute-update-params params id)]
           (jdbc/update! (rdbms/get-ds)
                         :trials update-params
-                        ["id = ?" id])
-          (dispatch-update (select-keys params [:id :task_id])))
+                        ["id = ?" id]))
         (catch Exception e
           (jdbc/update! (rdbms/get-ds)
                         :trials
                         {:state "failed"
                          :error (thrown/stringify e)}
-                        ["id = ?" id])
+                        ["id = ?" id]))
+        (finally
           (dispatch-update (select-keys params [:id :task_id])))))))


Actually fixed merge conflicts

Actually fixed merge conflicts

--- src/clj/forma/trends/analysis.clj
+++ src/clj/forma/trends/analysis.clj
@@ -92,21 +92,19 @@
     (for [x (range start-index (inc end-index))]
       (subvec base-vec 0 x))))

-<<<<<<< HEAD
+;; Functions to collect cleaning functions for use in the trend
+;; feature extraction
+
 (defn fake-deseasonalize
   [series freq]
   series)
-=======
-;; Functions to collect cleaning functions for use in the trend
-;; feature extraction
->>>>>>> upstream/develop

 (defn clean-trend
-  "Filter out bad values and remove seasonal component for a spectral
+  "Interpolate over bad values and remove seasonal component for a spectral
   time series (with frequency `freq`) using information in an
   associated reliability time series. Conditions check first whether series
   contains all bad or all good values, and returns nil or the original series,
-  respectively"
+  respectively."
   [freq spectral-ts reli-ts]
   (let [good-set #{1 0}
         bad-set #{255 3 2}
@@ -128,21 +126,7 @@
        (lengthening-ts start-idx end-idx spectral-ts)
        (lengthening-ts start-idx end-idx reli-ts)))

-<<<<<<< HEAD
-(defn telescoping-long-trend
-  "returns a three-tuple with the trend coefficient, trend t-stat, and
-  the hansen statistic for each period between `start-idx` (inclusive)
-  and `end-idx` (inclusive)."
-  [freq start-idx end-idx spectral-ts reli-ts cofactor-ts]
-  (let [params [freq start-idx end-idx spectral-ts reli-ts]
-        clean-ts (apply clean-timeseries params)
-        cofactor-tele (lengthening-ts start-idx end-idx cofactor-ts)]
-    (map flatten
-         (transpose [(map hansen-stat clean-ts)
-                     (map long-stats clean-ts cofactor-tele)]))))
-=======
 ;; Short-term trend characteristic; supporting functions
->>>>>>> upstream/develop

 (defn trend-mat
   "returns a (`len` x 2) matrix, with first column of ones; and second
@@ -188,8 +172,6 @@
   (map (partial grab-trend (hat-mat block-len))
        (moving-subvec block-len
                       (i/matrix (clean-trend freq spectral-ts reli-ts)))))
-
-

 ;; Collect the long- and short-term trend characteristics


re-enable Haarpsichord Studios by adding identity subtitle

--- src/clj/game/cards-identities.clj
+++ src/clj/game/cards-identities.clj
@@ -83,7 +83,7 @@
    "GRNDL: Power Unleashed"
    {:effect (effect (gain :credit 5 :bad-publicity 1))}

-   "Haarpsichord Studios"
+   "Haarpsichord Studios: Entertainment Unleashed"
    {:events {:pre-steal-cost {:req (req (:stole-agenda runner-reg))
                               :effect (effect (prevent-steal))}}}


Remove dead import

Remove dead import

--- src/clj/lambdacd/steps/status.clj
+++ src/clj/lambdacd/steps/status.clj
@@ -1,6 +1,5 @@
 (ns lambdacd.steps.status
-  (:require [lambdacd.util :as util]
-            [lambdacd.util.internal.map :as map-util]))
+  (:require [lambdacd.util.internal.map :as map-util]))

 (defn- all [statuses status]
   (every? #(= % status) statuses))


Fix api-panel children needs to be inlined with the for.

--- src/cljs/cljs_repl_web/views.cljs
+++ src/cljs/cljs_repl_web/views.cljs
@@ -482,14 +482,14 @@
       [h-box
        :size "1 1 auto"
        :gap "10px"
-       :children [(for [sections (partition-all (if (zero? (rem secs @cols))
-                                                  (quot secs @cols)
-                                                  (inc (quot secs @cols))) sections)]
-                    ^{:key sections} [v-box
-                                      :size (str "0 1 " (quot 100 @cols) "%")
-                                      :gap "10px"
-                                      :children (for [section sections]
-                                                  [api-section section])])]])))
+       :children (for [sections (partition-all (if (zero? (rem secs @cols))
+                                                 (quot secs @cols)
+                                                 (inc (quot secs @cols))) sections)]
+                   ^{:key sections} [v-box
+                                     :size (str "0 1 " (quot 100 @cols) "%")
+                                     :gap "10px"
+                                     :children (for [section sections]
+                                                 [api-section section])])])))

 )


Place results into app-state

Place results into app-state

--- src/cljs/onyx_dashboard/core.cljs
+++ src/cljs/onyx_dashboard/core.cljs
@@ -9,15 +9,15 @@
             [om-bootstrap.random :as r]
             [om-bootstrap.input :as i]
             [om-bootstrap.table :refer [table]]
-            [cljs.core.async :as async :refer (<! >! put! chan)]
+            [cljs.core.async :as async :refer [<! >! put! chan]]
             [cljs-uuid.core :as uuid]
-            [taoensso.sente  :as sente :refer (cb-success?)])
-  (:require-macros [cljs.core.async.macros :as asyncm :refer (go go-loop)]))
+            [taoensso.sente  :as sente :refer [cb-success?]])
+  (:require-macros [cljs.core.async.macros :as asyncm :refer [go go-loop]]))

 (enable-console-print!)

 (defonce app-state (atom {:text "Hello Chestnut!"
-                          :replica {}}))
+                          :tracking {}}))

 (let [{:keys [chsk ch-recv send-fn state]}
       (sente/make-channel-socket! "/chsk" {:type :auto})]
@@ -32,21 +32,15 @@
   (let [[msg-type msg] event]
     (case msg-type
       :chsk/recv
-      (println "Recv event " event)
+      (let [[recv-type recv-msg] msg]
+        (println "Recv event " event)
+        (case recv-type
+          :cluster/replica
+          (swap! app-state assoc :tracking recv-msg)
+          (println "Unhandled recv-type: " recv-type)))
       :chsk/state (when (:first-open? msg)
                     (chsk-send! [:cluster/track cluster-id])
                     (println "First opened: " event)))))
-
-; (defn- event-handler [{:keys [event]}]
-;   (match event
-;          [:chsk/state new-state]
-;          (match [new-state]
-;                 [{:first-open? true}]
-;                 (chsk-send! [:onyx.job/list])
-;                 :else
-;                 (println "Unmatched state change: " new-state))
-;          [:chsk/recv payload] (handle-payload payload)
-;          :else (print "Unmatched event: %s" event)))

 (sente/start-chsk-router! ch-chsk event-handler)


Revert "Try another approach to hiding the completion window"

This reverts commit 9d13c49130bb8535c54ad33b1e1c9ddf74116120.

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -405,8 +405,7 @@
                   condition JComponent/WHEN_FOCUSED]
               (.processKeyBinding text-area ks e condition true))
             (.consume e))
-          (doseq [w (.getOwnedWindows @ui/root)]
-            (.setVisible w false)))))))
+          (.hideChildWindows completer))))))

 (defn create-console
   ([path]


Delete now-dead code.

Delete now-dead code.

--- src/midje/sweet.clj
+++ src/midje/sweet.clj
@@ -4,8 +4,7 @@
   (:use clojure.test
         [clojure.contrib.ns-utils :only [immigrate]]
         [clojure.contrib.pprint :only [pprint]]
-        [clojure.contrib.seq :only [separate]]
-        clojure.contrib.condition)
+        [clojure.contrib.seq :only [separate]])

   (:use [midje production-mode metaconstants]
         midje.midje-forms.recognizing
@@ -39,27 +38,22 @@
 (defmacro fact [& forms]
   (when (user-desires-checking?)
     (try
-      (handler-case :type
-        (set-fallback-line-number-from &form)
-        (let [[background remainder] (separate-background-forms forms)]
-          (if (empty? background)
-            (let [things-to-run (-> remainder
-                                    add-line-numbers
-                                    translate-fact-body
-                                    unfold-prerequisites)]
-              (define-metaconstants things-to-run)
-              (multiwrap (midjcoexpand `(every? true? (list ~@things-to-run)))
-                         (forms-to-wrap-around :facts)))
-            `(against-background ~background (midje.sweet/fact ~@remainder))))
-        (catch Exception ex
-          `(do (clojure.test/report {:type :exceptional-user-error
-                                     :macro-form '~&form
-                                     :exception-lines '~(user-error-exception-lines ex)
-                                     :position (midje.util.file-position/line-number-known ~(:line (meta &form)))})
-               false))
-        (handle :user-error
-          (println "HI"))))))
-
+      (set-fallback-line-number-from &form)
+      (let [[background remainder] (separate-background-forms forms)]
+        (if (empty? background)
+          (let [things-to-run (-> remainder
+                                  add-line-numbers
+                                  translate-fact-body
+                                  unfold-prerequisites)]
+            (define-metaconstants things-to-run)
+            (multiwrap (midjcoexpand `(every? true? (list ~@things-to-run)))
+                       (forms-to-wrap-around :facts)))
+          `(against-background ~background (midje.sweet/fact ~@remainder))))
+      (catch Exception ex
+        `(clojure.test/report {:type :exceptional-user-error
+                                   :macro-form '~&form
+                                   :exception-lines '~(user-error-exception-lines ex)
+                                   :position (midje.util.file-position/line-number-known ~(:line (meta &form)))})))))

 (defmacro facts [& forms]
   (with-meta `(fact ~@forms) (meta &form)))


add module-id for qa

add module-id for qa

--- src/picsou/qa.clj
+++ src/picsou/qa.clj
@@ -3,19 +3,21 @@
             [clojure.string :as strings]
             [cheshire.core :as j]))

-(defn go []
-  (let [all (j/parse-string (slurp "resources/export.json"))
-        en (get (first (filter #(= "fr" (% "body")) all)) "start")
+(defn go
+  ([module-id]
+   (let [all (j/parse-string (slurp "resources/export.json"))
+        en (get (first (filter #(= module-id
+                                   (keyword (str (% "body") "$core"))) all)) "start")
         ;en (take 100 en)
         results (for [[phrase start' end'] en :when (<= end' (count phrase))]
                   (let [s (strings/trim (subs phrase start' end')) ;remove whitespaces
-                        {:keys [winners] :as res} (p/parse s p/default-context :en$core [{:dim :time :label "T"}])
+                        {:keys [winners] :as res} (p/parse s p/default-context module-id [{:dim :time :label "T"}])
                         {:keys [start end value] :as first-winner} (first winners)
                         covers? (and start
                                      (= 0 start)
                                      (= (count s) end))]
                     [s covers? value]))
         ko (remove second results)]
-    (printf "%d/%d passing\n" (- (count results) (count ko)) (count results))
-    (doseq [r ko]
-      (printf "%-40s %s\n" (first r) (-> r last :start)))))+     (printf "%d/%d passing\n" (- (count results) (count ko)) (count results))
+     (doseq [r ko]
+      (printf "%-40s %s\n" (first r) (-> r last :start))))))


macros being evil

macros being evil

--- src/runtime/q.clj
+++ src/runtime/q.clj
@@ -172,7 +172,31 @@
          (. ~(with-meta o {:tag class})
             (~method ~@args))))))

-
+(defmacro rethro
+  [ex]
+  `(thro ~ex)
+  )
+
+
+(do
+ (clojure.core/cond
+  (clojure.core/and
+   (clojure.core/instance? java.lang.Class t)
+   (clojure.core/contains?
+    (clojure.core/supers t)
+    java.lang.Throwable))
+  (throw (runtime.q/newClass t (clojure.core/str)))
+  (clojure.core/instance? java.lang.Throwable t)
+  (throw t)
+  :else
+  (throw
+   (new
+    java.lang.RuntimeException
+    (clojure.core/str
+     "you must pass a class2 to `"
+     'thro
+     "` at "
+     '{:line 1, :column 40})))))

 (defmacro thro
 "
@@ -181,24 +205,39 @@
   [ex & restt]
   ;(class? java.lang.String)
   `(do
-     (when-not
+     (cond
+
+       ;if passed a class or symbol resolving to a class
        (and
          (instance? java.lang.Class ~ex)
          (contains?
            (supers ~ex)
            java.lang.Throwable
            )
-         )
+         )
+       ;then
+       (throw (newClass ~ex (str ~@restt)))
+
+       ;if passed an instance of an exception
+       (instance? java.lang.Throwable ~ex)
+       ;then throw it as it is
+       (throw ~ex)
+
+       ;none of the above
+       :else
        (throw
          (new RuntimeException
-              (str "you must pass a class to `" '~(first &form)
-                   "` at " '~(meta &form)
-                   )
+              (str
+                "you must pass a class/instance to `"
+                '~(first &form)
+                "` at "
+                '~(meta &form)
+                )
               )
          )
        )
      ;(let [cls# (getAsClass ~ex)]
-       (throw (newClass ~ex (str ~@restt)))
+
       ; )
      )
   )
@@ -991,7 +1030,7 @@
 (defn getUniqueFolder
   [& [in-path prefix suffix]]
   ;(delay
-    (do
+    (try
       (let [uniqueFile (getUniqueFile)
             ]
         (assumedTrue (.exists uniqueFile) (.isFile uniqueFile))
@@ -1002,6 +1041,11 @@
         (assumedTrue (.exists uniqueFile) (.isDirectory uniqueFile))
         uniqueFile
         )
+      (catch Throwable t
+        (do
+          (throw t)
+          )
+        )
       )
    ; )
   )


Make the peer bail on stop failures.

Make the peer bail on stop failures.

--- src/onyx/api.clj
+++ src/onyx/api.clj
@@ -111,7 +111,11 @@
                              (let [restart-ch (:dead-restart-tail-ch (:peer live))
                                    [v ch] (alts!! [stop-ch restart-ch] :priority true)]
                                (when (= ch stop-ch)
-                                 (component/stop live))))
+                                 (try
+                                   (component/stop live)
+                                   (catch Exception e
+                                     (warn e)
+                                     :stopped)))))
                            (catch Exception e
                              (warn e)
                              (warn "Virtual peer failed, backing off and rebooting...")


always with those debug prints ...

always with those debug prints ...

--- src/main/shadow/cljs/bootstrap/browser.cljs
+++ src/main/shadow/cljs/bootstrap/browser.cljs
@@ -55,7 +55,6 @@
     (do (swap! env/loaded-ref set/union provides)
         (swap! cljs/*loaded* set/union provides)
         (let [js (str text "\n//# sourceURL=" uri "\n")]
-          (js/console.log "load" js)
           (script-eval js)))))

 (defn queue-task! [task]


Comment out visualize-hb-state for how

Comment out visualize-hb-state for how

--- src/edu/berkeley/ai/domains/hybrid_blocks.clj
+++ src/edu/berkeley/ai/domains/hybrid_blocks.clj
@@ -182,7 +182,6 @@

 (set! *warn-on-reflection* false)

-)

 (defn animate-hb-seq [env action-names delay-ms]
   (visualize-hb-state
@@ -205,6 +204,7 @@
 ;			  (hs/applicable-quasi-actions s as))
 ;			 as)))
 	       (dec n-steps))))))
+)

 (comment


Add missing character escaping

Add missing character escaping


Add view showing all usage; add separate usage-view; private fn


drop default cassandra version to 2

drop default cassandra version to 2


c in button/tab isn't adding value

c in button/tab isn't adding value

--- frontend/components/build.cljs
+++ frontend/components/build.cljs
@@ -59,7 +59,7 @@
           [:a.container-selector
            {:on-click #(put! controls-ch [:container-selected {:container-id container-id}])
             :class (container-model/status->classes status)}
-           (str "C" (:index container))
+           (str (:index container))
            (case status
              :failed [:i.fa.fa-times]
              :success [:i.fa.fa-check]


Latest ClojureScript

Latest ClojureScript

--- ClojureScript/project.clj
+++ ClojureScript/project.clj
@@ -1,7 +1,7 @@
 (defproject clik-clak-joe "0.1.0-SNAPSHOT"
   :description "React Native tic-tac-toe in ClojureScript"
   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/clojurescript "0.0-3058"]
+                 [org.clojure/clojurescript "0.0-3153"]
                  [org.omcljs/om "0.9.0-SNAPSHOT"]
                  [org.omcljs/ambly "0.1.0-SNAPSHOT"]]
   :plugins [[lein-cljsbuild "1.0.5"]]


Updating core Clojure function learning

Updating core Clojure function learning

--- Clojure-Core/clojure_core.clj
+++ Clojure-Core/clojure_core.clj
@@ -1,3 +1,422 @@
 ; Clojure Core Library - Exploring the `clojure.core`, in detail

 ; Ref: https://clojuredocs.org/core-library
+
+; ------------------------------------------------------------------------------
+; Thinking About Sequence and Abstraction
+
+;; One of the many benefits of Clojure is that it allows us to use the concept:
+;; 'programming to abstractions' - specifically, programming using the sequence
+;; and collection abstractions. Further, this opens the door to the evaluation
+;; of 'lazy sequences.'
+
+;; When we talk about programming to abstractions, we're really referring to
+;; the idea of an object, or data-structure, being an instance of an abstraction.
+;; If that object responds to "the core sequence operations (the functions 'first',
+;; 'rest', and 'cons')" we know it will also work with our mainstay higher-order
+;; functions ('map', 'filter', 'reduce', etc). In the words of Rich Hickey, the
+;; creator of Clojure, "having an open, and large, set of functions operate upon
+;; an open, and small, set of extensible abstractions is the key to algorithmic
+;; reuse and library interoperability".
+
+;; We can also refer back to the forward of Abelson and Sussman's SICP:
+;; "The simple structure and natural applicability of lists are reflected in
+;; functions that are amazingly nonidiosyncratic. In Pascal the plethora of
+;; declarable data structures induces a specialization within functions that
+;; inhibits and penalizes casual cooperation. It is better to have 100 functions
+;; operate on one data structure than to have 10 functions operate on 10 data structures."
+
+;; But...let's talk about sequence - that is, what is a sequence?
+
+;; We might say that a sequence is a 'collection of elements organized in
+;; linear order, as opposed to an unordered collection or a graph without
+;; a before-and-after relationship between its nodes.'
+
+;; Going back to our Clojure basics, the following data-structures all implement
+;; the sequence abstraction: lists, maps, vectors, and sets
+
+;; Given this principle:
+(defn metalize-your-startup
+  [startup-service]
+  (str
+   "If you love Twitter? You'll love Footsteps of Odin, an agile company "
+   "that is reimagining " startup-service " for fans of doom and speed metal."))
+
+; Vector
+(map metalize-your-startup ["Scrapbooking" "Woodworking"])
+
+; List
+(map metalize-your-startup '("Crocheting" "Competitive Hot Dog Eating"))
+
+; Set
+(map metalize-your-startup #{"Gardening" "Flyfishing"})
+
+; Map (map f) (map f coll) (map f c1 c2) (map f c1 c2 c3) (map f c1 c2 c3 & colls)
+
+(map #(metalize-your-startup (second %)) {:unusual-hobby "Extreme Ironing"})
+
+;; Taking a look at the three core functions that define a sequence, we'll
+;; build up a working understanding of these by using them to build the
+;; higher-order function 'map' with them. Along the way, we'll contrast
+;; a sequence against the JavaScript implementation of a linked list.
+
+;; Remember, "all Clojure asks is 'can I 'first', 'rest', and 'cons' it?'
+;; If the answer is yes, you can use the seq library with that data structure.
+
+var node1 = {
+  value: 'first',
+  next: node2
+};
+
+var node2 = {
+  value: 'middle',
+  next: node3
+};
+
+var node3 = {
+  value: 'last',
+  next: null
+};
+
+var first = function (node) {
+  return node.value;
+};
+
+var rest = function (node) {
+  return node.next;
+};
+
+var cons = function (newValue, node) {
+  return {
+    value: newValue,
+    next: node
+  };
+};
+
+first(node1);
+; //=> "first"
+
+first(rest(node1));
+; //=> "middle"
+
+first(rest(rest(node1)));
+; //=> "last"
+
+var node0 = cons("new first", node1);
+first(node0);
+; //=> "new first"
+
+first(rest(node0));
+; //=> "first"
+
+;; Implementing map using 'first', 'rest', and 'cons':
+var map = function (list, transformFn) {
+  if (list === null) {
+    return null;
+  } else {
+    return cons(transformFn(first(list)), map(rest(list), transformFn));
+  }
+}
+
+var arrayFirst = function (array) {
+  return array [0]
+};
+
+var arrayRest = function (array) {
+  var sliced = array.slice (1, array.length);
+  if (sliced.length === 0) {
+    return null;
+  } else {
+    return sliced;
+  }
+};
+
+var arrayCons = function (newValue, array) {
+  return [newValue].concat(array);
+};
+
+var list = ["Putrid Nightmare", "Darkness of the Beast"];
+map(list, function (val) { return val + " mapped!"})
+; //=> ["Putrid Nightmare mapped!", "Darkness of the Beast mapped!"]
+
+; Enough JavaScript for now! Back to Clojure! :)
+
+(seq '(1 2 3))
+; => (1 2 3)
+
+(seq [1 2 3])
+; => (1 2 3)
+
+(seq #{1 2 3})
+; => (1 2 3)
+
+(seq {:name "Lemmy" :occupation "Rock and Roll Demigod"})
+; => ([:name "Lemmy"] [:occupation "Rock and Roll Demigod"])
+
+;; In the above examples, we apply seq to an argument (i.e., a data-structure)
+;; and our return value looks and behaves like a list
+
+(into {} (seq {:a 1 :b 2 :c 3}))
+; => {:a 1 :b 2 :c 3}
+
+;; Applying the into function with two args (an empty data-structure, and an
+;; application of seq against a populated data-structure) will undo the effect
+;; of seq (i.e., taking the "listed" map and returning the original map structure)
+
+; ------------------------------------------------------------------------------
+; Seq Function Examples
+
+; Map
+
+;; We've already looked at map in-depth, but map can also be extended to handle
+;; the following:
+;; (1) taking multiple collections as arguments
+;; (2) taking a collection of functions as an argument
+
+(map str ["a" "b" "c"] ["A" "B" "C"])
+; => ("aA" "bB" "cC")
+
+;; When we pass multiple arguments to map, our transform function must be capable
+;; of taking arguments equal to the number we supply.
+
+;; Here, behind the scenes, it's as if:
+(list (str "a" "A") (str "b" "B") (str "c" "C"))
+
+;; Another example of passing multiple collections:
+(def nigel-tufnels-volume [11 11 11 11 11])
+(def everyone-elses-volume [10 10 10 10 10])
+(defn unify-amp-volume-data
+  [nigel others]
+  {:nigel-tufnel nigel
+   :everyone-else others})
+
+(map unify-amp-volume-data nigel-tufnels-volume everyone-elses-volume)
+;; ({:nigel-tufnel 11, :everyone-else 10}
+;;  {:nigel-tufnel 11, :everyone-else 10}
+;;  {:nigel-tufnel 11, :everyone-else 10}
+;;  {:nigel-tufnel 11, :everyone-else 10}
+;;  {:nigel-tufnel 11, :everyone-else 10})
+
+;; An example of operating on a single collection with multiple functions
+(def sum #(reduce +  %))
+(def avg #(/ (sum %) (count %)))
+(defn stats
+  [numbers]
+  (map #(% numbers) [sum count avg]))
+
+(stats [6 6 6])
+; => (18 3 6)
+
+;; Finally, a very common usage of map is to "retrieve the value associated with
+;; a keyword from a collection of map data structures...because keywords can be
+;; used as functions, you can do this succinctly"
+
+(def metal-stage-names
+  [{:alias "Alice Cooper" :real "Vincent Damon Furnier"}
+   {:alias "Dio" :real "Ronald James Padavona"}
+   {:alias "Slash" :real "Saul Hudson"}
+   {:alias "Quorthon" :real "Thomas Borje Forsberg"}])
+
+(map :real metal-stage-names)
+; => ("Vincent Damon Furnier" "Ronald James Padavona" "Saul Hudson" "Thomas Borje Forsberg")
+
+; Reduce (reduce f coll) (reduce f val coll)
+
+;; As we saw before, reduce processes each element in a sequence
+;; and builds a result, but we can use reduce to other ends, as well.
+
+;; Here, we transform a map's values, producing a new map with
+;; the same keys but with updated values
+
+;; Instead of writing this (NOTE: (assoc map key val):
+(assoc (assoc {} :max (inc 30))
+       :min (inc 10))
+
+;; We can write this:
+(reduce (fn [new-map [key val]]
+          (assoc new-map key (inc val)))
+        {}
+        {:max 30 :min 10})
+; => {:max 31, :min 11}
+
+;; Another use of reduce can be filtering out keys from a map based on their value:
+(reduce (fn [new-map [key val]]
+          (if (val > 4)
+            (assoc new-map key val)
+            new-map))
+        {}
+        {:human 4.1
+         :critter 3.9})
+; => {:human 4.1}
+
+; ------------------------------------------------------------------------------
+; TODO: (1) Implement `map` (2) `filter` and (3) `some` using `reduce`
+; ------------------------------------------------------------------------------
+
+; Take (take n) (take n coll)
+; Take-While (take-while pred) (take-while pred coll)
+; Drop (drop n) (drop n coll)
+; Drop-While (drop-while pred) (drop-while pred coll)
+
+(take 2 [6 6 6])
+; => (6 6)
+
+(drop 2 [6 6 6])
+; => (6)
+
+(def rock-journal
+  [{:month 1 :day 6 :band "The Velvet Underground" :venue "CBGB"}
+   {:month 1 :day 6 :band "Misfits" :venue "CBGB"}
+   {:month 2 :day 6 :band "Alice In Chains" :venue  "Crocodile Cafe"}
+   {:month 2 :day 6 :band "Neil Young" :venue "Fillmore Auditorium West"}
+   {:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+   {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"}
+   {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+   {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"}])
+
+(take-while #(< (:month %) 3) rock-journal)
+; => ({:month 1, :day 6, :band "The Velvet Underground", :venue "CBGB"}
+; =>  {:month 1, :day 6, :band "Misfits", :venue "CBGB"}
+; =>  {:month 2, :day 6, :band "Alice In Chains", :venue "Crocodile Cafe"}
+; =>  {:month 2, :day 6, :band "Neil Young", :venue "Fillmore Auditorium West"})
+
+(drop-while #(< (:month %) 3) rock-journal)
+; => ({:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+; =>  {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"}
+; =>  {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+; =>  {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"})
+
+(take-while #(< (:month %) 4)
+            (drop-while #(< (:month %) 2) rock-journal))
+; => ({:month 2 :day 6 :band "Alice In Chains" :venue  "Crocodile Cafe"}
+; =>  {:month 2 :day 6 :band "Neil Young" :venue "Fillmore Auditorium West"}
+; =>  {:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+; =>  {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"})
+
+; Filter (pred) (pred coll)
+; Some (pred coll)
+
+(def rock-journal
+  [{:month 1 :day 6 :band "The Velvet Underground" :venue "CBGB"}
+   {:month 1 :day 6 :band "Misfits" :venue "CBGB"}
+   {:month 2 :day 6 :band "Alice In Chains" :venue  "Crocodile Cafe"}
+   {:month 2 :day 6 :band "Neil Young" :venue "Fillmore Auditorium West"}
+   {:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+   {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"}
+   {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+   {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"}])
+
+(filter #(= (:venue %) "CBGB") rock-journal)
+; => ({:month 1 :day 6 :band "The Velvet Underground" : venue "CBGB"}
+; =>  {:month 1 :day 6 :band "Misfits" :venue "CBGB"})
+
+(take-while #(> (:month %) 3) rock-journal)
+; =>  {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+; =>  {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"})
+
+;; NOTE: filter is useful, but remember it processes all the data -
+;; take-while on the other hand doesn't have to process all data
+;; before returning a value
+
+;; Closely related to filter is the some function, which returns the first
+;; truthy value (any value not false or nil) returned by a predicate (
+;; i.e., filter criteria) function
+
+
+(def rock-journal
+  [{:month 1 :day 6 :band "The Velvet Underground" :venue "CBGB"}
+   {:month 1 :day 6 :band "Misfits" :venue "CBGB"}
+   {:month 2 :day 6 :band "Alice In Chains" :venue  "Crocodile Cafe"}
+   {:month 2 :day 6 :band "Neil Young" :venue "Fillmore Auditorium West"}
+   {:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+   {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"}
+   {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+   {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"}])
+
+(some #(> (:month %) 5) rock-journal)
+; => nil
+
+(some #(> (:month %) 3) rock-journal)
+; => true
+
+(def rock-journal
+  [{:month 1 :day 6 :band "The Velvet Underground" :venue "CBGB"}
+   {:month 1 :day 6 :band "Misfits" :venue "CBGB"}
+   {:month 2 :day 6 :band "Alice In Chains" :venue  "Crocodile Cafe"}
+   {:month 2 :day 6 :band "Neil Young" :venue "Fillmore Auditorium West"}
+   {:month 3 :day 6 :band "Guns N' Roses" :venue "The Troubadour"}
+   {:month 3 :day 6 :band "Motley Crue" :venue "Whisky A Go Go"}
+   {:month 4 :day 6 :band "R.E.M" :venue "The 40 Watt Club"}
+   {:month 4 :day 6 :band "The Sex Pistols" :venue "The 100 Club"}])
+
+(some #(and (> (:month %) 2) %) rock-journal)
+; => {:month 3, :day 6, :band "Guns N' Roses," :venue "The Troubadour"}
+
+; Sort (sort coll) (sort comp coll)
+; Sort-By (sort-by keyfn coll) (sort-by keyfn comp coll)
+
+(sort [666 641 695])
+; => (641 666 695)
+
+(sort-by count ["acdc" "bestial warlust" "pegazus" "wolfmother"])
+; => ("acdc" "pegazus" "wolfmother" "bestial warlust")
+
+; Concat (concat) (concat x) (concat x y) (concat x y  & zs)
+
+(concat [6] [6 6] [666])
+; => (6 6 6 666)
+
+(into [] (concat [6] [6] [6]))
+; => [6 6 6]
+
+;; NOTE: concat returns a lazy sequence representing the concatenation
+;; of the elements in the supplied collections
+
+
+; ------------------------------------------------------------------------------
+; Lazy Sequences
+
+;; A lazy sequence (or lazy seq) is a seq 'whose members aren't computed until
+;; you try to access them. Computing a seq's members is called realizing
+;; the seq. Deferring the computation until the moment it's needed makes your
+;; programs more efficient, and it has the surprising benefit of allowing
+;; you to construct infinite sequences.'
+
+; Demonstrating Lazy Seq Efficiency
+
+;; Task:
+;; It's the year 2022.
+;; We are in Mendig, Germany attending the Rock am Ring music festival.
+;; This show is for metalheads, but there's an imposter lurking about -
+;; a polka enthusiast!
+;; We need to find the polka fan in the crowd of 1 million hard rockers.
+
+;; Here's how we might do it:
+(def concert-audience
+  {0 {:has-tattoos? false :plays-accordian? false :name "Angus Lars Anthrax"}
+   1 {:has-tattoos? false :plays-accordian? false :name "Judas Jon Johannson"}
+   2 {:has-tattoos? true :plays-accordian? true :name "Ernst Van Streuselmeyer"}
+   3 {:has-tattoos? true :plays-accordian? false :name "Margot Gunnarschmitt"}})
+
+(defn metal-fan-details
+  [social-security-number]
+  (Thread/sleep 1000)
+  (get concert-audience social-security-number))
+
+(defn polka-enthusiast?
+  [record]
+  (and (:has-tattoos? record)
+       (:plays-accordian? record)
+       record))
+
+(defn identify-polka-enthusiast
+  [social-security-numbers]
+  (first (filter polka-enthusiast?
+                 (map metal-fan-details social-security-numbers))))
+
+;; Let's find out how much time it might take to compute our code:
+(time (metal-fan-details 0))
+; => "Elapsed time: 1005.303124 msecs"
+; => {:has-tattoos? false, :plays-accordian? false, :name "Angus Lars Anthrax"}
+
+(time (identify-polka-enthusiast (range 0 1000000)))


add some test about clojure function

add some test about clojure function

--- src/learnclojure/chapt1/core5.clj
+++ src/learnclojure/chapt1/core5.clj
@@ -35,7 +35,7 @@
   (even? 4))
 ;;可变参函数，下面函数中的rest被称为剩余参数
 (defn concat-rest
-  [x & rest]
+  [_ & rest]
   (apply str (butlast rest)))
 (concat-rest 1 2 3 4)
 ;;剩余参数可以像其他序列那样解构


Server now opens browser to URL

Server now opens browser to URL

--- src/leiningen/ring/run_server.clj
+++ src/leiningen/ring/run_server.clj
@@ -1,7 +1,7 @@
 (ns leiningen.ring.run-server
   (:use ring.adapter.jetty
         ring.middleware.stacktrace
-        ring.middleware.reload-modified))
+        [clojure.java.browse :only (browse-url)]))

 (defn- try-ports [func ports]
   (try (func (first ports))
@@ -12,8 +12,18 @@

 (def suitable-ports (range 3000 3011))

+(defn- jetty-server [handler port]
+  (if port
+    (run-jetty (wrap-stacktrace handler)
+               {:port port, :join? false})
+    (try-ports #(jetty-server handler %)
+               suitable-ports)))
+
 (defn run-server [handler port]
-  (if port
-    (do (println "Starting web server on port" port)
-        (run-jetty handler {:port port}))
-    (try-ports #(run-server handler %) suitable-ports)))
+  (let [server    (jetty-server handler port)
+        connector (first (.getConnectors server))
+        host      (or (.getHost connector) "0.0.0.0")
+        port      (.getPort connector)]
+    (println "Started server on port" port)
+    (browse-url (str "http://" host ":" port))
+    (.join server)))


security #7

security #7

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/browser/views.cljs
+++ src/status_im/ui/screens/browser/views.cljs
@@ -23,6 +23,12 @@
   (:require-macros
    [status-im.utils.slurp :refer [slurp]]
    [status-im.utils.views :as views]))
+
+(def timeout (atom {}))
+
+(defn debounce [event]
+  (when @timeout (js/clearTimeout @timeout))
+  (reset! timeout (js/setTimeout #(re-frame/dispatch event) 500)))

 (def browser-config-edn
   (slurp "./src/status_im/utils/browser_config.edn"))
@@ -59,6 +65,7 @@
    {:browser? true}
    [toolbar.view/nav-button
     (actions/close (fn []
+                     (when @timeout (js/clearTimeout @timeout))
                      (re-frame/dispatch [:navigate-back])
                      (when error?
                        (re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))))]
@@ -130,7 +137,7 @@
         :bounces                               false
         :local-storage-enabled                 true
         :render-error                          web-view-error
-        :on-navigation-state-change            #(re-frame/dispatch [:browser/navigation-state-changed % error?])
+        :on-navigation-state-change            #(debounce [:browser/navigation-state-changed % error?])
         :on-bridge-message                     #(re-frame/dispatch [:browser/bridge-message-received %])
         :on-load                               #(re-frame/dispatch [:browser/loading-started])
         :on-error                              #(re-frame/dispatch [:browser/error-occured])


started working on path finding from root to a given key

--- src/specly/core.clj
+++ src/specly/core.clj
@@ -369,6 +369,185 @@

+(s/def :fig-opt/housers1 string?)
+(s/def :fig-opt/housers2 string?)
+(s/def :fig-opt/housers3 string?)
+
+(s/def :fig-opt/house (strict-keys
+                       :opt-un [:fig-opt/housers1
+                                :fig-opt/housers2
+                                :fig-opt/housers3
+                                :fig-opt/car1]))
+
+(s/def :fig-opt/car1 string?)
+(s/def :fig-opt/car2 string?)
+(s/def :fig-opt/car3 string?)
+
+(s/def :fig-opt/car (strict-keys
+                      :opt-un [:fig-opt/car1
+                               :fig-opt/car2
+                               :fig-opt/car3]))
+
+(s/def :fig-opt/real (strict-keys
+                      :opt-un [:fig-opt/car
+                               :fig-opt/house]))
+
+;; this is really rough
+(defn seq-spec? [k]
+  {:pre [(keyword? k)]}
+  (s/regex? (spec-from-registry k)))
+
+(defn map-spec? [k]
+  {:pre [(keyword? k)]}
+  (prn k)
+  (#{'strict-keys 'keys}
+   (let [d (s/describe k)]
+     (and (sequential? d) (first d)))))
+
+(defn get-keys [k]
+  (->> k
+       s/describe
+       rest
+       (apply parse-keys-args)))
+
+;; we are dealing with a datatype
+;; a list of paths Monoid
+;; mempty   []
+;; mappend  cons
+;; mconcat  concat
+
+;; its also join and intersection
+;; join         set/union
+;; intersection set/intersection
+
+;; we need to cons a value to the head of each of the lists
+;; map-cons v list-of-paths
+
+;;
+
+
+(def empty-path-set #{})
+(def consable-empty-path-set #{[]})
+
+;; f -> PathSet -> PathSet
+(defn path-set-fmap [f path-set]
+  (into #{} (mapv f path-set)))
+
+(defn consable-path-set [path-set]
+  (or (not-empty path-set) consable-empty-path-set))
+
+(defn path-set-cons [v path-set]
+  (path-set-fmap #(cons v %) (consable-path-set path-set)))
+
+;; [PathSet] -> PathSet
+(defn path-set-join [list-of-path-sets]
+  (apply set/union list-of-path-sets))
+
+;; [PathSet] -> PathSet
+(defn path-set-intersect [list-of-path-sets]
+  (apply set/intersection list-of-path-sets))
+
+
+
+(defn key-paths [desc]
+  {:pre [(sequential? desc)]}
+  (let [{:keys [known-keys k->s]} (apply parse-keys-args (rest desc))]
+    (path-set-join
+     (map #(path-set-cons (hash-map :ky % :ky-spec (k->s %)) (poss-path (k->s %)))
+      known-keys))))
+
+;; DecribeKeyedVals -> [DecribeVal]
+(defn desc-keyed-vals [desc]
+  (vals (apply hash-map (rest desc))))
+
+;; DescribeVals -> [DescribeVal]
+(def desc-vals rest)
+
+
+(defn poss-path [desc]
+  #_(prn desc)
+  (if (and
+       (keyword? desc)
+       (spec-from-registry desc))
+    (poss-path (s/describe desc))
+    (condp = (and (sequential? desc)
+                  (first desc))
+      'keys (key-paths desc)
+      'strict-keys (key-paths desc)
+      'or    (path-set-join (map poss-path (desc-keyed-vals desc)))
+      ;; this is really the intersection paths
+      'and   (path-set-intersect (map poss-path (desc-vals desc)))
+
+      '*     (path-set-cons ::int-key (poss-path (second desc)))
+      '+     (path-set-cons ::int-key (poss-path (second desc)))
+      '?     (path-set-cons ::int-key (poss-path (second desc)))
+      'alt   (path-set-cons ::int-key
+                            (path-set-join (map poss-path (desc-keyed-vals desc))))
+
+
+      ;; cat is a splicing operation something without a numeric path is going to get one consed on
+
+
+
+
+      ;; 'cat
+      ;; else
+      empty-path-set
+
+      )))
+
+
+;; regex NOTE
+;; so every regex has an ::int-key because they index into a sequence
+;;
+
+;; all compond regex operators are splicing, meaning that they strip the :int-key off
+;; of the sub expression if they are regex
+;; this is the equivalent of concatenation something that was a sublist becomes part of the
+;; super list
+
+(re-matches #"((r+)*)?" "rrrrrrrr")
+
+(s/valid? (s/alt :hey even?
+                 :ouch even?) [4])
+
+(s/conform (s/cat :a even? :b (s/or :odd odd?
+                                    :even even?)) [4 3])
+
+
+(poss-path (s/describe (s/or :hi (s/or :hey :fig-opt/real)
+                                    :bye (s/or :son :fig-opt/car)
+                                    :lei (s/or :son :fig-opt/house))))
+
+(poss-path (s/describe (s/and ;:hi (s/or :hey :fig-opt/real)
+                             (s/or :son :fig-opt/car)
+                             (s/or :son :fig-opt/house))))
+
+(= (poss-path (s/describe (s/and :fig-opt/house)))
+   (poss-path (s/describe (s/or :son :fig-opt/house))))
+
+#_(poss-path (s/describe :fig-opt/real))
+
+(defn possible-paths [rk]
+  (cond (map-spec? rk)
+        (when-let [{:keys [known-keys keys->specs]} (not-empty (get-keys rk))]
+          (prn known-keys)
+          (mapcat (fn [k]
+                  (map #(cons k %)
+                       (or (not-empty (possible-paths (keys->specs k)))
+                           [[]])))
+               known-keys))))
+
+(comment
+  (seq-spec? :fig-opt/builds)
+  (s/describe :fig-opt/builds)
+
+  (possible-paths :fig-opt/car)
+
+
+  )
+
+
 (s/def :build-config/id (s/or :string string? :keyword keyword?))
 (s/def :build-config/source-paths (s/+ string?))
 (s/def :build-config/assert #(or (true? %) (false? %)))
@@ -381,7 +560,7 @@
 (s/def :fig-opt/http-server-root string?)
 (s/def :fig-opt/server-port      integer?)
 (s/def :fig-opt/server-ip        string?)
-(s/def :fig-opt/builds           (s/+ :fig-opt/build-config))
+(s/def :fig-opt/builds           (s/* :fig-opt/build-config))

 (s/def :project-top/figwheel (strict-keys
@@ -389,6 +568,9 @@
                                        :fig-opt/server-port
                                        :fig-opt/server-ip]
                               :req-un [:fig-opt/builds]))
+
+
+

 (comment


wip, if cljs.js ns required, add cljs/core.cljc as implicit dep

--- src/main/clojure/cljs/closure.clj
+++ src/main/clojure/cljs/closure.clj
@@ -535,8 +535,11 @@
   "Return an IJavaScript for this file. Compiled output will be
    written to the working directory."
   [opts {:keys [relative-path uri]}]
-  (let [js-file (comp/rename-to-js relative-path)]
-    (-compile uri (merge opts {:output-file js-file}))))
+  (let [js-file  (comp/rename-to-js relative-path)
+        compiled (-compile uri (merge opts {:output-file js-file}))]
+    (cond-> compiled
+      (= ["cljs.js"] (deps/-provides compiled))
+      (update-in compiled [:requires] conj ["cljs.core$macros"]))))

 (defn cljs-source-for-namespace
   "Given a namespace return the corresponding source with either a .cljs or
@@ -579,6 +582,10 @@
                    (IllegalArgumentException.
                      (str "Namespace " ns " does not exist"))))))))))))

+(defn compile-core-macros [opts]
+  (-compile (io/resource "cljs/core.cljc")
+    (merge opts {:output-file "core$macros.js"})))
+
 (defn cljs-dependencies
   "Given a list of all required namespaces, return a list of
   IJavaScripts which are the cljs dependencies. The returned list will
@@ -588,19 +595,21 @@

   Only load dependencies from the classpath."
   [opts requires]
-  (let [cljs-deps (fn [lib-names]
-                    (->> (remove #(or ((@env/*compiler* :js-dependency-index) %)
-                                    (deps/find-classpath-lib %))
-                           lib-names)
-                      (map cljs-source-for-namespace)
-                      (remove (comp nil? :uri))))]
+  (letfn [(cljs-deps [lib-names]
+            (->> lib-names
+              (remove #(or ((@env/*compiler* :js-dependency-index) %)
+                           (deps/find-classpath-lib %)))
+              (map cljs-source-for-namespace)
+              (remove (comp nil? :uri))))]
     (loop [required-files (cljs-deps requires)
-           visited (set required-files)
-           js-deps #{}]
+           visited        (set required-files)
+           js-deps        #{}]
       (if (seq required-files)
         (let [next-file (first required-files)
-              js (get-compiled-cljs opts next-file)
-              new-req (remove #(contains? visited %) (cljs-deps (deps/-requires js)))]
+              js        (if (= "cljs.core$macros" next-file)
+                          (compile-core-macros opts)
+                          (get-compiled-cljs opts next-file))
+              new-req   (remove #(contains? visited %) (cljs-deps (deps/-requires js)))]
           (recur (into (rest required-files) new-req)
                  (into visited new-req)
                  (conj js-deps js)))


Improve efficiency by using explicit take! and put! over go blocks

--- src/io/aviso/rook/async.clj
+++ src/io/aviso/rook/async.clj
@@ -24,7 +24,7 @@
   can be obtained without blocking."
   (:import (javax.servlet.http HttpServletResponse))
   (:require
-    [clojure.core.async :refer [chan go >! <! <!! >!! thread]]
+    [clojure.core.async :refer [chan go >! <! <!! >!! thread put! take!]]
     [clojure.tools.logging :as l]
     [clout.core :as clout]
     [ring.middleware
@@ -58,13 +58,13 @@

 (defmacro safe-go
-  "Wraps the body in a safety-first blocks and a go block. The request is used by safety-first if it must
+  "Wraps the body in a safety-first block and then in a go block. The request is used by safety-first if it must
   fabricate a response. Requires at least one expression."
   [request expr & more]
   `(go (safety-first ~request ~expr ~@more)))

 (defmacro safe-thread
-  "Wraps the body in a safety-first blocks and a thread block. The request is used by safety-first if it must
+  "Wraps the body in a safety-first block and then in a thread block. The request is used by safety-first if it must
   fabricate a response. Requires at least one expression."
   [request expr & more]
   `(thread (safety-first ~request ~expr ~@more)))
@@ -80,33 +80,36 @@
   nil is converted to false."
   [result]
   (let [ch (chan 1)]
-    (>!! ch (or result false))
+    (put! ch (or result false))
     ch))

 (defn ring-handler->async-handler
-  "Wraps a syncronous Ring handler function as an asynchrounous handler. The handler is invoked in another
+  "Wraps a syncronous Ring handler function as an asynchronous handler. The handler is invoked in another
    thread, and a nil response is converted to false."
   [handler]
   (fn [request]
     (safe-thread request (handler request))))
+
+(defn- routing*
+  [request response-ch handlers]
+  (if (empty? handlers)
+    ;; Resolve to false when running out of handlers.
+    (put! response-ch false)
+    ;; Otherwise, see if the first handler will return a truthy value
+    (take! (safety-first request ((first handlers) request))
+           (fn [handler-response]
+             (if handler-response
+               (put! response-ch handler-response)
+               (routing* request response-ch (rest handlers)))))))

 (defn routing
   "Routes a request to sequence of async handlers. Each handler should return a channel
   that contains either a Ring response map or false (nil is not an allowed value over a channel). Handlers
   are typically implemented using core.async go or thread blocks."
   [request & handlers]
-  (safe-go request
-    (loop [[handler & more] handlers]
-      (if handler
-        ;; Invoke the handler asynchronously and park until it responds.
-        (let [result-ch (handler request)
-              result (<! result-ch)]
-          ;; Again, a result of false means "continue the search".
-          (if-not (false? result)
-            result
-            (recur more)))
-        ;; And since there was no match yet, we signal to continue the search.
-        false))))
+  (let [response-ch (chan 1)]
+    (routing* request response-ch handlers)
+    response-ch))

 (defn routes
   "Creates an async handler that routes to a number of other async handlers."
@@ -125,11 +128,12 @@
   The function may return false to allow the search for a handler to continue.

   Asynchronous handler functions should be careful to return a 500 response if there is
-  a failure (e.g., a thrown exception).  For synchronous functions, a try block is provided
-  to generate the 500 response if an exception is thrown.
-
-  For a synchronous handler (which must have the :sync meta-data), the function
+  a failure (e.g., a thrown exception).  The safe-go and safe-thread macros
+  are useful to easily ensure this.
+
+  For a synchronous handler (which must have the :sync true meta-data), the function
   is invoked in a thread, and its result wrapped in a channel (with nil converted to false).
+  Exceptions thrown by a synchronous handler are automatically converted into a 500 response.

   If no resource handler function has been identified, this function
   will return false (wrapped in a channel)."
@@ -246,23 +250,27 @@
   ([handler]
    (wrap-restful-format handler [:json-kw :edn]))
   ([handler formats]
-   (let [req-handler (format-params/wrap-restful-params handler :formats formats)
-         req-handler' (fn [request]
-                        (safe-go request
-                                 (-> request req-handler <!)))]
+   (let [req-handler (format-params/wrap-restful-params handler :formats formats)]
      (fn [request]
-       (safe-go request
-                (if-let [response (-> request req-handler' <!)]
-                  (->
-                    ;; "Fake" handler. This is an ugly bit of hack to allow the execution
-                    ;; of the true handlers earlier in the go block, and have the response
-                    ;; (if not nil), already taken from the channel.
-                    (constantly response)
-                    (format-response/wrap-restful-response :formats formats)
-                    ;; And now we can invoke our "just brewed up" handler (wrapped around our
-                    ;; standin for the already executed handler).
-                    (as-> f (f request)))
-                  false))))))
+       (let [response-ch (chan 1)]
+         ;; To keep thing fully asynchronous, we first invoke the downstream handler.
+         (take! (try
+                   (req-handler request)
+                   (catch Throwable t
+                     (result->channel
+                       (utils/response HttpServletResponse/SC_INTERNAL_SERVER_ERROR
+                                       {:exception (exceptions/to-message t)}))))
+                (fn [handler-response]
+                  (put! response-ch
+                        (->
+                          ;; We can't pass the asynchronous req-handler to w-r-r, it expects
+                          ;; a sync handler. Instead, we provide a "fake" sync handler
+                          ;; that returns the previously obtained handler response.
+                          (constantly handler-response)
+                          (format-response/wrap-restful-response :formats formats)
+                          ;; Capture and invoke the wrapped, fake handler
+                          (as-> f (f request))))))
+         response-ch)))))

 (defn wrap-with-standard-middleware
   "Default asynchronous middleware."
@@ -282,8 +290,8 @@
    (let [options' (session/session-options options)]
      (fn [request]
        (safe-go request
-         (let [request' (session/session-request request options')]
-           (->
-             (handler request')
-             <!
-             (session/session-response request' options'))))))))+                (let [request' (session/session-request request options')]
+                  (->
+                    (handler request')
+                    <!
+                    (session/session-response request' options'))))))))


fix windows path issue

fix windows path issue

--- src/main/shadow/cljs/npm/cli.cljs
+++ src/main/shadow/cljs/npm/cli.cljs
@@ -185,7 +185,9 @@
         (fs/writeFileSync log-config-path
           (str (util/slurp (path/resolve js/__dirname ".." "default-log.properties"))
                "\njava.util.logging.FileHandler.pattern="
-               (path/join cache-root "shadow-cljs.log")
+               (-> (path/join cache-root "shadow-cljs.log")
+                   ;; don't generate windows paths \ will be treated as escape
+                   (str/replace "\\" "/"))
                "\n")))

       [(str "-Djava.util.logging.config.file=" log-config-path)]


fix renamed fn

fix renamed fn

--- src/pc/email.clj
+++ src/pc/email.clj
@@ -150,7 +150,7 @@
                                      " wants access to your document on Precursor")
                        :text (str "Hey there,\nSomeone wants access to your document on Precursor: " (urls/doc doc-id)
                                   "\nYou can grant or deny them access from the document's settings page.")
-                       :html (view/access-request-html doc-id requester)})))
+                       :html (view/document-access-request-html doc-id requester)})))

 (defn send-team-access-request-email [db access-request]
   (let [requester (:access-request/cust-ref access-request)


allow for international string date in transaction

--- test/clj_money/models/transactions_test.clj
+++ test/clj_money/models/transactions_test.clj
@@ -64,6 +64,13 @@
   (let [context (serialization/realize storage-spec create-context)
         transaction (transactions/create storage-spec (-> (attributes context)
                                                           (assoc :transaction-date "3/2/2016")))]
+    (is (validation/valid? transaction) "The transaction is valid")
+    (is (= (t/local-date 2016 3 2) (:transaction-date transaction)) "The transaction date is parsed correctly")))
+
+(deftest create-a-transaction-intl-string-date
+  (let [context (serialization/realize storage-spec create-context)
+        transaction (transactions/create storage-spec (-> (attributes context)
+                                                          (assoc :transaction-date "2016-03-02")))]
     (is (validation/valid? transaction) "The transaction is valid")
     (is (= (t/local-date 2016 3 2) (:transaction-date transaction)) "The transaction date is parsed correctly")))


Simplify build-no-missing-validators a bit

Remove some of the things we weren't actually using and skip some
intermediary let'ed vars that didn't really need to exist.

--- src/vip/data_processor/validation/v5/util.clj
+++ src/vip/data_processor/validation/v5/util.clj
@@ -79,35 +79,31 @@
                                  (->> (str/join ".")))]
         (fn [ctx]
           (log/info "Validating" :errors schema-type :missing)
-          (let [parents (map (comp #(.getValue %) :path)
-                             (korma/exec-raw
-                              (:conn postgres/xml-tree-values)
-                              ["SELECT DISTINCT subltree(path, 0, CAST(? AS INT)) AS path
-                                FROM xml_tree_values
-                                WHERE results_id = ?
-                                AND simple_path <@ text2ltree(?)"
-                               [path-to-parent-nlevel import-id
-                                path-to-parent]]
-                              :results))
-                children (map (fn [r]
-                                {:parent (-> r :parent_path .getValue)
-                                 :child (-> r :child_path .getValue)})
-                              (korma/exec-raw
+          (let [expected (->> (korma/exec-raw
                                (:conn postgres/xml-tree-values)
-                               ["SELECT path AS child_path,
-                                        subltree(path, 0, CAST(? AS INT)) AS parent_path
+                               ["SELECT DISTINCT subltree(path, 0, CAST(? AS INT)) AS path
                                  FROM xml_tree_values
                                  WHERE results_id = ?
                                  AND simple_path <@ text2ltree(?)"
                                 [path-to-parent-nlevel import-id
-                                 path-to-children]]
-                               :results))
-                expected-parent-set (set parents)
-                found-parent-set (->> children (map :parent) set)]
-            (if (= expected-parent-set found-parent-set)
+                                 path-to-parent]]
+                               :results)
+                              (map (comp #(.getValue %) :path))
+                              set)
+                found (->> (korma/exec-raw
+                            (:conn postgres/xml-tree-values)
+                            ["SELECT subltree(path, 0, CAST(? AS INT)) AS path
+                              FROM xml_tree_values
+                              WHERE results_id = ?
+                              AND simple_path <@ text2ltree(?)"
+                             [path-to-parent-nlevel import-id
+                              path-to-children]]
+                            :results)
+                           (map (comp #(.getValue %) :path))
+                           set)]
+            (if (= expected found)
               ctx
-              (let [missing (set/difference expected-parent-set
-                                            found-parent-set)]
+              (let [missing (set/difference expected found)]
                 (reduce (fn [ctx path]
                           (let [missing-path (str path "."
                                                   (last xml-element-path))]


remove unnecessary service from test

remove unnecessary service from test

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

 (deftest test-debug
   (testing "debug mode is off by default"
-    (let [app (bootstrap-services-with-empty-config [(foo-test-service)])
+    (let [app (bootstrap-services-with-empty-config [])
           get-in-config (trapperkeeper/get-service-fn app :config-service :get-in-config)]
       (is (= false (get-in-config [:debug]))))))

   (testing "--debug puts TK in debug mode"
-    (let [app (bootstrap*-with-empty-config [(foo-test-service)] ["--debug"])
+    (let [app (bootstrap*-with-empty-config [] ["--debug"])
           get-in-config (trapperkeeper/get-service-fn app :config-service :get-in-config)]
       (is (= true (get-in-config [:debug])))))


Assert on all fields for users endpoint test.

--- test/time_tracker/users/functional_test.clj
+++ test/time_tracker/users/functional_test.clj
@@ -23,7 +23,8 @@
     (let [url "http://localhost:8000/api/users/"
           {:keys [status body]} (test-helpers/http-request :get url "gid1")]
       (is (= 200 status))
-      (is (= #{"gid1" "gid2"}
+      (is (= #{{"name" "sandy", "google-id" "gid1", "role" "admin"}
+               {"name" "shaaz", "google-id" "gid2", "role" "user"}}
              (->> body
-                  (map #(get % "google-id"))
-                  (set)))))))+                  (map #(select-keys % ["name ""google-id" "role"]))
+                  (set)))))))


Add comment about `map-keys` and `map-vals`


Forgot to include ecoregion in output ...

--- src/clj/forma/hadoop/jobs/forma.clj
+++ src/clj/forma/hadoop/jobs/forma.clj
@@ -483,7 +483,7 @@

 (defn probs-gadm2
   [probs-src gadm2-src static-src]
-  (<- [?s-res ?mod-h ?mod-v ?sample ?line ?start-final ?merged-series ?gadm2]
+  (<- [?s-res ?mod-h ?mod-v ?sample ?line ?start-final ?merged-series ?gadm2 ?ecoid]
       (probs-src ?s-res ?mod-h ?mod-v ?sample ?line ?start-final ?merged-series)
       (gadm2-src ?s-res ?mod-h ?mod-v ?sample ?line ?gadm2)
       (static-src ?s-res ?mod-h ?mod-v ?sample ?line _ _ ?ecoid _ _)))


Add support for partitionAggregate to trident DSL

--- src/clj/marceline/storm/trident.clj
+++ src/clj/marceline/storm/trident.clj
@@ -415,6 +415,18 @@
                        state-updater
                        (apply fields out-fields))))

+(defn partition-aggregate
+  ([stream agg fn-fields]
+   (.partitionAggregate stream
+                        agg
+                        (apply fields fn-fields)))
+  ([stream in-fields agg fn-fields]
+   (.partitionAggregate stream
+                        (apply fields in-fields)
+                        agg
+                        (apply fields fn-fields))))
+
+
 (defn persistent-aggregate
   ([stream state fn-inst fn-fields]
      (.persistentAggregate stream


Fix not dereferencing the counter atom

Fix not dereferencing the counter atom

--- src/cljs/comic_reader/handlers.cljs
+++ src/cljs/comic_reader/handlers.cljs
@@ -90,9 +90,11 @@
                   (* @scroll-threshold document-height))
              (do
                (swap! counter inc)
-               (swap! scroll-threshold + (/ 1
-                                            (.pow js/Math
-                                                  2 counter)))
+               (swap! scroll-threshold
+                      +
+                      (/ 1
+                         (.pow js/Math
+                               2 @counter)))
                (get-next-image db))
              db))
          db))))


add option to download data as JSON

add option to download data as JSON

--- src/cljs/tictag/views/settings.cljs
+++ src/cljs/tictag/views/settings.cljs
@@ -173,12 +173,28 @@
                  :filter-box? true
                  :on-change #(dispatch [:settings/changed-timezone %])]]]))

+(defn download []
+  (let [pings (subscribe [:raw-pings])
+        blob  (js/Blob. #js [(js/JSON.stringify (clj->js @pings))] #js {:type "text/json"})
+        url   (.createObjectURL js/window.URL blob)]
+    [re-com/v-box
+     :children [[re-com/title :level :level1 :label "Download your data"]
+                [re-com/box
+                 :child [:label
+                         [:a {:download "tictag.json"
+                              :href url}
+                          [:span.rc-button.btn.btn-default
+                           [:i.zmdi.zmdi-cloud-download {:style {:cursor :pointer
+                                                                 :margin-right "1em"}}]
+                           "Download"]]]]]]))
+
 (defn settings []
   (let [auth-user (subscribe [:authorized-user])]
     [re-com/v-box
-     :children [[timezone]
+     :children [[slack]
+                [beeminder]
+                [timezone]
                 [tagtime-import]
-                [beeminder]
-                [slack]]]))
-
-
+                [download]]]))
+
+


Added genome_uniform_crossover and fixed a couple of recently added instructions.

--- src/clojush/instructions/genome.clj
+++ src/clojush/instructions/genome.clj
@@ -471,7 +471,8 @@
              (pop-item :genome)
              (pop-item :genome)
              (push-item (vec (:genome (alternation
-                                        {:genome genome}
+                                        {:genome genome1}
+                                        {:genome genome2}
                                         (merge @push-argmap
                                                {:alternation-rate rate
                                                 :alignment-deviation dev}))))
@@ -488,8 +489,25 @@
         (->> (pop-item :genome state)
              (pop-item :genome)
              (push-item (vec (:genome (two-point-crossover
-                                        {:genome genome}
+                                        {:genome genome1}
+                                        {:genome genome2}
                                         @push-argmap)))
                         :genome)))
       state)))
+
+(define-registered
+  genome_uniform_crossover
+  ^{:stack-types [:genome]}
+  (fn [state]
+    (if (not (empty? (rest (:genome state))))
+      (let [genome1 (first (:genome state))
+            genome2 (second (:genome state))]
+        (->> (pop-item :genome state)
+             (pop-item :genome)
+             (push-item (vec (:genome (uniform-crossover
+                                        {:genome genome1}
+                                        {:genome genome2}
+                                        @push-argmap)))
+                        :genome)))
+      state)))
 ;; @@


Removed old data sources ns.

Removed old data sources ns.

--- src/cmr_edsc_stubs/data/sources.clj
+++ src/cmr_edsc_stubs/data/sources.clj
@@ -1,49 +0,0 @@
-(ns cmr-edsc-stubs.data.sources
-  (:require
-   [clojure.java.io :as io]
-   [cmr-edsc-stubs.util :as util])
-  (:import
-   (clojure.lang Keyword)))
-
-(def services-dir (util/get-file "data/services" :obj))
-(def variables-dir (util/get-file "data/variables" :obj))
-
-(defn get-ges-disc-provider
-  ([]
-    (get-ges-disc-provider :data))
-  ([^Keyword as-data]
-    (util/get-file "data/providers/GES_DISC.json" as-data)))
-
-(defn get-ges-disc-airx3std-collection
-  ([]
-    (get-ges-disc-airx3std-collection :xml))
-  ([^Keyword file-type]
-    (case file-type
-      :json (util/get-file "data/collections/GES_DISC/AIRX3STD_006.json")
-      :xml (util/get-file "data/collections/GES_DISC/AIRX3STD_006.xml"))))
-
-(defn get-ges-disc-airx3std-opendap-service
-  []
-  (util/get-file "data/services/GES_DISC/AIRX3STD/OPeNDAP.json"))
-
-(defn get-ges-disc-airx3std-ch4-variable
-  ([filename-part]
-    (get-ges-disc-airx3std-ch4-variable filename-part :json))
-  ([filename-part ^Keyword file-type]
-    (get-ges-disc-airx3std-ch4-variable filename-part file-type :data))
-  ([filename-part ^Keyword file-type ^Keyword as-data]
-    (util/get-file
-      (format "data/variables/GES_DISC/AIRX3STD/CH4/CH4_%s.%s"
-              filename-part
-              (name file-type))
-      as-data)))
-
-(defn get-ges-disc-airx3std-ch4-variables
-  []
-  (util/get-files "data/variables/GES_DISC/AIRX3STD/CH4"))
-
-(defn get-ges-disc-airx3std-opendap-service
-  ([]
-    (get-ges-disc-airx3std-opendap-service [:json :edn]))
-  ([as-data]
-    (util/get-file "data/services/GES_DISC/AIRX3STD/OPeNDAP.json" as-data)))


add read/write helper fns

add read/write helper fns

--- src/com/cognitect/transit_cljs.cljs
+++ src/com/cognitect/transit_cljs.cljs
@@ -55,6 +55,9 @@
               :arrayBuilder (VectorBuilder.)
               :prefersStrings false}
          (clj->js opts)))))
+
+(def read [w str]
+  (.read w str))

 (deftype KeywordHandler []
   Object
@@ -165,3 +168,5 @@
                    false))}
           (clj->js (dissoc opts :handlers)))))))

+(defn write [w o]
+  (.write w o))


Experimental: Make issue-81-workround optional

--- src/taoensso/carmine/protocol.clj
+++ src/taoensso/carmine/protocol.clj
@@ -105,6 +105,8 @@
     ereqs)
   (.flush out))

+(def issue-81-workaround? true) ; Subject to `alter-var-root`
+
 (defn get-unparsed-reply
   "Implementation detail.
   BLOCKS to receive a single reply from Redis server and returns the result as
@@ -168,7 +170,7 @@
                   (let [payload (java.util.Arrays/copyOfRange ba 2 ba-size)]
                     ;; Workaround #81 (v2.6.0 may have written
                     ;; *serialized* bins:
-                    (if (and
+                    (if (and issue-81-workaround?
                          (>= (alength payload) 5) ; 4 byte NPY_ header + data
                          (== (aget payload 0) 78) ; N
                          (== (aget payload 1) 80) ; P


CMR-3254: Minor refactoring.

CMR-3254: Minor refactoring.

--- umm-spec-lib/src/cmr/umm_spec/test/iso19115_expected_conversion.clj
+++ umm-spec-lib/src/cmr/umm_spec/test/iso19115_expected_conversion.clj
@@ -183,26 +183,26 @@
   [umm-coll]
   (-> umm-coll
       fix-bounding-rectangles
-      (update-in [:SpatialExtent] update-iso-spatial)
+      (update :SpatialExtent update-iso-spatial)
       ;; ISO only supports a single tiling identification system
-      (update-in [:TilingIdentificationSystems] #(seq (take 1 %)))
-      (update-in [:TemporalExtents] expected-iso-19115-2-temporal)
+      (update :TilingIdentificationSystems #(seq (take 1 %)))
+      (update :TemporalExtents expected-iso-19115-2-temporal)
       ;; The following platform instrument properties are not supported in ISO 19115-2
       (update-in-each [:Platforms] update-in-each [:Instruments] assoc
                       :NumberOfSensors nil
                       :OperationalModes nil)
-      (update-in [:DataDates] expected-iso19115-data-dates)
+      (update :DataDates expected-iso19115-data-dates)
       (assoc :CollectionDataType nil)
-      (update-in [:DataLanguage] #(or % "eng"))
-      (update-in [:ProcessingLevel] su/convert-empty-record-to-nil)
-      (update-in [:Distributions] expected-iso-19115-2-distributions)
+      (update :DataLanguage #(or % "eng"))
+      (update :ProcessingLevel su/convert-empty-record-to-nil)
+      (update :Distributions expected-iso-19115-2-distributions)
       (update-in-each [:Projects] assoc :Campaigns nil :StartDate nil :EndDate nil)
-      (update-in [:PublicationReferences] iso-19115-2-publication-reference)
-      (update-in [:RelatedUrls] expected-iso-19115-2-related-urls)
+      (update :PublicationReferences iso-19115-2-publication-reference)
+      (update :RelatedUrls expected-iso-19115-2-related-urls)
       (update-in-each [:AdditionalAttributes] expected-iso19115-additional-attribute)
-      (update-in [:MetadataAssociations] group-metadata-assocations)
-      (update-in [:ISOTopicCategories] update-iso-topic-categories)
-      (update-in [:LocationKeywords] conversion-util/fix-location-keyword-conversion)
+      (update :MetadataAssociations group-metadata-assocations)
+      (update :ISOTopicCategories update-iso-topic-categories)
+      (update :LocationKeywords conversion-util/fix-location-keyword-conversion)
       (assoc :SpatialKeywords nil)
       (assoc :PaleoTemporalCoverages nil)
       (assoc :DataCenters [su/not-provided-data-center])


Rename button label

Rename button label

--- frontend/src/cruncher/views.cljs
+++ frontend/src/cruncher/views.cljs
@@ -28,7 +28,7 @@
              (dom/div #js {:className "row"}
                       (dom/div #js {:className "col-md-6"}
                                (dom/p #js {:className "lead"} "Controls")
-                               (vlib/button-primary #(com/route :get-all-pokemon) "Get all Pokemon")
+                               (vlib/button-primary #(com/route :get-all-pokemon) "Load your Pokemon")
                                (vlib/button-primary #(shredder/power-on this) (dom/span nil (vlib/fa-icon "fa-eraser") " Crunch selected Pokemon")))
                       (dom/div #js {:className "col-md-6"}
                                (dom/p #js {:className "lead"} "Information")


Get hot code reloading working with a top level key and ^:once

--- fulcro-todo/src/main/app/ui.cljs
+++ fulcro-todo/src/main/app/ui.cljs
@@ -2,22 +2,42 @@
   (:require [om.dom :as dom]
             [om.next :as om :refer [defui]]))

-(defui App
+(defui ^:once ItemAdder
   Object
   (render [this]
-          (dom/div
-           #js {:className "app"}
-           (dom/div
-            #js {:className "app__header"}
+          (dom/form
+           #js {:className "item-adder"
+                :onSubmit #(.preventDefault %)}
+           (dom/input
+            #js {:className "item-adder__input"
+                 :type "text"
+                 :value "hey"})
+           (dom/input
+            #js {:className "item-adder__button"
+                 :type "submit"
+                 :value "add"}))))
+
+(def ui-item-adder (om/factory ItemAdder))
+
+(defui ^:once App
+  Object
+  (render [this]
+          (let [{:keys [ui/react-key]} (om/props this)]
             (dom/div
-             #js {:className "app__header__title"}
-             "Todo List")
-            (dom/div
-             #js {:className "app__header__subtitle"}
-             "Developed with Fulcro"))
-           (dom/div
-            #js {:className "app__body"}
-            (dom/div
-             #js {:className "app__body__divider"})
-            (dom/div
-             #js {:className "app__body__divider"})))))
+             #js {:key react-key
+                  :className "app"}
+             (dom/div
+              #js {:className "app__header"}
+              (dom/div
+               #js {:className "app__header__title"}
+               "Todo List")
+              (dom/div
+               #js {:className "app__header__subtitle"}
+               "Developed with Fulcro"))
+             (dom/div
+              #js {:className "app__body"}
+              (dom/div
+               #js {:className "app__body__divider"})
+              (ui-item-adder)
+              (dom/div
+               #js {:className "app__body__divider"}))))))


Finalize tooltip

Finalize tooltip

--- src/discuss/components/tooltip.cljs
+++ src/discuss/components/tooltip.cljs
@@ -116,10 +116,9 @@
                   (vlib/fa-icon "fa-comment")
                   (translate :tooltip :discuss/start :space)]

-                 (when config/experimental-features?
-                   [:span
-                    (vlib/safe-space) " " (vlib/safe-space)
-                    [:span.pointer {:onClick #((lib/show-overlay) (hide))}
-                     (vlib/fa-icon "fa-comments")
-                     (translate :common :show-discuss :space)]])])))
+                 [:span
+                  (vlib/safe-space) " " (vlib/safe-space)
+                  [:span.pointer {:onClick #((lib/show-overlay) (hide))}
+                   (vlib/fa-icon "fa-comments")
+                   (translate :common :show-discuss :space)]]])))
 (def tooltip (om/factory Tooltip))


working on tree mess

working on tree mess

--- sample/src/sample/btree.clj
+++ sample/src/sample/btree.clj
@@ -1,5 +1,6 @@
 (ns sample.btree
   (:require [sample.rangemap :as rm]))
+

 (defprotocol TreeModify
@@ -9,23 +10,66 @@
   (search [this k]))

-(defrecord B+Tree [b slots root? leaf?]
+
+(defrecord BinaryTree [key-fn l r]

   TreeModify

   (add [this v]
-    (->B+Tree b (assoc slots (last v) v) root? leaf?))
+    )

   TreeSearch

   (search [this k]
-    (when-let [ref (get slots k)]
-      (if (satisfies? TreeSearch ref)
-        (search ref k)
-        ref))))
+    ))

-(defn b+tree [b & {:keys [root? leaf?]
-                   :or {root? true
-                        leaf? true}}]
-  (->B+Tree b (rm/range-map :find-ceiling) root? leaf?))
+
+#_(defrecord B+TreeChildren [children-map largest-child]
+
+  TreeModify
+
+  (add [this v]
+    )
+
+  TreeSearch
+
+  (search [this k]
+    (if-let [child (get children-map k)]
+      child
+      largest-child)))
+
+
+#_(defn- b+tree-children []
+  (->B+TreeChildren (rm/range-map :find-ceiling) nil))
+
+
+
+(defrecord B+Tree [b size key-fn children root? leaf?]
+
+  TreeModify
+
+  (add [this v]
+    (let [k (key-fn v)]
+      (if leaf?
+        (->B+Tree b (inc size) key-fn (assoc children k v) root? leaf?)
+        (if-let [child (get children k)]
+          (add child v)
+          (->B+Tree b (inc size) key-fn (assoc children k v) root? leaf?)))))
+
+  TreeSearch
+
+  (search [this k]
+    (when-let [child (get children k)]
+      (if (satisfies? TreeSearch child)
+        (search child k)
+        child))))
+
+
+(defn b+tree [b key-fn & {:keys [root? leaf?]
+                          :or {root? true
+                               leaf? true}}]
+  (let [children (if leaf?
+                   {}
+                   (rm/range-map :find-ceiling))]
+    (->B+Tree b 0 key-fn children root? leaf?)))


sort coll thumbs by date

sort coll thumbs by date

--- src-cljs/imago/collection.cljs
+++ src-cljs/imago/collection.cljs
@@ -133,10 +133,12 @@
                     items (q/query {:select :* :from graph
                                     :query [{:where '[[?img "dct:hasVersion" ?thumb]
                                                       [?img "dct:hasVersion" ?xl]
+                                                      [?img "dct:dateSubmitted" ?time]
                                                       [?thumb "dct:references"
                                                        "617e6192-d1a3-4422-b3cc-d7fcfb782de5"]
                                                       [?xl "dct:references"
-                                                       "fd9e54e5-3700-4736-ba32-a1bae45cf0b3"]]}]})]
+                                                       "fd9e54e5-3700-4736-ba32-a1bae45cf0b3"]]}]
+                                    :order-desc '?time})]
                 (swap!
                  local assoc
                  :title title