Cleaned up watcher loop, still pretty ugly though

--- src/demogorgon/nh.clj
+++ src/demogorgon/nh.clj
@@ -347,8 +347,10 @@
       (announce irc (make-livelog-out data)))))

 (defn run-watcher [watcher]
-  (with-local-vars [xlogfile-length (.length (File. "/opt/nethack.nu/var/unnethack/xlogfile"))
-                    livelog-length (.length (File. "/opt/nethack.nu/var/unnethack/livelog"))]
+  (with-local-vars [files {"livelog"   {:length (.length (File. (str (:un-dir config) "livelog")))
+                                        :callback #'handle-livelog-line}
+                           "xlogfile"  {:length (.length (File. (str (:un-dir config) "xlogfile")))
+                                        :callback #'handle-livelog-line}}]
     (while
      (not (Thread/interrupted))
      (.debug logger (str "Waiting for events.."))
@@ -356,29 +358,23 @@
        (.debug logger "Got events")
        (doseq [event (.pollEvents key)]
          (.debug logger (str "context " (.context event)))
-         (if (= (.toString (.context event)) "livelog")
-           (let [ra (RandomAccessFile. "/opt/nethack.nu/var/unnethack/livelog" "r")]
-             (.debug logger "livelog")
-             (.seek ra (var-get livelog-length))
-             (loop [line (.readLine ra)]
-               (if line
-                 (do
-                   (handle-livelog-line (:irc @watcher) line)
-                   (var-set livelog-length (.getFilePointer ra))
-                   (recur (.readLine ra)))))
-             (.close ra)))
-         (if (= (.toString (.context event)) "xlogfile")
-           (let [ra (RandomAccessFile. "/opt/nethack.nu/var/unnethack/xlogfile" "r")]
-             (.debug logger "xlogfile")
-             (.seek ra (var-get xlogfile-length))
-             (loop [line (.readLine ra)]
-               (if line
-                 (do
-                   (handle-xlogfile-line (:irc @watcher) line)
-                   (var-set xlogfile-length (.getFilePointer ra))
-                   (recur (.readLine ra)))))
-             (.close ra))))
-       (.reset key)))))
+         (let [fn (.toString (.context event))
+               file (get (var-get files) fn)]
+           (if file
+             (do
+               (.debug logger (str "file modified: " fn))
+               (let [ra (RandomAccessFile. (str (:un-dir config) fn))]
+                 (.seek ra (:length file))
+                 (loop [line (.readLine ra)]
+                   (if line
+                     (do
+                       ((:callback file) (:irc @watcher) line)
+                       (var-set files (assoc (var-get files)
+                                        fn
+                                        (assoc (get fn (var-get files)) :length (.getFilePointer ra))))
+                       (recur (.readLine ra)))))
+                 (.close ra)))))
+         (.reset key))))))

 (defn nh-init [irc]
   (let [watcher (ref (struct-map watcher-instance


Small cleanup

Small cleanup

--- src/demogorgon/nh.clj
+++ src/demogorgon/nh.clj
@@ -89,7 +89,7 @@
         keys (map (fn [x] (keyword (aget (.split x "=") 0))) props)
         values (map (fn [x] (let [tokens (.split x "=")]
                               (if (> (alength tokens) 1)
-                                (aget (.split x "=") 1)
+                                (aget tokens 1)
                                 ""))) props)]
     (zipmap keys values)))


using recursive mappings

using recursive mappings

--- src/docker/remote.clj
+++ src/docker/remote.clj
@@ -12,7 +12,6 @@
 (ns docker.remote
   "Docker http remote API client"
   (:require
-    [flatland.useful.map :refer [map-keys]]
     [camel-snake-kebab :as k]
     [celestial.model :refer (clone hypervisor)]
     [cheshire.core :refer :all]
@@ -25,6 +24,11 @@

 (defn root [node]
   (<< "https://~(hypervisor :docker :nodes node :host):~(hypervisor :docker :nodes node :port)/"))
+
+(defn map-keys
+  "Recursively transforms all map keys"
+  [m f]
+  (clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map (fn [[k v]] [(f k) v]) x)) x)) m))

 (defn uncamel [m]
  (map-keys m k/->kebab-case))


Improved docstrings on stream ns.

Improved docstrings on stream ns.

--- src/futura/stream.clj
+++ src/futura/stream.clj
@@ -28,6 +28,8 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn- chan->subscription
+  "Coerce a core.async channel to an instance
+  of subscription interface."
   [subscriber source xform]
   (let [completed (atomic/boolean false)
         requests (async/chan)
@@ -64,6 +66,8 @@
           (async/close! requests))))))

 (defn- promise->subscription
+  "Coerce a promise instance to an instance
+  of subscription interface."
   [subscriber source]
   (let [canceled (atomic/boolean false)
         completed (atomic/boolean false)]
@@ -79,6 +83,10 @@
         (atomic/set! canceled true)))))

 (defn- proxy-subscriber
+  "Create a proxy subscriber.
+  The main purpose of this proxy is apply some
+  kind of transformations to the proxied publisher
+  using transducers."
   [^Publisher p xform subscriber]
   (let [rf (xform (fn
                     ([s] s)
@@ -112,6 +120,8 @@
           (.onComplete subscriber))))))

 (defn- subscribe-once
+  "Create a subscription instance that only
+  subscribes for one value."
   [^Publisher p callback]
   (let [subscription (atomic/ref nil)
         completed (atomic/boolean false)


Clojure 1.2 update: flatten has been promoted to core.

--- src/leiningen/classpath.clj
+++ src/leiningen/classpath.clj
@@ -1,6 +1,5 @@
 (ns leiningen.classpath
   (:use (clojure.contrib [io :only (file)]
-                         [seq :only (flatten)]
                          [string :only (join)])
         [leiningen.checkout-deps :only [checkout-deps-paths]])
   (:import org.apache.tools.ant.types.Path))


lein-template: Add default cljs file.

lein-template: Add default cljs file.

--- lein-template/src/main/leiningen/new/aviary/src/main/cljs/aviary/site.cljs
+++ lein-template/src/main/leiningen/new/aviary/src/main/cljs/aviary/site.cljs
@@ -0,0 +1,17 @@
+(ns {{namespace}}.core)
+
+(defonce site (atom {:running? false}))
+
+(defn start
+  "Start the site. Attempt to be idempotent."
+  []
+  (when-not (:running? @site)
+    (swap! site assoc :running? true)))
+
+(defn stop
+  "Stop the site. Attempt to be idempotent. Useful for interactive local development."
+  []
+  (when (:running? @site)
+    (swap! site assoc :running? false)))
+
+(start)


Add tests that include additional operations.

--- test/dsbdp/test/data_processing_dsl_tests.clj
+++ test/dsbdp/test/data_processing_dsl_tests.clj
@@ -60,3 +60,23 @@
         result (data-processing-fn byte-array-test-data 0)]
     (is (= expected result))))

+(deftest byte-array-to-java-map-with-additional-operation-test
+  (let [expected {"udpSrc" 1024, "udpDst" 2048}
+        dsl-expression {:output-type :java-map
+                        :rules [['udpSrc '(/ (int16 50) 2)]
+                                ['udpDst '(/ (int16 52) 2)]]}
+        data-processing-fn (create-data-processing-fn dsl-expression)
+        result (data-processing-fn byte-array-test-data 0)]
+    (is (= java.util.HashMap (type result)))
+    (is (= expected result))))
+
+(deftest byte-array-to-java-map-with-additional-operation-and-float-type-test
+  (let [expected {"udpSrc" (float 0.031250477), "udpDst" (float 0.06250095)}
+        dsl-expression {:output-type :java-map
+                        :rules [['udpSrc '(float (/ (int16 50) 65535))]
+                                ['udpDst '(float (/ (int16 52) 65535))]]}
+        data-processing-fn (create-data-processing-fn dsl-expression)
+        result (data-processing-fn byte-array-test-data 0)]
+    (is (= java.util.HashMap (type result)))
+    (is (= expected result))))
+


Rough measure of how long lazy web seach takes

--- test/layzee/integration/lazy_web_examples.clj
+++ test/layzee/integration/lazy_web_examples.clj
@@ -14,5 +14,5 @@
 (facts "How long does it take roughly?"
        (fact "to, for example, do a lazy web search"
        (let [result (time #(twitter/lazy-web settings/twitter-bearer-token))]
-         (println (:duration result))
+         (:duration result) => (roughly 2000 1000)
          (count (:result result)) => 15)))


updating statement tests, #68

updating statement tests, #68

--- test/org/libraryweasel/ligature/core_test.clj
+++ test/org/libraryweasel/ligature/core_test.clj
@@ -40,9 +40,12 @@
   (testing "Common examples"
     (is (statement? ["hello" "world" "triple"]))
     (is (statement? ["hello" "world" "triple" "graph"]))
+    (is (not (statement? [])))
+    (is (not (statement? ["g"])))
+    (is (not (statement? ["test" "test"])))
+    (is (not (statement? ["test" "test" "g" "h" "e"])))
     (is (not (statement? [5 3 66 554])))
     (is (not (statement? ["test" "test" :a])))
-    (is (= ["test" :a "test" "test"] ["test" "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" "test" "test"]))
     (is (statement? ["test" :a "test" "test"])))) ; TODO more test cases

 (deftest lang-tag?-test


Fix misspelling

Fix misspelling

--- src/leiningen/droid/build.clj
+++ src/leiningen/droid/build.clj
@@ -135,7 +135,7 @@
   (info "Creating APK...")
   (ensure-paths sdk-path out-res-pkg-path out-dex-path)
   (let [apkbuilder-bin (str sdk-path "/tools/apkbuilder")
-        suffix (if (dev-build? project) "debug-analigned" "unaligned")
+        suffix (if (dev-build? project) "debug-unaligned" "unaligned")
         unaligned-path (append-suffix out-apk-path suffix)
         clojure-jar (first-matched #(re-find #"android/clojure" (str %))
                                    (resolve-dependencies :dependencies project))
@@ -154,7 +154,7 @@
   [{{:keys [out-apk-path keystore-path key-alias]} :android :as project}]
   (info "Signing APK...")
   (let [dev-build (dev-build? project)
-        suffix (if dev-build "debug-analigned" "unaligned")
+        suffix (if dev-build "debug-unaligned" "unaligned")
         unaligned-path (append-suffix out-apk-path suffix)
         storepass (if dev-build "android"
                       (read-password "Enter storepass: "))
@@ -179,7 +179,7 @@
   [{{:keys [sdk-path out-apk-path]} :android :as project}]
   (info "Aligning APK...")
   (let [zipalign-bin (str sdk-path "/tools/zipalign")
-        unaligned-suffix (if (dev-build? project) "debug-analigned" "unaligned")
+        unaligned-suffix (if (dev-build? project) "debug-unaligned" "unaligned")
         unaligned-path (append-suffix out-apk-path unaligned-suffix)
         aligned-path (if (dev-build? project)
                        (append-suffix out-apk-path "debug")


A bit 'o documentation

A bit 'o documentation

--- src/midje/checking/core.clj
+++ src/midje/checking/core.clj
@@ -5,13 +5,17 @@
 ;;; There is a notion of "extended falsehood", in which a false value may be a
 ;;; map containing information about what went wrong.

+(defn data-laden-falsehood? [value]
+  (:midje/data-laden-falsehood (meta value)))
+
 (defn as-data-laden-falsehood [value]
   (vary-meta value assoc :midje/data-laden-falsehood true))

-(defn data-laden-falsehood? [value]
-  (:midje/data-laden-falsehood (meta value)))
-
-(defn data-laden-falsehood-to-map [value]
+(defn data-laden-falsehood-to-map
+  "Used for testing Midje itself, this prevents a Midje
+   example of the expected creation of a data-laden falsehood
+   from being interpreted as a failure."
+  [value]
   (with-meta value {}))

 (defn extended-false? [value]
@@ -22,6 +26,8 @@
   (not (extended-false? value)))

 (defn user-friendly-falsehood [value]
+  "'downcast' a possible data-laden falsehood into
+   `false` if necessary."
   (if (data-laden-falsehood? value)
     false
     value))


remove debug tap>

remove debug tap>

--- src/main/shadow/build/npm.clj
+++ src/main/shadow/build/npm.clj
@@ -217,7 +217,6 @@

     ;; when package.json exists lookup entry
     ;; otherwise look for <dir>/index.js
-    (tap> [:find-package-main package-dir package-json npm])
     (or (and package-json
              (let [entries
                    (->> (get-in npm [:js-options :entry-keys])


ensure live and core are similar

ensure live and core are similar

--- src/overtone/live.clj
+++ src/overtone/live.clj
@@ -1,64 +1,64 @@
 (ns overtone.live
   (:use [overtone.libs.boot-msg]
-        [overtone.helpers lib ns])
+        [overtone.helpers.ns])
   (:require clojure.stacktrace
             [overtone.config store]
-            [overtone midi osc speech version]
+            [overtone version midi osc speech]
             [overtone.algo chance scaling trig]
             [overtone.sc bindings buffer bus envelope example info
                          ugens defcgen mixer node sample server synth trigger]
-
             [overtone.sc.cgens oscillators demand mix io buf-io env tap]
             [overtone.music rhythm pitch tuning time]
-            [overtone.studio inst mixer midi util fx wavetable]
+            [overtone.studio mixer inst util fx wavetable]
             [overtone.repl ugens examples shell inst debug]
-            [overtone.libs asset event freesound]))
+            [overtone.libs asset event freesound]
+            [overtone.gui scope mixer control]))

-(immigrate 'overtone.osc
-           'overtone.midi
-           'overtone.algo.chance
-           'overtone.algo.scaling
-           'overtone.algo.trig
-           'overtone.config.store
-           'overtone.sc.bindings
-           'overtone.sc.buffer
-           'overtone.sc.bus
-           'overtone.sc.envelope
-           'overtone.sc.example
-           'overtone.sc.info
-           'overtone.sc.mixer
-           'overtone.sc.node
-           'overtone.sc.sample
-           'overtone.sc.server
-           'overtone.sc.synth
-           'overtone.sc.trigger
-           'overtone.sc.ugens
-           'overtone.sc.defcgen
-           'overtone.sc.cgens.oscillators
-           'overtone.sc.cgens.demand
-           'overtone.sc.cgens.mix
-           'overtone.sc.cgens.io
-           'overtone.sc.cgens.buf-io
-           'overtone.sc.cgens.env
-           'overtone.sc.cgens.tap
-           'overtone.music.rhythm
-           'overtone.music.pitch
-           'overtone.music.tuning
-           'overtone.music.time
-           'overtone.studio.mixer
-           'overtone.studio.inst
-           'overtone.studio.fx
-           'overtone.studio.wavetable
-           'overtone.studio.midi
-           'overtone.speech
-           'overtone.repl.ugens
-           'overtone.repl.examples
-           'overtone.repl.shell
-           'overtone.repl.inst
-           'overtone.repl.debug
-           'overtone.libs.asset
-           'overtone.libs.event
-           'overtone.libs.freesound
-           'overtone.version)
+(immigrate
+  'overtone.osc
+  'overtone.midi
+  'overtone.algo.chance
+  'overtone.algo.scaling
+  'overtone.algo.trig
+  'overtone.config.store
+  'overtone.sc.bindings
+  'overtone.sc.buffer
+  'overtone.sc.bus
+  'overtone.sc.envelope
+  'overtone.sc.example
+  'overtone.sc.info
+  'overtone.sc.mixer
+  'overtone.sc.node
+  'overtone.sc.sample
+  'overtone.sc.server
+  'overtone.sc.synth
+  'overtone.sc.trigger
+  'overtone.sc.ugens
+  'overtone.sc.defcgen
+  'overtone.sc.cgens.oscillators
+  'overtone.sc.cgens.demand
+  'overtone.sc.cgens.mix
+  'overtone.sc.cgens.io
+  'overtone.sc.cgens.buf-io
+  'overtone.sc.cgens.env
+  'overtone.sc.cgens.tap
+  'overtone.music.rhythm
+  'overtone.music.pitch
+  'overtone.music.tuning
+  'overtone.music.time
+  'overtone.studio.mixer
+  'overtone.studio.inst
+  'overtone.studio.fx
+  'overtone.studio.wavetable
+  'overtone.speech
+  'overtone.repl.ugens
+  'overtone.repl.examples
+  'overtone.repl.shell
+  'overtone.repl.inst
+  'overtone.repl.debug
+  'overtone.libs.asset
+  'overtone.libs.event
+  'overtone.libs.freesound
+  'overtone.version)

 (defonce _auto-boot_ (boot-server-and-mixer))


stylistic change

stylistic change

--- src/pe_datomic_utils/core.clj
+++ src/pe_datomic_utils/core.clj
@@ -175,20 +175,6 @@
                        results))
           (distinct)))))))

-(defn is-entity-updated-since
-  [conn since-inst entid]
-  (let [db (d/db conn)
-        since-entity (into {} (d/entity (d/since db since-inst) entid))]
-    (and (not (empty? since-entity))
-         (not= (into {} (d/entity (d/as-of db since-inst) entid))
-               since-entity))))
-
-(defn is-entity-deleted-since
-  [conn since-inst entid]
-  (let [db (d/db conn)]
-    (and (not (empty? (into {} (d/entity (d/as-of db since-inst) entid))))
-         (empty? (into {} (d/entity (d/since db since-inst) entid))))))
-
 (defn are-attributes-retracted-since
   "Returns true if the entity with ID entid has attributes attrs all retracted
   as of since-inst.  Otherwise returns false."
@@ -209,6 +195,20 @@
                      (when last-datom
                        (not (.added last-datom)))))
                  attr-entids))))
+
+(defn is-entity-updated-since
+  [conn since-inst entid]
+  (let [db (d/db conn)
+        since-entity (into {} (d/entity (d/since db since-inst) entid))]
+    (and (not (empty? since-entity))
+         (not= (into {} (d/entity (d/as-of db since-inst) entid))
+               since-entity))))
+
+(defn is-entity-deleted-since
+  [conn since-inst entid]
+  (let [db (d/db conn)]
+    (and (not (empty? (into {} (d/entity (d/as-of db since-inst) entid))))
+         (empty? (into {} (d/entity (d/since db since-inst) entid))))))

 (defn change-log-since
   "Returns a map with 2 keys: :updates and :deletions.  The value at each key is


Actually build the modal

Actually build the modal

How did that even happen?

--- src/om_bootstrap/modal.cljs
+++ src/om_bootstrap/modal.cljs
@@ -54,4 +54,5 @@
               (:footer bs))))))))

 (sm/defn modal
-  [opts :- Modal & children])
+  [opts :- Modal & children]
+  (->modal* {:opts opts :children children}))


Never compare to max-tx when it is nil. Filter any txes higher than max

--- src/onyx/plugin/datomic.clj
+++ src/onyx/plugin/datomic.clj
@@ -216,19 +216,23 @@
                         (loop [tx-index start-tx]
                           ;; tx-range called up to maximum tx in each iteration
                           ;; relies on the fact that tx-range is lazy, therefore only read-size elements will be realised
+                          ;; use a nil end-tx, and rely on removing higher tx values
                           (if-let [entries (seq
                                              (take read-size
                                                    (seq
-                                                     (d/tx-range (d/log conn) tx-index max-tx))))]
+                                                     (d/tx-range (d/log conn) tx-index nil))))]
                             (do
-                              (doseq [entry entries]
+                              (doseq [entry (filter #(or (nil? max-tx)
+                                                         (< (:t %) max-tx))
+                                                    entries)]
                                 (>!! ch
                                      (t/input (java.util.UUID/randomUUID)
                                               (update (into {} entry)
                                                       :data (partial map unroll-log-datom)))))
                               (let [last-t (:t (last entries))
                                     next-t (inc last-t)]
-                                (if (< last-t max-tx)
+                                (if (or (nil? max-tx)
+                                        (< last-t max-tx))
                                   (recur next-t))))
                             ;; timeout could be used to backoff here
                             ;; when no entries are read


Fix typo

Fix typo

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -234,7 +234,7 @@
         entities))

     ; 2D physics contact (for play-clj.g2d-physics)
-    ; Tip: use first-entity and second-entity to get the get the entities that are contacting
+    ; Tip: use first-entity and second-entity to get the entities that are contacting
     (defscreen my-screen
       :on-begin-contact ; two bodies began to touch
       (fn [screen entities]
@@ -246,7 +246,7 @@
         entities))

     ; 3D physics contact (for play-clj.g3d-physics)
-    ; Tip: use first-entity and second-entity to get the get the entities that are contacting
+    ; Tip: use first-entity and second-entity to get the entities that are contacting
     (defscreen my-screen
       :on-begin-contact ; two bodies began to touch
       (fn [screen entities]


util/log.clj: modified to use lexical namespace

--- src/org/altlaw/util/log.clj
+++ src/org/altlaw/util/log.clj
@@ -5,40 +5,35 @@

 (JavaLoggingToCommonLoggingRedirector/activate)

-;; Returns the logger named after the given namespace.  Caches
-;; loggers.
-(def get-ns-log
-     (memoize (fn [ns] (LogFactory/getLog (str (ns-name ns))))))
-
 (defmacro trace [label arg]
   `(let [value# ~arg
-         log# (get-ns-log *ns*)]
+         log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isTraceEnabled)
        (. log# (trace (str ~label ":" (pr-str value#)))))
      value#))

 (defmacro debug [& args]
-  `(let [log# (get-ns-log *ns*)]
+  `(let [log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isDebugEnabled)
        (. log# (debug (str ~@args))))))

 (defmacro info [& args]
-  `(let [log# (get-ns-log *ns*)]
+  `(let [log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isInfoEnabled)
        (. log# (info (str ~@args))))))

 (defmacro warn [& args]
-  `(let [log# (get-ns-log *ns*)]
+  `(let [log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isWarnEnabled)
        (. log# (warn (str ~@args))))))

 (defmacro error [& args]
-  `(let [log# (get-ns-log *ns*)]
+  `(let [log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isErrorEnabled)
        (. log# (error (str ~@args))))))

 (defmacro fatal [& args]
-  `(let [log# (get-ns-log *ns*)]
+  `(let [log# (. LogFactory getLog ~(str (ns-name *ns*)))]
      (when (. log# isFatalEnabled)
        (. log# (fatal (str ~@args))))))


util/tsv.clj: fix read-tsv-stream bug

util/tsv.clj: fix read-tsv-stream bug

--- src/org/altlaw/util/tsv.clj
+++ src/org/altlaw/util/tsv.clj
@@ -2,7 +2,7 @@

 (ns org.altlaw.util.tsv
   (:import (java.io BufferedReader InputStreamReader
-                    FileInputStream)
+                    FileInputStream InputStream)
            (java.util.zip GZIPInputStream)))

 (defn read-tsv-stream
@@ -15,7 +15,7 @@
     (reduce (fn [map #^String line]
               (let [[#^String key value] (.split line "\t")]
                 (assoc map key value)))
-            {} (line-seq stream))))
+            {} (line-seq reader))))

 (defn write-tsv-stream
   "Writes a gzip-compressed binary stream of a tab-separated-value


(every? identity (map f xs)) is equivalent to (every? f xs)

--- src/overcode/introvert.cljs
+++ src/overcode/introvert.cljs
@@ -133,9 +133,8 @@
            (deep-arr= (.keys js/Object val1)
                       (.keys js/Object val2)
                       visited))
-    (every? identity
-            (map #(deep= (aget val1 %) (aget val2 %) visited)
-                 (.keys js/Object val1)))
+    (every? #(deep= (aget val1 %) (aget val2 %) visited)
+            (.keys js/Object val1))
     false)))

 (defn deep=


don't allow cs80lead to free on fenv's fdecay val

--- src/overtone/inst/synth.clj
+++ src/overtone/inst/synth.clj
@@ -46,7 +46,7 @@
   (let [freq (lag freq freq-lag)
         cuttoff (in:kr cbus)
         env     (env-gen (adsr att decay sus rel) gate :action FREE)
-        fenv    (env-gen (adsr fatt fdecay fsus frel 2) gate :action FREE)
+        fenv    (env-gen (adsr fatt fdecay fsus frel 2) gate)

         vib     (+ 1 (lin-lin:kr (sin-osc:kr vibrate) -1 1 (- vibdepth) vibdepth))


Remove extraneous println.

Remove extraneous println.

--- spec/custer/core_spec.clj
+++ spec/custer/core_spec.clj
@@ -83,7 +83,6 @@
       (should= true @writer-written-to)))

   (it "should get a response from the server"
-    (println "target test")
     (let [server (atom @server)]
       (future (accept-connection @server accept-fn))
       (should= @expected-get-response


Add some documentation to functions in the core namespace.

--- src/pubhouse/core.clj
+++ src/pubhouse/core.clj
@@ -12,22 +12,26 @@
 (def ^:dynamic *meta-sep*  "===")

 (defn relative-path
+  "Takes a path as the sole argument and returns path with any parts
+  matching the current *cwd* removed. Requires path to be a child of
+  *cwd*."
   [path]
   (->> (fs/split path)
        (drop (count (fs/split fs/*cwd*)))
        (clojure.string/join "/")))

-(defn with-parent-dir
-  "Ensure that the parent directory struture of the path
-  exists before invoking the function f. Most likely, f
-  will write to the file at path."
+(defn ensure-parent-dir
+  "Invoke the function f, ensuring that the parent directory of the file at path
+  exists. Presumabely, f has side-effects involving writing to the file at path."
   [path f]
   (let [parent (fs/parent path)]
     (if (fs/exists? parent)
       (f)
       (do (fs/mkdirs parent) (f)))))

-(def content-file? (complement fs/directory?))
+(def content-file?
+  "Any files for which this predicate returns true will be compiled."
+  (complement fs/directory?))

 (defn get-file-info
   [file]
@@ -35,10 +39,12 @@
    :mod-time (fs/mod-time file)})

 (defn get-page-info
+  "Reads the lines preceding the *meta-sep* line as a persistent map."
   [lines]
   (->> lines (take-while #(not= % *meta-sep*)) (join "\n") (read-string)))

 (defn content-section
+  "Returns a lazy sequence of lines following the *meta-sep* line."
   [lines]
   (->> lines (drop-while #(not= % *meta-sep*)) (drop 1)))

@@ -77,8 +83,11 @@
   (reduce #(assoc-in %1 (fs/split (:url %2)) %2) {} pages))

 (defn with-file-ends
+  "Creates a reader and writer using the input and output files, and invokes the
+  f with the arguments (reader writer). Ensures that the parent directory of the output
+  file exists."
   [input output f]
-  (with-parent-dir output
+  (ensure-parent-dir output
     (fn []
       (with-open [reader (clojure.java.io/reader input)
                   writer (clojure.java.io/writer output)]


make this-many param optional

make this-many param optional

--- src/babel/francais/qa.clj
+++ src/babel/francais/qa.clj
@@ -21,7 +21,7 @@
 (def total-errors (atom 0))
 (def total (atom 0))

-(defn read-expressions [this-many]
+(defn read-expressions [& [this-many]]
   (let [this-many (if this-many (Integer. this-many))
         results (db/exec-raw [(str "SELECT target.serialized::text AS target,target.surface
                                       FROM expression AS target
@@ -48,13 +48,13 @@
                                             :subj (get-in structure [:synsem :sem :subj])
                                             :pred (get-in structure [:synsem :sem :pred])}}
                              :root {:français {:français (get-in structure [:root :français :français])}}}]
-                        (log/error (str "we think it should be: (" spec "): '"
+                        (if false (log/error (str "we think it should be:'"
                                         (fo (generate spec
                                                       )
                                             )
                                         "'."
                                         )
-                                   ))
+                                   )))
                       (swap! total-errors (fn [current] (+ 1 current)))
                       (log/error (str "errors so far: " @total-errors " out of "
                                       @total "; error rate=" (string/replace (str (/ @total-errors (+ 0.0 @total)) "00")


Add support to search for missing gen-classes from other namespaces

--- build-support/clojure-compile.clj
+++ build-support/clojure-compile.clj
@@ -10,6 +10,7 @@
 ; this software.

 (use 'clojure.java.io)
+(use 'clojure.stacktrace)
 (import '[java.io File PushbackReader]
         '[java.util.regex Matcher Pattern])

@@ -38,12 +39,34 @@
           :else
             (recur (next-form)))))))

+(def compiled-ns (atom #{}))
+
 (defn compile-ns
   "Compiles a namespace."
-  [ns]
-  (println (format "Compiling %s…" ns))
-  (compile ns))
-
+  ([ns failed-ns]
+   (when-not (@compiled-ns ns)
+     (try
+       (println (format "Compiling %s…" ns))
+       (compile ns)
+       (swap! compiled-ns conj ns)
+       true
+       (catch clojure.lang.Compiler$CompilerException e
+         (let [msg (.getMessage e)
+               cnfe-pattern #"^java\.lang\.ClassNotFoundException: ([a-zA-z0-9-_.]+) \(.*:\d+\)$"]
+           (let [matches (re-matches cnfe-pattern msg)]
+             (if matches
+               (let [not-found-ns (symbol (matches 1))]
+                 (println (format "Dependency failure detected, will try to compile %s." not-found-ns))
+                 (if (failed-ns not-found-ns)
+                   (throw e)
+                   (if (compile-ns not-found-ns (conj failed-ns ns))
+                     (do
+                       (println "Failure resolved.")
+                       (compile-ns ns failed-ns))
+                     (throw e))))
+               (throw e))))))))
+  ([ns]
+   (compile-ns ns #{})))

 (defn compile-dir
   "Compiles all Clojure files in the given directory."


Store status message

Store status message

--- frontend/src/cruncher/utils/lib.cljs
+++ frontend/src/cruncher/utils/lib.cljs
@@ -5,7 +5,6 @@

 (defonce app-state
          (atom
-<<<<<<< 010157a5406735dcd98fd6520b39944f79e7b6c1
            {:pokemon           []
             :user              {:view       :default
                                 :logged-in? false}
@@ -17,18 +16,6 @@
                                 :deleted   0
                                 :status    "ok"}
             :progress-running? false}))
-=======
-           {:pokemon []
-            :user    {:view       :default
-                      :logged-in? false}
-            :error   {:message nil}
-            :info    {:message nil}
-            :app     {:loading? false
-                      :progress {}}}))
-<<<<<<< 2eacc09b925a97a5b015af1af1c5c0f3934e5388
->>>>>>> Add reconciler function to store progress status
-=======
->>>>>>> Add reconciler function to store progress status

 (declare get-pokemon-by-id)

@@ -90,8 +77,6 @@

 (defmethod mutate 'status/progress
   [{:keys [state]} _ {:keys [status]}]
-<<<<<<< 2eacc09b925a97a5b015af1af1c5c0f3934e5388
-<<<<<<< 010157a5406735dcd98fd6520b39944f79e7b6c1
   {:action (fn [] (swap! state update-in [:progress]
                          (fn [] {:status    (:status status)
                                  :to_delete (:to_delete status)
@@ -101,17 +86,6 @@
   [{:keys [state]} _ {:keys [status]}]
   {:action (fn [] (swap! state update-in [:progress-running?] (fn [] status)))})

-=======
-=======
->>>>>>> Add reconciler function to store progress status
-  {:action (fn [] (swap! state update-in [:app :progress]
-                         (fn [] {:to-delete (:to_delete status)
-                                 :deleted   (:deleted status)})))})
-
-<<<<<<< 2eacc09b925a97a5b015af1af1c5c0f3934e5388
->>>>>>> Add reconciler function to store progress status
-=======
->>>>>>> Add reconciler function to store progress status
 (defonce reconciler
          (om/reconciler
            {:state  app-state


CMR-203: Added missing score sort key.

CMR-203: Added missing score sort key.

--- src/cmr/search/services/parameters/parameter_validation.clj
+++ src/cmr/search/services/parameters/parameter_validation.clj
@@ -80,7 +80,8 @@
                  :provider
                  :platform
                  :instrument
-                 :sensor}
+                 :sensor
+                 :score}
    :granule #{:granule-ur
               :producer-granule-id
               :readable-granule-name


Sort by priority

Sort by priority

--- org-mode/src/com/gfredericks/org_agenda.clj
+++ org-mode/src/com/gfredericks/org_agenda.clj
@@ -154,6 +154,15 @@
                                                              (count all-dates)
                                                              %)))))))
           [base])))))
+
+(defn priority
+  "Returns a long, where a higher number corresponds to higher priority."
+  [item]
+  (case (:priority-cookie item)
+    nil 5
+    "[#A]" 10
+    "[#B]" 4
+    "[#C]" 1))

 (defn to-local-date
   [x]
@@ -413,12 +422,12 @@
       (when (seq deadlines)
         (println "== DEADLINES ==")
         (println "(TODO: show upcoming deadlines based on the -0d cookie)")
-        (doseq [item (sort-by (juxt :created-at :file :line-number) deadlines)]
+        (doseq [item (sort-by (juxt (comp - priority) :created-at :file :line-number) deadlines)]
           (print-todo-line item {}))
         (println))
       (when (seq triage)
         (println "== TRIAGE ==")
-        (doseq [item (sort-by (juxt :created-at :file :line) triage)]
+        (doseq [item (sort-by (juxt (comp - priority) :created-at :file :line) triage)]
           (print-todo-line item {}))
         (println))
       (let [stats-by-date
@@ -457,7 +466,7 @@
           ;; TODO: we shouldn't be putting things in the calendar if they're
           ;; scheduled in the past...
           (->> todos
-               (sort-by (juxt relevant-date :file :line))
+               (sort-by (juxt (comp - priority) relevant-date :file :line))
                (run! (fn [item] (print-todo-line item {}))))
           (when (= date today)
             (println "\n\n--------------------------------------------------------------------------------")


Added queue arn as a resource to access policy

--- message-queue-lib/src/cmr/message_queue/queue/sqs.clj
+++ message-queue-lib/src/cmr/message_queue/queue/sqs.clj
@@ -21,7 +21,7 @@
    [cmr.message-queue.services.queue :as queue])
   (:import
    (com.amazonaws ClientConfiguration)
-   (com.amazonaws.auth.policy Condition Policy Principal Statement Statement$Effect)
+   (com.amazonaws.auth.policy Condition Policy Principal Resource Statement Statement$Effect)
    (com.amazonaws.auth.policy.actions SQSActions)
    (com.amazonaws.auth.policy.conditions ConditionFactory)
    (com.amazonaws.services.sns AmazonSNSClient)
@@ -161,9 +161,12 @@
   "Returns an access policy allowing the given SNS topic to publish to the given SQS queue."
   [sns-client sqs-client queue-name exchange-names]
   (let [conditions (topic-conditions sns-client exchange-names)
+        queue-arn (get-queue-arn sqs-client queue-name)
+        resource (Resource. queue-arn)
         statement (doto (Statement. Statement$Effect/Allow)
                         (.withPrincipals (into-array Principal [Principal/AllUsers]))
                         (.withActions (into-array SQSActions [SQSActions/SendMessage]))
+                        (.withResources (into-array Resource [resource]))
                         (.withConditions (into-array Condition conditions)))
         policy (.withStatements (Policy.) (into-array Statement [statement]))]
     (.toJson policy)))
@@ -175,10 +178,10 @@
        q-arn (get-queue-arn sqs-client q-name)
        q-url (.getQueueUrl (.getQueueUrl sqs-client q-name))
        ;; create an access policy to allow the topic to publish to the queue
-       access-policy (sns-to-sqs-access-policy sns-client sqs-client queue-name exchange-names)
+       access-policy (sns-to-sqs-access-policy sns-client sqs-client q-name exchange-names)
        q-attrs (HashMap. {"Policy" access-policy})

-       ;; create and empty SetQueueAttributesRequest object and then set the attributes on it
+       ;; create an empty SetQueueAttributesRequest object and then set the attributes on it
        set-queue-attrs-request (doto (SetQueueAttributesRequest.)
                                      (.setAttributes q-attrs)
                                      (.setQueueUrl q-url))]
@@ -323,23 +326,24 @@

 ;; Tests to make sure SNS/SQS is working
 (comment
+  ; (.subscribe (:sns-client broker) "arn:aws:sns:us-east-1:688991608580:gsfc-eosdis-cmr-ingest_exchange" "sqs" "arn:aws:sqs:us-east-1:688991608580:gsfc-eosdis-cmr-ngap-cmr-test_queue")
   ;; create a broker
   (def broker (lifecycle/start (create-queue-broker {}) nil))
   ;; list the topics for the cmr-ingest_exchange exchange/topic
   (get-topic (:sns-client broker) "cmr_ingest_exchange")
   ;; list the queues for the cmr_ingest_exchange
-  (queue/get-queues-bound-to-exchange broker "cmr_ingest_exchange")
+  (queue/get-queues-bound-to-exchange broker "ngap-cmr_testB_exchange")
   ;; create a test queue
-  (create-queue (:sqs-client broker) "cmr-test.queue")
+  (create-queue (:sqs-client broker) "test-ABG")
   ;; create a test exchange
-  (create-exchange (:sns-client broker) "cmr_test_exchange")
+  (create-exchange (:sns-client broker) "ngap-cmr_testB_exchange")
   ;; list the queues for the cmr_test_exchange
   (queue/get-queues-bound-to-exchange broker "cmr_test_exchange")
   ;; Bind the queue to the new exchange
-  (bind-queue-to-exchanges (:sns-client broker) (:sqs-client broker) ["cmr_test_exchange"] "cmr-test.queue")
+  (bind-queue-to-exchanges (:sns-client broker) (:sqs-client broker) ["ngap-cmr_testB_exchange"] "test-ABG")
   ;; subscribe to test queue with a simple handler that prints received messages
   (queue/subscribe broker "cmr-test.queue" (fn [msg] (println "Got Message: " msg)))
   ;; publish a message to the queue to verify our subscribe worked
   (queue/publish-to-queue broker "cmr-test.queue" "{\"body\": \"ABC\"}")
   ;; publish a message to the exchange to verify the message is sent to the queue
-  (queue/publish-to-exchange broker "cmr_test_exchange" "{\"body\": \"ABC-exchange\"}"))
+  (queue/publish-to-exchange broker "ngap-cmr_testB_exchange" "{\"body\": \"ABC-exchange\"}"))


Allow http-only cookies.

Allow http-only cookies.

--- ring-core/src/ring/middleware/cookies.clj
+++ ring-core/src/ring/middleware/cookies.clj
@@ -34,7 +34,7 @@
   set-cookie-attrs
   {:comment "Comment", :comment-url "CommentURL", :discard "Discard",
    :domain "Domain", :max-age "Max-Age", :path "Path", :port "Port",
-   :secure "Secure", :version "Version", :expires "Expires"})
+   :secure "Secure", :version "Version", :expires "Expires", :http-only "HttpOnly"})

 (defn- parse-cookie-header
   "Turn a HTTP Cookie header into a list of name/value pairs."


rearanged conditional reader to fix compile errors

--- src/twigs/core.cljc
+++ src/twigs/core.cljc
@@ -1,6 +1,7 @@
 (ns twigs.core
-  (#?(:cljs
-       (:require [cljsjs.firebase]))))
+  (:refer-clojure :exclude [ref])
+  #?(:cljs
+      (:require [cljsjs.firebase])))

 #?(:cljs
     (deftype TwigRef [fb-ref]
@@ -25,5 +26,5 @@
           false))))

 (defn ref [url]
-  (TwigRef. #?(:cljs (js/Firebase. url))))
+  #?(:cljs (TwigRef. (js/Firebase. url))))


Initial work on high-level crypto primitives.

--- src/buddy/core/crypto.clj
+++ src/buddy/core/crypto.clj
@@ -164,51 +164,48 @@
 ;; High level api.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-;; (defn split-by-blocksize
-;;   "Split a byte array in blocksize blocks.
-
-;;   Given a arbitrary size bytearray and block size in bytes,
-;;   returns a lazy sequence of bytearray blocks of blocksize
-;;   size. If last block does not have enought data for fill
-;;   all block, it is padded using zerobyte padding."
-;;   [^bytes input ^long blocksize]
-;;   (let [inputsize (count input)
-;;         seqgen (fn seqgen [& {:keys [cursormin cursormax remain]}]
-;;                  (cond
-;;                    (<= remain blocksize)
-;;                    (let [buffer (byte-array blocksize)]
-;;                      (System/arraycopy input cursormin buffer 0 remain)
-;;                      (list buffer))
-
-;;                    (> remain blocksize)
-;;                    (let [buffer (byte-array blocksize)]
-;;                      (System/arraycopy input cursormin buffer 0 blocksize)
-;;                      (cons buffer (lazy-seq (seqgen :cursormin cursormax
-;;                                                     :cursormax (+ cursormax blocksize)
-;;                                                     :remain (- inputsize cursormax)))))
-;;                    :else nil))]
-;;     (lazy-seq (seqgen :cursormin 0
-;;                       :cursormax blocksize
-;;                       :remain inputsize))))
-
-;; (defn encrypt
-;;   "Encrypt message, and return a result as byte array."
-;;   [input & {:keys [alg mode iv nonce key] :or {alg :aes mode :ctr}}]
-;;   {:pre [(or (bytes/bytes? iv)
-;;              (bytes/bytes? nonce))
-;;          (bytes/bytes? key)]}
-;;   (let [^bytes iv (or iv nonce)
-;;         ^bytes input (codecs/->byte-array input)]
-;;     (cond
-;;       (algorithm-supported? :block alg)
-;;       (let [cipher (block-cipher alg mode)
-;;             blocksize (get-block-size cipher)]
-;;         (initialize! cipher {:op :encrypt :iv iv :key key})
-;;         (apply bytes/concat (reduce (fn [acc block]
-;;                                       (conj acc (process-block! cipher block)))
-;;                                     [] (split-by-blocksize input blocksize))))
-
-;;       (algorithm-supported? :stream alg)
-;;       (let [cipher (stream-cipher alg)]
-;;         (initialize! cipher {:op :encrypt :iv iv :key key})
-;;         (process-block! cipher input)))))
+(defn split-by-blocksize
+  "Split a byte array in blocksize blocks.
+
+  Given a arbitrary size bytearray and block size in bytes,
+  returns a lazy sequence of bytearray blocks of blocksize
+  size. If last block does not have enought data for fill
+  all block, it is padded using zerobyte padding."
+  [^bytes input ^long blocksize]
+  (let [inputsize (count input)
+        seqgen (fn seqgen [& {:keys [cursormin cursormax remain]}]
+                 (cond
+                   (<= remain blocksize)
+                   (let [buffer (byte-array blocksize)]
+                     (System/arraycopy input cursormin buffer 0 remain)
+                     (list buffer))
+
+                   (> remain blocksize)
+                   (let [buffer (byte-array blocksize)]
+                     (System/arraycopy input cursormin buffer 0 blocksize)
+                     (cons buffer (lazy-seq (seqgen :cursormin cursormax
+                                                    :cursormax (+ cursormax blocksize)
+                                                    :remain (- inputsize cursormax)))))
+                   :else nil))]
+    (lazy-seq (seqgen :cursormin 0
+                      :cursormax blocksize
+                      :remain inputsize))))
+
+(defn encrypt
+  "Encrypt message, and return a result as byte array."
+  [input & {:keys [alg mode iv key] :or {alg :aes mode :ctr}}]
+  {:pre [(bytes/bytes? iv) (bytes/bytes? key)]}
+  (let [^bytes input (codecs/->byte-array input)]
+    (cond
+      (algorithm-supported? :block alg)
+      (let [cipher (block-cipher alg mode)
+            blocksize (get-block-size cipher)]
+        (initialize! cipher {:op :encrypt :iv iv :key key})
+        (apply bytes/concat (reduce (fn [acc block]
+                                      (conj acc (process-block! cipher block)))
+                                    [] (split-by-blocksize input blocksize))))
+
+      (algorithm-supported? :stream alg)
+      (let [cipher (stream-cipher alg)]
+        (initialize! cipher {:op :encrypt :iv iv :key key})
+        (process-block! cipher input)))))


use helper function for reporting invalid arguments

--- src/calfpath/internal.clj
+++ src/calfpath/internal.clj
@@ -1,5 +1,14 @@
 (ns calfpath.internal
   (:require [clojure.string :as str]))
+
+
+(defn expected
+  ([expectation found]
+    (throw (IllegalArgumentException.
+             (format "Expected %s, but found (%s) %s" expectation (class found) (pr-str found)))))
+  ([pred expectation found]
+    (when-not (pred found)
+      (expected expectation found))))

 (defn parse-uri-template
@@ -35,9 +44,8 @@
     (and (vector? uri-pattern-or-template)
       (every? (some-fn string? keyword?)
         uri-pattern-or-template))          uri-pattern-or-template
-    :otherwise (throw (IllegalArgumentException.
-                        (str "Expected a string URI pattern or a parsed URI template, but found ("
-                          (class uri-pattern-or-template) ") " (pr-str uri-pattern-or-template))))))
+    :otherwise                             (expected "a string URI pattern or a parsed URI template"
+                                             uri-pattern-or-template)))

 (def valid-method-keys #{:get :head :options :put :post :delete})
@@ -46,9 +54,7 @@
 (defmacro method-dispatch
   ([method-keyword request expr]
     (when-not (valid-method-keys method-keyword)
-      (throw (IllegalArgumentException.
-               (str "Expected a method key (" valid-method-keys "), but found (" (class method-keyword) ") "
-                 (pr-str method-keyword)))))
+      (expected (str "a method key (" valid-method-keys ")") method-keyword))
     (let [method-string (->> (name method-keyword)
                           str/upper-case)
           default-expr {:status 405
@@ -60,9 +66,7 @@
          ~default-expr)))
   ([method-keyword request expr default-expr]
     (when-not (valid-method-keys method-keyword)
-      (throw (IllegalArgumentException.
-               (str "Expected a method key (" valid-method-keys "), but found (" (class method-keyword) ") "
-                 (pr-str method-keyword)))))
+      (expected (str "a method key (" valid-method-keys ")") method-keyword))
     `(if (identical? ~method-keyword (:request-method ~request))
        ~expr
        ~default-expr)))


cleaned up function a bit

cleaned up function a bit

--- src/server/rooms.cljs
+++ src/server/rooms.cljs
@@ -301,9 +301,7 @@
     (fn [num-users]
       (.lpush redis-client (redis-room-prefix room-id sync-command) user-id
         (fn [err length]
-          (if (= length num-users)
-            (callback true)
-            (callback false)))))))
+          (callback (= length num-users)))))))

 (defn delete-client-sync [room-id sync-command callback]
   (.del redis-client (redis-room-prefix room-id sync-command)


Schematized data.cljs

Schematized data.cljs

--- src/chessground/data.cljs
+++ src/chessground/data.cljs
@@ -1,9 +1,12 @@
 (ns chessground.data
   "Representation and manipulation of the application data"
   (:require [chessground.common :as common :refer [pp]]
-            [chessground.chess :as chess]))
+            [chessground.chess :as chess]
+            [chessground.schemas :refer [ChessState]]
+            [schema.core :as s :refer [Str Bool]])
+  (:require-macros [schema.macros :as sm :refer [defschema]]))

-(def defaults
+(sm/def defaults :- ChessState
   "Default state, overridable by user configuration"
   {:fen nil ; replaced by :chess by data/make
    :chess {} ; representation of a chess game
@@ -21,9 +24,14 @@
    :spare-pieces false ; provide extra pieces to put on the board)
    })

-(defn with-fen [state fen] (assoc state :chess (chess/make fen)))

-(defn make [js-config]
+(sm/defn with-fen :- ChessState
+  [state :- ChessState
+   fen :- Str]
+  (assoc state :chess (chess/make fen)))
+
+(sm/defn make :- ChessState
+  [js-config :- js/Object]
   (let [config (-> js-config
                    common/keywordize-keys
                    (common/keywordize-keys-in [:movable])
@@ -32,26 +40,34 @@
         (with-fen (:fen config))
         (dissoc :fen))))

-(defn clear [state]
+(sm/defn clear :- ChessState
+  [state :- ChessState]
   (-> state
       (assoc :chess chess/clear)
       (assoc-in [:movable :dests] nil)))

-(defn is-movable? [state key]
+(sm/defn is-movable? :- Bool
   "Piece on this square may be moved somewhere, if the validation allows it"
+  [state :- ChessState
+   key :- Str]
   (let [owner (chess/owner-color (:chess state) key)
         movable (:movable state)
         color (:color movable)]
     (and owner (or (= color "both") (= color owner)))))

-(defn can-move? [state orig dest]
+(sm/defn can-move? :- Bool
   "The piece on orig can definitely be moved to dest"
+  [state :- ChessState
+   orig :- Str
+   dest :- Str]
   (and (is-movable? state orig)
        (or (-> state :movable :free)
            (common/set-contains? (get-in state [:movable :dests orig]) dest))))

-(defn dests-of [state orig]
+(sm/defn dests-of :- (s/maybe [Square])
   "List of destinations square keys for this origin"
+  [state :- ChessState
+   orig :- Str]
   (when (is-movable? state orig)
     (if (-> state :movable :free)
       (for [rank (range 1 9)


Added emission of max-fixed-arity

Added emission of max-fixed-arity

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -189,23 +189,36 @@
     (print (str " = " (emits init)))
     (when-not (= :expr (:context env)) (print ";\n"))))

+(defn ^:dynamic emit-fn-prefix [name max-fixed-arity]
+  (println
+   (str "(function (f) {\n"
+        "  f.maxFixedArity = " max-fixed-arity ";\n"
+        "  return f;\n"
+        "})(")))
+
+(defn ^:dynamic emit-fn-postfix [name max-fixed-arity]
+  (println ")"))
+
 (defn emit-fn-method
   [{:keys [gthis name variadic params statements ret env recurs]}]
-  (emit-wrap env
-             (print (str "(function " name "(" (comma-sep params) "){\n"))
-             (when gthis
-               (println (str "var " gthis " = this;")))
-             (when variadic
-               (println (str (last params) " = Array.prototype.slice.call(arguments, " (dec (count params)) ");")))
-             (when recurs (print "while(true){\n"))
-             (emit-block :return statements ret)
-             (when recurs (print "break;\n}\n"))
-             (print "})")))
+  (binding [emit-fn-prefix  (constantly nil)
+            emit-fn-postfix (constantly nil)]
+    (emit-wrap env
+               (print (str "(function " name "(" (comma-sep params) "){\n"))
+               (when gthis
+                 (println (str "var " gthis " = this;")))
+               (when variadic
+                 (println (str (last params) " = Array.prototype.slice.call(arguments, " (dec (count params)) ");")))
+               (when recurs (print "while(true){\n"))
+               (emit-block :return statements ret)
+               (when recurs (print "break;\n}\n"))
+               (print "})"))))

 (defmethod emit :fn
-  [{:keys [name env methods]}]
+  [{:keys [name env methods max-fixed-arity]}]
   ;;fn statements get erased, serve no purpose and can pollute scope if named
   (when-not (= :statement (:context env))
+    (emit-fn-prefix name max-fixed-arity)
     (if (= 1 (count methods))
       (emit-fn-method (assoc (first methods) :name name))
       (let [name (or name (gensym))
@@ -228,9 +241,10 @@
                                                          (str "," (comma-sep (take pcnt maxparams)))) ");")))))
         (println "}")
         (println "throw('Invalid arity: ' + arguments.length);")
-        (println "}")
+        (println "};")
         (println (str "return " name ";"))
-        (println "})()")))))
+        (println "})()")))
+    (emit-fn-postfix name max-fixed-arity)))

 (defmethod emit :do
   [{:keys [statements ret env]}]
@@ -434,6 +448,7 @@
         fields (-> params meta ::fields)
         variadic (some '#{&} params)
         params (remove '#{&} params)
+        fixed-arity (count (if variadic (butlast params) params))
         body (next meth)
         gthis (and fields (gensym "this__"))
         locals (reduce (fn [m fld] (assoc m fld {:name (symbol (str gthis "." (munge fld)))})) locals fields)
@@ -441,7 +456,7 @@
         recur-frame {:names (vec (map munge params)) :flag (atom nil)}
         block (binding [*recur-frame* recur-frame]
                 (analyze-block (assoc env :context :return :locals locals) body))]
-    (merge {:env env :variadic variadic :params (map munge params) :gthis gthis :recurs @(:flag recur-frame)} block)))
+    (merge {:env env :variadic variadic :params (map munge params) :fixed-arity fixed-arity :gthis gthis :recurs @(:flag recur-frame)} block)))

 (defmethod parse 'fn*
   [op env [_ & args] name]
@@ -454,10 +469,11 @@
         locals (:locals env)
         locals (if name (assoc locals name {:name mname}) locals)
         menv (if (> (count meths) 1) (assoc env :context :expr) env)
-        methods (map #(analyze-fn-method menv locals %) meths)]
+        methods (map #(analyze-fn-method menv locals %) meths)
+        max-fixed-arity (apply max (map :fixed-arity methods))]
     ;;(assert (= 1 (count methods)) "Arity overloading not yet supported")
     ;;todo - validate unique arities, at most one variadic, variadic takes max required args
-    {:env env :op :fn :name mname :methods methods}))
+    {:env env :op :fn :name mname :methods methods :max-fixed-arity max-fixed-arity}))

 (defmethod parse 'do
   [op env [_ & exprs] _]


bugfix: all branches of get-expander's cond now return an ns or nil

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -813,12 +813,12 @@
   (let [mvar
         (when-not (-> env :locals sym)  ;locals hide macros
           (if-let [nstr (namespace sym)]
-            (when-let [nsym (cond
-                             (= "clojure.core" nstr) 'cljs.core
-                             (.contains nstr ".") (symbol nstr)
-                             :else
-                             (-> env :ns :requires-macros (get (symbol nstr))))]
-              (and (find-ns nsym) (.findInternedVar ^clojure.lang.Namespace (find-ns nsym) (symbol (name sym)))))
+            (when-let [ns (cond
+                           (= "clojure.core" nstr) (find-ns 'cljs.core)
+                           (.contains nstr ".") (find-ns (symbol nstr))
+                           :else
+                           (-> env :ns :requires-macros (get (symbol nstr))))]
+              (.findInternedVar ^clojure.lang.Namespace ns (symbol (name sym))))
             (.findInternedVar ^clojure.lang.Namespace (find-ns 'cljs.core) sym)))]
     (when (and mvar (.isMacro ^clojure.lang.Var mvar))
       @mvar)))


avoid emitting the same goog.require

avoid emitting the same goog.require

(:require [clojure.string :as str]) would
emit goog.require("clojure.string") twice
:refer might also cause this.

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -792,7 +792,7 @@
   (emitln "goog.provide('" (munge name) "');")
   (when-not (= name 'cljs.core)
     (emitln "goog.require('cljs.core');"))
-  (doseq [lib (into (vals requires) (distinct (vals uses)))]
+  (doseq [lib (distinct (concat (vals requires) (vals uses)))]
     (emitln "goog.require('" (munge lib) "');")))

 (defmethod emit* :deftype*


fix DCE regression for trivial programs

fix DCE regression for trivial programs

ns forms should not emit *loaded-libs* code when COMPILED=true

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -810,8 +810,8 @@
     (let [loaded-libs      (munge 'cljs.core.*loaded-libs*)
           loaded-libs-temp (munge (gensym 'cljs.core.*loaded-libs*))]
       (when (-> libs meta :reload-all)
-        (emitln loaded-libs-temp " = " loaded-libs " || cljs.core.set();")
-        (emitln loaded-libs " = cljs.core.set();"))
+        (emitln "if(!COMPILED) " loaded-libs-temp " = " loaded-libs " || cljs.core.set();")
+        (emitln "if(!COMPILED) " loaded-libs " = cljs.core.set();"))
       (doseq [lib (remove (set (vals seen)) (distinct (vals libs)))]
         (cond
           ;; only emit if foreign lib under Node.js
@@ -829,7 +829,7 @@
           :else
           (emitln "goog.require('" (munge lib) "');")))
       (when (-> libs meta :reload-all)
-        (emitln loaded-libs " = cljs.core.into(" loaded-libs-temp ", " loaded-libs ");")))))
+        (emitln "if(!COMPILED) " loaded-libs " = cljs.core.into(" loaded-libs-temp ", " loaded-libs ");")))))

 (defmethod emit* :ns
   [{:keys [name requires uses require-macros env]}]


A bit of compression in the main api ns

A bit of compression in the main api ns

--- src/clj_bots/pin_ctrl.clj
+++ src/clj_bots/pin_ctrl.clj
@@ -61,41 +61,31 @@

 (defn set-mode!
   "Set the mode of the pin. Must be a value supported by the pin."
-  ([pin mode]
-   (board-apply p/set-mode! pin mode))
-  ([board pin-n mode]
-   (p/set-mode! board pin-n mode)))
+  ([pin mode] (board-apply p/set-mode! pin mode))
+  ([board pin-n mode] (p/set-mode! board pin-n mode)))

 (defn read-value
   "Read a single value from the pin. If an analog input, returns a value between 0 and 1."
-  ([pin]
-   (board-apply p/read-value pin))
-  ([board pin-n]
-   (p/read-value board pin-n)))
+  ([pin] (board-apply p/read-value pin))
+  ([board pin-n] (p/read-value board pin-n)))

 (defn read-raw-value
   "Read a raw unprocessed value from an analog input pin."
-  ([pin]
-   (board-apply p/read-raw-value pin))
-  ([board pin-n]
-   (p/read-raw-value board pin-n)))
+  ([pin] (board-apply p/read-raw-value pin))
+  ([board pin-n] (p/read-raw-value board pin-n)))

 (defn write-value!
   "Write a value to a writable pin. The kind of value supported and what it means is entirely dependent on
   what kind of pin is being used."
-  ([pin val]
-   (board-apply p/write-value! pin val))
-  ([board pin-n val]
-   (p/write-value! board pin-n val)))
+  ([pin val] (board-apply p/write-value! pin val))
+  ([board pin-n val] (p/write-value! board pin-n val)))

 ;; ### Edge detection functionality

 (defn set-edge!
   "Set the edge direction of a pin. Accepts `:falling`, `:rising` and `:both`."
-  ([pin edge]
-   (board-apply p/set-edge! pin edge))
-  ([board pin-n edge]
-   (p/set-edge! board pin-n edge)))
+  ([pin edge] (board-apply p/set-edge! pin edge))
+  ([board pin-n edge] (p/set-edge! board pin-n edge)))

 (defmulti create-edge-channel
   "Return a channel on which events will be published. Buffer defaults to 1:


syntax

syntax

--- src/cljs/cljs/reader.cljs
+++ src/cljs/cljs/reader.cljs
@@ -7,8 +7,7 @@
 ;   You must not remove this notice, or any other, from this software.

 (ns cljs.reader
-  (:require [goog.string :as gstring
-             goog.string.StringBuffer :as gsb]))
+  (:require [goog.string :as gstring]))

 (defprotocol PushbackReader
   (read-char [reader] "Returns the next char from the Reader,
@@ -63,16 +62,16 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn macro-terminating? [ch]
-  (and (not= ch "#") (not= ch "\'") (contains? macros ch)))
+  (and (not= ch "#") (not= ch \') (contains? macros ch)))

 (defn read-token
   [rdr initch]
-  (loop [sb (gsb/StringBuffer. initch)
+  (loop [sb (gstring/StringBuffer. initch)
          ch (read-char rdr)]
     (if (or (nil? ch)
             (whitespace? ch)
             (macro-terminating? ch))
-      (do (unread rdr ch) (.toString gsb))
+      (do (unread rdr ch) (.toString sb))
       (recur (do (.append sb ch) sb) (read-char rdr)))))

 (defn- skip-line
@@ -209,7 +208,7 @@

 (defn read-number
   [reader initch]
-  (loop [buffer (gsb/StringBuffer. initch)
+  (loop [buffer (gstring/StringBuffer. initch)
          ch (read-char reader)]
     (if (or (nil? ch) (whitespace? ch) (contains? macros ch))
       (do
@@ -219,7 +218,7 @@

 (defn read-string
   [reader _]
-  (loop [buffer (gsb/StringBuffer.)
+  (loop [buffer (gstring/StringBuffer.)
          ch (read-char reader)]
     (cond
      (nil? ch) (throw "EOF while reading string")


With new cljs compiler release, into-array no longer needed.

--- src/cljx/c2/geo/core.cljx
+++ src/cljx/c2/geo/core.cljx
@@ -9,12 +9,6 @@

 ;;Use JS native map and join fns; this is about 3 times faster than using CLJS seqs and str.
 ^:cljs (do
-         ;;taken from ClojureScript master; remove once a new release is cut.
-         (defn into-array
-           ([aseq]
-              (into-array nil aseq))
-           ([type aseq]
-              (reduce (fn [a x] (.push a x) a) (array) aseq)))

          (defn ->arr [c]
            (if (= js/Array (type c))


Add more examples

Add more examples

--- src/clojure/cfbt/ch10.clj
+++ src/clojure/cfbt/ch10.clj
@@ -113,13 +113,13 @@
    {:cuddle-hunger-level 0 :percent-deteriorated 0}
    :validator percent-deteriorated-validator))

-(swap! bobby update-in [:percent-deteriorated] + 200)
+;;(swap! bobby update-in [:percent-deteriorated] + 200)

 ;; Refs ::

 (def sock-varieties
   #{"darned" "argyle" "wool" "horsehair" "mulleted"
-    "passive-aggressive" "stripped" "polka-dotted"
+    "passive-aggressive" "striped" "polka-dotted"
     "athletic" "business" "power" "invisible" "gollumed"})

 (defn sock-count
@@ -140,6 +140,40 @@
                  :socks (set (map #(sock-count % 2) sock-varieties))}))

 (:socks @dryer) ;;
-;; #{{:variety "gollumed", :count 2} {:variety "wool", :count 2} {:variety "passive-aggressive", :count 2} {:variety "argyle", :count 2} {:variety "business", :count 2} {:variety "darned", :count 2} {:variety "polka-dotted", :count 2} {:variety "horsehair", :count 2} {:variety "power", :count 2} {:variety "stripped", :count 2} {:variety "athletic", :count 2} {:variety "mulleted", :count 2} {:variety "invisible", :count 2}}
+;; #{{:variety "gollumed", :count 2} {:variety "striped", :count 2} {:variety "wool", :count 2} {:variety "passive-aggressive", :count 2} {:variety "argyle", :count 2} {:variety "business", :count 2} {:variety "darned", :count 2} {:variety "polka-dotted", :count 2} {:variety "horsehair", :count 2} {:variety "power", :count 2} {:variety "athletic", :count 2} {:variety "mulleted", :count 2} {:variety "invisible", :count 2}}

-;; TBC: 219
+(defn steal-sock
+  [gnome dryer]
+  (dosync
+   (when-let [pair (some #(if (= (:count %) 2) %) (:socks @dryer))]
+     (let [updated-count (sock-count (:variety pair) 1)]
+       (alter gnome update-in [:socks] conj updated-count)
+       (alter dryer update-in [:socks] disj pair)
+       (alter dryer update-in [:socks] conj updated-count)))))
+
+(steal-sock sock-gnome dryer)
+;; {:name "LG 1337", :socks #{{:variety "striped", :count 2} {:variety "wool", :count 2} {:variety "passive-aggressive", :count 2} {:variety "argyle", :count 2} {:variety "business", :count 2} {:variety "darned", :count 2} {:variety "polka-dotted", :count 2} {:variety "horsehair", :count 2} {:variety "power", :count 2} {:variety "athletic", :count 2} {:variety "gollumed", :count 1} {:variety "mulleted", :count 2} {:variety "invisible", :count 2}}}
+
+(:socks @sock-gnome)
+;; #{{:variety "gollumed", :count 1}}
+
+(defn similar-socks
+  [target-sock sock-set]
+  (filter #(= (:variety %) (:variety target-sock)) sock-set))
+
+(similar-socks (first (:socks @sock-gnome)) (:socks @dryer))
+;; ({:variety "gollumed", :count 1})
+
+(def counter (ref 0))
+(future
+  (dosync
+   (alter counter inc)
+   (println @counter)
+   (Thread/sleep 500)
+   (alter counter inc)
+   (println @counter)))
+
+(Thread/sleep 250)
+(println @counter)
+
+;; Commute :: p220


Moar.

Moar.

--- src/clojurecraft/core.clj
+++ src/clojurecraft/core.clj
@@ -16,6 +16,8 @@
      0x07 :useentity
      0x08 :updatehealth
      0x09 :respawn
+     0x0A :player
+     0x0B :playerposition
 })
 (def packet-ids (apply assoc {} (mapcat reverse packet-types)))

@@ -55,6 +57,11 @@
       (doto (:out @conn)
          (.writeLong (int i))))

+(defn -write-double [conn i]
+      (println (str "-> DOUBLE: " i))
+      (doto (:out @conn)
+         (.writeDouble (int i))))
+
 (defn -write-string16 [conn s]
       (-write-short conn (count s))
       (println (str "-> STRING: " s))
@@ -94,6 +101,21 @@

       (-write-bool conn world))

+(defn write-packet-player [conn {onground :onground}]
+      (-write-byte conn (:player packet-ids))
+
+      (-write-bool conn onground))
+
+(defn write-packet-playerposition [conn {x :x y :y stance :stance z :z onground :onground}]
+      (-write-byte conn (:playerposition packet-ids))
+
+      (-write-double conn x)
+      (-write-double conn y)
+      (-write-double conn stance)
+      (-write-double conn z)
+      (-write-bool conn onground)
+      )
+

 ; Writing Wrappers -----------------------------------------------------------------
 (defn flushc [conn]
@@ -101,11 +123,13 @@

 (defn write-packet [conn packet-type payload]
       (cond
-        (= packet-type :keepalive) (write-packet-handshake conn payload)
-        (= packet-type :handshake) (write-packet-handshake conn payload)
-        (= packet-type :login)     (write-packet-login conn payload)
-        (= packet-type :chat)      (write-packet-chat conn payload)
-        (= packet-type :respawn)   (write-packet-respawn conn payload)
+        (= packet-type :keepalive)      (write-packet-handshake conn payload)
+        (= packet-type :handshake)      (write-packet-handshake conn payload)
+        (= packet-type :login)          (write-packet-login conn payload)
+        (= packet-type :chat)           (write-packet-chat conn payload)
+        (= packet-type :respawn)        (write-packet-respawn conn payload)
+        (= packet-type :player)         (write-packet-player conn payload)
+        (= packet-type :playerposition) (write-packet-playerposition conn payload)
         )
       (flushc conn))


Add methods for unpacking blobs.

Add methods for unpacking blobs.

--- src/cavm/h2.clj
+++ src/cavm/h2.clj
@@ -1008,3 +1008,55 @@
   (let [db (apply create-db args)]
     (with-db db (create))
     (H2Db. db)))
+
+;
+; Support for pulling a row from a blob column. Implements
+; an LRU cache of retrieved blobs.
+;
+
+(def field-bin-query
+  (cached-statement
+    "SELECT `scores` FROM `field_score`
+     JOIN `scores` ON `scores_id` = `scores`.`id`
+     WHERE `field_id` = ? AND `i` = ?"
+    true))
+
+(def feature-value-query
+  (cached-statement
+    "SELECT `value` FROM `feature`
+     JOIN `code` ON `feature`.`id` = `feature_id`
+     WHERE `field_id` = ? AND `ordering` = ?"
+    true))
+
+(defn fetch-bin [conn field-id bin]
+  (-> (field-bin-query conn field-id bin)
+      first
+      :scores ; XXX check for null before trying to unpack
+      bytes-to-floats))
+
+(def cache-size (int (/ (* 128 1024) bin-size))) ; 128k bin cache
+
+(def bin-cache-state (atom (cache/lru-cache-factory {} :threshold cache-size)))
+
+(defn update-bin-cache [c conn args]
+  (if (cache/has? c args)
+    (cache/hit c args)
+    (cache/miss c args (apply fetch-bin conn args))))
+
+(defn bin-cache [conn & args]
+  (cache/lookup (swap! bin-cache-state update-bin-cache conn args) args))
+
+(defn lookup-row [conn field-id row]
+  (let [^floats bin (bin-cache conn field-id (quot row bin-size))
+        i (rem row bin-size)]
+    (aget bin i)))
+
+(defn lookup-value [conn field-id row]
+  (let [ordering (int (lookup-row conn field-id row))]
+    (-> (feature-value-query conn field-id ordering)
+        first
+        :value))) ; XXX check for null before trying to unpack
+
+
+(unpack/set-lookup-row! lookup-row)
+(unpack/set-lookup-value! lookup-value)


short-name for logging

short-name for logging

--- src/co/nclk/flax/node.clj
+++ src/co/nclk/flax/node.clj
@@ -229,7 +229,7 @@
           (= (name (:name node)) "local"))
       "local"

-      :else (str "flax-" (name (:name node)) "-" (.getTime (:effective self)) "-" (:version self))))
+      :else (str (name (:name node)) "-" (.getTime (:effective self)) "-" (:version self))))
   (isolate [self] self))


Add badge for renaming section, close #42

--- frontend/src/cruncher/rename.cljs
+++ frontend/src/cruncher/rename.cljs
@@ -78,7 +78,7 @@
   Object
   (render [this]
     (dom/div nil
-             (dom/p #js {:className "lead"} "Renaming")
+             (dom/p #js {:className "lead"} "Renaming " (dom/span #js {:className "badge"} "new"))
              (dom/label #js {:className "control-label"} "Renames selected Pokemon. Not reversible")
              (select-schemes (om/props this)))))
 (def controls (om/factory RenamingControls))


Weekdays can contain trailing s: "Montags um 16:00"

--- resources/languages/de/rules/time.clj
+++ resources/languages/de/rules/time.clj
@@ -30,31 +30,31 @@
   ;; Named things

   "named-day"
-  #"(?i)montag|mo\.?"
+  #"(?i)montags?|mo\.?"
   (day-of-week 1)

   "named-day"
-  #"(?i)die?nstag|di?\.?"
+  #"(?i)die?nstags?|di?\.?"
   (day-of-week 2)

   "named-day"
-  #"(?i)mittwoch|mi\.?"
+  #"(?i)mittwochs?|mi\.?"
   (day-of-week 3)

   "named-day"
-  #"(?i)donn?erstag|do\.?"
+  #"(?i)donn?erstags?|do\.?"
   (day-of-week 4)

   "named-day"
-  #"(?i)freitag|fr\.?"
+  #"(?i)freitags?|fr\.?"
   (day-of-week 5)

   "named-day"
-  #"(?i)samstag|sa\.?"
+  #"(?i)samstags?|sa\.?"
   (day-of-week 6)

   "named-day"
-  #"(?i)sonntag|so\.?"
+  #"(?i)sonntags?|so\.?"
   (day-of-week 7)

   "named-month"


Add logs to debug issue

Add logs to debug issue

Debug https://flowhelp.reamaze.com/admin/conversations/akvolumen-support-request-number-207626-from-annabelle-at-akvo-dot-org

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -36,13 +36,17 @@
                                 (cond-> {:id (get column "columnName")
                                          :type (get column "type")}
                                   (contains? column "key") (assoc :key (boolean (get column "key")))))
-                              imported-columns)]
-    (set/subset? (set (map #(select-keys % [:id :type]) imported-columns))
-                 (set (map #(select-keys % [:id :type])
-                           ;; https://github.com/akvo/akvo-lumen/issues/1923
-                           ;; https://github.com/akvo/akvo-lumen/issues/1926
-                           ;; remove this map conversion logic once #1926 is finished
-                           (map #(update % :id name) columns))))))
+                              imported-columns)
+        compatible? (set/subset? (set (map #(select-keys % [:id :type]) imported-columns))
+                         (set (map #(select-keys % [:id :type])
+                                   ;; https://github.com/akvo/akvo-lumen/issues/1923
+                                   ;; https://github.com/akvo/akvo-lumen/issues/1926
+                                   ;; remove this map conversion logic once #1926 is finished
+                                   (map #(update % :id name) columns))))]
+    (if compatible?
+      compatible?
+      (do (log/error :imported-columns imported-columns)
+          (log/error :columns columns)))))

 (defn- do-update [tenant-conn import-config dataset-id data-source-id job-execution-id data-source-spec]
   (jdbc/with-db-transaction [conn tenant-conn]


Allowing for environment to specify data file.

--- src/ahnentafel/system.clj
+++ src/ahnentafel/system.clj
@@ -6,7 +6,7 @@
   (:require [clojure.java.io :refer [resource]]))

 (defn system []
-  (let [file (resource "sample.ged")
+  (let [file (resource (:file env "sample.ged"))
         data (future (read-file file))
         app-data {:version (:ahnentafel-version env)
                   :port (:port env)


release version 3.5.0

release version 3.5.0

--- kafka-clj/project.clj
+++ kafka-clj/project.clj
@@ -1,4 +1,4 @@
-(defproject kafka-clj "3.DEBUG.4-SNAPSHOT"
+(defproject kafka-clj "3.5.0"
   :description "fast kafka library implemented in clojure"
   :url "https://github.com/gerritjvv/kafka-fast"
   :license {:name "Eclipse Public License"


up version

up version

--- kafka-clj/project.clj
+++ kafka-clj/project.clj
@@ -30,9 +30,9 @@
                  [org.clojure/tools.trace "0.7.6"]
                  [org.xerial.snappy/snappy-java "1.1.1.6"]
                  [org.clojure/tools.logging "0.3.0"]
-                 [clj-tcp "0.4.5-SNAPSHOT"]
+                 [clj-tcp "0.4.5"]
                  [fmap-clojure "LATEST" :exclusions [org.clojure/tools.logging]]
-                 [fun-utils "0.5.2-SNAPSHOT" :exclusions [org.clojure/tools.logging]]
+                 [fun-utils "0.5.2" :exclusions [org.clojure/tools.logging]]
                  [clj-tuple "0.1.7"]
                  [thread-load "0.1.3" :exclusions [org.clojure/clojure]]
                  [com.codahale.metrics/metrics-core "3.0.1"]


Add missing parameter to default impl of services.

--- src/uxbox/services/core.clj
+++ src/uxbox/services/core.clj
@@ -25,11 +25,11 @@
   :hierarchy #'+hierarchy+)

 (defmethod -novelty :default
-  [data]
+  [conn data]
   (throw (ex-info "Not implemented" {})))

 (defmethod -query :default
-  [data]
+  [conn data]
   (throw (ex-info "Not implemented" {})))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Remove duplicated events from workspace component.

--- src/uxbox/ui/workspace.cljs
+++ src/uxbox/ui/workspace.cljs
@@ -36,10 +36,7 @@
   [own]
   (let [[projectid pageid] (:rum/props own)]
     (rs/emit! (dw/initialize projectid pageid)
-              (udp/fetch-pages projectid)
-              (udh/watch-page-changes)
-              (udh/fetch-page-history pageid)
-              (udh/fetch-pinned-page-history pageid))
+              (udh/watch-page-changes))
     own))

 (defn- workspace-did-mount


Improved coordenates component.

Improved coordenates component.

--- src/uxbox/ui/workspace.cljs
+++ src/uxbox/ui/workspace.cljs
@@ -28,11 +28,8 @@
   [own]
   (let [{:keys [x y]} (rum/react wb/mouse-position)]
     (html
-     [:div {:style {:position "absolute" :left "80px" :top "20px"}}
-      [:table
-       [:tbody
-        [:tr [:td "x="] [:td x]]
-        [:tr [:td "y="] [:td y]]]]])))
+     [:div {:style {:position "absolute" :left "50px" :top "25px"}}
+      [:span (str "| x=" x " | y=" y " |")]])))

 (def coordinates
   (mx/component


Updated session auth example.

Updated session auth example.

--- examples/session/src/authexample/web.clj
+++ examples/session/src/authexample/web.clj
@@ -27,13 +27,6 @@
     (throw-unauthorized)
     (response (slurp (io/resource "index.html")))))

-
-;; Global var that stores valid users with their
-;; respective passwords.
-
-(def authdata {:admin "secret"
-               :test "secret"})
-
 ;; Login page controller
 ;; It returns a login page on get requests.

@@ -41,28 +34,8 @@
   [request]
   (render (slurp (io/resource "login.html")) request))

-;; Authenticate Handler
-;; Respons to post requests in same url as login and is responsible to
-;; identify the incoming credentials and set the appropiate authenticated
-;; user into session. `authdata` will be used as source of valid users.
-
-(defn login-authenticate
-  [request]
-  (let [username (get-in request [:form-params "username"])
-        password (get-in request [:form-params "password"])
-        session (:session request)]
-    (if-let [found-password (get authdata (keyword username))]
-      (if (= found-password password)
-        (let [nexturl (get-in request [:query-params :next] "/")
-              session (assoc session :identity (keyword username))]
-          (-> (redirect nexturl)
-              (assoc :session session)))
-        (render (slurp (io/resource "login.html")) request))
-      (render (slurp (io/resource "login.html")) request))))
-
-
 ;; Logout handler
-;; It is responsible of cleaing session.
+;; Responsible for clearing the session.

 (defn logout
   [request]
@@ -70,12 +43,42 @@
       (assoc :session {})))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Authentication                                   ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def authdata
+  "Global var that stores valid users with their
+   respective passwords."
+  {:admin "secret"
+   :test "secret"})
+
+;; Authentication Handler
+;; Used to respond to POST requests to /login.
+
+(defn login-authenticate
+  "Check request username and password against authdata username and passwords.
+  On successful authentication, set appropriate user into the session and
+  redirect to the value of (:query-params (:next request)).
+  On failed authentication, renders the login page."
+  [request]
+  (let [username (get-in request [:form-params "username"])
+        password (get-in request [:form-params "password"])
+        session (:session request)
+        found-password (get authdata (keyword username))]
+    (if (= found-password password)
+      (let [next-url (get-in request [:query-params :next] "/")
+            updated-session (assoc session :identity (keyword username))]
+        (-> (redirect next-url)
+            (assoc :session updated-session)))
+      (render (slurp (io/resource "login.html")) request))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Routes and Middlewares                           ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; User defined application routes using compojure routing library.
-;; Note: no any middleware for authorization, all authorization system
-;; is totally decoupled from main routes.
+;; Note: We do not use middleware for authorization, all of the authorization
+;; system is decoupled from main routes.

 (defroutes app
   (GET "/" [] home)
@@ -83,9 +86,8 @@
   (POST "/login" [] login-authenticate)
   (GET "/logout" [] logout))

-
-;; Self defined unauthorized handler
-;; This function is responsible of handling unauthorized requests.
+;; User defined unauthorized handler
+;; This function is responsible for handling unauthorized requests.
 ;; (When unauthorized exception is raised by some handler)

 (defn unauthorized-handler
@@ -97,12 +99,10 @@
     (authenticated? request)
     (-> (render (slurp (io/resource "error.html")) request)
         (assoc :status 403))
-
     ;; In other cases, redirect it user to login.
     :else
     (let [current-url (:uri request)]
       (redirect (format "/login?next=%s" current-url)))))
-

 ;; Create an instance of auth backend.


Remove development def

Remove development def

--- src/atom_finder/patch.clj
+++ src/atom_finder/patch.clj
@@ -173,8 +173,3 @@
   (partial map #(update-in % [:ranges]
     (partial map (fn [x] {:old [(:old-min x) (:old-max x)]
                           :new [(:new-min x) (:new-max x)]})))))
-
-(def corrs (->> "patch/gcc_97574c57cf26ace9b8609575bbab66465924fef7.patch"
-     resource-path slurp parse-diff patch-correspondences))
-
-


:speak_no_evil: s/localhost/puns.ericb.me/

--- src/puns/html.clj
+++ src/puns/html.clj
@@ -64,7 +64,7 @@
      "no@thanks.com"]]])

 (defn main-page [& [pun]]
-  (with-base-url "http://localhost:3000" ; "http://puns.ericb.me"
+  (with-base-url "http://puns.ericb.me"
     (html5
      {:prefix "og: http://ogp.me/ns#"}
      (html


[execute] Fix args to :or destructuring. (#135)

--- src/cortex/nn/execute.clj
+++ src/cortex/nn/execute.clj
@@ -106,7 +106,7 @@

 (defn train-batch!
   [network forward-buffer-map & {:keys [optimize?]
-                                 :or [optimize? true]}]
+                                 :or {optimize? true}}]
   (-> network
       (compute-binding/update-traversal-buffers forward-buffer-map :stream :buffer)
       (compute-binding/do-traverse :forward)


fixed swagger-ui model signatures

fixed swagger-ui model signatures

--- src/ctia/schemas/core.clj
+++ src/ctia/schemas/core.clj
@@ -17,91 +17,91 @@
              [verdict :as vs]
              [vocabularies :as vocs]]
             [flanders.schema :as fs]
-            [schema.core :as s]))
+            [schema.core :refer [defschema Str Bool]]))

 ;; actor
-(def NewActor (fs/->schema-tree as/NewActor))
-(def StoredActor (fs/->schema-tree as/StoredActor))
+(defschema NewActor (fs/->schema-tree as/NewActor))
+(defschema StoredActor (fs/->schema-tree as/StoredActor))

 ;; campaign
-(def NewCampaign (fs/->schema-tree cs/NewCampaign))
-(def StoredCampaign (fs/->schema-tree cs/StoredCampaign))
+(defschema NewCampaign (fs/->schema-tree cs/NewCampaign))
+(defschema StoredCampaign (fs/->schema-tree cs/StoredCampaign))

 ;; coa
-(def NewCOA (fs/->schema-tree coas/NewCOA))
-(def StoredCOA (fs/->schema-tree coas/StoredCOA))
+(defschema NewCOA (fs/->schema-tree coas/NewCOA))
+(defschema StoredCOA (fs/->schema-tree coas/StoredCOA))

 ;; data-table
-(def NewDataTable (-> ds/NewDataTable
-                      fs/replace-either-with-any
-                      fs/->schema-tree))
+(defschema NewDataTable (-> ds/NewDataTable
+                            fs/replace-either-with-any
+                            fs/->schema-tree))

-(def StoredDataTable (-> ds/StoredDataTable
+(defschema StoredDataTable (-> ds/StoredDataTable
+                               fs/replace-either-with-any
+                               fs/->schema-tree))
+
+;; exploit-target
+(defschema NewExploitTarget (fs/->schema-tree es/NewExploitTarget))
+(defschema StoredExploitTarget (fs/->schema-tree es/StoredExploitTarget))
+
+;; sighting
+(defschema NewSighting (fs/->schema-tree ss/NewSighting))
+(defschema StoredSighting (fs/->schema-tree ss/StoredSighting))
+
+;; judgement
+(defschema NewJudgement (fs/->schema-tree js/NewJudgement))
+(defschema StoredJudgement (fs/->schema-tree js/StoredJudgement))
+
+;; verdict
+(defschema Verdict (fs/->schema-tree vs/Verdict))
+(defschema StoredVerdict (fs/->schema-tree vs/StoredVerdict))
+
+;; feedback
+(defschema NewFeedback (fs/->schema-tree feedbacks/NewFeedback))
+(defschema StoredFeedback (fs/->schema-tree feedbacks/StoredFeedback))
+
+;; incident
+(defschema NewIncident (fs/->schema-tree is/NewIncident))
+(defschema StoredIncident (fs/->schema-tree is/StoredIncident))
+
+;; indicator
+(defschema NewIndicator (-> ins/NewIndicator
+                            fs/replace-either-with-any
+                            fs/->schema-tree))
+
+(defschema StoredIndicator (-> ins/StoredIndicator
+                               fs/replace-either-with-any
+                               fs/->schema-tree))
+
+;; ttp
+(defschema NewTTP (fs/->schema-tree ttps/NewTTP))
+(defschema StoredTTP (fs/->schema-tree ttps/StoredTTP))
+
+;; bundle
+(defschema NewBundle (-> bs/NewBundle
                          fs/replace-either-with-any
                          fs/->schema-tree))

-;; exploit-target
-(def NewExploitTarget (fs/->schema-tree es/NewExploitTarget))
-(def StoredExploitTarget (fs/->schema-tree es/StoredExploitTarget))
-
-;; sighting
-(def NewSighting (fs/->schema-tree ss/NewSighting))
-(def StoredSighting (fs/->schema-tree ss/StoredSighting))
-
-;; judgement
-(def NewJudgement (fs/->schema-tree js/NewJudgement))
-(def StoredJudgement (fs/->schema-tree js/StoredJudgement))
-
-;; verdict
-(def Verdict (fs/->schema-tree vs/Verdict))
-(def StoredVerdict (fs/->schema-tree vs/StoredVerdict))
-
-;; feedback
-(def NewFeedback (fs/->schema-tree feedbacks/NewFeedback))
-(def StoredFeedback (fs/->schema-tree feedbacks/StoredFeedback))
-
-;; incident
-(def NewIncident (fs/->schema-tree is/NewIncident))
-(def StoredIncident (fs/->schema-tree is/StoredIncident))
-
-;; indicator
-(def NewIndicator (-> ins/NewIndicator
-                      fs/replace-either-with-any
-                      fs/->schema-tree))
-
-(def StoredIndicator (-> ins/StoredIndicator
-                         fs/replace-either-with-any
-                         fs/->schema-tree))
-
-;; ttp
-(def NewTTP (fs/->schema-tree ttps/NewTTP))
-(def StoredTTP (fs/->schema-tree ttps/StoredTTP))
-
-;; bundle
-(def NewBundle (-> bs/NewBundle
-                   fs/replace-either-with-any
-                   fs/->schema-tree))
-
-(def StoredBundle (-> bs/StoredBundle
-                      fs/replace-either-with-any
-                      fs/->schema-tree))
+(defschema StoredBundle (-> bs/StoredBundle
+                            fs/replace-either-with-any
+                            fs/->schema-tree))

 ;; relationships
-(def RelatedIndicator (fs/->schema-tree rels/RelatedIndicator))
+(defschema RelatedIndicator (fs/->schema-tree rels/RelatedIndicator))

 ;; common
-(def Observable (fs/->schema-tree cos/Observable))
-(def Reference (fs/->schema-tree cos/Reference))
-(def ID (fs/->schema-tree cos/ID))
+(defschema Observable (fs/->schema-tree cos/Observable))
+(defschema Reference (fs/->schema-tree cos/Reference))
+(defschema ID (fs/->schema-tree cos/ID))

-(s/defschema VersionInfo
+(defschema VersionInfo
   "Version information for a specific instance of CTIA"
-  {:base s/Str
-   :version s/Str
-   :build s/Str
-   :beta s/Bool
-   :supported_features [s/Str]})
+  {:base Str
+   :version Str
+   :build Str
+   :beta Bool
+   :supported_features [Str]})

 ;; vocabularies
-(def ObservableTypeIdentifier
+(defschema ObservableTypeIdentifier
   (fs/->schema-tree vocs/ObservableTypeIdentifier))


made extra-opts in pacman extension actually get used

--- src/duffel_ext/pacman.clj
+++ src/duffel_ext/pacman.clj
@@ -21,7 +21,7 @@
     (preprocess-file [x file-tree] file-tree)
     (preprocess-dir [x dir-tree] dir-tree)
     (file-meta-tpl [x]
-        { :extra-opts '(:list (:optional ())) })
+        { :extra-opts '( :list (:optional ()) (:map-tpl (:string)) ) })
     (dir-meta-tpl [x] {})
     (postprocess-file [x file-struct] file-struct)
     (postprocess-dir [x dir-struct] dir-struct)
@@ -29,7 +29,7 @@
     (process-file [x app meta-struct abs local]
         (let [all-pacs (s/split (slurp local) #"\n")
               pacs (remove package-installed? all-pacs)]
-            (when-not (empty? pacs) (install-packages! pacs))))
+            (when-not (empty? pacs) (apply install-packages! pacs (meta-struct :extra-opts)))))

     (process-dir [x app meta-struct abs local]


Set Piggieback REPL output directory (fixes #268)

--- sidecar/src/figwheel_sidecar/repl.clj
+++ sidecar/src/figwheel_sidecar/repl.clj
@@ -126,13 +126,14 @@
   (try
     (require 'cemerick.piggieback)
     (let [cljs-repl (resolve 'cemerick.piggieback/cljs-repl)
-          special-fns (or (:special-fns opts) cljs.repl/default-special-fns)]
+          special-fns (or (:special-fns opts) cljs.repl/default-special-fns)
+          output-dir (or (:output-dir opts) "out")]
       (try
         ;; Piggieback version 0.2+
-        (cljs-repl figwheel-env :special-fns special-fns)
+        (cljs-repl figwheel-env :special-fns special-fns :output-dir output-dir)
         (catch Exception e
           ;; Piggieback version 0.1.5
-          (cljs-repl :repl-env figwheel-env :special-fns special-fns))))
+          (cljs-repl :repl-env figwheel-env :special-fns special-fns :output-dir output-dir))))
     (catch Exception e
       (println "INFO: nREPL connection found but unable to load piggieback. Starting default REPL")
       (start-cljs-repl :default figwheel-env opts))))


demo: update text when options change, and keep cursor visible

--- site/src/parinfer_site/editor_ui.cljs
+++ site/src/parinfer_site/editor_ui.cljs
@@ -3,7 +3,15 @@
     [parinfer-site.state :refer [state]]
     [om.core :as om]
     [sablono.core :refer-macros [html]]
-    ))
+    [parinfer-site.editor-support :refer [fix-text!]]
+    [goog.dom :as gdom]))
+
+(defn refresh!
+  [cm]
+  (fix-text! cm)
+  (let [element (.getWrapperElement cm)
+        cursor (gdom/getElementByClass "CodeMirror-cursors" element)]
+    (set! (.. cursor -style -visibility) "visible")))

 (defn editor-header
   [editor]
@@ -18,7 +26,8 @@
          [:select.mode
           {:value (name (:mode editor))
            :on-change (fn [e]
-                        (om/update! editor :mode (keyword (.. e -target -value))))}
+                        (om/update! editor :mode (keyword (.. e -target -value)))
+                        (refresh! (:cm editor)))}
           [:option {:value "indent-mode"} "Indent Mode"]
           [:option {:value "paren-mode"} "Paren Mode"]]

@@ -29,7 +38,8 @@
                {:type "checkbox"
                 :checked (get-in editor path)
                 :on-change (fn [e]
-                             (om/update! editor path (.. e -target -checked)))}]
+                             (om/update! editor path (.. e -target -checked))
+                             (refresh! (:cm editor)))}]
               "preview cursor scope"]))

          (when (= (:mode editor) :paren-mode)


Fix issue in file-store delete! implementation.

--- src/blocks/store/file.clj
+++ src/blocks/store/file.clj
@@ -193,9 +193,10 @@

   (-delete!
     [this id]
-    (when-block id
-      (locking this
-        (.delete file))))
+    (or (when-block id
+          (locking this
+            (.delete file)))
+        false))

   store/BlockEnumerator


Set TTL of ring session to one hour, instead of 1 minute for testing.

--- dev-resources/spec.clj
+++ dev-resources/spec.clj
@@ -16,7 +16,7 @@
  :cassandra {:config-file "cassandra.yaml"}
  :alia {:contact-points ["localhost"]
         :port 9042}
- :session-store {:ttl 1}
+ :session-store {:ttl 60}
  :kafka {:server {:port 9090
                   :broker.id 1
                   :log.dir "target/kafka-log"


Fix CLJS tests

Fix CLJS tests

--- src/expound/problems.cljc
+++ src/expound/problems.cljc
@@ -113,13 +113,17 @@
                 nil))

         new-in (cond
+                   ;; TODO - simplify by returning nil?
+                 (and in1
+                      (not= ::paths/not-found-path in1))
                  in1
-                 in1
-
+
+                 (and in2
+                      (not= ::paths/not-found-path in2))
                  in2
-                 in2
-
-                 in3
+
+                 (and in3
+                      (not= ::paths/not-found-path in3))
                  in3

                  (or (= '(apply fn) (:pred problem))
@@ -130,7 +134,7 @@
                  ::paths/not-found-path)]
     (assoc problem
            :expound/in
-           new-in)))
+           (or new-in ::paths/not-found-path))))

 (defn- adjust-path [failure problem]
   (assoc problem :expound/path


Take out the extra ? for favicon

Take out the extra ? for favicon

--- src/foreclojure/utils.clj
+++ src/foreclojure/utils.clj
@@ -92,7 +92,7 @@
     [:head
      [:title "4Clojure"]
      [:link {:rel "alternate" :type "application/atom+xml" :title "Atom" :href "http://4clojure.com/problems/rss"}]
-     [:link {:rel "shortcut icon" :href "/favicon.ico?"}]
+     [:link {:rel "shortcut icon" :href "/favicon.ico"}]
      (include-js "/script/jquery-1.5.2.min.js" "/script/jquery.dataTables.min.js")
      (include-js "/script/foreclojure.js")
      (include-js "/script/xregexp.js" "/script/shCore.js" "/script/shBrushClojure.js")


config default merging is broken

config default merging is broken

--- src/chessground/data.cljs
+++ src/chessground/data.cljs
@@ -24,9 +24,9 @@

 (defn make [js-config]
   (let [config (-> js-config
-                   keywordize-keys
-                   (update-in [:movable] keywordize-keys)
-                   (update-in [:movable :events] keywordize-keys))]
+                   keywordize-keys)]
+                   ; (update-in [:movable] keywordize-keys)
+                   ; (update-in [:movable :events] keywordize-keys))]
     (-> (merge defaults config)
         (with-fen (:fen config))
         (dissoc :fen))))


Remove duplicated tests from core_tests.clj file.

--- test/catacumba/core_tests.clj
+++ test/catacumba/core_tests.clj
@@ -234,31 +234,6 @@
 )

-(deftest form-parsing
-  (testing "Multipart form parsing with multiple files."
-    (let [p (promise)
-          handler (fn [context]
-                    (let [form (ct/parse-formdata context)]
-                      (deliver p form)
-                      "hello world"))]
-      (with-server handler
-        (let [multipart {:multipart [{:name "foo" :content "bar"}
-                                     {:name "myfile"
-                                      :content (-> (io/resource "public/test.txt")
-                                                   (io/file))
-                                      :encoding "UTF-8"
-                                      :mime-type "text/plain"}
-                                     {:name "myfile"
-                                      :content (-> (io/resource "public/test.txt")
-                                                   (io/file))
-                                      :encoding "UTF-8"
-                                      :mime-type "text/plain"}]}
-              response (client/post base-url multipart)]
-          (is (= (:status response) 200))
-          (is (= (:body response) "hello world"))
-          (let [formdata (deref p 1000 nil)]
-            (is (= (get formdata "foo") "bar"))))))))
-
 (deftest request-body-handling
   (testing "Read body as text"
     (let [p (promise)


Added momentum & l2 regularization for bias

--- src/clj/asols/trainer.clj
+++ src/clj/asols/trainer.clj
@@ -69,11 +69,11 @@

 (defmethod forward ::relu
   [_ in-vec]
-  (m/emap (partial max 0) in-vec))
+  (m/emap #(if (pos? %) % 0.0) in-vec))

 (defmethod derivative ::relu
   [_ out-vec]
-  (m/emap #(if (pos? %) 1 0) out-vec))
+  (m/emap #(if (pos? %) 1.0 0.0) out-vec))

 ;; Softmax output layer with log-likehood loss

@@ -184,10 +184,12 @@

   Params:
    - deltas-vec - vector of deltas (errors) of current layer"
-  [t-opts deltas-vec]
-  (m/mul -1
-         (:learning-rate t-opts)
-         deltas-vec))
+  [e-count t-opts layer deltas-vec prev-delta-b]
+  (let [{:keys [learning-rate momentum l2-lambda]} t-opts]
+    (-> (m/mul -1 learning-rate deltas-vec)
+        (m/add! (m/mul momentum prev-delta-b))
+        (m/sub! (m/mul (:biases layer)
+                       l2-lambda learning-rate (/ 1 e-count))))))

 (defn get-initial-delta-w
   "Returns collection of matrixes of initial delta weights of layers"
@@ -196,12 +198,18 @@
         :let [[in-count out-count] (net/get-layer-shape layer)]]
     (m/zero-matrix in-count out-count)))

+(defn get-initial-delta-b
+  [net]
+  (for [layer (:layers net)
+        :let [[_ out-count] (net/get-layer-shape layer)]]
+    (m/zero-vector out-count)))
+
 (defn backprop-step-delta
   "Performs forward & backward passes of single data entry.
   Returns vector of [delta-weights delta-biases cost-val] where:
     delta-weights - coll of matrixes of weights deltas for each layer
     delta-biases - coll of vectors of biases deltas for each layer"
-  [net entry e-count t-opts prev-delta-w]
+  [net entry e-count t-opts prev-delta-w prev-delta-b]
   (let [{:keys [input-vec target-vec]} entry
         {:keys [in-node-prob hidden-node-prob]} t-opts
         forward-vecs (forward-pass net input-vec in-node-prob hidden-node-prob)
@@ -212,29 +220,31 @@
        deltas-vecs
        forward-vecs
        prev-delta-w)
-
      (map
-       #(backprop-delta-layer-biases t-opts %1)
-       deltas-vecs)]))
+       #(backprop-delta-layer-biases e-count t-opts %1 %2 %3)
+       (:layers net)
+       deltas-vecs
+       prev-delta-b)]))

 (defn backprop-step
   "Performs forward & backward pass, tunes network weights & biases.
   Returns new network and weights deltas."
-  [net entry e-count t-opts prev-delta-w]
-  (let [results (backprop-step-delta net entry e-count t-opts prev-delta-w)
+  [net entry e-count t-opts prev-delta-w prev-delta-b]
+  (let [results (backprop-step-delta net entry e-count t-opts prev-delta-w prev-delta-b)
         [delta-weights delta-biases] results
         new-layers (map
                      (fn [{:keys [edges-matrix edges-mask biases] :as layer} delta-w delta-b]
                        (let [delta-w (m/mul delta-w edges-mask)
                              new-edges-matrix (m/add delta-w edges-matrix)
-                             new-biases (m/add! delta-b biases)]
+                             new-biases (m/add delta-b biases)]
                          (assoc layer :edges-matrix new-edges-matrix
                                       :biases new-biases)))
                      (:layers net)
                      delta-weights
                      delta-biases)]
     [(assoc net :layers (vec new-layers))
-     delta-weights]))
+     delta-weights
+     delta-biases]))

 (defn calc-cost
   "Performs forward pass, calculates cost of out layer for each entry.
@@ -254,15 +264,14 @@
   (let [e-count (count entries)]
     (loop [curr-net start-net
            entry-i 0
-           curr-delta-w (get-initial-delta-w curr-net)]
+           curr-delta-w (get-initial-delta-w curr-net)
+           curr-delta-b (get-initial-delta-b curr-net)]
       (if (>= entry-i e-count)
         curr-net
         (let [entry (nth entries entry-i)
-              step-result (backprop-step curr-net entry e-count t-opts curr-delta-w)
-              [new-net new-delta-w] step-result]
-          (recur new-net
-                 (inc entry-i)
-                 new-delta-w))))))
+              step-result (backprop-step curr-net entry e-count t-opts curr-delta-w curr-delta-b)
+              [new-net new-delta-w new-delta-b] step-result]
+          (recur new-net (inc entry-i) new-delta-w new-delta-b))))))

 (defn train
   "Trains given network on a dataset during multiple epochs.


CLJS-1004: warning about single segment namespaces

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -63,7 +63,8 @@
    :invalid-arithmetic true
    :protocol-invalid-method true
    :protocol-duped-method true
-   :protocol-multiple-impls true})
+   :protocol-multiple-impls true
+   :single-segment-namespace true})

 (declare message namespaces)

@@ -172,6 +173,10 @@
 (defmethod error-message :invoke-ctor
   [warning-type info]
   (str "Cannot invoke type constructor " (-> info :fexpr :info :name) " as function "))
+
+(defmethod error-message :single-segment-namespace
+  [warning-type info]
+  (str (:name info) " is a single segment namespace"))

 (defn ^:private default-warning-handler [warning-type env extra]
   (when (warning-type *cljs-warnings*)
@@ -1279,6 +1284,8 @@
   [_ env [_ name & args :as form] _ opts]
   (when-not (symbol? name)
     (throw (error env "Namespaces must be named by a symbol.")))
+  (when (= 1 (count (string/split (clojure.core/name name) #"\.")))
+    (warning :single-segment-namespace env {:name name}))
   (let [docstring (if (string? (first args)) (first args))
         args      (if docstring (next args) args)
         metadata  (if (map? (first args)) (first args))


macro resolution wip

macro resolution wip

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -384,6 +384,10 @@
   (let [sym (symbol name)]
     (get (:requires (:ns env)) sym sym)))

+(defn resolve-macro-ns-alias [env name]
+  (let [sym (symbol name)]
+    (get (:require-macros (:ns env)) sym sym)))
+
 (defn confirm-ns [env ns-sym]
   (when (and (nil? (get '#{cljs.core goog Math goog.string} ns-sym))
              (nil? (get (-> env :ns :requires) ns-sym))
@@ -478,6 +482,27 @@
           ev (resolve-existing-var env name)]
       (when (and ev (not (-> ev :dynamic)))
         (warning :dynamic env {:ev ev :name (:name ev)})))))
+
+(defn resolve-macro-var [env sym]
+  (let [ns (-> env :ns :name)
+        namespaces (get @env/*compiler* ::namespaces)]
+    (cond
+      (namespace sym)
+      (let [ns (namespace sym)
+            ns (if (= "clojure.core" ns) "cljs.core" ns)
+            full-ns (resolve-macro-ns-alias env ns)]
+        (get-in namespaces [full-ns :macros (symbol (name sym))]))
+
+      (get-in namespaces [ns :use-macros sym])
+      (let [full-ns (get-in namespaces [ns :uses-macros sym])]
+        (get-in namespaces [full-ns :macros sym]))
+
+      :else
+      (let [ns (cond
+                 (get-in namespaces [ns :macros sym]) ns
+                 (core-name? env sym) 'cljs.core)]
+        (when ns
+          (get-in namespaces [ns :macros sym]))))))

 (defn ns-dependents
   ([ns]