code cleanup

code cleanup

--- src/metabase/sample_data/generate.clj
+++ src/metabase/sample_data/generate.clj
@@ -249,24 +249,19 @@
       (assoc person :orders (vec (repeatedly num-orders #(random-order person (rand-nth products))))))))

 (defn create-random-data [& {:keys [people products]
-                             :or   {people 2500 products 125}}]
+                             :or   {people 2500 products 200}}]
   {:post [(map? %)
           (= (count (:people %)) people)
           (= (count (:products %)) products)
           (every? keyword? (keys %))
           (every? sequential? (vals %))]}
   (println (format "Generating random data: %d people, %d products..." people products))
-  (let [people   (create-randoms people random-person)
-        products (mapv product-add-reviews (create-randoms products random-product))
-        reviews  (vec (mapcat :reviews products))
-        products (mapv #(dissoc % :reviews) products)
-        people   (mapv (partial person-add-orders products) people)
-        orders   (vec (mapcat :orders people))
-        people   (mapv #(dissoc % :orders) people)]
-    {:people   people
-     :products products
-     :reviews  reviews
-     :orders   orders}))
+  (let [products (mapv product-add-reviews (create-randoms products random-product))
+        people   (mapv (partial person-add-orders products) (create-randoms people random-person))]
+    {:people   (mapv #(dissoc % :orders) people)
+     :products (mapv #(dissoc % :reviews) products)
+     :reviews  (vec (mapcat :reviews products))
+     :orders   (vec (mapcat :orders people))}))

 ;;; # LOADING THE DATA


copyright update

copyright update

--- src/norman_sicily_static/partials.clj
+++ src/norman_sicily_static/partials.clj
@@ -30,7 +30,7 @@
      [:div {:class="col-12-xs"}
       [:div {:class "footer-links"}
        [:p
-        "© 2015 - 2017 by Dawn Marie Hayes and Joseph Hayes. All Rights Reserved."
+        "© 2015 - 2018 by Dawn Marie Hayes and Joseph Hayes. All Rights Reserved."

         [:div {:id "license"}
          [:a {:rel "license" :href "http://creativecommons.org/licenses/by-nc-sa/4.0/"} [:img {:alt "Creative Commons License" :style "border-width:0;padding-bottom:10px" :src "https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"}]] [:br ] "This " [:span {:xmlns:dct "http://purl.org/dc/terms/" :href "http://purl.org/dc/dcmitype/StillImage" :rel "dct:type"} "work"] " by " [:a {:xmlns:cc "http://creativecommons.org/ns#" :href "normansicily.org" :property "cc:attributionName" :rel "cc:attributionURL"} "Dawn Marie Hayes, Ph.D. and Joseph Hayes "] "is licensed under a" [:a {:rel "license" :href "http://creativecommons.org/licenses/by-nc-sa/4.0/"} "  Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"]]]]]]]])


add log-width and logo-height as optional keys to the company representation

--- src/open_company/resources/common.clj
+++ src/open_company/resources/common.clj
@@ -115,6 +115,8 @@
           }
           (schema/optional-key :home-page) schema/Str
           (schema/optional-key :logo) schema/Str
+          (schema/optional-key :logo-width) schema/Int
+          (schema/optional-key :logo-height) schema/Int
           (schema/optional-key :created-at) schema/Str
           (schema/optional-key :updated-at) schema/Str}
         InlineSections))


Add function doc

Add function doc

--- src/lazy_map/core.clj
+++ src/lazy_map/core.clj
@@ -14,5 +14,7 @@
           (.write w ", "))
         (.write w "...}")))))

-(definline lazy-map [seed fun]
-  `(LazyMap. ~seed ~fun))
+(definline lazy-map
+  "Creates a lazy map with the given seed map and loader function."
+  [seed loader]
+  `(LazyMap. ~seed ~loader))


emacs-centric fix by moving cursor reversion into hide!

--- src/lt/objs/find.cljs
+++ src/lt/objs/find.cljs
@@ -71,8 +71,12 @@

 (behavior ::hide!
           :triggers #{:hide!}
-          :reaction (fn [this]
+          :reaction (fn [this revert-pos]
                       (when-let [ed (pool/last-active)]
+                        (when revert-pos
+                          (when-let [pos (:pos @this)]
+                            (editor/move-cursor ed pos)))
+
                             (editor/focus ed))))

 (behavior ::next!
@@ -123,11 +127,12 @@
           :triggers #{:search!}
           :debounce 50
           :reaction (fn [this v]
+                      (.log js/console "search!" v)
                       (if (empty? v)
                         (object/raise this :clear!)
                         (when-let [e (pool/last-active)]
-                          (when-let [pos (:pos @this)]
-                            (editor/move-cursor e pos))
+;;                           (when-let [pos (:pos @this)]
+;;                             (editor/move-cursor e pos))
                           (object/merge! this {:searching? true})
                           (object/merge! e {:searching.for v})
                           (let [ed (editor/->cm-ed e)]
@@ -181,8 +186,8 @@

 (cmd/command {:command :find.hide
               :desc "Find: Hide the find bar"
-              :exec (fn []
-                      (object/raise bar :hide!))})
+              :exec (fn [revert-pos]
+                      (object/raise bar :hide! revert-pos))})

 (cmd/command {:command :find.next
               :desc "Find: Next find result"


(maint) Flush cli messages; send errors to stderr

Flush cli-error and cli-help messages in main before System/exit, since
the JVM doesn't necessarily flush on exit, and redirect cli-error messages
to stderr, to follow the normal command-line convention.

--- src/puppetlabs/trapperkeeper/core.clj
+++ src/puppetlabs/trapperkeeper/core.clj
@@ -155,16 +155,17 @@
   [& args]
   {:pre [((some-fn sequential? nil?) args)
          (every? string? args)]}
-  (try+
-    (-> (or args '())
-        (internal/parse-cli-args!)
-        (run))
-    (catch map? m
-      (case (without-ns (:type m))
-        :cli-error ((println (:message m))
-                    (System/exit 1))
-        :cli-help ((println (:message m))
-                   (System/exit 0))
-        (throw+ m)))
-    (finally
-      (shutdown-agents))))
+  (let [quit (fn [status msg stream]
+               (binding [*out* stream] (println msg) (flush))
+               (System/exit status))]
+    (try+
+     (-> (or args '())
+         (internal/parse-cli-args!)
+         (run))
+     (catch map? m
+       (case (without-ns (:type m))
+         :cli-error (quit 1 (:message m) *err*)
+         :cli-help (quit 0 (:message m) *out*)
+         (throw+ m)))
+     (finally
+       (shutdown-agents)))))


don't send invite-sent chat until after it sent

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -206,8 +206,8 @@
             cid (client-uuid->uuid client-uuid)]
         (log/infof "%s sending an email to %s on doc %s" (:cust/email cust) email doc-id)
         (try
+          (email/send-chat-invite {:cust cust :to-email email :doc-id doc-id})
           (send-chat "Invite sent!")
-          (email/send-chat-invite {:cust cust :to-email email :doc-id doc-id})
           (catch Exception e
             (log/error e)
             (.printStackTrace e)


move the reply after the transaction

move the reply after the transaction

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -448,8 +448,6 @@
         rejects (remove (comp (partial datomic2/whitelisted? access-scope)
                               pcd/datom->transaction)
                         datoms)]
-    (when ?reply-fn
-      (?reply-fn {:rejected-datoms rejects}))
     (log/infof "transacting %s datoms (minus %s rejects) on %s for %s" (count datoms) (count rejects) document-id client-id)
     (datomic2/transact! datoms
                         {:document-id document-id
@@ -458,7 +456,9 @@
                          :cust-uuid cust-uuid
                          :frontend-id-seed (get-in @document-subs [document-id client-id :frontend-id-seed])
                          :session-uuid (UUID/fromString (get-in req [:ring-req :session :sente-id]))
-                         :timestamp (:receive-instant req)})))
+                         :timestamp (:receive-instant req)})
+    (when ?reply-fn
+      (?reply-fn {:rejected-datoms rejects}))))

 (defmethod ws-handler :frontend/mouse-position [{:keys [client-id ?data] :as req}]
   (check-document-access (-> ?data :document/id) req :read)


Don't remove entities/world when disposing the world

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -82,12 +82,9 @@
      :entities entities
      :options options
      :show (fn []
-             ; if using a physics engine in a REPL, we need to forcibly remove
-             ; the entities and world so they are cleaned up properly
-             (when (:world @screen)
-               (update-screen! @screen (reset! entities []))
-               (some-> @screen :world :object .dispose)
-               (update-fn! dissoc [:world]))
+             ; if using a physics engine in a REPL, we need to forcibly dispose
+             ; the world so it is cleaned up properly
+             (some-> @screen :world :object .dispose)
              ; set the initial values in the screen map
              (update-fn! assoc
                          [:total-time 0


Improved pretty-printing.

Improved pretty-printing.

--- src/promesa/core.cljc
+++ src/promesa/core.cljc
@@ -78,9 +78,9 @@
      (-repr [it]
        (str "#<Promise ["
             (cond
-              (p/-pending? it) "pending"
-              (p/-rejected? it) "rejected"
-              :else "resolved")
+              (p/-pending? it) "~"
+              (p/-rejected? it) (str "error=" (m/extract it))
+              :else (str "value=" (m/extract it)))
             "]>"))

      mp/Extract
@@ -114,9 +114,9 @@
      (-repr [it]
        (str "#<Promise ["
             (cond
-              (p/-pending? it) "pending"
-              (p/-rejected? it) "rejected"
-              :else "resolved")
+              (p/-pending? it) "~"
+              (p/-rejected? it) (str "error=" (m/extract it))
+              :else (str "value=" (m/extract it)))
             "]>"))

      mp/Extract


Fix inputs losing focus on change due to random react keys.

--- src/reforms/core.cljs
+++ src/reforms/core.cljs
@@ -62,8 +62,7 @@
        (panel {:class \"my-special-panel\"} \"My special panel\" :close #(js/alert \"closed\")
            [:div \"Contents go here\"])"
   [& args]
-  (let [[attrs [title & rest-args]] (impl/resolve-args [:panel] {:class "panel panel-default"
-                                                                 :key   (gen-key)} args)
+  (let [[attrs [title & rest-args]] (impl/resolve-args [:panel] {:class "panel panel-default"} args)
         [{:keys [close]} & contents] (impl/parse-options rest-args)]
     [:div attrs
      [:div {:class "panel-heading"
@@ -96,8 +95,7 @@
   [& args]
   (let [[attrs & elems] (impl/resolve-args [:form]
                                            {:on-submit #(.preventDefault %)
-                                            :class     (when (impl/form-horizontal?) "form-horizontal")
-                                            :key       (gen-key)}
+                                            :class     (when (impl/form-horizontal?) "form-horizontal")}
                                            args)]
     [:form attrs
      elems
@@ -117,8 +115,7 @@
    - title - the title; a string or Hiccup/Sablono style template
    - tag   - (optional) name of the tag to use, e.g. :h4"
   [& args]
-  (let [[attrs [title & {:keys [tag]}]] (impl/resolve-args [:group-title] {:class "group-title"
-                                                                           :key   (gen-key)} args)]
+  (let [[attrs [title & {:keys [tag]}]] (impl/resolve-args [:group-title] {:class "group-title"} args)]
     [(or tag (get-options [:group-title :tag]))
      attrs
      title]))
@@ -139,7 +136,7 @@
    - :valid?               - (optional) if false shows a validation error; internal
    - :validation-error-fn  - (optional) lambda <korks> -> <error message>; internal"
   [type & args]
-  (let [[attrs [label placeholder cursor korks & opts]] (impl/resolve-args [:html5-input type] {:key (gen-key)} args)]
+  (let [[attrs [label placeholder cursor korks & opts]] (impl/resolve-args [:html5-input type] {} args)]
     (apply impl/html5-input* attrs label placeholder cursor korks (name type) opts)))

 (defn text


Fixed render fn, since renderComponentToString is no longer async.

--- src/sablono/core.cljx
+++ src/sablono/core.cljx
@@ -64,9 +64,7 @@
 (defn render
   "Render the React `component` as an HTML string."
   [component]
-  (let [html (atom nil)]
-    (.renderComponentToString js/React component #(reset! html %))
-    (deref html)))
+  (.renderComponentToString js/React component))

 (defn include-css
   "Include a list of external stylesheet files."


Fixed seq in couple nodes

Fixed seq in couple nodes

--- src/tango/export2.clj
+++ src/tango/export2.clj
@@ -161,7 +161,7 @@
                 :Round "Awsome3"
                 :AdjQty adj-qty
                 :D3 "0"}
-               (make-couple-node (first result-array) 666 3 3)))
+               (reduce #(conj %1 (make-couple-node %2 (count %1) 666 adj-qty)) [] result-array)))

 (defn fix-class [class class-result]
   (clojure.walk/postwalk


use newer version

use newer version

--- server/project.clj
+++ server/project.clj
@@ -7,7 +7,7 @@

   :dependencies [[org.clojure/clojure "1.5.1"]
                  [org.clojure/clojure-contrib "1.2.0"]
-                 [com.datomic/datomic-free "0.8.3862"]
+                 [com.datomic/datomic-free "0.8.3889"]
                  [environ "0.4.0"]
                  [ring "1.1.8"]
                  [ring-middleware-format "0.3.0"]


fixed a bug, everything is damn slow, i need to figure out when the slowdown was introduced

--- src/blind/reader.clj
+++ src/blind/reader.clj
@@ -104,8 +104,9 @@
 (defn- numeric?
   "Checks whether a given character is numeric"
   [^Character ch]
-  (Character/isDigit ch))
-
+  (if ch
+    (Character/isDigit ch)))
+
 (defn- comment-prefix?
   "Checks whether the character begins a comment."
   [ch]
@@ -432,8 +433,8 @@
           (reader-error rdr "Invalid token:" token)))))

 (defn- resolve-ns [sym]
-  (or (find-ns sym)
-      ((ns-aliases *ns*) sym)))
+  (or ((ns-aliases *ns*) sym)
+      (find-ns sym)))

 (defn read-keyword
   [reader initch]
@@ -672,7 +673,7 @@
           (symbol (.getName ^Class o))
           (if (instance? Var o)
             (symbol (-> ^Var o .ns .name name) (-> ^Var o .sym name))))
-        (symbol (.name *ns*) (name s))))))
+        (symbol (name (.name *ns*)) (name s))))))

 (defn syntax-quote [form]
   (cond
@@ -851,15 +852,3 @@
   "Reads one object from the string s"
   [s]
   (read (string-push-back-reader s) true nil false))
-
-(comment
- (def l (slurp "/home/bronsa/src/clojure/src/clj/clojure/core.clj"))
-
- (defn bench [] (let [pl (pbr l)] (loop [r (read pl true nil true)]
-                                    (if r (recur (try (read pl true nil true)
-                                                      (catch Exception _)))))))
-
- (defn bench- [] (let [pl (java.io.PushbackReader. (java.io.StringReader. l))]
-                   (loop [r (clojure.core/read pl true nil true)]
-                     (if r (recur (try (clojure.core/read pl true nil true)
-                                       (catch Exception _))))))))


Make the tests pass

Make the tests pass

--- src/caesium/util.clj
+++ src/caesium/util.clj
@@ -12,3 +12,12 @@

 (defn hexify [b]
   (.encode Encoder/HEX b))
+
+(defn n->bytes
+  "Turns n into a byte array of length len."
+  [len n]
+  (let [unpadded (.toByteArray (biginteger n))
+        bytelen (alength unpadded)
+        output (byte-array len)]
+    (System/arraycopy unpadded 0 output (- noncebytes bytelen) bytelen)
+    output))


Added support for hg.

Added support for hg.

--- src/cake/project.clj
+++ src/cake/project.clj
@@ -5,7 +5,8 @@
         [uncle.core :only [fileset-seq]]
         [clojure.string :only [join trim-newline]]
         [clojure.java.shell :only [sh]]
-        [cake.utils.useful :only [update merge-in tap]])
+        [cake.utils.useful :only [update merge-in tap]]
+        [clojure.java.io :only [reader]])
   (:import [java.io File]))

 (defn- make-url [file]
@@ -131,6 +132,9 @@
 (defmethod get-version :git [_]
   (:out (sh "git" "describe" "--tags")))

+(defmethod get-version :hg [_]
+  (-> ".hgtags" reader line-seq last (.split " ") last))
+
 (defmethod get-version :default [r]
   (println "No pre-defined get-version method for that key."))


allow project.classpath to contain wildcards for jars

--- src/cake/project.clj
+++ src/cake/project.clj
@@ -12,12 +12,18 @@
 (defn- make-url [file]
   (str "file:" (.getPath file) (if (.isDirectory file) "/" "")))

+(defn- path-files [paths]
+  (mapcat (fn [path]
+            (if-let [[_ path] (re-matches #"(.*)/\*" path)]
+              (fileset-seq {:dir path :includes "*.jar"})
+              [(file path)]))
+          (absorb paths (split (re-pattern File/pathSeparator)))))
+
 (defn classpath []
   (map make-url
-       (concat (map file (into [(System/getProperty "bake.path")
-                                "src/" "src/clj/" "classes/" "resources/" "dev/" "test/" "test/classes/"]
-                               (absorb (get *config* "project.classpath")
-                                       (split (re-pattern File/pathSeparator)))))
+       (concat (map file [(System/getProperty "bake.path")
+                          "src/" "src/clj/" "classes/" "resources/" "dev/" "test/" "test/classes/"])
+               (path-files (get *config* "project.classpath"))
                (fileset-seq {:dir (file "lib")            :includes "*.jar"})
                (fileset-seq {:dir (file "lib/dev")        :includes "*.jar"})
                (fileset-seq {:dir (global-file "lib/dev") :includes "*.jar"}))))


anglicizes 0 to 99

anglicizes 0 to 99

--- src/clj_app/core.clj
+++ src/clj_app/core.clj
@@ -19,21 +19,20 @@
 (def tens     {20 "twenty", 30 "thirty",  40 "fourty", 50 "fifty",
                60 "sixty" , 70 "seventy", 80 "eighty", 90 "ninety"})

-(conj [] (tens (count-tens 22)) (zero-to-nineteen 2))

 (defn count-tens [n]
   (* (int (/ n 10)) 10))
-
-(count-tens 30)

 (defn count-hundreds [n]
   (* (int (/ n 100))) 100)

 (defn get-n-after-decimal-point [n]
+
   " Get .00 digits,
     up to 2 decimal places? :("
-  (int
-   (* ;; make it a whole number
+
+  (int ;; make it a whole number
+   (*
      (read-string ;; make it a number again
        (format "0%s"
                (first (rest (re-find #"\d+(\.\d{1,2})?" (str n)))))) 100)))
@@ -41,11 +40,15 @@
 (get-n-after-decimal-point 2.10) ;; => 10
 (get-n-after-decimal-point 2.01) ;; => 1

-(defn digit-parser [x & [power]]
+
+(defn single-digit-parser [x & [power]]
   (let [p (or power 10)]
   (rem x (or power 10))))

-(digit-parser 12)
+(single-digit-parser 12)
+
+(defn super-n-formater [n] ;; naming is hard ? :?
+  (apply str (conj [] (tens (count-tens n)) "-" (zero-to-nineteen (single-digit-parser n)))))

 (defn amount [n]

@@ -56,14 +59,14 @@
          answer (if (not (number? n)) :not-a-number
                  (if (rational? n)
                    ((fn [r] ;; rational
-                      (
+                      (let
                         [tens-fiter (and (>= r 20) (<= r 99))
                          hundreds-filter (and (>= r 100) (<= r 999))])
                         (cond
                          (<= r 19) (zero-to-nineteen r)
                          (and (zero? (mod n 10)) 'tens-fiter)  (tens (count-tens n))
                          (and (zero? (mod n 100)) 'hundreds-filter) (tens (count-tens n))
-                         ;;'(tens-fiter) "tes"
+                         '(tens-fiter) (super-n-formater r)
                         )) n)
                     ((fn [i] ;; irrational
                        :irrational
@@ -72,10 +75,11 @@
       (println answer)

       (when (not= answer :not-a-number)
-        (str
-          (format "%s dollars :: %d" answer n)))))
+        (if (= answer "one")
+        (str (format "%s dollar :: %d" answer n)) ;; the singular case
+        (str (format "%s dollars :: %d" answer n)))))) ;; the plural case

-(amount 20)
+(amount 1)


extract peaks helper

extract peaks helper

--- src/clojure/core.clj
+++ src/clojure/core.clj
@@ -162,6 +162,16 @@
       (xtract/delete_double_array windowed)
       spectrum)))

+(defn extract-peaks
+  "Extract the amplitude and frequency of spectral peaks from a magnitude spectrum"
+  [coefficients block-size sample-ratio peak-threshold]
+  (let [peaks (c-double block-size)]
+    (xtract/xtract_peak_spectrum coefficients
+                                 (/ block-size 2)
+                                 (xtract-args sample-ratio peak-threshold)
+                                 peaks)
+    peaks))
+
 (defn raise-errors [result]
     (cond
       (= result xtract-success)        true
@@ -226,82 +236,77 @@
                       midi     (if (> f0 0.0)
                                  (Integer/parseInt (format "%.0f" (/ cents 100)))
                                  0)
-                      peaks    (c-double block-size)
-
-                      spectrum (extract-fft-spectrum wav-data block-size SAMPLE_RATE full-window)]
-
-                  (xtract/xtract_peak_spectrum spectrum
-                                               half-block-size
-                                               (xtract-args SAMPLE_RATE_RATIO 10.0 0.0 0.0)
-                                               peaks)
-
-                  (let [rms                   (double-array [0])
-                        spectral-irregularity (double-array [0])
-                        spectral-centroid     (double-array [0])
-                        spectral-variance     (double-array [0])
-
-                        ;;TODO
-                        noiseness             (double-array [0])
-                        loudness              (double-array [0])
-                        tonality              (double-array [0])
-
-                        spectral-inharmonicity (spectral-inharmonicity
-                                                peaks block-size
-                                                f0 0.5 NUM_HARMONICS 0)]
-
-                    (xtract/xtract_rms_amplitude wav-data block-size (xtract-args SAMPLE_RATE_RATIO) rms)
-
-                    (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid)
-                    (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity)
-
-                    (let [spectral-skewness      (double-array [0])
-                          spectral-std-deviation (double-array [0])
-                          spectral-mean          (double-array [0])
-                          spectral-kurtosis      (double-array [0])]
-
-                      (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean)
-                      (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance)
-                      (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation)
-
-                      (let [argv (xtract-args (first spectral-mean) (first spectral-std-deviation))]
-                        (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness)
-                        (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis))
-
-                      ;;(xtract/xtract_noisiness     wav-data block-size (xtract-args NUM_HARMONICS ) noiseness)
-
-                      (let [_ 10
-                            ;;bark-cofficents (clojure->c-double (range 0 xtract-bark-bands))
-                            ]
-
-                        ;;(xtract/xtract_bark_coefficients spectrum half-block-size (xtract-args ) bark-cofficents)
-                        ;;(xtract/xtract_loudness      wav-data block-size (apply xtract-args argv) loudness)
-                        )
+
+                      spectrum (extract-fft-spectrum wav-data block-size SAMPLE_RATE full-window)
+                      peaks (extract-peaks spectrum block-size SAMPLE_RATE_RATIO 10.0)
+
+                      rms                   (double-array [0])
+                      spectral-irregularity (double-array [0])
+                      spectral-centroid     (double-array [0])
+                      spectral-variance     (double-array [0])

                       ;;TODO
-                      ;;(xtract/xtract_tonality      wav-data block-size (xtract-args ) tonality)
-
-                      ;;TODO: More memory, probably slower... Re-using variables faster but sad
-                      (xtract/delete_double_array wav-data)
-                      (xtract/delete_double_array spectrum)
-                      (xtract/delete_double_array peaks)
-
-                      {
-                       (format "%.6f" (/  (* idx half-block-size) SAMPLE_RATE))
-
-                       {:spectral-inharmonicity spectral-inharmonicity
-                        :spectral-irregularity  (first spectral-irregularity)
-                        :spectral-centroid      (first spectral-centroid)
-                        :spectral-skewness      (first spectral-skewness)
-                        :spectral-kurtosis      (first spectral-kurtosis)
-                        :rms-amplitude          (first rms)
-
-                        :todo {:noisiness (first noiseness)
-                               :loudness (first loudness)
-                               :tonality (first tonality)}
-                        :midi midi
-                        :f0 f0}
-                       }
-                      ))))
+                      noiseness             (double-array [0])
+                      loudness              (double-array [0])
+                      tonality              (double-array [0])
+
+                      spectral-inharmonicity (spectral-inharmonicity
+                                              peaks block-size
+                                              f0 0.5 NUM_HARMONICS 0)]
+
+                  (xtract/xtract_rms_amplitude wav-data block-size (xtract-args SAMPLE_RATE_RATIO) rms)
+
+                  (xtract/xtract_spectral_centroid spectrum block-size (xtract-args 0.0) spectral-centroid)
+                  (xtract/xtract_irregularity_j    spectrum half-block-size nil spectral-irregularity)
+
+                  (let [spectral-skewness      (double-array [0])
+                        spectral-std-deviation (double-array [0])
+                        spectral-mean          (double-array [0])
+                        spectral-kurtosis      (double-array [0])]
+
+                    (xtract/xtract_spectral_mean spectrum block-size nil spectral-mean)
+                    (xtract/xtract_variance spectrum block-size (xtract-args (first spectral-mean)) spectral-variance)
+                    (xtract/xtract_spectral_standard_deviation spectrum block-size (xtract-args (first spectral-variance)) spectral-std-deviation)
+
+                    (let [argv (xtract-args (first spectral-mean) (first spectral-std-deviation))]
+                      (xtract/xtract_spectral_skewness spectrum block-size argv spectral-skewness)
+                      (xtract/xtract_spectral_kurtosis spectrum block-size argv spectral-kurtosis))
+
+                    ;;(xtract/xtract_noisiness     wav-data block-size (xtract-args NUM_HARMONICS ) noiseness)
+
+                    (let [_ 10
+                          ;;bark-cofficents (clojure->c-double (range 0 xtract-bark-bands))
+                          ]
+
+                      ;;(xtract/xtract_bark_coefficients spectrum half-block-size (xtract-args ) bark-cofficents)
+                      ;;(xtract/xtract_loudness      wav-data block-size (apply xtract-args argv) loudness)
+                      )
+
+                    ;;TODO
+                    ;;(xtract/xtract_tonality      wav-data block-size (xtract-args ) tonality)
+
+                    ;;TODO: More memory, probably slower... Re-using variables faster but sad
+                    (xtract/delete_double_array wav-data)
+                    (xtract/delete_double_array spectrum)
+                    (xtract/delete_double_array peaks)
+
+                    {
+                     (format "%.6f" (/  (* idx half-block-size) SAMPLE_RATE))
+
+                     {:spectral-inharmonicity spectral-inharmonicity
+                      :spectral-irregularity  (first spectral-irregularity)
+                      :spectral-centroid      (first spectral-centroid)
+                      :spectral-skewness      (first spectral-skewness)
+                      :spectral-kurtosis      (first spectral-kurtosis)
+                      :rms-amplitude          (first rms)
+
+                      :todo {:noisiness (first noiseness)
+                             :loudness (first loudness)
+                             :tonality (first tonality)}
+                      :midi midi
+                      :f0 f0}
+                     }
+                    )))
               data)]

          (xtract/xtract_free_window full-window)


Removed unneeded index from percentiles calculation

--- src/engulf/utils.clj
+++ src/engulf/utils.clj
@@ -36,8 +36,8 @@
   [coll]
   (let [len   (count coll)
         partn (if (>= len 100) (int (/ len 100)) 1)]
-    (map-indexed
-     (fn [idx group]
+    (map
+     (fn [group]
        {:min (first group)
         :max (last group)
         :median (median group)


fix file name

fix file name

--- src/fileape/core.clj
+++ src/fileape/core.clj
@@ -60,10 +60,9 @@
     "Create the filename that would be written once the file has been rolled"
     [f i]
     (let [^File file (clojure.java.io/file f)]
-      (.getParent file
-                  ^String (add-file-name-index
-                           (clj-str/join "" (interpose "_" (-> (.getName file) (clj-str/split #"_") drop-last)))
-                           i))))
+      (str
+       (.getParent file) "/" (add-file-name-index
+                              (clj-str/join "" (interpose "_" (-> (.getName file) (clj-str/split #"_") drop-last))) i))))

   (defn create-file-data
     "Create a file and return a map with keys file codec file-key out,


Update schema to support bytea, mime-type

--- src/doctopus/db/schema.clj
+++ src/doctopus/db/schema.clj
@@ -42,6 +42,8 @@
   [[:name "varchar(50)" "PRIMARY KEY"]
    [:uri "varchar(100) NOT NULL"]
    [:body :text "NOT NULL"]
+   [:mime_type "varchar(127) NOT NULL"] ;; Max length according to RFC http://tools.ietf.org/html/rfc4288#section-4.2
+   [:image "bytea"]
    [:search_vector "tsvector"]
    [:tentacle_name "varchar(50) references tentacles(name) on delete cascade"]
    [:created :timestamp "NOT NULL DEFAULT NOW()"]


Instead of #to_time, clojurize using #strftime

This should work better with other classes representing time/date.

--- src/zweikopf/core.clj
+++ src/zweikopf/core.clj
@@ -106,7 +106,11 @@
   (clojurize [this]
     (condp #(call-ruby %2 respond_to? %1) this
       "to_hash" (clojurize (call-ruby this to_hash))
-      "to_time" (clojurize (call-ruby this to_time))))
+      "strftime" (-> this
+                     (call-ruby strftime "%s")
+                     (call-ruby to_i)
+                     (* 1000)
+                     java.util.Date.)))

   java.lang.Object
   (clojurize [this] this))


help page update

help page update

--- src/cljs/netrunner/help.cljs
+++ src/cljs/netrunner/help.cljs
@@ -58,7 +58,7 @@
                         [:li [:code "/deck #n"] " - Put card number n from your hand on top of your deck"]
                         [:li [:code "/end-run"] " - End the run (Corp only)"]
                         [:li [:code "/jack-out"] " - Jack out (Runner only)"]
-                        [:li [:code "/trace n"] " - Start trace with base strength n (Corp only)"]
+                        [:li [:code "/trace n"] " - Start a trace with base strength n (Corp only)"]
                         [:li [:code "/psi"] " - Start a Psi game (Corp only)"]
                         [:li [:code "/close-prompt"] " - close an active prompt and show the next waiting prompt, or the core click actions"]
                         [:li [:code "/counter n"] " - set counters on a card to n (player's own cards only)"]
@@ -123,6 +123,22 @@
              :title "How do I send a private message / add someone to friendlist?"
              :content [:p "The community management issues such as private messages or friendlist are currently not implemented. "
                        "They are planned, but no specific date is set, as all of our code is written by volunteers."]}
+            {:id "competitive"
+             :title "What is the point of the \"Competitive\" room in lobby? How does it differ from \"Casual\"?"
+             :content (list [:p "Different rooms in lobby are meant to help people with similar expectations about the game find each other. "
+                             "In general, competitive room is for games with players intending to play competitively. "
+                             "This may mean something different to each of them... However, since it's a non-default room, "
+                             "going there and creating or joining a game usually isn't accidental and is a declaration of some kind of competitive intent."]
+                            [:p "Some recommendations for playing in the competitive room:"
+                             [:ul
+                              [:li "a decent knowledge of the game's rules"]
+                              [:li "familiarity with the site's interface"]
+                              [:li "a " [:span.legal "tournament legal"] " deck"]
+                              [:li "enough time reserved for a full game and no distractions"]]]
+                            [:p "Games with players not able or willing to follow above recommendations are propably better suited to the Casual room."
+                             "Some examples could be learning the game, learning the site's interface, testing a completely new and crazy deck idea, "
+                             "testing future spoilers, playing at work and likely to have to quit on short notice, etc."])}
+
             )}
     {:id "cards"
      :title "Cards and Specific Interactions"
@@ -142,7 +158,7 @@
                        "put one copy of each directive in the deck in addition to your normal deck. Yes, that means that "
                        "minimal Adam decksize on Jinteki.net is 48."]}
             {:id "napdmwl"
-             :title "What is MWL? Why is my deck marked as \"Casual play only\"?"
+             :title "What is MWL and \"Tournament legal\"? Why is my deck marked as \"Casual play only\"?"
              :content (list
                         [:p "New Angeles Police Department Most Wanted List, also known as NAPD MWL or just MWL, is a list "
                          "of restricted cards introduced by FFG to tournament play. Each of the cards on the list reduces "
@@ -155,11 +171,11 @@
                         [:p "Putting cards in your deck that are not yet available for sale (i.e. future spoilers) or ones that are "
                          "out of competitive rotation will also result in your deck being marked as " [:span.casual "Casual play only"] ". Such cards "
                          "should be easy to identify - they are " [:span.casual "highlighted"] " in the deckbuilder."])}
-            {:id "rezaccess"
-             :title "How do I rez cards as Corp in the 4.3 run timing window?"
-             :content [:p "Sadly, this window is currently unimplemented - you need to ask the Runner manually. "
-                       "See " [:a {:href "https://github.com/mtgred/netrunner/issues/334"} "the discussion on GitHub"]
-                       " about this issue."]}
+            {:id "altarts"
+             :title "How do I change my decks to use alternative art versions of cards (or promotional ones)?"
+             :content [:p "Alternative art cards are enabled for the " [:a {:href "#donations"} "donators"] " and "
+                       [:a {:href "#devs"} "developers"] " of the site. If you belong to one of the aforementioned groups and you feel like you should have them enabled, "
+                       "but you don't, " [:a {:href "/about"} "contact us"] "."]}
              )}
     {:id "troubleshooting"
      :title "Troubleshooting"


adding insert support

adding insert support

--- src/gce/provider.clj
+++ src/gce/provider.clj
@@ -30,26 +30,31 @@
          (.setHttpRequestInitializer (.createScoped auth scopes))
          (.build))))

+(defn instances [compute]
+  (-> compute (.instances)))
+
 (defn list-instances [compute project zone]
-  (let [items (get (-> compute (.instances) (.list project zone) (.execute)) "items")]
+  (let [items (get (-> (instances compute) (.list project zone) (.execute)) "items")]
     (map clojure.walk/keywordize-keys items)))

-(defn create-instance [spec]
-  (.fromString (JacksonFactory/getDefaultInstance) (write-str spec) Instance))
+(defn create-instance [compute gce {:keys [project-id zone] :as spec}]
+  (let [instance (.fromString (JacksonFactory/getDefaultInstance) (write-str gce) Instance)]
+    (-> (instances compute) (.insert project-id zone instance))
+    ))

 (defmacro with-id [& body])

-(defrecord GCEInstance [spec system-id]
+(defrecord GCEInstance [compute gce spec]
   Vm
   (create [this]
-    (let [{:keys [id] :as instance} (create-instance spec) ]
+    (let [{:keys [id] :as instance} (create-instance gce) ]
      (debug "created" id)
-     (s/partial-system system-id {:gce {:id id}})
+     (s/partial-system (spec :system-id) {:gce {:id id}})
       this))

   (start [this]
     (with-id
-      (let [{:keys [machine]} (s/get-system (system :system-id))]
+      (let [{:keys [machine]} (s/get-system (spec :system-id))]
         (when-not (= "running" (.status this))
           )
         (wait-for-ssh (machine :ip) "root" [5 :minute]))
@@ -81,21 +86,17 @@
   "Construcuting machine transformations"
    {:image (fn [os] (:image ((os->template :gce) os)))})

-(defmethod translate :gce [{:keys [machine gce] :as spec}]
+(defmethod translate :gce [{:keys [machine gce] :as spec} system-id]
     "Convert the general model into a gce instance"
-    (-> (merge machine gce)
+    (-> (merge machine gce {:system-id system-id})
       (mappings {:os :image})
       (transform (machine-ts machine))
-      into-gce
+      ((juxt into-gce (select-keys [:system-id :project-id])))
     ))

 (defn validate [spec &]
   (validate-provider spec) spec)

 (defmethod vconstruct :gce [{:keys [system-id] :as spec}]
-  (apply ->GCEInstance [(validate (translate spec)) system-id]))
+  (apply ->GCEInstance [(build-compute "") (validate (translate spec)) system-id]))

-
-#_(let [compute (build-compute "/home/ronen/small-cell-vagrant.json")]
-  (clojure.pprint/pprint (first (list-vms compute "714167917779" "europe-west1-d")))
- )


items can now be edited

items can now be edited

--- src/eatme/client/main.cljs
+++ src/eatme/client/main.cljs
@@ -93,6 +93,8 @@

 (def item-deleted (pubsub/publishize (fn [row-id] {:row-id row-id}) bus))

+(def item-edited (pubsub/publishize (fn [row-id] {:row-id row-id}) bus))
+
 (def basket-loaded (pubsub/publishize identity bus))

 (defn add-item-to-list [the-list item]
@@ -102,6 +104,7 @@
     (let [item-row (d/single-node (css/sel (str "#" row-id)))]
       (gestures/on-swipe [:left :right] item-row #(item-deleted row-id))
       (event/listen-once! (css/sel item-row "button[rel=delete-item]") :click #(item-deleted row-id))
+      (event/listen-once! (css/sel item-row "button[rel=edit-item]") :click #(item-edited row-id))
       (if (= :list (keyword (:state item)))
         (event/listen-once! (css/sel item-row "button[rel=complete]") :click #(completed-item row-id))
         (d/add-class! (css/sel item-row "button[rel=complete]") "btn-success")))))
@@ -244,6 +247,11 @@
   (d/set-value! item-name-field "")
   (d/set-value! item-qty-field 1))

+(defn fill-item-input [{:keys [row-id]}]
+  (let [item (css/sel (str "#" row-id))]
+    (d/set-value! item-name-field (d/attr item "data-name"))
+    (d/set-value! item-qty-field (d/attr item "data-qty"))))
+
 (defn log-to-console [event o]
   (js/console.log event ": " o))

@@ -278,6 +286,11 @@
 (pubsub/subscribe bus item-deleted remove-item-from-list)
 (pubsub/subscribe bus item-deleted mark-basket-unsaved!)

+(pubsub/subscribe bus item-edited fill-item-input)
+(pubsub/subscribe bus item-edited remove-item-from-list)
+(pubsub/subscribe bus item-edited mark-basket-unsaved!)
+(pubsub/subscribe bus item-edited focus-item-input)
+
 (pubsub/subscribe bus quantity-changed change-quantity)
 (pubsub/subscribe bus quantity-changed mark-basket-unsaved!)


New lein version makes standalone-repl no longer required.

--- opt/profiles.clj
+++ opt/profiles.clj
@@ -2,8 +2,7 @@
                   ;; TODO: re-enable once clojars releases repo is up
                   ;; "clojars" "http://s3pository.herokuapp.com/clojars"
                   }
-        :aliases {"repl" "standalone-repl"}
-        :plugins [[lein-standalone-repl "0.1.4"]]}}
+        :aliases {"repl" ["with-profile" "production" "trampoline" "repl"]}}
  :production {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central"
                         ;; "clojars" "http://s3pository.herokuapp.com/clojars"
                         }


Back to standalone-repl plugin until 2.1.3.

--- opt/profiles.clj
+++ opt/profiles.clj
@@ -2,9 +2,8 @@
                   ;; TODO: re-enable once clojars releases repo is up
                   ;; "clojars" "http://s3pository.herokuapp.com/clojars"
                   }
-        :aliases {"repl" ["update-in" ":dependencies" "conj" "[reply \"0.1.6\"]" "--"
-                          "with-profile" "production" "trampoline" "run" "-m"
-                          "reply.main/launch-standalone" "nil"]}}
+        :aliases {"repl" "standalone-repl"}
+        :plugins [[lein-standalone-repl "0.1.5"]]}
  :production {:mirrors {"central" "http://s3pository.herokuapp.com/maven-central"
                         ;; "clojars" "http://s3pository.herokuapp.com/clojars"
                         }


spectator in game chat

spectator in game chat

--- src/cljs/netrunner/gameboard.cljs
+++ src/cljs/netrunner/gameboard.cljs
@@ -73,7 +73,7 @@
         text (.-value input)
         $div (js/$ ".gameboard .messages")]
     (when-not (empty? text)
-      (send-command "say" {:text text})
+      (send-command "say" {:user (:user @app-state) :text text})
       (.scrollTop $div (+ (.prop $div "scrollHeight") 500))
       (aset input "value" "")
       (.focus input))))


Add schema for an atom

Add schema for an atom

--- src/com/frereth/common/schema.clj
+++ src/com/frereth/common/schema.clj
@@ -6,6 +6,7 @@
   (:import [java.util Date]))

 (def async-channel (class (async/chan)))
+(def atom-type (class (atom nil)))
 (def java-byte-array mq/byte-array-class)
 (def korks
   "I hated this name the first few times I ran across it in argument lists.


Document api/read-related

Document api/read-related

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -110,8 +110,12 @@
   dispatch)

 (defmulti read-related
-  "Returns a sequence of things representing symbols related to this or prior
-  versions of the given symbol."
+  "Succeeds with a result Seq[Def] being the sequence of Things \"related\"
+  according to the documentation writer to the Thing for which related entities
+  was requested.
+
+  As of 0.6.X, this operation is only defined over Defs, however future versions
+  of this API may extend this operation to other types."

   {:arglists '[[config thing]]}
   dispatch)


got rid of frequency guessing stuff

got rid of frequency guessing stuff

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -43,31 +43,31 @@
     (map vec word-seq) ))

 (defn num-rows
-  "Given a 2D array (seq of seqs), return the number of rows (1st dimension)."
-  [word-array]
-  (count word-array) )
+  "Given a list of words (seq of seqs), return the number of rows (1st dimension)."
+  [word-list]
+  (count word-list) )

 (defn num-cols
-  "Given a 2D array (seq of seqs), return the number of columns (2nd dimension)."
-  [word-array]
-  (count (first word-array)) )
+  "Given a list of words (seq of seqs), return the number of columns (2nd dimension)."
+  [word-list]
+  (count (first word-list)) )

 (defn get-array-col
-  "Given a 2D array (seq of seqs), return a vector of elements
+  "Given a list of words (seq of seqs), return a vector of elements
   from the specified column."
-  [word-seq col-idx]
-  { :pre  [ (vector? word-seq) (integer? col-idx) ]
+  [word-list col-idx]
+  { :pre  [ (integer? col-idx) ]
     :post [] }
   (reduce #(conj %1 (nth %2 col-idx))
-          [] word-seq ) )
+          [] word-list ) )

 (defn get-array-row
-  "Given a 2D array (vector of vectors), return a vector of elements
+  "Given a list of words (seq of seqs), return a vector of elements
   from the specified row."
-  [word-array row-idx]
+  [word-list row-idx]
   { :pre  [ (integer? row-idx) ]
     :post [] }
-  (nth word-array row-idx) )
+  (nth word-list row-idx) )

 (defn filter-with-idx
   "Returns values from data-seq where corresponding pred-seq elements are truthy.


Escape HTML in markdown output

Escape HTML in markdown output

The code doesn't account for html that's already within backticks
because that doesn't actually happen in any of the fact docs (yet).
That's definitely something to add.

--- src/extracter/markdown.clj
+++ src/extracter/markdown.clj
@@ -1,5 +1,11 @@
 (ns extracter.markdown
   (:require [clojure.string :as s]))
+
+(defn html-escape
+  [md]
+  (s/escape md {\> ">"
+                \< "<"
+                \& "&"}))

 (defn bullet
   "Given a collection of strings (assumed to be the body of a section),
@@ -10,10 +16,16 @@
     (mapv (partial str "* ") body)
     body))

+(defn body-preprocess
+  [body]
+  (->> body
+       (map html-escape)
+       bullet))
+
 (defn section->md
   [{:keys [body heading]}]
   (when (not (empty? body))
-    [(format "**%s**:" heading) "" (bullet body) ""]))
+    [(format "**%s**:" heading) "" (body-preprocess body) ""]))

 (defn title->md
   [title]


Update the help page [issue 141]

Update the help page [issue 141]

--- src/foreclojure/static.clj
+++ src/foreclojure/static.clj
@@ -73,10 +73,9 @@
       [:br][:br]
       "Some operations are prohibited for security reasons.  For instance, you will not be able to use \"def\" or switch namespaces.  In addition, some problems have special restrictions.  For example, a function which is supposed to count the number of elements in a sequence will not be allowed to use the \"count\" function.  Obviously, this would defeat the purpose.  Any special restrictions will be listed on the problem page."
       [:br][:br]
-      "Many of the easier problems on this site can be solved using only your browser.  However at some point you will want to install Clojure, and use your favorite IDE or text editor to write your code.  We prefer using Emacs, but it's totally a matter of personal preference.  Writing all your code directly on the site has a few disadvantages:"
+      "Many of the easier problems on this site can be solved using only your browser.  However at some point you will want to install Clojure, and use your favorite IDE or text editor to write your code.  We prefer using Emacs, but it's totally a matter of personal preference.  Writing all your code directly on the site has a disadvantage:"
       [:br][:br]
       [:li "4Clojure is not an IDE, and doesn't try to be"]
-      [:li "4Clojure won't save any of your code for later use"]
       [:br]
       "Check out the official Clojure "
       [:a {:href "http://clojure.org/help"} "help"]


Allow an initial context to be passed in when creating main Isla env.

--- src/isla/library.clj
+++ src/isla/library.clj
@@ -6,18 +6,25 @@

 (defn get-initial-env [& args]
   (def extra-types (first args))
+  (def initial-ctx (second args))
+
+  (def isla-ctx
+    {
+     ;; fns
+     "write" (fn [env str]
+               (utils/output str) ;; print out
+               str) ;; add to context
+
+
+     ;; types
+     :types (if (nil? extra-types)
+              user/types
+              (merge extra-types user/types))
+     })
+
+  ;; final env
   {
    :ret nil
-   :ctx {
-         ;; fns
-         "write" (fn [env str]
-                   (utils/output str) ;; print out
-                   str) ;; add to context
+   :ctx (merge isla-ctx initial-ctx)
+   })

-
-         ;; types
-         :types (if (nil? extra-types)
-                  user/types
-                  (merge extra-types user/types))
-         }
-  })


Indent things

Indent things

--- src-cljs/frontend/components/pieces/topbar.cljs
+++ src-cljs/frontend/components/pieces/topbar.cljs
@@ -29,21 +29,21 @@
       [:div.navs-container
         [:ul.nav-items.collapsing-nav
           [:li
-         [:a.has-icon {:href "/dashboard"
-                   :aria-label "Builds"}
-          [:i.material-icons "storage"] "Builds"]]
+            [:a.has-icon {:href "/dashboard"
+                          :aria-label "Builds"}
+              [:i.material-icons "storage"] "Builds"]]
           [:li
-         [:a.has-icon {:href "/build-insights"
-                   :aria-label "Insights"}
-          [:i.material-icons "assessment"] "Insights"]]
+            [:a.has-icon {:href "/build-insights"
+                          :aria-label "Insights"}
+              [:i.material-icons "assessment"] "Insights"]]
           [:li
-         [:a.has-icon {:href "/projects"
-                   :aria-label "Projects"}
-          [:i.material-icons "book"] "Projects"]]
+            [:a.has-icon {:href "/projects"
+                          :aria-label "Projects"}
+              [:i.material-icons "book"] "Projects"]]
           [:li
-         [:a.has-icon {:href "/team"
-                   :aria-label "Teams"}
-          [:i.material-icons "group"] "Teams"]]]
+            [:a.has-icon {:href "/team"
+                          :aria-label "Teams"}
+              [:i.material-icons "group"] "Teams"]]]
         [:ul.nav-items.nav-items-left.collapsing-nav
          [:li.dropdown
           [:button.dropdown-toggle


OO|ME: Do not render table view unless it is active Closes #131

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -416,44 +416,52 @@
    each of whose value is a function of the form (fn [event args]) as described
    in the SlickGrid documentation for event handlers.
    https://github.com/mleibman/SlickGrid/wiki/Getting-Started"
-  (reify
-    om/IRenderState
-    (render-state [_ _]
-      (let [no-data? (empty? (get-in app-state [:data]))
-            {:keys [num_of_submissions] :as dataset-info}
-            (:dataset-info app-state)
-            with-info #(merge % {:dataset-info dataset-info})]
-        (html
-         [:div.table-view
-          (om/build submission-view
-                    (with-info (get-in app-state
-                                       [:table-page :submission-clicked]))
-                    {:opts (merge (select-keys opts #{:delete-record! :role})
-                                  {:view :table})})
-          (om/build table-header app-state)
-          [:div {:id table-id :class "slickgrid"}
-           (if (and no-data? (zero? num_of_submissions))
-             [:span {:class "empty-state"} "No data"]
-             [:span
-              [:i.fa.fa-spinner.fa-pulse] "Loading..."])]])))
-    om/IDidMount
-    (did-mount [_]
-      (let [data (get-in app-state [:data])]
-        (when-let [[grid dataview]
-                   (init-grid! data owner slick-grid-event-handlers)]
-          (handle-table-events app-state grid dataview))))
-    om/IWillReceiveProps
-    (will-receive-props [_ next-props]
-      "will-recieve-props resets slickgrid data if the table data has changed."
-      (let [old-data (get-in (om/get-props owner) [:data])
-            new-data (get-in next-props [:data])
-            {:keys [grid dataview]} (om/get-state owner)]
-        (when (not= old-data new-data)
-          (if (empty? old-data)
+  (let [active? (-> app-state
+                    :views
+                    :active
+                    set
+                    (contains? :table))]
+    (reify
+      om/IRender
+      (render [_]
+        (let [no-data? (empty? (get-in app-state [:data]))
+              {:keys [num_of_submissions] :as dataset-info}
+              (:dataset-info app-state)
+              with-info #(merge % {:dataset-info dataset-info})]
+          (when active?
+            (html
+             [:div.table-view
+              (om/build submission-view
+                        (with-info (get-in app-state
+                                           [:table-page :submission-clicked]))
+                        {:opts (merge (select-keys opts #{:delete-record! :role})
+                                      {:view :table})})
+              (om/build table-header app-state)
+              [:div {:id table-id :class "slickgrid"}
+               (if (and no-data? (zero? num_of_submissions))
+                 [:span {:class "empty-state"} "No data"]
+                 [:span
+                  [:i.fa.fa-spinner.fa-pulse] "Loading..."])]]))))
+      om/IDidMount
+      (did-mount [_]
+        (when active?
+          (let [data (get-in app-state [:data])]
             (when-let [[grid dataview]
-                       (init-grid! new-data owner slick-grid-event-handlers)]
-              (handle-table-events app-state grid dataview))
-            (do ; data has changed
-              (.invalidateAllRows grid)
-              (.setItems dataview (clj->js new-data) _id)
-              (.render grid))))))))
+                       (init-grid! data owner slick-grid-event-handlers)]
+              (handle-table-events app-state grid dataview)))))
+      om/IWillReceiveProps
+      (will-receive-props [_ next-props]
+        "will-recieve-props resets slickgrid data if the table data has changed."
+        (when active?
+          (let [old-data (get-in (om/get-props owner) [:data])
+                new-data (get-in next-props [:data])
+                {:keys [grid dataview]} (om/get-state owner)]
+            (when (not= old-data new-data)
+              (if (empty? old-data)
+                (when-let [[grid dataview]
+                           (init-grid! new-data owner slick-grid-event-handlers)]
+                  (handle-table-events app-state grid dataview))
+                (do ; data has changed
+                  (.invalidateAllRows grid)
+                  (.setItems dataview (clj->js new-data) _id)
+                  (.render grid))))))))))


use lists rather than vecs

use lists rather than vecs

--- src/k_means/core.clj
+++ src/k_means/core.clj
@@ -7,7 +7,7 @@

 (defn choose-initial-centroids
   "Randomly choose k centroids from vectors"
-  ([l k] (choose-initial-centroids l k (vector)))
+  ([l k] (choose-initial-centroids l k (list)))
   ([l k c]
     (cond
       (< k 1) c
@@ -34,18 +34,18 @@
 (defn k-means-p
   "Perform k-means using concurrent paradigms"
   ([l k max-iterations]
-    (k-means-p l k (p :choose-initial-centroids (choose-initial-centroids l k)) (vector/make-vector k) max-iterations))
+    (k-means-p l k (p :choose-initial-centroids (choose-initial-centroids l k)) (vector/make-list k) max-iterations))
   ([l k c g max-iterations]
-    (let [t c g (p :cluster-parallel (cluster/cluster-p l c)) c (p :mean-centroids (cluster/mean-centroids g))]
+    (let [t c g (p :cluster-parallel (cluster/cluster-p l c)) c (p :mean-centroids (cluster/mean-centroids-p g))]
       (println "Iteration" (- 100 max-iterations) c)
       (cond
         (> 0 max-iterations) g
         (still-moving? t c) ; Keep shifting centroids until equilibrium
           (recur l k c g (dec max-iterations))
-        :else (vec g)))))
+        :else g))))

 (defn -main
   "Main function for k-means"
   [& args]
-  (let [c (profile :info :Arithmetic (k-means-p (vector/make-vector-rand 40000) 5 100)) => "Done"]
-    (spit "k-means.txt" c)) (shutdown-agents))
+  (let [c (profile :info :Arithmetic (k-means (vector/make-list-rand 5000) 7 15)) => "Done"]
+    (spit "k-means.txt" (vec c))) (shutdown-agents))


Added 'top domains per period' figure.

Added 'top domains per period' figure.

--- src/laskuri/core.clj
+++ src/laskuri/core.clj
@@ -20,6 +20,11 @@
   "Format a Key, Value line, where K is a vector, into a tab separated string."
   [[ks v]]
   (format "%s\t%s" (string/join "\t" ks) (str v)))
+
+(defn format-kvs
+  "Format a Key, Value line into a tab separated string."
+  [[k vs]]
+  (format "%s\t%s" k (string/join "\t" (flatten vs))))

 (defn get-parsed-lines [ctx location redact?]
   "Get a new input stream of parsed lines."
@@ -178,8 +183,16 @@
         ; subdomain -> count per period
         subdomain-period-count (count-by-key subdomain-period-date)
         ; sort by host
-        subdomain-period-count (f/map (f/sort-by-key (f/map subdomain-period-count (f/fn [kv] [((fn [[[host domain] date2]] host) kv) kv]))) (f/fn [[_ v]] v))]
-
+        subdomain-period-count (f/map (f/sort-by-key (f/map subdomain-period-count (f/fn [kv] [((fn [[[host domain] date2]] host) kv) kv]))) (f/fn [[_ v]] v))
+
+        ; period -> [[host, count]]
+        period-domains-count (f/group-by-key (f/map domain-period-count (f/fn [[[host domain date] cnt]] [date [host cnt]])))
+
+        ; sort domains in memory
+        ; period -> [[host, count]] sorted and limited
+        period-domains-sorted (f/map period-domains-count (f/fn [[date items]] [date (take 100 (reverse (sort-by second items)))]))]
+
+    (.saveAsTextFile (f/map period-domains-sorted format-kvs) (str output-location "/" (name period) "-top-domains"))
     (.saveAsTextFile (f/map doi-period-count format-ksv) (str output-location "/" (name period) "-doi-period-count"))
     (.saveAsTextFile (f/map domain-period-count format-ksv) (str output-location "/" (name period) "-domain-period-count"))
     (.saveAsTextFile (f/map subdomain-period-count format-ksv) (str output-location "/" (name period) "-subdomain-period-count"))))
@@ -195,7 +208,7 @@
         ; If local, use this config. Otherwise empty, will be loaded from `spark-submit`.
         conf (if dev-local
                 (-> (conf/spark-conf)
-                   (conf/master "local")
+                   (conf/master "local[5]")
                    (conf/app-name "laskuri")
                    (conf/set "spark.driver.memory" "500m")
                    (conf/set "spark.executor.memory" "500m")


Go back to honoring IClockFinder contract.

Was returning a seq but not a set after today's changes, causing
crashes in the show control web page.

--- src/afterglow/midi.clj
+++ src/afterglow/midi.clj
@@ -413,7 +413,7 @@
 (defrecord ClockFinder [listener results traktor-candidates]
   IClockFinder
   (finder-current-sources [this]
-    (annotate-traktor-grid-sources @results @traktor-candidates))
+    (set (annotate-traktor-grid-sources @results @traktor-candidates)))
   (finder-finished [this]
     (remove-global-handler! listener)
     (reset! results nil)


Improve byte-to-long speed

Improve byte-to-long speed

--- src/mavlink/type.clj
+++ src/mavlink/type.clj
@@ -95,7 +95,7 @@
                      {:cause :unknown-type
                       :type type-key}))))

-(defn byte-to-long
-  "Accept a byte, return it as a long."
+(defmacro byte-to-long
+  "Accept a byte, return it as a long"
   [b]
-  (bit-and (long b) 0xff))
+  `(bit-and ~b 0xff))


Fixing some reflection cases uncovered by `lein check`.

--- src/measure/core.clj
+++ src/measure/core.clj
@@ -51,11 +51,11 @@
   (MetricRegistry.))

 (defn register
-  [registry name metric]
+  [^MetricRegistry registry name metric]
   (.register registry name metric)
   metric)

-(deftype ^:private FnGauge [^Callable value-fn]
+(deftype ^:private FnGauge [value-fn]
   Gauge
   (getValue [_] (value-fn)))


fix ns tracking logic of eval-str

fix ns tracking logic of eval-str

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -463,35 +463,37 @@
         eof  (js-obj)
         aenv (ana/empty-env)
         sb   (StringBuffer.)]
-    ((fn compile-loop []
+    ((fn compile-loop [ns]
        (binding [env/*compiler*         (:*compiler* bound-vars)
                  *eval-fn*              (:*eval-fn* bound-vars)
-                 ana/*cljs-ns*          (:*cljs-ns* bound-vars)
-                 *ns*                   (:*ns* bound-vars)
+                 ana/*cljs-ns*          ns
+                 *ns*                   (create-ns ns)
                  r/*data-readers*       (:*data-readers* bound-vars)
                  comp/*source-map-data* (:*sm-data* bound-vars)]
          (let [form (r/read {:eof eof :read-cond :allow :features #{:cljs}} rdr)]
            (if-not (identical? eof form)
-             (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ana/*cljs-ns*))
+             (let [aenv (cond-> (assoc aenv :ns (ana/get-namespace ns))
                           (:context opts) (assoc :context (:context opts))
                           (:def-emits-var opts) (assoc :def-emits-var true))
-                   ast  (ana/analyze aenv form)]
+                   ast  (ana/analyze aenv form)
+                   ns'  ana/*cljs-ns*]
                (if (= :ns (:op ast))
                  (do
                    (.append sb
                      (str "goog.provide(\"" (munge (:name ast)) "\");\n"))
                    (ns-side-effects true bound-vars aenv ast opts
-                     (fn [_] (compile-loop))))
+                     (fn [_] (compile-loop ns'))))
                  (do
                    (.append sb (with-out-str (comp/emit ast)))
-                   (recur))))
+                   (recur ns'))))
              (let [js-source (.toString sb)]
                (when (:verbose opts)
                  (debug-prn js-source))
                (cb (*eval-fn* {:lang   :clj
                                :name   name
                                :path   (ns->relpath name)
-                               :source js-source}))))))))))
+                               :source js-source})))))))
+      (:*cljs-ns* bound-vars))))

 (defn eval-str
   "Evalute ClojureScript source given as a string. The parameters:


correction, inline source maps do not yet work under Node.js

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -860,6 +860,9 @@
           (println (.. error -cause -stack)))
         (println res))))

+  ;; *NOT* source mapped under Node.js
+  ;; source-map-support does not yet work, users will need to map
+  ;; themselves
   (cljs/eval-str st
     "(ns foo.bar)\n(ffirst [1 2 3])"
     'foo.bar


[system]: is now detachable. stop and refactor out are.. next

--- src/mount/system.clj
+++ src/mount/system.clj
@@ -1,4 +1,5 @@
-(ns mount.system)
+(ns mount.system
+  (:require [mount.core :as mount]))

 (defprotocol Lifecycle
   (start [this] "starts a system")
@@ -33,14 +34,42 @@
     (for [state (keys states)]
       [state :not-started])))

+(defn- detach [sys]
+  (doseq [[state {:keys [var status] :as v}] sys]
+    (alter-var-root var (constantly :not-started))
+    (#'mount.core/update-meta! [state :status] #{:stopped})
+    (#'mount.core/update-meta! [state :var] :not-started)))
+
+(defn- attach [sys]
+  (into {}
+        (for [[k {:keys [var]}] sys]
+          [(unvar-state k) @var])))
+
+(defn- spawn [sys]
+  (mount/start)
+  (let [spawned (attach sys)]
+    (detach sys)
+    spawned))
+
 (defn new-system [meta-state]
   (let [states (-> (sort-by (comp :order val) <
                             meta-state)
-                   unvar-names)
-        up (select-fun states :start)
+                    unvar-names)
         down (reverse (select-fun states :stop))]
     (extend-type MountSystem
       Lifecycle
-      (start [_] (bring-system up))   ;; these two will have two lift inter var deps
-      (stop [_] (bring-system down))) ;;
+      (start [states] (->MountSystem (spawn meta-state)))
+      (stop [_] (bring-system down)))
     (->MountSystem (not-started states))))
+
+(comment
+
+(require :reload '[mount.system :as m])
+(def ms @@#'mount.core/meta-state)
+(def sys (new-system ms))
+(def sys (m/start sys))
+
+;; at this point the system is up and detached: i.e. "global" vars and mount do not see it
+;; TODO: figure out stopping it.. i.e. need to convert stops to work with @deps
+;;       ... quite possible in "cljc" :)
+)


WS (and seeing if my ssh workflow is going)

--- src/omhome/ssgen.clj
+++ src/omhome/ssgen.clj
@@ -13,7 +13,6 @@
             [optimus.optimizations :as optimisations]
             [optimus.prime :as optimus]
             [optimus.strategies :refer [serve-live-assets]]
-
             [omhome.helpers :refer :all]
             [omhome.posts-meta :refer [posts]])
   (:import [java.io.File]))


Doc tweaks

Doc tweaks

--- src/omhome/ssgen.clj
+++ src/omhome/ssgen.clj
@@ -34,8 +34,7 @@
       (if (:title options)
         [:title (:title options)]
         [:title "Everything is Placeholder"])
-      (html/link-to-css-bundles req ["blog.css"])
-      ]
+      (html/link-to-css-bundles req ["blog.css"])]
      [:body
       [:div.logo "olivermooney.com"]
       [:div.body (binding [*ns* (find-ns (symbol "omhome.ssgen"))] (eval page))]])))
@@ -69,10 +68,12 @@
     :markdown-pages (markdown->pages (stasis/slurp-directory "resources/markdown" #".*\.md$" :encoding "UTF-8"))}))

 (defn prepare-page [page req]
+  "Standard final step applied to a HTML post."
   (-> (if (string? page) page (page req))
       highlight-code-blocks))

 (defn prepare-pages [pages]
+  "Apply a final processing step to all generated HTML posts."
   (zipmap (keys pages)
           (map #(partial prepare-page %) (vals pages))))


Add dbg-println, a configurable alternative to using println for debugging. Behavior is controlled by dbg-println-mode and *dbg-println-level* (and the current logging level if dbg-println-mode=:log)

--- src/pamela/utils.clj
+++ src/pamela/utils.clj
@@ -127,3 +127,37 @@
   (clojure.string/replace
    (translate/->Camel_Snake_Case_String raw-name)
    "_" " "))
+
+;;Supported modes are:
+;; :log - use the logging utility (e.g., log/warn)
+;; :println - Just use println if level
+(def ^{:doc
+       "Specifies which mode of debugging output will be used, either :log or :println"}
+  dbg-println-mode :println)
+
+(def ^{:doc
+       "The highest level, where higher = lower severity, at which println will be called
+ when in :println mode"
+       :dynamic true}
+  *dbg-println-level*
+  6)
+
+;;For internal use only.  The order matters.
+(def dbg-println-levels [:fatal :error :warn :info :debug :trace])
+
+(defmacro dbg-println "Configurable alternative to using println for debugging."
+    [level & more]
+  (case dbg-println-mode
+    :log (let [f (case level
+                   (1 :fatal) 'log/fatal
+                   (2 :error) 'log/error
+                   (3 :warn) 'log/warn
+                   (4 :info) 'log/info
+                   (5 :debug) 'log/debug
+                   (6 :trace) 'log/trace)]
+           `(~f ~@more))
+    :println (let [level (if (integer? level)
+                           level
+                           (inc (.indexOf dbg-println-levels level)))]
+               `(if (<= ~level *dbg-println-level*)
+                  (println ~@more)))))


Oh man. What an idiot. It's defn not def.

--- src/leiningen/new/cljskel.clj
+++ src/leiningen/new/cljskel.clj
@@ -3,7 +3,7 @@

 (def render (renderer "cljskel"))

-(def cap [s]
+(defn cap [s]
   (str (.toUpperCase (subs s 0 1)) (subs s 1)))

 (defn cljskel


t2 has its own server-conn-loop.

t2 has its own server-conn-loop.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -1,10 +1,29 @@
 (ns cbfg.world.t2
-  (:require-macros [cbfg.act :refer [act achan aput atake]])
+  (:require-macros [cbfg.act :refer [act act-loop achan aput atake atimeout]])
   (:require [cbfg.world.t1 :refer [prog-base-now prog-curr-now prog-evt
-                                   wait-done addr-override-xy]]))
+                                   wait-done addr-override-xy]]
+            [cbfg.lane]))

 (defn world-vis-init [el-prefix init-event-delay]
   (cbfg.world.t1/world-vis-init-t "cbfg.world.t2" el-prefix init-event-delay))
+
+; --------------------------------------------
+
+(defn server-conn-loop [actx server-send-ch server-recv-ch close-server-recv-ch]
+  (let [lanes-in-ch (achan actx)
+        lanes-out-ch (achan actx)]
+    (cbfg.lane/make-lane-pump actx lanes-in-ch lanes-out-ch
+                              cbfg.world.lane/make-fenced-pump-lane)
+    (act-loop lanes-in actx [num-ins 0]
+              (let [msg (atake lanes-in server-recv-ch)]
+                (aput lanes-in lanes-in-ch msg)
+                (when (> (:sleep msg) 0)
+                  (let [sleep-ch (atimeout lanes-in (:sleep msg))]
+                    (atake lanes-in sleep-ch)))
+                (recur (inc num-ins))))
+    (act-loop lanes-out actx [num-outs 0]
+              (aput lanes-out server-send-ch [(atake lanes-out lanes-out-ch)])
+              (recur (inc num-outs)))))

 ; --------------------------------------------

@@ -18,7 +37,8 @@
                    [server-addr port listen-result-ch])
              (when-let [[accept-ch close-accept-ch]
                         (atake server-init listen-result-ch)]
-               (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch)))
+               (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch
+                                                  :server-conn-loop server-conn-loop)))
            (reset! done true))
       (wait-done done)
       (prog-evt world :kv-server {:server-addr server-addr :server-port port}


returning tid and identity translating status to human readable form

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -71,20 +71,23 @@
 (defn status [queue uuid]
   (mq/message-status (server-conn) queue uuid))

-(defn- job-desc [type js]
-  (mapv (fn [[jid {:keys [args]}]]
-          {:type type :status (status type jid) :id ((args 0) :system-id) :jid jid}) (apply hash-map js)))
+(def readable-status
+  {:queued :queued :locked :processing :recently-done :done :backoff :backing-off nil :unkown})
+
+(defn- message-desc [type js]
+  (mapv (fn [[jid {:keys [identity args tid] :as message}]]
+     {:type type :status (readable-status (status type jid)) :id identity :jid jid :tid tid}) (apply hash-map js)))

 (defn queue-status
-  "The entire queue messages statuses"
+  "The entire queue message statuses"
   [job]
   (let [ks [:messages :locks :backoffs]]
     (reduce
-      (fn [r v] (into r (job-desc job v))) []
+      (fn [r message] (into r (message-desc job message))) []
             (apply merge (vals (select-keys (mq/queue-status (server-conn) job) ks))))))

-(defn jobs-statues
-  "Get all jobs message statuses"
+(defn jobs-status
+  "Get all jobs status"
   []
   (reduce (fn [r t] (into r (queue-status (name t)))) [] (keys @jobs)))


proper revert failing tests

proper revert failing tests

--- test/clj/foosball/test/routes/api.clj
+++ test/clj/foosball/test/routes/api.clj
@@ -45,13 +45,13 @@
           (is (= {:role :user
                   :active true
                   :name name
-                  :player/id id} (-> request handler :body edn/read-string first)))
+                  :id id} (-> request handler :body edn/read-string first)))
           (test-route-for-supported-media-types handler request)
           (testing "JSON output is parsable into something similar"
             (is  (= {:role "user"
                      :name name
                      :active true
-                     :player/id (str id)} (-> request
+                     :id (str id)} (-> request
                      (mockr/header :accept "application/json")
                      handler
                      :body


fix tests

fix tests

--- test/clj/just_married/labels_test.clj
+++ test/clj/just_married/labels_test.clj
@@ -10,7 +10,9 @@
 (deftest gen-table-test
   (testing "gen table with one address"
     (is (= [:pdf-table
+            {:width-percent 100, :horizontal-align :right}
             [20 20 20]
             [[:pdf-cell
+              {:align :right}
               "Long group name\nMy street 42, Town 10022 (PR)\nItaly"]]]
            (sut/gen-table [sample-address])))))


add limit for audio buffers, remove max-sdefs for sdefs (doesn't seem to be used) also add a bit more error handling to help with these issues in the future

--- src/overtone/sc/allocator.clj
+++ src/overtone/sc/allocator.clj
@@ -25,10 +25,10 @@
    :control-bus  (mk-bitset MAX-NODES)})

 (defonce allocator-limits
-  {:node    MAX-NODES
-   :sdefs     MAX-SDEFS
-   :audio-bus   MAX-AUDIO-BUS
-   :control-bus MAX-CONTROL-BUS})
+  {:node         MAX-NODES
+   :audio-buffer MAX-BUFFERS
+   :audio-bus    MAX-AUDIO-BUS
+   :control-bus  MAX-CONTROL-BUS})

 (defn- fill-gaps
   "Fill a given vector bs with size consecutive vals from idx"
@@ -42,7 +42,7 @@

 (defn- find-gap
   [bs size idx gap-found limit]
-  (if (> idx limit)
+  (when (> idx limit)
     (throw (Exception. (str "No more ids! Unable to allocate a sequence of ids of length" size))))
   (if (= gap-found size)
     (- idx gap-found)
@@ -55,6 +55,10 @@
   ([k size]
      (let [bits  (get allocator-bits k)
            limit (get allocator-limits k)]
+       (when-not bits
+         (throw (Exception. (str "Unable to get allocator bits for keyword " k))))
+       (when-not limit
+         (throw (Exception. (str "Unable to get allocator limit for keyword " k))))
        (dosync
         (let [id (find-gap @bits size 0 0 limit)]
           (alter bits fill-gaps id size true)


Add npc cap

Add npc cap

--- src/robinson/npc.clj
+++ src/robinson/npc.clj
@@ -264,15 +264,19 @@
 (defn add-npcs-random
   "Randomly add monsters inside the viewport."
   [state]
+  ; num of curent npcs
   (let [num-npcs (reduce + (vals (npc-freqs-in-player-place state)))]
-    ;; higher random number = less npcs
-    (if (and (< (rr/uniform-int 210)
-                (if (rw/is-night? state)
-                   (/ 180 (inc num-npcs))
-                   (/ 80 (inc num-npcs))))
-             (< (count (get-npcs state))
-               60))
-      (add-npcs state)
+    ;; add no more than 10 npcs per place
+    (if (< num-npcs 10)
+      ;; higher random number = fewer npcs
+      (if (and (< (rr/uniform-int 210)
+                  (if (rw/is-night? state)
+                     (/ 180 (inc num-npcs))
+                     (/ 80 (inc num-npcs))))
+               (< (count (get-npcs state))
+                 60))
+        (add-npcs state)
+        state)
       state)))

 (defn has-status?


update unit test to reflect the fk :origin now hydrates :table :db

--- test/metabase/api/meta/table_test.clj
+++ test/metabase/api/meta/table_test.clj
@@ -201,7 +201,15 @@
                            :active true
                            :id $
                            :db_id $
-                           :created_at $})})
+                           :created_at $
+                           :db (match-$ @test-db
+                                 {:description nil,
+                                  :organization_id 1,
+                                  :name "Test Database",
+                                  :updated_at $,
+                                  :id $,
+                                  :engine "h2",
+                                  :created_at $})})})
       :destination (match-$ users-id-field
                      {:id $
                       :table_id $


Add a note to remember to fix the aggregate middleware

--- test/momentum/test/http/aggregate.clj
+++ test/momentum/test/http/aggregate.clj
@@ -49,3 +49,6 @@

       (is (= (to-string (response-body))
              "HelloWorld")))))
+
+;; TODO:
+;; * TE:chunked header is stripped


Tiny whitespace fix.

Tiny whitespace fix.

--- src/circle/workers.clj
+++ src/circle/workers.clj
@@ -28,7 +28,7 @@
   `(future
      (try
        (let [result# (do ~@body)]
-         (infof "%s returned %s" (quote  ~@body) result#)
+         (infof "%s returned %s" (quote ~@body) result#)
          result#)
        (catch Exception e#
          (airbrake :data {:body (quote ~@body) :future true})


Enable running application from jar

Enable running application from jar

--- src/nhl_score_api/core.clj
+++ src/nhl_score_api/core.clj
@@ -3,9 +3,24 @@
             [nhl-score-api.cache :as cache]
             [camel-snake-kebab.core :refer [->camelCaseString]]
             [org.httpkit.server :as server]
-            [clojure.data.json :as json]))
+            [clojure.data.json :as json]
+            [clojure.java.io :as io])
+  (:import (java.util Properties))
+  (:gen-class))

-(def version (System/getProperty "nhl-score-api.version"))
+; From http://stackoverflow.com/a/33070806
+(defn- get-version-from-pom [dep]
+  (let [path (str "META-INF/maven/" (or (namespace dep) (name dep))
+                  "/" (name dep) "/pom.properties")
+        props (io/resource path)]
+    (when props
+      (with-open [stream (io/input-stream props)]
+        (let [props (doto (Properties.) (.load stream))]
+          (.getProperty props "version"))))))
+
+(def version
+  (or (System/getProperty "nhl-score-api.version")
+      (get-version-from-pom 'nhl-score-api)))

 (declare app)


Cards involved in dynamic ice strengths.

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -426,7 +426,22 @@
                                  state side
                                  {:choices {:req #(and (has? % :type "ICE") (:rezzed %))}
                                   :msg (msg "add " boost " strength to " (:title target))
-                                  :effect (effect (trash card))} card nil)))}]}
+                                  :effect (req
+                                            (update! state side (assoc card :troubleshooter-target target
+                                                                       :troubleshooter-amount boost))
+                                            (trash state side (get-card state card))
+                                            (update-ice-strength state side target))} card nil)))}]
+    :events {:pre-ice-strength nil :end-turn nil}
+    :trash-effect
+      {:effect (req (register-events
+                      state side
+                      (let [ct {:effect (req (unregister-events state side card)
+                                             (update! state side (dissoc card :troubleshooter-target))
+                                             (update-ice-strength state side (:troubleshooter-target card)))}]
+                        {:pre-ice-strength
+                          {:req (req (= (:cid target) (:cid (:troubleshooter-target card))))
+                           :effect (effect (ice-strength-bonus (:troubleshooter-amount card)))}
+                         :runner-turn-ends ct :corp-turn-ends ct}) card))}}

    "Corporate War"
    {:msg (msg (if (> (:credit corp) 6) "gain 7 [Credits]" "lose all credits"))
@@ -504,9 +519,18 @@
                  :msg "force the Corp to trash the top card of R&D"}]}

    "Datasucker"
-   {:events {:successful-run {:effect (effect (add-prop card :counter 1))
-                              :req (req (#{:hq :rd :archives} target))}}
-    :abilities [{:counter-cost 1 :msg (msg "give -1 strength to " (:title current-ice))}]}
+   {:events (let [ds {:effect (req (update! state side (dissoc card :datasucker-count)))}]
+                 {:successful-run {:effect (effect (add-prop card :counter 1))
+                                   :req (req (#{:hq :rd :archives} target))}
+                  :pre-ice-strength {:req (req (and (= (:cid target) (:cid current-ice))
+                                                    (:datasucker-count card)))
+                                     :effect (req (let [c (:datasucker-count (get-card state card))]
+                                                       (ice-strength-bonus state side (- c))))}
+                  :pass-ice ds :run-ends ds})
+    :abilities [{:counter-cost 1 :msg (msg "give -1 strength to " (:title current-ice))
+                 :req (req current-ice)
+                 :effect (req (update! state side (update-in card [:datasucker-count] (fnil #(+ % 1) 0)))
+                              (update-ice-strength state side current-ice))}]}

    "Day Job"
    {:additional-cost [:click 3] :effect (effect (gain :credit 10))}
@@ -666,7 +690,10 @@
                           (reduce (fn [c server]
                                     (+ c (count (filter (fn [ice] (and (has? ice :subtype "Code Gate")
                                                                        (:rezzed ice))) (:ices server)))))
-                                  0 (flatten (seq (:servers corp))))))}
+                                  0 (flatten (seq (:servers corp))))))
+
+    :events {:pre-ice-strength {:req (req (has? target :subtype "Code Gate"))
+                                :effect (effect (ice-strength-bonus 1))}}}

    "Encryption Protocol"
    {:events {:pre-trash {:req (req (= (first (:zone target)) :servers))
@@ -707,6 +734,13 @@

    "Executive Wiretaps"
    {:msg (msg "reveal cards in HQ: " (map :title (:hand corp)))}
+
+   "Experiential Data"
+   {:effect (req (update-ice-in-server state side (card->server state card)))
+    :events {:pre-ice-strength {:req (req (= (card->server state card) (card->server state target)))
+                                :effect (effect (ice-strength-bonus 1))}}
+    :derez-effect {:effect (req (update-ice-in-server state side (card->server state card)))}
+    :trash-effect {:effect (req (update-all-ice state side))}}

    "Expert Schedule Analyzer"
    {:abilities
@@ -867,6 +901,10 @@
    "Haas-Bioroid: Engineering the Future"
    {:events {:corp-install {:once :per-turn :msg "gain 1 [Credits]"
                             :effect (effect (gain :credit 1))}}}
+
+   "Haas-Bioroid: Stronger Together"
+   {:events {:pre-ice-strength {:req (req (and (= (:type target) "ICE") (has? target :subtype "Bioroid")))
+                                :effect (effect (ice-strength-bonus 1))}}}

    "Hacktivist Meeting"
    {:events {:rez {:req (req (not= (:type target) "ICE"))
@@ -990,6 +1028,11 @@
     :abilities [{:counter-cost 1 :effect (effect (gain :credit 1))
                  :msg "take 1 [Credits] to install programs"}]}

+   "Ice Carver"
+   {:events {:pre-ice-strength
+             {:req (req (and (= (:cid target) (:cid current-ice)) (:rezzed target)))
+              :effect (effect (ice-strength-bonus -1))}}}
+
    "Imp"
    {:data {:counter 2}
     :abilities [{:counter-cost 1 :msg "trash at no cost" :once :per-turn
@@ -1129,6 +1172,9 @@
    {:data {:counter 2}
     :abilities [{:counter-cost 1 :effect (effect (prevent-jack-out))
                  :msg "prevent the Runner from jacking out"}]}
+
+   "Lag Time"
+   {:events {:pre-ice-strength {:effect (effect (ice-strength-bonus 1))}}}

    "Lamprey"
    {:events {:successful-run {:req (req (= target :hq)) :msg "to force the Corp to lose 1 [Credits]"
@@ -1430,6 +1476,12 @@
    "PAD Campaign"
    {:events {:corp-turn-begins {:msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}

+   "Patch"
+   {:hosting {:req #(and (= (:type %) "ICE") (:rezzed %))}
+    :effect (effect (update-ice-strength (:host card)))
+    :events {:pre-ice-strength {:req (req (= (:cid target) (:cid (:host card))))
+                                :effect (effect (ice-strength-bonus 2))}}}
+
    "Posted Bounty"
    {:optional {:prompt "Forfeit Posted Bounty to give the Runner 1 tag and take 1 bad publicity?"
                :msg "give the Runner 1 tag and take 1 bad publicity"
@@ -1470,14 +1522,15 @@

    "Parasite"
    {:hosting {:req #(and (= (:type %) "ICE") (:rezzed %))}
-    :effect (req (when-let [h (:host card)]
-                   (when (<= (:strength h) (:counter card))
-                     (trash state side h))))
+    :effect (req (when-let [h (:host card)] (update-ice-strength state side h)))
     :events {:runner-turn-begins
-             {:effect (req (add-prop state side card :counter 1)
-                           (when-let [h (get-card state (:host card))]
-                             (when (>= (inc (:counter card)) (:strength h))
-                               (trash state side h))))}}}
+             {:effect (req (add-prop state side card :counter 1) (update-ice-strength state side (:host card)))}
+             :pre-ice-strength
+             {:req (req (= (:cid target) (:cid (:host card))))
+              :effect (effect (ice-strength-bonus (- (get-virus-counters state side card))))}
+             :ice-strength-changed
+             {:req (req (and (= (:cid target) (:cid (:host card))) (<= (:current-strength target) 0)))
+              :effect (effect (trash target))}}}

    "Paricia"
    {:recurring 2}
@@ -1861,6 +1914,14 @@
    "Scorched Earth"
    {:req (req tagged) :effect (effect (damage :meat 4 {:card card}))}

+   "Scrubbed"
+   {:events (let [sc {:effect (req (update! state side (dissoc card :scrubbed-target)))}]
+                 {:encounter-ice {:once :per-turn
+                                  :effect (effect (update! (assoc card :scrubbed-target target)))}
+                  :pre-ice-strength {:req (req (= (:cid target) (:cid (:scrubbed-target card))))
+                                     :effect (effect (ice-strength-bonus -2))}
+                  :pass-ice sc :run-ends sc})}
+
    "Scrubber"
    {:recurring 2}

@@ -2113,11 +2174,14 @@
                                                                    (:rezzed ice))) (:ices server)))))
                               0 (flatten (seq (:servers corp))))
               " [Credits]")
-    :effect (effect (gain :credit
+    :effect (req (do (gain state :corp :credit
                           (reduce (fn [c server]
                                     (+ c (count (filter (fn [ice] (and (has? ice :subtype "Barrier")
                                                                        (:rezzed ice))) (:ices server)))))
-                                  0 (flatten (seq (:servers corp))))))}
+                                  0 (flatten (seq (:servers corp)))))
+                     (update-all-ice state side)))
+    :events {:pre-ice-strength {:req (req (has? target :subtype "Barrier"))
+                                :effect (effect (ice-strength-bonus 1))}}}

    "Sure Gamble"
    {:effect (effect (gain :credit 9))}
@@ -2728,10 +2792,15 @@

    "Crick"
    {:abilities [{:msg "install a card from Archives" :choices (req (:discard corp))
-                 :prompt "Choose a card to install" :effect (effect (corp-install target nil))}]}
+                 :prompt "Choose a card to install" :effect (effect (corp-install target nil))}]
+    :strength-bonus (req (if (= (second (:zone card)) :archives) 3 0))}

    "Curtain Wall"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (let [ices (:ices (card->server state card))]
+                              (if (= (:cid card) (:cid (last ices))) 4 0)))
+    :events {:rez {:req (req (= (card->server state card) (card->server state target)))
+                   :effect (effect (update-ice-strength card))}}}

    "Data Hound"
    {:abilities [{:label "Trace 2 - Look at the top of Stack"
@@ -2757,6 +2826,7 @@
    "Dracō"
    {:prompt "How many power counters?" :choices :credit :msg (msg "add " target " power counters")
     :effect (effect (set-prop card :counter target))
+    :strength-bonus (req (or (:counter card) 0))
     :abilities [{:label "Trace 2"
                  :trace {:base 2 :msg "give the Runner 1 tag and end the run"
                          :effect (effect (gain :runner :tag 1) (end-run))}}]}
@@ -2782,7 +2852,8 @@
                 {:msg "end the run" :effect (effect (end-run))}]}

    "Fire Wall"
-   {:advanceable :always :abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:advanceable :always :abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (or (:advance-counter card) 0))}

    "Flare"
    {:abilities [{:prompt "Choose a piece of hardware to trash"
@@ -2810,11 +2881,13 @@

    "Gutenberg"
    {:abilities [{:label "Trace 7 - Give the Runner 1 tag"
-                 :trace {:base 7 :msg "give the Runner 1 tag" :effect (effect (gain :runner :tag 1))}}]}
+                 :trace {:base 7 :msg "give the Runner 1 tag" :effect (effect (gain :runner :tag 1))}}]
+    :strength-bonus (req (if (= (second (:zone card)) :rd) 3 0))}

    "Hadrians Wall"
    {:advanceable :always
-    :abilities [{:msg "end the run" :effect (effect (end-run))}]}
+    :abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (or (:advance-counter card) 0))}

    "Himitsu-Bako"
    {:abilities [{:msg "end the run" :effect (effect (end-run))}
@@ -2845,7 +2918,8 @@
                  :trace {:base 3 :msg "give the Runner 1 tag" :effect (effect (gain :runner :tag 1))}}]}

    "Ice Wall"
-   {:advanceable :always :abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:advanceable :always :abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (or (:advance-counter card) 0))}

    "Ichi 1.0"
    {:abilities [{:prompt "Choose a program to trash" :msg (msg "trash " (:title target))
@@ -2864,7 +2938,8 @@
                          :effect (effect (damage :brain 1 {:card card}) (gain :runner :tag 1))}}]}

    "IQ"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (count (:hand corp)))}

    "Information Overload"
    {:abilities [{:label "Trace 1 - Give the Runner 1 tag"
@@ -2933,7 +3008,8 @@
    {:abilities [{:msg "do 2 net damage" :effect (effect (damage :net 2 {:card card}))}]}

    "Meru Mati"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (if (= (second (:zone card)) :hq) 3 0))}

    "Minelayer"
    {:abilities [{:msg "install an ICE from HQ"
@@ -2980,7 +3056,14 @@
    {:abilities [{:msg "do 3 net damage" :effect (effect (damage :net 3 {:card card}))}]}

    "NEXT Bronze"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (reduce (fn [c server]
+                                         (+ c (count (filter (fn [ice] (and (:rezzed ice) (has? ice :subtype "NEXT")))
+                                                             (:ices server)))))
+                                     0 (flatten (seq (:servers corp)))))
+    :events (let [nb {:req (req (has? target :subtype "NEXT"))
+                   :effect (effect (update-ice-strength card))}]
+                 {:rez nb :derez nb :trash nb :card-moved nb})}

    "NEXT Gold"
    {:abilities [{:label "Do 1 net damage for each rezzed NEXT ice"
@@ -3056,11 +3139,13 @@
     :abilities [{:label "Trace X - Give the runner 1 tag"
                  :trace {:base (req (or (:advance-counter card) 0)) :effect (effect (gain :runner :tag 1))
                          :msg "give the Runner 1 tag"}}]}
+
    "Shadow"
    {:advanceable :always
     :abilities [{:msg "gain 2 [Credits]" :effect (effect (gain :credit 2))}
                 {:label "Trace 3 - Give the Runner 1 tag"
-                 :trace {:base 3 :msg "give the Runner 1 tag" :effect (effect (gain :runner :tag 1))}}]}
+                 :trace {:base 3 :msg "give the Runner 1 tag" :effect (effect (gain :runner :tag 1))}}]
+    :strength-bonus (req (or (:advance-counter card) 0))}

    "Sherlock 1.0"
    {:abilities [{:label "Trace 4 - Add an installed program to the top of Stack"
@@ -3138,7 +3223,8 @@
                 {:msg "do 1 net damage" :effect (effect (damage :net 1 {:card card}))}]}

    "Turing"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (if (= (second (:zone card)) :remote) 3 0))}

    "Tyrant"
    {:advanceable :while-rezzed
@@ -3207,7 +3293,12 @@
    {:abilities [{:msg "end the run" :effect (effect (end-run))}]}

    "Wraparound"
-   {:abilities [{:msg "end the run" :effect (effect (end-run))}]}
+   {:abilities [{:msg "end the run" :effect (effect (end-run))}]
+    :strength-bonus (req (if (some #(has? % :subtype "Fracter") (get-in runner [:rig :program]))
+                           0 7))
+    :events (let [wr {:req (req (has? target :subtype "Fracter"))
+                      :effect (effect (update-ice-strength card))}]
+                 {:runner-install wr :trash wr :card-moved wr})}

    "Yagura"
    {:abilities [{:msg "do 1 net damage" :effect (effect (damage :net 1 {:card card}))}


Surround inky-version with quotes

Surround inky-version with quotes

--- src/clj/inky/entry.clj
+++ src/clj/inky/entry.clj
@@ -164,7 +164,7 @@
          "."]
         [:li [:code "cd inkystarter"]]]]
       [:section
-       [:h4 "Step 2: Add the Inky Leiningen Plugin"]
+       [:h4 "Step 2: Add the Inky Leiningen Plugin to your Lein Profile"]
        [:p "Leiningen allows you globally add functionality, like (surprise!) the ability to compile inky sketches, by adding a specific file to your home directory. We're going to add the lein-inky plugin to this file, which will allow you to compile sketches locally and view them in the same way they'll appear on the site."]
        [:ol
         [:li
@@ -172,7 +172,7 @@
          [:code "~/.lein/profiles.clj"]]
         [:li
          "Add "
-         [:code "[lein-inky " common/inky-version "]"]
+         [:code "[lein-inky \"" common/inky-version "\"]"]
          " to the plugins section. Your " [:code "profiles.clj"] " should look something like:"
          [:br] [:br]
          [:pre


polish a test

polish a test

--- test/tamaki/template/page_test.clj
+++ test/tamaki/template/page_test.clj
@@ -32,8 +32,7 @@
       (is (some? (-> loaded :metadata :title)))
       ))
   (testing "Write a html file about a map generated from a markdown file."
-    (let [config (config/read-config)
-          loaded (#'page/load-md (-> "tamaki/template/test.md" io/resource io/file .getAbsolutePath))]
+    (let [loaded (#'page/load-md (-> "tamaki/template/test.md" io/resource io/file .getAbsolutePath))]
       (is (= nil (#'page/write-page loaded))))
   ))


Disable debug event handler.

Disable debug event handler.

--- src/om_event_bus/impl.cljx
+++ src/om_event_bus/impl.cljx
@@ -106,6 +106,7 @@
       (leg router down-bus mid-ch up-bus)
       (when event-feed
         (fork router down-bus up-bus event-feed)
+        (handle-events! event-feed handler))
         (dbg-handle-events! event-feed handler))
       up-bus)))


Fixed bug from prior commit

Fixed bug from prior commit

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_ice/ontology_ice_gen_rules.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_ice/ontology_ice_gen_rules.clj
@@ -6,8 +6,8 @@
   :head ((?/id rdf/type ccp/IAO_EXT_0000190) ; ontology root concept identifer
          (?/id obo/IAO_0000219 ?/root)) ; denotes
   :sparql-string "select ?root {
-								  ?root rdfs:subClassOf owl:Class .
-								  minus{?root rdf:type ?class}
+								  ?root rdf:type owl:Class .
+								  minus{?root rdfs:subClassOf ?class}
 								  minus{?root owl:deprecated true}
 								         }"
   :reify ([?/id {:ln (:localname ?/root)


Fix warnings on illegal reflective access for XML classes with recent Java versions (#117)

Fixes #91

--- ancient-clj/project.clj
+++ ancient-clj/project.clj
@@ -6,7 +6,7 @@
             :year 2013
             :key "mit"}
   :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
-                 [org.clojure/data.xml "0.0.8"]
+                 [org.clojure/data.xml "0.2.0-alpha6"]
                  [version-clj "0.1.2"]
                  ;; Note that this is the samve version used by s3-wagon-private 1.3.0
                  [com.amazonaws/aws-java-sdk-s3 "1.11.28"]


env variables are strings. must convert to int.

--- src/t2000/server.clj
+++ src/t2000/server.clj
@@ -32,7 +32,7 @@
 (defonce server (atom nil))

 (defn start-server []
-  (let [port (get env :twitlib-http-port 3000)]
+  (let [port (Integer/parseInt (get env :twitlib-http-port 3000))]
     (reset! server (run-server #'app {:port port :join? false}))
     (println (str "Http server started on http://127.0.0.1:" port))))