Fix user/stop with disabled smtp server.

--- src/pepa/smtp.clj
+++ src/pepa/smtp.clj
@@ -12,44 +12,46 @@
 (defrecord SMTP [config db server]
   component/Lifecycle
   (start [component]
-    (when (get-in component [:config :smtp :enable])
-      (println ";; Starting SMTP server")
-      (let [config (:smtp config)
-            host (:host config)
-            port (:port config)
-            address (and host (InetAddress/getByName host))
-            server (->
-                    (proxy [SimpleMessageListener] []
-                      (accept [from to] true)
-                      (deliver [from to data]
-                        (db/with-transaction [db (:db component)]
-                          ;; TODO: Use proper mail address parser
-                          (let [origin (if (.startsWith to "scanner@") "scanner" "email")
-                                files (m/store-files! db
-                                                      (m/mime-message->files data)
-                                                      {:origin origin})]
-                            (when (= origin "email")
-                              (doseq [file files]
-                                (let [id (m/create-document! db {:file (:id file)
-                                                                 :title (:name file)})
-                                      tagging (get-in component [:config :tagging])]
-                                  (m/auto-tag! db id tagging
-                                               {:origin origin
-                                                :mail/from from
-                                                :mail/to to}))))))))
-                    (SimpleMessageListenerAdapter.)
-                    (SMTPServer.))]
-        (doto server
-          (.setPort port)
-          (.setHostName host)
-          (.setBindAddress address)
-          (.start))
-        (assoc component
-               :server server))))
-
+    (if (get-in component [:config :smtp :enable])
+      (do
+        (println ";; Starting SMTP server")
+        (let [config (:smtp config)
+              host (:host config)
+              port (:port config)
+              address (and host (InetAddress/getByName host))
+              server (->
+                      (proxy [SimpleMessageListener] []
+                        (accept [from to] true)
+                        (deliver [from to data]
+                          (db/with-transaction [db (:db component)]
+                            ;; TODO: Use proper mail address parser
+                            (let [origin (if (.startsWith to "scanner@") "scanner" "email")
+                                  files (m/store-files! db
+                                                        (m/mime-message->files data)
+                                                        {:origin origin})]
+                              (when (= origin "email")
+                                (doseq [file files]
+                                  (let [id (m/create-document! db {:file (:id file)
+                                                                   :title (:name file)})
+                                        tagging (get-in component [:config :tagging])]
+                                    (m/auto-tag! db id tagging
+                                                 {:origin origin
+                                                  :mail/from from
+                                                  :mail/to to}))))))))
+                      (SimpleMessageListenerAdapter.)
+                      (SMTPServer.))]
+          (doto server
+            (.setPort port)
+            (.setHostName host)
+            (.setBindAddress address)
+            (.start))
+          (assoc component
+                 :server server)))
+      component))
   (stop [component]
-    (println ";; Stopping SMTP server")
-    (.stop server)
+    (when-let [server (:server component)]
+      (println ";; Stopping SMTP server")
+      (.stop server))
     (assoc component :server nil)))

 (defmethod clojure.core/print-method SMTP


Tweak comment formatting.

Tweak comment formatting.

--- src/tabular/grafter/tabular.clj
+++ src/tabular/grafter/tabular.clj
@@ -625,8 +625,8 @@

   `(def my-graft (comp make-graph my-pipeline))`

-  It is used with defpipeline to indicate that a transformation also
-  supports conversion into graph data.
+  It is used with defpipe to indicate that a transformation also supports
+  conversion into graph data.

   It takes an optional docstring, if no docstring is specified then a
   default docstring will be generated."


Remote page require

Remote page require

--- src/shouter/web.clj
+++ src/shouter/web.clj
@@ -10,7 +10,6 @@
             [shouter.controllers.google-auth :as google-auth]
             [shouter.views.layout :as layout]
             [shouter.models.migration :as schema]
-            [hiccup.page :as page]
             [clojure.pprint :refer [pprint]]
             [shouter.middleware.oauth2 :refer [wrap-oauth2]]
             [environ.core :refer [env]])


Added a resources resource

Added a resources resource

--- src/shuppet/web.clj
+++ src/shuppet/web.clj
@@ -97,6 +97,22 @@
            :status code
            :message message}))

+(def ^:private resources
+  {:GET
+   (array-map "/healthcheck" "Healthcheck"
+              "/1.x/status" "Status"
+              "/1.x./ping" "Pong"
+              "/1.x/icon" "Icon"
+              "/1.x/envs" "Available environments"
+              "/1.x/envs/:env-name" "Read and evaluates the environment configuration"
+              "/1.x/envs/:env-name/apply" "Apply the environment configuration"
+              "/1.x/envs/:env-name/apps" "All available applications"
+              "/1.x/envs/:env-name/apps/:app-name" "Read and evaluate application configuration with env configuration"
+              "/1.x/envs/:env-name/apps/:app-name/apply" "Apply the application configuration in the environment")
+   :POST
+   (array-map "/1.x/apps/:app-name" "Creates an application configuration"
+              "/1.x/validate/:name" "Validates the configuration passed in the body")})
+
 (defroutes applications-routes

   (GET "/"
@@ -175,6 +191,11 @@
        []
        (->  (ring-response/response "I am healthy. Thank you for asking.")
             (ring-response/content-type  "text/plain;charset=utf-8")))
+
+  (GET "/resources"
+       []
+       (->  (ring-response/response (-> resources (write-str)))
+            (ring-response/content-type  "application/json")))

   (route/not-found (error-response "Resource not found" 404)))


a valid atomic value should only give a single letter improvement

--- src/specly/core.clj
+++ src/specly/core.clj
@@ -75,7 +75,7 @@
      (cond-> (/ score 10)
        ;; TODO: I don't think this is neccessary at all
        (and valid (coll? key-val)) dec
-       valid dec
+       valid (- 1/10) ;; a single letter difference for being an atomic value and correct
        (and (not valid) (map? key-val) (fuzzy-spec? key-spec))
        (- (or (fuzzy-conform-score (spec-from-registry key-spec) key-val)
               0)))]))


Remove print statements

Remove print statements

--- src/web/chatom/web/ui/core.cljs
+++ src/web/chatom/web/ui/core.cljs
@@ -19,7 +19,6 @@
   (render [this]
     (let [{:keys [id] :as props} (om/props this)
           render-page (pages/page-id->factory id)]
-      (pprint props)
       (if render-page
         (render-page props)
         (html [:div.page#not-found-page "Page not found"])))))
@@ -48,8 +47,6 @@
     (let [{:keys [:app/routing :app/pages] :as props} (om/props this)
           page-id (get-in routing [:data :app/current-page :id])
           current-page (first (filter #(= page-id (:id %)) pages))]
-      (pprint page-id)
-      (pprint pages)
       (html
        [:div
         (navbar/navbar (:data routing))


Adapt multiple condition question type to string values

--- backend/src/akvo/lumen/lib/import/common.clj
+++ backend/src/akvo/lumen/lib/import/common.clj
@@ -33,7 +33,7 @@
             {:title (:name q)
              :type t
              :id (format "c%s" (:id q))}
-            (when (= t :multiple)
+            (when (= t "multiple")
               (if (:caddisflyResourceUuid q)
                 {:multipleType :caddisfly
                  :multipleId (:caddisflyResourceUuid q)}


Don't pass invalid props to input component or React complains.

--- examples/todomvc/src/todomvc/views.cljs
+++ examples/todomvc/src/todomvc/views.cljs
@@ -12,7 +12,7 @@
                 (when (seq v) (on-save v))
                 (stop))]
     (fn [props]
-      [:input (merge props
+      [:input (merge (dissoc props :on-save :on-stop :title)
                      {:type        "text"
                       :value       @val
                       :auto-focus  true


Add missing own argument on canvas render function.


rename the test alias name

rename the test alias name

--- test/bzzz/core_handler_test.clj
+++ test/bzzz/core_handler_test.clj
@@ -156,24 +156,25 @@
       (is (= 0 (:total r)))))

   (testing "create-alias"
-    (let [r (fn [fn x] (json/read-str (:body @(fn "http://localhost:3000" {:body (json/write-str x)}))))
+    (let [aliased "core-handler-test-alias-testing"
+          r (fn [fn x] (json/read-str (:body @(fn "http://localhost:3000" {:body (json/write-str x)}))))
           g (fn [x] (dissoc (r http-client/get {:index x
                                                 :query "name:alias"}) "took"))]
-      (is (= 0 (get (g "bzbz") "total")))
-      (r http-client/post {:index test-index-name :alias-set "bzbz"})
-      (r http-client/post {:index "bzbz" :documents [{:name "alias write"}]})
+      (is (= 0 (get (g aliased) "total")))
+      (r http-client/post {:index test-index-name :alias-set aliased})
+      (r http-client/post {:index aliased :documents [{:name "alias write"}]})
       (refresh-search-managers)
-      (let [ra (g "bzbz")
+      (let [ra (g aliased)
             rb (g test-index-name)]
         (is (= ra rb))
         (is (= 1 (get ra "total"))))
-      (r http-client/post {:index test-index-name :alias-del "bzbz"})
-      (is (= 0 (get (g "bzbz") "total")))
-      (r http-client/post {:index test-index-name :alias-set "bzbz"})
-      (is (= 1 (get (g "bzbz") "total")))
-      (r http-client/delete {:index "bzbz" :query {:match-all {}}})
+      (r http-client/post {:index test-index-name :alias-del aliased})
+      (is (= 0 (get (g aliased) "total")))
+      (r http-client/post {:index test-index-name :alias-set aliased})
+      (is (= 1 (get (g aliased) "total")))
+      (r http-client/delete {:index aliased :query {:match-all {}}})
       (refresh-search-managers)
-      (let [ra (g "bzbz")
+      (let [ra (g aliased)
             rb (g test-index-name)]
         (is (= ra rb))
         (is (= 0 (get ra "total"))))))


indenting

indenting

--- test/celestial/test/proxmox.clj
+++ test/celestial/test/proxmox.clj
@@ -1,6 +1,5 @@
 (ns celestial.test.proxmox
   (:require
-    [clojure.core.strint :refer (<<)]
     [celestial.common :refer (curr-time)]
     [celestial.model :refer (vconstruct)]
     [proxmox.generators :refer (ct-id)]
@@ -30,9 +29,7 @@
         (fact "vzctl usage"
               (enable-features ct) => '()
               (provided
-                (vzctl ct "set 101 --features \"nfs:on\" --save") => nil :times 1))
-
-        ))))
+                (vzctl ct "set 101 --features \"nfs:on\" --save") => nil :times 1))))))

 (with-conf
   (let [headers {"Cookie" "PVEAuthCookie=" "CSRFPreventionToken" "foobar"}]


fix align

fix align

--- test/cljam/algo/pileup_test.clj
+++ test/cljam/algo/pileup_test.clj
@@ -347,11 +347,11 @@
         plps-cont (->> reads-continal-for-pileup
                        (pileup* {:chr "seq1" :start 1 :end 10} {}))
         plps-overlap (->> reads-overlapping-for-pileup
-                       (pileup* {:chr "seq1" :start 1 :end 10} {}))
+                          (pileup* {:chr "seq1" :start 1 :end 10} {}))
         plps-include (->> reads-including-for-pileup
-                       (pileup* {:chr "seq1" :start 1 :end 10} {}))
+                          (pileup* {:chr "seq1" :start 1 :end 10} {}))
         plps-chunk (->> reads-overlapping-for-pileup
-                     (pileup* {:chr "seq1" :start 1 :end 15} {:chunk-size 2}))]
+                        (pileup* {:chr "seq1" :start 1 :end 15} {:chunk-size 2}))]
     (is (= (filter pos? [0 0 1 1 1 1 1 1 1 1])
            (map (comp count :pile) plps)))
     (is (= (filter seq [[] [] [\T] [\T] [\G] [\G] [\C] [\C] [\A] [\A]])


Avoid name conflicts with core clojure methods

--- test/clojure_ruby/core_test.clj
+++ test/clojure_ruby/core_test.clj
@@ -81,7 +81,7 @@
            "<"
            [:number "4"]]])))

-(deftest infix-and-naked
+(deftest infix-and-regular-precedence
   (is (unambigous? "alpha.beta < 4"))
   (is (= (ruby-parser "alpha.beta < 4")
          [[:method_call_infix
@@ -121,7 +121,7 @@
             "y"
             [:number "1"]]]])))

-(deftest if
+(deftest flow-if
   (is (unambigous?    "if 1; o.m; 10; end"))
   (is (= (ruby-parser "if 1; o.m; 10; end")
          [[:if [:number "1"]
@@ -134,21 +134,21 @@
            [:number "3"]
            [:number "4"]]])))

-(deftest while
+(deftest flow-while
   (is (unambigous? "while 1; o.m; 10; end"))
   (is (= (ruby-parser "while 1; o.m; 10; end")
          [[:while [:number "1"]
            [:method_call [:var_ref "o"] "m"]
            [:number "10"]]])))

-(deftest until
+(deftest flow-until
   (is (unambigous? "until 1; o.m; 10; end"))
   (is (= (ruby-parser "until 1; o.m; 10; end")
          [[:until [:number "1"]
            [:method_call [:var_ref "o"] "m"]
            [:number "10"]]])))

-(deftest case
+(deftest flow-case
   (is (unambigous? "case 1; when 1; 2; end"))
   (is (= (ruby-parser "case 1; when 1; 2; end")
          [[:case [:number "1"]


Allow for more than one cache cleanup during testing

Tests would fail sporadically because of multiple cleanups, which are
perfectly fine.

--- test/integration/test/cache.clj
+++ test/integration/test/cache.clj
@@ -85,7 +85,7 @@
           cache (c/create-query-cache "query_cache" (fn [_] (swap! cleanups inc) []))
           worker (c/create-worker cache)]
       (run-all-jobs worker)
-      (does= @cleanups 1))))
+      (is (>= @cleanups 1)))))

 (deftest ^:integration test-add-to-queue
   (testing "it adds a document to jobs"


Fixed wrong return value from golomb-report.

--- src/clojush/problems/integer_regression/golomb.clj
+++ src/clojush/problems/integer_regression/golomb.clj
@@ -53,7 +53,7 @@
     (println (format "Test mean error for best: %.5f"
                      (double (/ best-total-test-error (count best-test-errors)))))
     (println ";;******************************")
-    best-with-test))
+    best))

 (def argmap
@@ -70,3 +70,4 @@
    :report-simplifications 0
    :problem-specific-report golomb-report})

+


Bumps version to 1.42.2-SNAPSHOT

Bumps version to 1.42.2-SNAPSHOT

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


Restored btset/from-sorted

Restored btset/from-sorted

--- bench/src/datascript_bench/datascript.cljc
+++ bench/src/datascript_bench/datascript.cljc
@@ -122,7 +122,7 @@

 (defn ^:export qpred1 []
   (core/bench
-    (q3/q '[:find ?e ?s
+    (d/q '[:find ?e ?s
            :where [?e :salary ?s]
                   [(> ?s 50000)]]
       db100k)))
@@ -130,7 +130,7 @@

 (defn ^:export qpred2 []
   (core/bench
-    (q3/q '[:find ?e ?s
+    (d/q '[:find ?e ?s
            :in   $ ?min_s
            :where [?e :salary ?s]
                   [(> ?s ?min_s)]]


lein-release plugin: preparing 0.2.0 release

--- prosemirror/project.clj
+++ prosemirror/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view/prosemirror "0.2.0-SNAPSHOT"
+(defproject re-view/prosemirror "0.2.0"

   :description "Rich text editors built with ProseMirror in Re-View"


Une première solution à l'exercice Strain de Exercism dans la track Clojure

--- exercism/clojure/strain/src/strain.clj
+++ exercism/clojure/strain/src/strain.clj
@@ -1,9 +1,9 @@
 (ns strain)

-(defn retain [] ;; <- arglist goes here
-      ;; your code goes here
+(defn retain [pred v]
+  (reduce #(if (pred %2) (conj %1 %2) %1) [] v)
+  )
+
+(defn discard [pred v]
+  (reduce #(if (pred %2) %1 (conj %1 %2)) [] v)
 )
-
-(defn discard [] ;; <- arglist goes here
-  ;; your code goes here
-)


core: re-matches

core: re-matches

--- core/data/core.clj
+++ core/data/core.clj
@@ -2548,20 +2548,22 @@
   [^Regex re s]
   (re-seq* re s))

-#_(defn re-matches
-  "Returns the match, if any, of string to pattern."
-  {:added "1.0"
-   :static true}
-  [^java.util.regex.Pattern re s]
-    (let [m (re-matcher re s)]
-      (when (. m (matches))
-        (re-groups m))))
-
 (defn re-find
   "Returns the leftmost regex match, if any, of string to pattern."
   {:added "1.0"}
   [^Regex re s]
   (re-find* re s))
+
+(defn re-matches
+  "Returns the match, if any, of string to pattern."
+  {:added "1.0"}
+  [^Regex re s]
+  (let [m (re-find re s)
+        c (if (instance? String m)
+            (count m)
+            (count (first m)))]
+    (when (= c (count s))
+      m)))

 (defmacro defn-
   "same as defn, yielding non-public def"


core: case, partition-all

core: case, partition-all

--- core/data/core.clj
+++ core/data/core.clj
@@ -3301,7 +3301,7 @@
   value of condp. A single default expression can follow the clauses,
   and its value will be returned if no clause matches. If no default
   expression is provided and no clause matches, an
-  IllegalArgumentException is thrown."
+  exception is thrown."
   {:added "1.0"}

   [pred expr & clauses]
@@ -3390,6 +3390,43 @@
      ([a b c] (f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c)))
      ([a b c & ds] (apply f (if (nil? a) x a) (if (nil? b) y b) (if (nil? c) z c) ds)))))

+(defn partition-all
+  "Returns a lazy sequence of lists like partition, but may include
+  partitions with fewer than n items at the end."
+  {:added "1.0"}
+  ([n coll]
+   (partition-all n n coll))
+  ([n step coll]
+   (lazy-seq
+    (when-let [s (seq coll)]
+      (let [seg (doall (take n s))]
+        (cons seg (partition-all n step (nthrest s step))))))))
+
+(defmacro case
+  "Takes an expression, and a set of clauses.
+
+  Each clause can take the form of either:
+
+  test-expr result-expr
+
+  (test-expr ... test-expr)  result-expr
+
+  If the expression is equal to a value of
+  test-expr, the corresponding result-expr is returned. A single
+  default expression can follow the clauses, and its value will be
+  returned if no clause matches. If no default expression is provided
+  and no clause matches, an exception is thrown."
+  {:added "1.0"}
+  [expr & clauses]
+  (let [parts (partition-all 2 clauses)
+        setized (for [[test then] parts]
+                  (if then
+                    [(if (list? test) (set test) (set [test])) then]
+                    [test]))
+        transformed-clauses (apply concat setized)]
+    `(condp contains? ~expr
+       ~@transformed-clauses)))
+
 (defmacro cond->
   "Takes an expression and a set of test/form pairs. Threads expr (via ->)
   through each form for which the corresponding test


System.exit after client finishes

System.exit after client finishes

… the thread/connection pools must be left and not closing so it won't shut down … instead of tracking them down right now I'm forcing it to exit.

--- ws-client/src/main/clojure/ws/client/ws_client.clj
+++ ws-client/src/main/clojure/ws/client/ws_client.clj
@@ -11,7 +11,7 @@
   [url numThreads]
   (println (str "Running load test => Threads: " numThreads  " URL: " url))
   (run-load-test url (Integer/parseInt numThreads))
-  (System/exit))
+  (System/exit 0))

 (defn run-load-test


(TK-110) Set a default proxy idle timeout of 60s

--- src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
+++ src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
@@ -133,6 +133,11 @@
 ;;; Constants

 (def default-graceful-stop-timeout 60000)
+
+(def default-proxy-idle-timeout
+  "The default number of seconds to wait before the proxy gives up on the
+  upstream server if the :idle-timeout value isn't set in the proxy config."
+  60)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Utility Functions
@@ -367,12 +372,12 @@
           client))

       (createHttpClient []
-        (let [client (proxy-super createHttpClient)]
+        (let [client (proxy-super createHttpClient)
+              timeout (* 1000 (or idle-timeout default-proxy-idle-timeout))]
           (if (:follow-redirects options)
             (.setFollowRedirects client true)
             (.setFollowRedirects client false))
-          (when idle-timeout
-            (.setIdleTimeout client (* 1000 idle-timeout)))
+          (.setIdleTimeout client timeout)
           client))

       (customizeProxyRequest [proxy-req req]


update bench

update bench

--- src/scripts/clojure/palisades/lakes/multix/intersects/bench.clj
+++ src/scripts/clojure/palisades/lakes/multix/intersects/bench.clj
@@ -5,7 +5,7 @@
   "Use criterium for alternative multimethod implementations."
   {:author "palisades dot lakes at gmail dot com"
    :since "2017-05-29"
-   :version "2017-08-18"}
+   :version "2017-08-19"}
   (:require [palisades.lakes.bench.random.prng :as prng]
             [palisades.lakes.bench.random.generators :as g]
             [palisades.lakes.bench.core :as benchtools]
@@ -58,39 +58,41 @@
   ;; baselines: both args always IntegerInterval
   (bench ii palisades.lakes.bench.java.sets.IntegerInterval
          ii palisades.lakes.bench.java.sets.IntegerInterval
-         [defs/dynafun
+         [defs/invokestatic
+          defs/invokevirtual
+          defs/invokeinterface
           defs/manual-java
-          #_defs/invokestatic
-          #_defs/invokevirtual
-          #_defs/invokeinterface
-          #_defs/hashmap-tables
+          defs/defmulti
+          defs/manual-java
+          defs/dynafun
           defs/no-hierarchy
-          #_defs/signature-dispatch-value
-          #_defs/non-volatile-cache
-          #_defs/defmulti])
+          defs/signature-dispatch-value
+          defs/non-volatile-cache
+          defs/hashmap-tables])
   ;; 50% probability of repeat same method,
   ;; 1st arg always IntegerInterval
   ;; 2nd randomly IntegerInterval or DoubleInterval
   (bench ii ran2
-         [defs/dynafun
+         [defs/manual-java
+          defs/defmulti
           defs/manual-java
-          #_defs/defmulti
-          #_defs/hashmap-tables
-          #_defs/manual-java
+          defs/dynafun
           defs/no-hierarchy
-          #_defs/signature-dispatch-value
-          #_defs/non-volatile-cache])
+          defs/signature-dispatch-value
+          defs/non-volatile-cache
+          defs/hashmap-tables])
   ;; 1/9 probability of same method
   ;; 1st and 2nd args randomly from IntegerInterval,
   ;; DoubleInterval and SingletonSet
   (bench ran3 ran3
-        [ #_defs/defmulti
-         #_defs/hashmap-tables
-         defs/manual-java
-         defs/no-hierarchy
-         defs/dynafun
-         #_defs/signature-dispatch-value
-         #_defs/non-volatile-cache]))
+         [defs/manual-java
+          defs/defmulti
+          defs/manual-java
+          defs/dynafun
+          defs/no-hierarchy
+          defs/signature-dispatch-value
+          defs/non-volatile-cache
+          defs/hashmap-tables]))
 (shutdown-agents)
 (System/exit 0)
 ;;----------------------------------------------------------------


Don't transform configs more than once [IMMUTANT-47]

--- support/build-support/src/main/clojure/immutant/build/tools.clj
+++ support/build-support/src/main/clojure/immutant/build/tools.clj
@@ -25,7 +25,7 @@
             [clojure.contrib.zip-filter.xml :as zfx]
             [clojure.xml                    :as xml]
             [clojure.contrib.lazy-xml       :as lazy-xml]
-            [org.satta.glob :as glob])
+            [org.satta.glob                 :as glob])
   (:use [clojure.pprint :only [pprint]]))

 (defn unzip [zip-file dest-dir]
@@ -193,10 +193,13 @@
 (defn transform-config [file]
   (let [in-file (io/file jboss-dir file)
         out-file in-file]
-    (println "transforming" file)
-    (io/make-parents out-file)
-    (io/copy (with-out-str
-               (lazy-xml/emit
-                (walk-the-doc (prepare-zip in-file))
-                :indent 4))
-             out-file)))
+    (if (re-find #"immutant" (slurp in-file))
+      (println file "already transformed, skipping")
+      (do
+        (println "transforming" file)
+        (io/make-parents out-file)
+        (io/copy (with-out-str
+                   (lazy-xml/emit
+                    (walk-the-doc (prepare-zip in-file))
+                    :indent 4))
+                 out-file)))))


Added Reagent dependency to the project.

--- app/project.clj
+++ app/project.clj
@@ -13,7 +13,8 @@
                  [metosin/ring-swagger-ui "2.1.5-M2"]
                  [prismatic/schema "0.4.3"]
                  [hiccup "1.0.5"]
-                 [org.clojure/clojurescript "0.0-3269"]]
+                 [org.clojure/clojurescript "0.0-3269"]
+                 [reagent "0.5.0"]]
   :main ^:skip-aot clj-web-example.main
   :target-path "target/%s"
   :profiles {:uberjar {:aot :all}})


Clean up with comments, semantic fix

Clean up with comments, semantic fix

--- clojure/src/euler/003.clj
+++ clojure/src/euler/003.clj
@@ -18,15 +18,17 @@
                   (range 2 (+ 1 (math/sqrt n))))))

 (defn primes-below [n]
-  "Returns a lazy seq of all possible primes below n."
-  (filter prime? (range (int (math/floor n)) 1 -1)))
+  "Returns a lazy seq of all possible primes less than n."
+  ; Use `int` to cast and floor n, subtract 1 so it's exclusive of `n`
+  (filter prime? (range (dec (int n)) 1 -1)))

 (defn possible-prime-factors-of [n]
   "Returns a lazy seq of all possible prime factors of n in order of largest to smallest."
-  (primes-below (math/floor (math/sqrt n))))
+  ; Add 1 so `primes-below` results includes `sqrt(n)`
+  (primes-below (inc (math/floor (math/sqrt n)))))

 (defn biggest-prime-divisor-of-n [n]
-  "Lazily retrieves the first prime divisor "
+  "Returns the first prime divisor of n, or `nil` if ."
   (let [possible-primes (possible-prime-factors-of n)]
     (first (drop-while #(not (zero? (mod n %)))
                        possible-primes))))


Some simplifications for the Tamari Lattice example

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

--- doc/examples/tamari-lattice.clj
+++ doc/examples/tamari-lattice.clj
@@ -9,25 +9,17 @@

 ;;;

-(defn two-elemental-subsets
-  "Returns the set of all two elemental subsets of set."
-  [set]
-  (set-of #{a b} [a set, b (disj set a)]))
-
 (defn T
   "Returns a context for the Tamari lattice of all bracketings of n+1
   symbols."
   [n]
-  (let [base-set (two-elemental-subsets (set-of-range n))]
+  (let [elements (set-of-range n),
+        base-set (set-of [a b] [a elements, b elements, :when (< a b)])]
     (make-context base-set
                   base-set
-                  (set-of [#{i j} #{p q}]
-                          [pair-1 base-set,
-                           pair-2 base-set,
-                           :let [i (apply min pair-1),
-                                 j (apply max pair-1),
-                                 p (apply min pair-2),
-                                 q (apply max pair-2)]
+                  (set-of [[i j] [p q]]
+                          [[i j] base-set,
+                           [p q] base-set,
                            :when (not (and (<= p i q j)
                                            (not= i q)))]))))


Single add input through processing too

Single add input through processing too

--- src/app/importer.cljs
+++ src/app/importer.cljs
@@ -38,7 +38,7 @@
 (defonce nextword (atom ""))

 (defn textfield-import! [words word eventbus-in]
-  (data/add! (@data/wordlists @ctl/active-list-idx) (js->clj word))
+  (data/add-multiple! (@data/wordlists @ctl/active-list-idx) (process-input (js->clj word)))
   (reset! nextword "")
   (put! eventbus-in :data-updated))


not use machine ssh agent in order to prevent auth errors

--- src/celestial/ssh.clj
+++ src/celestial/ssh.clj
@@ -7,7 +7,7 @@
     [clojure.string :only (join)]
     [slingshot.slingshot :only  [throw+ try+]]
     [clj-ssh.ssh :only
-      (session ssh-agent with-connection sftp ssh-sftp with-channel-connection ssh)]))
+      (session ssh-agent with-connection sftp ssh-sftp with-channel-connection ssh add-identity)]))

 (defn ssh-opts
   "SSH session options" [port]
@@ -16,12 +16,14 @@
 (defn with-session
   "Executes f on host with an ssh session"
   [host port f]
-  (let [session (session (ssh-agent {}) host (ssh-opts port))]
-    (try+
-      (with-connection session (f session))
-      (catch #(= (:message %) "Auth fail") e
-        (throw+ {:type ::auth :host host}
-                "Failed to login make sure to ssh-copy-id to the remote host")))))
+  (let [agent (ssh-agent  {:use-system-ssh-agent false})]
+    (add-identity agent {:private-key-path (config :ssh)})
+    (let [session (session agent host (ssh-opts port))]
+      (try+
+        (with-connection session (f session))
+        (catch #(= (:message %) "Auth fail") e
+          (throw+ {:type ::auth :host host}
+                  "Failed to login make sure to ssh-copy-id to the remote host"))))))

 (defn put
   "Copies a file into host under dest"
@@ -44,12 +46,13 @@
   (doseq [b batches]
     (with-session host port
       (fn [session]
-        (let [{:keys [channel out-stream] :as res} (ssh session {:in  (join "\n" b)  :out :stream})]
+        (let [{:keys [channel out-stream] :as res} (ssh session {:in  (join "\n" b)  :out :stream :agent-forwarding false})]
           (log-output out-stream)
           (let [exit (.getExitStatus channel)]
             (when-not (= exit 0)
               (throw+ (merge res {:type ::execute-failed :exit exit} (meta b))))))
         ))))
+

 (defn fname [uri] (-> uri (split '#"/") last))


logging about reaching out to cluster on new client instance

rather than logging every time when a client instance is called, sinc if the instance was previously created, it should just return with no attempts to connect to the cluster

--- src/chazel/chazel.clj
+++ src/chazel/chazel.clj
@@ -55,11 +55,11 @@
 (defn client-instance
   ([] (client-instance default-client-config))
   ([conf]
-    (info "connecting to: " conf)
     (let [ci @c-instance]
       (if (and ci (instance-active? ci))
         ci
         (try
+          (info "connecting to: " conf)
           (reset! c-instance
                   (HazelcastClient/newHazelcastClient (client-config conf)))
           (catch Throwable t


support side effecting statements in body of deftest

--- src/clj/cljs/test.clj
+++ src/clj/cljs/test.clj
@@ -210,7 +210,13 @@
                   ([] (self# (cljs.test/empty-env)))
                   ([env#]
                    (let [~'cljs$lang$test$body nil
-                         ret# (reduce #(%2 %1) env# [~@body])]
+                         ret# (reduce
+                                (fn [env'# thunk#]
+                                  (let [ret# (thunk#)]
+                                    (if (fn? ret#)
+                                      (ret# env'#)
+                                      env'#)))
+                                env# [~@(map (fn [expr] `(fn [] ~expr)) body)])]
                      (when (:return env#)
                        ret#)))))
          (fn


fix absolute -> relative positioning from breaking scroll position

--- frontend/controllers/controls.cljs
+++ frontend/controllers/controls.cljs
@@ -160,22 +160,29 @@
   [target message {:keys [container-id animate?] :or {animate? true}} previous-state current-state]
   (when-let [parent (sel1 target "#container_parent")]
     (let [container (sel1 target (str "#container_" container-id))
+          app-main (sel1 target ".app-main")
           current-scroll-top (.-scrollTop parent)
+          app-main-scroll-top (.-scrollTop app-main)
           current-scroll-left (.-scrollLeft parent)
           new-scroll-left (int (.-x (goog.style.getContainerOffsetToScrollInto container parent)))]
-      (if-not animate?
-        (set! (.-scrollLeft parent) new-scroll-left)
-        (let [scroller (or (.-scroll_handler parent)
-                            (set! (.-scroll_handler parent)
-                                  ;; Store this on the parent so that we don't handle parent scroll while
-                                  ;; the animation is playing
-                                  (goog.fx.dom.Scroll. parent
-                                                       #js [0 0]
-                                                       #js [0 0]
-                                                       250)))]
-          (set! (.-startPoint scroller) #js [current-scroll-left current-scroll-top])
-          (set! (.-endPoint scroller) #js [new-scroll-left current-scroll-top])
-          (.play scroller)))))
+      (let [scroller (or (.-scroll_handler parent)
+                         (set! (.-scroll_handler parent)
+                               ;; Store this on the parent so that we don't handle parent scroll while
+                               ;; the animation is playing
+                               (goog.fx.dom.Scroll. parent
+                                                    #js [0 0]
+                                                    #js [0 0]
+                                                    (if animate? 250 0))))
+            onEnd (.-onEnd scroller)]
+        (set! (.-startPoint scroller) #js [current-scroll-left 0])
+        (set! (.-endPoint scroller) #js [new-scroll-left 0])
+        ;; Browser find can scroll an absolutely positioned container into view,
+        ;; causing the parent to scroll. But then we set it to relative and there
+        ;; is no longer any overflow, so we need to scroll app-main instead.
+        (set! (.-onEnd scroller) #(do (.call onEnd scroller)
+                                      (set! (.-scrollTop app-main)
+                                            (+ app-main-scroll-top current-scroll-top))))
+        (.play scroller))))
   (when (not= (get-in previous-state state/current-container-path)
               container-id)
     (let [container (get-in current-state (state/container-path container-id))


properly close jarfiles

properly close jarfiles

--- boot/pod/src/boot/pod.clj
+++ boot/pod/src/boot/pod.clj
@@ -100,7 +100,7 @@

 (defn pom-properties
   [jarpath]
-  (let [jarfile (JarFile. (io/file jarpath))]
+  (with-open [jarfile (JarFile. (io/file jarpath))]
     (doto (Properties.)
       (.load (->> jarfile .entries enumeration-seq
                (filter #(.endsWith (.getName %) "/pom.properties"))
@@ -141,7 +141,7 @@

 (defn pom-xml
   [jarpath]
-  (let [jarfile (JarFile. (io/file jarpath))]
+  (with-open [jarfile (JarFile. (io/file jarpath))]
     (some->> jarfile .entries enumeration-seq
       (filter #(.endsWith (.getName %) "/pom.xml"))
       first (.getInputStream jarfile) slurp)))


Check nil value for template string

Check nil value for template string

--- src/cordula/proxy.clj
+++ src/cordula/proxy.clj
@@ -41,7 +41,8 @@
   \"Hello Matthieu!\"
   "
   [s values]
-  (string/replace s #"~\{([^~\{]*)\}" #(format-param->value % values)))
+  (when s
+    (string/replace s #"~\{([^~\{]*)\}" #(format-param->value % values))))

 (s/defn with-headers
   "Merge request headers with those configured."


[#3091] Use data-groups-future fixture

[#3091] Use data-groups-future fixture

--- backend/test/akvo/lumen/lib/transformation_test.clj
+++ backend/test/akvo/lumen/lib/transformation_test.clj
@@ -4,6 +4,7 @@
                                          *system*
                                          tenant-conn-fixture
                                          system-fixture
+                                         data-groups-future-fixture
                                          *error-tracker*
                                          error-tracker-fixture
                                          summarise-transformation-logs-fixture
@@ -75,7 +76,7 @@
 (alias 'db.dataset-version.s                    'akvo.lumen.specs.db.dataset-version)
 (alias 'db.dataset-version.column.s             'akvo.lumen.specs.db.dataset-version.column)

-(use-fixtures :once tu/spec-instrument caddisfly-fixture system-fixture tenant-conn-fixture error-tracker-fixture summarise-transformation-logs-fixture)
+(use-fixtures :once tu/spec-instrument caddisfly-fixture system-fixture data-groups-future-fixture tenant-conn-fixture error-tracker-fixture summarise-transformation-logs-fixture)

 (hugsql/def-db-fns "akvo/lumen/lib/job-execution.sql")
 (hugsql/def-db-fns "akvo/lumen/lib/transformation.sql")


implementing naive binary tree

implementing naive binary tree

--- sample/src/sample/btree.clj
+++ sample/src/sample/btree.clj
@@ -4,24 +4,39 @@

 (defprotocol TreeModify
-  (add [this k v root]))
+  (add [this k v]))

 (defprotocol TreeSearch
   (search [this k]))

-(defrecord BinaryTree [k* v* l r]
+(defrecord BinaryTreeNode [k* v* l r]

   TreeModify

-  (add [this k v root]
-    )
+  (add [this k v]
+    (let [[l r] (if (<= (compare k k*) 0)
+                  [(if-not (nil? l)
+                     (add l k v)
+                     (BinaryTreeNode. k v nil nil))
+                   r]
+                  [l
+                   (if-not (nil? r)
+                     (add r k v)
+                     (BinaryTreeNode. k v nil nil))])]
+      (BinaryTreeNode. k* v* l r)))

   TreeSearch

   (search [this k]
-    ))
+    (let [cres (compare k k*)]
+      (cond
+        (< cres 0) (when-not (nil? l)
+                     (search l k))
+        (> cres 0) (when-not (nil? r)
+                     (search r k))
+        true v*))))

@@ -45,11 +60,11 @@

-(defrecord B+Tree [b size key-fn children root? leaf?]
+#_(defrecord B+Tree [b size key-fn children root? leaf?]

   TreeModify

-  (add [this v]
+  (add* [this v]
     (let [k (key-fn v)]
       (if leaf?
         (->B+Tree b (inc size) key-fn (assoc children k v) root? leaf?)
@@ -59,14 +74,14 @@

   TreeSearch

-  (search [this k]
+  (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?]
+#_(defn b+tree [b key-fn & {:keys [root? leaf?]
                           :or {root? true
                                leaf? true}}]
   (let [children (if leaf?


animation test

animation test

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


use supported url for GCS downloads, a la https://cloud.google.com/storage/docs/authentication#cookieauth


remove some unused imports

remove some unused imports

--- src/pc/convert.clj
+++ src/pc/convert.clj
@@ -1,9 +1,5 @@
 (ns pc.convert
-  (:import [javax.imageio ImageIO]
-           [org.apache.commons.io FileUtils]
-           [java.io ByteArrayOutputStream ByteArrayInputStream]
-           [java.awt Color]
-           [java.awt.image BufferedImage]
+  (:import [java.io ByteArrayOutputStream ByteArrayInputStream]
            [org.apache.batik.transcoder.image PNGTranscoder]
            [org.apache.batik.transcoder TranscoderInput TranscoderOutput]))


regex improvement in hashtags replacer

regex improvement in hashtags replacer


Slight simplification

Slight simplification

--- src/eddy/schedule.clj
+++ src/eddy/schedule.clj
@@ -60,6 +60,5 @@
       (quartzite/schedule scheduler (get job :job) (get job :trigger)))))

 (defmacro sch [job-type & interval]
-  (let [job-id (str "jobs." (str job-type) "." (. (str (gensym)) toLowerCase))
-        job-class (resolve job-type)]
-    `{:job (job ~job-class ~job-id) :trigger (trigger ~job-id ~interval)}))
+  (let [job-id (str "jobs." (str job-type) "." (. (str (gensym)) toLowerCase))]
+    `{:job (job ~job-type ~job-id) :trigger (trigger ~job-id ~interval)}))


Fix 'Send message' handler in chat profile window


Add incise.config.

Add incise.config.

--- src/incise/config.clj
+++ src/incise/config.clj
@@ -1,3 +1,12 @@
-(ns incise.config)
+(ns incise.config
+  (:refer-clojure :exclude [assoc get]))

 (def config (atom {}))
+
+(defn assoc [& args]
+  (apply swap! config assoc args))
+
+(defn get [& args]
+  (if (empty? args)
+    @config
+    (apply @config args)))


pull out the Jetty webserver management stuff into functions and track its lifecycle more explicitly so that we can gracefully trigger shutdown when needed.  The -main function now just wraps our (init) and (start-jetty) functions in a basic try/catch.

--- src/metabase/core.clj
+++ src/metabase/core.clj
@@ -65,25 +65,45 @@
   true)

+;; ## Jetty (Web) Server
+
+
+(def ^:private jetty-instance
+  (atom nil))
+
+(defn start-jetty
+  "Start the embedded Jetty web server."
+  []
+  (when-not @jetty-instance
+    (let [jetty-config (cond-> (medley/filter-vals identity {:port (config/config-int :mb-jetty-port)
+                                                             :host (config/config-str :mb-jetty-host)
+                                                             :max-threads (config/config-int :mb-jetty-maxthreads)
+                                                             :min-threads (config/config-int :mb-jetty-minthreads)
+                                                             :max-queued (config/config-int :mb-jetty-maxqueued)
+                                                             :max-idle-time (config/config-int :mb-jetty-maxidletime)})
+                         (config/config-str :mb-jetty-join) (assoc :join? (config/config-bool :mb-jetty-join))
+                         (config/config-str :mb-jetty-daemon) (assoc :daemon? (config/config-bool :mb-jetty-daemon)))]
+      (log/info "Launching Embedded Jetty Webserver with config:\n" (with-out-str (clojure.pprint/pprint jetty-config)))
+      (->> (ring-jetty/run-jetty app jetty-config)
+        (reset! jetty-instance)))))
+
+(defn stop-jetty
+  "Stop the embedded Jetty web server."
+  []
+  (when @jetty-instance
+    (log/info "Shutting Down Embedded Jetty Webserver")
+    (.stop ^org.eclipse.jetty.server.Server @jetty-instance)
+    (reset! jetty-instance nil)))
+
+
 (defn -main
   "Launch Metabase in standalone mode."
   [& args]
   (log/info "Starting Metabase in STANDALONE mode")
-
-  ;; run application init and if there are no issues then continue on to launching the webserver
-  (when (try
-          (init)
-          (catch Exception e
-            (log/error "Metabase Initialization FAILED: " (.getMessage e))))
-    ;; startup webserver
-    (let [jetty-config (->> {:port (config/config-int :mb-jetty-port)
-                             :host (config/config-str :mb-jetty-host)
-                             :join? (config/config-bool :mb-jetty-join?)
-                             :daemon? (config/config-bool :mb-jetty-daemon?)
-                             :max-threads (config/config-int :mb-jetty-maxthreads)
-                             :min-threads (config/config-int :mb-jetty-minthreads)
-                             :max-queued (config/config-int :mb-jetty-maxqueued)
-                             :max-idle-time (config/config-int :mb-jetty-maxidletime)}
-                         (medley/filter-vals identity))]
-      (log/info "Launching Embedded Jetty Webserver with config:\n" (with-out-str (clojure.pprint/pprint jetty-config)))
-      (ring-jetty/run-jetty app jetty-config))))
+  (try
+    ;; run our initialization process
+    (init)
+    ;; launch embedded webserver
+    (start-jetty)
+    (catch Exception e
+      (log/error "Metabase Initialization FAILED: " (.getMessage e)))))


Darken note stripes when pressed

Darken note stripes when pressed

--- src/musicbox/one.cljs
+++ src/musicbox/one.cljs
@@ -8,15 +8,27 @@

 (def timbre js/T)

-(def colors ["6DA0CB" "A76AB9" "BB67A2" "C55D83" "D35E4C" "E18C43" "E1B040"])
+(def colors [{:light "6DA0CB" :dark "314B61"}
+             {:light "A76AB9" :dark "4F2F59"}
+             {:light "BB67A2" :dark "5E3152"}
+             {:light "C55D83" :dark "692F44"}
+             {:light "D35E4C" :dark "692B22"}
+             {:light "E18C43" :dark "6B401C"}
+             {:light "E1B040" :dark "69511A"}])

-(defn draw [draw-ctx interface notes]
-  (let [{w :w h :h} interface
-        note-count (count (:scale interface))
+;; later: use pagehide to cancel in-progress presses when leaving tab
+
+(defn draw [draw-ctx instrument]
+  (let [{w :w h :h} instrument
+        freqs (keys (:notes instrument))
+        note-count (count freqs)
         note-width (/ w note-count)]
     (.clearRect draw-ctx 0 0 w h)
     (dotimes [n note-count]
-      (set! (.-fillStyle draw-ctx) (nth colors (mod n (count colors))))
+      (let [note-on (:touch-id (get (:notes instrument) (nth freqs n)))]
+        (set! (.-fillStyle draw-ctx)
+              ((if note-on :dark :light)
+               (nth colors (mod n (count colors))))))
       (.fillRect draw-ctx (* n note-width) 0 note-width h))))

 (defn create-synth


set up a signalling channel between clients

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -480,6 +480,18 @@
                                                                                :recording? recording?
                                                                                :mouse-position mouse-position})]))))

+(defmethod ws-handler :rtc/signal [{:keys [client-id ?data] :as req}]
+  (check-document-access (-> ?data :document/id) req :read)
+  (let [document-id (:document/id ?data)
+        consumer (-> ?data :consumer)
+        producer (-> ?data :producer)
+        target (first (filter #(not= client-id %) [consumer producer]))
+        data (select-keys ?data [:candidate :sdp :consumer :producer :subscribe-to-recording?])]
+    (assert (get-in @document-subs [document-id target])
+            (format "%s is the target, but isn't subscribed to %s" target document-id))
+    (log/infof "sending signal from %s to %s" client-id target)
+    ((:send-fn @sente-state) target [:rtc/signal data])))
+
 (defmethod ws-handler :frontend/update-self [{:keys [client-id ?data] :as req}]
   ;; TODO: update subscribers in a different way
   (check-document-access (-> ?data :document/id) req :read)


Remove calls to vec that were not needed

This matches the changes to the compojure test.

--- luminus/hello/src/hello/models/db.clj
+++ luminus/hello/src/hello/models/db.clj
@@ -28,19 +28,17 @@

 ; Run the specified number of queries, return the results
 (defn run-queries [queries]
-  (vec ; Return as a vector
    (flatten ; Make it a list of maps
     (take
      queries ; Number of queries to run
-     (repeatedly get-world)))))
+     (repeatedly get-world))))

 ; Run the specified number of queries, return the results
 (defn run-queries-raw [queries]
-  (vec ; Return as a vector
    (flatten ; Make it a list of maps
     (take
      queries ; Number of queries to run
-     (repeatedly get-world-raw)))))
+     (repeatedly get-world-raw))))

 (defn get-query-count [queries]
   "Parse provided string value of query count, clamping values to between 1 and 500."


:lipstick: Minor cosmetic change on frame memo equals func.

--- frontend/src/uxbox/main/ui/shapes/frame.cljs
+++ frontend/src/uxbox/main/ui/shapes/frame.cljs
@@ -31,32 +31,28 @@
 (declare frame-shape)
 (declare translate-to-frame)

-(defn wrap-memo-frame
-  ([component]
-   (mf/memo'
-    component
-    (fn [np op]
-      (let [n-shape (aget np "shape")
-            o-shape (aget op "shape")
-            n-objs  (aget np "objects")
-            o-objs  (aget op "objects")
+(defn frame-wrapper-memo-equals?
+  [np op]
+  (let [n-shape (aget np "shape")
+        o-shape (aget op "shape")
+        n-objs  (aget np "objects")
+        o-objs  (aget op "objects")

-            ids (:shapes n-shape)]
-        (and (identical? n-shape o-shape)
-             (loop [id (first ids)
-                    ids (rest ids)]
-               (if (nil? id)
-                 true
-                 (if (identical? (get n-objs id)
-                                 (get o-objs id))
-                   (recur (first ids) (rest ids))
-                   false)))))))))
-
+        ids (:shapes n-shape)]
+    (and (identical? n-shape o-shape)
+         (loop [id (first ids)
+                ids (rest ids)]
+           (if (nil? id)
+             true
+             (if (identical? (get n-objs id)
+                             (get o-objs id))
+               (recur (first ids) (rest ids))
+               false))))))

 (defn frame-wrapper
   [shape-wrapper]
   (mf/fnc frame-wrapper
-    {::mf/wrap [wrap-memo-frame]}
+    {::mf/wrap [#(mf/memo' % frame-wrapper-memo-equals?)]}
     [{:keys [shape objects] :as props}]
     (let [selected-iref (-> (mf/deps (:id shape))
                             (mf/use-memo #(refs/make-selected (:id shape))))


one recursive macro replaces two flat macros

--- src/splash/macros.clj
+++ src/splash/macros.clj
@@ -1,25 +1,26 @@
 (ns splash.macros)

-;(def ^:dynamic *canvas* nil)
-;(def ^:dynamic *layer* nil)
+(defmacro ^:private assert-args
+  [& pairs]
+  `(do (when-not ~(first pairs)
+         (throw (IllegalArgumentException.
+                  (str (first ~'&form) " requires " ~(second pairs) " in " ~'*ns* ":" (:line (meta ~'&form))))))
+     ~(let [more (nnext pairs)]
+        (when more
+          (list* `assert-args more)))))

-(defmacro ignore [& body]
-  '())
+(defmacro with-sprite [canvas layer bindings & body]
+  (assert-args
+   (vector? bindings) "a vector for its binding"
+   (even? (count bindings)) "an even number of forms in binding vector")
+
+  (if (pos? (count bindings))
+    (let [symb (first bindings) val (second bindings)]
+      `(let [~symb ~val]
+         (.addChild (-> ~canvas :layer ~layer) ~symb)
+         (with-sprites ~canvas ~layer ~(subvec bindings 2) ~@body)
+         (.removeChild (-> ~canvas :layer ~layer) ~symb)))
+    `(do ~@body)))

-(defmacro with-sprite [canvas layer [symb bind] & body]
-  `(let [~symb ~bind]
-     (.addChild (-> ~canvas :layer ~layer) ~symb)
-     (do ~@body)
-     (.removeChild (-> ~canvas :layer ~layer) ~symb)))
-
-;; todo: reqrite these two macros recursively
-(defmacro with-sprites [canvas layer binds & body]
-  (let [symbols (map first (partition 2 binds))]
-    (list 'let binds
-          (concat (map (fn [symb] `(.addChild (-> ~canvas :layer ~layer) ~symb)) symbols)
-                  [(cons 'do body)]
-                  (map (fn [symb] `(.removeChild (-> ~canvas :layer ~layer) ~symb)) (reverse symbols))))))
-
-
-(macroexpand '(with-sprites canv lay [a my-a b my-b] (do1) (do2)))
+(macroexpand '(with-sprites canv lay [] (do1) (do2)))


Revert "Refactor http async pool client"

--- scheduler/src/clj_http_async_pool/client.clj
+++ scheduler/src/clj_http_async_pool/client.clj
@@ -19,43 +19,47 @@
   (:require [clj-http-async-pool.core :refer :all])
   (:refer-clojure :exclude (get update)))

-(defn- make-req
-  [this url req method]
-  (request this (merge req {:url url
-                            :method method})))
-
 (defn get
   [this url req]
-  (make-req this url req :get))
+  (request this (merge req {:url url
+                            :method :get})))

 (defn head
   [this url req]
-  (make-req this url req :head))
+  (request this (merge req {:url url
+                            :method :head})))

 (defn post
   [this url req]
-  (make-req this url req :post))
+  (request this (merge req {:url url
+                            :method :post})))

 (defn put
   [this url req]
-  (make-req this url req :put))
+  (request this (merge req {:url url
+                            :method :put})))

 (defn delete
   [this url req]
-  (make-req this url req :delete))
+  (request this (merge req {:url url
+                            :method :delete})))

 (defn options
   [this url req]
-  (make-req this url req :options))
+  (request this (merge req {:url url
+                            :method :options})))

 (defn copy
   [this url req]
-  (make-req this url req :copy))
+  (request this (merge req {:url url
+                            :method :copy})))

 (defn move
   [this url req]
-  (make-req this url req :move))
+  (request this (merge req {:url url
+                            :method :move})))

 (defn patch
   [this url req]
-  (make-req this url req :patch))
+  (request this (merge req {:url url
+                            :method :patch})))


render all .text

render all .text

--- src-cljs/irc_logger/core.cljs
+++ src-cljs/irc_logger/core.cljs
@@ -95,7 +95,7 @@
 (defn main-log []
   (let [name-el (sel :.user)
         time-el (sel :time)
-        text-el (sel [:.PRIVMSG :.text])]
+        text-el (sel :.text)]
     (doseq [name-e name-el]
       (let [name (dommy/text name-e)]
         (dommy/add-class! name-e (get-color-class name))))
@@ -153,13 +153,11 @@
                 [:a {:title (row :user)
                      :class (str "user "(get-color-class (row :nick)))}
                  (row :nick)]
-                [:p.text (if true; (= (row :coammand) "PRIVMSG")
-                           (-> (row :text)
-                               (html-escape)
-                               (parse-text)
-                               (parse-url)
-                               (parse-image))
-                           (html-escape (row :text)))]])
+                [:p.text (-> (row :text)
+                             (html-escape)
+                             (parse-text)
+                             (parse-url)
+                             (parse-image))]])
              log)))

 (defn main-search []


Новые компоненты

Новые компоненты


detect api port accordingly

detect api port accordingly

--- frontend/src/leftover/core.cljs
+++ frontend/src/leftover/core.cljs
@@ -14,7 +14,14 @@
 (defonce app-state (atom {:state :enter-payment
                       :data {}}))

-(def base-url (str "http://" (.. js/document -location -hostname) ":8000"))
+; if using figwheel, connect to separate port
+; otherwise, use the same port as source
+(def source-port (.. js/document -location -port))
+(if (= "3449" source-port)
+  (def port "8000")
+  (def port source-port))
+
+(def base-url (str "http://" (.. js/document -location -hostname) ":" port))

 ; handle events from the UI
 (go (loop []


Fix typo in lint error message

Fix typo in lint error message

--- ring-devel/src/ring/middleware/lint.clj
+++ ring-devel/src/ring/middleware/lint.clj
@@ -70,7 +70,7 @@
     "Ring response must be a Clojure map")

   (lint (:status resp) #(and (integer? %) (>= % 100))
-    ":status must be an Intger greater than or equal to 100")
+    ":status must be an Integer greater than or equal to 100")

   (let [headers (:headers resp)]
     (lint headers map?


add 3rd singular present "goes down/upstairs"

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -480,7 +480,8 @@
                     :discrete false
                     :pred :go-downstairs
                     :subj {:animate true}}}
-    :english {:past "went downstairs"}}
+    :english {:past "went downstairs"
+              :present {:3sing "goes downstairs"}}}

    "go upstairs"
    {:synsem {:cat :verb
@@ -488,7 +489,8 @@
                     :discrete false
                     :pred :go-upstairs
                     :subj {:animate true}}}
-    :english {:past "went upstairs"}}
+    :english {:past "went upstairs"
+              :present {:3sing "goes downstairs"}}}

    "grab"  {:synsem {:cat :verb
                      :sem {:pred :prendere}}


Add explicit function for apply rotation.


Improve system/exec; set default timeout to 1 s

--- src/cider_ci/utils/system.clj
+++ src/cider_ci/utils/system.clj
@@ -10,13 +10,22 @@
     ))

-(defn exec [& args]
-  (logging/debug exec [args])
-  (let [res @(apply commons-exec/sh args)]
-    (if (not= 0 (:exit res))
-      (throw (IllegalStateException. (str "Unsuccessful shell execution"
-                                          args
-                                          (:err res)
-                                          (:out res))))
-      res)))
+(defn exec
+  ([command]
+   (exec command {}))
+  ([command opts]
+   (let [options (conj {:watchdog 1000} opts)
+         res @(commons-exec/sh command options)]
+     (logging/debug exec {:res res})

+     (if (not= 0 (:exit res))
+       (throw (IllegalStateException. (str "Unsuccessful shell execution"
+                                           command
+                                           options
+                                           {:result res})))
+       res)
+     )))
+
+
+;(exec ["ls" "-lah"]{:dir "/tmp"})
+;(exec ["sleep" "1"])


Fix initialization issue in launch window

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/launch_analysis.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/launch_analysis.cljs
@@ -78,7 +78,7 @@

 (defn render-form [entities state refs props]
   (let [entity-map (group-by #(% "entityType") entities)
-        filter (or (:filter @state) "Sample")
+        filter (or (:filter @state) (:root-entity-type props) "Sample")
         filtered-entities (entity-map filter)
         selected-entity (or (:selected-entity @state) (first filtered-entities))]
     [:div {:style {:padding "22px 48px 40px" :backgroundColor (:background-gray style/colors)}}
@@ -94,7 +94,7 @@
         (style/create-form-label "Select Entity Type")
         (style/create-select
          {:style {:width "50%" :minWidth 50 :maxWidth 200} :ref "filter"
-          :defaultValue (:root-entity-type props)
+          :defaultValue (or (:root-entity-type props) "Sample")
           :onChange #(let [value (common/get-text refs "filter")]
                        (swap! state assoc :filter value))}
          (keys entity-map))


Add route for getting card info

Add route for getting card info

--- src/clj/decktouch/handler.clj
+++ src/clj/decktouch/handler.clj
@@ -1,8 +1,11 @@
 (ns decktouch.handler
   (:require [decktouch.dev :refer [browser-repl start-figwheel]]
-            [compojure.core :refer [GET defroutes]]
+            [compojure.core :refer [GET POST defroutes]]
             [compojure.route :refer [not-found resources]]
             [ring.middleware.defaults :refer [site-defaults wrap-defaults]]
+            [ring.middleware.params :refer [wrap-params]]
+            [ring.middleware.reload :refer [wrap-reload]]
+            [ring.adapter.jetty :as jetty]
             [selmer.parser :refer [render-file]]
             [environ.core :refer [env]]
             [prone.middleware :refer [wrap-exceptions]]
@@ -14,9 +17,12 @@
   (GET "/data/input/:query" [query]
        (json/write-str
          (mtg-card-master/get-cards-matching-query query)))
+  (POST "/data/card" request
+        (let [card-name ((request :params) "card-name")]
+          (str (mtg-card-master/get-card-info card-name))))
   (resources "/")
   (not-found "Not Found"))

 (def app
-  (let [handler (wrap-defaults routes site-defaults)]
-    (if (env :dev?) (wrap-exceptions handler) handler)))
+  (let [handler (wrap-reload (wrap-params routes site-defaults))]
+    (if (env :dev?) (wrap-reload (wrap-exceptions handler)) handler)))


Fixed service/status-loading? to also check for ReadyStatus with optional LoadingStatus set (for live updating).

--- src/clj/elephantdb/thrift.clj
+++ src/clj/elephantdb/thrift.clj
@@ -27,7 +27,10 @@
   (= (.getSetField domain-status) DomainStatus$_Fields/FAILED))

 (defn status-loading? [#^DomainStatus domain-status]
-  (= (.getSetField domain-status) DomainStatus$_Fields/LOADING))
+  (let [field (.getSetField domain-status)]
+    (or (= field DomainStatus$_Fields/LOADING)
+        (and (= field DomainStatus$_Fields/READY)
+             (.get_update_status (.get_ready domain-status))))))

 (defn domain-not-found-ex [domain]
   (DomainNotFoundException. domain))


doc changes to rain.

doc changes to rain.

--- src/clj/forma/source/rain.clj
+++ src/clj/forma/source/rain.clj
@@ -193,10 +193,12 @@

 (defn rain-months
   "Cascalog subquery to extract all months from a directory of PREC/L
-  datasets at the supplied WGS84 spatial step, paired with a
-  datestring of the format `yyyy-mm-dd`. Source can be any tap that
-  supplies PRECL files named precl_mon_v1.0.lnx.YYYY.gri0.5m(.gz,
-  optionally)."
+  datasets with the supplied map of WGS84 dataset information, paired
+  with a datestring of the format `yyyy-mm-dd`. (See `forma.static`
+  for examples of well-formed wgs84 dataset maps.)
+
+  Source can be any tap that supplies PRECL files named
+  precl_mon_v1.0.lnx.YYYY.gri0.5m(.gz, optionally)."
   [ascii-info source]
   (let [step (:step ascii-info)]
     (<- [?dataset ?temporal-res ?date ?raindata]
@@ -223,7 +225,7 @@
 ;; two sets. We accomplish this by feeding every tuple into
 ;; `forma.hadoop.predicate/add-fields` with argument `m-res`, the
 ;; supplied MODIS resolution into which we're translating the PRECL
-;; sets. `identity` produces the common dynamic variable
+;; sets. `add-fields` produces the common dynamic variable
 ;; `?spatial-res`, needed by `fancy-index`.

 (defn cross-join
@@ -270,7 +272,7 @@
   "Cascalog subquery to fully process a WGS84 float array at the
   supplied resolution (`:step`, within `ascii-map`) into tuples
   suitable for comparison to any MODIS dataset at the supplied modis
-  resolution (`m-res`), partitioned by the supplied chunk size."
+  resolution `m-res`, partitioned by the supplied chunk size."
   [m-res ascii-map chunk-size tile-seq source]
   (let [rnd (int (* 100000 (rand)))
         tmp (hfs-seqfile (str "/tmp/" rnd))]


implement Mumba Temple

implement Mumba Temple

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -362,6 +362,9 @@
     :leave-play (effect (lose :runner :max-hand-size 1))
     :derezzed-events {:runner-turn-ends corp-rez-toast}
     :events {:corp-turn-begins {:msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}
+
+   "Mumba Temple"
+   {:recurring 2}

    "Net Police"
    {:recurring (effect (set-prop card :rec-counter (:link runner)))


prevent bug on click/trash assets when they have 0 counters

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -22,8 +22,8 @@
    "Alix T4LB07"
    {:events {:corp-install {:effect (effect (add-prop card :counter 1))}}
     :abilities [{:cost [:click 1] :label "Gain 2 [Credits] for each counter on Alix T4LB07"
-                 :msg (msg "gain " (* 2 (:counter card)) " [Credits]")
-                 :effect (effect (gain :credit (* 2 (:counter card))) (trash card))}]}
+                 :msg (msg "gain " (* 2 (get card :counter 0)) " [Credits]")
+                 :effect (effect (gain :credit (* 2 (get card :counter 0))) (trash card))}]}

    "Allele Repression"
    {:advanceable :always
@@ -219,8 +219,8 @@
    "GRNDL Refinery"
    {:advanceable :always
     :abilities [{:label "Gain 4 [Credits] for each advancement token on GRNDL Refinery"
-                 :cost [:click 1] :msg (msg "gain " (* 4 (:advance-counter card)) " [Credits]")
-                 :effect (effect (trash card) (gain :credit (* 4 (:advance-counter card))))}]}
+                 :cost [:click 1] :msg (msg "gain " (* 4 (get card :advance-counter 0)) " [Credits]")
+                 :effect (effect (trash card) (gain :credit (* 4 (get card :advance-counter 0))))}]}

    "Haas Arcology AI"
    {:advanceable :while-unrezzed
@@ -388,8 +388,8 @@
    {:advanceable :always
     :access {:optional {:prompt "Pay 1 [Credits] to use Project Junebug ability?"
                         :req (req (and installed (> (:credit corp) 0)))
-                        :yes-ability {:cost [:credit 1] :msg (msg "do " (* 2 (:advance-counter card)) " net damage")
-                                      :effect (effect (damage :net (* 2 (:advance-counter card)) {:card card}))}}}}
+                        :yes-ability {:cost [:credit 1] :msg (msg "do " (* 2 (get card :advance-counter 0)) " net damage")
+                                      :effect (effect (damage :net (* 2 (get card :advance-counter 0)) {:card card}))}}}}

    "Psychic Field"
    (let [ab {:psi {:req (req installed)
@@ -415,8 +415,8 @@
    {:advanceable :always
     :abilities [{:cost [:click 1]
                  :label "Force the Runner to lose 4 [Credits] per advancement"
-                 :msg (msg "force the Runner to lose " (min (* 4 (:advance-counter card)) (:credit runner)) " [Credits]")
-                 :effect (effect (lose :runner :credit (* 4 (:advance-counter card))) (trash card))}]}
+                 :msg (msg "force the Runner to lose " (min (* 4 (get card :advance-counter 0)) (:credit runner)) " [Credits]")
+                 :effect (effect (lose :runner :credit (* 4 (get card :advance-counter 0))) (trash card))}]}

    "Rex Campaign"
    {:effect (effect (add-prop card :counter 3))
@@ -600,8 +600,8 @@

    "Thomas Haas"
    {:advanceable :always
-    :abilities [{:label "Gain credits" :msg (msg "gain " (* 2 (:advance-counter card)) " [Credits]")
-                 :effect (effect (gain :credit (* 2 (:advance-counter card))) (trash card))}]}
+    :abilities [{:label "Gain credits" :msg (msg "gain " (* 2 (get card :advance-counter 0)) " [Credits]")
+                 :effect (effect (gain :credit (* 2 (get card :advance-counter 0))) (trash card))}]}

    "Toshiyuki Sakai"
    {:advanceable :always}


improve normalization

improve normalization

--- src/cljam/util/chromosome.clj
+++ src/cljam/util/chromosome.clj
@@ -1,35 +1,38 @@
 (ns cljam.util.chromosome
-  (:require [clojure.string :as str]))
+  (:require [clojure.string :as cstr]))

 (defn normalize-name
   [s]
   (-> s
-      (str/replace #"\."  "_")
-      (str/replace #","  "_")
-      (str/replace #"\""  "")
-      (str/replace #"\'"  "")))
+      (cstr/replace #"\."  "_")
+      (cstr/replace #","  "_")
+      (cstr/replace #"\""  "")
+      (cstr/replace #"\'"  "")))

 (defn trim-chromosome-key
   [s]
   (-> s
-      (str/replace #"Chr" "")
-      (str/replace #"chr" "")))
+      (cstr/replace #"Chr" "")
+      (cstr/replace #"chr" "")))

 (defn- normalize-chromosome-prefix
   [s]
-  (let [m (re-matches #"(?i)^chr([0-9]+|X|Y|M|MT)" s)]
+  (let [m (re-matches #"(?i)^chr([0-9]{1,2}|X|Y|M|MT)(.*)$" s)]
     (if (nil? m)
       s
-      (let [[_ tail] m]
-        (str "chr" (str/upper-case tail))))))
+      (let [[_ base leftover] m
+            base  (if (re-find #"^\d+$" base)
+                    (str (Integer. base))
+                    base)]
+        (str "chr" (cstr/upper-case (str base leftover)))))))

 (defn- prepend-chromosome-prefix
   [s]
-  (let [m (re-matches #"(?i)^([0-9]+|X|Y|M|MT)" s)]
+  (let [m (re-matches #"(?i)^([0-9]{1,2}|X|Y|M|MT)(.*)$" s)]
     (if (nil? m)
       s
-      (let [[_ tail] m]
-        (str "chr" (str/upper-case tail))))))
+      (let [[_ base leftover] m]
+        (str "chr" (cstr/upper-case (str base leftover)))))))

 (defn normalize-chromosome-key
   [s]


Initial working version with content type hack

Couldn't get blob or arraybufffer working
Will give it another go :)

--- src/cljs/my_project/core.cljs
+++ src/cljs/my_project/core.cljs
@@ -40,7 +40,9 @@
     [cljs.core.async        :refer [put! >! chan <! alts! close! dropping-buffer mult tap]]
     [ff-om-draggable.core   :refer [draggable-item]]

+    [goog.crypt             :as crypt]
     [goog.crypt.base64      :as b64]
+    [goog.labs.net.xhr      :as xhr2]

     [om.core                :as om :include-macros true]
     [om.dom                 :as dom :include-macros true]))
@@ -49,6 +51,112 @@
 (enable-console-print!)

 ;;; }}}
+
+;; =============================================================================
+;; {{{ XHR2 experiment
+
+(def file-name "/data/tiles.png")
+
+
+
+(defprotocol IBytesPlz
+  (get-str [_])
+  (get-b64 [_])
+  (get-bytes [_ ]))
+; var utf8 = unescape(encodeURIComponent(str));
+
+; var arr = [];
+; for  var i = 0; i < utf8.length; i++) {
+;     arr.push(utf8.charCodeAt(i));
+
+(defn get-bytes-str [this]
+  (let [ret (js/Uint8ClampedArray. (count this))]
+    (doseq [i (range (count this))]
+      (let [c (.charCodeAt this i)]
+
+        (aset ret i (bit-and 0xff(if (< c 0)
+                      (- 65536 c)
+                      c)) )))
+    ret
+    ))
+
+(extend-type js/XMLHttpRequest
+  IBytesPlz
+
+  (get-str [this]
+    (.-responseText this))
+
+  (get-b64 [this]
+    (->
+      this
+      (get-bytes)
+      (b64/encodeByteArray)))
+
+  (get-bytes [this]
+    (->
+      this
+
+      ; (get-str)
+      ; (get-bytes-str)
+      (get-str)
+      (crypt/stringToUtf8ByteArray)
+      )))
+
+
+
+(def opts #js {"Content-type" "text/plain;charset=x-user-defined"
+               "responseType" "blob"})
+
+; (def ret (xhr2/send "GET" file-name nil opts))
+
+
+; (.then ret (fn [r]
+;              (let [arr (get-bytes r)
+;                    enc (get-b64 r)
+;                    ostr (get-str r) ]
+
+;                (println (.charCodeAt ostr 0))
+;                (println (.charCodeAt ostr 1))
+;                (log-js (get-bytes-str ostr))
+
+;                )
+
+;              ))
+
+
+(defn rep-array [arr]
+  (str "size: " (.-length arr) "\n"
+       "type: " (type arr) "\n"))
+
+(defn gaz-send [uri cb]
+  (let [xhr (js/XMLHttpRequest.) ]
+    (do
+      (.open xhr "GET" uri true)
+      (.overrideMimeType xhr "text/plain; charset=x-user-defined")
+      (aset xhr "onreadystatechange"
+            (fn [e]
+              (let [ready-state (.-readyState xhr)
+                    status (.-status xhr)
+                    arr (get-bytes-str (.-responseText xhr)) ]
+                (when (and (== ready-state 4) (== status 200))
+                  (cb arr)
+                  )
+                )))
+      (.send xhr))))
+
+
+(gaz-send file-name (fn [i]
+                      (log-js i)
+                      ))
+
+
+
+
+
+
+
+
+;; }}}

 ;; {{{ Ignore for now
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Timer

Timer

Hires timer now works

--- src/cljs/my_project/core.cljs
+++ src/cljs/my_project/core.cljs
@@ -46,38 +46,27 @@

 ;;; }}}

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Log Window
-(def log-chan (chan))
-(def log-state (atom {}) )
-
-(defn log-window
-  [{:keys [in-chan class-name] :as data} owner ]
-  (let [in-chan    (or in-chan (chan))
-        class-name (or class-name "pane")]
-    (reify
-      om/IWillMount
-      (will-mount [ this ]
-        (go
-          (om/set-state! owner :text "")
-          (loop []
-            (let [txt (<! in-chan)
-                  txt-req {:text txt}]
-              (om/update-state! owner [:text] #(str % "\n" txt ))
-              (recur)))))
-
-      om/IRenderState
-      (render-state [_ {:keys [text]}]
-        (dom/div
-          #js { :className class-name }
-          (dom/span nil "Logs")
-          (dom/textarea #js {:width "100%" :value text}))))))
-
-(def draggable-log-window (draggable-item log-window [:position]))
-
-;; }}}
-
+;; {{{ Ignore for now
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; {{{ Game obect
+(def pogue-game
+  (game/make-game
+    (reify
+      game/IGameInit
+      (game-init [this]
+        this)
+
+      game/IGameUpdate
+      (game-update [this dt]
+        this)
+
+      game/IGameClose
+      (game-close [this]
+        this))))
+;; }}}
+
+
 ;; {{{ FPS Component

 (def time-chan (chan))
@@ -122,56 +111,6 @@
                  )))))
 ;; }}}

-; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Timer
-(defprotocol ITimer
-  (tick! [_]))
-
-(defn is-valid? [{:keys [previous now] :as c}]
-  (not (or
-         (nil? previous)
-         (nil? now))))
-
-(defn time-passed [{:keys [previous now] :as c}]
-  (if (is-valid? c)
-    (- now previous)
-    0))
-
-(defn html-timer []
-  (let [c (atom {:previous nil
-                 :now nil})]
-    (reify ITimer
-      (tick! [_]
-        (do
-          (swap!  c assoc
-               :previous (:now @c)
-               :now (.now js/performace)))
-        (if (is-valid? @c)
-          (- (:now @c) (:previous @c))
-          0)))))
-
-;; }}}
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Every Frame
-(defprotocol IEveryFrame
-  (get-fps [_])
-  (get-ms-per-frame [_])
-  (every [_ f]))
-;; }}}
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Timer
-(def my-timer (html-timer))
-
-(defn animate [f]
-  (do
-    (.requestAnimationFrame js/window animate)
-    (let [dt (tick! my-timer)]
-      (when (not= dt 0)
-        (f dt)))))
-
-;;; }}}

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; {{{ Log Window
@@ -204,7 +143,39 @@

 ;; }}}

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; {{{ Log Window
+(def log-chan (chan))
+(def log-state (atom {}) )
+
+(defn log-window
+  [{:keys [in-chan class-name] :as data} owner ]
+  (let [in-chan    (or in-chan (chan))
+        class-name (or class-name "pane")]
+    (reify
+      om/IWillMount
+      (will-mount [ this ]
+        (go
+          (om/set-state! owner :text "")
+          (loop []
+            (let [txt (<! in-chan)
+                  txt-req {:text txt}]
+              (om/update-state! owner [:text] #(str % "\n" txt ))
+              (recur)))))
+
+      om/IRenderState
+      (render-state [_ {:keys [text]}]
+        (dom/div
+          #js { :className class-name }
+          (dom/span nil "Logs")
+          (dom/textarea #js {:width "100%" :value text}))))))
+
+(def draggable-log-window (draggable-item log-window [:position]))
+
+;; }}}
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; {{{ FPS Component

 (def time-chan (chan))
@@ -249,8 +220,11 @@
                  )))))
 ;; }}}

-; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Timer / Animation Stuff
+
+;; }}}
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;; {{{ Timer
 (defprotocol ITimer
   (tick! [_]))

@@ -266,55 +240,50 @@

 (defn html-timer []
   (let [c (atom {:previous nil
-                 :now nil})]
+                 :now nil}) ]
     (reify ITimer
       (tick! [_]
-        (do
-          (swap!  c assoc
-               :previous (:now @c)
-               :now (.now js/performace)))
-        (if (is-valid? @c)
-          (- (:now @c) (:previous @c))
-          0)))))
+        (let [perf-now    (.now (aget js/window "performance"))
+              new-c (assoc @c
+                           :previous (:now @c)
+                           :now perf-now)  ]
+          (do
+            (reset! c new-c)
+            (time-passed new-c)))))))
+
+;; }}}
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; {{{ Animator with Timer
+
+(defprotocol IEveryFrame
+  (get-fps [_])
+  (get-ms-per-frame [_])
+  (every [_ f]))

 (def my-timer (html-timer))

-(defn animate [f]
+(defn animate [callback-fn]
   (do
-    (.requestAnimationFrame js/window animate)
+    (.requestAnimationFrame js/window #(animate callback-fn))
     (let [dt (tick! my-timer)]
       (when (not= dt 0)
-        (f dt)))))
-
-;; }}}
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; {{{ Game obect
-(def pogue-game
-  (game/make-game
-    (reify
-      game/IGameInit
-      (game-init [this]
-        this)
-
-      game/IGameUpdate
-      (game-update [this dt]
-        this)
-
-      game/IGameClose
-      (game-close [this]
-        this))))
-;; }}}
+        (callback-fn dt)))))
+
+;;; }}}

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; {{{ Main

 (defonce first-time? (atom true))

+(defn do-update [ dt ]
+ (put! time-chan dt) )
+
 (when @first-time?
-    (do
-      (swap! first-time? not)
-      (js/setInterval (fn [] (put! time-chan (/ 1 60))) 16)))
+  (do
+    (swap! first-time? not)
+    (animate do-update)))

 (defn main []
   (do
@@ -323,18 +292,18 @@
       {:in-chan time-chan :class-name "pane" }
       {:target (by-id "test") })

-    (om/root
-      draggable-log-window
-      {:in-chan log-chan :class-name "pane" :position {:left 100 :top 20}}
-      {:target (by-id "app")}
-      )
-
     (let [rm (rmhtml/mk-resource-manager "resources")
           _ (clear-resources! rm)
           ; img-chan (load-img! rm "tiles")
           rend (create-render-target! rm "shit" 300 300) ]
-      )
-    )
+      ))
+
+  ; {{{
+
+    ; (om/root
+    ;   draggable-log-window
+    ;   {:in-chan log-chan :class-name "pane" :position {:left 100 :top 20}}
+    ;   {:target (by-id "app")})

   ; (let [rm (rmhtml/mk-resource-manager "resources")
   ;       _ (clear-resources! rm)
@@ -344,6 +313,7 @@
   ;     (let [img (<! img-chan)]
   ;       (log-js (rman/height img))
   ;       (log-js (rman/width img)))))
+  ; }}}
   )

 ;; }}}


Create new `process-generation` function (#246)

By refactoring this logic out of the `loop` into a function, we can
now more easily run it by itself for profiling purposes and record
it's inputs.

--- src/clojush/pushgp/pushgp.clj
+++ src/clojush/pushgp/pushgp.clj
@@ -7,7 +7,7 @@
         [clojush.instructions boolean code common numbers random-instructions string char vectors
          tag zip environment input-output genome]
         [clojush.pushgp breed report]
-        [clojush.pushgp.selection
+        [clojush.pushgp.selection
          selection epsilon-lexicase elitegroup-lexicase implicit-fitness-sharing novelty]
         [clojush.experimental.decimation]))

@@ -40,7 +40,7 @@
   (let [population-agents (vec (repeatedly population-size
                                            #(make-individual
                                               :genome (strip-random-insertion-flags
-                                                        (random-plush-genome
+                                                        (random-plush-genome
                                                           max-genome-size-in-initial-program
                                                           atom-generators
                                                           argmap))
@@ -56,8 +56,8 @@
   [{:keys [use-single-thread population-size]}]
   (vec (repeatedly population-size
                    #((if use-single-thread atom agent)
-                      (make-individual)
-                      :error-handler agent-error-handler))))
+                     (make-individual)
+                     :error-handler agent-error-handler))))

 (defn make-rng
   "Creates the random number generators used by the agents in the population.
@@ -66,8 +66,8 @@
   (let [random-seeds (loop [seeds '()]
                        (let [num-remaining (- population-size (count seeds))]
                          (if (pos? num-remaining)
-                           (let [new-seeds (repeatedly num-remaining
-                                                       #(random/lrand-bytes
+                           (let [new-seeds (repeatedly num-remaining
+                                                       #(random/lrand-bytes
                                                           (:mersennetwister random/*seed-length*)))]
                              (recur (list-concat seeds (filter ; only add seeds that we do not already have
                                                          (fn [candidate]
@@ -76,8 +76,8 @@
                            seeds)))]
     {:random-seeds random-seeds
      :rand-gens (vec (doall (for [k (range population-size)]
-                              (random/make-mersennetwister-rng (nth random-seeds k)))))
-     }))
+                              (random/make-mersennetwister-rng (nth random-seeds k)))))}))
+

 (defn compute-errors
   [pop-agents rand-gens {:keys [use-single-thread error-function] :as argmap}]
@@ -95,7 +95,7 @@

 (defn produce-new-offspring
   [pop-agents child-agents rand-gens
-   {:keys [decimation-ratio population-size decimation-tournament-size use-single-thread ]}]
+   {:keys [decimation-ratio population-size decimation-tournament-size use-single-thread]}]
   (let [pop (if (>= decimation-ratio 1)
               (vec (doall (map deref pop-agents)))
               (decimate (vec (doall (map deref pop-agents)))
@@ -106,16 +106,16 @@
     (reset! max-age (apply max ages))
     (dotimes [i population-size]
       ((if use-single-thread swap! send)
-           (nth child-agents i)
-           breed
-           i (nth rand-gens i) pop @push-argmap)))
+       (nth child-agents i)
+       breed
+       i (nth rand-gens i) pop @push-argmap)))
   (when-not use-single-thread (apply await child-agents))) ;; SYNCHRONIZE

 (defn install-next-generation
   [pop-agents child-agents {:keys [population-size use-single-thread]}]
   (dotimes [i population-size]
     ((if use-single-thread swap! send)
-         (nth pop-agents i) (fn [av] (deref (nth child-agents i)))))
+     (nth pop-agents i) (fn [av] (deref (nth child-agents i)))))
   (when-not use-single-thread (apply await pop-agents))) ;; SYNCHRONIZE

 (defn check-genetic-operator-probabilities-add-to-one
@@ -145,86 +145,95 @@
       (reset! timer-atom (System/currentTimeMillis))
       (swap! timing-map assoc step (+ current-time-for-step (- @timer-atom start-time))))))

+
+(defn process-generation
+  "Processes the generation, returning [new novelty archive, return val],
+   where new novelty archive will be nil if we are done."
+  [rand-gens pop-agents child-agents generation novelty-archive]
+  (r/new-generation! generation)
+  (println "Processing generation:" generation) (flush)
+  (population-translate-plush-to-push pop-agents @push-argmap)
+  (timer @push-argmap :reproduction)
+  (print "Computing errors... ") (flush)
+  (compute-errors pop-agents rand-gens @push-argmap)
+  (println "Done computing errors.") (flush)
+  (timer @push-argmap :fitness)
+  ;; calculate solution rates if necessary for historically-assessed hardness
+  (calculate-hah-solution-rates pop-agents @push-argmap)
+  ;; create global structure to support elite group lexicase selection
+  (when (= (:parent-selection @push-argmap) :elitegroup-lexicase)
+    (build-elitegroups pop-agents @push-argmap))
+  ;; calculate implicit fitness sharing fitness for population
+  (when (= (:total-error-method @push-argmap) :ifs)
+    (calculate-implicit-fitness-sharing pop-agents @push-argmap))
+  ;; calculate epsilons for epsilon lexicase selection
+  (when (= (:parent-selection @push-argmap) :epsilon-lexicase)
+    (calculate-epsilons-for-epsilon-lexicase pop-agents @push-argmap))
+  ;; calculate novelty when necessary
+  (when (or (= (:parent-selection @push-argmap) :novelty-search)
+            (some #{:novelty} (:meta-error-categories @push-argmap)))
+    (calculate-novelty pop-agents novelty-archive @push-argmap))
+  (timer @push-argmap :other)
+  ;; report and check for success
+  (let [[outcome best] (report-and-check-for-success (vec (doall (map deref pop-agents)))
+                                                     generation @push-argmap)]
+    (r/generation-data! [:outcome] outcome)
+    (r/end-generation!)
+    (cond (= outcome :failure) (do (printf "\nFAILURE\n")
+                                   (flush)
+                                   [nil
+                                    (when (:return-simplified-on-failure @push-argmap)
+                                      (auto-simplify best
+                                                     (:error-function @push-argmap)
+                                                     (:final-report-simplifications @push-argmap)
+                                                     true
+                                                     500))])
+          (= outcome :continue) (let [next-novelty-archive
+                                      (list-concat novelty-archive
+                                                   (select-individuals-for-novelty-archive
+                                                     (map deref pop-agents)
+                                                     @push-argmap))]
+                                  (timer @push-argmap :report)
+                                  (println "\nProducing offspring...") (flush)
+                                  (produce-new-offspring pop-agents
+                                                         child-agents
+                                                         rand-gens
+                                                         @push-argmap)
+                                  (println "Installing next generation...") (flush)
+                                  (install-next-generation pop-agents child-agents @push-argmap)
+                                  [next-novelty-archive nil])
+          :else [nil (final-report generation best @push-argmap)])))
+
+
+
 (defn pushgp
   "The top-level routine of pushgp."
   ([] (pushgp '()))
   ([args]
-    (reset! timer-atom (System/currentTimeMillis))
-    (load-push-argmap args)
-    (when (some? (:record-host @push-argmap))
-      (r/host! (str (:record-host @push-argmap))))
-    (random/with-rng (random/make-mersennetwister-rng (:random-seed @push-argmap))
-      ;; set globals from parameters
-      (reset-globals)
-      (initial-report @push-argmap) ;; Print the inital report
-      (r/uuid! (:run-uuid @push-argmap))
-      (print-params (r/config-data! [:argmap] (dissoc @push-argmap :run-uuid)))
-      (check-genetic-operator-probabilities-add-to-one @push-argmap)
-      (timer @push-argmap :initialization)
-      (when (:print-timings @push-argmap)
-        (r/config-data! [:initialization-ms] (:initialization @timer-atom)))
-      (println "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")
-      (println "\nGenerating initial population...") (flush)
-      (let [pop-agents (make-pop-agents @push-argmap)
-            child-agents (make-child-agents @push-argmap)
-            {:keys [rand-gens random-seeds]} (make-rng @push-argmap)]
-        ;(print "Random seeds: ")
-        ;(doseq [seed random-seeds] (print " " seed))
-        ;(println)
-        ;; Main loop
-        (loop [generation 0
-               novelty-archive '()]
-          (r/new-generation! generation)
-          (println "Processing generation:" generation) (flush)
-          (population-translate-plush-to-push pop-agents @push-argmap)
-          (timer @push-argmap :reproduction)
-          (print "Computing errors... ") (flush)
-          (compute-errors pop-agents rand-gens @push-argmap)
-          (println "Done computing errors.") (flush)
-          (timer @push-argmap :fitness)
-          ;; calculate solution rates if necessary for historically-assessed hardness
-          (calculate-hah-solution-rates pop-agents @push-argmap)
-          ;; create global structure to support elite group lexicase selection
-          (when (= (:parent-selection @push-argmap) :elitegroup-lexicase)
-            (build-elitegroups pop-agents @push-argmap))
-          ;; calculate implicit fitness sharing fitness for population
-          (when (= (:total-error-method @push-argmap) :ifs)
-            (calculate-implicit-fitness-sharing pop-agents @push-argmap))
-          ;; calculate epsilons for epsilon lexicase selection
-          (when (= (:parent-selection @push-argmap) :epsilon-lexicase)
-            (calculate-epsilons-for-epsilon-lexicase pop-agents @push-argmap))
-          ;; calculate novelty when necessary
-          (when (or (= (:parent-selection @push-argmap) :novelty-search)
-                    (some #{:novelty} (:meta-error-categories @push-argmap)))
-            (calculate-novelty pop-agents novelty-archive @push-argmap))
-          (timer @push-argmap :other)
-          ;; report and check for success
-          (let [[outcome best] (report-and-check-for-success (vec (doall (map deref pop-agents)))
-                                                             generation @push-argmap)]
-            (r/generation-data! [:outcome] outcome)
-            (r/end-generation!)
-            (cond (= outcome :failure) (do (printf "\nFAILURE\n")
-                                         (if (:return-simplified-on-failure @push-argmap)
-                                           (auto-simplify best
-                                                          (:error-function @push-argmap)
-                                                          (:final-report-simplifications @push-argmap)
-                                                          true
-                                                          500)
-                                           (flush)))
-                  (= outcome :continue) (let [next-novelty-archive
-                                              (list-concat novelty-archive
-                                                           (select-individuals-for-novelty-archive
-                                                             (map deref pop-agents)
-                                                             @push-argmap))]
-                                          (timer @push-argmap :report)
-                                          (println "\nProducing offspring...") (flush)
-                                          (produce-new-offspring pop-agents
-                                                                 child-agents
-                                                                 rand-gens
-                                                                 @push-argmap)
-                                          (println "Installing next generation...") (flush)
-                                          (install-next-generation pop-agents child-agents @push-argmap)
-                                          (recur (inc generation)
-                                                 next-novelty-archive))
-                  :else  (final-report generation best @push-argmap))))))))
-
+   (reset! timer-atom (System/currentTimeMillis))
+   (load-push-argmap args)
+   (when (some? (:record-host @push-argmap))
+     (r/host! (str (:record-host @push-argmap))))
+   (random/with-rng (random/make-mersennetwister-rng (:random-seed @push-argmap))
+     ;; set globals from parameters
+     (reset-globals)
+     (initial-report @push-argmap) ;; Print the inital report
+     (r/uuid! (:run-uuid @push-argmap))
+     (print-params (r/config-data! [:argmap] (dissoc @push-argmap :run-uuid)))
+     (check-genetic-operator-probabilities-add-to-one @push-argmap)
+     (timer @push-argmap :initialization)
+     (when (:print-timings @push-argmap)
+       (r/config-data! [:initialization-ms] (:initialization @timer-atom)))
+     (println "\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;")
+     (println "\nGenerating initial population...") (flush)
+     (let [pop-agents (make-pop-agents @push-argmap)
+           child-agents (make-child-agents @push-argmap)
+           {:keys [rand-gens]} (make-rng @push-argmap)]
+       (loop [generation 0
+              novelty-archive '()]
+         (let [[next-novelty-archive return-val]
+               (process-generation rand-gens pop-agents child-agents
+                                   generation novelty-archive)]
+           (if (nil? next-novelty-archive)
+             return-val
+             (recur (inc generation) next-novelty-archive))))))))


Expose magicnonce.secretbox keybytes

Expose magicnonce.secretbox keybytes

--- src/caesium/magicnonce/secretbox.clj
+++ src/caesium/magicnonce/secretbox.clj
@@ -16,6 +16,8 @@
             [caesium.randombytes :as r]
             [caesium.crypto.generichash :as g])
   (:import [java.nio ByteBuffer]))
+
+(def keybytes s/keybytes)

 (defn secretbox-pfx
   "secretbox, with the given nonce embedded in the ciphertext as a prefix.


Update home function in web.clj

Update home function in web.clj

(response content) from home function causes the browser to download the index.html instead of rendering it.

Change to (render content request) in order to properly send the page to client.

--- examples/session/src/authexample/web.clj
+++ examples/session/src/authexample/web.clj
@@ -28,7 +28,7 @@
   (if-not (authenticated? request)
     (throw-unauthorized)
     (let [content (slurp (io/resource "index.html"))]
-      (response content))))
+      (render content request))))

 ;; Login page controller
 ;; It returns a login page on get requests.


update product transforms so not to look for "width" string etc to support other languages

--- src/clj/ikea_clojure_cup/product.clj
+++ src/clj/ikea_clojure_cup/product.clj
@@ -11,8 +11,16 @@
                            (s/select (s/class "ikea-measurements-table-row-child") site-htree))
         filter-fn #(remove cs/blank? (map cs/trim (filter string? (:content %))))]
     (reduce (fn [v m]
-              (conj v (concat (filter-fn m)
-                              (filter-fn (first (s/select (s/class "measure-quantity") m))))))
+              (let [d (filter-fn m)
+                    units (map #(cs/split % #" ") d)]
+                (conj v {:dimensions-and-weight (map #(-> (re-find #"\d+" %) Integer/parseInt) d)
+                         :packages (-> (filter-fn (first (s/select (s/class "measure-quantity") m)))
+                                       first
+                                       (cs/split #" ")
+                                       first
+                                       Integer/parseInt)
+                         :dimension-unit (-> units first last)
+                         :weight-unit (-> units last last)})))
             []
             table-rows)))

@@ -23,13 +31,14 @@
   (Integer/parseInt (nth (cs/split (first coll) #"\s") 2)))

 (defn- transform-packages [hick-packages]
-  (reduce (fn [v m]
-            (conj v {:width (dimension->int (filter-string-contains m "Width"))
-                     :height (dimension->int (filter-string-contains m "Height"))
-                     :length (dimension->int (filter-string-contains m "Length"))
-                     :weight (let [w (cs/split (first (filter-string-contains m "Weight")) #"\s")]
-                               (str (nth w 2) (nth w 3)))
-                     :quantity (Integer/parseInt (first (cs/split (first (filter-string-contains m "packages")) #" ")))}))
+  (reduce (fn [v {:keys [dimensions-and-weight packages weight-unit dimension-unit]}]
+            (conj v {:width (nth dimensions-and-weight 0)
+                     :height (nth dimensions-and-weight 1)
+                     :length (nth dimensions-and-weight 2)
+                     :weight (nth dimensions-and-weight 3)
+                     :quantity packages
+                     :weight-unit weight-unit
+                     :dimension-unit dimension-unit}))
           []
           hick-packages))

@@ -42,13 +51,13 @@
 ;; (count (get-hick-packages multi))
 ;; (transform-packages (get-hick-packages multi))

-
-
 (comment
   ;;multi
-  (product "au" "art" "20227125")
+  (product "au" "en" "art" "20227125")
   ;;single
-  (product "au" "art" "90263855")
+  (product "au" "en" "art" "90263855")
+  ;spr
+;;   (product "au" "en" "spr" "39111083")
   )

 (comment
@@ -1716,3 +1725,5 @@
         "\r\n"
         "\r\n"]}]}]}
   ))
+
+(def spr-sample )


MRG: whitespace conflict issue in merge

MRG: whitespace conflict issue in merge

--- src/clj_prj03/ch5_core_functions.clj
+++ src/clj_prj03/ch5_core_functions.clj
@@ -261,7 +261,7 @@
 (apply max [0 1 2])

 ; 4.2 partial
-;;
+;;

 (def add10 (partial + 10))
 (add10 3)
@@ -311,4 +311,3 @@
 (def my-pos? (my-complement neg?))
 (my-pos? 1)
 (my-pos? -1)
-


Fix for refresh + error

Fix for refresh + error

--- src/cljs-admin/sbsk_admin/views.cljs
+++ src/cljs-admin/sbsk_admin/views.cljs
@@ -361,5 +361,5 @@
                   [re-com/line]
                   (when-not (or @error @refreshing?) [actions])
                   (when-not (or @error @refreshing?) [tabs])
-                  (when @error (error-panel @error))
-                  (when @refreshing? (refreshing-panel))]])))
+                  (when (and (not @error) @refreshing?) (refreshing-panel))
+                  (when @error (error-panel @error))]])))