Add more experiments with custom queryparts.

--- test/suricatta/extend_test.clj
+++ test/suricatta/extend_test.clj
@@ -4,10 +4,11 @@
             [suricatta.dsl :as dsl]
             [suricatta.format :refer [get-sql get-bind-values sqlvec] :as fmt]
             [cheshire.core :refer :all])
-  (:import org.postgresql.util.PGobject))
+  (:import org.postgresql.util.PGobject
+           org.jooq.impl.DSL))

 ;; (def dbspec {:subprotocol "postgresql"
-;;              :subname "//localhost/test"})
+;;              :subname "//127.0.0.1/test"})

 ;; (def ^:dynamic *ctx*)

@@ -45,9 +46,38 @@
 ;;                       obj)))))))

+;; (defn json
+;;   [data]
+;;   (-> (str "'" (generate-string data) "'::json")
+;;       (DSL/queryPart)))
+
+;; (defn json
+;;   [data]
+;;   (proxy [org.jooq.impl.CustomField] [nil org.jooq.util.postgres.PostgresDataType/JSON]
+;;     (toSQL [context]
+;;       (if (.inline context)
+;;         (doto context
+;;           (.sql "'")
+;;           (.sql (generate-string data))
+;;           (.sql "'::json"))
+;;         (.sql context "?")))
+;;     (bind [context]
+;;       (let [statement (.statement context)
+;;             next-index (.nextIndex context)]
+;;         (.setObject statement next-index (doto (PGobject.)
+;;                                            (.setType "json")
+;;                                            (.setValue (generate-string data))))))))
+
+
 ;; (deftest inserting-json
 ;;   (sc/execute *ctx* "create table t1 (data json, k int)")
 ;;   (sc/execute *ctx* ["insert into t1 (data, k) values (?, ?)" (json {:foo "bar"}) 2])
+;;   (-> (sc/fetch *ctx* "select * from t1")
+;;       (println)))
+
+;; (deftest inserting-array
+;;   (sc/execute *ctx* "create table t1 (data json, k int)")
+;;   (sc/execute *ctx* ["insert into t1 (data, k) values ({0}, {1})" (json {:foo "bar"}) 2])
 ;;   (-> (sc/fetch *ctx* "select * from t1")
 ;;       (println)))


+comment

+comment


Add ->coll util helper.

Add ->coll util helper.


flesh out differences between ruby to indexed json fields and luffer fields


Don't forget the new function.

Don't forget the new function.

--- src/active/clojure/monad.cljc
+++ src/active/clojure/monad.cljc
@@ -45,6 +45,10 @@

    :else (with-meta (make-free-bind mv f)
            (meta mv))))
+
+(defn throw-illegal-argument-exception
+  [msg]
+  (c/assertion-violation `throw-illegal-argument-exception "Illegal argument" msg))

 #?(:clj
 (defmacro monadic
@@ -81,6 +85,7 @@
                            (when-not (even? (count bindings))
                              (throw-illegal-argument-exception (str "bindings must be even-sized vector in "
                                                                     *ns* " " ?meta))))]
+
       (cond
        (vector? ?stmt)
        (do


remove unused require

remove unused require

--- src/clj/clj_money/db.clj
+++ src/clj/clj_money/db.clj
@@ -1,7 +1,6 @@
 (ns clj-money.db
   (:refer-clojure :exclude [update])
   (:require [clojure.tools.cli :refer [parse-opts]]
-            [clojure.tools.logging :as log]
             [clojure.core.async :as a :refer [go chan go-loop >! <! <!! buffer]]
             [clojure.pprint :refer [pprint]]
             [clojure.java.io :as io]


Box ints to avoid Clojure auto-coercion to long for #318.

--- src/clj/forma/thrift.clj
+++ src/clj/forma/thrift.clj
@@ -26,6 +26,7 @@
   Example usage for unpacking a TimeSeries:

     > (def ts (TimeSeries* 0 1 [1.0 2.0 3.0]))
+
     > (unpack ts)
     [0 1 #<ArrayValue <ArrayValue doubles:DoubleArray(doubles:[1.0, 2.0, 3.0])>>]

@@ -143,11 +144,17 @@
                 (try (f x)
                      (catch Exception e nil)))))

+(defn box-int
+  "Clojure automatically coerces primitive ints to longs. For Thrift, we need
+  ints, so this helper function boxes an integer value to avoid that coercion."
+  [x]
+  (Integer. (.intValue x)))
+
 (defn int-struct
   "Return a IntArray that contains all numbers in the supplied sequence cast
   to ints."
   [xs]
-  (let [ints (list-of int xs)]
+  (let [ints (map box-int xs)]
     (doto (IntArray.)
       (.setInts ints))))

@@ -180,7 +187,8 @@
                forma.schema.FireValue forma.schema.FormaArray
                forma.schema.FormaValue forma.schema.IntArray
                forma.schema.LongArray forma.schema.TimeSeries
-               java.lang.Double java.lang.Integer java.lang.Long]
+               java.lang.Double java.lang.Integer java.lang.Long
+               java.lang.Short]
         vals (if (coll? x) x (vector x))]
     (some (fn [val] (some #(= (type val) %) types)) vals)))

@@ -362,6 +370,7 @@
 (extend-protocol IPackable
   java.lang.Iterable
   (pack [[v :as xs]]
+    (prn "v" (integer?  v) "xs" (type xs))
     (cond (= forma.schema.FormaValue (type v)) (forma-array xs)
           (= forma.schema.FireValue (type v)) (fire-array xs)
           (integer? v) (int-struct xs)


start in user.dir when searching for build_metadata files

This *should* be the same as $WORKSPACE but will also work with local
tests of runbld as well as with any non-jenkins jobs in the future.

--- src/clj/runbld/build.clj
+++ src/clj/runbld/build.clj
@@ -153,19 +153,21 @@
   "Searches the build workspace for files starting with build_metadata
   and concats their contents and stores it in the build metadata in
   Elasticsearch."
-  [opts]
+  [{:keys [logger] :as opts}]
+  (logger "Searching for build metadata in" (System/getProperty "user.dir"))
   (let [prep-content #(-> %
                           string/trim
                           (string/replace #"\n+$" "")
                           ;; strip trailing semicolons so we can blindly
                           ;; str/join
                           (string/replace #";+$" ""))
-        metadata (->> (rio/find-files (-> opts :process :cwd)
-                                      #"/build_metadata")
+        metadata (->> (rio/find-files
+                       (System/getProperty "user.dir")
+                       #"/build_metadata")
                       (map slurp)
                       (map prep-content)
                       (string/join ";"))]
-    ((:logger opts) "Storing build metadata:" metadata)
+    (logger "Storing build metadata:" metadata)
     (assoc-in opts [:build :metadata] metadata)))


still learning

still learning

--- The-Sieve-of-Eratosthenes/SoE.clj
+++ The-Sieve-of-Eratosthenes/SoE.clj
@@ -0,0 +1 @@
+(defn soe [n])


spacing

spacing

--- test/celestial/test/proxmox.clj
+++ test/celestial/test/proxmox.clj
@@ -120,3 +120,6 @@

    (validate-entity (assoc-in redis-bridged-prox [:machine :netmask] "123")) =>
       (throws ExceptionInfo (with-m? {:machine {:netmask '("must be a legal ip address")}})))
+
+
+


paramType guess works too

paramType guess works too

--- test/celestial/test/swagger.clj
+++ test/celestial/test/swagger.clj
@@ -23,4 +23,6 @@
 (deftest auto-param-type-guessing
     (is (= (-> (GET- "/machine/" [^:string host] {} ()) meta
          (get-in [:parameters 0 :dataType]))) :string)
+    (is (= (-> (GET- "/machine/:host" [^:string host] {} ()) meta
+         (get-in [:parameters 0 :paramType]))) "path")
   )


[clj] bump cider-nrepl

[clj] bump cider-nrepl

--- .boot/profile.boot
+++ .boot/profile.boot
@@ -1,6 +1,6 @@
 ;; https://github.com/clojure-vim/vim-cider#using
 (swap! boot.repl/*default-dependencies*
-       concat '[[cider/cider-nrepl "0.19.0"]
+       concat '[[cider/cider-nrepl "0.20.0"]
                 [refactor-nrepl "2.4.0"]])

 (swap! boot.repl/*default-middleware* conj


Fix an insidious bug in hsv-components.

Fix an insidious bug in hsv-components.


PDOK-4774 Fix CLI runner after Java interop changes

--- src/gml_to_featured/runner.clj
+++ src/gml_to_featured/runner.clj
@@ -161,8 +161,8 @@
         (process reader writer dataset validity))))

   (defn translate-filesystem [dataset edn-config-location validity in-file out-file]
-    (with-open [reader (clojure.java.io/reader in-file),
-                writer (clojure.java.io/writer out-file)]
+    (with-open [reader (clojure.java.io/input-stream in-file),
+                writer (clojure.java.io/output-stream out-file)]
       (translate dataset (slurp edn-config-location) validity reader writer)))

   (defn error-msg [errors]


Add utilities to make working with arrays more similar to vectors

--- src/main/audio_utils/util.cljs
+++ src/main/audio_utils/util.cljs
@@ -1,4 +1,5 @@
-(ns audio-utils.util)
+(ns audio-utils.util
+  (:refer-clojure :exclude [amap]))

 ;;;; Pseudo atom based on a JS array

@@ -21,6 +22,38 @@

 (def << aderef)
 (def >> areset!)
+
+;;;; Array utilities to make using arrays more like using vectors
+
+(defn acount
+  [array]
+  (.-length array))
+
+(defn afirst
+  [array]
+  (aget array 0))
+
+(defn anth
+  [array n]
+  (aget array n))
+
+(defn amap
+  [f array]
+  (into-array (map f (array-seq array))))
+
+(defn aconj
+  [arr x]
+  (doto (or arr (array))
+    (.push x)))
+
+(defn aassoc
+  [array n v]
+  (aset array n v)
+  array)
+
+(defn aupdate
+  [array n f & args]
+  (aassoc array n (apply f (into [(anth array n)] args))))

 ;;;; Time/samples and dB/amplitude conversion


Update lein plugins.

Update lein plugins.

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -3,8 +3,9 @@
                   "eval" ^{:doc
                            "Evaluate a Clojure string with clojure.main/main."}
                     ["run" "-m" "clojure.main/main" "-e"]}
-        :plugins [[lein-shell "0.2.0"]
-                  [lein-miditest "0.1.0"]]}
+        :plugins [[lein-shell "0.3.0"]
+                  [lein-miditest "0.1.0"]
+                  [lein-pprint "1.1.1"]]}
  :math {:dependencies [[org.clojure/math.combinatorics "0.0.2"]
                        [org.clojure/math.numeric-tower "0.0.1"]
                        [org.clojure/tools.trace "0.7.3"]]


[lein] Add JVM options

[lein] Add JVM options

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -14,6 +14,8 @@
                   [cider/cider-nrepl                 "0.15.0"]
                   [venantius/ultra                   "0.5.1"]
                   [venantius/yagni                   "0.1.4"]]
+
+        :jvm-opts ["-XX:-OmitStackTraceInFastThrow"]

         :dependencies [; Code quality
                        [slamhound                    "1.5.5"]


working on rewriting French to the new convention that Italiano and Espanol are using

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -19,7 +19,91 @@
 (require '[dag-unify.core :refer (fail? get-in strip-refs)])

 (defn tout [ & [count]]
-  (let [count (if count (Integer. count) 10)]
+  (let [count (if count (Integer. count) 10)
+        root-verbs
+        (zipmap
+         (keys @lexicon)
+         (map (fn [lexeme-set]
+                (filter (fn [lexeme]
+                          (and
+                           (= (get-in lexeme [:synsem :cat]) :verb)
+                           (= (get-in lexeme [:synsem :infl]) :top)
+                           (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
+                        lexeme-set))
+              (vals @lexicon)))
+        root-verb-array
+        (reduce concat
+                (map (fn [key]
+                       (get root-verbs key))
+                     (sort (keys root-verbs))))]
+    (write-lexicon "fr" @lexicon)
+    (log/info (str "done writing lexicon."))
+    (log/info (str "generating examples with this many verbs:"
+                   (.size root-verb-array)))
+
+    ;; for debugging, change (pmap) to (map) so logging is easier to read: in-order rather than interleaved by multiple workers.
+    (.size (pmap (fn [verb]
+                   (log/trace (str "verb: " (strip-refs verb)))
+                   (let [root-form (get-in verb [:espanol :espanol])]
+                     (log/info (str "generating with verb: '" root-form "'"))
+                     (.size (map (fn [tense]
+                                   (let [spec (unify {:root {:espanol {:espanol root-form}}}
+                                                     tense)]
+                                     (.size
+                                      (map (fn [gender]
+                                             (let [spec (unify spec
+                                                               {:comp {:synsem {:agr gender}}})]
+                                               (log/trace (str "generating from gender: " gender))
+                                               (.size
+                                                (map (fn [person]
+                                                       (let [spec (unify spec
+                                                                         {:comp {:synsem {:agr {:person person}}}})]
+                                                         (log/trace (str "generating from person: " person))
+                                                         (.size
+                                                          (map (fn [number]
+                                                                 (let [spec (unify spec
+                                                                                {:comp {:synsem {:agr {:number number}}}})]
+                                                                   (log/debug (str "generating from spec: " spec))
+                                                                   (try
+                                                                     (process [{:fill-one-language
+                                                                                {:count 1
+                                                                                :spec spec
+                                                                                :model small
+                                                                                }}]
+                                                                              "es")
+                                                                     (catch Exception e
+                                                                       (cond
+
+                                                                        ;; TODO: make this conditional on
+                                                                        ;; there being a legitimate reason for the exception -
+                                                                        ;; e.g. the verb is "funzionare" (which takes a non-human
+                                                                        ;; subject), but we're trying to generate with
+                                                                        ;; {:agr {:person :1st or :2nd}}, for which the only lexemes
+                                                                        ;; are human.
+                                                                        false
+
+                                                                        (log/warn (str "ignoring exception: " e))
+                                                                        true
+                                                                       (throw e))))
+                                                                   ))
+                                                               [:sing :plur]))))
+                                                     [:1st :2nd :3rd]))))
+                                           (cond (= tense
+                                                    {:synsem {:sem {:aspect :perfect
+                                                                    :tense :past}}})
+                                                 [{:gender :masc}
+                                                  {:gender :fem}]
+                                                 true
+                                                 [:top])))))
+                                 (list {:synsem {:sem {:tense :conditional}}}
+                                       {:synsem {:sem {:tense :future}}}
+                                       {:synsem {:sem {:tense :present}}}
+                                       {:synsem {:sem {:aspect :perfect
+                                                       :tense :past}}}
+                                       )))))
+                 root-verb-array))))
+
+

     ;; A place to erase old mistakes (before attempting again).
     ;; TODO: promote to the (process) command set.


s/'()/[]/

s/'()/[]/

--- src/babel/italiano/writer.clj
+++ src/babel/italiano/writer.clj
@@ -64,7 +64,7 @@
                    (log/debug (str "tutti: verb: " (strip-refs verb)))
                    (let [root-form (get-in verb [:italiano :italiano])]
                      (generate-one-verb (unify
-                                         {:synsem {:subcat '()}}
+                                         {:synsem {:subcat []}}
                                          {:modified false}
                                          {:synsem {:sem
                                                    (get-in verb [:synsem :sem] :top)}}


cleanup

cleanup

--- src/babel/italiano/writer.clj
+++ src/babel/italiano/writer.clj
@@ -12,53 +12,7 @@
 (defn rewrite-lexicon []
   (write-lexicon "it" @lexicon))

-(defn camminare [ & [count]]
-  (let [count (if count (Integer. count) 10)
-        ;; subset of the lexicon: only verbs which are infinitives and that can be roots:
-        ;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
-        root-verbs
-        (zipmap
-         (keys @lexicon)
-         (map (fn [lexeme-set]
-                (filter (fn [lexeme]
-                          (and
-                           (= (get-in lexeme [:synsem :cat]) :verb)
-                           (= (get-in lexeme [:synsem :infl]) :top)
-                           (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
-                        lexeme-set))
-              (vals @lexicon)))]
-
-    (delete-from-expressions "it" {:root {:italiano {:italiano "camminare"}}})
-
-    (write-lexicon "it" @lexicon)
-    (log/info (str "done writing lexicon."))
-    (.size (map (fn [verb]
-                  (let [root-form (get-in verb [:italiano :italiano])]
-                    (log/debug (str "generating from root-form:" root-form))
-                    (.size (map (fn [tense]
-                                  (let [spec (unify {:root {:italiano {:italiano root-form}}}
-                                                    tense)]
-                                    (log/debug (str "generating from: " spec))
-                                    (process [{:fill
-                                               {:spec spec
-                                                :source-model en/small-plus-vp-pronoun
-                                                :target-model small
-                                                :count count}}] "it")))
-                                (list {:synsem {:sem {:tense :conditional}}}
-                                      {:synsem {:sem {:tense :future}}}
-                                      {:synsem {:sem {:tense :present}}}
-                                      {:synsem {:sem {:aspect :progressive
-                                                      :tense :past}}}
-                                      {:synsem {:sem {:aspect :perfect
-                                                      :tense :past}}})))))
-                (reduce concat
-                        (map (fn [key]
-                               (get root-verbs key))
-                             (filter #(= % "camminare")
-                                     (sort (keys root-verbs)))))))))
-
-
-(defn alzarsi [ & [count]]
+(defn tutti [ & [count]]
   (let [count (if count (Integer. count) 10)
         ;; subset of the lexicon: only verbs which are infinitives and that can be roots:
         ;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
@@ -74,19 +28,16 @@
                         lexeme-set))
               (vals @lexicon)))

-        alzarsi
+        tutti
         (reduce concat
                 (map (fn [key]
                        (get root-verbs key))
-                     (filter #(= % "alzarsi")
-                             (sort (keys root-verbs)))))]
+                     (sort (keys root-verbs))))]

-    (delete-from-expressions "it" {:root {:italiano {:italiano "alzarsi"}}})
-
-;    (write-lexicon "it" @lexicon)
-;    (log/info (str "done writing lexicon."))
+    (write-lexicon "it" @lexicon)
+    (log/info (str "done writing lexicon."))
     (log/info (str "generating examples with this many verbs:"
-                   (.size alzarsi)))
+                   (.size tutti)))
     (.size (map (fn [verb]
                   (log/trace (str "verb: " (strip-refs verb)))
                   (let [root-form (get-in verb [:italiano :italiano])]
@@ -125,58 +76,13 @@
                                                  {:gender :fem}]
                                                 true
                                                 [:top])))))
-                                (list ;{:synsem {:sem {:tense :conditional}}}
-                                      ;{:synsem {:sem {:tense :future}}}
-                                      ;{:synsem {:sem {:tense :present}}}
-                                      ;{:synsem {:sem {:aspect :progressive
-                                      ;                :tense :past}}}
-                                      {:synsem {:sem {:aspect :perfect
-                                                      :tense :past}}}
-                                      )))))
-                alzarsi))))
-
-(defn tutti [ & [count]]
-  (let [count (if count (Integer. count) 10)
-        ;; subset of the lexicon: only verbs which are infinitives and that can be roots:
-        ;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
-        root-verbs
-        (zipmap
-         (keys @lexicon)
-         (map (fn [lexeme-set]
-                (filter (fn [lexeme]
-                          (and
-                           (= (get-in lexeme [:synsem :cat]) :verb)
-                           (= (get-in lexeme [:synsem :infl]) :top)
-                           (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
-                        lexeme-set))
-              (vals @lexicon)))]
-    (if false
-      (delete-from-expressions "it" {:synsem {:sem {:subj {:pred :io}}}}))
-
-    (write-lexicon "it" @lexicon)
-    (log/info (str "done writing lexicon."))
-    (log/info (str "generating with this many verbs: " (.size (reduce concat (vals root-verbs)))))
-    (.size (map (fn [verb]
-                  (let [root-form (get-in verb [:italiano :italiano])]
-                    (log/debug (str "generating from root-form:" root-form))
-                    (.size (map (fn [tense]
-                                  (let [spec (unify {:root {:italiano {:italiano root-form}}}
-                                                    tense)]
-                                    (log/debug (str "generating from: " spec))
-                                    (process [{:fill
-                                               {:spec spec
-                                                :source-model en/small-plus-vp-pronoun
-                                                :target-model small
-                                                :count count}}] "it")))
                                 (list {:synsem {:sem {:tense :conditional}}}
                                       {:synsem {:sem {:tense :future}}}
                                       {:synsem {:sem {:tense :present}}}
                                       {:synsem {:sem {:aspect :progressive
                                                       :tense :past}}}
                                       {:synsem {:sem {:aspect :perfect
-                                                      :tense :past}}})))))
-                (reduce concat
-                        (map (fn [key]
-                               (get root-verbs key))
-                             (sort (keys root-verbs))))))))
+                                                      :tense :past}}}
+                                      )))))
+                tutti))))


fix node-repl issue related to recent relative path change

--- src/main/shadow/build/node.clj
+++ src/main/shadow/build/node.clj
@@ -129,6 +129,13 @@
               [prepend

                (str "var SHADOW_IMPORT_PATH = __dirname + '/" rel-path "';")
+               ;; special case for node-repl which doesn't execute a file
+               ;; but instead executes the code via stdin pipe
+               (str "if (__dirname == '.') { SHADOW_IMPORT_PATH = "
+                    (-> (data/output-file state cljs-runtime-path)
+                        (.getAbsolutePath)
+                        (pr-str))
+                    "; }")

                "global.$CLJS = global;"


JarUrlConnection doesn't have close

JarUrlConnection doesn't have close

--- src/main/shadow/cljs/build.clj
+++ src/main/shadow/cljs/build.clj
@@ -34,9 +34,9 @@
 ;; (set! *warn-on-reflection* true)

 (def SHADOW-TIMESTAMP
-  (with-open [con (-> (io/resource "shadow/cljs/build.clj")
-                      (.openConnection))]
-    (.getLastModified con)))
+  (-> (io/resource "shadow/cljs/build.clj")
+      (.openConnection)
+      (.getLastModified)))

 (def default-externs (CommandLineRunner/getDefaultExterns))

@@ -240,6 +240,9 @@
           (seq module-type)
           (merge (let [ns (filename->ns name)]
                    (assert (<= 0 (count provides) 1) "module with more than one provide?")
+                   ;; FIXME: cannot do this aliasing, it will break things
+                   ;; source-path-a/lib/foo.js -> lib.foo
+                   ;; source-path-b/lib/foo.js -> lib.foo
                    {:module-type (keyword module-type)
                     :module-alias (first provides)
                     :ns ns
@@ -1391,7 +1394,7 @@
              (map (fn [{:keys [url] :as info}]
                     (if (nil? url)
                       info
-                      (with-open [con (.openConnection url)]
+                      (let [con (.openConnection url)]
                         (assoc info :last-modified (.getLastModified con)))
                       )))
              ;; get file (if not in jar)


Implement segmentation in bpm detection

Implement segmentation in bpm detection

--- src/clj/beat_detector/bpm.clj
+++ src/clj/beat_detector/bpm.clj
@@ -21,20 +21,22 @@
                         [] index-zip))))

 (defn candidate-major-beats
-  "Finds candidate major beats from the given 'pivot' major beat."
+  "Finds the longest major beats candidate chain and constructs them into a
+  vector."
   [times pivot interval]
   (loop [dst [] ^long cand pivot]
     (if (<= cand (+ C (last times)))
       (let [found (find-near cand times)]
-        (if (<= (Math/abs (- cand found)) 4) ; FIXME: 4 is hardcoded
+        (if (<= (Math/abs (- cand found)) 4) ; FIXME hardcoded
           (recur (conj dst found) (+ found interval))
           (recur dst (+ cand interval))))
       dst)))

-(defn find-major-beats ; SLOW
-  [times]
+(defn find-major-beats-segment
+  "Tries candidate-major-beats using times as pivots and finds a long enough
+  major beats chain."
+  [times interval]
   (let [pivots (patterned-beats times)
-        interval (estimated-interval times)
         _ (println "All beats:" times)
         _ (println "Patterned beats:" pivots)
         _ (println "Interval: " interval)]
@@ -47,6 +49,18 @@
                     (println "Elected candidate:" candidates)
                     (reduced candidates))))) 0 pivots)))

+(defn find-major-beats
+  [times]
+  (let [interval (estimated-interval times)
+        segments (reduce (fn [xs y]
+                           (let [xs (vec xs)
+                                 x (if (empty? xs) y (last (last xs)))]
+                             (if (> (- y x) (* 4 interval)) ; New segment
+                               (conj xs (vector y))
+                               (conj (vec (butlast xs))
+                                     (conj (vec (last xs)) y))))) [] times)]
+    (mapcat #(find-major-beats-segment % interval) segments)))
+
 (defn determine-bpm ; SLOW
   [times]
   (let [majors (find-major-beats times)


put the generated file at the right spot

--- src/clj/budget/preprocess.clj
+++ src/clj/budget/preprocess.clj
@@ -24,7 +24,7 @@
    :v2016 (parse-value v2016)})

 (defn load-csv-file [f]
-  (with-open [f (io/reader (io/file (io/resource f)))]
+  (with-open [f (io/reader (io/file f))]
     (into [] (map parse-line (drop 1 (csv/read-csv f))))))

 (defn parse-lines [rows]
@@ -45,10 +45,20 @@
     (assoc node :children (into [] (map walk-node (vals children))))
     node))

-(comment
-  (require '[clojure.pprint :refer [pprint]])
-  (def depenses (load-csv-file "budget2016-depenses.csv"))
-  (def root (parse-lines depenses))
-  (spit (io/file "/tmp/foo.json") (json/generate-string (walk-node root)))
-  ;;(pprint (walk-node nodes))
-  )
+(defn preprocess []
+  (let [input-file (-> "input/budget2016-depenses.csv" io/resource io/file)
+        output-file (-> input-file
+                        (.getParentFile)
+                        (.getParentFile)
+                        (io/file "generated")
+                        (io/file "budget2016-depenses.json"))]
+    (when-not (.exists output-file)
+      (.mkdirs (.getParentFile output-file))
+      (->> (load-csv-file input-file)
+           parse-lines
+           walk-node
+           json/generate-string
+           (spit output-file)))))
+
+(preprocess)
+


spec improvements: - defonce instrumented-vars - s/test/check - better keyword names for check results

Signed-off-by: Rich Hickey <2f3b32171da334ad5d7d0db393d0928eef4308ab@gmail.com>

--- src/clj/clojure/spec/test.clj
+++ src/clj/clojure/spec/test.clj
@@ -125,7 +125,7 @@
                                          first)
                              ed (merge (assoc (s/explain-data* spec [role] [] [] data)
                                          ::s/args args
-                                         ::s/failure :instrument-check-failed)
+                                         ::s/failure :instrument)
                                        (when caller
                                          {::caller (dissoc caller :class :method)}))]
                          (throw (ex-info
@@ -141,14 +141,12 @@
            (.applyTo ^clojure.lang.IFn f args)))
        (.applyTo ^clojure.lang.IFn f args)))))

-(defn- no-fn-spec
+(defn- no-fspec
   [v spec]
   (ex-info (str "Fn at " v " is not spec'ed.")
-           {:var v :spec spec ::s/failure :no-fn-spec}))
-
-(def ^:private instrumented-vars
-     "Map for instrumented vars to :raw/:wrapped fns"
-     (atom {}))
+           {:var v :spec spec ::s/failure :no-fspec}))
+
+(defonce ^:private instrumented-vars (atom {}))

 (defn- instrument-choose-fn
   "Helper for instrument."
@@ -170,7 +168,7 @@
           current @v
           to-wrap (if (= wrapped current) raw current)
           ospec (or (instrument-choose-spec spec s opts)
-                      (throw (no-fn-spec v spec)))
+                      (throw (no-fspec v spec)))
           ofn (instrument-choose-fn to-wrap ospec s opts)
           checked (spec-checking-fn v ofn ospec)]
       (alter-var-root v (constantly checked))
@@ -272,15 +270,15 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; testing  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn- explain-test
+(defn- explain-check
   [args spec v role]
   (ex-info
-   "Specification-based test failed"
+   "Specification-based check failed"
    (when-not (s/valid? spec v nil)
      (assoc (s/explain-data* spec [role] [] [] v)
        ::args args
        ::val v
-       ::s/failure :test-failed))))
+       ::s/failure :check-failed))))

 (defn- check-call
   "Returns true if call passes specs, otherwise *returns* an exception
@@ -288,18 +286,18 @@
   [f specs args]
   (let [cargs (when (:args specs) (s/conform (:args specs) args))]
     (if (= cargs ::s/invalid)
-      (explain-test args (:args specs) args :args)
+      (explain-check args (:args specs) args :args)
       (let [ret (apply f args)
             cret (when (:ret specs) (s/conform (:ret specs) ret))]
         (if (= cret ::s/invalid)
-          (explain-test args (:ret specs) ret :ret)
+          (explain-check args (:ret specs) ret :ret)
           (if (and (:args specs) (:ret specs) (:fn specs))
             (if (s/valid? (:fn specs) {:args cargs :ret cret})
               true
-              (explain-test args (:fn specs) {:args cargs :ret cret} :fn))
+              (explain-check args (:fn specs) {:args cargs :ret cret} :fn))
             true))))))

-(defn- check-fn
+(defn- quick-check
   [f specs {gen :gen opts ::stc/opts}]
   (let [{:keys [num-tests] :or {num-tests 1000}} opts
         g (try (s/gen (:args specs) gen) (catch Throwable t t))]
@@ -312,19 +310,19 @@
   [x]
   (::s/failure (ex-data x)))

-(defn- make-test-result
+(defn- make-check-result
   "Builds spec result map."
-  [test-sym spec test-check-ret]
+  [check-sym spec test-check-ret]
   (merge {:spec spec
           ::stc/ret test-check-ret}
-         (when test-sym
-           {:sym test-sym})
+         (when check-sym
+           {:sym check-sym})
          (when-let [result (-> test-check-ret :result)]
            {:result result})
          (when-let [shrunk (-> test-check-ret :shrunk)]
            {:result (:result shrunk)})))

-(defn- test-1
+(defn- check-1
   [{:keys [s f v spec]} {:keys [result-callback] :as opts}]
   (when v (unstrument s))
   (try
@@ -334,46 +332,46 @@
       {::s/failure :no-fn :sym s :spec spec}

       (:args spec)
-      (let [tcret (check-fn f spec opts)]
-        (make-test-result s spec tcret))
+      (let [tcret (quick-check f spec opts)]
+        (make-check-result s spec tcret))

       :default
       {::s/failure :no-args-spec :sym s :spec spec}))
    (finally
     (when v (instrument s)))))

-(defn- sym->test-map
+(defn- sym->check-map
   [s]
   (let [v (resolve s)]
     {:s s
      :v v
      :spec (when v (s/get-spec v))}))

-(defn- validate-test-opts
+(defn- validate-check-opts
   [opts]
-  (assert (every? ident? (keys (:gen opts))) "test :gen expects ident keys"))
-
-(defn test-fn
+  (assert (every? ident? (keys (:gen opts))) "check :gen expects ident keys"))
+
+(defn check-fn
   "Runs generative tests for fn f using spec and opts. See
-'test' for options and return."
-  ([f spec] (test-fn f spec nil))
+'check' for options and return."
+  ([f spec] (check-fn f spec nil))
   ([f spec opts]
-     (validate-test-opts opts)
-     (test-1 {:f f :spec spec} opts)))
+     (validate-check-opts opts)
+     (check-1 {:f f :spec spec} opts)))

 (defn testable-syms
-  "Given an opts map as per test, returns the set of syms that
+  "Given an opts map as per check, returns the set of syms that
 can be tested."
   ([] (testable-syms nil))
   ([opts]
-     (validate-test-opts opts)
+     (validate-check-opts opts)
      (reduce into #{} [(filter fn-spec-name? (keys (s/registry)))
                        (keys (:spec opts))])))

-(defn test
+(defn check
   "Run generative tests for spec conformance on vars named by
 sym-or-syms, a symbol or collection of symbols. If sym-or-syms
-is not specified, test all testable vars.
+is not specified, check all testable vars.

 The opts map includes the following optional keys, where stc
 aliases clojure.spec.test.check:
@@ -385,39 +383,41 @@
 documented by test.check. Generator overrides are passed to
 spec/gen when generating function args.

-Returns a lazy sequence of test result maps with the following
+Returns a lazy sequence of check result maps with the following
 keys

 :spec       the spec tested
-:type       the type of the test result
+:type       the type of the check result
 :sym        optional symbol naming the var tested
-:result     optional test result
+:result     optional check result
 ::stc/ret   optional value returned by test.check/quick-check

 Values for the :result key can be one of

-true        passing test
-exception   code under test threw
+true        passing check
+exception   code under check threw
 map         with explain-data under :clojure.spec/problems

 Values for the :type key can be one of

-:pass       test passed
-:fail       test failed
-:error      test threw
-:no-argspec no :args in fn-spec
-:no-gen     unable to generate :args
-:no-fn      unable to resolve fn to test
+:check-passed   all checked fn returns conformed
+:check-failed   at least one checked return did not conform
+:check-threw    checked fn threw an exception
+:no-args-spec   no :args spec provided
+:no-fn          no fn provided
+:no-fspec       no fspec provided
+:no-gen         unable to generate :args
+:instrument     invalid args detected by instrument
 "
-  ([] (test (testable-syms)))
-  ([sym-or-syms] (test sym-or-syms nil))
+  ([] (check (testable-syms)))
+  ([sym-or-syms] (check sym-or-syms nil))
   ([sym-or-syms opts]
      (->> (collectionize sym-or-syms)
           (filter (testable-syms opts))
           (pmap
-           #(test-1 (sym->test-map %) opts)))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; test reporting  ;;;;;;;;;;;;;;;;;;;;;;;;
+           #(check-1 (sym->check-map %) opts)))))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; check reporting  ;;;;;;;;;;;;;;;;;;;;;;;;

 (defn- unwrap-failure
   [x]
@@ -429,12 +429,12 @@
   [ret]
   (let [result (:result ret)]
     (cond
-     (true? result) :test-passed
+     (true? result) :check-passed
      (failure-type result) (failure-type result)
-     :default :test-threw)))
+     :default :check-threw)))

 (defn abbrev-result
-  "Given a test result, returns an abbreviated version
+  "Given a check result, returns an abbreviated version
 suitable for summary use."
   [x]
   (if (true? (:result x))
@@ -444,13 +444,13 @@
         (update :result unwrap-failure))))

 (defn summarize-results
-  "Given a collection of test-results, e.g. from 'test', pretty
+  "Given a collection of check-results, e.g. from 'check', pretty
 prints the summary-result (default abbrev-result) of each.

 Returns a map with :total, the total number of results, plus a
 key with a count for each different :type of result."
-  ([test-results] (summarize-results test-results abbrev-result))
-  ([test-results summary-result]
+  ([check-results] (summarize-results check-results abbrev-result))
+  ([check-results summary-result]
      (reduce
       (fn [summary result]
         (pp/pprint (summary-result result))
@@ -458,7 +458,7 @@
             (update :total inc)
             (update (result-type result) (fnil inc 0))))
       {:total 0}
-       test-results)))
-
-
-
+       check-results)))
+
+
+


Implement Lily Lockwell

Implement Lily Lockwell

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -279,6 +279,20 @@
                  :choices (req (filter #(has? % :type "ICE") (:deck corp)))
                  :label "Search R&D for a piece of ICE"
                  :cost [:click 1 :credit 1] :effect (effect (move target :hand) (shuffle! :deck))}]}
+
+   "Lily Lockwell"
+   {:effect (effect (draw 3))
+    :msg (msg "draw 3 cards")
+    :abilities [{:label "Remove a tag to search R&D for an operation"
+                 :prompt "Choose an operation to put on top of R&D"
+                 :cost [:click 1]
+                 :choices (req (filter #(has? % :type "Operation") (:deck corp)))
+                 :req (req (> (get-in @state [:runner :tag]) 0))
+                 :effect (req (let [c (move state :corp target :play-area)]
+                                (shuffle! state :corp :deck)
+                                (move state :corp c :deck {:front true})
+                                (lose state :runner :tag 1)
+                                (system-msg state side (str "uses Lily Lockwell to put " (:title c) " on top of R&D"))))}]}

    "Mark Yale"
    {:events {:agenda-counter-spent {:effect (effect (gain :credit 1))


Make exploring grant less will to live

Make exploring grant less will to live

--- src/cljc/robinson/update.cljc
+++ src/cljc/robinson/update.cljc
@@ -148,7 +148,7 @@
         dwtl             (/ (reduce (fn [acc [x y]] (+ acc (- (dec new-time)
                                                               (get (rw/get-cell state x y) :discovered (- new-time 10000)))))
                                  0 visible-cells)
-                            48000)
+                            888000)
         _                (log/info "delta will-to-live" (float dwtl))
         will-to-live     (min (+ will-to-live dwtl)
                               max-will-to-live)]


acr routes #331

acr routes
#331

--- src/cljc/swarmpit/routes.cljc
+++ src/cljc/swarmpit/routes.cljc
@@ -132,6 +132,8 @@
                                             ["/" :id "/edit"] :reg-v2-edit}
                    "/registries/ecr"       {["/" :id]         :reg-ecr-info
                                             ["/" :id "/edit"] :reg-ecr-edit}
+                   "/registries/acr"       {["/" :id]         :reg-acr-info
+                                            ["/" :id "/edit"] :reg-acr-edit}
                    "/registries/dockerhub" {["/" :id]         :reg-dockerhub-info
                                             ["/" :id "/edit"] :reg-dockerhub-edit}
                    "/users"                {""                :user-list


Update Helloworld message

Update Helloworld message

--- src/cljs/babelfeesh/core.cljs
+++ src/cljs/babelfeesh/core.cljs
@@ -4,7 +4,7 @@

 (enable-console-print!)

-(defonce app-state (atom {:text "Hello Babelfeesh!"}))
+(defonce app-state (atom {:text "Hello Babelfeesh!!"}))

 (defn main []
   (om/root


Made styling / DOM more like actual app

Made styling / DOM more like actual app

--- src/cljs/iframe_app/core.cljs
+++ src/cljs/iframe_app/core.cljs
@@ -45,6 +45,7 @@

 (defn get-fields-by-ids [fields ids]
   (filter #(ids (:id %)) fields))
+

 (defcomponent conditions-manager [conditions owner]
@@ -182,40 +183,73 @@
   (render-state [_ {:keys [selected-field-id slave-fields-picker-chan
                            selected-value]}]
     (html
-      [:div.cfa_navbar
-       [:div.pane.left
-        [:aside.sidebar
-         [:div.all_rules
-          [:h4.rules_summary_title
-           "Conditions in this form"]
-          (om/build conditions-manager (:conditions app-state))
-          ]]]
-       [:div.pane.right.section
-        [:section.main
-         [:ul.table-header.clearfix
-          [:li "Fields"]
-          [:li "Values"]
-          [:li "Fields to show"]]
-
-         [:div.table-wrapper
-          [:table.table
-           [:tbody
-            [:tr
-             [:td.fields
-              [:div.separator "Available"]
-              (om/build master-field-picker
-                        (:selections app-state))]
-
-             [:td.key
-              [:div.values
+      [:section.ember-view.apps.app-554.apps_nav_bar.app_pane.main_panes
+       [:header
+        [:h3 "Conditional Fields"]]
+
+       [:div.cfa_navbar
+        {:data-main 1}
+        [:div.pane.left
+         [:h4 "Conditions for:"]
+         [:select {:style {:width "90%"}}
+          [:option "Agent"]
+          [:option "what"]]
+
+         [:h4 "Ticket Form:"]
+         [:select {:style {:width "90%"}}
+          [:option "Default Ticket Form"]
+          [:option "what"]]
+
+         [:aside.sidebar
+          [:div.all_rules
+           [:h4.rules_summary_title
+            (str "Conditions in this form (" (count (:conditions app-state)) ")")]
+           (om/build conditions-manager (:conditions app-state))]]]
+        [:div.pane.right.section
+         [:section.main
+          [:div.intro
+           [:h3 "Manage conditional fields"]
+           [:p
+            "Configure your conditions to build your conditional fields. Select a field, a value for that field, and the appropriate field to show. "
+            [:a
+             {:target "_blank",
+              :href
+                      "https://support.zendesk.com/entries/26674953-Using-the-Conditional-Fields-app-Enterprise-Only-"}
+             "Learn more."]]]
+
+          [:ul.table-header.clearfix
+           [:li "Fields"]
+           [:li "Values"]
+           [:li "Fields to show"]]
+
+          [:div.table-wrapper
+           [:table.table
+            [:tbody
+             [:tr
+              [:td.fields
                [:div.separator "Available"]
-               (om/build value-picker
-                         (:selections app-state))
-               ]]
-             [:td.selected
-              [:div.values
-               [:div.separator "Available"]
-               (om/build slave-fields-picker (:selections app-state))]]]]]]]]])))
+               (om/build master-field-picker
+                         (:selections app-state))]
+
+              [:td.key
+               [:div.values
+                [:div.separator "Available"]
+                (om/build value-picker
+                          (:selections app-state))
+                ]]
+              [:td.selected
+               [:div.values
+                [:div.separator "Available"]
+                (om/build slave-fields-picker (:selections app-state))]]]]]]]]
+
+        [:footer
+         [:div.pane
+          [:button.delete.text-error.deleteAll
+           {:style {:display :none}}
+           "Delete all conditional rules for this form"]
+          [:div.action-buttons.pull-right
+           [:button.btn.cancel {:disabled "disabled"} "Cancel changes"]
+           [:button.btn.btn-primary.save {:disabled "disabled"} "Save"]]]]]])))

@@ -230,3 +264,10 @@
     {:target (. js/document (getElementById "app"))
      :shared {:pick-channel (chan)}}))

+
+
+
+
+
+
+


Add general state merging mutator

Add general state merging mutator

--- src/cljs/koeeoadi/parser.cljs
+++ src/cljs/koeeoadi/parser.cljs
@@ -75,6 +75,10 @@
 ;; non-local
 (defmethod mutate :default
   [_ _ _] {:remote true})
+
+(defmethod mutate 'state/merge
+  [{:keys [state]} _ props]
+  (swap! state merge props))

 (defmethod mutate 'theme/update
   [{:keys [state]} _ props]


Remove lazy monad.

Remove lazy monad.

--- src/cljx/cats/monad/lazy.cljx
+++ src/cljx/cats/monad/lazy.cljx
@@ -1,78 +0,0 @@
-(ns cats.monad.lazy
-  "The Lazy Monad."
-  #+clj
-  (:require [cats.protocols :as proto]
-            [cats.core :as m :refer (with-monad)])
-  #+cljs
-  (:require-macros [cats.core :refer (with-monad)])
-  #+cljs
-  (:require [cats.protocols :as proto]
-            [cats.core :as m]))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Delay/Lazy Monad
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(def lazy-monad
-  (reify
-    proto/Functor
-    (fmap [_ f fv]
-      (delay (f (proto/get-value fv))))
-
-    proto/Applicative
-    (pure [_ v]
-      (delay v))
-
-    (fapply [m af av]
-      (proto/fmap m (deref af) av))
-
-    proto/Monad
-    (mbind [m self f]
-      (delay
-       (with-monad m
-         (proto/get-value (f @self)))))
-
-    (mreturn [_ v]
-      (delay v))))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Monad transformer definition
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-(defn lazy-transformer [inner-monad]
-  (reify
-    proto/Functor
-    (fmap [_ f fv]
-      (proto/fmap lazy-monad
-                  (partial proto/fmap inner-monad f)
-                  fv))
-    proto/Monad
-    (mreturn [_ v]
-      (->> (proto/mreturn inner-monad v)
-           (proto/mreturn lazy-monad)))
-
-    (mbind [_ mv f]
-      (proto/mbind lazy-monad
-                   mv
-                   (fn [mv']
-                     (proto/mbind inner-monad mv' f))))
-
-    proto/MonadTrans
-    (base [_]
-      lazy-monad)
-
-    (inner [_]
-      inner-monad)
-
-    (lift [_ mv]
-      (proto/mbind inner-monad
-                   mv
-                   (fn [v]
-                     (->> (proto/mreturn inner-monad v)
-                          (proto/mreturn lazy-monad)))))))
-
-(extend-type #+clj clojure.lang.Delay
-             #+cljs cljs.core.Delay
-  proto/Context
-  (get-context [_] lazy-monad)
-  (get-value [self] @self))


Restore functions for runtime resource resolution

Separate these function from compile-time ones. This way it is
possible to resolve resources in both runtime and compile-time.

--- src/clojure/neko/resource.clj
+++ src/clojure/neko/resource.clj
@@ -11,30 +11,28 @@

 (ns neko.resource
   "Provides utilities to resolve application resources."
-  (:require [clojure.string :as string])
-  (:use [neko.init.options :only [*package-name*]]
-        [neko.context :only [context]]))
+  (:require [clojure.string :as string]
+            [neko.context :as context])
+  (:use [neko.init.options :only [*package-name*]])
+  (:import android.content.Context android.graphics.drawable.Drawable))
+
+;; ## Runtime resource resolution

 (def package-name *package-name*)

-(defn- resource-symbol
-  "Returns a symbol that represents a resource field specified by type
-  and name keywords. If `name` is not a keyword, just returns it back."
-  [type name]
-  (if (not (keyword? name))
-    name
-    (let [package (or (namespace name) package-name)
-          type    (clojure.core/name type)
-          name    (-> (clojure.core/name name)
-                      (string/replace \- \_)
-                      (string/replace \. \_))]
-      (symbol (str package ".R$" type "/" name)))))
+(defn- kw-to-res-name
+  "Takes the name of the keyword and turns all hyphens and periods to
+  underscores."
+  [kw]
+  (-> (name kw)
+      (string/replace \- \_)
+      (string/replace \. \_)))

-(defmacro get-resource
+(defn get-resource
   "Resolves the resource ID of a given type with the given name.  For example,
   to refer to what in Java would be R.string.my_string, you can use:

-    (get-resource :string :my_string)
+    `(get-resource :string :my-string)`

   The type should be a keyword corresponding to a resource type such as
   :layout, :attr, or :id.
@@ -45,7 +43,7 @@
   can be used to access the resources from the platform.  For example, the
   equivalent to android.R.layout.simple_list_item_1 is:

-    (get-resource :layout :android/simple_list_item_1)
+    `(get-resource :layout :android/simple-list-item-1)`

   The name portion of the name argument will be converted to a string and any
   hyphens or periods will be transformed to underscores.  Note that hyphens are
@@ -53,29 +51,111 @@

   If the name argument is an integer, it is assumed to be a valid resource ID
   and will be returned as is without any processing."
+  ([res-type res-name]
+     (get-resource context/context res-type res-name))
+  ([^Context context, res-type res-name]
+     (if (keyword? res-name)
+       (.getIdentifier (.getResources context)
+                       (kw-to-res-name res-name)
+                       (name res-type)
+                       (or (namespace res-name)
+                           (.getPackageName context)))
+       res-name)))
+
+(defn get-id
+  "Finds the ID for the XML item with the given name. This is simply a
+  convenient way of calling `(get-resource :id name)`."
+  ([res-name]
+     (get-resource context/context :id res-name))
+  ([^Context context, res-name]
+     (get-resource context :id res-name)))
+
+(defn get-layout
+  "Finds the resource ID for the layout with the given name. This is simply a
+  convenient way of calling `(get-resource :layout name)`."
+  ([res-name]
+     (get-resource context/context :layout res-name))
+  ([^Context context, res-name]
+     (get-resource context :layout res-name)))
+
+(defn get-string
+  "Gets the localized string with the given ID or name from the context.
+  The name will be resolved using get-resource. If res-name is a
+  string, returns it unchanged.
+
+  If additional arguments are supplied, the string will be interpreted as a
+  format and the arguments will be applied to the format."
+  [& args]
+  (let [[^Context context args] (if (instance? Context (first args))
+                                  [(first args) (rest args)]
+                                  [context/context args])
+        [res-name & format-args] args]
+    (if (string? res-name)
+      res-name
+      (if format-args
+        (.getString context (get-resource context :string res-name)
+                    (to-array format-args))
+        (.getString context (get-resource context :string res-name))))))
+
+(alter-meta! #'get-string
+             assoc :arglists '([res-name & format-args?] [context res-name & format-args?]))
+
+(defn get-drawable
+  "Gets a Drawable object associated with the given ID or name from
+  the context. The name will be resolved using get-resource. If
+  res-name is a Drawable, returns it unchanged."
+  ([res-name]
+     (get-drawable context/context res-name))
+  ([^Context context, res-name]
+     (if (instance? Drawable res-name)
+       res-name
+       (.getDrawable (.getResources context)
+                     (get-resource context :drawable res-name)))))
+
+;; Compile time resource resolution
+
+(defn- resource-symbol
+  "Returns a symbol that represents a resource field specified by type
+  and name keywords. If `name` is not a keyword, just returns it back."
+  [res-type res-name]
+  (if (not (keyword? res-name))
+    name
+    (let [package (or (namespace res-name) package-name)
+          res-type (name res-type)
+          res-name (kw-to-res-name res-name)]
+      (symbol (str package ".R$" res-type "/" res-name)))))
+
+(defmacro resolve-resource
+  "Resolves a resource identifier by its type and name. This is the
+  same as `get-resource`, but executes in compile-time."
   [type name]
   {:pre  [(keyword? type)]}
   (resource-symbol type name))

-(defmacro get-id
-  "Finds the ID for the XML item with the given name.  This is simply a
-  convenient way of calling (get-resource :id name)."
+(defmacro resolve-id
+  "Finds the resource ID for the XML item with the given name in
+  compile time. This is simply a convenient way of calling
+  `(resolve-resource :id name)`."
   [name]
   (resource-symbol :id name))

-(defmacro get-string
-  "Gets the localized string with the given ID or name from the context.
-  The name will be resolved using get-resource.
+(defmacro resolve-string
+  "Finds the resource ID for the string with the given name in compile
+  time. This is simply a convenient way of calling `(resolve-resource
+  :string name)`."
+  [name]
+  (resource-symbol :string name))

-  If additional arguments are supplied, the string will be interpreted as a
-  format and the arguments will be applied to the format."
-  ([name]
-     `(.getString context ~(resource-symbol :string name)))
-  ([name & args]
-     `(.getString context ~(resource-symbol :string name) (to-array ~args))))
-
-(defmacro get-layout
-  "Finds the resource ID for the layout with the given name.  This is simply a
-  convenient way of calling (get-resource context :layout name)."
+(defmacro resolve-layout
+  "Finds the resource ID for the layout with the given name in compile
+  time. This is simply a convenient way of calling `(resolve-resource
+  :layout name)`."
   [name]
   (resource-symbol :layout name))
+
+(defmacro resolve-drawable
+  "Finds the resource ID for the Drawable with the given name in compile
+  time. This is simply a convenient way of calling `(resolve-resource
+  :drawable name)`."
+  [name]
+  (resource-symbol :drawable name))


Retry failing job-status polls with exponential backoff.

--- src/clojure/parkour/graph.clj
+++ src/clojure/parkour/graph.clj
@@ -11,7 +11,8 @@
             [parkour.util.shutdown :as shutdown]
             [parkour.util :refer
              [ignore-errors returning doto-let prev-reset!]])
-  (:import [java.util.concurrent ExecutionException]
+  (:import [java.io IOException]
+           [java.util.concurrent ExecutionException]
            [clojure.lang Var]
            [org.apache.hadoop.io NullWritable]
            [org.apache.hadoop.mapreduce Job]
@@ -299,13 +300,32 @@
     (cstep/apply! (cstep/base jname))
     (cstep/apply! (:config node))))

+(defn ^:private check-job-status
+  [f ^Job job]
+  (let [interval (conf/get-int job "jobclient.completion.poll.interval" 5000)
+        attempts (conf/get-int job "parkour.jobclient.attempts" 3)]
+    (loop [i 1]
+      (let [[res exp] (try [(f job) nil] (catch IOException exp [nil exp]))]
+        (cond
+         (nil? exp) res
+         (>= i attempts) (throw exp)
+         :else (let [interval (* interval (bit-shift-left 1 (dec i)))]
+                 (Thread/sleep interval)
+                 (recur (inc i))))))))
+
+(def ^:private job-complete?
+  (partial check-job-status #(.isComplete ^Job %)))
+
+(def ^:private job-successful?
+  (partial check-job-status #(.isSuccessful ^Job %)))
+
 (defn ^:private job-running?
   "True iff `job` is currently running."
-  [^Job job] (boolean (ignore-errors (not (.isComplete job)))))
+  [^Job job] (boolean (ignore-errors (not (job-complete? job)))))

 (defn ^:private job-ran?
   "True iff `job` ran or is currently running."
-  [^Job job] (boolean (ignore-errors (.isComplete job) true)))
+  [^Job job] (boolean (ignore-errors (job-complete? job) true)))

 (defn ^:private abort-fn
   "Function for terminating `job`, killing it and cleaning up output path(s)."
@@ -321,7 +341,7 @@
             (log/warn "Stopping job" jname)
             (ignore-errors
              (.killJob job)
-             (while (not (.isComplete job))
+             (while (not (job-complete? job))
                (Thread/sleep 100))))
           (when (job-ran? job)
             (doseq [[fs path] fs-paths]
@@ -341,9 +361,9 @@
       (try
         (log/info "Launching job" jname)
         (.submit job)
-        (while (not (.isComplete job))
+        (while (not (job-complete? job))
           (Thread/sleep interval))
-        (doto-let [result (.isSuccessful job)]
+        (doto-let [result (job-successful? job)]
           (if result
             (log/info "Job" jname "succeeded")
             (do


Changed Exception in catch to Throwable in errors.clj.

--- src/cmr/common/api/errors.clj
+++ src/cmr/common/api/errors.clj
@@ -27,6 +27,6 @@
             (do
               (error e)
               internal-error-ring-response))))
-      (catch Exception e
+      (catch Throwable e
         (error e)
         internal-error-ring-response))))


Added option to disable use of compression in applications.

--- src/cmr/dev_system/system.clj
+++ src/cmr/dev_system/system.clj
@@ -38,7 +38,23 @@
   [:metadata-db :index-set :indexer :ingest :transformer :search :bootstrap])

 (def in-memory-elastic-port 9206)
+
 (def in-memory-elastic-port-for-connection 9206)
+
+(def use-compression?
+  "Indicates whether the servers will use gzip compression. Disable this to make tcpmon usable"
+  true)
+
+(defn- set-app-compression
+  "Modifies the app server instances to configure the use of compression or not. Takes the system
+  and returns it with the updates made. Should be run a system before it is started"
+  [system]
+  (update-in system [:apps]
+             (fn [app-map]
+               (into {} (for [[app-name app-system] app-map]
+                          [app-name (assoc-in app-system
+                                              [:web :use-compression?]
+                                              use-compression?)])))))

 (defmulti create-system
   "Returns a new instance of the whole application."
@@ -111,17 +127,18 @@

 (defn- start-apps
   [system]
-  (reduce (fn [system app]
-            (let [{start-fn :start} (app-control-functions app)]
-              (update-in system [:apps app]
-                         #(try
-                            (when %
-                              (start-fn %))
-                            (catch Exception e
-                              (stop-components (stop-apps system))
-                              (throw e))))))
-          system
-          app-startup-order))
+  (let [system (set-app-compression system)]
+    (reduce (fn [system app]
+              (let [{start-fn :start} (app-control-functions app)]
+                (update-in system [:apps app]
+                           #(try
+                              (when %
+                                (start-fn %))
+                              (catch Exception e
+                                (stop-components (stop-apps system))
+                                (throw e))))))
+            system
+            app-startup-order)))

 (defn start
   "Performs side effects to initialize the system, acquire resources,


Tiny efficiency tweak.

Tiny efficiency tweak.

--- src/com/lemonodor/viterbi.clj
+++ src/com/lemonodor/viterbi.clj
@@ -24,15 +24,15 @@
     [path v]))

-(defn candidates-for-state [hmm obs v t y]
+(defn candidates-for-state [hmm obs-t v y]
   (let [{:keys [states trans-p emit-p]} hmm]
     (let [candidates
-          (map (fn [[i y0]]
+          (map (fn [y0]
                  [(+ (v y0)
                      (Math/log10 (trans-p y0 y))
-                     (Math/log10 (emit-p y (obs t))))
+                     (Math/log10 (emit-p y obs-t)))
                   y0])
-               (indexed states))]
+               states)]
       candidates)))

@@ -43,8 +43,9 @@
 (defn run-step [hmm obs prev-v path t]
   ;;(println "prev-v:" prev-v)
   (let [{:keys [states trans-p emit-p]} hmm
+        obs-t (obs t)
         updates (pmap (fn [y]
-                       (let [candidates (candidates-for-state hmm obs prev-v t y)
+                       (let [candidates (candidates-for-state hmm obs-t prev-v y)
                              [prob state] (best-candidate candidates)]
                          ;;(println
                          ;; (str "  candidates for state " y ": " (apply list candidates)))


No longer validate the docauthor

No longer validate the docauthor

--- src/mdr2/dtbook/validation.clj
+++ src/mdr2/dtbook/validation.clj
@@ -19,8 +19,7 @@

 (def ^:private param-mapping
   {:title [(get-metadata-path "dc:Title")]
-   :creator [(get-metadata-path "dc:Creator")
-             (get-element-path :docauthor)]
+   :creator [(get-metadata-path "dc:Creator")]
    :subject [(get-metadata-path "dc:Subject")]
    :description [(get-metadata-path "dc:Description")]
    :publisher [(get-metadata-path "dc:Publisher")]


add a data migration which sets the proper values for `fk_target_field_id` based on existing metabase_foreignkey entries.

--- src/metabase/db/migrations.clj
+++ src/metabase/db/migrations.clj
@@ -149,3 +149,12 @@
       (k/set-fields {:visibility_type "normal"})
       (k/where      {:visibility_type "unset"
                      :active          true}))))
+
+
+(defmigration migrate-fk-metadata
+  (when (> 1 (:cnt (first (k/select Field (k/aggregate (count :*) :cnt) (k/where (not= :fk_target_field_id nil))))))
+    (when-let [fks (not-empty (db/sel :many ForeignKey))]
+      (doseq [{:keys [origin_id destination_id]} fks]
+        (k/update Field
+          (k/set-fields {:fk_target_field_id destination_id})
+          (k/where      {:id                 origin_id}))))))


Fix wrong var name

Fix wrong var name

--- src/midara/builder/builder.clj
+++ src/midara/builder/builder.clj
@@ -124,7 +124,7 @@
     ;    source /workspace/.midara
     ; then `.main` function in `.midara` is kicked off and run
     ;(sh "docker" "run" "--rm" "-v" "/var/run/docker.sock:/var/run/docker.sock" "-v" (str workdir "/src:/workspace") "-v" "" "docker" "'source /workspace/.midara; main'" " >> " build-log " 2>&1")))
-    (def docker (if (is-trusted-build? owner repo (get-in [:sender :username]))
+    (def docker (if (is-trusted-build? owner name (get-in [:sender :username]))
       (str "docker run --rm -e REPO_COMMIT=" commit " -e REPO_OWNER=" (clojure.string/lower-case owner) " -e REPO_NAME=" (clojure.string/lower-case name) " -v /var/run/docker.sock:/var/run/docker.sock -v " workdir "/src:/workspace -v " project-dir "/env:/env -v " pwd "/resources/scripts/build:/build notyim/midara-builder:0.1 /build >> " build-log " 2>&1")
       "@TODO implement untrusted build commnand here"
       ))


[#2127] Add "metadata" as a groupId and groupName in flow data

--- backend/src/akvo/lumen/lib/import/flow_common.clj
+++ backend/src/akvo/lumen/lib/import/flow_common.clj
@@ -113,13 +113,14 @@
 (def metadata-keys #{"identifier" "instance_id" "display_name" "submitter" "submitted_at" "surveyal_time" "device_id"})

 (defn commons-columns [form]
-  [(cond-> {:title "Identifier" :type "text" :id "identifier"}
-     (:registration-form? form) (assoc :key true))
-   {:title "Instance id" :type "text" :id "instance_id" :key true}
-   {:title "Display name" :type "text" :id "display_name"}
-   {:title "Submitter" :type "text" :id "submitter"}
-   {:title "Submitted at" :type "date" :id "submitted_at"}
-   {:title "Surveyal time" :type "number" :id "surveyal_time"}])
+  (->> [(cond-> {:title "Identifier" :type "text" :id "identifier"}
+          (:registration-form? form) (assoc :key true))
+        {:title "Instance id" :type "text" :id "instance_id" :key true}
+        {:title "Display name" :type "text" :id "display_name"}
+        {:title "Submitter" :type "text" :id "submitter"}
+        {:title "Submitted at" :type "date" :id "submitted_at"}
+        {:title "Surveyal time" :type "number" :id "surveyal_time"}]
+       (mapv #(assoc % :groupName "metadata" :groupId "metadata"))))

 (defn common-records [form-instance data-point]
   {:instance_id   (get form-instance "id")


[#1077] Validate layer spec WIP

[#1077] Validate layer spec WIP

--- backend/src/akvo/lumen/lib/visualisation/maps.clj
+++ backend/src/akvo/lumen/lib/visualisation/maps.clj
@@ -41,11 +41,32 @@
              "metadata" metadata
              "tenantDB" db-name})))

+(defn invalid-location-spec? [layer]
+  false)
+
+(defn conform-create-args [dataset-id layer]
+  (clojure.pprint/pprint layer)
+  (cond
+    (nil? dataset-id)
+    (throw (ex-info "No datasetID"
+                    {"reason" "No datasetID"}))
+    (nil? layer)
+    (throw (ex-info "No layer"
+                    {"reason" "No layer"}))
+    (invalid-location-spec? layer)
+    (throw (ex-info "No geom"
+                    {"reason" "No geom"}))
+    :else [dataset-id layer]))
+
+
 (defn create
   [tenant-conn windshaft-url dataset-id layer]
-  (if (nil? dataset-id)
-    (lib/bad-request {"reason" "No datasetID"})
-    (do-create tenant-conn windshaft-url dataset-id layer)))
+  (try
+    (let [[dataset-id layer] (conform-create-args dataset-id layer)]
+      (do-create tenant-conn windshaft-url dataset-id layer))
+    (catch Exception e
+      (lib/bad-request (ex-data e)))))
+


[#85] Remove dummy test

[#85] Remove dummy test

--- backend/test/org/akvo/dash/endpoint/flow_test.clj
+++ backend/test/org/akvo/dash/endpoint/flow_test.clj
@@ -1,9 +1,3 @@
 (ns org.akvo.dash.endpoint.flow-test
   (:require [clojure.test :refer :all]
             [org.akvo.dash.endpoint.flow :as flow]))
-
-
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


Minor

Minor

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -299,10 +299,8 @@
 (defn toggle-class
   "Toggle CSS class of provided DOM element. A third paramenter as boolean can be provided to
    force removing or adding the class."
-  ([dom-element class]
-   (.classList/toggle dom-element class))
-  ([dom-element class bool]
-   (.classList/toggle dom-element class bool)))
+  ([dom-element class] (.classList/toggle dom-element class))
+  ([dom-element class bool] (.classList/toggle dom-element class bool)))

 (defn remove-class
   "Remove a specific class of a DOM element."


Fix typos, propose better wording for ui_component

--- src/keechma/ui_component.cljs
+++ src/keechma/ui_component.cljs
@@ -154,7 +154,7 @@
   ;; Returns a new version of the `news-component` with the :user-profile component resolved
   ```

-  Two shorthand functions are defined that allow you to omit first two arguments:
+  Two shorthand functions are defined that allow you to omit the first two arguments:

   - `resolve-subscription-dep` - Resolves a subscription dependency
   - `resolve-component-dep` - Resolves a component dependency
@@ -222,7 +222,7 @@
   "Creates a component system.

   Component system is a group of components that are interdependent. Each component
-  system must define a `:main` component which will be returned from the `system`
+  system must define a `:main` component that will be returned from the `system`
   function.

   `system` function resolves dependencies between components.
@@ -239,7 +239,7 @@
   Chat room list component has a subscription dependency on `:chat-rooms` which will
   return the list of chat rooms to render.

-  Usually you would either pass the chat rooms subscription from layout to sidebar to the
+  Usually, you would either pass the chat rooms subscription from layout to sidebar to the
   chat room list component, or the chat room list component would have a dependency
   on a global `:chat-rooms` subscription.

@@ -268,7 +268,7 @@

   (def chat-room-list-component (constructor {:subscription-deps [:chat-rooms]}))

-  (def main-component (system {:main layout-component ;; Map compnents to keys
+  (def main-component (system {:main layout-component ;; Map components to keys
   :sidebar sidebar-component
   :chat-room-list chat-room-list-component}
   {:chat-rooms (fn [app-state-atom])})) ;; Map subscriptions to keys
@@ -291,7 +291,7 @@
        (assoc (:main system) ::system system)))))

 (defn constructor
-  "Createas a UIComponent record. Accepts `opts` as the argument. `opts` is
+  "Creates a UIComponent record. Accepts `opts` as the argument. `opts` is
   a map that can have the following params:

   - `:component-deps` - Which child component is this component dependent on
@@ -300,8 +300,8 @@
   - `:renderer` - A renderer function (Reagent component)

   The UIComponent record is a way to list all the dependencies for a component. When
-  the application is started each component's renderer function will be partiall
-  applied with a verion of it's UIComponent that has the component and subscription
+  the application is started each component's renderer function will be partially
+  applied with a version of its UIComponent that has the component and subscription
   dependencies resolved.

   This allows you to write components that are completely decoupled from the rest


Update Dirac to 1.2.15

Update Dirac to 1.2.15

--- src/leiningen/new/tenzing.clj
+++ src/leiningen/new/tenzing.clj
@@ -105,7 +105,7 @@
           (sass?     opts)           (conj "org.slf4j/slf4j-nop  \"1.7.21\" :scope \"test\"")
           (less?     opts)           (conj "deraen/boot-less \"0.6.0\" :scope \"test\"")
           (devtools? opts)           (conj "binaryage/devtools \"0.9.4\" :scope \"test\"")
-          (dirac?    opts)           (conj "binaryage/dirac \"1.2.9\" :scope \"test\"")
+          (dirac?    opts)           (conj "binaryage/dirac \"1.2.15\" :scope \"test\"")
           (boot-cljs-devtools? opts) (conj "powerlaces/boot-cljs-devtools \"0.2.0\" :scope \"test\"")))

 (defn build-requires [opts]


it seems more elegant to append a newline char to each line, rather than join on newline and put the ad-hoc newline at the end of it all;

--- src/mustached_hipster/core.clj
+++ src/mustached_hipster/core.clj
@@ -10,12 +10,9 @@
    (alter-var-root #'*read-eval* (constantly false))

    (spit "foo.txt"
-      (str
-         (join
-            "\n"
-            (map
-               #(first (split (trim %) #"\?"))
-               (filter
-                  #(not= \# (first %))
-                  (split-lines (:body (http/get url))))))
-         "\n")))
+      (apply str
+         (map
+            #(str (first (split (trim %) #"\?")) "\n")
+            (filter
+               #(not= \# (first %))
+               (split-lines (:body (http/get url))))))))


Fix dismiss.

Fix dismiss.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -206,7 +206,6 @@
                                (:user-visibility existing-entry))
                               {})
           pb? (:publisher-board existing-board)
-          dismiss-at {:dismiss-at dismiss-at}
           uv-value (cond)
           updated-self-visibility (cond
                                     (= action-type :dismiss)


remove debug notes from last commit

remove debug notes from last commit

--- src/overtone/gui/pianoroll.clj
+++ src/overtone/gui/pianoroll.clj
@@ -76,26 +76,29 @@
           ;; paint the active notes last
           (paint-active-notes notes active-notes g note-width note-height)))

-(defn update-active-notes [notes-atom active-notes-atom x-cell y-cell]
+(defn update-active-notes [notes-atom active-notes-atom creating-note x-cell y-cell]
   (let [x x-cell
         y y-cell]
     (if
       (= 1 (nth (nth @notes-atom x-cell) y-cell))
           (do
-            (println "adding new note @" x-cell y-cell)
-            (println @active-notes-atom)
+            ; (println "adding new note @" x-cell y-cell)
+            ; (println @active-notes-atom)
+            (swap! creating-note (fn [b] true))
             (swap! active-notes-atom (fn [notes] (conj notes [x-cell y-cell])))
-            (println @active-notes-atom))
+            ; (println @active-notes-atom)
+            )
           (do
-            (println "removing a note @" x-cell y-cell)
-            (println @active-notes-atom)
+            ; (println "removing a note @" x-cell y-cell)
+            ; (println @active-notes-atom)
             (swap! active-notes-atom (fn [notes] (remove #{[x-cell y-cell]} @active-notes-atom)))
-            (println @active-notes-atom)))))
+            ; (println @active-notes-atom)
+            ))))

 (defn piano-roll-widget
   [num-measures num-bars num-beats num-steps-per-beat num-octaves]
   (let [notes-atom (atom (note-matrix (atom nil) num-octaves num-measures num-bars num-beats num-steps-per-beat))
-        active-notes-atom (atom [[0 5][5 2] [5 6][8 2]])
+        active-notes-atom (atom [])
         piano-roll (canvas  :id :piano-roll
                             :paint (partial paint-piano-roll 4 4 4 4 4 notes-atom active-notes-atom))
         panel (border-panel :center piano-roll)
@@ -105,6 +108,8 @@
         beat-width (/ measure-width 4)
         note-width (/ beat-width 4)
         note-height NOTE_HEIGHT
+        creating-note (atom false)
+        current-count (atom 0)
         ]

     (listen piano-roll
@@ -117,13 +122,17 @@
                 measure (int (/ piano-roll-width MEASURE_WIDTH))]
                 (swap! notes-atom (fn [old-matrix] (update-note old-matrix x-cell y-cell (if (zero? (nth (nth old-matrix x-cell) y-cell)) 1 0))))

-            (update-active-notes notes-atom active-notes-atom x-cell y-cell)
+            (update-active-notes notes-atom active-notes-atom creating-note x-cell y-cell)
+            (.repaint (.getSource e))
             ))
       :mouse-dragged
-        (fn [e])
+        (fn [e]
+          (if creating-note 0 1))

       :mouse-released
-        (fn [e] (.repaint (.getSource e))))
+        (fn [e]
+          (swap! creating-note (fn [b] false))
+          (.repaint (.getSource e))))
     panel))

 (defn create-piano-roll


add nil-arg-checker for ugen fns

add nil-arg-checker for ugen fns

--- src/overtone/sc/ugen/specs.clj
+++ src/overtone/sc/ugen/specs.clj
@@ -213,6 +213,7 @@
       (assoc ugen :n-outputs (count (flatten [(first n-outs-arg)])))
       ugen)))

+;;TODO check to see if this can be removed. Args can not take keywords as vals
 (defn- map-ugen-args
   "Perform argument mappings for ugen args that take a keyword but need to be
   looked up in a map supplied in the spec. (e.g. envelope actions)"
@@ -278,6 +279,13 @@
                                       (get arg :mode :standard)))]
                   (assoc arg :expands? expands?)))
               (:args spec))))
+
+(defn- nil-arg-checker
+  [ugen]
+  (let [args (:args ugen)]
+    (when (some nil? args)
+      (throw (IllegalArgumentException. (str "Error - attempted to call the " (:name ugen) " ugen with one or more nil arguments. This usually happens when the ugen contains arguments without defaults which haven't been explicitly called. Got " (vec args))))))
+  ugen)

 (defn- with-init-fn
   "Creates the final argument initialization function which is applied to
@@ -317,6 +325,7 @@
                  bus->id
                  appender
                  auto-rater
+                 nil-arg-checker
                  rate-checker
                  bespoke-checker)))))


add additional add/3 arity to grafter.rdf/add

--- src/grafter/rdf.clj
+++ src/grafter/rdf.clj
@@ -192,5 +192,7 @@
 (defn add
   "Adds a sequence of statements to the specified datasink.  Supports
   all the same targets as add-statement."
-  [target triples]
-  (pr/add target triples))
+  ([target triples]
+     (pr/add target triples))
+  ([target graph triples]
+     (pr/add target graph triples)))


(SERVER-815) Split out test functions based on PR feedback

This commit splits a few of the functions defined in a let block in the
new `class-info-test` deftest into separate top-level defns for better
readability.  This commit also adds one more assertion that the
class info retrieved for an environment which has been deleted is nil.

--- test/integration/puppetlabs/services/jruby/class_info_test.clj
+++ test/integration/puppetlabs/services/jruby/class_info_test.clj
@@ -6,6 +6,67 @@
             [me.raynes.fs :as fs]
             [cheshire.core :as cheshire])
   (:import (java.util.concurrent LinkedBlockingDeque)))
+
+(defn create-file
+  [file content]
+  (ks/mkdirs! (fs/parent file))
+  (spit file content))
+
+(defn gen-classes
+  [[mod-dir manifests]]
+  (let [manifest-dir (fs/file mod-dir "manifests")]
+    (ks/mkdirs! manifest-dir)
+    (doseq [manifest manifests]
+      (spit (fs/file manifest-dir (str manifest ".pp"))
+            (str
+              "class " manifest "($" manifest "_a, Integer $"
+              manifest "_b, String $" manifest
+              "_c = 'c default value') { }\n"
+              "class " manifest "2($" manifest "2_a, Integer $"
+              manifest "2_b, String $" manifest
+              "2_c = 'c default value') { }\n")))))
+
+(defn create-env-conf
+  [env-dir content]
+  (create-file (fs/file env-dir "environment.conf")
+               (str "environment_timeout = unlimited\n"
+                    content)))
+
+(defn create-env
+  [[env-dir manifests]]
+  (create-env-conf env-dir "")
+  (gen-classes [env-dir manifests]))
+
+(defn roundtrip-via-json
+  [obj]
+  (-> obj
+      (cheshire/generate-string)
+      (cheshire/parse-string)))
+
+(defn expected-class-info
+  [class]
+    {"name" class
+     "params" [{"name" (str class "_a")}
+               {"name" (str class "_b"),
+                "type" "Integer"}
+               {"name" (str class "_c"),
+                "type" "String",
+                "default_literal" "c default value"}]})
+
+(defn expected-manifests-info
+  [manifests]
+  (into {}
+        (apply concat
+               (for [[dir names] manifests]
+                 (do
+                   (for [name names]
+                     [(.getAbsolutePath
+                        (fs/file dir
+                                 "manifests"
+                                 (str name ".pp")))
+                      [(expected-class-info name)
+                       (expected-class-info
+                         (str name "2"))]]))))))

 (deftest ^:integration class-info-test
   (testing "class info properly enumerated for"
@@ -20,34 +81,11 @@
           jruby-puppet (:jruby-puppet instance)
           container (:scripting-container instance)

+          _ (create-file (fs/file conf-dir "puppet.conf")
+                         "[main]\nenvironment_timeout=unlimited\nbasemodulepath=$codedir/modules\n")
+
           env-dir (fn [env-name]
                     (fs/file code-dir "environments" env-name))
-          create-file (fn [file content]
-                        (ks/mkdirs! (fs/parent file))
-                        (spit file content))
-          gen-classes (fn [[mod-dir manifests]]
-                        (let [manifest-dir (fs/file mod-dir "manifests")]
-                          (ks/mkdirs! manifest-dir)
-                          (doseq [manifest manifests]
-                            (spit (fs/file manifest-dir (str manifest ".pp"))
-                                  (str
-                                    "class " manifest "($" manifest "_a, Integer $"
-                                    manifest "_b, String $" manifest
-                                    "_c = 'c default value') { }\n"
-                                    "class " manifest "2($" manifest "2_a, Integer $"
-                                    manifest "2_b, String $" manifest
-                                    "2_c = 'c default value') { }\n")))))
-          create-env-conf (fn [env-dir content]
-                            (create-file (fs/file env-dir "environment.conf")
-                                         (str "environment_timeout = unlimited\n"
-                                              content)))
-          create-env (fn [[env-dir manifests]]
-                       (create-env-conf env-dir "")
-                       (gen-classes [env-dir manifests]))
-
-          _ (create-file (fs/file conf-dir "puppet.conf")
-                         "[main]\nenvironment_timeout=unlimited\nbasemodulepath=$codedir/modules\n")
-
           env-1-dir (env-dir "env1")
           env-1-dir-and-manifests [env-1-dir ["foo" "bar"]]
           _ (create-env env-1-dir-and-manifests)
@@ -78,36 +116,9 @@
           _ (gen-classes [bogus-env-dir ["envbogus"]])
           _ (gen-classes [(fs/file base-mod-dir "base-bogus") ["base-bogus1"]])

-          roundtrip-via-json (fn [obj]
-                               (-> obj
-                                   (cheshire/generate-string)
-                                   (cheshire/parse-string)))
-          expected-class-info (fn [class]
-                                    {"name" class
-                                     "params" [{"name" (str class "_a")}
-                                               {"name" (str class "_b"),
-                                                "type" "Integer"}
-                                               {"name" (str class "_c"),
-                                                "type" "String",
-                                                "default_literal" "c default value"}]})
-
-          expected-manifests-info (fn [manifests]
-                                        (into {}
-                                              (apply concat
-                                                     (for [[dir names] manifests]
-                                                       (do
-                                                         (for [name names]
-                                                           [(.getAbsolutePath
-                                                              (fs/file dir
-                                                                       "manifests"
-                                                                       (str name ".pp")))
-                                                            [(expected-class-info name)
-                                                             (expected-class-info
-                                                               (str name "2"))]]))))))
           get-class-info (fn []
-                           (-> (.getClassInfoForAllEnvironments
-                                jruby-puppet)
-                              (roundtrip-via-json)))
+            (-> (.getClassInfoForAllEnvironments jruby-puppet)
+                (roundtrip-via-json)))
           get-class-info-for-env (fn [env]
                                    (-> (.getClassInfoForEnvironment jruby-puppet
                                                                     env)
@@ -198,6 +209,8 @@
               (testing "all environments"
                 (is (= expected-envs-info (get-class-info))))
               (testing "one environment by name"
+                (is (nil? (get-class-info-for-env "env1"))
+                    "Unexpected info retrieved for 'env1'")
                 (is (= (expected-envs-info "env2")
                        (get-class-info-for-env "env2"))
                     "Unexpected info retrieved for 'env2'")


Bind /api routes to /*

Bind /api routes to /*

We deploy our servlet as api.war, which will be bound
to api/. Therefore we don't need /api/* routes anymore
(which would lead to /api/api routes).

--- api/src/geocommit/app_servlet.clj
+++ api/src/geocommit/app_servlet.clj
@@ -9,30 +9,32 @@
   geocommit.app_servlet
   (:gen-class :extends javax.servlet.http.HttpServlet)
   (:use compojure.core
-	[compojure.route :as route]
-	[compojure.handler :as handler]
 	[geocommit.hook :only [app-hook]]
 	[geocommit.api :only [app-api-geocommits]]
-	[geocommit.signup :only [app-verify-hook app-signup]]
-	[geocommit.http :only [mslurp]])
-  (:require [compojure.route :as route]
-	    [clojure.contrib.trace :as t]))
+	[geocommit.signup :only [app-verify-hook app-signup]])
+  (:require [clojure.contrib.trace :as t]
+	    [compojure.route :as route]
+	    [compojure.handler :as handler]
+	    [clojure.contrib.duck-streams :as ds]))

 (defroutes main-routes
-  (GET "/api/geocommits"
+  (GET "/geocommits"
        [payload]
        (app-api-geocommits payload))
-  (POST "/api*"
-	payload
-	(if (= (:content-type payload) "application/githubpostreceive+json")
-	  (app-hook (mslurp (.getInputStream (:request payload))))
-	  (app-hook (:payload (:params payload)))))
   (GET "/signup/verify/:code"
        [code]
        (app-verify-hook code))
   (POST "/signup*"
 	[mailaddr]
 	(app-signup mailaddr))
+  (POST "/*"
+	payload
+	(if (= (:content-type payload) "application/githubpostreceive+json")
+	  (app-hook
+	   (cond
+	    (:request payload) (ds/slurp* (.getInputStream (:request payload)))
+	    (:body payload) (ds/slurp* (:body payload))))
+	  (app-hook (:payload (:params payload)))))
   (route/not-found "not a valid request"))

 (def app


schwacher bugfix für decrement

schwacher bugfix für decrement

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -23,7 +23,7 @@
 (defn sqlquery [name]

 ;(first (jdbc/query mysql-db [(str "select * from konten where Name='" name "'")])))
-(jdbc/update! mysql-db :konten {:Kontostand "Kontostand-1"} ["Name = ?" name]))
+(jdbc/update! mysql-db :konten {:Kontostand "Kontostand - 1"} ["Name = ?" name]))
 ;maybe this sets the guthaben to 99

 (defn page [name]


simplifies test streaming debugging (#668)

## Changes proposed in this PR

- makes a separate canary call from streaming calls

## Why are we making these changes?

We would like to see the CID in the failed streaming requests to easily debug failed assertions.

--- waiter/integration/waiter/streaming_test.clj
+++ waiter/integration/waiter/streaming_test.clj
@@ -21,24 +21,28 @@

 (deftest ^:parallel ^:integration-fast test-streaming
   (testing-using-waiter-url
-    (let [file-size-double 690606.0
-          file-path "test-files/big.txt"
+    (let [file-path "test-files/big.txt"
           service-name (rand-name)
           post-body (slurp file-path)
-          make-request #(make-kitchen-request waiter-url %1 :body post-body)
+          body-size (count (.getBytes post-body "utf-8"))
           metrics-sync-interval-ms (get-in (waiter-settings waiter-url) [:metrics-config :metrics-sync-interval-ms])
           headers {:x-cid (str service-name "-canary")
                    :x-kitchen-echo "true"
                    :x-waiter-name service-name}
-          response (make-request headers)
-          service-id (retrieve-service-id waiter-url (:request-headers response))
-          epsilon 0.01]
-      (assert-response-status response 200)
-      (dotimes [n 49]
-        (let [headers (assoc headers :x-cid (str service-name "-iter" n))
-              {:keys [body] :as response} (make-request headers)]
-          (assert-response-status response 200)
-          (is (= post-body body))))
+          {:keys [request-headers] :as canary-response} (make-kitchen-request waiter-url headers)
+          service-id (retrieve-service-id waiter-url request-headers)
+          epsilon 0.01
+          num-streaming-requests 50]
+      (assert-response-status canary-response 200)
+      (dotimes [n num-streaming-requests]
+        (let [request-cid (str service-name "-iter" n)
+              headers (assoc headers
+                        :content-length body-size
+                        :content-type "application/octet-stream"
+                        :x-cid request-cid)
+              {:keys [body] :as response} (make-kitchen-request waiter-url headers :body post-body)]
+          (is (= 200 (:status response)) (str "Request correlation-id: " request-cid))
+          (is (= post-body body) (str (:status response) (:headers response)))))
       ; wait to allow metrics to be aggregated
       (let [sleep-period (max (* 20 metrics-sync-interval-ms) 10000)]
         (log/debug "sleeping for" sleep-period "ms")
@@ -52,23 +56,27 @@
             response-size-histogram (get-in aggregate-metrics [:histograms :response-size])]
         (is (zero? (:outstanding request-counts)) (-> aggregate-metrics))
         (is (zero? (:streaming request-counts)))
-        (is (= 50 (:successful request-counts)))
-        (is (= 50 (:total request-counts)))
-        (is (= 50 (get-in request-size-histogram [:count] 0))
+        (is (= (inc num-streaming-requests) (:successful request-counts)))
+        (is (= (inc num-streaming-requests) (:total request-counts)))
+        ;; there is no content length on the canary request
+        (is (= num-streaming-requests (get-in request-size-histogram [:count] 0))
             (str "request-size-histogram: " request-size-histogram))
-        (is (->> (- file-size-double (get-in request-size-histogram [:value :0.0] 0.0)) (double) (Math/abs) (>= epsilon))
+        (is (->> (- body-size (get-in request-size-histogram [:value :0.0] 0.0)) (double) (Math/abs) (>= epsilon))
             (str "request-size-histogram: " request-size-histogram))
-        (is (= 50 (get-in response-size-histogram [:count]))
+        (is (= (inc num-streaming-requests) (get-in response-size-histogram [:count]))
             (str "response-size-histogram: " response-size-histogram))
-        (is (->> (- file-size-double (get-in response-size-histogram [:value :0.0] 0.0)) (double) (Math/abs) (>= epsilon))
+        ;; all (canary and streaming) response sizes are logged
+        (is (->> (get-in response-size-histogram [:value :0.0] 0.0) (double) (Math/abs) (>= epsilon))
+            (str "response-size-histogram: " response-size-histogram))
+        (is (->> (- body-size (get-in response-size-histogram [:value :0.25] 0.0)) (double) (Math/abs) (>= epsilon))
             (str "response-size-histogram: " response-size-histogram)))
       (delete-service waiter-url service-id))))

 (deftest ^:parallel ^:integration-fast test-large-request
   (testing-using-waiter-url
     (let [request-body (apply str (take 2000000 (repeat "hello")))
-         headers {:x-waiter-name (rand-name), :x-kitchen-echo true}
-         {:keys [body request-headers] :as response} (make-kitchen-request waiter-url headers :body request-body)]
+          headers {:x-waiter-name (rand-name), :x-kitchen-echo true}
+          {:keys [body request-headers] :as response} (make-kitchen-request waiter-url headers :body request-body)]
       (assert-response-status response 200)
       (is (= (count request-body) (count body)))
       (delete-service waiter-url (retrieve-service-id waiter-url request-headers)))))


Simplify input creation a bit

Simplify input creation a bit

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -176,11 +176,10 @@
        (input-render-setup this jsprops)
        (make-element argv comp jsprops first-child)))})

-(defn reagent-input [argv comp jsprops first-child]
+(defn reagent-input []
   (when (nil? reagent-input-class)
-    (set! reagent-input-class
-          (comp/create-class input-spec)))
-  (reagent-input-class argv comp jsprops first-child))
+    (set! reagent-input-class (comp/create-class input-spec)))
+  reagent-input-class)

 ;;; Conversion from Hiccup forms
@@ -250,7 +249,7 @@
           jsprops (convert-props (if hasprops props) parsed)
           first-child (if hasprops 2 1)]
       (if (input-component? comp)
-        (-> [reagent-input argv comp jsprops first-child]
+        (-> [(reagent-input) argv comp jsprops first-child]
             (with-meta (meta argv))
             as-element)
         (let [p (if-some [key (some-> (meta argv) get-key)]


/admin/running-builds and /admin/queued-builds

Insight into what the system is doing in enterprise installations

--- src-cljs/frontend/routes.cljs
+++ src-cljs/frontend/routes.cljs
@@ -37,6 +37,12 @@
     (open-to-inner! nav-ch :switch {:admin true}))
   (defroute v1-admin-recent-builds "/admin/recent-builds" []
     (open-to-inner! nav-ch :dashboard {:admin true}))
+  (defroute v1-admin-current-builds "/admin/running-builds" []
+    (open-to-inner! nav-ch :dashboard {:admin true
+                                       :query-params {:status "running"}}))
+  (defroute v1-admin-queued-builds "/admin/queued-builds" []
+    (open-to-inner! nav-ch :dashboard {:admin true
+                                       :query-params {:status "scheduled,queued"}}))
   (defroute v1-admin-deployments "/admin/deployments" []
     (open-to-inner! nav-ch :dashboard {:deployments true}))
   (defroute v1-admin-build-state "/admin/build-state" []


modified make-brick-rows

modified make-brick-rows

--- src/maqueta/hello/physics.clj
+++ src/maqueta/hello/physics.clj
@@ -74,15 +74,13 @@

 (defn make-brick-rows
   [j startpt height app]
-  (if (> j 0)
-    (do
-      (doall (map (fn [i]
-                    (make-brick (Vector3f. (+ startpt (* i brick-length 2))
-                                           (+ brick-height height)
-                                           0)
-                                app))
-                  (range 6)))
-      (make-brick-rows (- j 1) (- startpt) (+ height (* brick-height 2)) app))))
+  (when (> j 0)
+    (doseq [i (range 6)]
+      (make-brick (Vector3f. (+ startpt (* i brick-length 2))
+                             (+ brick-height height)
+                             0)
+                  app))
+    (make-brick-rows (- j 1) (- startpt) (+ height (* brick-height 2)) app)))

 (defn init-wall
   [app]


added support for objects and arrays

added support for objects and arrays

--- src/metabase/driver/crate.clj
+++ src/metabase/driver/crate.clj
@@ -18,18 +18,33 @@
   "Map of Postgres column types -> Field base types.
    Add more mappings here as you come across them."
   [_ column-type]
-  ({:integer   :IntegerField
-    :string    :TextField
-    :boolean   :BooleanField
-    :byte      :IntegerField
-    :short     :IntegerField
-    :long      :BigIntegerField
-    :float     :FloatField
-    :double    :FloatField
-    :ip        :UnknownField
-    :timestamp :DateTimeField
-    :geo_point :UnknownField
-    :geo_shape :UnknownField
+  ({:integer          :IntegerField
+    :string           :TextField
+    :boolean          :BooleanField
+    :byte             :IntegerField
+    :short            :IntegerField
+    :long             :BigIntegerField
+    :float            :FloatField
+    :double           :FloatField
+    :ip               :UnknownField
+    :timestamp        :DateTimeField
+    :geo_shape        :UnknownField
+    :geo_point        :UnknownField
+    :object           :DictionaryField
+    :array            :ArrayField
+    :object_array     :ArrayField
+    :string_array     :ArrayField
+    :integer_array    :ArrayField
+    :float_array      :ArrayField
+    :boolean_array    :ArrayField
+    :byte_array       :ArrayField
+    :timestamp_array  :ArrayField
+    :short_array      :ArrayField
+    :long_array       :ArrayField
+    :double_array     :ArrayField
+    :ip_array         :UnknownField
+    :geo_shape_array  :UnknownField
+    :geo_point_array  :UnknownField
     } column-type))

 ;; # Adapt generic SQL to Crate SQL