Properly format purge url

Properly format purge url

--- src/clojars/cdn.clj
+++ src/clojars/cdn.clj
@@ -4,7 +4,7 @@

 (defn purge [key cdn-url path]
   (let [res (http/request {:method "PURGE"
-                           :url (str cdn-url path)
+                           :url (format "%/%s" cdn-url path)
                            :headers {"Fastly-Key" key}})
         body (json/parse-string (:body res) true)]
     (assoc body :http-status (:status res))))


automatically render template if render returned a vector

--- src/pump/utils.cljs
+++ src/pump/utils.cljs
@@ -1,4 +1,5 @@
-(ns pump.utils)
+(ns pump.utils
+  (:require [pump.template :refer [html]]))

 (defn add-this-as-first-argument
   [f]
@@ -8,7 +9,11 @@

 (defn wrap-functions
   [{:keys [render] :as props-map}]
-  (let [render-proxy #(this-as this (render this (.-state this) (.-props this)))
+  (let [render-proxy #(this-as this
+                        (let [res (render this (.-state this) (.-props this))]
+                          (if (vector? res)
+                            (html res)
+                            res)))
         props-proxy (for [[name f] (dissoc props-map :render)]
                       [name (add-this-as-first-argument f)])
         props (into {:render render-proxy} props-proxy)]


Change the default drum beat ;)

Change the default drum beat ;)

--- src/drum_machine/state.cljs
+++ src/drum_machine/state.cljs
@@ -4,11 +4,11 @@
   {:tracks
    [{:name "Kick"
      :source "http://sampleswap.org/samples-ghost/DRUMS%20and%20SINGLE%20HITS/kicks/61[kb]bass-kickers-2.wav.mp3"
-     :play-on [1 3]
+     :play-on [1]
      :volume 1.0}
     {:name "Snare"
      :source "http://sampleswap.org/samples-ghost/DRUMS%20and%20SINGLE%20HITS/snares/57[kb]acoustic_snare.aif.mp3"
-     :play-on [2 4]
+     :play-on [3]
      :volume 1.0}
     {:name "Hi-Hat"
      :source "http://sampleswap.org/samples-ghost/DRUMS%20and%20SINGLE%20HITS/hats/29[kb]909-squoosh-hat.aif.mp3"


check if data is not defined

check if data is not defined

--- src/combo/core.cljs
+++ src/combo/core.cljs
@@ -46,7 +46,7 @@
   (let [props #(select-keys % ubiquitous-keys)]
     (merge
       (props spec)
-      (when-let [v (data (:entity spec))]
+      (when-let [v (get data (:entity spec))]
         (if (map? v)
           (props v)
           {:value v})))))
@@ -56,9 +56,8 @@
         out (om/get-state owner :commit-chan)]
     (go-loop []
       (let [[_ a v :as msg] (async/<! in)]
-        (om/update! data a v)
-        (when out
-          (async/>! out msg)))
+        (when data (om/update! data a v))
+        (when out (async/>! out msg)))
       (recur))))

 (defn- setup-commit [data owner opts]
@@ -66,7 +65,7 @@
         pubc (om/get-state owner :update-pubc)
         chan (om/get-state owner :intern-chan)]
     (async/sub pubc :combo/commit chan)
-    (commit data owner)))
+    (when data (commit data owner))))

 (defn view [data owner opts]
   (reify


Tweak ssl/tls settings for better defaults and more flexibility.

--- src/postal/smtp.clj
+++ src/postal/smtp.clj
@@ -12,16 +12,18 @@
          (catch Exception e
            {:code 99 :error (class e) :message (.getMessage e)}))))
   ([auth-map & msgs]
-     (let [{:keys [host port user pass sender] :or {host "localhost"
-                                                    port 25}}
+     (let [{:keys [host port
+                   user pass
+                   sender ssl] :or {host "localhost"}}
            auth-map
+           port (if (not port)
+                  (if ssl 465 25))
+           protocol (if ssl "smtps" "smtp")
            session (doto (Session/getInstance (make-props sender auth-map))
                      (.setDebug false))]
-       (with-open [transport (.getTransport session (if (and user pass)
-                                                      "smtps"
-                                                      "smtp"))]
+       (with-open [transport (.getTransport session (if ssl "smtps" "smtp"))]
          (.connect transport host port (str user) (str pass))
-         (let [jmsgs (map #(make-jmessage % session) msgs)]
+         (let [jmsgs (map #(make-jmessage % session) msgs)]
            (doseq [jmsg jmsgs]
              (.sendMessage transport jmsg (.getAllRecipients jmsg)))
            {:code 0 :error :SUCCESS :message "messages sent"})))))


Update oracle.clj

Update oracle.clj

--- src/dbms/oracle.clj
+++ src/dbms/oracle.clj
@@ -1,14 +1,6 @@
 (ns dbms.oracle
   (:use (korma db core config))
   (:require (clojure [string :as str])))
-
-;; (def db-spec
-;;   {:classname "oracle.jdbc.OracleDriver"
-;;    :subprotocol "oracle"
-;;    :subname "thin:@192.168.1.83:1521:testdb"
-;;    :user "xxx"
-;;    :password "xxx"
-;;    :naming {:keys str/lower-case :fields str/upper-case}})

 (def db-spec
   (oracle {:subname "@//192.168.1.83:1521/testdb"


added world* as global variable, and added the direct buffer-copy function

--- src/overtone/core/sc.clj
+++ src/overtone/core/sc.clj
@@ -33,6 +33,8 @@
 (defonce server*        (ref nil))
 (defonce status*        (ref :no-audio))
 (defonce synths*        (ref nil))
+
+(defonce world* (ref nil))

 ;TODO: Figure out the real limits...  These are total guesses, but
 ; it should be plenty.
@@ -322,9 +324,10 @@
                              (set! (. opts lib-scsynth-path) (str (find-scsynth-lib-path)))
                              (set! (. opts plugin-path) (str (find-synthdefs-lib-path)))

-                             (let [world (ScJnaStart opts)]
-                               (World_WaitForQuit world)
-                               (ScJnaCleanup))))
+                             (dosync (ref-set world* (ScJnaStart opts)))
+
+                             (World_WaitForQuit @world*)
+                             (ScJnaCleanup)))
              sc-thread (Thread. boot-thread)]
          (.setDaemon sc-thread true)
          (log/debug "Booting SuperCollider internal server (scsynth)...")
@@ -589,6 +592,9 @@
   (assert (buffer? buf))
   (snd "/b_write" (:id buf) path "wav" "float"))

+(defn buffer-copy [id]
+  (ScJnaCopySndBuf @world* id))
+
 (defn load-sample
   "Load a wav file into memory so it can be played as a sample."
   [path & args]


improve trigger event fn docstrings

improve trigger event fn docstrings

--- src/overtone/sc/trig.clj
+++ src/overtone/sc/trig.clj
@@ -13,11 +13,7 @@
   "Returns a new globally unique id useful for feeding into send-trig
    and matching on the event stream.

-   (def uid (trig-id))
-   (defsynth foo [] (send-trig (impulse 10) uid (sin-osc)))
-   (on-trigger uid
-               (fn [val] (println \"trig val:\" val)))
-   (foo)"
+   See on-trigger docstring for usage example."
   []
   (next-id ::trig-id))

@@ -32,7 +28,26 @@
   "Registers a standard on-event handler with key which will call
    handler when matching triggers are recieved. Triggers are created
    with the send-trig ugen. Handler should be a fn which takes one
-   argument - the latest trigger value."
+   argument - the latest trigger value.
+
+   Consider using trig-id to create a unique trigger id
+
+    ;; create new id
+    (def uid (trig-id))
+
+    ;; define a synth which uses send-trig
+    (defsynth foo
+              [t-id 0]
+              (send-trig (impulse 10) t-id (sin-osc)))
+
+    ;; register a handler fn
+    (on-trigger uid
+                (fn [val] (println \"trig val:\" val))
+                ::debug)
+
+    ;; create a new instance of synth foo with trigger id as a
+    ;; param
+    (foo uid)"
   ([trig-id handler key]
      (add-handler on-event [:overtone :trigger trig-id] handler key))
   ([node trig-id handler key]
@@ -42,7 +57,10 @@
   "Registers a standard on-latest-event handler with key which will call
    handler when matching triggers are recieved. Triggers are created
    with the send-trig ugen. Handler should be a fn which takes one
-   argument - the latest trigger value."
+   argument - the latest trigger value.
+
+   Consider using trig-id to create a unique trigger id. See on-trigger
+   docstring for usage example."
   ([trig-id handler key]
      (add-handler on-latest-event [:overtone :trigger trig-id] handler key))
   ([node trig-id handler key]
@@ -52,7 +70,10 @@
   "Registers a standard on-sync-event handler with key which will call
    handler when matching triggers are recieved. Triggers are created
    with the send-trig ugen. Handler should be a fn which takes one
-   argument - the latest trigger value."
+   argument - the latest trigger value.
+
+   Consider using trig-id to create a unique trigger id. See on-trigger
+   docstring for usage example."
   ([trig-id handler key]
      (add-handler on-sync-event [:overtone :trigger trig-id] handler key))
   ([node trig-id handler key]


Track execution errors in *e

Track execution errors in *e

--- planck-cljs/src/planck/core.cljs
+++ planck-cljs/src/planck/core.cljs
@@ -236,4 +236,5 @@
               (when error
                 (print-error error))))
           (catch :default e
+            (set! *e e)
             (print-error e)))))))


Removing unused run-thumbnailer call signature

--- src/vignette/util/thumbnail.clj
+++ src/vignette/util/thumbnail.clj
@@ -55,18 +55,15 @@
           thumb-map))

 (defn run-thumbnailer
-  ([args thumb-map]
-    (let [start-ms (System/currentTimeMillis)
-          result (perf/timing :imagemagick (apply sh args))
-          elapsed-ms (- (System/currentTimeMillis) start-ms)]
-      (if (> elapsed-ms 5000)
-          (do
-            (log/info "slow-thumbnailer-call" {:time_ms elapsed-ms :thumb_map thumb-map})
-            result)
+  [args thumb-map]
+  (let [start-ms (System/currentTimeMillis)
+        result (perf/timing :imagemagick (apply sh args))
+        elapsed-ms (- (System/currentTimeMillis) start-ms)]
+    (if (> elapsed-ms 5000)
+        (do
+          (log/info "slow-thumbnailer-call" {:time_ms elapsed-ms :thumb_map thumb-map})
           result)
-      ))
-  ([args]
-    (run-thumbnailer args {})))
+        result)))

 (defn original->thumbnail
   [resource thumb-map]


Get rid of spurious/impossible fallback clause

--- src/cheshire/generate.clj
+++ src/cheshire/generate.clj
@@ -147,10 +147,7 @@
                             sdf (doto (SimpleDateFormat. date-format)
                                   (.setTimeZone (SimpleTimeZone. 0 "UTC")))]
                         (write-string ^JsonGenerator jg (.format sdf obj)))
-   :else (try
-           (.writeNumber ^JsonGenerator jg obj)
-           (catch Exception e
-             (fail obj jg ex)))))
+   :else (fail obj jg ex)))

 ;; Generic encoders, these can be used by someone writing a custom
 ;; encoder if so desired, after transforming an arbitrary data


Removed broken single-char command line opts

--- src/engulf/core.clj
+++ src/engulf/core.clj
@@ -14,15 +14,15 @@
 (defn parse-args
   [args]
   (cli args
-       ["-p" "--http-port" "Listen on this port for the HTTP UI"
+       ["--http-port" "Listen on this port for the HTTP UI"
         :parse-fn #(Integer. %) :default (:http-port settings/all)]
-       ["-n" "--manager-port" "TCP Port for manager to listen on"
+       ["--manager-port" "TCP Port for manager to listen on"
         :parse-fn #(Integer. %) :default (:manager-port settings/all)]
-       ["-m" "--mode" "{combined:master:worker}"
+       ["--mode" "{combined:master:worker}"
         :parse-fn keyword :default (:mode settings/all)]
-       ["-c" "--connect-to" "When in worker mode, connect to this TCP host:port"
+       ["--connect-to" "When in worker mode, connect to this TCP host:port"
         :parse-fn #(let [[h p] (split % #":")] [h (Integer/valueOf p)]) :default (:connect-to settings/all)]
-       ["-h" "--help" "Show help, then exit" :default false :flag true]))
+       ["--help" "Show help, then exit" :default false :flag true]))

 (defn -main [& args]
   (let [[opts args banner] (parse-args args)]


CLJS-1117: Dependencies in JARs don't use cached analysis

cljs.analyzer/analyze:
    * :pre condition so opts map isn't accidentally passed as
       3rd name argument.

cljs.analyzer/analyze-file:
    * fix bad caching boolean test
    * invoke cljs.analyzer/analyze correctly
    * Use implied output-dir.

--- src/clj/cljs/analyzer.clj
+++ src/clj/cljs/analyzer.clj
@@ -1844,6 +1844,8 @@
   ([env form] (analyze env form nil))
   ([env form name] (analyze env form name nil))
   ([env form name opts]
+   {:pre [(or (nil? name) (symbol? name))
+          (or (nil? opts) (map? opts))]}
     (env/ensure
       (wrapping-errors env
         (reduce (fn [ast pass] (pass env ast))
@@ -2033,9 +2035,10 @@
    \":output-dir/some/ns/foo.cljs.cache.edn\". This function does not return a
    meaningful value."
   ([f] (analyze-file f nil))
-  ([f {:keys [output-dir] :as opts}]
+  ([f opts]
    (binding [*file-defs* (atom #{})]
-     (let [res (cond
+     (let [output-dir (util/output-directory opts)
+           res (cond
                  (instance? File f) f
                  (instance? URL f) f
                  (re-find #"^file://" f) (URL. f)
@@ -2047,11 +2050,10 @@
                       (.getPath ^File res)
                       (.getPath ^URL res))
                cache (when (or (= (:ns ns-info) 'cljs.core)
-                               (and (:cache-analysis opts) output-dir))
+                               (:cache-analysis opts))
                        (cache-file res ns-info output-dir))]
            (when-not (get-in @env/*compiler* [::namespaces (:ns ns-info)])
-             (if (or (not= (:ns ns-info) 'cljs.core)
-                     (not cache)
+             (if (or (not cache)
                      (requires-analysis? res output-dir))
                (binding [*cljs-ns* 'cljs.user
                          *cljs-file* path
@@ -2063,7 +2065,7 @@
                             (if forms
                               (let [form (first forms)
                                     env (assoc env :ns (get-namespace *cljs-ns*))
-                                    ast (analyze env form opts)]
+                                    ast (analyze env form nil opts)]
                                 (if (= (:op ast) :ns)
                                   (recur (:name ast) (next forms))
                                   (recur ns (next forms))))


fix the way foreign libs are loaded via the :ns form

foreign libs are always placed at the root of the output directory. load them
 from there.

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -814,7 +814,9 @@
       (doseq [lib (remove (set (vals seen)) (distinct (vals libs)))]
         (cond
           (ana/foreign-dep? lib)
-          (emitln "cljs.core.load_file(\"" (munge (name lib)) ".js\");")
+          (let [js-index (:js-dependency-index @env/*compiler*)
+                ijs-url  (get-in js-index [(name lib) :url])]
+            (emitln "cljs.core.load_file(\"" (util/get-name ijs-url) "\");"))

           (-> libs meta :reload)
           (emitln "goog.require('" (munge lib) "', true);")


Fix ranger armor

Fix ranger armor

--- src/clj/zetawar/data.cljs
+++ src/clj/zetawar/data.cljs
@@ -116,17 +116,17 @@
             :min-range 1
             :max-range 1
             :armor-type :personnel
-            :armor 6
+            :armor 9
             :capturing-armor 2
             :repair 1
             :state-map :move-attack
             :image "tilesets/elite-command/units/ranger-COLOR.png"
             :terrain-effects
-            {:plains    {:movement-cost 3 :attack-bonus  0 :armor-bonus  0}
-             :mountains {:movement-cost 6 :attack-bonus  2 :armor-bonus  5}
-             :woods     {:movement-cost 3 :attack-bonus  2 :armor-bonus  4}
-             :desert    {:movement-cost 3 :attack-bonus -1 :armor-bonus -1}
-             :base      {:movement-cost 2 :attack-bonus  2 :armor-bonus  3}}
+            {:plains    {:movement-cost 3 :armor-bonus  0 :attack-bonus  0}
+             :mountains {:movement-cost 6 :armor-bonus  5 :attack-bonus  2}
+             :woods     {:movement-cost 3 :armor-bonus  4 :attack-bonus  2}
+             :desert    {:movement-cost 3 :armor-bonus -1 :attack-bonus -1}
+             :base      {:movement-cost 2 :armor-bonus  3 :attack-bonus  2}}
             :attack-strengths
             {:personnel 9
              :armored 4}}
@@ -138,6 +138,7 @@
             :max-range 1
             :armor-type :armored
             :armor 8
+            ;; TODO: capturing armor doesn't make sense for units that can't canpture
             :capturing-armor 2
             :repair 1
             :state-map :free-attack-twice
@@ -158,6 +159,7 @@
           :max-range 1
           :armor-type :armored
           :armor 12
+          ;; TODO: capturing armor doesn't make sense for units that can't canpture
           :capturing-armor 2
           :repair 1
           :state-map :move-attack


Turning some comments into doc strings

Turning some comments into doc strings

--- src/clj/zetawar/game.cljs
+++ src/clj/zetawar/game.cljs
@@ -328,12 +328,6 @@
     (throw (ex-info "Specified destination is not a valid move"
                     {:q q :r r}))))

-;; Moveable
-;; - member of active faction
-;; - not repaired
-;; - not capturing
-;; - hasn't attacked
-
 (defn check-can-move [db game unit]
   (check-unit-current db game unit)
   (when (= (:unit/round-built unit) (:game/round game))
@@ -360,12 +354,6 @@
 ;; - add legal moves to frontier
 ;; - repeat with updated movement points + frontier

-;; Move
-;; x check can move
-;; - check valid move
-;; x update coordinates
-;; x update move-count
-
 (defn teleport-tx [db game from-q from-r to-q to-r]
   (let [unit (checked-unit-at db game from-q from-r)]
     [{:db/id (e unit)
@@ -373,12 +361,13 @@
       :unit/q to-q
       :unit/r to-r}]))

+;; TODO: check move is valid
 (defn move-tx
+  "Returns a transaction that updates the unit's location and move count."
   ([db game unit to-terrain]
    (let [new-move-count (inc (get unit :unit/move-count 0))
          [to-q to-r] (terrain-hex to-terrain)]
      (check-can-move db game unit)
-     ;; TODO: check move is valid
      [{:db/id (e unit)
        :unit/game-pos-idx (game-pos-idx game to-q to-r)
        :unit/q to-q
@@ -559,6 +548,8 @@
       false)))

 (defn repair-tx
+  "Returns a transaction that increments unit count and sets the unit repaired
+  flag to true."
   ([db game unit]
    (check-can-repair db game unit)
    [{:db/id (e unit)
@@ -604,13 +595,9 @@
     (catch :default ex
       false)))

-;; Capture
-;; x check unit can capture
-;; x check base capturable
-;; x set state to capturing
-;; x set capture round

 (defn capture-tx
+  "Returns a transaction that sets the unit capturing flag and capture round."
   ([db game unit]
    (let [base (base-at db game (:unit/q unit) (:unit/r unit))
          round (:game/round game)]
@@ -639,14 +626,8 @@
       ;; TODO: include info about occupying unit
       (throw (ex-info "Base is occupied" {:q q :r r})))))

-;; Build
-;; x check base ownership
-;; x check credits
-;; x check space unoccupied
-;; x create new unit
-;; x update credits
-
 (defn build-tx
+  "Returns a transaction that creates a new unit and updates faction credits."
   ([db game q r unit-type-id]
    (let [base (checked-base-at db game q r)]
      (build-tx db game base unit-type-id)))
@@ -688,13 +669,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; End Turn

-;; End Turn
-;; x complete captures
-;; x clear per round unit flags
-;; x update active faction <=
-;; x add credits <=
-;; x update round number if appropriate <=
-
 (defn end-turn-capture-tx [db game unit]
   (let [{:keys [unit/capture-round unit/q unit/r]} unit
         faction (unit-faction db unit)
@@ -711,7 +685,10 @@
       (and capturing (= capture-round (:game/round game)))
       (into (end-turn-capture-tx db game unit)))))

-(defn end-turn-tx [db game]
+(defn end-turn-tx
+  "Return a transaction that completes captures, clears per round unit flags,
+  updates the current faction, adds faction credits, and updates the round."
+  [db game]
   (let [starting-faction (qe '[:find ?f
                                :in $ ?g
                                :where


Add a flag to show the query status

Add a flag to show the query status

--- src/cljs/bartleby/db.cljs
+++ src/cljs/bartleby/db.cljs
@@ -2,4 +2,5 @@

 (def default-db
   "Default state"
-  {:tasks []})
+  {:rest ""
+   :tasks []})


CLJS-722: Move nodejs string_print fiddling into a function

This is a bit more polite than doing it when the module loads, and lets
us use ClojureScript in node-like environments that don't expose "util"

--- src/cljs/cljs/nodejs.cljs
+++ src/cljs/cljs/nodejs.cljs
@@ -8,4 +8,5 @@
 (def process (js* "process"))

 ; Have ClojureScript print using Node's sys.print function
-(set! cljs.core/string-print (.-print (require "util")))
+(defn enable-util-print! []
+  (set! cljs.core/string-print (.-print (require "util"))))


implementation of `slides-path` route

implementation of `slides-path` route

--- src/cljs/slides/core.cljs
+++ src/cljs/slides/core.cljs
@@ -23,7 +23,10 @@
 (defroute "/" []
   (.setToken (History.) "/slides/0"))

-(defroute slide-path "/slides/:index" [index])
+(defroute slide-path "/slides/:index" [index]
+  (let [index (js/parseInt index)]
+    (when (within-slides? index app-state)
+    (swap! app-state assoc :index index))))

 (defn slide [model owner]
   (reify


Route all evaluation through a separate method for better debugging and tracing

--- src/clojure_ruby/core.clj
+++ src/clojure_ruby/core.clj
@@ -88,45 +88,49 @@

 (swap! variables assoc "File" File)

-(defmulti evaluate first)
+(declare evaluate)
+(defmulti evaluate-one first)

-(defmethod evaluate :assignment [stmt]
+(defmethod evaluate-one :assignment [stmt]
   (let [[_ name val] stmt
         val (evaluate val)]
     (swap! variables assoc name val)))

-(defmethod evaluate :var_ref [stmt]
+(defmethod evaluate-one :var_ref [stmt]
   (let [[_ name] stmt]
     (if-let [var (get @variables name)]
       var
       (throw (RuntimeException. (str "Cannot find variable [" name "]"))))))

-(defmethod evaluate :method_call [stmt]
+(defmethod evaluate-one :method_call [stmt]
   (let [[_ obj method & args] stmt
         obj (evaluate obj)
         args (map evaluate args)]
     (rb-send obj method args)))

-(defmethod evaluate :number [stmt]
+(defmethod evaluate-one :number [stmt]
   (let [[_ val] stmt]
     (create-number (Long. val))))

-(defmethod evaluate :string [stmt]
+(defmethod evaluate-one :string [stmt]
   (let [[_ val] stmt]
     (create-string val)))

-(defmethod evaluate :while [stmt]
+(defmethod evaluate-one :while [stmt]
   (let [[_ predicate & body] stmt
         predicate (evaluate predicate)]
     (if predicate
       (mapv evaluate body))))

+(defn evaluate [stmt]
+  (prn stmt)
+  (try
+    (evaluate-one stmt)
+    (catch Exception e
+      (let [[start end] (insta/span stmt)]
+        (throw (RuntimeException. (str "evaluation failed; [" start ", " end "]") e))))))
+
 (defn evaluate-all [stmts]
   (when-let [[stmt & stmts] stmts]
-    (try
-      (prn stmt)
-      (evaluate stmt)
-      (catch Exception e
-        (let [[start end] (insta/span stmt)]
-          (throw (RuntimeException. (str "evaluation failed; [" start ", " end "]") e)))))
+    (evaluate stmt)
     (recur stmts)))


Moar.

Moar.

--- src/clojurecraft/core.clj
+++ src/clojurecraft/core.clj
@@ -13,6 +13,7 @@
      0x04 :timeupdate
      0x05 :equipment
      0x06 :spawnposition
+     0x07 :useentity
 })
 (def packet-ids (apply assoc {} (mapcat reverse packet-types)))

@@ -117,6 +118,10 @@
    (let [i (.readShort (:in @conn))]
      i))

+(defn -read-bool [conn]
+   (let [b (.readBoolean (:in @conn))]
+     b))
+
 (defn -read-string16 [conn]
   (let [str-len (.readShort (:in @conn))
         s (apply str (repeatedly str-len #(.readChar (:in @conn))))]
@@ -158,6 +163,12 @@
           (assoc :x (-read-int conn))
           (assoc :y (-read-int conn))
           (assoc :z (-read-int conn))))
+
+(defn read-packet-useentity [conn]
+      (-> {}
+          (assoc :user (-read-int conn))
+          (assoc :target (-read-int conn))
+          (assoc :leftclick (-read-bool conn))))

 ; Reading Wrappers -----------------------------------------------------------------
@@ -174,6 +185,7 @@
             (= packet-type :timeupdate) (read-packet-timeupdate conn)
             (= packet-type :equipment) (read-packet-equipment conn)
             (= packet-type :spawnposition) (read-packet-spawnposition conn)
+            (= packet-type :useentity) (read-packet-useentity conn)
             :else (str "UNKNOWN PACKET TYPE: " packet-id)
             ))
         (println "\n\n\n")))


[#3] Fixed bug when finding existing comment.

--- src/gbu/webhook.clj
+++ src/gbu/webhook.clj
@@ -50,11 +50,11 @@
 (defn- comment-exists?
   "Returns true if the comment exists in the same
 file, the same line and the content is the same."
-  [{:keys [file line msg] :as result} comments]
-  (some (fn [{:keys [original-position body path]}]
-          (and
+  [{:keys [file msg] :as result} rel-line comments]
+  (some (fn [{:keys [position body path]}]
+          (and
             (= file path)
-            (= line original-position)
+            (= rel-line position)
             (= msg body)))
     comments))

@@ -65,12 +65,11 @@
    {:keys [pull-req-file line msg file] :as result}]
   (let [patch    (:patch pull-req-file)
         rel-line (utils/abs-line->patch-line patch line)]
-    (when-not (comment-exists? result comments)
-      (prn
-        (pulls/create-comment
-          user reponame id sha
-          file rel-line msg
-          {:auth github-basic-auth})))))
+    (when-not (comment-exists? result rel-line comments)
+      (pulls/create-comment
+        user reponame id sha
+        file rel-line msg
+        {:auth github-basic-auth}))))

 (defn- handle-pull-req
   "Clones the repo and checks out the PR's latest sha.
@@ -99,6 +98,7 @@
                            (map (partial match-pr-file pr-files))
                            (filter :pull-req-file)
                            (map (partial create-comment user reponame pr-id sha comments))
+                           (filter identity)
                            count)]
             (println "Created" cnt "comments.")))))))


Fix write-handlers.

Fix write-handlers.

--- src/incognito/fressian.cljs
+++ src/incognito/fressian.cljs
@@ -1,28 +1,36 @@
 (ns incognito.fressian
-  (:require [incognito.base :refer [incognito-reader incognito-writer]]
+  (:require [incognito.base :refer [incognito-reader incognito-writer IncognitoTaggedLiteral]]
             [fress.api :refer [read-object write-tag write-object]]
-            [fress.reader :refer [IFressianReader readInt]]
-            [fress.writer :refer [IFressianWriter writeInt]]))
+            [fress.reader :as r :refer [IFressianReader readInt]]
+            [fress.writer :as w :refer [IFressianWriter writeInt beginClosedList endList class-sym]]
+            [fress.impl.codes :as codes]
+            [fress.impl.buffer :as buf]
+            [fress.impl.raw-input :as rawIn]))

-(defn- record-reader [read-handlers reader]
-  (let [len (readInt reader)
-        tag (read-object reader)
-        val (->> (range len)
-                 (map (fn [_] (read-object reader)))
-                 (map vec)
-                 (into {}))]
-    (incognito-reader @read-handlers
-                      {:tag tag :value val})))
+;;add incognito write-handlers
+(defn- record-writer
+  [write-handlers]
+  (fn [w rec]
+    (let [{:keys [tag] :as r} (if (isa? (type rec) incognito.base.IncognitoTaggedLiteral)
+                          (into {} rec)
+                          (incognito-writer @write-handlers rec))]
+      (write-tag w "record" 2)
+      (write-object w (str tag))
+      (write-tag w "map" 1)
+      (beginClosedList w)
+      (doseq [[field value] r]
+        (write-object w field true)
+        (write-object w value))
+      (endList w))))

-(defn- record-writer [write-handlers writer record]
-  (let [{:keys [tag value]} (if (isa? (type record) incognito.base.IncognitoTaggedLiteral)
-                              (into {} record) ;; carry on as map
-                              (incognito-writer @write-handlers record))]
-    (write-tag writer "irecord" 2)
-    (writeInt writer (count value))
-    (write-object writer tag)
-    (doseq [e value]
-      (write-object writer e))))
+;;add incognito read-handler
+(defn- record-reader
+  [read-handlers]
+  (fn [rdr tag component-count]
+    (let [tag   (read-object rdr)
+          value (read-object rdr)]
+      (incognito-reader @read-handlers
+                        {:tag tag :value val}))))

 (defn- plist-reader [reader _ _]
   (let [len (readInt reader)]
@@ -54,7 +62,7 @@
         (into #{} l)))

 (defn incognito-read-handlers [read-handlers]
-  {"irecord" (partial record-reader read-handlers)
+  {"record" (record-reader read-handlers)
    "plist"   plist-reader
    "pvec"    pvec-reader
    "set"     set-reader})
@@ -62,20 +70,26 @@
 (defn incognito-write-handlers [write-handlers]
   {cljs.core/List             plist-writer
    cljs.core/EmptyList        plist-writer
-   cljs.core/IRecord          (partial record-writer write-handlers)
+   "record"                   (record-writer write-handlers) ;; conversion to pk lib ;:record->name {SomeRecord "SomeRec"
    cljs.core/LazySeq          plist-writer
    cljs.core/PersistentVector pvec-writer})

 (comment

-  (defrecord Foo [a b])
+  (do
+    (prn "---->>> Start Test <<<<------")
+    (defrecord SomeRecord [f1 f2]) ; map->SomeRecord is now implicitly def3ned
+    (def rec (SomeRecord. "field1" "field2"))
+    (def buf (fress.api/byte-stream))
+    (def writer (fress.api/create-writer buf :handlers
+                                         (incognito-write-handlers (atom {'incognito.fressian.SomeRecord (fn [foo] (println "foos") (assoc foo :c "donkey"))})) ))

-  (let [buffer         (fress.api/byte-stream)
-        read-handlers  (atom {'incognito.fressian.Foo map->Foo})
-        write-handlers (atom {'incognito.fressian.Foo (fn [foo] (println "foos") (assoc foo :c "donkey"))})
-        w              (fress.api/create-writer buffer :handlers (incognito-write-handlers write-handlers))]
-    (fress.api/write-object w #{4 2 3})
-    (fress.api/read buffer
-                          :handlers (incognito-read-handlers read-handlers)))
+    (prn "write object------------")
+    (w/writeObject writer rec)
+    (prn "read object------------")
+    (prn (fress.api/read buf :handlers (incognito-read-handlers (atom {}))))
+    (prn "---->>> End Test <<<<------"))

-  )
+
+
+)


renamed stuff

renamed stuff

--- src/crawler/extractor.clj
+++ src/crawler/extractor.clj
@@ -450,7 +450,7 @@
       []
       explorations-ds)))

-(defn fetch-enum-xpaths
+(defn get-enum-xpaths
   "Process the explorations and clusters to fetch the enumeration XPath"
   [{url                  :src-link
     explorations         :explorations
@@ -505,6 +505,6 @@
   [explorations clusters]

   (let [total-expl   (-> clusters flatten count)
-        enums-ranked (fetch-enum-xpaths explorations clusters)]
+        enums-ranked (get-enum-xpaths explorations clusters)]

     {:enum-candidates-ranked enums-ranked}))


apply the schema overrides on CTIM entities (#595)

--- src/ctia/schemas/core.clj
+++ src/ctia/schemas/core.clj
@@ -43,8 +43,9 @@
 (defmacro def-stored-schema [name-sym ddl spec-kw-ns]
   `(do
      (sc/defschema ~name-sym
-       (st/merge ACLStoredEntity
-                 (f-schema/->schema ~ddl)))
+       (st/merge
+        (f-schema/->schema ~ddl)
+        ACLStoredEntity))
      (f-spec/->spec ~ddl ~spec-kw-ns)))

 (defmacro def-acl-schema [name-sym ddl spec-kw-ns]


More test cases.

More test cases.

--- src/rewindable/core.cljs
+++ src/rewindable/core.cljs
@@ -25,6 +25,13 @@
          (println "yo" msg)
          msg)))

+(defn child2 [agw in-ch]
+  (ago agw
+       (loop [yas 0]
+         (println "ya0" yas (<! in-ch))
+         (println "ya1" yas (<! in-ch))
+         (recur (inc yas)))))
+
 (let [hi-ch (listen-el (gdom/getElement "hi") "click")
       bye-ch (listen-el (gdom/getElement "bye") "click")
       fie-ch (listen-el (gdom/getElement "fie") "click")
@@ -32,7 +39,8 @@
       rtw-ch (listen-el (gdom/getElement "rtw") "click") ; restore-the-world button
       last-snapshot (atom nil)
       agw (make-ago-world)
-      ch1 (ago-chan agw 1)]
+      ch1 (ago-chan agw 1)
+      ch2 (ago-chan agw 2)]
   (go-loop []
     (<! stw-ch)
     (reset! last-snapshot (ago-snapshot agw))
@@ -45,7 +53,6 @@
        (loop [num-hi 0 num-bye 0]
          (println "num-hi" num-hi "num-bye" num-bye)
          (println :agw @agw)
-         (println :lss @last-snapshot)
          (let [[x ch] (alts! [hi-ch bye-ch])]
            (cond
             (= ch hi-ch)
@@ -80,7 +87,8 @@
        (loop [num-fie 0]
          (println "num-fie" num-fie)
          (println :agw @agw)
-         (println :lss @last-snapshot)
+         (>! ch2 [:fie num-fie])
+         (>! ch2 [:foe num-fie])
          (let [[x ch] (alts! [fie-ch])]
            (cond
             (= ch fie-ch)
@@ -96,5 +104,6 @@
                     (println "ERROR"
                              "x" x "num-fie" num-fie
                              "x2" x2 "num-fie2" num-fie2)
-                    (recur (inc num-fie))))))))))
+                    (recur (inc num-fie)))))))))
+  (child2 agw ch2))


Rewrite some load fns to be more generic.

--- src/incise/load.clj
+++ src/incise/load.clj
@@ -5,26 +5,40 @@

 (defn- namespace-is-layout-or-parser?
   "Predicate to determine if the given symbol is a namespace for a layout or
-   parser. It would be a namespace under incise.layouts or incise.parsers."
+   parser."
   [namespace-sym]
   (re-find #"incise\.(layouts|parsers)\.impl\..+" (str namespace-sym)))
+
+(defn- namespace-is-deployment-workflow?
+  "Predicate to determine if the given symbol is a namespace for a deployment
+   workflow."
+  [namespace-sym]
+  (re-find #"incise\.deploy\.workflows\..+" (str namespace-sym)))

 (defn- namespace-is-spec-or-test?
   "Predicate to determine if the given namespace is a spec or test."
   [namespace-sym]
   (re-find #"-(test|spec)$" (str namespace-sym)))

-(defn- find-parser-and-layout-symbols
-  "Find symbols for namespaces on the classpath that are valid layouts and
-   parsers."
-  []
+(defn- filter-namespaces
+  "Find symbols for namespaces on the classpath that pass the given filter
+   function."
+  [filter-fn]
   (->> (classpath)
        (ns-tools/find-namespaces)
        (remove namespace-is-spec-or-test?)
-       (filter namespace-is-layout-or-parser?)))
+       (filter filter-fn)))

-(defn load-parsers-and-layouts
-  "Require with reload all namespaces under incise.layouts and incise.parsers."
-  []
-  (doseq [ns-sym (find-parser-and-layout-symbols)]
+(defn- load-ns-syms
+  "Require with reload all namespaces returned by the given fn."
+  [ns-syms-fn]
+  (doseq [ns-sym (ns-syms-fn)]
     (require :reload ns-sym)))
+
+(def load-parsers-and-layouts
+  (partial load-ns-syms
+           (partial filter-namespaces namespace-is-layout-or-parser?)))
+
+(def load-deployment-workflows
+  (partial load-ns-syms
+          (partial filter-namespaces namespace-is-deployment-workflow?)))


Add id to written JSON

Add id to written JSON

--- src/invadm/core.clj
+++ src/invadm/core.clj
@@ -52,7 +52,7 @@
     (not (:client options)) (exit 1 (error-msg ["-r CLIENT is required"]))
     (not (:amount options)) (exit 1 (error-msg ["-a AMOUNT is required"]))
     (not (get arguments 1)) (exit 1 (error-msg ["invoice id is required"])))
-  (write-json (id-to-filename (get arguments 1)) options))
+  (write-json (id-to-filename (get arguments 1)) (assoc options "id" (get arguments 1))))

 (defn cwd []
   (System/getProperty "user.dir"))


Make s/and and s/or traceable

Make s/and and s/or traceable

--- src/spectrace/trace.cljc
+++ src/spectrace/trace.cljc
@@ -48,32 +48,40 @@
     (succ ret fail)
     (fail)))

-(defmethod step* `s/cat [state succ fail]
-  (with-cont succ fail
-    (fn []
-      (let [{[segment & path] :path :keys [spec val in]} state]
-        (when-let [spec' (get (:args spec) segment)]
-          {:spec spec' :path path :in (rest in)
-           :val (nth val (first in))})))))
-
-(defmethod step* `s/& [state succ fail]
+(defn- choose-spec [specs state succ fail]
   (letfn [(rec [specs]
             (if (empty? specs)
               (fail)
               (succ (assoc state :spec (first specs))
                     #(rec (rest specs)))))]
-    (let [args (get-in state [:spec :args])
-          specs (cons (:re args) (:preds args))]
-      (rec specs))))
+    (rec specs)))
+
+(defmethod step* `s/and [state succ fail]
+  (let [specs (get-in state [:spec :args])]
+    (choose-spec specs state succ fail)))
+
+(defn- step-by-key [{:keys [spec path val in]} succ fail & {:keys [val-fn]}]
+  (with-cont succ fail
+    (fn []
+      (let [[segment & path] path, [key & in] in]
+        (when-let [spec' (some #(and (= (:key %) segment) (:pred %))
+                               (:args spec))]
+          {:spec spec' :path path :in in
+           :val (cond-> val val-fn #(val-fn % key))})))))
+
+(defmethod step* `s/or [state succ fail]
+  (step-by-key state succ fail))
+
+(defmethod step* `s/cat [state succ fail]
+  (step-by-key state succ fail :val-fn nth))
+
+(defmethod step* `s/& [state succ fail]
+  (let [args (get-in state [:spec :args])
+        specs (cons (:re args) (:preds args))]
+    (choose-spec specs state succ fail)))

 (defmethod step* `s/alt [state succ fail]
-  (with-cont succ fail
-    (fn []
-      (let [{[segment & path] :path :keys [spec val in]} state]
-        (when-let [spec' (some #(and (= (:key %) segment) (:pred %))
-                               (:args spec))]
-          {:spec spec' :path path :in (rest in)
-           :val (nth val (first in))})))))
+  (step-by-key state succ fail))

 (defmethod step* `s/* [{:keys [spec] :as state} succ fail]
   (step (assoc state :spec (get-in spec [:args :pred-form])) succ fail))


`wcar`: document `:none` pool option

`wcar`: document `:none` pool option

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -24,7 +24,8 @@
   server's response. Releases connection back to pool when done.

   `conn-opts` arg is a map with connection pool and spec options, e.g.:
-    {:pool {} :spec {:host \"127.0.0.1\" :port 6379}} ; Default
+    {:pool {}    :spec {:host \"127.0.0.1\" :port 6379}} ; Default
+    {:pool :none :spec {:host \"127.0.0.1\" :port 6379}} ; No pool
     {:pool {} :spec {:uri \"redis://redistogo:pass@panga.redistogo.com:9475/\"}}
     {:pool {} :spec {:host \"127.0.0.1\"
                      :port 6379


Basic documentation

Basic documentation

--- src/tenor/constructs.clj
+++ src/tenor/constructs.clj
@@ -1,14 +1,26 @@
+;; tenor/constructs.clj
+;; Primitive components of music theory.
+
 (ns tenor.constructs
   (:use [overtone.live]))

+
+;; --- Notes --- ;;
+
 (defn make-note [notation]
+  "Take pitch letter + octave notation
+  and generate an overtone note keyword."
   (let [notation-re #"^([A-G])([#b]?)([1-9])$"
         components (re-matches notation-re notation)]
     (if components
       (keyword (reduce str (rest components)))
       (throw (Exception. "Invalid notation")))))

+;; --- Time Signature --- ;;
+
 (defn time-signature [note-count & [sig]]
+  "Decompose a measure into randomly spaced out beats,
+  within the time signature's note count."
   (cond
     (> note-count 3)
     (let [beat (rand-nth [2 3 4])
@@ -19,9 +31,13 @@
       (time-signature 0 sig))
     :else sig))

+;; --- Beats --- ;;;
+
 (defn segment-beat [note-count note-value
                     & {:keys [sparseness]
                        :or {sparseness 1}}]
+  "Break a beat down into sixteenth-note positions and
+  assign notes and rests to each position by iteration."
   (let [sixteenth-count (* (/ 16 note-value) note-count)
         notes (range 1 (inc sixteenth-count))
         distribution (cons true (repeat sparseness false))]
@@ -29,10 +45,23 @@
       (fn [x] (or (= 1 x) (rand-nth distribution)))
       notes)))

+;; --- Scales --- ;;;
+
+(defn generate-random-scale []
+  "Generate a random scale (Example - :E3 :Dorian)."
+  (let [scale-type (rand-nth (keys SCALE))
+        ninth-octave-count 131
+        note-name (find-note-name (rand-int ninth-octave-count))]
+    (scale note-name scale-type)))
+
+;; --- Measures --- ;;;
+
 (defn segment-measure [measure
                        & {:keys [running-count result note-value sparseness]
                           :or {running-count 0 result '()
                                note-value 16 sparseness 1}}]
+  "Segment a measure into beats and further segment the beats,
+  essentially breaking the measure down into sixteenth-notes."
   (if (empty? measure)
     result
     (let [result (concat result (map #(+ running-count %)
@@ -46,29 +75,35 @@
                        :note-value note-value
                        :sparseness sparseness))))

-(defn generate-random-scale []
-  (let [scale-type (rand-nth (keys SCALE))
-        ninth-octave-count 131
-        note-name (find-note-name (rand-int ninth-octave-count))]
-    (scale note-name scale-type)))

 (defn map-measure [measure scale]
+  "Create a list of hash-maps of positions as keys
+  and musical notes as values."
   (map #(hash-map :pos %, :note (rand-nth scale)) measure))

 (defn generate-measure-map [note-count note-value]
+  "Take note count and note value, and generate a
+  measure map using map-measure."
   (map-measure
     (segment-measure (time-signature note-count))
     (generate-random-scale)))

+;; --- Playback --- ;;
+
 (defmacro construct-note [time player entity]
+  "Take time, instrument and note entity as arguments,
+  and return overtone code that plays the note."
   `(list 'at ~time (list ~player ~entity)))

 (defmacro construct-measure [measure-maps base-time player]
+  "Take a measure map and run construct-note on each
+  note, creating a list of overtone playback code components."
   `(map #(construct-note (+ (now) (* (:pos %) ~base-time))
                          ~player (:note %))
         ~measure-maps))

 (defn play-measure [measure-maps base-time player]
+  "Play the constructed measure with current time as start time."
   `(let [time# (now)]
      ~@(construct-measure measure-maps base-time player)))


hide edit icon, hide settings link, fix spacing

--- src-cljs/cljsbuild_ui/pages/main.cljs
+++ src-cljs/cljsbuild_ui/pages/main.cljs
@@ -657,29 +657,30 @@
   (let [prj-key (:filename prj)]
     (sablono/html
       [:div.project-1b83a
-       [:div.wrapper-714e4
-        [:div.left-ba9e7
-         (:name prj)
-         [:span.project-icons-dd1bb
-          [:i.fa.fa-folder-open-o.project-icon-1711d
-           {:on-click #(open-project-folder! prj-key)}]
-          (when (= (:state prj) :idle)
-            (list
-              [:i.fa.fa-edit.project-icon-1711d]
-              [:i.fa.fa-times.project-icon-1711d
-               {:on-click #(try-remove-project! prj-key)}]))]]
-        [:div.right-f5656
-         (case (:state prj)
-           :auto (auto-state prj-key)
-           :cleaning (cleaning-state prj-key)
-           :idle (idle-state prj-key prj)
-           :once (once-state prj-key)
-           "*unknown project state*")]]
-       [:table.tbl-bdf39
-        (bld-tbl-hdr)
-        (map-indexed
-          #(BuildRow (assoc %2 :idx %1 :prj-key prj-key))
-          (:builds prj))]])))
+        [:div.wrapper-714e4
+          [:div.left-ba9e7
+            (:name prj)
+            [:span.project-icons-dd1bb
+              [:i.fa.fa-folder-open-o.project-icon-1711d
+                {:on-click #(open-project-folder! prj-key)}]
+              (when (= (:state prj) :idle)
+                (list
+                  ;; NOTE: hiding edit link for now
+                  ;; [:i.fa.fa-edit.project-icon-1711d]
+                  [:i.fa.fa-times.project-icon-1711d
+                    {:on-click #(try-remove-project! prj-key)}]))]]
+          [:div.right-f5656
+            (case (:state prj)
+              :auto (auto-state prj-key)
+              :cleaning (cleaning-state prj-key)
+              :idle (idle-state prj-key prj)
+              :once (once-state prj-key)
+              "*unknown project state*")]]
+        [:table.tbl-bdf39
+          (bld-tbl-hdr)
+          (map-indexed
+            #(BuildRow (assoc %2 :idx %1 :prj-key prj-key))
+            (:builds prj))]])))

 (quiescent/defcomponent AppRoot [app-state]
   (sablono/html
@@ -689,9 +690,11 @@
         [:div.title-8749a "ClojureScript Compiler"]
         [:div.title-links-42b06
           [:span.link-3d3ad
-           {:on-click try-add-existing-project!}
-           [:i.fa.fa-plus] "Add project"]
-          [:span.link-3d3ad [:i.fa.fa-gear] "Settings"]]
+            {:on-click try-add-existing-project!}
+            [:i.fa.fa-plus] "Add project"]
+          ;; NOTE: hide settings for now
+          ;; [:span.link-3d3ad [:i.fa.fa-gear] "Settings"]
+          ]
         [:div.clr-737fa]]
       (map Project (get-ordered-projects (:projects app-state)))]))


Extract cheatsheet.

Extract cheatsheet.

--- src/klangmeister/views.cljs
+++ src/klangmeister/views.cljs
@@ -5,35 +5,38 @@
     [klangmeister.editor :as editor]
     [reagent.core :as reagent]))

+(defn cheatsheet []
+  (let [row (fn [term explanation example]
+              [:tr
+               [:td {:class "code"} term]
+               [:td explanation]
+               [:td {:class "code"} example]])]
+    [:table {:class "cheatsheet"}
+     [:tbody
+      (row "(..)" "Evaluate an expression" "(+ 1 1)")
+      (row "[..]" "Build a sequence." "[1 2 3]")
+      (row "->>" "Thread together multiple expressions." "(->> (range) (take 4))")
+      (row "A..G" "Translate a relative midi into the specified key." "(A 3) => 72")
+      (row "flat" "Translate a midi down one semitone." "(flat 72) => 71")
+      (row "phrase" "Build a melody from a sequence of durations and a sequence of pitches." "(phrase [1 1 2] [0 2 4])")
+      (row "bpm" "Build a function that converts beats into seconds." "((bpm 120) 3) => 1.5")
+      (row "major" "Convert a rank of a minor scale into a midi pitch." "(major 2) => 4")
+      (row "minor" "Convert a rank of a minor scale into a midi pitch." "(minor 2) => 3")
+      (row "sharp" "Translate a midi up one semitone." "(sharp 70) => 71")
+      (row "where" "Transform a specified key using a specified function." "(where :pitch inc notes)")
+      (row "with" "Combines two melodies." "(with notes bass-notes)")]]))
+
 (defn render [handle! state-atom]
   (let [state @state-atom
         button (if-not (:looping? state)
                  [:button {:on-click #(handle! (action/->Play))} "Play"]
                  [:button {:on-click #(handle! (action/->Stop))} "Stop"])
-        error (:error state)
-        row (fn [term explanation example] [:tr
-                                            [:td {:class "code"} term]
-                                            [:td explanation]
-                                            [:td {:class "code"} example]])]
+        error (:error state)]
     [:div
      [:div {:class "graph"} [graph/render handle! state-atom]]
      [:div {:class "controls"} button]
      [:div {:class (str "editor " (if error "error" ""))} [editor/render handle! state]]
-     [:div
-      [:table {:class "cheatsheet"}
-       [:tbody
-        (row "(..)" "Evaluate an expression" "(+ 1 1)")
-        (row "[..]" "Build a sequence." "[1 2 3]")
-        (row "->>" "Thread together multiple expressions." "(->> (range) (take 4))")
-        (row "A..G" "Translate a relative midi into the specified key." "(A 3) => 72")
-        (row "flat" "Translate a midi down one semitone." "(flat 72) => 71")
-        (row "phrase" "Build a melody from a sequence of durations and a sequence of pitches." "(phrase [1 1 2] [0 2 4])")
-        (row "bpm" "Build a function that converts beats into seconds." "((bpm 120) 3) => 1.5")
-        (row "major" "Convert a rank of a minor scale into a midi pitch." "(major 2) => 4")
-        (row "minor" "Convert a rank of a minor scale into a midi pitch." "(minor 2) => 3")
-        (row "sharp" "Translate a midi up one semitone." "(sharp 70) => 71")
-        (row "where" "Transform a specified key using a specified function." "(where :pitch inc notes)")
-        (row "with" "Combines two melodies." "(with notes bass-notes)")]]]
+     [:div [cheatsheet]]
      [:a {:href "https://github.com/ctford/klangmeister"}
       [:img {:style {:position "absolute" :top 0 :right 0 :border 0}
              :src "https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67"


pull in ns for repl

pull in ns for repl

--- src/rhymes/core.clj
+++ src/rhymes/core.clj
@@ -2,7 +2,7 @@
   (:require [rhymes.cmudict :as cmudict :refer [d]]
             [rhymes.lyrics :refer [fetch-lyrics
                                    lyrics->phones]]
-            [rhymes.rhyme])
+            [rhymes.rhyme :refer :all])
   (:gen-class))


Remove Comments.

Remove Comments.

--- src/konserve/filestore.cljs
+++ src/konserve/filestore.cljs
@@ -10,9 +10,6 @@
                                PJSONAsyncKeyValueStore -jget-in -jassoc-in -jupdate-in
                                PBinaryAsyncKeyValueStore -bget -bassoc
                                -serialize -deserialize]]
-   [incognito.transit :refer [incognito-read-handler
-                              incognito-write-handler]]
-   [cognitect.transit :as transit]
    [cljs.core.async :as async :refer (take! <! >! put! take! close! chan poll!)]
    [cljs.tools.reader.impl.inspect :as i])
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]))
@@ -48,7 +45,6 @@
   "Creates Folder with given path."
   [path]
   (let [test-file (str path "/" (random-uuid))]
-    (println "check and create folder")
     (try
       (when-not (fs.existsSync path)
         (.mkdirSync fs path))
@@ -306,15 +302,12 @@
                   write-handlers (atom {})
                   serializer     (ser/fressian-serializer)
                   config         {:fsync true}}}]
-  (println "creating store")
   (let [_ (check-and-create-folder path)
         _ (check-and-create-folder (str path "/meta"))
         _ (check-and-create-folder (str path "/data"))]
-    (println "creating system")
     (go (map->FileSystemNodejsStore {:folder         path
                                      :serializer     serializer
                                      :read-handlers  read-handlers
                                      :write-handlers write-handlers
                                      :locks          (atom {})
                                      :config         config}))))
-


Some first type hints for the context editor

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

--- src/conexp/contrib/gui/editors/context_editor/context_editor.clj
+++ src/conexp/contrib/gui/editors/context_editor/context_editor.clj
@@ -16,7 +16,7 @@
         conexp.contrib.gui.editors.context-editor.table-control
         conexp.contrib.gui.editors.context-editor.editable-contexts
         conexp.contrib.gui.editors.context-editor.context-editor-control)
-  (:import [javax.swing JRootPane KeyStroke Box JFrame]
+  (:import [javax.swing JRootPane KeyStroke Box JFrame JTable JComponent]
            [java.awt BorderLayout]
            [java.awt.event KeyEvent ActionEvent])
   (:import conexp.contrib.gui.editors.context_editor.context_editor_control.context-editor-widget))
@@ -112,7 +112,7 @@
   "Fills the selected cells from the table widget with 'X's"
   [obj]
   (assert (keyword-isa? obj conexp.contrib.gui.editors.context_editor.table_control.table-control))
-  (let [control     (get-control obj),
+  (let [^JTable control (get-control obj),
         sel-columns (-> control .getSelectedColumns seq),
         sel-rows    (-> control .getSelectedRows seq),
         sel-pairs   (map (fn [y]
@@ -203,8 +203,8 @@
                                                      (set-context @ectx ((:f button) widget))))]
                                    (set-handler bctrl handler)
                                    ;;(add-button toolbar bctrl)))
-                                   (.add box (get-widget bctrl)))))
-                             (.add (get-control toolbar) box)))]
+                                   (.add box ^JComponent (get-widget bctrl)))))
+                             (.add ^JComponent (get-control toolbar) box)))]
       (register-keyboard-action table fill-selection-with-X "Fill-X" keystroke-fill :focus)
       (add-widget e-ctx widget)
       (doto toolbar


Add some type hints.

Add some type hints.

--- src/multihash/core.clj
+++ src/multihash/core.clj
@@ -214,6 +214,7 @@

 (defn encode
   "Encodes a multihash into a binary representation."
+  ^bytes
   [mhash]
   (let [length (:length mhash)
         encoded (byte-array (+ length 2))]
@@ -225,6 +226,7 @@

 (defn hex
   "Encodes a multihash into a hexadecimal string."
+  ^String
   [mhash]
   (when mhash
     (hex/encode (encode mhash))))
@@ -232,6 +234,7 @@

 (defn base58
   "Encodes a multihash into a Base-58 string."
+  ^String
   [mhash]
   (when mhash
     (b58/encode (encode mhash))))


fixing typo

fixing typo

--- src/shuppet/web.clj
+++ src/shuppet/web.clj
@@ -132,10 +132,10 @@
 (def ^:private resources
   {:GET
    (array-map
+    "/healthcheck" "Healthcheck"
     "/1.x/icon" "Icon"
-    "/1.x./ping" "Pong"
+    "/1.x/ping" "Pong"
     "/1.x/status" "Status"
-    "/healthcheck" "Healthcheck"
     "/1.x/envs" "All available environments"
     "/1.x/envs/:env-name" "Read and evaluate the environment configuration :env-name.clj from GIT repository :env-name, return the configuration in JSON"
     "/1.x/envs/:env-name/apply" "Apply the environment configuration"


Stabilize morph order

Stabilize morph order

--- test-cljs/frontend/test_gencard.cljs
+++ test-cljs/frontend/test_gencard.cljs
@@ -25,6 +25,7 @@
   (->> (gen/sample-seq (s/gen spec))
        (take 100)
        (group-by (comp signature component))
+       (sort-by (comp hash key))
        vals
        (map first)))


fix prepare to avoid the line too long

fix prepare to avoid the line too long

--- src/neuseg/prepare.clj
+++ src/neuseg/prepare.clj
@@ -40,12 +40,18 @@
                           (map mdot (Neighbors/slider 4 quadzero (map get-vector (iterator-seq (NGram/quadgram text))))))
                           (partition 2 (tagging text)))))

+(def counter (atom 0))
+
 (defn gen-train [file-corpus file-output]
-  (with-open [wrtr (writer file-output  :encoding "utf-8")]
-    (with-open [rdr (reader file-corpus :encoding "utf-8")]
-      (let [text (clojure.string/join "" (line-seq rdr))]
-        (.write wrtr (str (count text) " 32 2\n"))
-        (.write wrtr (gen-cases text))))))
+  (let [baos (java.io.ByteArrayOutputStream.)]
+    (with-open [wrtr (writer baos :encoding "utf-8")]
+      (with-open [rdr (reader file-corpus :encoding "utf-8")]
+        (doseq [line (line-seq rdr)]
+          (swap! counter add (count line))
+          (.write wrtr (gen-cases text)))))
+    (with-open [wrtr (writer file-output  :encoding "utf-8")]
+        (.write wrtr (str @counter " 32 2\n"))
+          (.write wrtr (toString baos "utf-8"))))))

 (defn prepare []
   (gen-train "data/corpus/corpus" "data/trains/train")


jump-stack.push should use given editor

jump-stack.push should use given editor

--- src/lt/objs/jump_stack.cljs
+++ src/lt/objs/jump_stack.cljs
@@ -18,7 +18,7 @@
            :triggers #{:jump-stack.push!}
            :reaction (fn [jump-stack editor file pos]
                        (let [old-file (:path (:info @editor))
-                             old-pos (editor/->cursor (lt.objs.editor.pool/last-active))]
+                             old-pos (editor/->cursor editor)]
                          (if-not (files/exists? file)
                            (notifos/set-msg! (str "Could not find file: " file) {:class "error"})
                            (do (jump-to file pos)


Slightly beef up docstrings and fix indentation

--- src/overtone/event.clj
+++ src/overtone/event.clj
@@ -28,33 +28,39 @@
      true)))

 (defn on-event
-  "Takes an event-type (name of the event) a key (to refer back to this handler in the future) and a handler fn.
-  Runs handler whenever events of type event-type are fired.  The handler can
-  optionally accept a single event argument, which is a map containing the
-  :event-type property and any other properties specified when it was fired.
+  "Takes an event-type (name of the event) a key (to refer back to this handler
+  in the future) and a handler fn. Runs handler whenever events of type event-
+  type are fired.  The handler can optionally accept a single event argument,
+  which is a map containing the :event-type property and any other properties
+  specified when it was fired.

   (on-event \"/tr\" ::status-check handler)
-  (on-event :midi-note-down ::midi-note-down-handler (fn [event] (funky-bass (:note event))))
+  (on-event :midi-note-down ::midi-note-down-hdlr (fn [event]
+                                                    (funky-bass (:note event))))

   Handlers can return :done to be removed from the handler list after execution."
   [event-type key handler]
   (on-event* event-handlers* event-type key handler))

 (defn on-sync-event
-  "Synchronously runs handler whenever events of type event-type are fired.  The handler can
-  optionally accept a single event argument, which is a map containing the
-  :event-type property and any other properties specified when it was fired."
+  "Synchronously runs handler whenever events of type event-type are fired.
+  The handler can optionally accept a single event argument, which is a map
+  containing the :event-type property and any other properties specified when it
+  was fired. If handler returns :done it will automatically be removed and will
+  therefore no longer respond to future matching events."
   [event-type key handler]
   (on-event* sync-event-handlers* event-type key handler))

 (defn remove-handler
   "Remove an event handler previously registered to handle events of event-type.
-   Removes both sync and async handlers with a given key for a particular event type
+   Removes both sync and async handlers with a given key for a particular event
+  type

   (defn my-foo-handler [event] (do-stuff (:val event)))

   (on-event ::foo my-foo-handler)
-  (event ::foo :val 200) ; my-foo-handler gets called with {:event-type ::foo :val 200}
+  (event ::foo :val 200) ; my-foo-handler gets called with:
+                         ; {:event-type ::foo :val 200}
   (remove-handler ::foo my-foo-handler)
   (event ::foo :val 200) ; my-foo-handler no longer called
   "


don't style active lines for now in idea animations

--- src/parinfer/core.cljs
+++ src/parinfer/core.cljs
@@ -30,8 +30,8 @@

   (create-editor! "code-idea-nest" :idea-nest)
   (create-editor! "code-idea-wide-nest" :idea-wide-nest)
-  (create-editor! "code-idea-deep-nest" :idea-deep-nest {:styleActiveLine true})
-  (create-editor! "code-idea-insert-delete" :idea-insert-delete {:styleActiveLine true})
+  (create-editor! "code-idea-deep-nest" :idea-deep-nest)
+  (create-editor! "code-idea-insert-delete" :idea-insert-delete)

   (create-editor! "code-cue-dim" :cue-dim)
   (create-editor! "code-cue-block" :cue-block)


re-org to fit with Ryan's Data

re-org to fit with Ryan's Data

--- src/yalp/cities.clj
+++ src/yalp/cities.clj
@@ -1,91 +1,78 @@
 (ns yalp.cities)

 (def cities
-  {"Charlottetown" 42602
-   "Hamilton" 670580
-   "Grande Prairie" 54913
-   "Shawinigan" 47735
-   "Saint-Hyacinthe" 48576
-   "Prince Albert" 35552
-   "Kitchener" 444681
-   "Fredericton" 61522
-   "Oshawa" 290937
-   "Brandon" 46061
-   "Georgetown" 40150
-   "Woodstock" 37362
-   "Orillia" 30586
-   "Guelph" 122362
-   "Vancouver" 2135201
-   "Sudbury" 106840
-   "Abbotsford" 149855
-   "Penticton" 36902
-   "Chilliwack" 66382
-   "Stratford" 30886
-   "Victoria" 316327
-   "St. Thomas" 41688
-   "Sherbrooke" 140628
-   "Medicine Hat" 65671
-   "Peterborough" 80660
-   "Rimouski" 37664
-   "Moncton" 107086
-   "Sault Ste. Marie" 67646
-   "Kingston" 117787
-   "Saint John" 95902
-   "Lethbridge" 83679
-   "St. Catharines - Niagara" 309319
-   "Chicoutimi - JonquiËre" 106666
-   "Windsor" 276165
-   "Regina" 192756
-   "Vernon" 44600
-   "Drummondville" 66314
-   "Winnipeg" 671551
-   "Courtenay" 40809
-   "Thunder Bay" 102222
-   "Sarnia" 79526
-   "Cape Breton - Sydney" 31597
-   "Toronto" 5132794
-   "Edmonton" 960015
-   "Calgary" 1095404
-   "Ch‚teaugua" 70812
-   "White Rock" 82368
-   "Fort McMurray" 61374
-   "Airdrie" 42564
-   "Timmins" 30614
-   "London" 366191
-   "Kanata" 101760
-   "Moose Jaw" 33617
-   "Milton" 75573
-   "Granby" 60281
-   "Chatham" 44074
-   "Brantford" 93650
-   "Sorel" 36969
-   "Midland" 31428
-   "Joliette" 42883
-   "Saskatoon" 222035
-   "QuÈbec" 696946
-   "Belleville" 63985
-   "Campbell River" 34514
-   "Red Deer" 90207
-   "MontrÈal" 3407963
-   "Leamington" 31254
-   "Ottawa - Gatineau" 697267
-   "Barrie" 166634
-   "Saint-JÈrÙme" 65825
-   "Orangeville" 30729
-   "Kelowna" 141767
-   "Bowmanville - Newcastle" 43555
-   "St. John's" 165346
-   "Cornwall" 49243
-   "Nanaimo" 88799
-   "Victoriaville" 41701
-   "Trois-RiviËres" 126460
-   "North Bay" 53515
-   "Saint-Jean-sur-Richelieu" 83053
-   "Halifax" 297943
-   "Salaberry-de-Valleyfield" 39391
-   "Beloeil" 50796
-   "Kamloops" 73472
-   "Prince George" 65503})
+  {"Abbotsford" {:population 149855}
+   "Barrie" {:population 166634}
+   "Belleville" {:population 63985}
+   "Brandon" {:population 46061}
+   "Brantford" {:population 93650}
+   "Calgary" {:population 1095404}
+   "Campbell River" {:population 34514}
+   "Cape Breton - Sydney" {:population 31597}
+   "Charlottetown" {:population 42602}
+   "Chatham" {:population 44074}
+   "Chilliwack" {:population 66382}
+   "Cornwall" {:population 49243}
+   "Courtenay" {:population 40809}
+   "Drummondville" {:population 66314}
+   "Edmonton" {:population 960015}
+   "Fredericton" {:population 61522}
+   "Granby" {:population 60281}
+   "Grande Prairie" {:population 54913}
+   "Guelph" {:population 122362}
+   "Halifax" {:population 297943}
+   "Hamilton" {:population 670580}
+   "Joliette" {:population 42883}
+   "Kamloops" {:population 73472}
+   "Kelowna" {:population 141767}
+   "Kingston" {:population 117787}
+   "Kitchener" {:population 444681}
+   "Leamington" {:population 31254}
+   "Lethbridge" {:population 83679}
+   "London" {:population 366191}
+   "Medicine Hat" {:population 65671}
+   "Midland" {:population 31428}
+   "Moncton" {:population 107086}
+   "MontrÈal" {:population 3407963}
+   "Moose Jaw" {:population 33617}
+   "Nanaimo" {:population 88799}
+   "North Bay" {:population 53515}
+   "Orillia" {:population 30586}
+   "Oshawa" {:population 290937}
+   "Ottawa - Gatineau" {:population 697267}
+   "Penticton" {:population 36902}
+   "Peterborough" {:population 80660}
+   "Prince Albert" {:population 35552}
+   "Prince George" {:population 65503}
+   "QuÈbec" {:population 696946}
+   "Red Deer" {:population 90207}
+   "Regina" {:population 192756}
+   "Rimouski" {:population 37664}
+   "Saint John" {:population 95902}
+   "Saint-Hyacinthe" {:population 48576}
+   "Saint-Jean-sur-Richelieu" {:population 83053}
+   "Salaberry-de-Valleyfield" {:population 39391}
+   "Sarnia" {:population 79526}
+   "Saskatoon" {:population 222035}
+   "Sault Ste. Marie" {:population 67646}
+   "Shawinigan" {:population 47735}
+   "Sherbrooke" {:population 140628}
+   "Sorel" {:population 36969}
+   "St. Catharines - Niagara" {:population 309319}
+   "St. John's" {:population 165346}
+   "Stratford" {:population 30886}
+   "Sudbury" {:population 106840}
+   "Thunder Bay" {:population 102222}
+   "Timmins" {:population 30614}
+   "Toronto" {:population 5132794}
+   "Trois-RiviËres" {:population 126460}
+   "Vancouver" {:population 2135201}
+   "Vernon" {:population 44600}
+   "Victoria" {:population 316327}
+   "Victoriaville" {:population 41701}
+   "Windsor" {:population 276165}
+   "Winnipeg" {:population 671551}
+   "Woodstock" {:population 37362}})

 (defn dist [x y]
   (Math/abs (- x y)))


Cosmetic.

Cosmetic.

--- test/onyx/log/complete_task_test.clj
+++ test/onyx/log/complete_task_test.clj
@@ -27,8 +27,6 @@
   (fact (rep-reactions old-replica new-replica diff {:id :b}) =>
         [{:fn :volunteer-for-task :args {:id :b}}])
   (fact (rep-reactions old-replica new-replica diff {:id :c}) => nil?))
-
-

 (def entry (create-log-entry :volunteer-for-task {:id :a}))


test - add teardown fixture to cleanup handlers

--- test/re_frame_http_fx/core_test.cljs
+++ test/re_frame_http_fx/core_test.cljs
@@ -1,7 +1,7 @@
 (ns re-frame-http-fx.core-test
   (:require
     [ajax.core     :as ajax]
-    [cljs.test     :refer-macros [is deftest async]]
+    [cljs.test     :refer-macros [is deftest async use-fixtures]]
     [cljs.spec     :as s]
     [re-frame.core :as re-frame]
     [re-frame-http-fx.core]))
@@ -10,8 +10,16 @@
 (s/def ::api-result
   (s/keys :req-un [::type ::issues_url ::url ::public_repos])) ;; loose spec

+;; ---- FIXTURES ---------------------------------------------------------------
+
+(defn teardown! []
+  ; cleanup up our handlers
+  (doseq [event [::http-test ::good-http-result ::bad-http-result]]
+    (re-frame/clear-event! event)))
+
+(use-fixtures :each {:after teardown!})
+
 ;; ---- TESTS ------------------------------------------------------------------
-

 (deftest xhrio-get
   ;; Setup effects handler with :http-xhrio specifying an ajax-request.


Set smaller riemann batch size

Set smaller riemann batch size

--- src/onyx_benchmark/peer.clj
+++ src/onyx_benchmark/peer.clj
@@ -64,7 +64,9 @@

         host-id (str (java.util.UUID/randomUUID))
         m-cfg (monitoring/monitoring-config 10000)
-        riemann-config {:riemann/address riemann-addr :riemann/port (Integer/parseInt riemann-port)}
+        riemann-config {:riemann/address riemann-addr
+                        :riemann/batch-size 5
+                        :riemann/port (Integer/parseInt riemann-port)}
         monitoring-thread (riemann/riemann-sender riemann-config (:monitoring/ch m-cfg))
         peers (onyx.api/start-peers n-peers-parsed peer-group m-cfg)]
     (<!! (chan))))


Tweak vintage-bass so that it's audible and use the amp param.

Fixes #262.

--- src/overtone/inst/synth.clj
+++ src/overtone/inst/synth.clj
@@ -233,17 +233,17 @@
     (* env bounced)))

 (definst vintage-bass
-  [note 40 velocity 80 t 0.6 amp 0.5 gate 1]
+  [note 40 velocity 80 t 0.6 amp 1 gate 1]
   (let [freq     (midicps note)
         sub-freq (midicps (- note 12))
         velocity (/ velocity 127.0)
-        sawz1    (* 0.075 (saw [freq freq]))
+        sawz1    (* 0.275 (saw [freq (* 1.01 freq)]))
         sawz2    (* 0.75 (saw [(- freq 2) (+ 1 freq)]))
         sqz      (* 0.3 (pulse [sub-freq (- sub-freq 1)]))
-        mixed    (* 0.1 (mix sawz1 sawz2 sqz))
+        mixed    (* 5 (+ sawz1 sawz2 sqz))
         env      (env-gen (adsr 0.1 3.3 0.4 0.8) gate :action FREE)
         filt     (* env (moog-ff mixed (* velocity env (+ freq 200)) 2.2))]
-    filt))
+    (* amp filt)))

 ; B3 modeled a church organ using additive synthesis of 9 sin oscillators
 ; * Octave under root


Add more tests.

Add more tests.

--- test/beebster_clj/core_test.clj
+++ test/beebster_clj/core_test.clj
@@ -67,8 +67,6 @@
 INFO: 1 Matching Programmes
 ")

-
-
 (deftest test-thumbs-from-string
   (testing "get thumbnail from string"
     (is (= "http://www.bbc.co.uk/iplayer/images/episode/b03bncr5_150_84.jpg"
@@ -86,3 +84,28 @@
     (is (= "The Bridge: Series 2 Episode 2"
            (second (get-title-and-episode test-list-1))))))

+(deftest test-get-index-from-search
+  (testing "return index from searchresult"
+    (is (= "915"
+           (first (get-index-from-search test-list-1))))
+    (is (= "920"
+           (last (get-index-from-search test-list-1))))))
+
+(deftest test-get-download-modes
+  (testing "get-download-modes with test-info-1"
+    (is (= '("flashhigh" "flashvhigh" "flashlow")
+           (get-download-modes (list test-info-1))))))
+
+(deftest test-get-url
+  (testing "get-url "
+    (is (= "/info?index=333"
+           (get-url "333")))
+    (is (= "/info?index=1"
+           (get-url "1")))))
+
+
+
+
+
+
+


Add test for block preference util function.

--- test/blocks/store/util_test.clj
+++ test/blocks/store/util_test.clj
@@ -1,5 +1,6 @@
 (ns blocks.store.util-test
   (:require
+    [blocks.core :as block]
     [blocks.store.util :as util]
     [clojure.test :refer :all]
     [multihash.core :as multihash]))
@@ -44,6 +45,18 @@
           "should return valid hex"))))

+(deftest block-preference
+  (is (nil? (util/preferred-copy nil))
+      "returns nil with no block arguments")
+  (let [literal (block/read! "foo")
+        lazy-a (block/from-file "project.clj")
+        lazy-b (block/from-file "README.md")]
+    (is (= literal (util/preferred-copy lazy-a literal lazy-b))
+        "returns literal block if present")
+    (is (= lazy-a (util/preferred-copy lazy-a lazy-b))
+        "returns first block if all lazy")))
+
+
 (deftest stat-selection
   (let [a (multihash/create :sha1 "37b51d194a7513e45b56f6524f2d51f200000000")
         b (multihash/create :sha1 "73fcffa4b7f6bb68e44cf984c85f6e888843d7f9")


Fix segment tests

Fix segment tests

--- test/cljc/reitit/impl_test.cljc
+++ test/cljc/reitit/impl_test.cljc
@@ -3,9 +3,9 @@
             [reitit.impl :as impl]))

 (deftest segments-test
-  (is (= ["" "api" "ipa" "beer" "craft" "bisse"]
+  (is (= ["api" "ipa" "beer" "craft" "bisse"]
          (into [] (impl/segments "/api/ipa/beer/craft/bisse"))))
-  (is (= ["" "a" "" "b" "" "c" ""]
+  (is (= ["a" "" "b" "" "c" ""]
          (into [] (impl/segments "/a//b//c/")))))

 (deftest strip-nils-test


add lazy-content test

add lazy-content test

--- test/misaki/test/controller.clj
+++ test/misaki/test/controller.clj
@@ -25,18 +25,22 @@
   (let [posts (sort-by-date (get-posts))]
     (are [x y] (= x y)
       3 (count posts)
-
+      ; title
       "bar" (-> posts first :title)
       "foo" (-> posts second :title)
       "baz" (-> posts last :title)
-
+      ; url
       "/2022-02/bar.html" (-> posts first :url)
       "/2011-01/foo.html" (-> posts second :url)
       "/2000-01/foo.html" (-> posts last :url)
-
+      ; tag
       '("tag1" "tag2") (->> posts first :tag (map :name))
       '("tag2" "tag3") (->> posts second :tag (map :name))
-      () (-> posts last :tag))))
+      () (-> posts last :tag)
+      ; content
+      "
bar
" (-> posts first :lazy-content force)
+      "
foo
" (-> posts second :lazy-content force)
+      "
baz
" (-> posts last :lazy-content force))))

 ;; Tags test
 (deftest* get-template-tag-test


Refine author splitting

Refine author splitting

--- src/qcast/infoq/scraper.clj
+++ src/qcast/infoq/scraper.clj
@@ -36,7 +36,7 @@
   (select [:head :title] inner-text dom))

 (defn- authors [dom]
-  (let [authors-split #(split % #"(\s*,\s*|\s*&\s*|\s+and\s+)")
+  (let [authors-split #(split % #"(\s*[,;&]\s*|\s+and\s+)")
         transformer #(some->> % inner-text authors-split (map trim))]
     (select [:.author_general :> :a] transformer dom)))


Fixed rendering of top banner

Fixed rendering of top banner

--- src/zg/html_renderer.clj
+++ src/zg/html_renderer.clj
@@ -8,7 +8,7 @@
     "Renders part of HTML page - the header."
     [package]
     [:head
-        [:title "zg   " package]
+        [:title "zg" package]
         [:meta {:name "Author"    :content "Pavel Tisnovsky"}]
         [:meta {:name "Generator" :content "Clojure"}]
         [:meta {:http-equiv "Content-type" :content "text/html; charset=utf-8"}]
@@ -50,15 +50,15 @@
     [:nav {:class "navbar navbar-inverse navbar-fixed-top" :role "navigation"}
         [:div {:class "container-fluid"}
             [:div {:class "row"}
-                [:div {:class "col-md-2"}
+                [:div {:class "col-md-1"}
                     [:div {:class "navbar-header"}
                         [:a {:href "/" :class "navbar-brand"} "zg"]
                     ] ; ./navbar-header
                 ] ; col ends
-                [:div {:class "col-md-4"}
+                [:div {:class "col-md-3"}
                     (render-search-field word)
                 ] ; col ends
-                [:div {:class "col-md-4"}
+                [:div {:class "col-md-3"}
                     [:div {:class "navbar-header"}
                         [:a {:href "/all-words" :class "navbar-brand"} "All words"]
                     ] ; ./navbar-header


Fix long lines.

Fix long lines.

--- src/afterglow/effects/oscillators.clj
+++ src/afterglow/effects/oscillators.clj
@@ -252,7 +252,8 @@
   (let [adjusted-phase (- phase 0.25)
         two-pi (* 2.0 Math/PI)]
     (fn [^afterglow.rhythm.MetronomeSnapshot snapshot]
-      (+ 0.5 (* 0.5 (Math/sin (* two-pi (adjust-phase (rhythm/snapshot-bar-phase snapshot bar-ratio) adjusted-phase))))))))
+      (+ 0.5 (* 0.5 (Math/sin (* two-pi (adjust-phase (rhythm/snapshot-bar-phase snapshot bar-ratio)
+                                                      adjusted-phase))))))))

 (defn sine-phrase
   "Returns an oscillator which generates a sine wave relative to the
@@ -269,4 +270,5 @@
   (let [adjusted-phase (- phase 0.25)
         two-pi (* 2.0 Math/PI)]
     (fn [^afterglow.rhythm.MetronomeSnapshot snapshot]
-      (+ 0.5 (* 0.5 (Math/sin (* two-pi (adjust-phase (rhythm/snapshot-phrase-phase snapshot phrase-ratio) adjusted-phase))))))))
+      (+ 0.5 (* 0.5 (Math/sin (* two-pi (adjust-phase (rhythm/snapshot-phrase-phase snapshot phrase-ratio)
+                                                      adjusted-phase))))))))


Add config/periodically-expire

Add config/periodically-expire

--- src/reimann/config.clj
+++ src/reimann/config.clj
@@ -36,6 +36,11 @@
   (dosync
     (ref-set (core :index) (apply reimann.index/index opts))))

+(defn periodically-expire
+  "Sets up a reaper for this core. See core API docs."
+  [interval]
+  (periodically-expire core interval))
+
 ; Start the core
 (defn start []
   (reimann.core/start core))


Bring back accidentally deleted display: none;

--- src/braid/client/ui/styles/pills.cljs
+++ src/braid/client/ui/styles/pills.cljs
@@ -16,7 +16,8 @@

    [:.card
     (mixins/box-shadow)
-    {:position "absolute"
+    {:display "none"
+     :position "absolute"
      :z-index 5000
      :background "white"
      :min-width (em 15)


Bump the revision

Bump the revision

--- src/circle/backend/project/circle.clj
+++ src/circle/backend/project/circle.clj
@@ -28,7 +28,7 @@
           :type :deploy
           :vcs-type :git
           :vcs-url "git@github.com:arohner/CircleCI.git"
-          :vcs-revision "382279b1bd282f06a5aac1cbf5454cd7c997e45f"
+          :vcs-revision "00ff90391645b949a4a63b88e2b6fc1f1badf8a5"
           :num-nodes 1
           :lb-name "www"
           :group circle/circle-group


Duplicate keys fixed.

Duplicate keys fixed.

--- src/clj/elephantdb/common/example.clj
+++ src/clj/elephantdb/common/example.clj
@@ -33,9 +33,9 @@
                   :status <status-atom>
                   :domain-data <data-atom>
                   :current-version 12356456324
-                  :all-versions #{{:id 12356456324, :status :open
-                                   :id 123235324,    :status :downloading
-                                   :id 1234534123,   :status :ready}}}
+                  :all-versions #{{:id 12356456324, :status :open}
+                                  {:id 123235324,    :status :downloading}
+                                  {:id 1234534123,   :status :ready}}}
    ;; or this, for all-versions
    "other-domain" {:shard-index {:hosts-to-shards <map>
                                  :shards-to-hosts <map>}
@@ -44,8 +44,6 @@
                    :current-version 12356456324
                    :all-versions {123235324 {:status :downloading}
                                   1234534123 {:status :ready}}}}
-
-

   (load-version! example-db "domain" 123235324)
   ;; returns domain status on completion; triggers swaps on remote
@@ -88,9 +86,9 @@
                               :remote-handle "remote-fs-handle"
                               :domain-data <data-atom>
                               :current-version 12356456324
-                              :all-versions #{{:id 12356456324, :status :open
-                                               :id 123235324,    :status :downloading
-                                               :id 1234534123,   :status :ready}}}
+                              :all-versions #{{:id 12356456324, :status :open}
+                                              {:id 123235324,   :status :downloading}
+                                              {:id 1234534123,  :status :ready}}}
                ;; or this, for all-versions
                "other-domain" {:shard-index {:hosts-to-shards <map>
                                              :shards-to-hosts <map>}


semi-working version

semi-working version

--- src/cljs/omnext_routing_one/core.cljs
+++ src/cljs/omnext_routing_one/core.cljs
@@ -96,8 +96,9 @@
   (render [this]
           (apply dom/ul nil
                  (map (fn [country]
-                        (dom/li nil country)
+                        (dom/li nil (:name country))
                         )
+                      (:countries (om/props this))
                       )
                  )
           )
@@ -205,15 +206,23 @@
 ;; Components

 (defui RootView
-  ;static om/IQueryParams
-  ;(params [_]
-  ;        initial-params ; here and below, we're passing (pre-computed) value
-  ;                       ; and not doing function calls
-  ;  )
+  static om/IQueryParams
+  (params [_]
+          ;initial-params ; here and below, we're passing (pre-computed) value
+          ;               ; and not doing function calls
+          (merge {}
+         (:params (get-query-and-params-by-parsed-url tabs (parse-url-hash
+                                               js/window.location.hash
+                                               )))
+                 )
+    )

   static om/IQuery
   (query [_]
-         initial-query
+         ;initial-query
+         (with-meta (:query (get-query-and-params-by-parsed-url tabs (parse-url-hash
+                                               js/window.location.hash
+                                               ))) nil)
     )

   Object
@@ -355,6 +364,7 @@
         "..."
         (om/get-query
           reconciler)
+        (om/query RootView)
         )
       )
     )


fix gallery modal

fix gallery modal

--- src/cljs/salava/gallery/ui/modal.cljs
+++ src/cljs/salava/gallery/ui/modal.cljs
@@ -33,17 +33,12 @@
         selected-language (cursor state [:content-language])
         {:keys [name description tags alignment criteria_content image_file image_file issuer_content_id issuer_content_name issuer_content_url issuer_contact issuer_image issuer_description criteria_url creator_content_id creator_name creator_url creator_email creator_image creator_description message_count]} (content-setter @selected-language content)
         tags (tag-parser tags)]
-    [:div
-     [:div.col-xs-12
-      [:div.pull-right
-       [follow-badge badge_id]]]
+    [:div#gallery-modal
+     [bm/follow-verified-bar badge "gallery" @show-messages]
      [:div {:id "badge-contents"}
-      [:div {:class "pull-right text-right"}]
-      (if (or verified_by_obf issued_by_obf)
-        (bh/issued-by-obf obf_url verified_by_obf issued_by_obf))
-      [:div.row
+      [:div.row.flip
        [:div {:class "col-md-3 badge-image modal-left"}
-        [:img {:src (str "/" image_file)}]
+        [:div.badge-image [:img {:src (str "/" image_file)}]]
         (when (> average_rating 0)
           [:div.rating
            [r/rate-it average_rating]
@@ -53,10 +48,9 @@
         [:div
          [gallery-modal-message-info-link show-messages badge_id]]

-        (bm/badge-endorsement-modal-link badge_id endorsement_count)]
+        (when-not @show-messages (bm/badge-endorsement-modal-link badge_id endorsement_count))]

        [:div {:class "col-md-9 badge-info"}
-        (content-language-selector selected-language content)
         (if @show-messages
           [:div.rowmessage
            [:h1.uppercase-header (str name " - " (t :social/Messages))]
@@ -65,23 +59,23 @@
           [:div.rowcontent
            [:h1.uppercase-header name]
            [:div
-            #_(bh/issuer-label-image-link issuer_content_name issuer_content_url issuer_description issuer_contact issuer_image issuer-endorsements)
-            #_(bh/creator-label-image-link creator_name creator_url creator_description creator_email creator_image)
+            (if (< 1 (count content))
+              [:div.inline [:label (t :core/Languages)": "](content-language-selector selected-language content)])
             (bm/issuer-modal-link issuer_content_id issuer_content_name)
             (bm/creator-modal-link creator_content_id creator_name)
             [:div.row
              [:div {:class "col-md-12 description"}
               description]]

-           (when-not (empty? alignment)
-             [:div.row
-              [:div.col-md-12
-               [:h2.uppercase-header (t :badge/Alignments)]
-               (doall
-                 (map (fn [{:keys [name url description]}]
-                        [:p {:key url}
-                         [:a {:target "_blank" :rel "noopener noreferrer" :href url} name] [:br] description])
-                      alignment))]])
+            (when-not (empty? alignment)
+              [:div.row
+               [:div.col-md-12
+                [:h2.uppercase-header (t :badge/Alignments)]
+                (doall
+                  (map (fn [{:keys [name url description]}]
+                         [:p {:key url}
+                          [:a {:target "_blank" :rel "noopener noreferrer" :href url} name] [:br] description])
+                       alignment))]])

             [:div.row
              [:div {:class "col-md-12 badge-info"}
@@ -121,13 +115,13 @@

 (defn init-data [badge-id state]
   (ajax/GET
-     (path-for (str "/obpv1/gallery/public_badge_content/" badge-id) true)
-     {:handler (fn [data]
-                 (reset! state (assoc data
-                                      :permission "success"
-                                      :reload-fn (:reload-fn @state)
-                                      :content-language (init-content-language  (get-in data [:badge :content])))))}
-     (fn [] (swap! state assoc :permission "error")))
+    (path-for (str "/obpv1/gallery/public_badge_content/" badge-id) true)
+    {:handler (fn [data]
+                (reset! state (assoc data
+                                :permission "success"
+                                :reload-fn (:reload-fn @state)
+                                :content-language (init-content-language  (get-in data [:badge :content])))))}
+    (fn [] (swap! state assoc :permission "error")))
   )

 (defn handler [params]


Handle new indenting level default of 0 (not 1)

--- src/day8/re_frame_10x/view/event.cljs
+++ src/day8/re_frame_10x/view/event.cljs
@@ -166,8 +166,8 @@
                      ^{:key id}
                      [rc/v-box
                       :class    "code-fragment"
-                      :style    {:margin-left (str (* 9 (dec (:indent-level frag))) "px")
-                                 :margin-top  (when (pos? id) "-1px")}
+                      :style {:margin-left (str (* 9 (:indent-level frag)) "px")
+                              :margin-top  (when (pos? id) "-1px")}
                       :attr     {:on-mouse-enter (handler-fn #_(println "OVER:" (:id frag)) (rf/dispatch [:code/hover-form (:form frag)]))
                                  :on-mouse-leave (handler-fn #_(println " OUT:" (:id frag)) (rf/dispatch [:code/exit-hover-form (:form frag)]))}
                       :children [[code-header code-exec-id frag]


Upgrade to lein-ring 0.8.5

Upgrade to lein-ring 0.8.5

--- src/leiningen/new/cljskel/project.clj
+++ src/leiningen/new/cljskel/project.clj
@@ -31,7 +31,7 @@
                    :plugins [[lein-rpm "0.0.4"]
                              [lein-midje "3.0-alpha4"]
                              [jonase/kibit "0.0.4"]]}}
-  :plugins [[lein-ring "0.7.3"]
+  :plugins [[lein-ring "0.8.5"]
             [lein-environ "0.4.0"]
             [lein-release "1.0.73"]]

@@ -56,7 +56,8 @@
   :ring {:handler {{name}}.web/app
          :main {{name}}.setup
          :port ~(Integer.  (get (System/getenv) "SERVICE_PORT" "3000"))
-         :init {{name}}.setup/setup}
+         :init {{name}}.setup/setup
+         :browser-uri "/1.x/status"}

   :repositories {"internal-clojars"
                  "http://clojars.brislabs.com/repo"


bumped up cryogen-markdown

bumped up cryogen-markdown

--- src/leiningen/new/cryogen/project.clj
+++ src/leiningen/new/cryogen/project.clj
@@ -7,7 +7,7 @@
                            [ring/ring-devel "1.4.0"]
                            [compojure "1.5.0"]
                            [ring-server "0.4.0"]
-                           [cryogen-markdown "0.1.2"]
+                           [cryogen-markdown "0.1.3"]
                            [cryogen-core "0.1.39"]]
             :plugins [[lein-ring "0.9.7"]]
             :main cryogen.core


stripped video decoding, made it (more) functional.

--- src/sormilla/video.clj
+++ src/sormilla/video.clj
@@ -15,27 +15,13 @@

 ; (set! *warn-on-reflection* true)

-(def INBUF_SIZE 65535)
-(def inbuf-int (int-array (+ INBUF_SIZE MpegEncContext/FF_INPUT_BUFFER_PADDING_SIZE)))
-(def avpkt (doto (AVPacket.) (.av_init_packet)))
-(def codec (H264Decoder.))
-(def context ^MpegEncContext (MpegEncContext/avcodec_alloc_context))
-(def picture (AVFrame/avcodec_alloc_frame))
+;;
+;; I/O
+;;

-(if-not (zero? (bit-and (.capabilities codec) H264Decoder/CODEC_CAP_TRUNCATED))
-  (throw (Exception. "need to configure CODEC_FLAG_TRUNCATED")))
-(if (< (.avcodec_open context codec) 0)
-  (throw (Exception. "Could not open codec")))
-
-
-
-
-
-
-(defn read-input [^InputStream in size]
-  (let [b (byte-array size)]
-    (IOUtils/readFully in b)
-    b))
+(defn read-input [^InputStream in buffer size]
+  (IOUtils/readFully in buffer 0 size)
+  buffer)

 (defn skip-input [^InputStream in size]
   (.skip in size)
@@ -46,6 +32,90 @@
     (.write (byte-array (map bin/ubyte [1 0 0 0])))
     (.flush)))

+;;
+;; Video stream parsing
+;;
+
+(defn signature [header]    (bin/get-int header 0))
+(defn header-size [header]  (bin/get-short header 6))
+(defn payload-size [header] (bin/get-int header 8))
+
+
+;;
+;; Video decoding
+;;
+
+(defn ba->ia [^bytes source ^ints target]
+  (doseq [i (range (count source))]
+    (aset-int target i (bit-and 0xFF (nth source i))))
+  target)
+
+(defn buffer->image [w h buffer]
+  (let [image (BufferedImage. w h BufferedImage/TYPE_INT_RGB)]
+    (.setRGB image 0 0 w h buffer 0 w)
+    image))
+
+(defn make-decoder []
+  (let [codec           (H264Decoder.)
+        context         (MpegEncContext/avcodec_alloc_context)
+        packet          (AVPacket.)
+        frame           (AVFrame/avcodec_alloc_frame)
+        image-buffer    (byte-array (+ 65535 MpegEncContext/FF_INPUT_BUFFER_PADDING_SIZE))
+        ibuffer         (int-array (+ 65535 MpegEncContext/FF_INPUT_BUFFER_PADDING_SIZE))
+        got-picture?    (int-array [0])
+        header-buffer   (byte-array 12)]
+
+    (if-not (zero? (bit-and (.capabilities codec) H264Decoder/CODEC_CAP_TRUNCATED)) (throw (Exception. "need to configure CODEC_FLAG_TRUNCATED")))
+    (if (neg? (.avcodec_open context codec)) (throw (Exception. "Could not open codec")))
+    (.av_init_packet packet)
+
+    (fn [in]
+      (let [header       (read-input in header-buffer 12)
+            header-size  (header-size header)
+            image-size   (payload-size header)]
+
+        (when-not (= (signature header) 0x45566150) (throw (Exception. "out of sync")))
+        (skip-input in (- header-size 12))
+        (read-input in image-buffer image-size)
+
+        (set! (.size packet) image-size)
+        (set! (.data_base packet) (ba->ia image-buffer ibuffer)) ; FIXME: size
+        (set! (.data_offset packet) 0)
+
+        (.avcodec_decode_video2 context frame got-picture? packet)
+        (when (zero? (first got-picture?)) (throw (Exception. "Could not decode frame")))
+
+        (let [picture (.displayPicture (.priv_data context))
+              width (.imageWidth picture)
+              height (.imageHeight picture)
+              picture-buffer (int-array (* width height))]
+          (FrameUtils/YUV2RGB picture picture-buffer)
+          (buffer->image width height picture-buffer))))))
+
+(defn update-image [img]
+  (ImageIO/write img "png" (io/file "image.png")))
+
+
+(defn parse-file []
+  (let [in (io/input-stream (io/file "capture.h264"))
+        decoder (make-decoder)]
+    (try
+      (doseq [i (range 10)]
+        (ImageIO/write (decoder in) "png" (io/file (str "image-" i ".png"))))
+      (println "success!")
+      (catch Exception e
+        (println "failure" e)
+        (.printStackTrace e))
+      (finally
+        (try (.close in) (catch Exception e))))))
+
+
+(comment
+
+  (parse-file)
+
+  ; ffmpeg -f h264 -an -i capture.h264 stream.m4v
+
 (defn capture []
   (let [socket (doto (Socket.)
                  (.setSoTimeout 2000)
@@ -65,61 +135,9 @@
         (try (.close socket) (catch Exception e))
         (try (.close out) (catch Exception e))))))

-(comment
   (comm/send-commands! [(comm/video-codec :h264-360p) (comm/video-frame-rate 15) comm/leds-active])
   (capture)
   (comm/send-commands! [comm/leds-reset])
-  )
-
-
-
-
-
-
-
-
-
-
-(defn update-image [img]
-  (ImageIO/write img "png" (io/file "image.png")))
-
-
-
-
-
-
-
-(defn parse-header [data]
-  {:sig                  (bin/get-int    data   0)
-   ; :version            (bin/get-byte   data   4)
-   ; :codec              (bin/get-byte   data   5)
-   :header-size          (bin/get-short  data   6)
-   :payload-size         (bin/get-int    data   8)})
-
-(defn ba->ia [^bytes source ^ints target]
-  (doseq [i (range (count source))]
-    (aset-int target i (bit-and 0xFF (nth source i))))
-  target)
-
-(defn decode! [context picture avpkt b]
-  (let [got-picture? (int-array [0])]
-    (set! (.size avpkt) (count b))
-    (set! (.data_base avpkt) (ba->ia b inbuf-int))
-    (set! (.data_offset avpkt) 0)
-    (.avcodec_decode_video2 context picture got-picture? avpkt)
-    (when (zero? (first got-picture?)) (throw (Exception. "Could not decode frame")))))
-
-(defn buffer->image [w h buffer]
-  (let [image (BufferedImage. w h BufferedImage/TYPE_INT_RGB)]
-    (.setRGB image 0 0 w h buffer 0 w)
-    image))
-
-(defn frame->image [frame]
-  (decode! context picture avpkt frame)
-  (let [p (.displayPicture (.priv_data context))
-        buffer (int-array (* (.imageHeight p) (.imageWidth p)))]
-    (FrameUtils/YUV2RGB p buffer)
-    (buffer->image (.imageWidth p) (.imageHeight p) buffer)))

 (defn parse-file []
   (let [in (io/input-stream (io/file "capture.h264"))]
@@ -138,8 +156,8 @@
         (.printStackTrace e))
       (finally
         (try (.close in) (catch Exception e))))))
-
-(parse-file)
+
+)

 #_(doseq [n (range 100)]
           (let [header-data  (read-input in 68)


fix: point to value of remote state

fix: point to value of remote state

--- src/terraboot/core.clj
+++ src/terraboot/core.clj
@@ -434,4 +434,4 @@
                   :endpoint (get s3-endpoints region)}}))

 (defn remote-output-of [module name]
-  (clojure.string/join "." ["data"  "terraform_remote_state" module name]))
+  (str "${" (clojure.string/join "." ["data"  "terraform_remote_state" module name]) "}"))


adds correlation ids to k8s api requests and scheduler logs (#1560)

--- waiter/src/waiter/correlation_id.clj
+++ waiter/src/waiter/correlation_id.clj
@@ -120,8 +120,11 @@
   "Replaces instances of `PatternLayout` in appenders with instance of `CidEnhancedPatternLayout`."
   []
   (let [logger (Logger/getRootLogger)
-        appenders (.getAllAppenders logger)]
-    (doseq [^Appender appender (seq (Collections/list appenders))]
+        scheduler-logger (Logger/getLogger "Scheduler")
+        scheduler-appender (some-> scheduler-logger (.getAppender "SchedulerAppender"))
+        appenders (cond-> (seq (Collections/list (.getAllAppenders logger)))
+                    scheduler-appender (conj scheduler-appender))]
+    (doseq [^Appender appender appenders]
       (let [layout (.getLayout ^Appender appender)]
         (when (instance? PatternLayout layout)
           (println "Replacing the layout in" (.getName appender) (.getClass appender))


Add small sleep on fixtures function calls.

Just for make the created_at fields to be populated
with very different timestamp on each insert.

--- src/uxbox/fixtures.clj
+++ src/uxbox/fixtures.clj
@@ -41,6 +41,7 @@

 (defn- create-project
   [conn i ui]
+  (Thread/sleep 20)
   (println "create project" i "for user" ui)
   (sproj/create-project conn
                         {:id (mk-uuid "project" i)
@@ -49,6 +50,7 @@

 (defn- create-page
   [conn i pi ui]
+  (Thread/sleep 20)
   (println "create page" i "for user" ui "for project" pi)
   (spag/create-page conn
                     {:id (mk-uuid "page" i)


Test speed up using filter

Test speed up using filter

--- src/wlmmap/handler.clj
+++ src/wlmmap/handler.clj
@@ -41,30 +41,29 @@
   "return a string with the javascript code to generate addressPoints."
   [params]
   (let [mons (take 5000 (wcar* (car/smembers "frfrim")))
-        all (remove #(nil? %)
-                    (for [m mons]
-                      (let [res (read-string (wcar* (car/get m)))
-                            lat (:lat res)
-                            lon (:lon res)
-                            reg (:registrant_url res)
-                            id (:id res)
-                            nam (cleanup-name (:name res))
-                            imc (:image res)
-                            img (codec/url-encode imc)
-                            lng (:lang res)
-                            emb (str "")
-                            ilk (if (not (= imc ""))
-                                  (str "" emb "") "")
-                            art (:monument_article res)
-                            arl (format "%s" lng art art)
-                            src (format "Source: %s" reg id)]
-                        (when (and lat lon nam)
-                          (format "[%s,%s,\"%s\",\"%s\"]" lat lon nam
-                                  (str "
" nam "
"
-                                       ilk "
" (if art (str arl "
") "")
-                                       src "
"))))))]
+        all (for [m (filter #(:lat %) mons)]
+              (let [res (read-string (wcar* (car/get m)))
+                    lat (:lat res)
+                    lon (:lon res)
+                    reg (:registrant_url res)
+                    id (:id res)
+                    nam (cleanup-name (:name res))
+                    imc (:image res)
+                    img (codec/url-encode imc)
+                    lng (:lang res)
+                    emb (str "")
+                    ilk (if (not (= imc ""))
+                          (str "" emb "") "")
+                    art (:monument_article res)
+                    arl (format "%s" lng art art)
+                    src (format "Source: %s" reg id)]
+                (when (and lat lon nam)
+                  (format "[%s,%s,\"%s\",\"%s\"]" lat lon nam
+                          (str "
" nam "
"
+                               ilk "
" (if art (str arl "
") "")
+                               src "
")))))]
     (str "var addressPoints = [" (str/join "," all) "];")))

 (defn- index [params]


Unit tests for get-highlight-coords

Unit tests for get-highlight-coords

Former-commit-id: 0d636cd781a2a90152295b3dd4a05e8c21bdb122

--- planck-cljs/test/planck/repl_test.cljs
+++ planck-cljs/test/planck/repl_test.cljs
@@ -2,6 +2,15 @@
   (:require [cljs.test :refer-macros [deftest testing is]]
             [planck.repl]))

-(deftest a-test
-  (testing "Stub passing test"
-    (is (= 0 0))))
+(deftest get-highlight-coords
+  (testing "Highlight coordinates"
+    (is (= [0 0] (js->clj (planck.repl/get-highlight-coords 1 "[]" []))))
+    (is (= [0 1] (js->clj (planck.repl/get-highlight-coords 2 "[[]]" []))))
+    (is (= [0 0] (js->clj (planck.repl/get-highlight-coords 3 "[()]" []))))
+    (is (= [0 1] (js->clj (planck.repl/get-highlight-coords 2 " []" []))))
+    (is (= [1 0] (js->clj (planck.repl/get-highlight-coords 1 "]" ["["]))))
+    (is (= [2 0] (js->clj (planck.repl/get-highlight-coords 1 "]" ["[" ""]))))
+    (is (= [1 0] (js->clj (planck.repl/get-highlight-coords 1 "]" ["[" "["]))))
+    (is (= [2 0] (js->clj (planck.repl/get-highlight-coords 1 "]" ["[" "[]"]))))
+    (is (= [0 1] (js->clj (planck.repl/get-highlight-coords 2 "#{}" []))))
+    (is (= [0 0] (js->clj (planck.repl/get-highlight-coords 4 "[\"[\"]" []))))))


Repair error: extra character before commit

--- src/test_utils/sandbox.cljc
+++ src/test_utils/sandbox.cljc
@@ -416,7 +416,7 @@
      (if (= length-unit :ft)
        [:ft typical-location-in-ft]
        [:m (vec (map (convert-units-f :ft :m) typical-location-in-ft))]))))
-l
+
 (defn rand-well-reference-frame-xy []
   (rand-nth [:project :well-head :absolute-state-plane]))


Access-Control-Allow-Methods should be uppercase

--- src/yada/access_control.clj
+++ src/yada/access_control.clj
@@ -4,6 +4,7 @@
   (:require
    [byte-streams :as b]
    [manifold.deferred :as d]
+   [clojure.string :as str]
    [clojure.tools.logging :refer :all]
    [clojure.data.codec.base64 :as base64]
    [ring.middleware.basic-authentication :as ba]))
@@ -102,7 +103,7 @@

         (:allow-methods access-control)
         (assoc-in [:response :headers "access-control-allow-methods"]
-                  (to-header (call-fn-maybe (:allow-methods access-control) ctx)))
+                  (to-header (map (comp str/upper-case name) (call-fn-maybe (:allow-methods access-control) ctx))))

         (:allow-headers access-control)
         (assoc-in [:response :headers "access-control-allow-headers"]