ticket link fix

ticket link fix

--- src/cljs/salava/admin/ui/tickets.cljs
+++ src/cljs/salava/admin/ui/tickets.cljs
@@ -142,18 +142,13 @@
        [:h3 {:class "media-heading"}
         [:u (t (keyword (str "admin/" report_type)))]]
        [:h4 {:class "media-heading"}
-        (cond
-          (= "badges" item_type)[:a {:href "#" :on-click #(do
-                                                            (.preventDefault %)
-                                                            (open-admintool-modal "badges" (badge-id item_url) nil nil))}
-                                 (str (t (keyword (str "admin/" item_type))) " - " item_name)]
-
-          (= "badge" item_type) [:a {:href "#" :on-click #(do
-                                                            (.preventDefault %)
-                                                            (open-admintool-modal item_id "badge"))}
-                                 (str (t (keyword (str "admin/" item_type))) " - " item_name)]
-          :else [:a {:href item_url :target "_blank"}
-                 (str (t (keyword (str "admin/" item_type))) " - " item_name)])]]
+        (if (= "badges" item_type)
+          [:a {:href "#" :on-click #(do
+                                      (.preventDefault %)
+                                      (open-admintool-modal "badges" (badge-id item_url) nil nil))}
+           (str (t (keyword (str "admin/" item_type))) " - " item_name)]
+          [:a {:href item_url :target "_blank"}
+           (str (t (keyword (str "admin/" item_type))) " - " item_name)])]]
       [:div.media-descriprtion
        [:div {:class "col-xs-12"  :id (if open? "" "closed")}
         [:div [:label (str (t :admin/Description) ": ")] " " (if (< 130 (count description)) [text-shorter description 130]   description) ]


fix badge advert

fix badge advert

--- src/cljs/salava/social/ui/stream.cljs
+++ src/cljs/salava/social/ui/stream.cljs
@@ -188,13 +188,13 @@
       [:div.date (date-from-unix-time (* 1000 ctime) "days") ]
       [:i {:class "fa fa-bell"}]
       [:div [:h3 {:class "media-heading" :style {:padding-bottom "5px"}}
-             "New Badge Available!"]
+             (t :social/Badgeadvertisement)]
        [:div.media-body
+        [:div name]
         (bm/issuer-modal-link issuer_content_id issuer_content_name)
         [:a {:href "#"
              :on-click #(do
                           (.preventDefault %)
-                          (prn modal)
                           (modal subject state)
                           )} [:div.get-badge-link [:i {:class "fa fa-angle-double-right"}] (str " " (t :extra-application/Getthisbadge))]]]]
       ]]))


Fixed title

Fixed title

--- src/video_server/html.clj
+++ src/video_server/html.clj
@@ -172,7 +172,7 @@

 (deftemplate title-template "templates/title.html"
   [title info video containers season episode]
-  [:head :title] (content (full-title title info video))
+  [:head :title] (content (full-title title video))
   [:core-toolbar :div] (content (or (:title info) (:title title)))
   [:div#desc] (when (or (:year info) (:plot info)) identity)
   [:div#poster :img] (set-attr :src (or (:poster title) "placeholder.png"))


Variable renames from the 1.4.0 SDK documentation.

--- src/appengine_magic/services/channel.clj
+++ src/appengine_magic/services/channel.clj
@@ -13,17 +13,17 @@

 (defn create-channel
-  "Returns a channel ID."
-  [^String channel-group-key]
-  (.createChannel (get-channel-service) channel-group-key))
+  "Returns a channel token."
+  [^String client-id]
+  (.createChannel (get-channel-service) client-id))

-(defn make-message [^String channel-group-key, ^String message]
-  (ChannelMessage. channel-group-key message))
+(defn make-message [^String client-id, ^String message]
+  (ChannelMessage. client-id message))

 (defn send
   ([^ChannelMessage message]
      (.sendMessage (get-channel-service) message))
-  ([^String channel-group-key, ^String message]
-     (send (make-message channel-group-key message))))
+  ([^String client-id, ^String message]
+     (send (make-message client-id message))))


Fixing field name

Fixing field name

--- src/clj/forma/hadoop/jobs/timeseries.clj
+++ src/clj/forma/hadoop/jobs/timeseries.clj
@@ -59,7 +59,7 @@
         (ts-src ?name ?t-res ?s-res ?h ?v ?id ?size ?pixel-idx ?ts)
         (r/tile-position ?s-res ?size ?id ?pixel-idx :> ?sample ?line)
         (thrift/ModisPixelLocation* ?s-res ?h ?v ?sample ?line :> ?pixel-loc)
-        (thrift/DataChunk* ?name ?tile-loc ?ts ?t-res :> ?pixel-chunk)
+        (thrift/DataChunk* ?name ?pixel-loc ?ts ?t-res :> ?pixel-chunk)
         (:distinct false))))

 (def ^:dynamic *missing-val*
@@ -133,3 +133,4 @@
   (-> source-pail-path
       (pail/split-chunk-tap ["fire" (str m-res "-01")])
       (create-fire-series t-res start end)))
+


Removed unused namespace.

Removed unused namespace.

--- src/clj/mx/roads/forgotten/blog/post.clj
+++ src/clj/mx/roads/forgotten/blog/post.clj
@@ -1 +0,0 @@
-(ns mx.roads.forgotten.blog.post)


minor

minor

--- src/clj/tsask/frontend/calendar/crud.clj
+++ src/clj/tsask/frontend/calendar/crud.clj
@@ -29,6 +29,7 @@
               :form_id 1
               :start (- (.getTime (java.util.Date.)) one-day)
               :end (+ (.getTime (java.util.Date.)) one-day)})
+  (java.util.Date.)
   (type (.getTime (java.util.Date.))))

 (defn calevents
@@ -37,8 +38,6 @@
   (let [events (j/query SQLDB
                         (sql/select [:id :title :description :form_id :start :end] :calevent))]
     (ut/response events)))
-
-(java.util.Date.)

 (def CLNDR-template
   [:script


customizable ::userid keyword

customizable ::userid keyword

--- src/cljc/ow/starbuck/impl/websocket.cljc
+++ src/cljc/ow/starbuck/impl/websocket.cljc
@@ -16,9 +16,9 @@
            (sente/make-channel-socket! path
                                        {:wrap-recv-evs? false})))

-#?(:clj  (defn- do-send* [{:keys [senteobjs] :as this} msg]
-           (let [userid (::userid msg)
-                 msg (dissoc msg ::userid)
+#?(:clj  (defn- do-send* [{:keys [senteobjs userid-kw] :as this} msg]
+           (let [userid (get msg userid-kw)
+                 msg (dissoc msg userid-kw)
                  send-fn (:send-fn senteobjs)]
              (debug "sending message to remote id" userid ":" msg)
              (send-fn userid [::message msg])))
@@ -34,10 +34,11 @@
                      (recur [(inc i) (a/<! (a/timeout 500))])))
                (warn "could not send message after 100 tries, aborting:" msg)))))

-(defn- handle-inbound-sentemsg [{:keys [recv-fn userid-fn] :as this} {:keys [id ?data ring-req] :as sentemsg}]
+(defn- handle-inbound-sentemsg [{:keys [recv-fn userid-fn userid-kw] :as this}
+                                {:keys [id ?data ring-req] :as sentemsg}]
   (let [userid (and userid-fn (userid-fn ring-req))
         ?data (merge ?data
-                     (and userid {::userid userid}))]
+                     (and userid {userid-kw userid}))]
     (debug "got message from remote:" id ?data)
     ;;; TODO: add auth checking
     ;;; TODO: maybe add msg shaping
@@ -70,9 +71,10 @@
     (do-send this msg)))

 ;;; TODO: implement client for server side (not via sente, see factum project):
-#?(:clj  (defn tunnel [recv-fn userid-fn]
+#?(:clj  (defn tunnel [recv-fn userid-fn & {:keys [userid-kw]}]
            (map->ComponentWebsocket {:recv-fn recv-fn
-                                     :userid-fn userid-fn}))
+                                     :userid-fn userid-fn
+                                     :userid-kw (or userid-kw ::userid)}))
    :cljs (defn tunnel [recv-fn path]
            (map->ComponentWebsocket {:recv-fn recv-fn
                                      :path path})))


Removed non-age-like age-combining-functions, now in compute-grain-size for random-screen.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -46,34 +46,7 @@
                                  (- (inc (:age p2))
                                     (inc (:age p1)))))))))
     :first (fn [p1 p2 g]
-             (inc (:age p1)))
-    :fidelity (fn [p1 p2 g]
-                (sequence-similarity g (:genome p1)))
-    :infidelity (fn [p1 p2 g]
-                  (- 1 (sequence-similarity g (:genome p1))))
-    :consistency (fn [p1 p2 g]
-                   ;; don't compute when calling op via genome instruction
-                   (if (or (neg? (:age p1))
-                           (neg? (:age p2)))
-                     -1
-                     (- 1
-                        (#(- (max %1 %2) (min %1 %2))
-                          (sequence-similarity (:genome p1) g)
-                          (sequence-similarity
-                            (:genome p1)
-                            (produce-child-genome-by-autoconstruction
-                              g (:genome p1) (:genome p2) false argmap))))))
-    :inconsistency (fn [p1 p2 g]
-                     ;; don't compute when calling op via genome instruction
-                     (if (or (neg? (:age p1))
-                             (neg? (:age p2)))
-                       -1
-                       (#(- (max %1 %2) (min %1 %2))
-                         (sequence-similarity (:genome p1) g)
-                         (sequence-similarity
-                           (:genome p1)
-                           (produce-child-genome-by-autoconstruction
-                             g (:genome p1) (:genome p2) false argmap)))))))
+             (inc (:age p1)))))

 ;; test effects of :proportionate with expressions like this:
 ;(float ((age-combining-function {:age-combining-function :proportionate})


Fix boundary conditions on new-errors and at-least-half-new-errors diversification tests

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1029,9 +1029,7 @@
                                           {:genome (:genome ind)}
                                           argmap)}))))]
       (assoc ind :diversifying
-             (let [hist (:parent1-history argmap)]
-               (or (< (count hist) 2)
-                   (not (some #{errs} hist))))))))
+             (not (some #{errs} (:parent1-history argmap)))))))

 (defn at-least-half-new-errors-diversifying?
   [ind argmap]
@@ -1049,9 +1047,8 @@
                                           argmap)}))))]
       (assoc ind :diversifying
              (let [hist (:parent1-history argmap)]
-               (or (< (count hist) 2)
-                   (>= (* 2 (count (distinct (conj hist errs))))
-                       (count (conj hist errs)))))))))
+               (>= (* 2 (count (distinct (conj hist errs))))
+                   (count (conj hist errs))))))))

 (defn not-empty-diversifying?
   [ind argmap]


use loop variable instead of atom

use loop variable instead of atom

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -662,24 +662,24 @@
         (let [event (create-basic-event)
               state (create-basic-state)
               first-image (atom true)
-              start-time (jvm-time-ms)
-              last-time (atom 0)]
+              start-time (jvm-time-ms)]
           (dosync (ref-set live-mode-running true))
           (core startContinuousSequenceAcquisition 0)
           (log "started sequence acquisition")
           (.start (Thread.
-                    #(do (while @live-mode-running
-                           (let [raw-image {:pix (core getLastImage) :tags nil}
-                                 elapsed-time-ms (- (jvm-time-ms) start-time)
-                                 img (annotate-image raw-image event state elapsed-time-ms)
-                                 this-time (System/currentTimeMillis)
-                                 dt (- 33 (- this-time @last-time))]
-                             (reset-snap-window img)
-                             (Thread/sleep (max 0 dt))
-                             (reset! last-time this-time)
-                             (show-image @snap-window img @first-image)
-                             (reset! first-image false)))
-                         (core stopSequenceAcquisition))
+                    #(dorun (loop [last-time 0]
+                              (when @live-mode-running
+                                (let [raw-image {:pix (core getLastImage) :tags nil}
+                                      elapsed-time-ms (- (jvm-time-ms) start-time)
+                                      img (annotate-image raw-image event state elapsed-time-ms)
+                                      this-time (System/currentTimeMillis)
+                                      dt (- 33 (- this-time last-time))]
+                                  (reset-snap-window img)
+                                  (Thread/sleep (max 0 dt))
+                                  (show-image @snap-window img @first-image)
+                                  (reset! first-image false)
+                                  (recur this-time))))
+                            (core stopSequenceAcquisition))
                     "Live mode (clojure)")))
         (dosync (ref-set live-mode-running false))))


Whitespace

Whitespace

Former-commit-id: f57defb542f83bac7f732a7a8bd79db509f1799d

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -550,8 +550,8 @@
         (first (js/PLANCK_LOAD (str without-extension ".cljs")))))
     (let [file-source (first (js/PLANCK_LOAD filepath))]
       (or file-source
-          (first (js/PLANCK_LOAD (s/replace filepath #"^out/" "")))
-          (first (js/PLANCK_LOAD (s/replace filepath #"^src/" "")))))))
+        (first (js/PLANCK_LOAD (s/replace filepath #"^out/" "")))
+        (first (js/PLANCK_LOAD (s/replace filepath #"^src/" "")))))))

 (defn- fetch-source
   [var]


Adjustments to namespace completions

Adjustments to namespace completions

--- planck-cljs/src/planck/repl.cljs
+++ planck-cljs/src/planck/repl.cljs
@@ -457,6 +457,54 @@
    :gen-class
    :keywordize-keys])

+(def ^:private namespace-completion-exclusions
+  '[planck.from.io.aviso.ansi
+    planck.pprint.code
+    planck.pprint.data
+    planck.bundle
+    planck.js-deps
+    planck.repl
+    planck.repl-resources
+    planck.themes
+    tailrecursion.cljson
+    clojure.core.rrb-vector
+    clojure.core.rrb-vector.interop
+    clojure.core.rrb-vector.nodes
+    clojure.core.rrb-vector.protocols
+    clojure.core.rrb-vector.rrbt
+    clojure.core.rrb-vector.transients
+    clojure.core.rrb-vector.trees
+    cognitect.transit
+    fipp.deque
+    fipp.engine
+    fipp.visit
+    lazy-map.core
+    cljs.source-map
+    cljs.source-map.base64
+    cljs.source-map.base64-vlq
+    cljs.repl
+    cljs.tools.reader.impl.commons
+    cljs.tools.reader.impl.utils
+    cljs.stacktrace])
+
+(def ^:private namespace-completion-additons
+  '[planck.core
+    planck.io
+    planck.http
+    planck.shell
+    clojure.test
+    clojure.spec
+    clojure.pprint])
+
+(defn- namespace-completions
+  []
+  (->> (all-ns)
+    (map #(drop-macros-suffix (str %)))
+    (remove (into #{} (map str namespace-completion-exclusions)))
+    (concat (map str namespace-completion-additons))
+    sort
+    distinct))
+
 (defn- expand-typed-ns
   "Expand the typed namespace symbol to a known namespace, consulting
   current namespace aliases if necessary."
@@ -474,7 +522,7 @@
              (completion-candidates-for-ns (add-macros-suffix expanded-ns) false)))
          (concat
            (map str keyword-completions)
-           (map #(drop-macros-suffix (str %)) (all-ns))
+           (namespace-completions)
            (map #(str % "/") (keys (current-alias-map)))
            (completion-candidates-for-ns 'cljs.core false)
            (completion-candidates-for-ns 'cljs.core$macros false)


(PDB-3302) Fix fact_storage test assertion

--- test/puppetlabs/puppetdb/integration/apply/fact_storage.clj
+++ test/puppetlabs/puppetdb/integration/apply/fact_storage.clj
@@ -18,4 +18,4 @@
         (is (re-find #"second test" out))))

     (testing "Check that the fact was put in puppetdb"
-      (= [:value "second test"] (int/pql-query pdb "facts [value] { name='foo' }")))))
+      (is (= [{:value "second test"}] (int/pql-query pdb "facts [value] { name='foo' }"))))))


Add border under h3s in api docs

Add border under h3s in api docs

--- docs/src/ns_to_markdown.clj
+++ docs/src/ns_to_markdown.clj
@@ -1,9 +1,9 @@
 (ns ns-to-markdown
-  "This script is used to generate the API documentation for the namespace `re-frame.core`. It reads the
+  "This script is used to generate the API documentation for the namespace `re-frame.core`. It reads the
    source code in that namespace, extracts the docstrings (markdown) and produces a markdown-formatted
-   file suitable for providing to `mkdocs` which builds the re-frame website.
+   file suitable for providing to `mkdocs` which builds the re-frame website.

-   It is used within the GitHub Actions docs workflow at:
+   It is used within the GitHub Actions docs workflow at:
    https://github.com/day8/re-frame/blob/78ca09785e2adf9eea11f1e4bff2477d193f4b46/.github/workflows/docs-workflow.yml#L15

    The page it outputs can be seen here: http://day8.github.io/re-frame/api-re-frame.core/
@@ -88,9 +88,12 @@
     (catch Exception e
       (println e))))

+(def markdown-styles
+  "<style>\n.md-typeset h3 {\nborder-bottom: 2px solid #888;\n}\n</style>\n\n")
+
 (defn ns->markdown
   [m]
-  (format "# %s\n\n" (:name m)))
+  (format "%s# %s\n\n" markdown-styles (:name m)))

 (defn arglist->markdown
   [arglist]


correct function name

correct function name


Handle missing entities properly in *-allowed?

If the programme_id and project_id can't be found then the entity
doesn't exist so returning true as anyone can do things to something
that doesn't exist. Other methods will return how the missing resource
should be handled.


update to figwheel 0.2.0

update to figwheel 0.2.0

--- src/leiningen/new/reagent/project.clj
+++ src/leiningen/new/reagent/project.clj
@@ -38,7 +38,7 @@
                                   [ring/ring-devel "1.3.2"]
                                   [pjstadig/humane-test-output "0.6.0"]{{{lib-dependencies}}}]

-                   :plugins [[lein-figwheel "0.1.4-SNAPSHOT"]{{{lib-plugins}}}{{{project-dev-plugins}}}]
+                   :plugins [[lein-figwheel "0.2.0-SNAPSHOT"]{{{lib-plugins}}}{{{project-dev-plugins}}}]

                    :injections [(require 'pjstadig.humane-test-output)
                                 (pjstadig.humane-test-output/activate!)]


unsuccessful attempts at defconstexpr

unsuccessful attempts at defconstexpr

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -18,6 +18,16 @@
 (defmacro constexpr
   [fct & args]
   (eval `(~fct ~@args)))
+
+#_(defmacro constexpr-2
+  [[fct & args]]
+  (list* fct (map (fn [a] `~a) args)))
+
+#_(defmacro defconstexpr
+  [name arguments body]
+  (println (str body))
+  `(defmacro ~name ~arguments
+     (constexpr ~body)))

 ;; --------------------------------------------------------
 ;; Example 1: equivalent with constexpr


PDB-510 Add migration to fix sequence for catalog.id

The sequence for catalog.id had not been incremented during insert for migration
20 'differential-catalog-resources'.

This meant that the catalog.id column would throw a constraint exception during
insertion until the sequence had increased enough to be greater then the max id
already used in the column.

While this was only a temporary error, it does cause puppetdb to start to throw
errors and potentially dropping some catalog updates until a certain number of
catalogs had been attempted. In some cases catalogs had been queued up and
retried successfully, other cases meant they were simply dropped into the DLQ.

The fix is to reset the sequence to match the max id on the catalogs.id column.

This patch includes a new migration with this step, that utilizes a new function
created to generically reset sequences based on table and catalog in a database
independant way.

Signed-off-by: Ken Barber <470bc578162732ac7f9d387d34c4af4ca6e1b6f7@bob.sh>

--- src/com/puppetlabs/puppetdb/scf/migrate.clj
+++ src/com/puppetlabs/puppetdb/scf/migrate.clj
@@ -88,6 +88,31 @@
   [table]
   (drop-constraints table "foreign key"))

+(defn fix-identity-sequence
+  "Resets a sequence to the maximum value used in a column. Useful when a
+  sequence gets out of sync due to a bug or after a transfer."
+  [table column]
+  {:pre [(string? table)
+         (string? column)]}
+  (if (postgres?)
+    ;; PostgreSQL specific way
+    (sql/with-query-results _
+      [(str "SELECT setval(
+        pg_get_serial_sequence(?, ?),
+        (SELECT max(" column ") FROM " table "))") table column])
+
+    ;; HSQLDB specific way
+    (let [maxid (sql/with-query-results result-set
+                    [(str "SELECT max(" column ") as id FROM " table)]
+                    (:id (first result-set)))
+          ;; While postgres handles a nil case gracefully, hsqldb does not
+          restart (if (nil? maxid) 1 (inc maxid))]
+      (sql/do-commands
+        (str "ALTER TABLE " table " ALTER COLUMN " column
+          " RESTART WITH " restart)))))
+
+;; Migration functions
+
 (defn initialize-store
   "Create the initial database schema."
   []
@@ -658,6 +683,9 @@

             "ALTER TABLE catalog_resources DROP CONSTRAINT catalog_resources_pkey"
             "ALTER TABLE catalog_resources ADD CONSTRAINT catalog_resources_pkey PRIMARY KEY (catalog_id, type, title)"])))
+
+(defn reset-catalog-sequence-to-latest-id []
+  (fix-identity-sequence "catalogs" "id"))

 ;; The available migrations, as a map from migration version to migration function.
 (def migrations
@@ -680,7 +708,8 @@
    17 use-bigint-instead-of-catalog-hash
    18 add-index-on-exported-column
    19 differential-edges
-   20 differential-catalog-resources})
+   20 differential-catalog-resources
+   21 reset-catalog-sequence-to-latest-id})

 (def desired-schema-version (apply max (keys migrations)))


Clean frontend example project.clj

Clean frontend example project.clj

--- examples/frontend/project.clj
+++ examples/frontend/project.clj
@@ -10,17 +10,20 @@
                  [ring "1.6.3"]
                  [compojure "1.6.1"]
                  [hiccup "1.0.5"]
-                 [org.clojure/clojurescript "1.10.339" :scope "provided"]
+                 [org.clojure/clojurescript "1.10.339"]
                  [metosin/reitit "0.1.4-SNAPSHOT"]
                  [metosin/reitit-schema "0.1.4-SNAPSHOT"]
                  [metosin/reitit-frontend "0.1.4-SNAPSHOT"]
                  ;; Just for pretty printting the match
                  [fipp "0.6.12"]]

-  :plugins [[lein-cljsbuild "1.1.7"]]
+  :plugins [[lein-cljsbuild "1.1.7"]
+            [lein-figwheel "0.5.16"]]

   :source-paths []
   :resource-paths ["resources" "target/cljsbuild"]
+
+  :profiles {:dev {:dependencies [[binaryage/devtools "0.9.10"]]}}

   :cljsbuild
   {:builds
@@ -44,10 +47,6 @@
                 :optimizations :advanced
                 :pretty-print false}}]}

-  :figwheel
-  {:http-server-root "public"
-   :server-port 3449
-   :nrepl-port 7002}
-
-  :profiles {:dev {:dependencies [[binaryage/devtools "0.9.10"]]
-                   :plugins [[lein-figwheel "0.5.16"]]}})
+  :figwheel {:http-server-root "public"
+             :server-port 3449
+             :nrepl-port 7002})


removed import that was causing a warning

--- src/guide/untangled/ui/form_demo_cards.cljs
+++ src/guide/untangled/ui/form_demo_cards.cljs
@@ -5,7 +5,6 @@
     [om.next :as om :refer [defui]]
     [om.dom :as dom]
     [untangled.client.core :as uc]
-    [untangled.services.local-storage :as ls]
     [untangled.client.routing :as r :refer [defrouter]]
     [untangled.client.impl.network :as un]
     [untangled.client.mutations :as m :refer [defmutation]]


fixed a bug with the refresher

fixed a bug with the refresher

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -263,7 +263,7 @@
                        (to-day-ranges))
         last-cycle-type (last-cycle-type cycle-type day-ranges)]
     {:cycle-number (last-cycle-number cycle-number cycle-type day-ranges)
-     :last-index (-> indexed (last) (first) (#(if % % first-index)))
+     :last-index (-> indexed (last) (first) (#(if % % (dec first-index))))
      :cycle-type last-cycle-type
      :votes (days-into-votes (range (get-first-day cycle-number cycle-type)
                                     (+ cycle-number (count day-ranges) 1))


fix cryptic error when using unknown build id for watch

--- src/main/shadow/cljs/devtools/server.clj
+++ src/main/shadow/cljs/devtools/server.clj
@@ -222,12 +222,9 @@
       (when (not= x ::eof)
         (recur)))))

-(defn watch-builds [build-ids options]
+(defn watch-builds [config build-configs options]
   (let [{:keys [supervisor] :as app}
         @runtime/instance-ref
-
-        {:keys [builds] :as config}
-        (config/load-cljs-edn!)

         out-chan
         (-> (async/sliding-buffer 100)
@@ -235,19 +232,16 @@

         verbose
         (or (:verbose options)
-            (:verbose config))]
-
-    (doseq [build-id build-ids]
-      (let [{:keys [supervisor] :as app}
-            @runtime/instance-ref
-
-            build-config
-            (get builds build-id)]
-
-        (println "shadow-cljs - watching build" build-id)
-        (-> (api/get-or-start-worker build-config options)
-            (worker/watch out-chan false)
-            (worker/start-autobuild))))
+            (:verbose config))
+
+        {:keys [supervisor] :as app}
+        @runtime/instance-ref]
+
+    (doseq [{:keys [build-id] :as build-config} build-configs]
+      (println "shadow-cljs - watching build" build-id)
+      (-> (api/get-or-start-worker build-config options)
+          (worker/watch out-chan false)
+          (worker/start-autobuild)))

     (go (loop []
           (when-some [msg (<! out-chan)]
@@ -260,84 +254,96 @@
     ))

 (defn from-cli [action builds {:keys [verbose] :as options}]
-  (if (and (contains? #{:watch :cljs-repl} action)
-           (empty? builds))
-    (println "Build id required.")
-
-    (let [already-running?
-          (some? @runtime/instance-ref)]
-
-      (when-not already-running?
-        (start!))
-
-      (case action
-        :watch
-        (do (let [before (api/active-builds)]
-              (watch-builds builds options)
+  (let [config
+        (config/load-cljs-edn!)
+
+        build-configs
+        (->> builds
+             (map (fn [build-id]
+                    (let [build-config (get-in config [:builds build-id])]
+                      (when-not build-config
+                        (println (str "No config for build \"" (name build-id) "\" found.")))
+
+                      build-config
+                      )))
+             (remove nil?)
+             (into []))
+
+        already-running?
+        (some? @runtime/instance-ref)]
+
+    (if (and (contains? #{:watch :cljs-repl} action)
+             (empty? build-configs))
+      (println "Build id required.")
+
+      (do (when-not already-running?
+            (start!))
+
+          (case action
+            :watch
+            (let [before (api/active-builds)]
+              (watch-builds config build-configs options)

               (wait-for-eof!)

               ;; stop only builds that weren't running before
               (doseq [build builds
                       :when (not (contains? before build))]
-                (api/stop-worker build))))
-
-        :clj-repl
-        (r/enter-root {}
-          (socket-repl/repl {}))
-
-        :cljs-repl
-        (let [{:keys [supervisor] :as app}
-              @runtime/instance-ref
-
-              build-id
-              (first builds)
-
-              build-config
-              (config/get-build! build-id)]
-
-          (if (false? (get-in build-config [:devtools :enabled]))
-            (println (format "Build %s has :devtools {:enabled false}, can't connect to a REPL" build-id))
-            (let [worker
-                  (super/get-worker supervisor build-id)
-
-                  started-by-us?
-                  (nil? worker)
+                (api/stop-worker build)))
+
+            :clj-repl
+            (r/enter-root {}
+              (socket-repl/repl {}))
+
+            :cljs-repl
+            (let [{:keys [supervisor] :as app}
+                  @runtime/instance-ref
+
+                  {:keys [build-id] :as build-config}
+                  (first build-configs)]
+
+              (if (false? (get-in build-config [:devtools :enabled]))
+                (println (format "Build %s has :devtools {:enabled false}, can't connect to a REPL" build-id))
+                (let [worker
+                      (super/get-worker supervisor build-id)
+
+                      started-by-us?
+                      (nil? worker)
+
+                      worker
+                      (-> (or worker
+                              (-> (super/start-worker supervisor build-config)
+                                  (worker/compile)))
+                          ;; need to sync in case it is still compiling
+                          (worker/sync!))]
+
+                  (api/repl build-id)
+
+                  (when started-by-us?
+                    (super/stop-worker supervisor build-id)))))
+
+            :node-repl
+            (let [{:keys [supervisor] :as app} @runtime/instance-ref

                   worker
-                  (-> (or worker
-                          (-> (super/start-worker supervisor build-config)
-                              (worker/compile)))
-                      ;; need to sync in case it is still compiling
-                      (worker/sync!))]
-
-              (api/repl build-id)
-
-              (when started-by-us?
-                (super/stop-worker supervisor build-id)))))
-
-        :node-repl
-        (let [{:keys [supervisor] :as app} @runtime/instance-ref
-
-              worker
-              (super/get-worker supervisor :node-repl)]
-          ;; FIXME: connect to if already running or launch another one?
-          (if-not worker
-            (do (println "shadow-cljs - starting node-repl")
-                (api/node-repl options))
-
-            (do (println "shadow-cljs - connecting to running node-repl")
-                (api/repl :node-repl))
-            ))
-
-        ;; makes this a noop if server is already running
-        :server
-        (if already-running?
-          (println "server already running")
-          (wait-for-eof!)))
-
-      (when-not already-running?
-        (stop!)))))
+                  (super/get-worker supervisor :node-repl)]
+              ;; FIXME: connect to if already running or launch another one?
+              (if-not worker
+                (do (println "shadow-cljs - starting node-repl")
+                    (api/node-repl options))
+
+                (do (println "shadow-cljs - connecting to running node-repl")
+                    (api/repl :node-repl))
+                ))
+
+            ;; makes this a noop if server is already running
+            :server
+            (if already-running?
+              (println "server already running")
+              (wait-for-eof!)))
+
+          (when-not already-running?
+            (stop!))))))

 (comment
   (start!)


move #'derived? and #'derive-ugen-specs closer to where they are called

--- src/overtone/sc/machinery/ugen/specs.clj
+++ src/overtone/sc/machinery/ugen/specs.clj
@@ -10,37 +10,6 @@
   '[basicops buf-io compander delay envgen fft2 fft-unpacking grain
     io machine-listening misc osc beq-suite chaos control demand
     ff-osc fft info noise pan trig line input filter random mda stk])
-
-(defn- derived?
-  "Determines whether the supplied ugen spec is derived from another ugen spec.
-
-   This means that the ugen needs to inherit some properties from its parent.
-   (The ugen spec's parent is specified using the key :extends)"
-  [spec]
-  (contains? spec :extends))
-
-(defn- derive-ugen-specs
-  "Merge the specified ugen spec maps to give children their parent's attributes
-   by recursively reducing the specs to support arbitrary levels of derivation."
-  ([specs] (derive-ugen-specs specs {} 0))
-  ([children adults depth]
-     ;; Make sure a bogus UGen doesn't spin us off into infinity... ;-)
-     {:pre [(< depth 8)]}
-
-     (let [[adults children]
-           (reduce (fn [[full-specs new-children] spec]
-                     (if (derived? spec)
-                       (if (contains? full-specs (:extends spec))
-                         [(assoc full-specs (:name spec)
-                                 (merge (get full-specs (:extends spec)) spec))
-                          new-children]
-                         [full-specs (conj new-children spec)])
-                       [(assoc full-specs (:name spec) spec) new-children]))
-                   [adults []]
-                   children)]
-       (if (empty? children)
-         (vals adults)
-         (recur children adults (inc depth))))))

 (defn- specs-from-namespaces
   "Gathers all ugen spec metadata (stored in the vars spec and specs-collide)
@@ -389,6 +358,37 @@
       (doc/with-arg-defaults)
       (doc/with-full-doc)))

+(defn- derived?
+  "Determines whether the supplied ugen spec is derived from another ugen spec.
+
+   This means that the ugen needs to inherit some properties from its parent.
+   (The ugen spec's parent is specified using the key :extends)"
+  [spec]
+  (contains? spec :extends))
+
+(defn- derive-ugen-specs
+  "Merge the specified ugen spec maps to give children their parent's attributes
+   by recursively reducing the specs to support arbitrary levels of derivation."
+  ([specs] (derive-ugen-specs specs {} 0))
+  ([children adults depth]
+     ;; Make sure a bogus UGen doesn't spin us off into infinity... ;-)
+     {:pre [(< depth 8)]}
+
+     (let [[adults children]
+           (reduce (fn [[full-specs new-children] spec]
+                     (if (derived? spec)
+                       (if (contains? full-specs (:extends spec))
+                         [(assoc full-specs (:name spec)
+                                 (merge (get full-specs (:extends spec)) spec))
+                          new-children]
+                         [full-specs (conj new-children spec)])
+                       [(assoc full-specs (:name spec) spec) new-children]))
+                   [adults []]
+                   children)]
+       (if (empty? children)
+         (vals adults)
+         (recur children adults (inc depth))))))
+
 (defn- load-ugen-specs [namespaces]
   "Perform the derivations and setup defaults for rates, names
   argument initialization functions, and channel expansion flags."


Fix brackets and doc strings

Fix brackets and doc strings

--- src/reagent_components/test_harness.cljs
+++ src/reagent_components/test_harness.cljs
@@ -56,7 +56,7 @@
   [& {:keys [label on-click]}]
   "Render a button to launch a modal window"
   [button label on-click
-   ;; :text    label
+   ;; :label    label
    ;; :on-click on-click
    :style {:font-weight "bold" :color "red" :margin "1px" :height "39px"}
    :class "btn-info"])
@@ -121,18 +121,17 @@

 (defn loading-url-modal
   [url loading?]
-  "Show this modal window when loading a url
-  "
+  "Show this modal window when loading a url"
   [modal-window
    :markup [:div {:style {:max-width "600px"}}
             [:p (str "Loading data from '" url "'...")]
             [spinner]
             [cancel-button #(reset! loading? false)]]])

+
 (defn load-url
   [url loading?]
-  "Load some data from the remote server
-  "
+  "Load some data from the remote server"
   (util/console-log (str "*** Loading data from: " url))
   (system-load-url
    url
@@ -149,13 +148,12 @@
              ;; ***** PROCESS THE RETURNED DATA HERE
              )
            (util/console-log "*** CANCELLED!"))
-         (reset! loading? false))))
-   ))
+         (reset! loading? false))))))
+

 (defn test-load-url
   []
-  "Create a button to test the modal component for loading a url
-  "
+  "Create a button to test the modal component for loading a url"
   (let [loading? (reagent/atom false)
         url      "http://static.day8.com.au/locations.xml"]
     (fn []
@@ -166,9 +164,7 @@
                      (reset! loading? true)
                      (load-url url loading?))]
        (when @loading?
-         [loading-url-modal url loading?])
-       ])
-    ))
+         [loading-url-modal url loading?])])))

 ;; ------------------------------------------------------------------------------------
@@ -177,8 +173,7 @@

 (defn system-write-path
   [path data callback]
-  "Simulate the system's load-url functionality (will call back in 3 seconds)
-  "
+  "Simulate the system's load-url functionality (will call back in 3 seconds)"
   (let [err  "The file could not be saved - Disk Full!"
         data nil]
     (js/setTimeout #(callback err data) 3000)))
@@ -216,13 +211,12 @@
              ;; FURTHER PROCESSING HERE IF REQUIRED
              )
            (util/console-log "*** CANCELLED!"))
-         (reset! writing? false))))
-   ))
+         (reset! writing? false))))))
+

 (defn test-write-disk
   []
-  "Create a button to test the modal component for writing to disk
-  "
+  "Create a button to test the modal component for writing to disk"
   (let [writing? (reagent/atom false)
         mwi-file "C:\\Day8\\MWIEnhancer\\test.mwi"]
     (fn []
@@ -243,8 +237,7 @@

 (defn calcing-pivot-totals-modal
   []
-  "Show this modal window when calculating pivot totals
-  "
+  "Show this modal window when calculating pivot totals"
   [modal-window
    :markup [:div {:style {:max-width "200px"}}
             [:p {:style {:text-align "center"}}
@@ -252,18 +245,17 @@

 (defn calc-pivot-totals
   [calculating?]
-  "Calculate pivot totals
-  "
+  "Calculate pivot totals"
   (util/console-log "calc-pivot-totals START")
   (cpu-delay 500)
   ;; ***** PROCESS THE RETURNED DATA HERE
   (util/console-log "calc-pivot-totals END")
   (reset! calculating? false))

+
 (defn test-calc-pivot-totals
   []
-  "Create a button to test the modal component for calculating pivot totals
-  "
+  "Create a button to test the modal component for calculating pivot totals"
   (let [calculating? (reagent/atom false)]
     (fn []
       [:div
@@ -274,9 +266,7 @@
                      (start-cpu-intensive (fn [] (calc-pivot-totals calculating?)))
                      )] ;; Delay call to allow modal to show
        (when @calculating?
-         [calcing-pivot-totals-modal])
-       ])
-    ))
+         [calcing-pivot-totals-modal])])))

 ;; ------------------------------------------------------------------------------------
@@ -287,8 +277,7 @@

 (defn process-xml-modal
   [calculating?]
-  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)
-  "
+  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)"
   [modal-window
    :markup [:div {:style {:max-width "200px"}}
             [:p {:style {:text-align "center"}}
@@ -298,6 +287,7 @@
             [spinner]
             [cancel-button #(reset! calculating? false)]]])

+
 (defn process-xml
   []
   (let [chunks 5]
@@ -313,13 +303,12 @@
         (cpu-delay 50)
         (if (< new-p1 420196140727489660)
           next-params
-          nil)))
-    ))
+          nil)))))
+

 (defn test-process-xml
   []
-  "Create a button to test the modal component for calculating pivot totals
-  "
+  "Create a button to test the modal component for calculating pivot totals"
   (let [calculating? (reagent/atom false)]
     (fn []
       [:div
@@ -330,9 +319,7 @@
                     [1 1]
                     calculating?)]
        (when @calculating?
-         [process-xml-modal calculating?])
-       ])
-    ))
+         [process-xml-modal calculating?])])))

 ;; ------------------------------------------------------------------------------------
@@ -377,8 +364,7 @@

 (defn mwi-steps-modal
   [progress-msg progress-percent calculating?]
-  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)
-  "
+  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)"
   [modal-window
    :markup [:div {:style {:max-width "500px"}}
             [:p {:style {:text-align "center"}}
@@ -407,8 +393,7 @@

 (defn test-mwi-steps
   []
-  "Create a button to test the modal component for calculating multiple mwi steps
-  "
+  "Create a button to test the modal component for calculating multiple mwi steps"
   (let [calculating? (reagent/atom false)]
     (fn []
       [:div
@@ -457,8 +442,7 @@

 (defn mwi-steps-modal-2
   [progress-msg progress-percent calculating?]
-  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)
-  "
+  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)"
   [modal-window
    :markup [:div {:style {:max-width "500px"}}
             [:p {:style {:text-align "center"}}
@@ -488,15 +472,11 @@
             (let [step-result (apply (:fn this-step) (:params this-step))]
               (if (and step-result (< step-to-process (dec (count steps))))
                 [(inc step-to-process) progress-msg progress-percent ui-updated?] ;; Go again, run next step
-                nil))))
-
-        ))
-    ))
+                nil))))))))

 (defn test-mwi-steps-2
   []
-  "Create a button to test the modal component for calculating multiple mwi steps
-  "
+  "Create a button to test the modal component for calculating multiple mwi steps"
   (let [calculating?     (reagent/atom false)
         progress-msg     (reagent/atom "")
         progress-percent (reagent/atom 0)
@@ -513,9 +493,7 @@
          [mwi-steps-modal-2
           progress-msg
           progress-percent
-          calculating?])
-       ])
-    ))
+          calculating?])])))

 ;; ------------------------------------------------------------------------------------
@@ -724,8 +702,7 @@
              ;; FURTHER PROCESSING HERE IF REQUIRED
              )
            (util/console-log "*** CANCELLED!"))
-         (reset! writing? false))))
-   ))
+         (reset! writing? false))))))

 (defn update-chunked-json-ui
   [msg percent]
@@ -736,8 +713,7 @@

 (defn chunked-json-modal
   [progress-msg progress-percent calculating?]
-  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)
-  "
+  "Show this modal window when chunking through an in memory XML file (actualy we're justing calcing fibs)"
   [modal-window
    :markup [:div {:style {:max-width "500px"}}
             [:p {:style {:text-align "center"}}
@@ -761,8 +737,7 @@
         (let [step-result ((:fn this-step) (:params this-step))]
           (if (and step-result (< step-to-process (dec (count steps))))
             (inc step-to-process)
-            nil))))
-    ))
+            nil))))))

 (defn test-chunked-json
   []
@@ -778,9 +753,7 @@
          [chunked-json-modal
           chunked-json-progress-msg
           chunked-json-progress-percent
-          calculating?])
-       ])
-    ))
+          calculating?])])))

@@ -823,13 +796,11 @@
    [:hr {:style {:margin "10px 0 10px"}}]
    [button "Sign in" process-ok :class "btn-primary"]
    [:span " "]
-   [button "Cancel" process-cancel]
-   ])
+   [button "Cancel" process-cancel]])

 (defn test-modal-dialog
   []
-  "Create a button to test the modal component for modal dialogs
-  "
+  "Create a button to test the modal component for modal dialogs"
   (let [showing?       (reagent/atom false)
         form-data      (reagent/atom {:email       "gregg.ramsey@day8.com.au"
                                       :password    "abc123"
@@ -856,8 +827,7 @@
                         :markup [test-form-markup
                                  form-data
                                  process-ok
-                                 process-cancel]])])
-    ))
+                                 process-cancel]])])))

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


Small change in sample data import for SUs.

--- src/open_company/util/sample_data.clj
+++ src/open_company/util/sample_data.clj
@@ -26,7 +26,7 @@
     (if
       (su/create-stakeholder-update! conn
         (su/->stakeholder-update conn
-          company-slug
+          company
           (dissoc update :timestamp)
           as-of
           author))


used `macro-for` in unfinished*

used `macro-for` in unfinished*

--- src/midje/semi_sweet.clj
+++ src/midje/semi_sweet.clj
@@ -86,14 +86,12 @@
 ;;; Interface: unfinished

 (defn- unfinished* [names]
-  (let [declarations (for [name names]
-                      `(do
-                         (defn ~name [& args#]
-                           (throw (user-error (str "#'" '~name " has no implementation. It's used as a prerequisite in Midje tests."))))
-                         ;; A reliable way of determining if an `unfinished` function
-                         ;; has since been defined.
-                         (alter-meta! (var ~name) assoc :midje/unfinished-fun ~name)))]
-    `(do ~@declarations)))
+  (macro-for [name names]
+    `(do
+       (defn ~name [& args#]
+         (throw (user-error (str "#'" '~name " has no implementation. It's used as a prerequisite in Midje tests."))))
+       ;; A reliable way of determining if an `unfinished` function has since been defined.
+       (alter-meta! (var ~name) assoc :midje/unfinished-fun ~name))))

 (defmacro unfinished
   "Defines a list of names as functions that have no implementation yet. They will


removed local test connection

removed local test connection

--- frameworks/Clojure/luminus/hello/src/hello/db/core.clj
+++ frameworks/Clojure/luminus/hello/src/hello/db/core.clj
@@ -3,20 +3,12 @@
     [yesql.core :refer [defqueries]])
   (:import com.mchange.v2.c3p0.ComboPooledDataSource))

-#_(def db-spec
+(def db-spec
   {:classname "com.mysql.jdbc.Driver"
    :subprotocol "mysql"
    :subname "//localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
    :user "benchmarkdbuser"
    :password "benchmarkdbpass"})
-
-(def db-spec
-  {:classname "com.mysql.jdbc.Driver"
-   :subprotocol "mysql"
-   :subname "//localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
-   :user "root"
-   :password "root"
-   })

 (defn pool
   [spec]


Fixed bug where numeric args to the ctl method weren't converted to floats.

--- src/overtone/sc/core.clj
+++ src/overtone/sc/core.clj
@@ -371,7 +371,7 @@
   "Set control values for a node."
   [node-id & name-values]
   {:pre [(connected?)]}
-  (apply snd "/n_set" node-id (stringify name-values))
+  (apply snd "/n_set" node-id (floatify (stringify name-values)))
   node-id)

 ; This can be extended to support setting multiple ranges at once if necessary...


process all lines that a cursor jumps over when changing position

--- src/parinfer/editor.cljs
+++ src/parinfer/editor.cljs
@@ -45,10 +45,20 @@
           (- end-x start-x))))))

 (defn compute-cm-change
-  [cm change {:keys [cursor-line] :as overrides}]
-  (let [start-line    (if change (.. change -from -line) cursor-line)
-        end-line      (if change (inc (.. change -to -line)) (inc cursor-line))
-        num-new-lines (if change (alength (.-text change)) 1)
+  [cm change overrides prev-state]
+  (let [{:keys [start-line end-line num-new-lines]}
+        (if change
+          {:start-line (.. change -from -line)
+           :end-line (inc (.. change -to -line))
+           :num-new-lines (alength (.-text change))}
+
+          (let [[start end] (sort [(:cursor-line prev-state)
+                                   (:cursor-line overrides)])
+                end (inc end)]
+            {:start-line start
+             :end-line end
+             :num-new-lines (- end start)}))
+
         lines (for [i (range start-line (+ start-line num-new-lines))]
                 (.getLine cm i))]
     {:line-no [start-line end-line]
@@ -85,7 +95,7 @@
                  state (if (and use-cache? @prev-state)
                          (infer/process-text-change
                            @prev-state
-                           (compute-cm-change cm change overrides)
+                           (compute-cm-change cm change overrides @prev-state)
                            overrides)
                          (infer/process-text overrides current-text))]


Now writing lyrics for every note rather than tracking source file

--- src/aeolian/composer.clj
+++ src/aeolian/composer.clj
@@ -22,16 +22,15 @@
   (if (not (nil? indentation?))
     (midi/volume-boost)))

-(defn build-lyrics [current-source-file source-file]
+(defn build-lyrics [current-source-file]
   (abc/lyrics-for current-source-file))

 (defn build-instrument [current-author]
   (midi/instrument-command-for current-author))

-(defn build-measure [measure-lines-metrics composition-key source-file method-length]
+(defn build-measure [measure-lines-metrics composition-key method-length]
  (loop [measure {}
         remaining-line-metrics measure-lines-metrics
-        current-source-file source-file
         current-method-length method-length]
      (if (not remaining-line-metrics)
        measure
@@ -41,17 +40,16 @@
              final-note          (abc/note
                                   (build-note (:line-length metric-components) composition-key)
                                   (build-instrument (:author metric-components))
-                                  (build-lyrics current-source-file source-file)
+                                  (build-lyrics (:source-file metric-components))
                                   (build-tempo (:complexity metric-components)))]

         (recur
-         {:notes (conj (:notes measure) final-note) :source-file current-source-file :method-length current-method-length}
+         {:notes (conj (:notes measure) final-note) :method-length current-method-length}
          (next remaining-line-metrics)
-         (:source-file metric-components)
          (:method-length metric-components))))))

-(defn metrics-to-measure [metrics-in-measure composition-key source-file method-length]
- (let [measure               (build-measure metrics-in-measure composition-key source-file method-length)
+(defn metrics-to-measure [metrics-in-measure composition-key method-length]
+ (let [measure               (build-measure metrics-in-measure composition-key method-length)
        current-method-length (parser/find-longest-method-length-in metrics-in-measure)
        accompanying-chord    (n/pick-chord-for-method-length current-method-length composition-key (:method-length measure))]
    (abc/measure accompanying-chord (:notes measure))))
@@ -65,7 +63,7 @@

 (defn- map-metrics [metrics composition-key]
   (let [metrics-in-measures (split-metrics-into-equal-measures metrics)
-        mapped-notes         (map #(metrics-to-measure %1 composition-key "" 1) metrics-in-measures)]
+        mapped-notes         (map #(metrics-to-measure %1 composition-key 1) metrics-in-measures)]
     (apply str mapped-notes)))

 (defn compose [metrics composition-key]


Rename valide to validate for function name (#219)

--- src/selmer/validator.clj
+++ src/selmer/validator.clj
@@ -51,7 +51,7 @@
 (defn close-tags []
   (apply concat (vals @closing-tags)))

-(defn valide-tag [template line tags {:keys [tag-name args tag-value tag-type] :as tag}]
+(defn validate-tag [template line tags {:keys [tag-name args tag-value tag-type] :as tag}]
   (condp = tag-type
     :expr
     (let [last-tag (last tags)
@@ -106,7 +106,7 @@
       (if ch
         (if (open-tag? ch rdr)
           (if-let [tag-info (read-tag rdr line template)]
-            (recur (valide-tag template line tags tag-info) (read-char rdr) line)
+            (recur (validate-tag template line tags tag-info) (read-char rdr) line)
             (recur tags (read-char rdr) line))
           (recur tags (read-char rdr) (if (= \newline ch) (inc line) line)))
         tags))))


Warn on reflection

Warn on reflection

--- src/atom_finder/core.clj
+++ src/atom_finder/core.clj
@@ -15,12 +15,14 @@
 (defn -main
   [& args]

+  (set! *warn-on-reflection* true)
+
   ;(->> (atom-patch/atoms-changed-all-commits gcc-repo atoms)
   ;     ;(map prn)
   ;     (take 10)
   ;     dorun)

-  ; 3:51
+  ; 4:10
   (atom-patch/log-atoms-changed-all-commits "gcc-bugs-atoms_2017-03-20.txt" gcc-repo atoms)
 )


Make Specs work with regexs too

Make Specs work with regexs too

--- src/spec_tools/core.cljc
+++ src/spec_tools/core.cljc
@@ -154,8 +154,8 @@
       ;; there is a dynamic conformer
       (if-let [conform (get *conforming* type)]
         (conform this x)
-        ;; spec predicate
-        (if (s/spec? spec)
+        ;; spec or regex
+        (if (or (s/spec? spec) (s/regex? spec))
           (s/conform spec x)
           ;; invalid
           +invalid+))))


if :subcat is specified for :det or :adverb, then use that rather than clobbering to '()

--- src/babel/lexiconfn.cljc
+++ src/babel/lexiconfn.cljc
@@ -607,8 +607,11 @@
         lexical-entry))

 (defn category-to-subcat [lexical-entry]
-  (cond (or (= (get-in lexical-entry '(:synsem :cat)) :det)
-            (= (get-in lexical-entry '(:synsem :cat)) :adverb))
+  (cond (and (or (= :det (get-in lexical-entry [:synsem :cat]))
+                 (= :adverb (get-in lexical-entry [:synsem :cat])))
+
+             ;; if subcat is defined, then go with that rather than trying to unify with subcat0
+             (= :none (get-in lexical-entry [:synsem :subcat] :none)))
         (unifyc
          subcat0
          lexical-entry)


database: delete* should take an id, not a map

--- src/subrosa/database.clj
+++ src/subrosa/database.clj
@@ -41,17 +41,18 @@
                       (map m index)
                       (m index))])))

-(defn delete* [db table m]
+(defn delete* [db table id]
   (update-in db [table] assoc
              :data (reduce (fn [a [k v]]
                              (update-in a [k] dissoc v))
                            (get-in db [table :data])
-                           (select-from-indices db table m))))
+                           (select-from-indices
+                            db table (or (get* db table :id id)
+                                         {})))))

 (defn delete [table id]
   (dosync
-   (let [m (get table :id id)]
-     (alter db delete* table m))))
+   (alter db delete* table id)))

 (defn put* [db table m]
   (update-in db [table] assoc
@@ -65,5 +66,5 @@
    (let [m (ensure-id m)]
      (alter db (fn [db]
                  (-> db
-                     (delete* table m)
+                     (delete* table (:id m))
                      (put* table m)))))))


`as-bool` now interprets numerical 0,1

`as-bool` now interprets numerical 0,1

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -72,9 +72,9 @@
 ;;; versions that auto-serialized simple number types
 (defn as-long   [x] (when x (if (number? x) (long   x) (Long/parseLong     x))))
 (defn as-double [x] (when x (if (number? x) (double x) (Double/parseDouble x))))
-(defn as-bool   [x] (cond (or (true? x) (false? x))    x
-                          (or (= x "false") (= x "0")) false
-                          (or (= x "true")  (= x "1")) true
+(defn as-bool   [x] (cond (or (true? x) (false? x))            x
+                          (or (= x "false") (= x "0") (= x 0)) false
+                          (or (= x "true")  (= x "1") (= x 1)) true
                           :else nil))

 (defmacro parse-long     [& body] `(with-parser as-long      ~@body))


Fix `with-replies` unstashing + parser interaction issue

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -142,9 +142,8 @@
        (try (with-parser nil ~@body) ; Herewith dragons; tread lightly
             (protocol/get-replies! ~as-pipeline?)
             (finally
-             ;; Broken in for Clojure <1.5, Ref. http://goo.gl/5DvRt
-             ;; (doseq [reply# stashed-replies#] (return reply#))
-             (dorun (map return stashed-replies#)))))))
+             ;; doseq here broken with Clojure <1.5, Ref. http://goo.gl/5DvRt
+             (with-parser nil (dorun (map return stashed-replies#))))))))

 (comment (wc (echo 1) (println (with-replies (ping))) (echo 2))
          (wc (echo 1) (println (with-replies :as-pipeline (ping))) (echo 2)))


Write terminating newline in text format

--- src/bltool/data/text.clj
+++ src/bltool/data/text.clj
@@ -19,4 +19,5 @@
   (->> games
        (map to-text)
        (join "\n")
-       (.write sink)))
+       (.write sink))
+  (.write sink "\n"))


Fix parameters naming on `buddy.core.bytes/fill!` function.

--- src/buddy/core/bytes.clj
+++ src/buddy/core/bytes.clj
@@ -33,16 +33,16 @@
   of the specified array of bytes."
   ([^bytes input val]
    (Arrays/fill input (byte val)))
-  ([^bytes input val & {:keys [limit offset]}]
-   (let [offset (or offset 0)
-         limit (or limit (count input))]
-     (Arrays/fill input offset limit (byte val)))))
+  ([^bytes input val & {:keys [limit offset start end]}]
+   (let [start (or offset start 0)
+         end (or limit start (count input))]
+     (Arrays/fill input start end (byte val)))))

 (defn slice
-  "Given a byte array, get a copy of it. If offset
-  and limit is provided, a slice will be returned."
-  [^bytes input ^long offset ^long limit]
-  (Arrays/copyOfRange input offset limit))
+  "Returns a new copy of the byte array but
+  offset and crop by start and end indices."
+  [^bytes input ^long start ^long end]
+  (Arrays/copyOfRange input start end))

 (defn copy
   "Is a specialized version of slice that


fix swank

fix swank

--- src/cake/tasks/swank.clj
+++ src/cake/tasks/swank.clj
@@ -3,7 +3,7 @@

 (deftask swank
   "Report status of swank server and start it if not running."
-  (bake (:require [cake.swank :as swank]) []
+  (bake (:require [bake.swank :as swank]) []
         (if (not (swank/installed?))
           (do (println "swank-clojure is not in your library path.")
               (println "add swank-clojure as a dev-dependency in ~/.cake/project.clj to enable"))


Requires should go inside the namespace declaration

According to [1], at least, but I'll do it until I learn otherwise.

  [1] https://github.com/bbatsov/clojure-style-guide

--- src/chameleon/client.clj
+++ src/chameleon/client.clj
@@ -1,6 +1,6 @@
-(ns chameleon.client)
-(require '[clj-http.client :as client])
-(require '[clojure.data.json :as json])
+(ns chameleon.client
+  (:require [clj-http.client :as client])
+  (:require [clojure.data.json :as json]))

 (defn url [user-id]
   (str "http://api.stackexchange.com/2.2/users/" user-id "?site=stackoverflow"))


CLJS-473: cljs.closure/add-dep-string calls wrong munge

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -756,7 +756,7 @@
 (defn add-dep-string
   "Return a goog.addDependency string for an input."
   [opts input]
-  (letfn [(ns-list [coll] (when (seq coll) (apply str (interpose ", " (map #(str "'" (munge %) "'") coll)))))]
+  (letfn [(ns-list [coll] (when (seq coll) (apply str (interpose ", " (map #(str "'" (comp/munge %) "'") coll)))))]
     (str "goog.addDependency(\""
          (path-relative-to (io/file (output-directory opts) "goog/base.js") input)
          "\", ["


Fixing reconnect to respect max text message size.

--- src/clj_discord/core.clj
+++ src/clj_discord/core.clj
@@ -81,7 +81,7 @@
                                                                       "$referring_domain" ""}
                                                         "compress" false}}))
    (while (not @reconnect-needed) (Thread/sleep 1000))
-   (connect token functions log-events)))
+   (connect token functions log-events max-text-message-size)))

 (defn post-message [channel_id message]
   (http/post (str "https://discordapp.com/api/channels/" channel_id "/messages")


Fix the inport statement in the utils file.

--- src/clj_spotify/util.clj
+++ src/clj_spotify/util.clj
@@ -2,7 +2,7 @@
   (:require [clj-http.client :as client]
             [clojure.data.codec.base64 :as b64]
             [clojure.java.io :as io])
-  (import [org.apache.commons.io IOUtils]))
+  (:import [org.apache.commons.io IOUtils]))

 (defn get-access-token
   "Requests an access token from Spotify's API via the Client Credentials flow.


Add gtfve specific components

Add gtfve specific components

--- src/cljs/gtfve/maps.cljs
+++ src/cljs/gtfve/maps.cljs
@@ -136,3 +136,59 @@
                                 [r-map-object Maps.Marker
                                  (r/wrap marker-opts swap! state assoc-in [:markers id])
                                  @gmap]))])})))
+
+(declare route trip stop-time stop)
+(defn route [route gmap]
+  (let [{trips :route/trips} @route]
+    (for [{id :trip :as trip-data} trips]
+      ^{:key id}
+      [trip
+       (r/wrap trip-data swap! route assoc-in [:route/trips id])
+       gmap])))
+
+(defn trip [trip gmap]
+  (let [stop-times (->> @trip
+                        :trip/stops
+                        (sort-by :stop-time/stop-sequence))
+        stops (map :stop-time/stop stop-times)
+        path (->> stop-times
+                  (map :stop-time/stop)
+                  (map (juxt :stop/latitude
+                             :stop/longitude)))]
+    ;; TODO: add markers
+    [:span
+     [r-map-object Maps.PolyLine (merge default-polyline-opts {:path path}) gmap]]))
+
+(defn stop-time [stop-time gmap]
+  (let [{stop-data :stop-time/stop
+         index :stop-time/stop-sequence
+         arrival-time :stop-time/arrival-time
+         departure-time :stop-time/departure-time} @stop-time]))
+
+(defn stop [data gmap]
+  (let [{lat :stop/latitude
+         lng :stop/longitude
+         name :stop/name} @data]
+    [r-map-object Maps.Marker
+     (merge default-marker-opts
+            {:position (Maps.LatLng lat lng)
+             :title name})]))
+
+(defn route-map [state]
+  (let [gmap (atom nil)]
+    (r/create-class
+     {:component-did-mount (fn [this]
+                             (let [opts (:opts @state)
+                                   node (.getDOMNode this)
+                                   google-map (Maps.Map. node (clj->js opts))]
+                               (reset! gmap google-map)))
+      :component-function (fn [state]
+                            [:div {:id :map-canvas
+                                   :style {:height "100%"
+                                           :margin 0
+                                           :padding 0}}
+                             (doall
+                              (for [{id :route/id
+                                     :as route-data} (:routes @state)]
+                                ^{:key id}
+                                [route route-data gmap]))])})))


geolocation back in place

geolocation back in place

--- src/cljs/hivez/core.cljs
+++ src/cljs/hivez/core.cljs
@@ -49,6 +49,7 @@
               (google.maps.event.addListener marker
                 "rightclick"
                 #(.setMap marker nil)))))
+
         (if navigator.geolocation
           (.getCurrentPosition navigator.geolocation
            (fn [pos]
@@ -69,14 +70,14 @@

 (defn handleOrientation [evt]
   (swap! app-state #(assoc % :orientation
-                              (if (> (.-innerHeight js/window) (.-innerWidth js/window))
-                                :portrait
-                                :landscape))))
+                           (if (> (.-innerHeight js/window)
+                                 (.-innerWidth js/window))
+                             :portrait
+                             :landscape))))

 (defn app [data owner]
   (om/component
     (dom/div #js {:className "content-liner"}
-
       (dom/div #js {:className (str "flex-container"
                                  (if (= (:orientation data) :portrait)
                                    " column"


More transducers

More transducers

--- src/cljs/klang/core.cljs
+++ src/cljs/klang/core.cljs
@@ -780,7 +780,8 @@
 ;; Hmm, sounds like a coloring problem??

 (defn pred->color
-  ""
+  "Given a predicate pred? and which (:ns, :type) it wraps the part of
+  the log message in a span and applies the color."
   [db pred? which color]
   {:pre [(or (= :ns which) (= :type which))]}
   (register-transducer!
@@ -803,7 +804,10 @@
 (defn ns*->color
   "Gives all namespaces that are children of ns* a color."
   [db ns* color]
-  (pred->color db (fn [ns] (or (= ns* ns) (parent? ns* ns))) :ns color))
+  (pred->color db
+               (fn [ns] (or (= ns* ns)
+                            (parent? ns* ns)))
+               :ns color))

 (defn msg->console!
   "Registers a listener to the log channel which will --in addition to
@@ -832,16 +836,42 @@
                                          (set types)
                                          (:type %)))))

+(defn tab->ns*!
+  [db tab-key & namespaces]
+  (tab->transducer! db tab-key (filter #(some
+                                         (fn[ns] (self-or-parent? ns (:ns %)))
+                                         namespaces))))
+
+
+(defn tab->ns!
+  [db tab-key & namespaces]
+  (tab->transducer! db tab-key (filter #(some
+                                         (fn[ns] (= ns (:ns %)))
+                                         namespaces))))
+
+;; OLD:
+#_(defn tab->ns!
+  [db tab-key & namespaces]
+  (tab->transducer! db tab-key (filter #(contains?
+                                         (set namespaces)
+                                         (:ns %)))))
+

 (register-highlighter! *db*)
 (type->color *db* :INFO "lightblue")
 (type->color *db* :ERROR "red")
-(ns*->color *db* "my.ns" "darkred")
+(type->color *db* :TRACE "gray")
+(type->color *db* :WARN "orange")
+;;(ns*->color *db* "my.ns" "darkred")
 (msg->console! *db* :CONSOLE)
-(tab->type! *db* :error :ERROR :WARNING)
+(tab->type! *db* :error :ERROR)
+(tab->type! *db* :errwarn :ERROR :WARN)
+(tab->ns! *db* :my.ns "my.ns")
+(tab->ns*! *db* :my.ns* "my.ns")
 ;; Or if we want multiple:
 ;; (tab->transducer! *db* :my.ns (filter #(self-or-parent? "my.ns" (:ns %))))

+(log! *db* ::WARN :hi :there)

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Log some:
@@ -868,7 +898,7 @@
      ;;(l i)
      (recur (+ i 1)))))

-;; Dered me to generate logs and test freezing
+;; Deref me to generate logs and test freezing
 ;; @gen-logs

@@ -879,6 +909,8 @@
 (let [lg (logger ::ERROR)]
   (lg {:test "foo"} :bar :haha)
   (lg {:test "twooo"}))
+
+;;(log! )

 (let [lg (logger ::ERROR)]
   (lg {:test "foo"} :bar :haha)


Share replumb special form hint to mancy

--- src/cljs_mancy/core.cljs
+++ src/cljs_mancy/core.cljs
@@ -39,15 +39,19 @@

 (defn- callback!
   "Handle callback. Update ns"
-  [cb]
+  [cb expr]
   (fn [{:keys [error value ns]}]
-    (if error (cb (clj->js error) nil) (do (swap! copts assoc :ns ns) (clj->js value)) )))
+    (if error (cb (clj->js error) nil) (do
+      (swap! copts assoc :ns ns)
+      (cb nil (clj->js { :value value
+                 :special (if (repl-special? expr) (first expr) nil)
+               }))))))

 (defn compile
   [source cb]
   (try
     (let [expr (read-string {:read-cond :allow :features #{:cljs}} source)
-          on-return (callback! cb)]
+          on-return (callback! cb expr)]
       (if (repl-special? expr)
         (process-repl-special @copts on-return {:form expr :ns (:ns @copts) :target "nodejs"} expr)
         (jsc/eval-str*


expose math utils

expose math utils

--- src/cljx/mesh/utils.cljx
+++ src/cljx/mesh/utils.cljx
@@ -1,7 +1,5 @@
 (ns mesh.utils
-  (:require   [garden.core :refer [css]]
-              [mesh.typography :as typography]
-              [mesh.grid :as grid]))
+  (:require   [garden.core :refer [css]]))

 #+cljs
 (defn insert-stylesheet [styles]
@@ -11,3 +9,12 @@
     (.appendChild el node)
     (.appendChild (.-head js/document) el)
     el))
+
+
+ #+clj
+(defn pow [base e]
+  (.pow Math base e))
+
+#+cljs
+(defn pow [base e]
+  (.pow js/Math base e))


Add :discounted-case-improvement-ratios meta-error

--- src/clojush/evaluate.clj
+++ src/clojush/evaluate.clj
@@ -146,6 +146,26 @@
                                 (- 1 (/ (reduce + (mapv * improvements weights))
                                         (reduce + weights))))))
                           ;
+                          (= cat :discounted-case-improvement-ratios)
+                          (if (not (:print-history argmap))
+                            (throw
+                              (Exception.
+                                ":print-history must be true for :discounted-case-improvement-ratios"))
+                            (if (empty? (rest (:history ind)))
+                              (vec (repeat (count (:errors ind)) 1000000))
+                              (vec (for [case-history (apply map list (:history ind))]
+                                     (if (<= (first case-history) error-threshold)
+                                       0
+                                       (let [diffs (mapv (fn [[a b]] (- a b))
+                                                         (partition 2 1 case-history))
+                                             improvements (mapv #(if (neg? %) 1.0 0.0)
+                                                                diffs)
+                                             persistence 0.5
+                                             weights (take (count diffs)
+                                                           (iterate (partial * persistence) 1))]
+                                         (- 1 (/ (reduce + (mapv * improvements weights))
+                                                 (reduce + weights)))))))))
+                          ;
                           (= cat :reproductive-fidelity)
                           (let [g (:genome ind)]
                             (- 1.0
@@ -160,7 +180,7 @@
                                  (produce-child-genome-by-autoconstruction g g argmap)
                                  (produce-child-genome-by-autoconstruction g g argmap))))
                           :else (throw (Exception. (str "Unrecognized meta category: " cat)))))]
-    (doall (map meta-error-fn meta-error-categories))))
+    (vec (flatten (mapv meta-error-fn meta-error-categories)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; evaluate individuals


(PE-2115) Tests for missing service dependencies

--- test/puppetlabs/trapperkeeper/core_test.clj
+++ test/puppetlabs/trapperkeeper/core_test.clj
@@ -232,3 +232,26 @@
       (is (empty? @order))
       (trapperkeeper/shutdown! app)
       (is (= @order [2 1])))))
+
+(deftest dependency-error-handling
+  (testing "missing service dependency throws meaningful message"
+    (let [broken-service (service :broken-service
+                                  {:depends  [[:missing-service f]]
+                                   :provides [unused]}
+                                  {:unused #()})]
+      (is (thrown-with-msg?
+            RuntimeException #"Service ':missing-service' not found"
+            (trapperkeeper/bootstrap* [(broken-service)])))))
+
+  (testing "missing service function throws meaningful message"
+    (let [test-service    (service :test-service
+                                   {:depends  []
+                                    :provides [foo]}
+                                   {:foo #()})
+          broken-service  (service :broken-service
+                                   {:depends  [[:test-service bar]]
+                                    :provides [unused]}
+                                   {:unused #()})]
+      (is (thrown-with-msg?
+            RuntimeException #"Service function 'bar' not found"
+            (trapperkeeper/bootstrap* [(test-service) (broken-service)]))))))


Add some debugging output to the cross streams test.

--- web/test-integration/immutant/web/integ_test.clj
+++ web/test-integration/immutant/web/integ_test.clj
@@ -199,6 +199,7 @@
                                        (deliver done? true))))]
           (swap! clients conj client))))
     (is (deref done? 5000 nil))
+    (println "RESULTS" @results)
     (is (= (->> client-count (range 0) (map str) set)
           (set @results)))
     (doseq [client @clients]


Добавлен parse-boolean

Добавлен parse-boolean

--- radiolamp-6P3S/src/r6p3s/core.cljs
+++ radiolamp-6P3S/src/r6p3s/core.cljs
@@ -79,6 +79,14 @@

 (defn parse-number-or-zero [v]
   (parse-number-or v 0))
+
+
+
+(defn parse-boolean [v]
+  (new js/Boolean v))
+
+
+


cleans up examples

cleans up examples

--- usage.clj
+++ usage.clj
@@ -1,32 +1,33 @@
 (ns usage
   (:require [gyptis.core :refer :all]
-            [gyptis.view :refer [plot!]]
-            [gyptis.vega-templates :as vt]
-            [gyptis.validate :refer [valid?]]
-            [clojure.pprint :refer [pprint]]
+            [gyptis.vega-templates :refer [dodged-bar stacked-bar
+                                           point choropleth line]]
             [clojure.data.json :as json]))

-(def bar-data [{:x "a", :y 5 :facet_y "a" :fill 1}
-               {:x "a", :y 5 :facet_y "a" :fill 2}
-               {:x "b", :y 9 :facet_y "a" :fill 1}
-               {:x "c", :y 2 :facet_y "a" :fill 2}
-               {:x "d", :y 3 :facet_y "c" :fill 2}])
+(def bar-data [{:x "a", :y  1 :fill 1}
+               {:x "a", :y  1 :fill 2}
+               {:x "b", :y  2 :fill 1}
+               {:x "b", :y  3 :fill 2}
+               {:x "c", :y  5 :fill 1}
+               {:x "c", :y  8 :fill 2}
+               {:x "d", :y 13 :fill 1}
+               {:x "d", :y 21 :fill 2}])

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Let's make a bar chart

-(plot (vt/dodged-bar bar-data))
+(plot (dodged-bar bar-data))

 ;; plot every hashmap in `data' as a rectangle. Stacks bars with the same `x' value
-(plot (vt/stacked-bar bar-data))
+(plot (stacked-bar bar-data))

 ;; add labels
-(plot (-> bar-data vt/stacked-bar
+(plot (-> bar-data stacked-bar
           (assoc-in [:axes 0 :title] "letter")
           (assoc-in [:axes 1 :title] "rate")))

 ;; add mouse-over interactions
-(plot (-> bar-data vt/stacked-bar
+(plot (-> bar-data stacked-bar
           (assoc-in [:marks 0 :properties :hover]
                     {:fill {:value "red"}})))

@@ -44,8 +45,7 @@
    {:x (java.util.Date. "Jan 3, 2015"), :y 4 :stroke "b"}
    {:x (java.util.Date. "Jan 4, 2015"), :y 5 :stroke "b"}])

-(plot (-> time-series-data vt/->vg-data vt/line
-          (assoc :width 600)))
+(plot (-> time-series-data line))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Plays well with jdbc
@@ -61,8 +61,9 @@

 (plot (-> (sql/query db ["SELECT fips_county as x, unemploy_rate as y
                           FROM unemployment
-                          ORDER BY unemploy_rate DESC LIMIT 10"])
-          vt/dodged-bar))
+                          ORDER BY unemploy_rate DESC LIMIT 20"])
+          stacked-bar
+          vertical-x-labels))

 (def highest-unemployment-counties
   (sql/query db
@@ -71,11 +72,11 @@
                FROM fips_codes
                INNER JOIN unemployment ON (1000*fips_codes.state_fips + fips_codes.county_fips) = unemployment.fips_county
                WHERE fips_codes.entity_desc='County'
-               ORDER BY y DESC LIMIT 20"]))
+               ORDER BY y DESC LIMIT 25"]))

 ;; counties with highest unemployment rate
 (plot (-> highest-unemployment-counties
-          vt/stacked-bar
+          stacked-bar
           vertical-x-labels))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -83,7 +84,7 @@

 (def county-unemployment-geo
   (sql/query db [(str "SELECT feature as geopath, unemploy_rate as fill from unemployment
-INNER JOIN us_10m ON us_10m.id=unemployment.fips_county")]
+                       INNER JOIN us_10m ON us_10m.id=unemployment.fips_county")]
              :row-fn #(update % :geopath json/read-str)))

-(plot (vt/choropleth county-unemployment-geo))
+(plot (choropleth county-unemployment-geo))


Remove old vertex markers.

Remove old vertex markers.

--- src/constraint/core.cljs
+++ src/constraint/core.cljs
@@ -21,7 +21,6 @@
     ch))

-
 (def triangle-marker
   [:svg:marker
    {:id "Triangle"
@@ -32,21 +31,6 @@
     :markerHeight "3"
     :orient "auto"}
    [:svg:path {:d "M0,0 L 10,5 L0,10 z"}]])
-
-
-(def circle-marker
-  [:svg:marker
-   {:id "Vertex"
-    :refX "2"
-    :refY "2"
-    :markerWidth "5"
-    :markerHeight "5"
-    :orient "auto"}
-   [:svg:circle
-    {:fill "black"
-     :stroke "none"
-     :cx 2 :cy 2
-     :r 2}]])

 (defn make-line-dirs [from to]
@@ -63,9 +47,7 @@
     :stroke (name color)
     :stroke-width "10px"
     :fill "none"
-    ; :marker-start "url(#Vertex)"
     :marker-mid "url(#Triangle)"
-    ; :marker-end "url(#Vertex)"
     }])

 (def color->value {:red 1


Refactor getting click position in move-the-vertex

--- src/constraint/edit.cljs
+++ src/constraint/edit.cljs
@@ -2,13 +2,18 @@
   (:require [constraint.common :refer [edge-id]]))

+(defn where-svg-was-clicked [event]
+  (let [svg-rect (.getBoundingClientRect (dommy.core/sel1 :svg))
+        click-position [(.-clientX event) (.-clientY event)]
+        rect-position [(.-left svg-rect) (.-top svg-rect)]]
+    (map - click-position rect-position)))
+

 (defn move-the-vertex [world-state event]
   (let [moving (:selected world-state)
-        rect (.getBoundingClientRect (dommy.core/sel1 :svg))
-        pos [(- (.-clientX event) (.-left rect))
-             (- (.-clientY event) (.-top rect))]]
-    (update-in world-state [:vertices moving 1] (constantly pos))))
+        position-to-update [:vertices moving 1]
+        where (where-svg-was-clicked event)]
+    (update-in world-state position-to-update (constantly where))))

 (defn get-key [edge-str]
   (->> edge-str


allow nulls in target vector for MSE loss (no gradient)

--- src/cortex/optimise.cljc
+++ src/cortex/optimise.cljc
@@ -171,10 +171,17 @@
 ;; Loss Functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+(defn sub-with-nulls
+  "Subtracts b from 0. Returns 0.0 for elements where b is nil"
+  [a b]
+  (let [a (m/mutable a)]
+    (m/emap! (fn [av bv] (if (number? bv) (- (double av) (double bv)) 0.0))
+             a b)))
+
 (defn mean-squared-error
   "Computes the mean squared error of an activation array and a target array"
   ([activation target]
-    (/ (double (m/esum (m/square (m/sub activation target))))
+    (/ (double (m/esum (m/square (sub-with-nulls activation target))))
        (double (m/ecount activation)))))

 (deftype MSELoss []
@@ -183,8 +190,7 @@
       (mean-squared-error v target))

     (loss-gradient [this v target]
-      (let [r (m/mutable v)]
-        (m/sub! r target)
+      (let [r (sub-with-nulls v target)]
         (m/scale! r (/ 2.0 (double (m/ecount v)))))))

 (defn mse-loss


didn't mean to commit this. breaks on CI.

--- src/dev/demo/worker.cljs
+++ src/dev/demo/worker.cljs
@@ -1,7 +1,6 @@
-(ns demo.worker
-  (:require ["react" :as r]))
+(ns demo.worker)

 ;; this ns in only executed by the worker

-(js/console.log "worker started" (r/createElement "h1" nil "hello world"))
+(js/console.log "worker started")
 (js/postMessage (pr-str (assoc {:x 1} :y 2)))


Better format for defining predicates

Better format for defining predicates

--- src/structural_typing/api/predicates.clj
+++ src/structural_typing/api/predicates.clj
@@ -14,17 +14,30 @@
       lift/stash-defaults
       (lift/replace-explainer explainer)))

+(defn compose-predicate [pred fmt-fn]
+  (->> pred (explain-with fmt-fn)))

-;;; Useful predefined predicates

-(defn must-exist [val]
-  (not (nil? val)))
+;;; Predefined predicates
+
+(def must-exist
+  "False iff a key/path does not exist or has value `nil`."
+  (compose-predicate
+   (comp not nil?)
+   #(format "%s must exist and be non-nil" (path/friendly-path %))))

-(defn member [& args]
-  (letfn [(explainer [raw]
-            (format "%s should be a member of %s; it is `%s`",
-                    (path/friendly-path raw)
-                    (pr-str args)
-                    (pr-str (:leaf-value raw))))]
-    (->> #(some (set args) %)
-         (explain-with explainer))))
+
+(defn member
+  "Produce a predicate that's false when applied to a value not a member of `args`.
+
+        ( (member 2 3 5 7) 4) => false
+        (type/named! :small-primes {:n (member 2 3 5 7)})
+"
+  [& args]
+  (compose-predicate
+   #(some (set args) %)
+   #(format "%s should be a member of %s; it is `%s`",
+            (path/friendly-path %)
+            (pr-str args)
+            (pr-str (:leaf-value %)))))
+


adds ability to run optimizer queries at intervals during simulation (#1004)

--- scheduler/test/cook/test/simulator.clj
+++ scheduler/test/cook/test/simulator.clj
@@ -10,7 +10,7 @@
             [clojure.data.csv :as csv]
             [clojure.data.json :as json]
             [clojure.java.io :as io]
-            [clojure.tools.cli :refer  [parse-opts]]
+            [clojure.tools.cli :refer [parse-opts]]
             [clojure.tools.logging :as log]
             [clojure.walk :refer (keywordize-keys)]
             [com.rpl.specter :refer (transform ALL MAP-VALS MAP-KEYS select FIRST)]
@@ -24,7 +24,8 @@
             [plumbing.core :refer (map-vals map-keys map-from-vals)])
   (:import org.apache.curator.framework.CuratorFrameworkFactory
            org.apache.curator.framework.state.ConnectionStateListener
-           org.apache.curator.retry.BoundedExponentialBackoffRetry)
+           org.apache.curator.retry.BoundedExponentialBackoffRetry
+           org.joda.time.DateTimeUtils)
   (:gen-class))

 ;;; This namespace contains a simulator for cook scheduler that accepts a trace file
@@ -159,34 +160,34 @@
   (let [job (:job/_instance task)
         resources (util/job-ent->resources job)
         group (first (:group/_job job))]
-    {:job_id  (str (:job/uuid job))
-     :instance_id  (:instance/task-id task)
-     :submit_time_ms  (.getTime (:job/submit-time job))
-     :mesos_start_time_ms  (if (:instance/mesos-start-time task)
-                             (.getTime (:instance/mesos-start-time task))
-                             -1)
+    {:job_id (str (:job/uuid job))
+     :instance_id (:instance/task-id task)
+     :submit_time_ms (.getTime (:job/submit-time job))
+     :mesos_start_time_ms (if (:instance/mesos-start-time task)
+                            (.getTime (:instance/mesos-start-time task))
+                            -1)
      :group_id (:group/uuid group)
-     :start_time_ms  (.getTime (:instance/start-time task))
-     :end_time_ms  (.getTime (or (:instance/end-time task) (tc/to-date (t/now))))
+     :start_time_ms (.getTime (:instance/start-time task))
+     :end_time_ms (.getTime (or (:instance/end-time task) (tc/to-date (t/now))))
      :expected_run_time (:job/expected-runtime job)
-     :status  (:instance/status task)
-     :hostname  (:instance/hostname task)
-     :slave_id  (:instance/slave-id task)
-     :reason  (or (when (= (:instance/status task) :instance.status/failed)
-                    (:reason/string (:instance/reason task)))
-                  "")
-     :user  (:job/user job)
-     :mem  (or (:mem resources) -1)
-     :cpus  (or (:cpus resources) -1)
-     :job_name  (or (:job/name job) "")
-     :requested_run_time  (->> (:job/label job)
-                               (filter #(= (:label/key %) "JOB-RUNTIME"))
-                               first
-                               :label/value)
-     :requested_status  (->> (:job/label job)
-                             (filter #(= (:label/key %) "JOB-STATUS"))
-                             first
-                             :label/value)}))
+     :status (:instance/status task)
+     :hostname (:instance/hostname task)
+     :slave_id (:instance/slave-id task)
+     :reason (or (when (= (:instance/status task) :instance.status/failed)
+                   (:reason/string (:instance/reason task)))
+                 "")
+     :user (:job/user job)
+     :mem (or (:mem resources) -1)
+     :cpus (or (:cpus resources) -1)
+     :job_name (or (:job/name job) "")
+     :requested_run_time (->> (:job/label job)
+                              (filter #(= (:label/key %) "JOB-RUNTIME"))
+                              first
+                              :label/value)
+     :requested_status (->> (:job/label job)
+                            (filter #(= (:label/key %) "JOB-STATUS"))
+                            first
+                            :label/value)}))

 (defn dump-jobs-to-csv
   "Given a mesos db, dump a csv with a row per task"
@@ -233,7 +234,7 @@
           group (when group-uuid
                   [{:db/id (d/tempid :db.part/user)
                     :group/uuid (java.util.UUID/fromString group-uuid)
-                    :group/job job-id }])
+                    :group/job job-id}])
           txn [runtime-env
                status-env
                commit-latch
@@ -306,6 +307,7 @@
                                               :complete-trigger-chan complete-trigger-chan
                                               :state-atom state-atom))
         config (merge {:shares [{:user "default" :mem 4000.0 :cpus 4.0 :gpus 1.0}]
+                       :time-ms-between-optimizer-calls (-> 3 t/minutes t/in-millis)
                        :time-ms-between-rebalancing (-> 30 t/minutes t/in-millis)}
                       config)
         opt-config {:host-feed {:create-fn 'cook.mesos.optimizer/create-dummy-host-feed
@@ -322,22 +324,26 @@
                                                  :progress-updater-trigger-chan (async/chan)
                                                  :straggler-trigger-chan (async/chan)
                                                  :lingering-task-trigger-chan (async/chan)
-                                                 :cancelled-task-trigger-chan (async/chan)}})]
+                                                 :cancelled-task-trigger-chan (async/chan)}})
+        {:keys [time-ms-between-optimizer-calls time-ms-between-rebalancing]} config]
     ;; We are setting time to enable us to have deterministic runs
     ;; of the simulator while hooking into the scheduler as non-invasively
     ;; as possible. A longer explanation can be found in the simulator dev docs.
-    (org.joda.time.DateTimeUtils/setCurrentMillisFixed simulation-time)
+    (DateTimeUtils/setCurrentMillisFixed simulation-time)
     (log/info "Starting simulation.")
-    (with-cook-scheduler mesos-datomic-conn make-mesos-driver-fn
+    (with-cook-scheduler
+      mesos-datomic-conn
+      make-mesos-driver-fn
       scheduler-config
       (try
         (doseq [{:keys [user mem cpus gpus]} (:shares config)]
           (share/set-share! mesos-datomic-conn user nil "simulation" :mem mem :cpus cpus :gpus gpus))
         (loop [trace trace
                simulation-time simulation-time
-               time-ms-since-last-rebalancer 0]
-
-          (org.joda.time.DateTimeUtils/setCurrentMillisFixed simulation-time)
+               time-ms-since-last-rebalancer 0
+               time-ms-since-last-optimizer-call 0]
+
+          (DateTimeUtils/setCurrentMillisFixed simulation-time)

           (let [start-ms (System/currentTimeMillis)
                 submission-batch (take-while #(<= (:submit-time-ms %) simulation-time) trace)
@@ -357,79 +363,81 @@
             (log/info "Submitting batch")
             ;; Submit new jobs
             (doseq [job submission-batch]
-              (org.joda.time.DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
+              (DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
               (submit-job mesos-datomic-conn job))
             ;; Ensure peer has acknowledged the new jobs
             (when (seq submission-batch)
               (poll-until #(d/q '[:find ?j .
-                                      :in $ ?t
-                                      :where
-                                      [?j :job/submit-time ?t]]
-                                    (d/db mesos-datomic-conn)
-                                    ;; This relies on
-                                    ;; 1. Time is controlled
-                                    ;; 2. We increment time for each job submitted
-                                    (tc/to-date (t/now)))
-                        50
-                        60000))
+                                  :in $ ?t
+                                  :where
+                                  [?j :job/submit-time ?t]]
+                                (d/db mesos-datomic-conn)
+                                ;; This relies on
+                                ;; 1. Time is controlled
+                                ;; 2. We increment time for each job submitted
+                                (tc/to-date (t/now)))
+                          50
+                          60000))
             (log/info "Batch submission complete")

             ;; Request for jobs that are complete to have cook be notified
             (log/info "Send completion status to scheduler")
-            (org.joda.time.DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
+            (DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
             (async/>!! complete-trigger-chan flush-complete-chan)
             (async/<!! flush-complete-chan)

             ;; Ensure mesos and cook state of running jobs matches
             (poll-until #(= (set (map (comp str :instance/task-id)
-                                     (util/get-running-task-ents (d/db mesos-datomic-conn))))
+                                      (util/get-running-task-ents (d/db mesos-datomic-conn))))
                             (set (map str
-                                     (keys (:task-id->task @state-atom)))))
-                       50
-                       60000
-                       #(let [cook-tasks (set (map (comp str :instance/task-id)
-                                                   (util/get-running-task-ents (d/db mesos-datomic-conn))))
-                              mesos-tasks (set (map str
-                                                    (keys (:task-id->task @state-atom))))]
-                          {:running-tasks-ents (count cook-tasks)
-                           :tasks-in-mesos (count mesos-tasks)
-                           :cook-minus-mesos (count (clojure.set/difference cook-tasks mesos-tasks))
-                           :mesos-minus-cook (count (clojure.set/difference mesos-tasks cook-tasks))})
-                       )
+                                      (keys (:task-id->task @state-atom)))))
+                        50
+                        60000
+                        #(let [cook-tasks (set (map (comp str :instance/task-id)
+                                                    (util/get-running-task-ents (d/db mesos-datomic-conn))))
+                               mesos-tasks (set (map str
+                                                     (keys (:task-id->task @state-atom))))]
+                           {:running-tasks-ents (count cook-tasks)
+                            :tasks-in-mesos (count mesos-tasks)
+                            :cook-minus-mesos (count (clojure.set/difference cook-tasks mesos-tasks))
+                            :mesos-minus-cook (count (clojure.set/difference mesos-tasks cook-tasks))}))
             (log/info "Completion statuses sent")

             ;; Request rank occurs
             (log/info "Starting rank")
-            (org.joda.time.DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
+            (DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
             (async/>!! ranker-trigger-chan rank-complete-chan)
             (async/<!! rank-complete-chan)
             (log/info "Rank complete")

-            (async/>!! optimizer-trigger-chan optimizer-complete-chan)
-            (async/<!! optimizer-complete-chan)
+            (when (> time-ms-since-last-optimizer-call time-ms-between-optimizer-calls)
+              (log/info "Starting optimizer")
+              (async/>!! optimizer-trigger-chan optimizer-complete-chan)
+              (async/<!! optimizer-complete-chan)
+              (log/info "Optimizer complete"))

             ;; Match
             (log/info "Starting match")
-            (org.joda.time.DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
+            (DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
             (async/>!! offer-trigger-chan send-offers-complete-chan)
             (async/<!! send-offers-complete-chan)
             (async/>!! matcher-trigger-chan match-complete-chan)
             (async/<!! match-complete-chan)
             ;; Ensure the launch has been processed by mesos
             (poll-until #(every? :instance/mesos-start-time
-                                (util/get-running-task-ents (d/db mesos-datomic-conn)))
+                                 (util/get-running-task-ents (d/db mesos-datomic-conn)))
                         50
                         60000)
             (log/info "Match complete")

             ;; Rebalance
-            (when (> time-ms-since-last-rebalancer (:time-ms-between-rebalancing config))
+            (when (> time-ms-since-last-rebalancer time-ms-between-rebalancing)
               (log/info "Starting rebalance")
-              (org.joda.time.DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
+              (DateTimeUtils/setCurrentMillisFixed (inc (.getTime (tc/to-date (t/now)))))
               (async/>!! rebalancer-trigger-chan rebalancer-complete-chan)
               (async/<!! rebalancer-complete-chan)
               (log/info "Rebalance complete"))
-
+
             ;; Periodically perform full gc under hypothesis that holding onto
             ;; lot of memory is causing problems
             (when (> (rand) 0.9)
@@ -439,9 +447,12 @@
             (when (seq trace)
               (recur (drop (count submission-batch) trace)
                      (+ simulation-time cycle-step-ms)
-                     (if (> time-ms-since-last-rebalancer (:time-ms-between-rebalancing config))
+                     (if (> time-ms-since-last-rebalancer time-ms-between-rebalancing)
                        0
-                       (+ time-ms-since-last-rebalancer cycle-step-ms))))))
+                       (+ time-ms-since-last-rebalancer cycle-step-ms))
+                     (if (> time-ms-since-last-optimizer-call time-ms-between-optimizer-calls)
+                       0
+                       (+ time-ms-since-last-optimizer-call cycle-step-ms))))))
         (println "count of jobs submitted " (count (d/q '[:find ?e
                                                           :where
                                                           [?e :job/uuid _]]
@@ -487,11 +498,11 @@
       (System/exit 0))
     (when (not= (count required-options) (count (select-keys options required-options)))
       (println "Missing required options: "
-             (->> options
-                  keys
-                  set
-                  (clojure.set/difference required-options)
-                  (map name)))
+               (->> options
+                    keys
+                    set
+                    (clojure.set/difference required-options)
+                    (map name)))
       (println (usage summary))
       (System/exit 1))
     (log/info "Pulling input files")
@@ -518,7 +529,7 @@
   "Returns a job that can be used in the trace"
   [run-time-ms submit-time-ms &
    {:keys [user uuid command ncpus memory name retry-count max-runtime priority job-state submit-time custom-executor? gpus group committed?
-           disable-mea-culpa-retries ]
+           disable-mea-culpa-retries]
     :or {user (System/getProperty "user.name")
          uuid (d/squuid)
          committed? true


fixing redirect after completion

fixing redirect after completion

--- src/ardoq/swagger/api.clj
+++ src/ardoq/swagger/api.clj
@@ -86,22 +86,26 @@
              headers :headers
              {:strs [org token]} :query-params :as request}
         {:status 200
-         :body (tpl/render-resource "form.html" {:org-set (boolean org) :org org
-                                          :token-set (boolean token)
-                                          :token token})
+         :body (tpl/render-resource "form.html" {:org-set (boolean org)
+                                                 :org org
+                                                 :token-set (boolean token)
+                                                 :token token})
          :headers {"Content-Type" "text/html"}
-         :session (assoc session :referer (if (get headers "referer") (str "http://" (first (rest (rest (.split (get headers "referer") "/"))))) ""))})
-   (POST "/import" {{:strs [url token org wsname headers swag ignorer notifier] :as params} :form-params session :session :as request}
-         (let [ardoq-url (or (:referer session) (:base-url config))
+         :session (-> session
+                      (assoc :referer-host (some->> (get headers "referer") (re-find #"^https?://[^/]+")))
+                      (assoc :x-forwarded-host (some->> (get headers "X-Forwarded-Host") (re-find #"^https?://[^/]+"))))})
+   (POST "/import" {{:strs [url token org wsname headers swag ignorer notifier ardoq-base-url] :as params} :form-params session :session :as request}
+         (let [ardoq-url (or ardoq-base-url (:x-forwarded-host session) (:referer-host session) (:base-url config))
                client (c/client {:url ardoq-url
                                  :org org
                                  :token token})]
+           (prn ardoq-base-url (:x-forwarded-host session) (:referer-host session) (:base-url config))
            (try
              (let [wid (get-spec client url wsname (read-headers headers) swag ignorer)]
                (socket-close)
                (when notifier
                  (send-success-email! wid org session client))
-               (str (:referer session) "/app/view/workspace/" wid "?org=" org))
+               (str ardoq-url "/app/view/workspace/" wid))
              (catch com.fasterxml.jackson.core.JsonParseException e
                (.printStackTrace e)
                (when notifier