CLJS-1258: stack trace mapping does not appear to work with :asset-path

cljs.repl.browser
    - parse-file
      take repl-env as first arg, use supplied :host and :port to compute base
      url. if :asset-path supplied by opts use this over output-directory to
      remove leading path.
    - chrome-st-el->frame
      thread repl-env
    - firefox-st-el->frame
      thread repl-env
    - safari-st-el->frame
      thread repl-env
    - BrowserEnv
      fix malformed body,
    - repl-env*
      supply default :host

--- src/main/clojure/cljs/repl/browser.clj
+++ src/main/clojure/cljs/repl/browser.clj
@@ -213,23 +213,26 @@
        (cond-> column
          (.endsWith column ")") (string/replace ")" "")))]))

-(defn parse-file [file opts]
-  (if (re-find #"http://localhost:9000/" file)
-    (-> file
-      (string/replace #"http://localhost:9000/" "")
-      (string/replace (Pattern/compile (str "^" (util/output-directory opts) "/")) ""))
-    (if-let [asset-root (:asset-root opts)]
-      (string/replace file asset-root "")
-      (throw
-        (ex-info (str "Could not relativize URL " file)
-          {:type :parse-stacktrace
-           :reason :relativize-url})))))
+(defn parse-file [{:keys [host port] :as repl-env} file {:keys [asset-path] :as opts}]
+  (let [base-url-pattern (Pattern/compile (str "http://" host ":" port "/"))]
+    (if (re-find base-url-pattern file)
+      (-> file
+        (string/replace base-url-pattern "")
+        (string/replace
+          (Pattern/compile
+            (str "^" (or asset-path (util/output-directory opts)) "/")) ""))
+      (if-let [asset-root (:asset-root opts)]
+        (string/replace file asset-root "")
+        (throw
+          (ex-info (str "Could not relativize URL " file)
+            {:type :parse-stacktrace
+             :reason :relativize-url}))))))

 ;; -----------------------------------------------------------------------------
 ;; Chrome Stacktrace

 (defn chrome-st-el->frame
-  [st-el opts]
+  [repl-env st-el opts]
   (let [xs (-> st-el
              (string/replace #"\s+at\s+" "")
              (string/split #"\s+"))
@@ -238,7 +241,7 @@
                          [(first xs) (last xs)])
         [file line column] (parse-file-line-column flc)]
     (if (and file function line column)
-      {:file (parse-file file opts)
+      {:file (parse-file repl-env file opts)
        :function (string/replace function #"Object\." "")
        :line line
        :column column}
@@ -249,7 +252,7 @@
          :column nil}))))

 (comment
-  (chrome-st-el->frame
+  (chrome-st-el->frame {:host "localhost" :port 9000}
     "\tat cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34)" {})
   )

@@ -259,12 +262,12 @@
     string/split-lines
     (drop-while #(.startsWith % "Error"))
     (take-while #(not (.startsWith % "    at eval")))
-    (map #(chrome-st-el->frame % opts))
+    (map #(chrome-st-el->frame repl-env % opts))
     (remove nil?)
     vec))

 (comment
-  (parse-stacktrace nil
+  (parse-stacktrace {:host "localhost" :port 9000}
     "Error: 1 is not ISeqable
     at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4258:8)
     at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4288:19)
@@ -279,7 +282,7 @@
     {:ua-product :chrome}
     nil)

-  (parse-stacktrace nil
+  (parse-stacktrace {:host "localhost" :port 9000}
     "Error: 1 is not ISeqable
     at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4259:8)
     at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4289:19)
@@ -299,13 +302,13 @@
 ;; Safari Stacktrace

 (defn safari-st-el->frame
-  [st-el opts]
+  [repl-env st-el opts]
   (let [[function flc] (if (re-find #"@" st-el)
                          (string/split st-el #"@")
                          [nil st-el])
         [file line column] (parse-file-line-column flc)]
     (if (and file function line column)
-      {:file (parse-file file opts)
+      {:file (parse-file repl-env file opts)
        :function function
        :line line
        :column column}
@@ -316,8 +319,11 @@
          :column nil}))))

 (comment
-  (safari-st-el->frame
+  (safari-st-el->frame {:host "localhost" :port 9000}
     "cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17" {})
+
+  (safari-st-el->frame {:host "localhost" :port 9000}
+    "cljs$core$seq@http://localhost:9000/js/cljs/core.js:4259:17" {:asset-path "js"})
   )

 (defmethod parse-stacktrace :safari
@@ -327,7 +333,7 @@
     (drop-while #(.startsWith % "Error"))
     (take-while #(not (.startsWith % "eval code")))
     (remove string/blank?)
-    (map #(safari-st-el->frame % opts))
+    (map #(safari-st-el->frame repl-env % opts))
     (remove nil?)
     vec))

@@ -382,13 +388,13 @@
       (string/replace #"\/" ""))))

 (defn firefox-st-el->frame
-  [st-el opts]
+  [repl-env st-el opts]
   (let [[function flc] (if (re-find #"@" st-el)
                          (string/split st-el #"@")
                          [nil st-el])
         [file line column] (parse-file-line-column flc)]
     (if (and file function line column)
-      {:file (parse-file file opts)
+      {:file (parse-file repl-env file opts)
        :function (firefox-clean-function function)
        :line line
        :column column}
@@ -399,19 +405,19 @@
          :column nil}))))

 (comment
-  (firefox-st-el->frame
+  (firefox-st-el->frame {:host "localhost" :port 9000}
     "cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8" {})

-  (firefox-st-el->frame
+  (firefox-st-el->frame {:host "localhost" :port 9000}
     "cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})

-  (firefox-st-el->frame
+  (firefox-st-el->frame {:host "localhost" :port 9000}
     "cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})

-  (firefox-st-el->frame
+  (firefox-st-el->frame {:host "localhost" :port 9000}
     "cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8" {})

-  (firefox-st-el->frame
+  (firefox-st-el->frame {:host "localhost" :port 9000}
     "cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8" {})
   )

@@ -422,7 +428,7 @@
     (drop-while #(.startsWith % "Error"))
     (take-while #(= (.indexOf % "> eval") -1))
     (remove string/blank?)
-    (map #(firefox-st-el->frame % opts))
+    (map #(firefox-st-el->frame repl-env % opts))
     (remove nil?)
     vec))

@@ -502,6 +508,18 @@
   repl/IJavaScriptEnv
   (-setup [this opts]
     (setup this opts))
+  (-evaluate [this _ _ js]
+    (binding [browser-state (:browser-state this)
+              ordering (:ordering this)
+              es (:es this)
+              server/state (:server-state this)]
+      (browser-eval js)))
+  (-load [this provides url]
+    (load-javascript this provides url))
+  (-tear-down [this]
+    (binding [server/state (:server-state this)]
+      (server/stop))
+    (.shutdown (:es this)))
   repl/IReplEnvOptions
   (-repl-options [this]
     {:repl-requires
@@ -517,24 +535,13 @@
            (pr-str
              {:ua-product (clojure.browser.repl/get-ua-product)
               :value (str ~e)
-              :stacktrace (.-stack ~e)})))))
-  (-evaluate [this _ _ js]
-    (binding [browser-state (:browser-state this)
-              ordering (:ordering this)
-              es (:es this)
-              server/state (:server-state this)]
-      (browser-eval js)))
-  (-load [this provides url]
-    (load-javascript this provides url))
-  (-tear-down [this]
-    (binding [server/state (:server-state this)]
-      (server/stop))
-    (.shutdown (:es this))))
+              :stacktrace (.-stack ~e)}))))))

 (defn repl-env*
   [{:keys [output-dir] :as opts}]
   (merge (BrowserEnv.)
-    {:port 9000
+    {:host "localhost"
+     :port 9000
      :working-dir (->> [".repl" (util/clojurescript-version)]
                        (remove empty?) (string/join "-"))
      :serve-static true


Add docs for describe and using

Add docs for describe and using

--- src/main/clojure/lazytest/describe.clj
+++ src/main/clojure/lazytest/describe.clj
@@ -92,7 +92,20 @@

 ;;; Public

-(defmacro describe [& decl]
+(defmacro describe
+  "Defines a group of tests.
+
+  decl is: sym? doc? attr-map? children*
+
+  sym (optional) is a symbol; it will be resolved in the current namespace and
+  prepended to the documentation string.
+
+  doc (optional) is a documentation string
+
+  attr-map (optional) is a metadata map
+
+  children are test cases (see 'it') or nested test groups"
+  [& decl]
   (let [[sym decl] (get-arg symbol? decl)
 	[doc decl] (get-arg string? decl)
 	[attr-map body] (get-arg map? decl)
@@ -100,6 +113,32 @@
 	docstring (strcat (when sym (resolve sym)) doc)
 	metadata (merged-metadata body &form docstring attr-map)]
     `(def-unless-nested (test-group ~children ~metadata))))
+
+(defmacro using
+  "Defines a group of tests that use fixtures.
+
+  decl is: doc? attr-map? [bindings*] children*
+
+  attr-map (optional) is a metadata map
+
+  bindings are symbol/fixture pairs, as in 'let'.  The symbols will be
+  locally available in all nested test cases, where they will be bound
+  to the values returned by the 'before' functions of the
+  corresponding fixtures.  All destructuring forms are supported.
+
+  children are test cases (see 'it') or nested test groups"
+  [& decl]
+  (let [[doc decl] (get-arg string? decl)
+	[attr-map decl] (get-arg map? decl)
+	[bindings body] (get-arg vector? decl)
+	children (vec body)
+	metadata (merged-metadata body &form doc attr-map)]
+    (assert (vector? bindings))
+    (assert (even? (count bindings)))
+    (let [binding-forms (firsts bindings)
+	  fixtures (seconds bindings)
+	  local-bindings (vec (interleave binding-forms fixtures))]
+      `(wrap-local-scope ~local-bindings (test-group ~children ~metadata)))))

 (defmacro given [& decl]
   (let [[doc decl] (get-arg string? decl)
@@ -129,19 +168,6 @@
 	  local-bindings (vec (interleave binding-forms fixtures))]
       `(wrap-local-scope ~local-bindings (test-group ~children ~metadata)))))

-(defmacro using [& decl]
-  (let [[doc decl] (get-arg string? decl)
-	[attr-map decl] (get-arg map? decl)
-	[bindings body] (get-arg vector? decl)
-	children (vec body)
-	metadata (merged-metadata body &form doc attr-map)]
-    (assert (vector? bindings))
-    (assert (even? (count bindings)))
-    (let [binding-forms (firsts bindings)
-	  fixtures (seconds bindings)
-	  local-bindings (vec (interleave binding-forms fixtures))]
-      `(wrap-local-scope ~local-bindings (test-group ~children ~metadata)))))
-
 (defmacro it [& decl]
   (let [[sym decl] (get-arg symbol? decl)
 	[doc decl] (get-arg string? decl)


update comment again

update comment again

--- src/main/java/org/dada/demo/whales.clj
+++ src/main/java/org/dada/demo/whales.clj
@@ -90,7 +90,7 @@
   (insert *metamodel* model)
   model)

-;; create 10,000 whales and insert them into model - one by one
+;; create 10,000 whales and insert them into model
 (insert-n
  model
  (let [time (System/currentTimeMillis)]


figwheel doesn't seem to reload cljc properly, so don't try

--- script/figwheel.clj
+++ script/figwheel.clj
@@ -4,6 +4,7 @@
 (ra/start-figwheel!

   {:figwheel-options {:css-dirs ["resources/public/css"]
+                      :reload-clj-files {:clj false :cljc false}
                       :server-port 3559}
    :build-ids ["dev"]
    :all-builds


avoids command pileup as seen on LeicaDMI; also avoids light leak in another (fast-arriving) channel

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -274,7 +274,8 @@
       (device-best-effort (core getCameraDevice) (core snapImage))
       (swap! state assoc :last-image-time (elapsed-time @state))
       (when close-after
-        (set-shutter-open false)))))
+        (set-shutter-open false)
+        (wait-for-device shutter)))))

 (defn load-property-sequences [property-sequences]
   (let [new-seq (not= property-sequences @active-property-sequences)]


Boot show --predantic formatting tweaks

Boot show --predantic formatting tweaks

--- boot/pod/src/boot/pedantic.clj
+++ boot/pod/src/boot/pedantic.clj
@@ -40,17 +40,23 @@
   (->> env pod/resolve-dependencies (map #(vec (take 2 (:dep %)))) (into {})))

 (defn prn-conflicts [env]
-  (let [version (resolved-versions env)
-        deps    (->> env :dependencies (map #(vec (take 2 %))) (into {}))]
-    (doseq [[k v] (dep-conflicts env)
-            m     (if (deps k) "\u2714" "!")]
-      (print (ansi/bold-white (format "[%s] %s\n" m k)))
-      (doseq [[k' v'] (reverse v)
-              :let [v? (= k' (version k))
-                    m  (if v? "\u2714" "\u2718")
-                    c1 #((cond (= k %) ansi/bold-green
-                               v?      ansi/green
-                               :else   ansi/yellow) %)
-                    c2 (if v? ansi/bold-green ansi/bold-yellow)]]
-        (print (->> (string/join "\n      " (map c1 (sort v')))
-                    (format "    %s %s\n      %s\n" (c2 m) (c2 k'))))))))
+  (let [check-mark "\u2714"
+        version-of (resolved-versions env)]
+    (doseq [[dep versions] (dep-conflicts env)]
+      (let [explicit? (contains? (reduce into #{} (vals versions)) dep)
+            dep-mark  (if explicit? check-mark "-")]
+        (print (ansi/bold-white (format "[%s] %s\n" dep-mark dep)))
+        (doseq [[version vias] (reverse versions)]
+          (let [chosen?  (= version (version-of dep))
+                norm     (if chosen? ansi/green ansi/yellow)
+                bold     (if chosen? ansi/bold-green ansi/bold-yellow)
+                ver-mark (if chosen? dep-mark " ")]
+            (print (bold (format "    [%s] %s\n" ver-mark version)))
+            (doseq [via vias]
+              (let [given?    (= dep via)
+                    excluded? (not chosen?)
+                    color     (if given? bold norm)
+                    via-mark  (cond given?    check-mark
+                                    excluded? " "
+                                    :else     "-")]
+                (print (color (format "        [%s] %s\n" via-mark via)))))))))))


Index by 0

Index by 0

--- src/app/core.cljs
+++ src/app/core.cljs
@@ -119,9 +119,9 @@
               [:input {:type "text", :class "guestname", :value name}]
               [:fieldset
                [:div
-                (let [radio-name (str "guest" (inc n) "rsvp")]
+                (let [radio-name (str "guest" n "rsvp")]
                   (map (fn [[label for-str val]]
-                         (let [input-id (str "guest" (inc n) for-str)]
+                         (let [input-id (str "guest" n for-str)]
                            [:div
                             [:input {:type "radio"
                                      :id input-id


Adds lifecycle handling [ci skip]

Adds lifecycle handling [ci skip]

--- src/onyx/static/helpful_job_errors.clj
+++ src/onyx/static/helpful_job_errors.clj
@@ -7,7 +7,7 @@
 (def structure-names
   {:workflow :workflow
    :catalog :catalog-entry
-   :lifecycles :lifecycles-entry})
+   :lifecycles :lifecycle-entry})

 (defn matches-faulty-key? [k v elements faulty-key]
   (some #{k v} #{faulty-key}))
@@ -309,11 +309,13 @@

 (defmethod predicate-error-msg 'keyword-namespaced?
   [entry error-data]
-  (let [chain (->> (:predicates error-data)
-                   (select-keys predicate-phrases)
-                   (vals)
-                   (chain-phrases))]
-    [(str "^-- Value " (pr-str (get entry (:error-key error-data))) " must be " chain)]))
+  (if (seq (:predicates error-data))
+    (let [chain (->> (:predicates error-data)
+                     (select-keys predicate-phrases)
+                     (vals)
+                     (chain-phrases))]
+      [(str "^-- Value " (pr-str (get entry (:error-key error-data))) " must be " chain)])
+    [(str "^-- Value " (pr-str (get entry (:error-key error-data))) " must be " (get predicate-phrases (:predicate error-data)))]))

 (defmethod predicate-error-msg 'edge-two-nodes?
   [entry {:keys [error-value]}]
@@ -416,6 +418,19 @@
     (show-map context faulty-key error-f)
     (show-docs entry faulty-key)
     (show-footer)))
+
+(defmethod print-helpful-job-error [:catalog :missing-required-key]
+  [job error-data catalog structure-type]
+  (let [context (get-in job (butlast (:path error-data)))
+        faulty-key (:missing-key error-data)
+        entry (get-in model [(structure-names structure-type) :model faulty-key])]
+    (let [error-f (constantly nil)]
+      (show-header structure-type faulty-key)
+      (show-map context faulty-key error-f)
+      (println (a/magenta (str "^-- Missing required key " (a/bold faulty-key))))
+      (println)
+      (show-docs entry faulty-key)
+      (show-footer))))

 (defmethod print-helpful-job-error [:catalog :conditional-failed]
   [job error-data catalog structure-type]
@@ -458,3 +473,50 @@
             (show-map context faulty-key error-f)
             (show-docs entry faulty-key)
             (show-footer)))))
+
+(defmethod print-helpful-job-error [:lifecycles :type-error]
+  [job error-data entry structure-type]
+  (let [faulty-key (:error-key error-data)
+        faulty-val (:error-value error-data)
+        expected-type (:expected-type error-data)
+        found-type (:found-type error-data)
+        context (get-in job (butlast (:path error-data)))
+        entry (get-in model [(structure-names structure-type) :model faulty-key])
+        error-f
+        (fn [k v]
+          (println "  " (a/bold-red (str (pr-str k) " " (pr-str v))))
+          (println (str "    " (a/magenta (str " ^-- " (pr-str v) " isn't of the expected type."))))
+          (println (str "    " (a/magenta (str "     Found " (.getName (.getClass v)) ", requires " (.getName expected-type))))))]
+    (show-header structure-type faulty-key)
+    (show-map context faulty-key error-f)
+    (show-docs entry faulty-key)
+    (show-footer)))
+
+(defmethod print-helpful-job-error [:lifecycles :missing-required-key]
+  [job error-data catalog structure-type]
+  (let [context (get-in job (butlast (:path error-data)))
+        faulty-key (:missing-key error-data)
+        entry (get-in model [(structure-names structure-type) :model faulty-key])]
+    (let [error-f (constantly nil)]
+      (show-header structure-type faulty-key)
+      (show-map context faulty-key error-f)
+      (println (a/magenta (str "^-- Missing required key " (a/bold faulty-key))))
+      (println)
+      (show-docs entry faulty-key)
+      (show-footer))))
+
+(defmethod print-helpful-job-error [:lifecycles :value-predicate-error]
+  [job error-data context structure-type]
+  (let [faulty-key (last (:path error-data))
+        faulty-val (:error-value error-data)
+        entry (get-in model [(structure-names structure-type) :model faulty-key])
+        error-f
+        (fn [k v]
+
+          (println "  " (a/bold-red (str (pr-str k) " " (pr-str v))))
+          (doseq [m (predicate-error-msg context error-data)]
+            (println (str "   " (a/magenta m)))))]
+    (show-header :lifecycles faulty-key)
+    (show-map (get-in job (butlast (:path error-data))) faulty-key error-f)
+    (show-docs entry faulty-key)
+    (show-footer)))


add some missing top-level app routes to reserved slugs

--- src/open_company/resources/company.clj
+++ src/open_company/resources/company.clj
@@ -59,7 +59,7 @@
                       "developers" "faq" "founder" "founders"
                       "investor" "investors" "jobs" "login" "logout"
                       "news" "newsletter" "press" "privacy" "register"
-                      "signup" "terms"})
+                      "signup" "terms" "profile" "create-company"})

 (defn taken-slugs
   "Return all slugs which are in use as a set."


Put result-ch and accpet-ch asynchronously.

--- src/cbfg/net.cljs
+++ src/cbfg/net.cljs
@@ -7,13 +7,14 @@
               [ts 0
                request-listen-ch request-listen-ch
                request-connect-ch request-connect-ch
-               listens {}  ; Keyed by [addr port], value is accept-ch.
-               streams {}] ; A conn is represented by dual streams, where streams
-                           ; is keyed by send-ch and a value of...
-                           ; {:send-addr :send-port :send-ch
-                           ;  :recv-addr :recv-port :recv-ch
-                           ;  :to-side :to-addr :to-port
-                           ;  :msgs :tot-msgs}.
+               listens {} ; Keyed by [addr port], value is accept-ch.
+               streams {} ; A conn is represented by dual streams, where streams
+                          ; is keyed by send-ch and a value of...
+                          ; {:send-addr :send-port :send-ch
+                          ;  :recv-addr :recv-port :recv-ch
+                          ;  :to-side :to-addr :to-port
+                          ;  :msgs :tot-msgs}.
+               results []]
               (let [deliveries (mapcat (fn [send-ch stream]
                                          (when-let [[deliver-at msg] (first (:msgs stream))]
                                            (when (>= ts deliver-at)
@@ -24,16 +25,18 @@
                                          [(:send-ch stream)]))
                                       streams)
                     [v ch] (aalts net (vec (concat [request-listen-ch request-connect-ch]
-                                                   deliveries sendables)))]
+                                                   deliveries sendables
+                                                   results)))]
                 (cond
                  (= ch request-listen-ch)
                  (when-let [[addr port accept-ch] v]
                    (if (get listens [addr port])
                      (recur (inc ts) request-listen-ch request-connect-ch
                             (assoc listens [addr port] accept-ch)
-                            streams)
+                            streams results)
                      (do (aclose net accept-ch)
-                         (recur (inc ts) request-listen-ch request-connect-ch listens streams))))
+                         (recur (inc ts) request-listen-ch request-connect-ch listens
+                                streams results))))
                  (= ch request-connect-ch)
                  (when-let [[to-addr to-port from-addr result-ch] v]
                    (if-let [accept-ch (get listens [to-addr to-port])]
@@ -43,29 +46,35 @@
                            server-recv-ch (achan net)]
                        ; TODO: Need to model connection delay and running out of ports.
                        ; TODO: Need to model stop accepting connections / stop listening.
-                       (aput net result-ch [client-send-ch client-recv-ch])
-                       (aput net accept-ch [server-send-ch server-recv-ch])
                        (recur (inc ts) request-listen-ch request-connect-ch listens
                               (-> streams
                                   (assoc client-send-ch {:send-ch client-send-ch :recv-ch server-recv-ch
                                                          :to-side :recv :to-addr to-addr :to-port to-port})
                                   (assoc server-send-ch {:send-ch server-send-ch :recv-ch client-recv-ch
-                                                         :to-side :send :to-addr to-addr :to-port to-port}))))
+                                                         :to-side :send :to-addr to-addr :to-port to-port}))
+                              (-> results
+                                  (conj [result-ch [client-send-ch client-recv-ch]])
+                                  (conj [accept-ch [server-send-ch server-recv-ch]]))))
                      (do (aclose net result-ch)
-                         (recur (inc ts) request-listen-ch request-connect-ch listens streams))))
+                         (recur (inc ts) request-listen-ch request-connect-ch listens
+                                streams results))))
                  (contains? sendables ch)
                  (let [send-ch ch]
                    (if-let [stream (get streams send-ch)]
                      (let [[msg result-ch] v]
-                       (when result-ch
-                         (aput-close net result-ch :ok))
                        (recur (inc ts) request-listen-ch request-connect-ch listens
-                              (update-in streams [send-ch :msgs] conj msg)))
+                              (update-in streams [send-ch :msgs] conj msg)
+                              (if result-ch
+                                (conj results [result-ch :ok])
+                                result-ch)))
+                     ; TODO: Need to remove first msg from msgs.
+                     ; TODO: Handle closing recv-ch.
                      (recur (inc ts) request-listen-ch request-connect-ch listens
-                            (dissoc streams send-ch)))) ; TODO: Handle closing recv-ch.
-                 :else ; Must be completed delivery (recv).
-                 (let [recv-ch ch
-                       stream (first (filter #(= (:recv-ch %) recv-ch) (vals streams)))]
+                            (dissoc streams send-ch)
+                            results)))
+                 :else ; Must be completed delivery (recv) or completed results aput.
+                 (let [stream (first (filter #(= (:recv-ch %) ch) (vals streams)))]
                    (recur (inc ts) request-listen-ch request-connect-ch listens
-                          (dissoc streams (:send-ch stream)))))))))
+                          (dissoc streams (:send-ch stream))
+                          (remove #(= (first %) ch) results))))))))


isPlayer field

isPlayer field

--- clojure/src/dnd/character.cljs
+++ clojure/src/dnd/character.cljs
@@ -3,6 +3,7 @@
   (:require [com.rpl.specter :as s :refer-macros [select transform setval]]))

 (defonce base-character {:char "@"
+                         :isPlayer false
                          :x 3
                          :y 2
                          :hp 20
@@ -10,7 +11,7 @@
                          :view-distance 10
                          :direction "n" })

-(defn is-character [inhabitant] (= "@" (:char inhabitant)))
+(defn is-character [inhabitant] (:isPlayer inhabitant))

 (defn character-direction [dx dy]
   (if (= dx 0)


Correctly read properties for default store type

--- src/ctia/init.clj
+++ src/ctia/init.clj
@@ -66,4 +66,4 @@
 (defn init! []
   (p/init!)
   (init-auth-service!)
-  (init-mem-store!))
+  (init-store-service!))


Change layout to allow mobile editing

Change layout to allow mobile editing

It means that all windows not shown at once, but cover whole page now

--- idecode/myappshare/mainapp.cljs
+++ idecode/myappshare/mainapp.cljs
@@ -22,6 +22,10 @@

+
+
+
+
 (def ns-counter (atom 0))

 (defn start [] (str "(ns webapp.framework.client.fns" @ns-counter "\n
@@ -30,6 +34,10 @@
 (ns-coils 'webapp.framework.client.fns " @ns-counter ")"))
 (defn end [] "(webapp.framework.client.system-globals.touch [:ui])\n
   (reset! webapp.framework.client.system-globals/start-component  main)")
+
+
+
+

@@ -46,25 +54,86 @@

+(defn evalapp [app-id]
+  (go
+;    (js/alert (str app-id))
+    (let [x (remote  !getfilecontents  {:id app-id })]
+      (swap! ns-counter inc)
+      (js/sendcode (str (start) (:value x) (end) ))
+      )))
+
+
+
+
+
+
+
+(defn-ui-component     view-app-component   [app]
+  {:on-mount
+   (do  (go
+          ;(remote !loadapp {:id (read-ui app [:app-id] )})
+          ;(js/alert "loaded")
+          ))}
+
+  (iframe {:id "appframe" :style {:display "inline-block"}
+           :src
+           (str (cond
+                  @c/debug-mode
+                  "http://127.0.0.1:3449"
+
+                  :else
+                  "http://appshare.co/appshare")
+                "/devclient.html") :width "600" :height "800"}))
+
+
+

 (defn-ui-component     editor-component   [app]
   {:on-mount
-   (do  (go (if  (read-ui app [:app-id])
+   (do  (go
+          (if  (read-ui app [:app-id])
               (let [x (remote  !getfilecontents  {:id (read-ui app [:app-id]) })]

                 (js/createEditor)
                 (js/populateEditor (get x :value))
-                (reeval (read-ui app [:app-id]))
+                ;(reeval (read-ui app [:app-id]))
                 ;(js/populateEditor (str "Loaded: " (read-ui app [:app-id])))
-                ;(js/alert (str "loaded" (read-ui app [:app-id])))
+
                 ))))}

-  (div nil
-       (textarea {:id "cm" :style {:display "inline-block" :width "1200" :height "800"}} "")))
+  (div {}
+       (realtime select id, application_name from coils_applications where id = ? {:params [(read-ui app [:app-id])]}
+                 (cond
+                   (and (= (read-ui app [:submode]) "editappname") (= (<-- :id ) (read-ui app [:app-id])))
+                   (input-field {:style {:marginBottom "20px" :color "black"} :placeholder  (str (<-- :application_name))}
+                                app
+                                (fn [new-name]
+                                  (let [id (read-ui app [:app-id])]
+                                    (go
+                                      (sql "update  coils_applications
+                                           set application_name = ?
+                                           where id = ?"
+                                           [new-name id ]  )
+                                      ;(js/alert (str new-name ":" id))
+                                      (write-ui app [:submode] nil)
+                                      ))))
+
+
+                   ; if we select a different app
+                   :else
+                   (do
+                     (div {:onClick     #(go  (write-ui app [:submode] "editappname")
+                                              (write-ui app [:app-id] (<-- :id))
+                                              )
+
+                           :style {:display "inline-block" :fontFamily "Ubuntu" :fontWeight "700" :fontSize "1.3em" ::marginTop "0.7em"}}
+                          (str (<-- :application_name)))))
+       )
+       (textarea {:id "cm" :style {:display "inline-block" :width "1200" :height "800"}} "TEXT EDITOR")))

@@ -85,7 +154,7 @@
                (div nil

-                    (button {:style {:marginRight "30px" :marginBottom "10px"}
+                    (comment button {:style {:marginRight "30px" :marginBottom "10px"}
                              :className "btn btn-small"
                              :onClick     #(go (sql "delete from coils_applications
                                               where id = ?"
@@ -114,8 +183,11 @@
                       ; if we select a different app
                       :else
                       (do
-                        (div {:onClick     #(go  (write-ui app [:submode] "editappname")
-                                                 (write-ui app [:app-id] (<-- :id)))
+                        (div {:onClick     #(go  (write-ui app [:mode] "view")
+                                                 ;(write-ui app [:submode] "editappname")
+                                                 (write-ui app [:app-id] (<-- :id))
+                                                 (evalapp (<-- :id))
+                                                 )

                               :style {:display "inline-block" :fontFamily "Ubuntu" :fontWeight "700" :fontSize "1.3em" ::marginTop "0.7em"}}
                              (str (<-- :application_name)))))
@@ -125,12 +197,10 @@

-                    (button {:style {:marginBottom "10px" :marginLeft "30px"} :className "btn btn-default"
-                             :onClick     #(go (write-ui app [:mode] "edit")
-                                             (write-ui app [:app-id] (<-- :id))
-                                             (remote !loadapp {:id (<-- :id)})
-                                             )
-                             } "Edit")))))
+                    ))))
+
+
+

@@ -151,15 +221,29 @@
        (div {:style     {:border "0px" :backgroundColor "black" :width "100%" :height "3em" :verticalAlign "top"}}
             (img {:style {:display "inline-block" :marginTop "-0.0em"} :src "appshare_logo_dark_background.png"})

-            (button {:className    "btn btn-default"
+            (button {:className    "btn-lg btn-default"
                      :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "-0.3em"}
-                     :onClick     #(write-ui app [:mode] "browse")} "Browse")
-
-            (button {:className    "btn btn-default"
-                     :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "-0.3em"}
+                     :onClick     #(write-ui app [:mode] "browse")} "Home")
+
+            (button {:className    "btn-lg btn-default"
+                     :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "-0.3em"
+                                   :opacity (if (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse")) "1.0" "0.4")
+                                   }
+                     :disabled  (if (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse")) "" "true")
                      :onClick     #(go
-                                      (remote !newapp {}))   } "New")
-
+                                      (remote !newapp {})) } "New")
+
+            (button {:style {:marginBottom "10px" :marginLeft "30px"
+
+                             :opacity  (if (= (read-ui app [:mode]) "view")  "1.0" "0.4")
+
+                             } :className "btn-lg btn-default"
+                             :onClick     #(go (write-ui app [:mode] "edit")
+                                             ;(remote !loadapp {:id (read-ui app [:app-id])})
+                                             )
+                     :disabled  (if (= (read-ui app [:mode]) "view") "" "true")
+
+                             } "Edit")

             (cond
@@ -171,10 +255,21 @@
                    :href         (str "http://" @appshare-dev-server ":3450")}
                   "Run in own window")

-               (button {:className    "btn btn-default"
-                        :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "-0.3em"  }
-                        :onClick     #(reeval  (read-ui app [:app-id]))}
-                       "Save")))
+               ))
+
+
+
+            (button {:className    "btn-lg btn-default"
+                        :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "-0.3em"
+                                      :opacity  (if (= (read-ui app [:mode]) "edit")  "1.0" "0.4")
+
+                                      }
+                        :onClick     #(do
+                                        (write-ui app [:mode] "view")
+                                        (reeval  (read-ui app [:app-id])))
+                     :disabled  (if (= (read-ui app [:mode]) "edit") "" "true")
+                     }
+                       "Save")

             (a {:target       "appshare.co"
                 :style       {:textDecoration "underline" :float "right"  :display "inline-block" :marginRight "30px" :fontFamily "Ubuntu" :fontSize "2em" :marginTop "0.3em"}
@@ -182,30 +277,28 @@
                "AppShare on Github"))

-
-
-       (div {}
-            (div {:style {:display "inline-block" :width "1200" :height "800" :verticalAlign "top"}}
-                 (cond
-                   (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse"))
-                   (component browser-component app [])
-
-                   (= (read-ui app [:mode]) "edit")
-                   (component editor-component app [])
-
-                   :else
-                   (div {} "Nothing selected")))
-
-
-
-       (iframe {:id "appframe" :style {:display "inline-block"} :src
-                (str (cond
-                      @c/debug-mode
-                      "http://127.0.0.1:3449"
-
-                      :else
-                      "http://appshare.co/appshare")
-                     "/devclient.html") :width "600" :height "800"}))
+;       (div {} (str "mode: " (read-ui app [:mode])))
+;       (div {} (str "sub-mode: " (read-ui app [:sub-mode])))
+;       (div {} (str "app-id: " (read-ui app [:app-id])))
+
+
+       (div {:style {:display "inline-block" :width "1200" :height "800" :verticalAlign "top"}}
+
+            (cond
+
+              (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse"))
+              (div {:style {}} (component browser-component app []))
+
+
+              (= (read-ui app [:mode]) "edit")
+              (div {:style {} } (component editor-component app []))
+
+            )
+
+
+            (div {:style {:display (if (= (read-ui app [:mode]) "view") "" "none")}} (component  view-app-component  app [])))
+
+
        ))


added tranform from bigdecimal on server to float on client

--- src/untangled/client/impl/network.cljs
+++ src/untangled/client/impl/network.cljs
@@ -20,7 +20,7 @@
   (response-error [this] "Called by XhrIo on ERROR"))

 (defn parse-response [xhr-io]
-  (ct/read (t/reader) (.getResponseText xhr-io)))
+  (ct/read (t/reader {:handlers {"f" (fn [v] (js/parseFloat v))}}) (.getResponseText xhr-io)))

 (defrecord Network [xhr-io url error-callback valid-data-callback]
   IXhrIOCallbacks


Added code gen for character entities

Added code gen for character entities


Improve body parsing docstring

Improve body parsing docstring

--- test/icecap/e2e/common.clj
+++ test/icecap/e2e/common.clj
@@ -43,7 +43,7 @@
   (http/delete cap-url {:throw-exceptions false}))

 (defn get-body
-  "Given a request, extracts its body."
+  "Given a request, extracts and parses its body as EDN."
   [req]
   (-> (:body req)
       (bs/to-string)


Test for function rest-api/get-output-format

--- test/emender_jenkins/rest_api_test.clj
+++ test/emender_jenkins/rest_api_test.clj
@@ -410,6 +410,17 @@
             "application/json" nil
             "application/json" :other)))

+(deftest test-get-output-format
+    "Check the function emender-jenkins.rest-api/get-output-format."
+    (testing "the function emender-jenkins.rest-api/get-output-format."
+        (are [x y] (= x (get-output-format {:params {"format" y}}))
+            :json "json"
+            :xml  "xml"
+            :csv  "csv"
+            :edn  "edn"
+            :txt  "text"
+            :txt  "txt")))
+
 (deftest test-get-output-format-default
     "Check the function emender-jenkins.rest-api/get-output-format."
     (testing "the function emender-jenkins.rest-api/get-output-format."


Correct compression titles for derived slices

--- src/qu/loader.clj
+++ src/qu/loader.clj
@@ -299,10 +299,11 @@
         fields (data/slice-columns slicedef)
         zip-fn (field-zip-fn slicedef)
         rename-map (reduce (fn [acc field]
-                             (merge acc {(zip-fn field) field})) {} fields)
+                             (merge acc {field (zip-fn field)})) {} fields)
         agg-results (mongo/command (sorted-map :aggregate from-collection :pipeline agg-query :allowDiskUse true))]
     (log/info "Aggregation for " slice agg-query)
     (log/info "Results of aggregation for" slice agg-results)
+    ;; Convert field names to compressed fields
     (coll/update slice {} {"$rename" rename-map} :multi true)))

 (defmethod load-slice :default


more atoms, more pieces

more atoms, more pieces

--- src/bossig/kaos.clj
+++ src/bossig/kaos.clj
@@ -21,7 +21,7 @@
             ;(print " ")
             ;(print (:note e) )
             ;(print " ")
-            ;(println (:velocity e))
+

             (let [note (:note e)
                   vel  (:velocity e)
@@ -29,17 +29,31 @@
               (if (and (= channel 15) (and (= note 60) (= vel 64)))
                 (swap! bbeat inc)
                 ;(concat (print "note =") (println  note ))
-
                 (if (= channel 0)
                   (swap! bd assoc :note note :velocity vel)
                   ;(println (concat (print "stuff = ") (print note)))
+                  (if (= channel 1)
+                    (swap! sd assoc :note note :velocity vel)
+                    (if (= channel 2)

-                  (if (= channel 1)
-                    (swap! sd assoc :note note)
-                    )))
+                      ))))

               ))
           ::keyboard-handler)
+
+(on-event [:midi :control-change]
+          (fn [e]
+            ;(println e)
+            (let [data1 (:data1 e)
+                  data2 (:data2 e)
+                  channel (:channel e)]
+              (if (and  (= channel 2) (= data1 1))
+                (swap! ch assoc :pan data2)
+                )
+              )
+            )
+          ::control-handler
+          )

@@ -48,7 +62,18 @@
   ;(newt/update-particles width height)
   {
                                         ;:fm @(:left fmtonestaps)
-   ;:beat @bbeat
+   :beat @bbeat
+   :bd @bd
+   :sd @sd
+   :ch @ch
+   :oh @oh
+   :pc1 @pc1
+   :pc2 @pc2
+   :ld1 @ld1
+   :ld2 @ld2
+   :chords @chords
+   :keys @keys
+
    ;:drumbus @(audio-bus-monitor 0)
    ;:contrabus @(audio-bus-monitor 2)
    ;:fmtonesbus @(audio-bus-monitor 4)
@@ -68,8 +93,9 @@
                                         ;(q/text  0 0 10 10 )

   (q/background 25 25 255)
-  (q/with-translation [ (* (get  @bd :velocity ) 10) 1 1]
-    (q/rect 15 (* ( mod16) 25) 300 300)
+  (q/fill 0 (get @sd :velocity ) 2)
+  (q/with-translation [(* ( get @ch :pan) 10  )  (* (get  @bd :velocity ) 10) 1 ]
+    (q/rect 15 (* ( mod16) 0) 300 300)
     (println (mod16))
     )


Trim long lines.

Trim long lines.

--- src/cbfg/fence.cljs
+++ src/cbfg/fence.cljs
@@ -49,18 +49,18 @@
        (let [[v ch] (aalts fenced-pump chs)]
          (cond
           (= ch in-ch) (if (nil? v)
-                         (recur name inflight-chs out-ch nil)      ; using out-ch as a sentinel.
+                         (recur name inflight-chs out-ch nil)      ; use out-ch as sentinel.
                          (let [new-inflight ((:rq v) fenced-pump)]
                            (recur name (conj inflight-chs new-inflight)
                                   (when (:fence v) new-inflight)
                                   nil)))
-          (= v nil) (let [new-inflight-chs (disj inflight-chs ch)] ; an inflight request is done.
-                      (if (empty? new-inflight-chs)                ; if inflight requests are all done,
-                        (do (when fenced-ch-res                    ; finally send the held fenced-ch-res.
+          (= v nil) (let [new-inflight-chs (disj inflight-chs ch)] ; inflight request done.
+                      (if (empty? new-inflight-chs)           ; all inflight requests done,
+                        (do (when fenced-ch-res               ; so send held fenced-ch-res.
                               (aput fenced-pump out-ch fenced-ch-res))
                             (recur name new-inflight-chs nil nil))
                         (recur name new-inflight-chs fenced-ch fenced-ch-res)))
-          (= ch fenced-ch) (do (when fenced-ch-res ; send any previous fenced-res so we can hold onto v.
+          (= ch fenced-ch) (do (when fenced-ch-res ; send held fenced-res to hold onto v.
                                  (aput fenced-pump out-ch fenced-ch-res))
                                (recur name inflight-chs fenced-ch v))
           :else (do (aput fenced-pump out-ch v)


Logging macros p and pp shouldn't run expression twice (in case it side effects).

--- src/clj/c2/util.clj
+++ src/clj/c2/util.clj
@@ -4,12 +4,14 @@
   `(goog.typeOf ~x))

 (defmacro p [x]
-  `(do (.log js/console ~x)
-       ~x))
+  `(let [res# ~x]
+     (.log js/console res#)
+     res#))

 (defmacro pp [x]
-  `(do (.log js/console (pr-str ~x))
-       ~x))
+  `(let [res# ~x]
+     (.log js/console (prn-str res#))
+     res#))

 (defmacro timeout [delay & body]
   `(js/setTimeout (fn [] ~@body) ~delay))


small fixes

small fixes

--- src/cortex/util.clj
+++ src/cortex/util.clj
@@ -38,25 +38,25 @@

 (defn tanh'
   " tanh'(x) = 1 - tanh(x)^2 "
-  [a]
-  (math/emap (- 1 (* a a))))
+  [th]
+  (mat/emap (- 1 (* th th))))

 (defn sigmoid
   "y =  1 / (1 + e^(-z))
   Produces an output between 0 and 1."
   [z]
-  (mat/div! (mat/add! (util/exp! (mat/negate z)) 1.0)))
+  (mat/div! (mat/add! (exp! (mat/negate z)) 1.0)))

 (defn sigmoid!
   "y =  1 / (1 + e^(-z))
   It is a smooth threshold function with output between 0 and 1."
   [z]
-  (mat/div! (mat/add! (util/exp! (mat/negate! z)) 1.0)))
+  (mat/div! (mat/add! (exp! (mat/negate! z)) 1.0)))

 (defn sigmoid'
   "sigma'(x) = sigma(x) * (1-sigma(x)) "
-  [z]
-  (let [sz (sigmoid z)]
+  [s]
+  (let [sz (sigmoid s)]
     (mat/emul sz (mat/sub 1.0 sz))))

 (defn rand-vector


[#19] Fixed bug.

[#19] Fixed bug.

--- src/gbu/webhook.clj
+++ src/gbu/webhook.clj
@@ -90,8 +90,8 @@
             (filter utils/clojure-file?))
       (let [dirname   (clone-repo url sha)
             results   (run-eastwood dirname)]
+        (println "Eastwood made" (count results) "comments.")
         (when results
-          (println "Eastwood made" (count results) "comment.")
           (let [files    (file-seq (io/file dirname))
                 comments (pulls/comments user reponame pr-id {:auth github-basic-auth})
                 cnt      (->> results
@@ -101,9 +101,9 @@
                            (map (partial create-comment user reponame pr-id sha comments))
                            (filter identity)
                            count)]
-            (println "Deleting temp directory" dirname)
-            (utils/delete-recursively dirname)
-            (println "Created" cnt "comments.")))))))
+            (println "Created" cnt "comments.")))
+        (println "Deleting temp directory" dirname)
+        (utils/delete-recursively dirname)))))

 (defmulti handle-event ^:private
   (fn [event-type _] (utils/keywordize event-type)))


more dead code removal

more dead code removal

--- src/babel/index.cljc
+++ src/babel/index.cljc
@@ -15,11 +15,7 @@
   #?(:cljs
      (throw (js/Error. error-string))))

-(def head-index {})
-(def comp-index {})
 (declare show-spec)
-
-(declare spec-to-phrases)

 ;; TODO: remove: not used anymore.
 ;; TODO: diagnostic function that is too specific currently (e.g. refers to ':english').
@@ -66,45 +62,6 @@
                                      {:head lex}))))
                lexicon)}}
      (build-lex-sch-index (rest phrases) lexicon all-phrases))))
-
-(defn spec-to-phrases [specs all-phrases]
-  (if (not (empty? specs))
-    (let [spec (first specs)]
-      (conj
-       {spec
-        (filter #(not (fail? %))
-                (map (fn [each-phrase]
-                       (unify each-phrase spec))
-                     ;; TODO: possibly: remove-paths such as (subcat) from head: would make it easier to call with lexemes:
-                     ;; e.g. "generate a sentence whose head is the word 'mangiare'" (i.e. user passes the lexical entry as
-                     ;; head param of (lightning-bolt)".
-                     all-phrases))}
-       (spec-to-phrases (rest specs) all-phrases)))
-    {}))
-
-(defn get-parent-phrases-for-spec [index spec]
-  (log/trace (str "Looking up spec: " (show-spec spec)))
-  (let [result (get (get index :phrases-for-spec) (show-spec spec))
-        result (if (nil? result) (list) result)]
-    (if (empty? result)
-      (log/trace (str "parent-phrases for spec: " (show-spec spec) " is empty.")))
-    result))
-
-(defn get-head-phrases-of [parent index]
-  (if (= true (get-in parent [:head :phrasal] :true))
-    (let [result (:head-phrases (get index (get-in parent [:rule])))
-          result (if (nil? result) (list) result)
-          label (label-of parent)]
-      (if (empty? result)
-        (log/warn (str "headed-phrases of parent: " label " is empty: " (get-in parent [:head]))))
-      result)))
-
-(defn get-comp-phrases-of [parent index]
-  (let [result (:comp-phrases (get index (get-in parent [:rule])))
-        result (if (nil? result) (list) result)]
-    (if (empty? result)
-      (log/trace (str "comp-phrases of parent: " (label-of parent) " is empty.")))
-    result))

 (defn show-spec [spec]
   (cond (seq? spec)


Ensure dev setting is a boolean

Ensure dev setting is a boolean

--- src/cfpb/qu/main.clj
+++ src/cfpb/qu/main.clj
@@ -4,7 +4,7 @@
   (:require
    [cfpb.qu
     [app :refer [new-qu-system]]
-    [util :refer [->int]]
+    [util :refer [->int ->bool]]
     [env :refer [env]]
     [logging :as logging]
     [project :refer [project]]
@@ -75,7 +75,7 @@

 (defn default-options
   []
-  {:dev (:dev env)
+  {:dev (->bool (:dev env))
    :http (default-http-options)
    :log (default-log-options)
    :mongo (default-mongo-options)})


Clean up simplicity calculation.

Clean up simplicity calculation.

--- src/clj/c2/ticks.clj
+++ src/clj/c2/ticks.clj
@@ -15,18 +15,19 @@
   (first (for [[idx y] (map-indexed vector coll)
                :when (= y x)] idx)))

+(defn label-range-contains-zero? [l-min l-max l-step]
+  (and (> l-max 0) (< l-min 0) (zero? (mod l-min l-step))))

 (defn simplicity
   "Objective function modeling niceness of step sizes and whether a range includes zero."
-  [q Q j l-min l-max l-step]
-  (let [v ;;Does the range contain zero?
-        (and (> l-max 0)
-             (< l-min 0)
-             (zero? (mod l-min l-step)))]
+  [q Q j label-range-contains-zero]
+  (let [v (if label-range-contains-zero 1 0)]
     (if (<= (count Q) 1)
       (+ (- 1 j) v)
       (+ (- 1 (/ (index-of q Q) (dec (count Q))) j)
          v))))
+
+(defn max-simplicity [q Q j] (simplicity q Q j true))

 (defn coverage
   "Objective function based on distances between extreme data and extreme labels"


[Fix] cut down exp in _cross-validate

[Fix] cut down exp in _cross-validate

to train-to-eval

--- src/clj_elm/core.clj
+++ src/clj_elm/core.clj
@@ -179,10 +179,15 @@
    (p :select-count
       (count (filter cond coll)))))

-(defn train-to-eval [L train-data test-data exp]
-  (-> (train-model train-data L)
-      (#(pmap (fn [feature] (predict % feature)) (:features test-data)))
-      (#(evaluation (:classes test-data) % exp))))
+(defn train-to-eval [L train-data test-data]
+  (let [exp {:length-train-negative (select-count #(= % -1) (:classes train-data))
+             :length-test-negative (select-count #(= % -1) (:classes test-data))
+             :length-train-positive (select-count #(= % 1) (:classes train-data))
+             :length-test-positive (select-count #(= % 1) (:classes test-data))
+             :Accuracy 0.0 :Recall 0.0 :Precision 0.0 :TP 0 :FP 0 :TN 0 :FN 0 :L L}]
+    (-> (train-model train-data L)
+        (#(pmap (fn [feature] (predict % feature)) (:features test-data)))
+        (#(evaluation (:classes test-data) % exp)))))

 (defn _cross-validate
   ([dataset a b L]
@@ -190,14 +195,8 @@
    (let [test (DataSet. (data/extract-list (:classes dataset) a b)
                         (data/extract-list (:features dataset) a b))
          train (DataSet. (data/remove-list (:classes dataset) a b)
-                         (data/remove-list (:features dataset) a b))
-         exp {:num (str "Data " a " to " b)
-              :length-train-negative (select-count #(= % -1) (:classes train))
-              :length-test-negative (select-count #(= % -1) (:classes test))
-              :length-train-positive (select-count #(= % 1) (:classes train))
-              :length-test-positive (select-count #(= % 1) (:classes test))
-              :Accuracy 0.0 :Recall 0.0 :Precision 0.0 :TP 0 :FP 0 :TN 0 :FN 0 :L L}]
-     (train-to-eval L train test exp))))
+                         (data/remove-list (:features dataset) a b))]
+     (train-to-eval L train test))))

 (defn _print-exp-data [exp]
   {:pre [(map? exp)]


Add :non-recombinative option for :autoconstructive-genome-instructions

--- src/clojush/args.clj
+++ src/clojush/args.clj
@@ -611,7 +611,62 @@
                                       genome_alternation
                                       genome_uniform_crossover
                                       genome_gene_genome_instruction
-                                      genome_if_gene_genome_instruction)))]
+                                      genome_if_gene_genome_instruction))
+                    :non-recombinative (into (registered-for-stacks
+                                               (if (:autoconstructive-environments @push-argmap)
+                                                 [:integer :boolean :exec :float :tag :environment]
+                                                 [:integer :boolean :exec :float :tag]))
+                                             '(genome_pop
+                                                genome_dup
+                                                genome_swap
+                                                genome_rot
+                                                genome_flush
+                                                genome_eq
+                                                genome_stackdepth
+                                                genome_yank
+                                                genome_yankdup
+                                                genome_shove
+                                                genome_empty
+                                                genome_gene_dup
+                                                genome_gene_randomize
+                                                genome_gene_replace
+                                                genome_gene_delete
+                                                genome_rotate
+                                                ;genome_gene_copy
+                                                ;genome_gene_copy_range
+                                                genome_toggle_silent
+                                                genome_silence
+                                                genome_unsilence
+                                                genome_instruction_eq
+                                                genome_gene_close
+                                                genome_gene_silent
+                                                genome_close_inc
+                                                genome_close_dec
+                                                genome_new
+                                                genome_parent1
+                                                genome_parent2
+                                                autoconstructive_integer_rand
+                                                autoconstructive_boolean_rand
+                                                genome_autoconstructing
+                                                genome_if_autoconstructing
+                                                genome_gene_genome_instruction
+                                                genome_if_gene_genome_instruction
+                                                genome_genesis
+                                                genome_uniform_instruction_mutation
+                                                genome_uniform_integer_mutation
+                                                genome_uniform_float_mutation
+                                                genome_uniform_tag_mutation
+                                                genome_uniform_string_mutation
+                                                genome_uniform_boolean_mutation
+                                                genome_uniform_close_mutation
+                                                genome_uniform_silence_mutation
+                                                genome_uniform_deletion
+                                                genome_uniform_addition
+                                                genome_uniform_addition_and_deletion
+                                                ;genome_uniform_combination_and_deletion
+                                                ;genome_alternation
+                                                ;genome_uniform_crossover
+                                                )))]
       (when (not (some #{instr} (:atom-generators @push-argmap)))
         (swap! push-argmap assoc :atom-generators (conj (:atom-generators @push-argmap) instr))))
     (swap! push-argmap assoc


Fixed zipper use in util

Fixed zipper use in util

--- src/clojush/util.clj
+++ src/clojush/util.clj
@@ -7,6 +7,15 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; utilities
+
+(defn seq-zip
+  "Returns a zipper for nested sequences, given a root sequence"
+  {:added "1.0"}
+  [root]
+  (zip/zipper seq?
+          seq
+          (fn [node children] (with-meta children (meta node)))
+          root))

 (defn ensure-list [thing] ;; really make-list-if-not-seq, but close enough for here
   (if (seq? thing)
@@ -54,7 +63,7 @@
   "Returns a subtree of tree indexed by point-index in a depth first traversal."
   [tree point-index]
   (let [index (mod (math/abs point-index) (count-points tree))
-        zipper (zip/seq-zip tree)]
+        zipper (seq-zip tree)]
     (loop [z zipper i index]
       (if (zero? i)
         (zip/node z)
@@ -65,7 +74,7 @@
    point-index (in a depth-first traversal) replaced by new-subtree."
   [tree point-index new-subtree]
   (let [index (mod (math/abs point-index) (count-points tree))
-        zipper (zip/seq-zip tree)]
+        zipper (seq-zip tree)]
     (loop [z zipper i index]
       (if (zero? i)
         (zip/root (zip/replace z new-subtree))
@@ -78,7 +87,7 @@
    from the behavior in other implementations of Push.)"
   [tree point-index]
   (let [index (mod (math/abs point-index) (count-points tree))
-        zipper (zip/seq-zip tree)]
+        zipper (seq-zip tree)]
     (if (zero? index)
       tree ;; can't remove entire tree
       (loop [z zipper i index]
@@ -98,7 +107,7 @@
    since you can't remove the outmost parens."
   [tree point-index]
   (let [index (mod (math/abs point-index) (count-points tree))
-        zipper (zip/seq-zip tree)]
+        zipper (seq-zip tree)]
     (if (zero? index)
       tree ;; can't remove entire tree's parens
       (let [z-found (loop [z zipper i index]
@@ -198,7 +207,7 @@
         loc (inc (lrand-int (dec (count-points tree))))]
     (zip/root
       ((lrand-nth [zip/insert-left zip/insert-right])
-        (loop [z (zip/seq-zip tree) i 0]
+        (loop [z (seq-zip tree) i 0]
           (if (= i loc)
             z
             (recur (zip/next z) (inc i))))


Close the sse channel when we are done with it

If not, it leaks the connection, and triggers IMMUTANT-599.

--- src/demo/web/sse.clj
+++ src/demo/web/sse.clj
@@ -10,6 +10,9 @@
                 (doseq [x (range 5 0 -1)]
                   (sse/send! ch x)
                   (Thread/sleep 500))
-                ;; Signal the client to call EventSource.close()
-                (sse/send! ch {:event "close", :data "bye!"}))}))
+                ;; Signal the client to call EventSource.close(), and
+                ;; close our end after the send
+                (sse/send! ch
+                  {:event "close", :data "bye!"}
+                  :close? true))}))


note that a different structure would better

--- src/gangway/util.clj
+++ src/gangway/util.clj
@@ -1,6 +1,10 @@
 (ns gangway.util
   (:require [gangway.worker :as gw-worker]))

+;; TODO: Figure out how to support incoming and outgoing queues with
+;; the same key in a reasonable way.
+;; Before this question can be answered, must figure out how outgoing
+;; queues would be presented via REST.
 (def queues
   {:showevidence {:name "queue.showevidence-in"
                   :worker-fn gw-worker/do-work}})


Fix line numbering error

Fix line numbering error

--- src/icfp2014/ghc.clj
+++ src/icfp2014/ghc.clj
@@ -187,7 +187,7 @@
                         (format "MOV $TMP,%s" dest)
                         (format "MOV %s,%s" dest x)
                         (format "SUB %s,$TMP" dest)])
-
+
                      "JMP"
                      (let [[dest] args]
                        [(format "JEQ %s,0,0" dest)]))
@@ -195,13 +195,18 @@
         (s/join "\n" instrs))
       line)))

+(defn resplit
+  [lines]
+  (s/split (s/join "\n" lines) #"\n"))
+
 (defn tag-file*
   [fin-path]
   (->> fin-path
        io/reader
        line-seq
+       (map macrolize)
+       resplit
        tag-lines
-       (map macrolize)
        var-lines
        check-length
        (s/join "\n")))


Change sets in world desc to maps to obtain unique IDs per entity

--- src/player/core.cljs
+++ src/player/core.cljs
@@ -43,34 +43,28 @@
    :camera-height 240
    :scroll-x      0
    :scroll-y      0
-   :walls         #{{:type :white :x 0 :y 0 :w 256 :h 8}
-                    {:type :white :x 0 :y 8 :w 8 :h 16}
-                    {:type :white :x 96 :y 8 :w 8 :h 16}
-                    {:type :white :x 160 :y 8 :w 8 :h 16}}
-   :objects       #{{:id    :ga
-                     :type  :goomba
-                     :state :right
-                     :x     8 :y 8}
-                    {:id    :gb
-                     :type  :goomba
-                     :state :right
-                     :x     32 :y 8}
-                    {:id    :gc
-                     :type  :goomba
-                     :state :right
-                     :x     12 :y 35}
-                    {:id    :gd
-                     :type  :goomba
-                     :state :right
-                     :x     64 :y 8}
-                    {:id    :ge
-                     :type  :goomba
-                     :state :right
-                     :x     96 :y 32}
-                    {:id    :m
-                     :type  :mario
-                     :state :idle-right
-                     :x     200 :y 8}}})
+   :walls         {0 {:type :white :x 0 :y 0 :w 256 :h 8}
+                   1 {:type :white :x 0 :y 8 :w 8 :h 16}
+                   2 {:type :white :x 96 :y 8 :w 8 :h 16}
+                   3 {:type :white :x 160 :y 8 :w 8 :h 16}}
+   :objects       {:ga {:type  :goomba
+                        :state :right
+                        :x     8 :y 8}
+                   :gb {:type  :goomba
+                        :state :right
+                        :x     32 :y 8}
+                   :gc {:type  :goomba
+                        :state :right
+                        :x     12 :y 35}
+                   :gd {:type  :goomba
+                        :state :right
+                        :x     64 :y 8}
+                   :ge {:type  :goomba
+                        :state :right
+                        :x     96 :y 32}
+                   :m  {:type  :mario
+                        :state :idle-right
+                        :x     200 :y 8}}})

 (set! heval/frame-length (/ 1 30))
 (set! heval/time-units-per-frame 10000)
@@ -117,7 +111,7 @@
         defs (:ha-defs w)
         [obj-dict tr-caches] (heval/init-has
                                defs
-                               (map (fn [{id :id state :state :as ha-desc}]
+                               (map (fn [[id {state :state :as ha-desc}]]
                                       (let [v0 (dissoc ha-desc :id :type :state)]
                                         (ha/init-ha (get defs id)
                                                     id
@@ -147,12 +141,12 @@
                                           #_[:m :moving-right 10.0]])))))

 (defn make-world [world-desc]
-  (let [ids (set (map :id (:objects world-desc)))
-        walls (set (map (fn [{x :x y :y w :w h :h}]
+  (let [ids (set (keys (:objects world-desc)))
+        walls (set (map (fn [[_k {x :x y :y w :w h :h}]]
                           [x y w h])
                         (:walls world-desc)))
         defs (ha/define-has
-               (map (fn [{type :type id :id}]
+               (map (fn [[id {type :type}]]
                       (case type
                         :goomba (util/goomba id 16 ids walls)
                         :mario (util/mario id ids walls)
@@ -186,11 +180,6 @@
           :configs (conj (subvec cfgs 0 (dec (count cfgs)))
                          (heval/recache-trs (:ha-defs wld)
                                             last-config)))))))
-
-(defonce key-states (atom {:on       #{}
-                           :pressed  #{}
-                           :released #{}}))
-
 (defn pair [a b]
   (map (fn [ai bi] [ai bi]) a b))


corrected tick placement

corrected tick placement

--- src/prais2/data.cljs
+++ src/prais2/data.cljs
@@ -209,9 +209,9 @@

 (r/defc tick < r/static [baseline value]
   (let [percent (* 100 (/ (- value baseline) (- 100 baseline)))]
-    [:.tick
-     {:style {:left (pc (if (< percent 0) 0 percent))}}
-     [:span.tick-label (pc value)]]))
+    (when (>= percent 0)
+      [:.tick {:style {:left (pc percent)}}
+       [:span.tick-label (pc value)]])))

 (r/defc ticks < r/static [slider-axis-value tick-count]
   (let [baseline (* min-outer-low slider-axis-value)


Add some API redirects

Add some API redirects

Change-Id: Icad961a02cb835db117cfa6e440887f510d82390

--- src/qcast/server.clj
+++ src/qcast/server.clj
@@ -37,6 +37,8 @@
 (defroutes api-routes
   "Routes for client API"
   (let [api-count (config/get :api :items-count)]
+    (GET "/api"    [] (response/redirect "api/v1"))
+    (GET "/api/v1" [] (response/redirect "api/v1/presentations"))
     (GET "/api/v1/presentations" {{since-id "since"} :query-params}
       (->> (if since-id
              (cache/latest api-count since-id)


object -> filename

object -> filename

--- src/revdiff/core.clj
+++ src/revdiff/core.clj
@@ -39,7 +39,7 @@
           r2 (first (rest revpairs))
           mf (matching-files r1 r2 item filt)]
       (println (str "Checking: r" r1 " vs r" r2))
-      (doseq [object mf] (svndiff r1 r2 object item))
+      (doseq [filename mf] (svndiff r1 r2 filename item))
       (diffrevpairs item filt (rest (rest revpairs))))))

 ;; Try to explain why this has failed.
@@ -51,7 +51,6 @@
   (println))

 ;; Return a string containing the xml-formatted svn log for the requested item.
-;; Stop on copy to avoid following the history of a differently-named object.

 (defn log [item]
   (:out (sh "svn" "log" shhh "--stop-on-copy" "--xml" item)))
@@ -95,20 +94,14 @@
     (concat (list (first (rest revlist)) (first revlist))
             (revpairs (rest revlist) item))))

-;; Run "svn diff" on the file/pathname in object. The format of the file/path
-;; name following "Index:" in diff's output depends on the argument: If the
-;; argument is a filesystem pathname, the object name is absolute, and we can
-;; simply use that. If the argument is a uri, the object name is relative to the
-;; base item name. If the base item name was the uri to a file (and therefore a
-;; complete pathname) we can use item; if it was the uri to a directory, we have
-;; to concatenate the item and object to form a complete pathname.
+;; WRITE NEW COMMENT HERE

-(defn svndiff [r1 r2 object item]
+(defn svndiff [r1 r2 filename item]
   (let [item (baseitem item)
-        r (re-pattern (str "^.*/" object "$"))
+        r (re-pattern (str "^.*/" filename "$"))
         p (if (uri? item)
-            (if (re-matches r item) item (str item "/" object))
-            object)
+            (if (re-matches r item) item (str item "/" filename))
+            filename)
         v (vpaths r1 r2 p item)]
     (sh "svn" "diff" (first v) (second v))))


random alphabet

random alphabet

--- src/shorty/coder.clj
+++ src/shorty/coder.clj
@@ -21,7 +21,7 @@
 ;; Также само собой разумеется, что set, sequence, vector, hash-map (и любой свой defrecord)
 ;; универсально обрабатываются в map/filter (интерфейс ISeq). В отличие, например, от Go, где
 ;; до сих пор [нет универсального итератора](https://groups.google.com/forum/#!topic/golang-nuts/v6m86sTRbqA)
-(def alphabet (vec "bcdfghjkmnpqrstvwxyz23456789BCDFGHJKLMNPQRSTVWXYZ"))
+(def alphabet (vec "jdxXVYrtpv3k7BFsMyzNbh9wqRcJS865WKCGT2L4mDfgZHPQn"))
 (def base (count alphabet))

 ;; ### Рекурсия


work-in-progress commit

work-in-progress commit

--- src/tgmart/opus1.clj
+++ src/tgmart/opus1.clj
@@ -6,6 +6,7 @@
   (:require [tweegeemee.core :as tgm]))

 ;; working towards http://zine.electricobjects.com/artist-program
+;;
 ;; Still Images
 ;;
 ;; 1080px x 1920 pixels
@@ -27,24 +28,21 @@
 ;; have unsightly gaps.

 ;; some snippets based on mikea's code.  modified from telegenic so I
-;; could use ffmpeg.
-(def DEFAULT-OPTIONS
-  {:filename "art/a%03d.png"
-   :width (* (/ 1080 10) 3)
-   :height (* (/ 1920 10) 3)})
-
+;; could use ffmpeg.  also modified to allow for parallel runs on different
+;; systems
 (defmacro render-animation
-  "Macro to render a sequence of frames, looping with a symbolic frame counter."
-  ([[key frame-count] src]
-    `(render-animation [~key ~frame-count] ~src))
-  ([[key frame-count] src options]
+  "Macro to render a sequence of frames, looping with a symbolic frame counter.
+   Example: (render-animation [i 10] (offset [(* i 10) 0.0 0.0] (vnoise)))"
+  ([[key frame-end] src options]
+   `(render-animation [~key 0 ~frame-end 1] ~src))
+  ([[key frame-start frame-end] src options]
+   `(render-animation [~key ~frame-start ~frame-end 1] ~src))
+  ([[key frame-start frame-end frame-step] src options]
     (when-not (symbol? key) (error "render-animation needs a symbol binding for the frame number"))
-    (when-not (integer? frame-count) (error "render-animation needs an integer number of frames"))
-    `(let [mopts# (merge DEFAULT-OPTIONS ~options)
-           opts#  (mapcat identity mopts#)]
-       (doseq [~key (range ~frame-count)]    ;; loop over all frames, lazily (doseq for mem?)
+    `(let [opts#  (mapcat identity options#)]
+       (doseq [~key (range ~frame-start ~frame-end ~frame-step)] ;; loop over all frames, lazily. don't hold memory
          (let [im# (apply image ~src opts#)  ;; create the frame
-               fn# (format (:filename mopts#) ~key)]
+               fn# (format (:filename options#) ~key)]
            (apply show im# opts#)            ;; show the latest frame
            (ImageIO/write im# "png" (File. fn#))))))) ;; write the frame

@@ -58,6 +56,8 @@
 ;;   -c:v libx264 -preset slow -crf 22 \
 ;;   a.mp4

+;; rescale the data to frame it appropriately
+;; NOTE: https://github.com/mikera/clisk/issues/15
 (defn scale-for-vert-hd0
   "center at 0,0.  x ranges [-9/16,9/16], y [-1,1]"
   [fn]
@@ -71,36 +71,44 @@
   (->> fn
        (scale  [(/ 16 9) (/ 16 9)])))

+;; easing-like functions.  use on the key to create a scalar per frame
+(def circle-cos [i max-range steps]
+  (* max-range (Math/cos (* 2 Math/PI (/ i steps)))))
+(def circle-sin [i max-range steps]
+  (* max-range (Math/sin (* 2 Math/PI (/ i steps)))))
+(def half-circle-cos [i max-range steps]
+  (* max-range (Math/cos (* Math/PI (/ i steps)))))
+(def half-circle-sin [i max-range steps]
+  (* max-range (Math/sin (* Math/PI (/ i steps)))))
+
 ;; ======================================================================
 ;; Animation creation code
 (comment

   ;; ======================================================================
-  ;; pastel-dream
+  ;; opus1a - pastel dream
   ;; SAVE THIS -- really nice loop.
   (render-animation
    [i 3390] ;; 113 seconds
-   (offset
-    [0.0 0.0 0.0]     ;; use an offset in x-axis to scroll the image over time
-    (scale-for-vert-hd
-     (vpow
-      (length plasma)
-      (sigmoid
-       (gradient
+   (scale-for-vert-hd
+    (vpow
+     (length plasma)
+     (sigmoid
+      (gradient
+       (green-from-hsl
         (green-from-hsl
-         (green-from-hsl
-          (rgb-from-hsl
-           (v+ (offset [(* (Math/cos (* 2 Math/PI (/ i 3390))) 0.15)
-                        0.0
-                        (* (Math/sin (* 2 Math/PI (/ i 3390))) 0.15)]
-                       pos)
-               (blue-from-hsl [0.6035 -2.8447 0.9631]))))))))))
-   {:filename "art/pastel_dream/a%04d.png"
-    :width    (* (/ 1080 10) 3)
-    :height   (* (/ 1920 10) 3)})
-
-  ;; ======================================================================
-  ;; fun noise fn1
+         (rgb-from-hsl
+          (v+ (offset [(circle-cos i 0.15 3390)
+                       0.0
+                       (circle-sin i 0.15 3390)]
+                      pos)
+              (blue-from-hsl [0.6035 -2.8447 0.9631]))))))))))
+  {:filename "art/opus1a/a%04d.png"
+   :width    (* (/ 1080 10) 3)
+   :height   (* (/ 1920 10) 3)})
+
+  ;; ======================================================================
+  ;; fun noise opus1b
   ;; this is pretty good but not my favorite -- took 5.5 hours for 480 frames on MacBook Pro
   (render-animation
    [i 480]
@@ -133,13 +141,17 @@
        )
       )
      )
-   {:filename "art/fn1/a%04d.png"
+   {:filename "art/opus1b/a%04d.png"
     :width    (* (/ 1080 10) 3)
     :height   (* (/ 1920 10) 3)
     })

   ;; ======================================================================
-  ;; fun noise fn2 -- 30s/frame. [ ] Go with 1000 frames over night
+  ;; opus1c - orange fun noise
+  ;; 30s/frame.
+  ;; [ ] Go with 1000 frames over night (got 870)
+  ;; I like the circular movement, but the noise has to stay still or change MUCH less.
+  ;; maybe try no cross3 offset?
   (render-animation
    [i 1000]
     (scale-for-vert-hd
@@ -174,37 +186,31 @@
        )
       )
      )
-   {:filename "art/fn2/a%04d.png"
+   {:filename "art/opus1c/a%04d.png"
     :width    (* (/ 1080 10) 3)
     :height   (* (/ 1920 10) 3)
     })

   ;; ======================================================================
-  ;; fn3 :name "151130_023115_N.clj"
+  ;; opus1d based on "151130_023115_N.clj"
   ;; in process...
   (render-animation
-   [i 10]
-    (scale-for-vert-hd
+   [i 300]
+    (scale-for-vert-hd0
      (adjust-hsl
-      (offset
-        [(* (Math/sin (* 2 Math/PI (/ i 10))) 0.1)
-         (* (Math/cos (* 2 Math/PI (/ i 10))) 0.1)
-         (* (Math/sin (* 2 Math/PI (/ i 10))) 0.1)]
-        (adjust-hue
-         (x (gradient (x (gradient (gradient spots)))))
-         (max-component (hsl-from-rgb [0.795 2.244 -0.63])))
-        )
-      (gradient
-       (offset
-        [(* (Math/sin (* 2 Math/PI (/ i 10))) 0.04)
-         (* (Math/cos (* 2 Math/PI (/ i 10))) 0.02)
-         0.0]
-        (gradient spots)
-        )
+      (rotate
+       (* 2 Math/PI (/ i -300))
+      (adjust-hue
+       (x (gradient (x (gradient (gradient spots)))))
+       (max-component (hsl-from-rgb [0.795 2.244 -0.63])))
+      )
+      (rotate
+       (* 2 Math/PI (/ i 300))
+       (gradient (gradient spots))
        )
       )
      )
-   {:filename "art/fn3/a%04d.png"
+   {:filename "art/opus1d/a%04d.png"
     :width    (* (/ 1080 10) 3)
     :height   (* (/ 1920 10) 3)
     })


whitespace

whitespace

--- src/cavm/db.clj
+++ src/cavm/db.clj
@@ -4,6 +4,7 @@
   "Xena database protocol"
   (write-matrix [this mname files metadata data-fn features always]
                 "Write a matrix to storage")
-  (write-probemap [this pname files metadata data-fn always] "Write a probemap to storage")
+  (write-probemap [this pname files metadata data-fn always]
+                  "Write a probemap to storage")
   (run-query [this query] "Execute a metadata sql query")
   (close [this] "Close the database"))


0.2.4 template

0.2.4 template

--- template/project.clj
+++ template/project.clj
@@ -1,4 +1,4 @@
-(defproject cljs-lambda/lein-template "0.2.3"
+(defproject cljs-lambda/lein-template "0.2.4"
   :description "Clojurescript on AWS Lambda"
   :url "https://github.com/nervous-systems/cljs-lambda"
   :license {:name "Unlicense" :url "http://unlicense.org/UNLICENSE"}


cleaned up code

cleaned up code

--- src/io/cyanite/store.clj
+++ src/io/cyanite/store.clj
@@ -146,13 +146,12 @@
            chan_size 10000
            batch_size 500}}]
   (info "creating cassandra metric store")
-  (if (not-any? nil? [username password]) (info "username or password is missing"))
 (let [cluster (if (sequential? cluster) cluster [cluster])
-      session (-> (if (not-any? nil? [username password])
-                    (alia/cluster {:contact-points cluster :credentials {:user username, :password password}})
-                    (alia/cluster {:contact-points cluster})
-                    )
-                   (alia/connect keyspace))
+      session (-> {:contact-points cluster}
+          (cond-> (and username password)
+                   (assoc :credentials {:user username :password password}))
+          (alia/cluster)
+          (alia/connect keyspace))
         insert! (insertq session)
         fetch!  (fetchq session)]
     (reify


style

style

--- src/java_time/graph.cljc
+++ src/java_time/graph.cljc
@@ -140,7 +140,7 @@
 (deftype ConversionGraph [m-by-arity srcs]
   IConversionGraph
   (get-conversion [_ src dst]
-    (let [m (get m-by-arity (.arity ^Types src))]
+    (let [m (m-by-arity (.arity ^Types src))]
       (->> (get-in m (.types ^Types src))
            (some #(= dst (first %))))))
   (assoc-conversion [_ src dst f cost]
@@ -150,19 +150,19 @@
       (conj srcs src)))
   (possible-sources [_] srcs)
   (equivalent-targets [_ dst]
-    (->> (vals m-by-arity)
-         (mapcat collect-targets)
-         (map first)
-         (filter #(assignable? % dst))
-         (set)))
+    (into #{} (comp (mapcat collect-targets)
+                    (map first)
+                    (filter #(assignable? % dst)))
+          (vals m-by-arity)))
   (possible-conversions [_ src]
-    (let [result (volatile! (vector))]
+    (let [^Types src src
+          result (volatile! [])]
       (search-for-possible-sources
         result
-        (get m-by-arity (.arity ^Types src))
-        (vector)
-        (first (.types ^Types src))
-        (next (.types ^Types src)))
+        (m-by-arity (.arity src))
+        []
+        (first (.types src))
+        (next (.types src)))
       @result)))

 (defn conversion-graph []
@@ -184,7 +184,7 @@

 (defn- conj-path [^ConversionPath p src dst ^Conversion c]
   (ConversionPath.
-    (conj (.path p) (vector src dst))
+    (conj (.path p) [src dst])
     (conj (.fns p) (.f c))
     (conj (.visited? p) dst)
     (+ (.cost p) (.cost c))))
@@ -224,13 +224,14 @@
           (subvec v (inc (last idxs)) (count v))))

 (defn- index-conversions [^Types src idxs [[_ ^Types replacement] ^Conversion conv]]
-  (vector src (types (replace-range (.types src) (.types replacement) idxs))
-          (fn [vs]
-            (let [vs (vec vs)]
-              (replace-range vs
-                             ((.f conv) (subvec vs (first idxs) (inc (last idxs))))
-                             idxs)))
-          (.cost conv)))
+  [src
+   (types (replace-range (.types src) (.types replacement) idxs))
+   (fn [vs]
+     (let [vs (vec vs)]
+       (replace-range vs
+                      ((.f conv) (subvec vs (first idxs) (inc (last idxs))))
+                      idxs)))
+   (.cost conv)])

 (defn- sub-conversions
   "Given an `src` types, generate all of the conversions from these types that
@@ -247,7 +248,7 @@
               [src -> String]"
   [g ^Types src]
   (if (> (.arity src) max-arity)
-    (vector)
+    []
     (->> (continuous-combinations (.arity src))
          (mapcat
            (fn [idxs]
@@ -259,7 +260,8 @@
                     (map #(index-conversions src idxs %)))))))))

 (defn- with-conversions [g convs]
-  (loop [g g, new-conversions (vector)
+  (loop [g g
+         new-conversions []
          [src dst f cost :as con] (first convs)
          convs (next convs)]
     (if con
@@ -275,16 +277,15 @@
 ;; we want to skip the branches that contain the destination types as their part.
 ;; In our conversion world it's very unlikely that a value will be reduced to
 ;; the value of the same type.
-(def contains-types?
+(defn contains-types?
   "True if `a` contains `b` as its part."
-  (fn [^Types a, ^Types b]
-    (and (not= (.arity a) (.arity b))
-         (let [ta (.types a), tb (.types b)]
-           (loop [idx 0]
-             (when (>= (.arity a) (+ idx (.arity b)))
-               (if (= tb (subvec ta idx (+ idx (.arity b))))
-                 true
-                 (recur (inc idx)))))))))
+  [^Types a, ^Types b]
+  (and (not= (.arity a) (.arity b))
+       (let [ta (.types a), tb (.types b)]
+         (loop [idx 0]
+           (when (>= (.arity a) (+ idx (.arity b)))
+             (or (= tb (subvec ta idx (+ idx (.arity b))))
+                 (recur (inc idx))))))))

 ;; if a graph's sources do not contain all of the types present in the
 ;; requested source and the destination doesn't contain them either we conclude
@@ -318,15 +319,14 @@
           (graph-conversion-path g' src dst))))))

 (defn- convert-via [path]
-  (condp = (count (:path path))
-    0 (vector path (fn [x] x))
-    1 (vector path (->> path :fns first))
-    (let [fns (->> path :fns vec)]
-      (vector path (fn [v] (reduce (fn [v f] (f v)) v fns))))))
+  (case (count (:path path))
+    0 [path identity]
+    1 [path (-> path :fns first)]
+    [path (fn [v] (reduce (fn [v f] (f v)) v (:fns path)))]))

 (defn conversion-fn
   "Create a function which will convert between the `src` and the `dst`
   `Types`."
   [g src dst]
-  (when-let [path (conversion-path g src dst)]
+  (when-some [path (conversion-path g src dst)]
     (convert-via path)))


Removed unknown type (keep null as default)

--- src/lobos/migrations.clj
+++ src/lobos/migrations.clj
@@ -23,9 +23,7 @@

 (defmigration add-basic-types
               (up [] (sql/insert! (lobos.config/db) :types
-                                  {:name "Unknown"}
                                   {:name "Bar"}
                                   {:name "Pub"}
                                   {:name "Take Away"} ))
-              (down [] (sql/delete! (lobos.config/db) :types [])))
-
+              (down [] (sql/delete! (lobos.config/db) :types [])))


AB & RS | 128 | Add stub index handler to pass build

--- src/mooncake/handler.clj
+++ src/mooncake/handler.clj
@@ -3,6 +3,9 @@
             [ring.adapter.jetty :as ring-jetty]
             [mooncake.routes :as routes]
             [mooncake.config :as config]))
+
+(defn index [request]
+  "test")

 (def site-handlers
   {:index index})
@@ -13,4 +16,6 @@
 (def app (create-app (config/create-config)))

 (defn -main [& args]
-  (ring-jetty/run-jetty app {:port (config/port config-m) :host (config/host config-m)}))
+  (let [config-m (config/create-config)]
+    (ring-jetty/run-jetty app {:port (config/port config-m)
+                               :host (config/host config-m)})))


AB & RS | 128 | Minor change to test heroku deploy

--- src/mooncake/handler.clj
+++ src/mooncake/handler.clj
@@ -6,7 +6,7 @@
             [mooncake.config :as config]))

 (defn index [request]
-  (r/response "test"))
+  (r/response "test 2"))

 (def site-handlers
   {:index index})


refactored copypaste away

refactored copypaste away

--- src/ontrail/exercise.clj
+++ src/ontrail/exercise.clj
@@ -57,7 +57,7 @@
      :hrReserve heart-rate-reserve
      :pace (get-pace exercise)
      :commentCount comment-count
-     :comments comments}))
+     :comments comments}))

 (defn as-ex-result-list [results]
   (map as-ex-result results))
@@ -75,29 +75,6 @@
   (let [exercise (mc/find-one-as-map EXERCISE {:_id (ObjectId. id)})]
     (.debug logger (format " get ex=%s" id))
     (if (nil? exercise)
-      {:error "No such id"}
-      (let [user (:user exercise)
-            user-profile (:profile (mc/find-one-as-map ONUSER {:username user}))
-            heart-rate-reserve (get-heart-rate-reserve exercise user-profile)
-            comments (:comments exercise)
-            distance (to-human-distance (:distance exercise))
-            comment-count (if-not (nil? comments) (count comments) 0)
-            avatar (get-avatar-url user)
-            date (to-human-date (:creationDate exercise))]
-        {:id id
-         :user user
-         :distance distance
-         :title (:title exercise)
-         :body (:body exercise)
-         :tags (:tags exercise)
-         :did (get-verb (:sport exercise))
-         :sport (:sport exercise)
-         :avatar avatar
-         :date date
-         :duration (to-human-time (:duration exercise))
-         :creationDate (to-human-date (:creationDate exercise))
-         :avghr (:avghr exercise)
-         :hrReserve heart-rate-reserve
-         :pace (get-pace exercise)
-         :commentCount comment-count
-         :comments comments}))))+      {:error "No such id"}
+      (as-ex-result exercise))))
+


Update schema.

Update schema.

--- src/onyx/log/replica.clj
+++ src/onyx/log/replica.clj
@@ -31,4 +31,6 @@
    :killed-jobs []
    :state-logs {}
    :state-logs-marked #{}
-   :task-slot-ids {}})
+   :task-slot-ids {}
+   :required-tags {}
+   :peer-tags {}})


Document par-group

Document par-group

--- src/overtone/sc/node.clj
+++ src/overtone/sc/node.clj
@@ -394,6 +394,9 @@
 ;; SCLang (as opposed to from the command line) there will also be a 'default
 ;; group' with an ID of 1 which is the default target for all new Nodes. See
 ;; RootNode and default_group for more info.
+;; A ParGroup is behaves similarly to a group and has the same interface, but
+;; will allow parallel audio processing for nodes within it when run in the
+;; Supernova synthesis server.


immigrate fns as vars not vals - enables dynamic reloading in the original namespace to propagate through to immigrated versions of the fns.

--- src/overtone/util/ns.clj
+++ src/overtone/util/ns.clj
@@ -10,5 +10,7 @@
    (doseq [[sym var] (ns-publics ns)]
      (let [sym (with-meta sym (assoc (meta var) :orig-ns ns))]
        (if (.isBound var)
-         (intern *ns* sym (var-get var))
+         (intern *ns* sym (if (fn? (var-get var))
+                            var
+                            (var-get var)))
          (intern *ns* sym))))))


remove inspect

remove inspect

--- src/pc/http/datomic2.clj
+++ src/pc/http/datomic2.clj
@@ -204,7 +204,7 @@
          true)))

 (defn add-issue-frontend-ids [txes]
-  (let [eid-map (pc.utils/inspect (zipmap (set (map (comp second second) txes)) (repeatedly #(d/tempid :db.part/user))))
+  (let [eid-map (zipmap (set (map (comp second second) txes)) (repeatedly #(d/tempid :db.part/user)))
         ;; matches tempid with issue-id
         ;; TODO: should we use value for identity type and look up ids?
         frontend-id-txes (map (fn [[frontend-id tempid]] [:db/add tempid :frontend/issue-id frontend-id]) eid-map)]


fixed keyhandling previous item

fixed keyhandling previous item

--- src/re_complete/app.cljs
+++ src/re_complete/app.cljs
@@ -133,7 +133,7 @@
         previous-selected-item-index (dec (first selected-item))
         new-selected-item (if-not selected-item
                             (last suggestion-indexed-vector)
-                            (if (= (count suggestion-list) previous-selected-item-index)
+                            (if (= -1 previous-selected-item-index)
                               (last suggestion-indexed-vector)
                               (nth suggestion-indexed-vector previous-selected-item-index)))]
     (-> db


Some indentation and comment update

Some indentation and comment update

--- src/riemann/influxdb.clj
+++ src/riemann/influxdb.clj
@@ -5,9 +5,8 @@

 (defn influxdb
   "Returns a function which accepts an event and sends it to InfluxDB.
-  Use:
-
-  ;; For giving series name as the combination of :host and :service separated by dot.
+
+  ;; For giving series name as the concatenation of :host and :service fields with dot separator.

   (influxdb {:host \"play.influxdb.org\" :port 8086 :series \"host.service\"})

@@ -21,8 +20,7 @@

   :password       Password of the corresponding user.

-  :series         Name of the InfluxDB time-series."
-
+  :series         Name of the InfluxDB's time-series."
   [opts]
   (let [opts (merge {:host "127.0.0.1"
                      :port 8086
@@ -34,10 +32,10 @@
         client (influx/make-client opts)]
     (fn [event]
       (let [series (join "." (map (fn [e] (e event)) (vec (map (fn [k] (keyword k)) (split (:series opts) #"\.")))))]
-      (when (:metric event)
-        (when (:service event)
-          (when (:host event)
-            (influx/post-points client series [{ :name (:service event)
-                                                 :host (:host event)
-                                                 :state (:state event)
-                                                 :value (:metric event) }]))))))))
+        (when (:metric event)
+          (when (:service event)
+            (when (:host event)
+              (influx/post-points client series [{ :name (:service event)
+                                                   :host (:host event)
+                                                   :state (:state event)
+                                                   :value (:metric event) }]))))))))


Add examplars for strings with unrecognized encodings

--- test/exemplar.clj
+++ test/exemplar.clj
@@ -219,6 +219,16 @@
     [{"aaaa" 1 "bbbb" 2} {"aaaa" 3 "bbbb" 4} {"aaaa" 5 "bbbb" 6}])

   (write-exemplar
+    "maps_unrecognized_keys"
+    "Vector of maps with keys with unrecognized encodings"
+    [{"`~#unrecognized" :anything} {"`~#U" :anything-else}])
+
+  (write-exemplar
+    "map_unrecognized_vals"
+    "Map with vals with unrecognized encodings"
+    {:key "`~unrecognized"})
+
+  (write-exemplar
     "vector_93_keywords_repeated_twice"
     "Vector of 93 keywords, repeated twice"
     (vector-of-keywords 93 186))
@@ -231,4 +241,9 @@
   (write-exemplar
     "vector_95_keywords_repeated_twice"
     "Vector of 95 keywords, repeated twice"
-    (vector-of-keywords 95 190)))
+    (vector-of-keywords 95 190))
+
+  (write-exemplar
+    "vector_unrecognized_vals"
+    "Vector with vals with unrecognized encodings"
+    ["`~unrecognized"]))


cleanup

cleanup

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -437,8 +437,7 @@
             :english {:past "carried"}}

    "cat" {:synsem {:cat :noun
-                   :sem {:pred :cat
-                         :pet true}}}
+                   :sem {:pred :cat}}}

    "chair" {:synsem {:cat :noun
                      :sem {:pred :chair}}}
@@ -599,8 +598,7 @@
                         :sem {:pred :scaricare}}}

    "dog" {:synsem {:cat :noun
-                   :sem {:pred :dog
-                         :pet true}}}
+                   :sem {:pred :dog}}}

    "earn"  {:synsem {:cat :verb
                      :sem {:pred :earn}}}


Implemented the random bitwise and instruction

--- src/chip8_clj/instructions.clj
+++ src/chip8_clj/instructions.clj
@@ -159,8 +159,15 @@

 (defn execute-CXNN
   [machine-state opcode]
-  (log/info "execute-CXNN: Error: Not yet implemented")
-  (System/exit 1))
+  (let [reg-num (utils/get-nibble1 opcode)
+        imm (utils/get-byte1 opcode)
+        rnd (rand-int 0xFF)
+        result (bit-and imm rnd)]
+    (log/info (format "0x%04x CXNN 0x%04x rnd V[%d](0x%02x) <- rand(0x%02x) & NN(0x%02x)"
+                       (:pc machine-state) opcode reg-num result rnd imm))
+    (-> machine-state
+        (machine-state/set-register reg-num result)
+        (machine-state/increment-pc))))

 (defn execute-DXYN
   [machine-state opcode]


added a unit test for 15 minutes

added a unit test for 15 minutes

--- src/clj/test/cards-agendas.clj
+++ src/clj/test/cards-agendas.clj
@@ -1,4 +1,41 @@
 (in-ns 'test.core)
+
+(deftest fifteen-minutes
+  "15 Minutes - check if it works correctly from both sides"
+  (do-game
+    (new-game (default-corp [(qty "15 Minutes" 1)]) (default-runner))
+    (play-from-hand state :corp "15 Minutes" "New remote")
+    (take-credits state :corp)
+    ; use 15 minutes to take it away from runner
+    (core/click-run state :runner {:server "Server 1"})
+    (core/no-action state :corp nil)
+    (core/successful-run state :runner nil)
+    (prompt-choice :runner "Steal")
+    (take-credits state :runner)
+    (is (= 1 (:agenda-point (get-runner))))
+    (is (= 1 (count (:scored (get-runner)))))
+    (let [fifm (first (:scored (get-runner)))]
+      (is (= 3 (:click (get-corp))))
+      (is (= 1 (count (:abilities (refresh fifm)))))
+      (card-ability state :corp (refresh fifm) 0)
+      (is (= 0 (:agenda-point (get-runner))))
+      (is (= 0 (count (:scored (get-runner))))))
+    (is (= "15 Minutes" (:title (first (:deck (get-corp))))))
+    (is (= 2 (:click (get-corp))))
+    ; use 15 minutes to take it away from corp (hey, maybe some obscure case happens where corp would want that)
+    (core/click-draw state :corp 1)
+    (play-from-hand state :corp "15 Minutes" "New remote")
+    (take-credits state :runner)
+    (score-agenda state :corp (get-in @state [:corp :servers :remote2 :content 0]))
+    (is (= 1 (:agenda-point (get-corp))))
+    (is (= 1 (count (:scored (get-corp)))))
+    (let [fifm (first (:scored (get-corp)))]
+      (is (= 1 (count (:abilities (refresh fifm)))))
+      (card-ability state :corp (refresh fifm) 0)
+      (is (= 0 (:agenda-point (get-corp))))
+      (is (= 0 (count (:scored (get-corp))))))
+    (is (= "15 Minutes" (:title (first (:deck (get-corp))))))
+    ))

 (deftest ancestral-imager
   "Ancestral Imager - damage on jack out"


Add draft of expedintures.

Add draft of expedintures.

--- src/cljs/beatha/automaton.cljs
+++ src/cljs/beatha/automaton.cljs
@@ -196,9 +196,11 @@
 (def market-model
   (let [env (atom {:tax-rate 0.05
                    :prices
-                   {:corp-1 10 :corp-2 10 :corp-3 10 :corp-4 10}
+                   {:corp-1 100 :corp-2 100 :corp-3 100 :corp-4 100}
                    :capital
-                   {:corp-1 0 :corp-2 0 :corp-3 0 :corp-4 0 :government 0}
+                   {:corp-1 0 :corp-2 0 :corp-3 0 :corp-4 0 :government 1000}
+                   :expenditures-per-cell
+                   {:government 1 :corp-1 20 :corp-2 20 :corp-3 20 :corp-4 20}
                    :depreciation 0.03
                    :utility-params
                    {:a 1 :p -1}
@@ -244,46 +246,62 @@
             :without-good))
       (next-grid [this grid]
         (let [cell-count (* (:width grid) (:height grid))
+              env-atom env
+              env @env
               global-share
               (->> (vals (:cells grid))
                    (group-by :state)
                    (map (fn [[k v]] [k (/ (count v) cell-count)]))
-                   (into {:corp-1 0 :corp-2 0 :corp-3 0 :corp-4 0}))]
-          (transition
-           this grid :without-good
-           (fn [this width height cells x y]
-             (let [env-atom env
-                   env @env
-                   get-cell (partial get-cell this cells)
-                   n-states
-                   (ordered-neighbour-states get-cell width height x y)
-
-                   {:keys [top-left top top-right left right
-                           bottom-left bottom bottom-right]}
-                   n-states
-
-                   cell (get-cell [x y])
-                   s (:state cell)
-                   without-good? (fn [s] (= :without-good s))]
-               (when-not (without-good? s)
-                 (let [price (get-in env [:prices s] 0)
-                       tax (* price (get env :tax-rate 0))
-                       income (- price tax)]
-                   (swap! env-atom
-                          (fn [e]
-                            (-> e
-                                (update-in [:capital s] + income)
-                                (update-in [:capital :government] + tax))))))
-               {[x y]
-                {:state
-                 (cond
-                  (< (rand) (:depreciation env))
-                  :without-good
-
-                  (without-good? s)
-                  (weighted (user-preferences env global-share n-states))
-
-                  :else s)}})))))
+                   (into {:corp-1 0 :corp-2 0 :corp-3 0 :corp-4 0}))
+
+              next
+              (transition
+               this grid :without-good
+               (fn [this width height cells x y]
+                 (let [get-cell (partial get-cell this cells)
+                       n-states
+                       (ordered-neighbour-states get-cell width height x y)
+
+                       {:keys [top-left top top-right left right
+                               bottom-left bottom bottom-right]}
+                       n-states
+
+                       cell (get-cell [x y])
+                       s (:state cell)
+                       without-good? (fn [s] (= :without-good s))]
+                   (when-not (without-good? s)
+                     (let [price (get-in env [:prices s] 0)
+                           exp (get-in env [:expenditures-per-cell s] 0)
+                           tax (* price (get env :tax-rate 0))
+                           income (- price tax exp)]
+                       (swap! env-atom
+                              (fn [e]
+                                (-> e
+                                    (update-in [:capital s] + income)
+                                    (update-in [:capital :government]
+                                               + tax))))))
+                   {[x y]
+                    {:state
+                     (cond
+                      (< (rand) (:depreciation env))
+                      :without-good
+
+                      (without-good? s)
+                      (weighted (user-preferences env global-share n-states))
+
+                      :else s)}})))]
+          (swap! env-atom
+                 (fn [e]
+                   (update-in
+                    e [:capital :government]
+                    (fn [capital cell-count]
+                      (- capital
+                         (* cell-count
+                            (get-in env [:expenditures-per-cell :government]
+                                    0))))
+                    cell-count)))
+          (println env)
+          next))

       InformationChannelsSpecification
       (process-info-channel [this ic])