Extend computation of updated mapping.

Extend computation of updated mapping.

--- src/dsbdp/local_dpp_self_adaptivity.clj
+++ src/dsbdp/local_dpp_self_adaptivity.clj
@@ -93,12 +93,41 @@

 (defn create-mapping-updater
   []
-  (fn [orig-mapping drop-det-vec]
-    (let [fn-drops (subvec drop-det-vec 0 (dec (count drop-det-vec)))]
-    (cond
-      (every? #(= false %) fn-drops) orig-mapping
-      :default nil
-      ))
-    )
+  (let [limit-reached (atom #{})]
+    (fn [orig-mapping drop-det-vec]
+      (let [fn-drops (subvec drop-det-vec 0 (dec (count drop-det-vec)))
+            drop-indices (get-drop-indices drop-det-vec)
+            last-drop (last drop-indices)
+            non-drop-indices (get-non-drop-indices drop-det-vec)
+            last-non-drop (last non-drop-indices)]
+      (cond
+        (every? #(= false %) fn-drops)
+          orig-mapping
+        (> last-drop last-non-drop)
+          nil
+        (< last-drop last-non-drop)
+          (let [available (- last-non-drop last-drop)
+                incremented-mapping (reduce-kv
+                                      (fn [o k v]
+                                        (if (> k last-drop)
+                                          (conj o (inc v))
+                                          (conj o v)))
+                                      []
+                                      orig-mapping)]
+            (loop [av available idx 0 m incremented-mapping]
+              (if (> av 1)
+                (recur
+                  (dec av)
+                  (if (< (inc idx) (count drop-indices))
+                    (inc idx)
+                    0)
+                  (update m (drop-indices idx) dec))
+                m
+                )
+              )
+            )
+        :default nil
+        ))
+    ))
   )


put garden css in resources/dev

put garden css in resources/dev

--- src/leiningen/new/reagent_liveedit/project.clj
+++ src/leiningen/new/reagent_liveedit/project.clj
@@ -83,12 +83,12 @@
   :garden {:builds [{:id "site"
                      :source-paths ["src/styles"]
                      :stylesheet {{ns-name}}.styles.site/site
-                     :compiler {:output-to "resources/public/css/site.css"
+                     :compiler {:output-to "resources/dev/css/site.css"
                                 :pretty-print? true}}
                     {:id "dev"
                      :source-paths ["src/styles"]
                      :stylesheet {{ns-name}}.styles.dev/dev
-                     :compiler {:output-to "resources/public/css/dev.css"
+                     :compiler {:output-to "resources/dev/css/dev.css"
                                 :pretty-print? true}}]}

   :cljsbuild {:builds {:app {:source-paths ["src/cljs"]


Add api/start to start system as library

--- src/overseer/api.clj
+++ src/overseer/api.clj
@@ -2,7 +2,13 @@
   "User-facing core API"
   (:require [datomic.api :as d]
             [clojure.set :as set]
-            [overseer.core :as core]))
+            (overseer
+              [core :as core]
+              [system :as system])))
+
+(def start
+  "Alias in order to start the system as a library"
+  system/start)

 (defn ->graph-txn
   "Entry point to add assert a sequence of jobs into the system.


Naming with ns

Naming with ns

--- src/freecoin/views/transaction_form.clj
+++ src/freecoin/views/transaction_form.clj
@@ -52,7 +52,7 @@
                    :method "POST"}
             [:input {:name "__anti-forgery-token"
                      :type "hidden"
-                     :value (get-in ctx [:request :session "__anti-forgery-token"])}]
+                     :value (get-in ctx [:request :session :ring.middleware.anti-forgery/anti-forgery-token])}]
             [:input {:name "recipient"
                      :type "hidden"
                      :value email}]


a plausible fix to faq back button issue

--- src/prais2/main.cljs
+++ src/prais2/main.cljs
@@ -356,7 +356,8 @@
               (prn faq-ref)
               (let [[sec id] faq-ref]
                 (do (prn "nav to faq " faq-ref " = " sec "," id)
-                    (.pushState js/history [] "" (routes/faq {:section sec :id id}))
+                    ;(.pushState js/history [] "" (routes/faq {:section sec :id id}))
+                    (.replaceState js/history [] "" (routes/faq {:section sec :id id}))
                     (swap! core/app #(assoc % :page :faqs :section faq-ref))))))

   ;;;


Always use Europe/Amsterdam as default (fix for Travis)

--- src/main/clojure/pdok/featured/json_reader.clj
+++ src/main/clojure/pdok/featured/json_reader.clj
@@ -1,11 +1,12 @@
 (ns pdok.featured.json-reader
   (:require [pdok.featured.feature :refer [nilled as-jts]]
             [cheshire [core :as json] [factory :as jfac] [parse :as jparse]]
-            [clj-time [core :as t] [format :as tf] [coerce :as tc]]
+            [clj-time [format :as tf] [coerce :as tc]]
             [clojure.walk :refer [postwalk]])
   (:import (com.fasterxml.jackson.core JsonFactory JsonFactory$Feature
                                        JsonParser$Feature JsonParser JsonToken)
-           (pdok.featured GeometryAttribute)))
+           (pdok.featured GeometryAttribute)
+           (org.joda.time DateTimeZone)))

 (def ^:private pdok-field-replacements
   {"_action" :action "_collection" :collection "_id" :id "_validity" :validity
@@ -28,7 +29,7 @@
     feature))

 ;; 2015-02-26T15:48:26.578Z
-(def ^{:private true} date-time-formatter (tf/with-zone (tf/formatters :date-time-parser) (t/default-time-zone)))
+(def ^{:private true} date-time-formatter (tf/with-zone (tf/formatters :date-time-parser) (DateTimeZone/forID "Europe/Amsterdam")))

 (def ^{:private true} date-formatter (tf/formatter "yyyy-MM-dd"))


- use standard 'args' naming convention

- use standard 'args' naming convention

--- src/re_com/date.cljs
+++ src/re_com/date.cljs
@@ -201,8 +201,8 @@
    })

 (defn inline-picker
-  [& {:keys [model] :as allprops}]
-  {:pre [(superset? api (keys allprops))]}
+  [& {:keys [model] :as args}]
+  {:pre [(superset? api (keys args))]}
   (let [current (-> (real-value model) first-day-of-the-month reagent/atom)]
     (fn
       [& {:keys [model disabled hide-border on-change] :as properties}]


update ns doc string

update ns doc string

--- src/main/clojure/clojure/spec/alpha.clj
+++ src/main/clojure/clojure/spec/alpha.clj
@@ -6,7 +6,14 @@
 ;   the terms of this license.
 ;   You must not remove this notice, or any other, from this software.

-(ns clojure.spec.alpha
+(ns
+ ^{:doc "The spec library specifies the structure of data or functions and provides
+  operations to validate, conform, explain, describe, and generate data based on
+  the specs.
+
+  Rationale: https://clojure.org/about/spec
+  Guide: https://clojure.org/guides/spec"}
+  clojure.spec.alpha
   (:refer-clojure :exclude [+ * and assert or cat def keys merge])
   (:require [clojure.walk :as walk]
             [clojure.spec.gen.alpha :as gen]


get all subvectors

get all subvectors

--- src/sandbox/lz77.clj
+++ src/sandbox/lz77.clj
@@ -2,13 +2,16 @@
   (:require [clojure.set :as cset]))

-(defn expand [the-vector [distance length]]
-  (->> (take-last distance the-vector)
+(defn expand [xs [distance length]]
+  (->> (take-last distance xs)
        (cycle)
        (take length)))

-(defn un-LZ77 [bites]
+(defn un-LZ77 [xs]
   (reduce #(if-not (vector? %2)
              (conj %1 %2)
              (into %1 (expand %1 %2)))
-          [] bites))
+          [] xs))
+
+(defn all-subvecs [xs]
+  (mapcat #(partition % 1 xs) (range 1 (count xs))))


Implemented smart quoting in auto-paren plugin.

--- src/lt/plugins/auto_paren.cljs
+++ src/lt/plugins/auto_paren.cljs
@@ -2,6 +2,7 @@
   (:require [lt.object :as object]
             [lt.objs.command :as cmd]
             [lt.objs.editor :as editor]
+            [lt.objs.editor.pool :as pool]
             [lt.objs.context :as ctx]
             [lt.objs.keyboard :refer [passthrough]])
   (:require-macros [lt.macros :refer [behavior]]))
@@ -30,11 +31,14 @@
 (behavior ::open-pair
           :triggers #{:open-pair!}
           :reaction (fn [this ch]
-                      (if (re-seq word-char (get-char this 1))
-                        (editor/insert-at-cursor this ch)
-                        (do
-                          (editor/insert-at-cursor this (str ch (pairs ch)))
-                          (move-cursor this -1)))))
+                      (let [current-selection (editor/selection this)]
+                        (if-not (= current-selection "")
+                          (editor/replace-selection this (str ch current-selection (pairs ch)))
+                          (if (re-seq word-char (get-char this 1))
+                            (editor/insert-at-cursor this ch)
+                            (do
+                              (editor/insert-at-cursor this (str ch (pairs ch)))
+                              (move-cursor this -1)))))))

 (behavior ::close-pair
           :triggers #{:close-pair!}
@@ -47,13 +51,16 @@
 (behavior ::repeat-pair
           :triggers #{:repeat-pair!}
           :reaction (fn [this ch]
-                      (cond
-                       (= ch (get-char this 1)) (move-cursor this 1)
-                       (re-seq word-char (get-char this 1)) (editor/insert-at-cursor this ch)
-                       (re-seq word-char (get-char this -1)) (editor/insert-at-cursor this ch)
-                       :else (do
-                               (editor/insert-at-cursor this (str ch ch))
-                               (move-cursor this -1)))))
+                      (let [current-selection (editor/selection this)]
+                        (if-not (= something-selected "")
+                          (editor/replace-selection this (str ch current-selection ch))
+                          (cond
+                           (= ch (get-char this 1)) (move-cursor this 1)
+                           (re-seq word-char (get-char this 1)) (editor/insert-at-cursor this ch)
+                           (re-seq word-char (get-char this -1)) (editor/insert-at-cursor this ch)
+                           :else (do
+                                   (editor/insert-at-cursor this (str ch ch))
+                                   (move-cursor this -1)))))))

 (behavior ::try-remove-pair
           :triggers #{:backspace!}


Compile flow conditions for from and to all

--- src/onyx/flow_conditions/fc_compile.clj
+++ src/onyx/flow_conditions/fc_compile.clj
@@ -37,8 +37,9 @@
 (defn only-relevant-branches [flow-conditions workflow task]
   (filter #(or (= (:flow/from %) task)
                (and (= (:flow/from %) :all)
-                    (subset? (into #{} (:flow/to %))
-                             (into #{} (egress-tasks workflow task)))))
+                    (or (= (:flow/to %) :all)
+                        (subset? (into #{} (:flow/to %))
+                                 (into #{} (egress-tasks workflow task))))))
           flow-conditions))

 (defn compile-flow-conditions [flow-conditions workflow task-name f]


Remove commented code.

Remove commented code.

--- src/uxbox/main/ui/workspace/base.cljs
+++ src/uxbox/main/ui/workspace/base.cljs
@@ -32,8 +32,6 @@
 (def page-ref
   (letfn [(getter [state]
             (let [page (get-in state [:workspace :page])]
-              ;; (println "page-l$getter" page)
-
               (get-in state [:pages-by-id page])))]
     (-> (l/lens getter)
         (l/derive st/state))))


Add some interactions to group entry on layers toolbox.

--- src/uxbox/ui/workspace/toolboxes.cljs
+++ src/uxbox/ui/workspace/toolboxes.cljs
@@ -159,31 +159,46 @@

 (defn- layer-group-render
   [own item selected]
-  (let [selected? (contains? selected (:id item))
+  (let [local (:rum/local own)
+        selected? (contains? selected (:id item))
+        open? (:open @local true)
+        select #(select-shape selected item %)
+        toggle-visibility #(toggle-visibility selected item %)
+        toggle-blocking #(toggle-blocking item %)
+        toggle-open (fn [event]
+                      (dom/stop-propagation event)
+                      (swap! local assoc :open (not open?)))
         shapes-by-id (rum/react shapes-by-id)]
     (html
-     [:li.group.open
-      [:div.element-list-body {:class (when selected? "selected")}
+     [:li.group {:class (when open? "open")}
+      [:div.element-list-body {:class (when selected? "selected")
+                               :on-click select}
        [:div.element-actions
-        [:div.toggle-element i/eye]
-        [:div.block-element i/lock]
+        [:div.toggle-element {:class (when-not (:hidden item) "selected")
+                              :on-click toggle-visibility}
+         i/eye]
+        [:div.block-element {:class (when (:blocked item) "selected")
+                             :on-click toggle-blocking}
+         i/lock]
         [:div.chain-element i/chain]]
        [:div.element-icon i/folder]
-       [:span "Opened group"]
-       [:span.toggle-content i/arrow-slide]]
-      [:ul
-       (for [shape (map #(get shapes-by-id %) (:items item))
-             :let [key (str (:id shape))]]
-         ;; TODO: make polymorphic
-         (case (:type shape)
-           :builtin/icon (rum/with-key (layer-element shape selected) key)
-           :builtin/group (rum/with-key (layer-group shape selected) key)))]])))
+       [:span (:name item "Unnamed group")]
+       [:span.toggle-content {:on-click toggle-open}
+        i/arrow-slide]]
+      (if open?
+        [:ul
+         (for [shape (map #(get shapes-by-id %) (:items item))
+               :let [key (str (:id shape))]]
+           ;; TODO: make polymorphic
+           (case (:type shape)
+             :builtin/icon (rum/with-key (layer-element shape selected) key)
+             :builtin/group (rum/with-key (layer-group shape selected) key)))])])))

 (def ^:static ^:private layer-group
   (mx/component
    {:render layer-group-render
     :name "layer-group"
-    :mixins [mx/static rum/reactive]}))
+    :mixins [mx/static rum/reactive (mx/local)]}))

 (defn layers-render
   [own]


faster spec boolean validation

faster spec boolean validation

--- src/validation_benchmark/lib/spec.clj
+++ src/validation_benchmark/lib/spec.clj
@@ -6,7 +6,7 @@

 (s/def ::age int?)
 (s/def ::name string?)
-(s/def ::saiyan? (s/or :t true? :f false?))
+(s/def ::saiyan? boolean?)
 (s/def ::keyword-set (s/every keyword :kind set?))
 (s/def ::nilable-saiyan? (s/nilable ::saiyan?))
 (s/def ::nilable-number (s/nilable number?))


remove unfriendly test

remove unfriendly test

--- test/com/billpiel/sayid/core_test.clj
+++ test/com/billpiel/sayid/core_test.clj
@@ -186,15 +186,6 @@
       (t/testing "; throw cause"
         (t/is (= (-> trace :children first :throw :cause)
                  "Exception from func-throws: :a")))
-
-      (t/testing "; throw via"
-        (t/is (= (-> trace :children first :throw :via first)
-                 {:at {:class-name "com.billpiel.sayid.test_ns1$func_throws"
-                       :file-name "test_ns1.clj"
-                       :line-number 14
-                       :method-name "invoke"}
-                  :message "Exception from func-throws: :a"
-                  :type java.lang.Exception})))

       (t/testing "; first child"
         (t/is (= (-> trace


Revert ZK port in test

Revert ZK port in test

--- test/onyx/metrics/throughput_test.clj
+++ test/onyx/metrics/throughput_test.clj
@@ -11,13 +11,13 @@
 (def id (java.util.UUID/randomUUID))

 (def env-config
-  {:zookeeper/address "127.0.0.1:22181"
+  {:zookeeper/address "127.0.0.1:2188"
    :zookeeper/server? true
    :zookeeper.server/port 2188
    :onyx/id id})

 (def peer-config
-  {:zookeeper/address "127.0.0.1:22181"
+  {:zookeeper/address "127.0.0.1:2188"
    :onyx/id id
    :onyx.peer/job-scheduler :onyx.job-scheduler/greedy
    :onyx.messaging/impl :aeron


Improve test runner by formatting and coloring favicon

--- env/test/test_runner.cljs
+++ env/test/test_runner.cljs
@@ -1,11 +1,47 @@
 (ns gigrig.test-runner
   (:require [cljs.test :as test :include-macros true :refer [report]]
             [devtools.core :as devtools]
+            [goog.string :as str]
+            [goog.string.format]
             [gigrig.tests-to-run]))

 (enable-console-print!)
 (devtools/install! [:custom-formatters :sanity-hints])

+(defn color-favicon-data-url
+  "Takes a color and returns a 16x16 data url of the color"
+  [color]
+  (let [cvs (.createElement js/document "canvas")]
+    (set! (.-width cvs) 16)
+    (set! (.-height cvs) 16)
+    (let [ctx (.getContext cvs "2d")]
+      (set! (.-fillStyle ctx) color)
+      (.fillRect ctx 0 0 16 16))
+    (.toDataURL cvs)))
+
+(defn change-favicon-to-color
+  "Changes the tabs favicon to the given color"
+  [color]
+  (let [icon (.getElementById js/document "favicon")]
+    (set! (.-href icon) (color-favicon-data-url color))))
+
+(defn log
+  "Logs any text to the console with the given color"
+  [{:keys [color]} & args]
+  (.log js/console (apply str "%c" args)
+        (str "color: " color "; font-weight: bold")))
+
+(defmethod report [::test/default :summary] [{:keys [fail error test pass]}]
+  (let [failure (< 0 (+ fail error))
+        color (if failure "#d00" "#0d0")]
+    (log {:color "blue"}
+         (str/format "Ran %d tests containing %d assertions" test (+ pass fail error)))
+    (log {:color color}
+         (str/format "%d failures, %d errors" fail error))
+    (change-favicon-to-color color)))
+
+(.clear js/console)
+
 (test/run-all-tests #"gigrig.*-test")

 (.groupCollapsed js/console "Figwheel Information")


Update :require formatting in MsgpackSerde

--- src/rads/kafka/transit/MsgpackSerde.clj
+++ src/rads/kafka/transit/MsgpackSerde.clj
@@ -1,6 +1,7 @@
 (ns rads.kafka.transit.MsgpackSerde
-  (:require [franzy.serialization.transit.serializers :as serializers]
-            [franzy.serialization.transit.deserializers :as deserializers])
+  (:require
+    [franzy.serialization.transit.serializers :as serializers]
+    [franzy.serialization.transit.deserializers :as deserializers])
   (:gen-class
     :implements [org.apache.kafka.common.serialization.Serde]
     :constructors {[] []}))


Client-API's max number of resultsis configurable.

--- src/ruuvi_server/database/event_dao.clj
+++ src/ruuvi_server/database/event_dao.clj
@@ -2,6 +2,7 @@
   (:use korma.db)
   (:use korma.core)
   (:use ruuvi-server.database.entities)
+  (:require [ruuvi-server.configuration :as conf])
   (:use [clojure.tools.logging :only (debug info warn error)])
   (:require [ruuvi-server.util :as util])
   (:import org.joda.time.DateTime)
@@ -75,7 +76,7 @@
         store-start (to-sql-timestamp (:storeTimeStart criteria))
         store-end (to-sql-timestamp (:storeTimeEnd criteria))
         tracker-ids (:trackerIds criteria)
-        max-result-count 50
+        max-result-count (:max-search-results (:client-api (conf/*config*)))
         max-results (:maxResults criteria max-result-count)
         result-limit (min max-result-count max-results)


Added arrow to UI partial debugger

Added arrow to UI partial debugger

--- src/webapp/framework/client/components/debugger_main.cljs
+++ src/webapp/framework/client/components/debugger_main.cljs
@@ -339,8 +339,43 @@
                               (do
                                 (if (=  debug-id (-> debug-ui-state :pos))
                                   (om/root
-                                   (get (:react-components-fns @debugger-ui)
-                                        (str component-name))
+                                   (fn [ partial-state  partial-owner ]
+                                     (reify
+                                       om/IRender
+                                       ;---------
+                                       (render
+                                        [state]
+
+                                        (dom/div #js {:style #js {:paddingTop "25px"}}
+                                                 (om/build
+                                                  (get (:react-components-fns @debugger-ui)
+                                                       (str component-name))
+                                                  partial-state)
+                                                 (dom/svg #js {:style #js {:width "40" :height "40"}}
+                                                          (dom/line #js {:x1 "0"
+                                                                           :y1 "20"
+                                                                           :x2  "21"
+                                                                           :y2  "0"
+                                                                           :stroke "black"
+                                                                           :strokeWidth "4"
+                                                                           :fill "black"} )
+                                                          (dom/line #js {:x1 "19"
+                                                                           :y1 "0"
+                                                                           :x2  "40"
+                                                                           :y2  "20"
+                                                                           :stroke "black"
+                                                                           :strokeWidth "4"
+                                                                           :fill "black"} )
+                                                          (dom/line #js {:x1 "20"
+                                                                           :y1 "0"
+                                                                           :x2  "20"
+                                                                           :y2  "40"
+                                                                           :stroke "black"
+                                                                           :strokeWidth "4"
+                                                                           :fill "black"} )
+                                                          )
+                                                 ))))
+
                                    (atom component-data)
                                    {:target (js/document.getElementById "debugger_ui_preview")}))


replaced the current header view with the anonymous-header

--- src-cljs/bitfondue/core.cljs
+++ src-cljs/bitfondue/core.cljs
@@ -102,20 +102,7 @@
 (defn header
   []
   [:nav.navbar.navbar-light.bg-faded
-   [:div.container
-    [:a.navbar-brand (nav-helper "/") "bitfondue"]
-    [:ul.nav.navbar-nav
-     [:li.nav-item
-      [:a.nav-link (nav-helper "/features") "Features"]]
-     [:li.nav-item
-      [:a.nav-link (nav-helper "/pricing") "Pricing"]]
-     [:li.nav-item
-      [:a.nav-link (nav-helper "/about") "About"]]]
-    [:ul.nav.navbar-nav.pull-right
-     [:li.nav-item
-      [:a.nav-link (nav-helper "/login") "Login"]]
-     [:li.nav-item
-      [:a.nav-link (nav-helper "/register") "Register"]]]]])
+   [anonymous-header]])

 (defn footer
   []


Fix typo.

Fix typo.

--- src/oc/storage/representations/media_types.clj
+++ src/oc/storage/representations/media_types.clj
@@ -11,8 +11,6 @@
 (def board-author-media-type "application/vnd.open-company.board.author.v1")
 (def board-viewer-media-type "application/vnd.open-company.board.viewer.v1")
 (def topic-list-media-type "application/vnd.open-company.topic-list.v1+json")
-(def board-author-media-type "application/vnd.open-company.board.author.v1")
-(def board-viewer-media-type "application/vnd.open-company.board.viewer.v1")

 ;; Entry media types
 (def entry-media-type "application/vnd.open-company.entry.v1+json")


fix node-library :exports-fn

fix node-library :exports-fn

--- src/main/shadow/build/targets/node_library.clj
+++ src/main/shadow/build/targets/node_library.clj
@@ -62,7 +62,7 @@

           exports-fn
           [#{(-> exports-fn namespace symbol)}
-           `(~exports)]
+           `(~exports-fn)]

           (map? exports)
           [(->> exports


Redefine all lenses in a way that makes them properly comparable with =

--- src/active/clojure/lens.cljc
+++ src/active/clojure/lens.cljc
@@ -29,28 +29,30 @@

 (defrecord ExplicitLens
     ^{:private true}
-  [yanker shover]
+  [yanker shover args]
   Lens
-  (-yank [lens data] (yanker data))
-  (-shove [lens data v] (shover data v)))
+  (-yank [lens data] (apply yanker data args))
+  (-shove [lens data v] (apply shover data v args)))

 (defn lens
-  "Returns a new lens defined by the given yanker function, which takes a data
-   structure and must return the focused value, and the given shover function
-   which takes a data structure and the new value in the focus."
-  [yank shove]
-  (ExplicitLens. yank shove))
+  "Returns a new lens defined by the given yanker function, which
+  takes a data structure and must return the focused value, and the
+  given shover function which takes a data structure and the new value
+  in the focus. Any additional arguments are passed unchanged to the yank
+  and shove functions."
+  [yank shove & args]
+  (ExplicitLens. yank shove args))
+
+(defn- xmap-yank [data f g & args]
+  (apply f data args))
+(defn- xmap-shove [data v f g & args]
+  (apply g v args))

 (defn xmap
   "Returns a \"view lens\", that transforms a whole data structure
    to something else (f) and back (g)."
-  [f g]
-  (lens f #(g %2)))
-
-(defrecord IdentityLens []
-  Lens
-  (-yank [_ data] data)
-  (-shove [_ data v] v))
+  [f g & args]
+  (apply lens xmap-yank xmap-shove f g args))

 (def
   ^{:doc "Identity lens, that just show a data structure as it is.
@@ -58,10 +60,14 @@
           reacl.lens/>>."}
   id (xmap identity identity))

+(defn- comb-yank [data l1 l2]
+  (yank (yank data l1) l2))
+(defn- comb-shove [data v l1 l2]
+  (shove data l1 (shove (yank data l1) l2 v)))
+
 (defn- >>2
   [l1 l2]
-  (lens (fn [data] (yank (yank data l1) l2))
-        (fn [data v] (shove data l1 (shove (yank data l1) l2 v)))))
+  (lens comb-yank comb-shove l1 l2))

 (defn >>
   "Returns a concatenation of two or more lenses, so that the combination shows the
@@ -75,11 +81,15 @@
       res
       (recur (>>2 res (first lmore)) (rest lmore)))))

+(defn- default-yank [data dflt]
+  (if (nil? data) dflt data))
+(defn- default-shove [v dflt]
+  (if (= dflt v) nil v))
+
 (defn default
-  "Returns a lens that shows nil as the given value, but does not change any other value."
-  [v]
-  (xmap #(if (nil? %) v %)
-        #(if (= v %) nil %)))
+  "Returns a lens that shows nil as the given default value, but does not change any other value."
+  [dflt]
+  (xmap default-yank default-shove dflt))

 (defn- consx [v coll]
   (if (and (nil? v) (empty? coll))
@@ -134,52 +144,71 @@
            %1
            (seq %2))))

+(defn- contains-shove [data mem? v]
+  (if mem?
+    (conj data v)
+    (disj data v)))
+
 (defn contains
   "Returns a lens showing the membership of the given value in a set."
   [v]
-  (lens #(contains? % v)
-        #(if %2
-           (conj %1 v)
-           (disj %1 v))))
+  (lens contains?
+        contains-shove
+        v))

 (def ^{:doc "A lens that views a sequence of pairs as a map."}
   as-map
   (xmap #(into {} %) seq))
+
+(defn- member-shove [data v key not-found]
+  (if (= v not-found)
+    (dissoc data key)
+    (assoc data key v)))

 (defn member
   "Returns a lens showing the value mapped to the given key in a map,
   not-found or nil if key is not present. Note that when not-found (or
   nil) is shoved into the map, the association is removed."
   [key & [not-found]]
-  (lens #(get % key not-found)
-        #(if (= %2 not-found)
-           (dissoc %1 key)
-           (assoc %1 key %2))))
+  (lens get
+        member-shove
+        key not-found))

 (def ^{:doc "A trivial lens that just shows nil over anything, and does never change anything."}
   void
   (lens (constantly nil) (fn [data _] data)))
+
+(defn- is-shove [data is? cmp]
+  (if is?
+    cmp
+    (if (= data cmp)
+      nil
+      data)))

 (defn is
   "Returns a lens showing if a data structure equals the non-nil value v."
   [v]
   (assert (not (nil? v)))
-  (lens #(= % v)
-        #(if %2
-           v
-           (if (= %1 v)
-             nil
-             %1))))
+  (lens =
+        is-shove
+        v))
+
+(defn- mult-yank [data lenses]
+  (map yank
+       data lenses))
+
+(defn- mult-shove [data v lenses]
+  (map shove
+       data lenses v))

 (defn **
   "Return the product of several lenses, which means that each lens is
   held over an element of a collection in the order they appear in the
   argument list."
   [& lenses]
-  (lens (fn [data] (map #(yank %1 %2)
-                       data lenses))
-        (fn [data v] (map #(shove %1 %2 %3)
-                         data lenses v))))
+  (lens mult-yank
+        mult-shove
+        lenses))

 ;; not very general:
 ;; (defn repeated
@@ -190,28 +219,35 @@
 ;;                     v)
 ;;               data))))

+(defn- plus-yank [data lenses]
+  (map yank
+       (repeat data)
+       lenses))
+(defn- plus-shove [data v lenses]
+  (reduce (fn [data [l v]] (shove data l v))
+          data
+          (map vector lenses v)))
+
 (defn ++
   "Returns a lens over some data structure that shows a sequence of
   elements that each of the given lenses show on that. Note that the
   behaviour is undefined if those lenses do not show distrinct parts
   of the data structure."
   [& lenses]
-  (lens (fn [data] (map #(yank %1 %2)
-                       (repeat data)
-                       lenses))
-        (fn [data v] (reduce (fn [data [l v]] (shove data l v))
-                            data
-                            (map vector lenses v)))))
-
-
+  (lens plus-yank
+        plus-shove
+        lenses))
+
+(defn- at-index-shove [coll v n]
+  (let [[front back] (split-at n coll)]
+    (concat front
+            [v]
+            (rest back))))

 (defn at-index
   "Returns a lens that focuses on the value at position n in a sequence.
   The sequence must have >= n elements."
   [n]
-  (lens (fn [coll] (nth coll n))
-        (fn [coll v]
-          (let [[front back] (split-at n coll)]
-            (concat front
-                    [v]
-                    (rest back))))))
+  (lens nth
+        at-index-shove
+        n))


update+assoc is faster than assoc-in in this case (and this is a hot code path)

--- src/asciinema/player/vt.cljc
+++ src/asciinema/player/vt.cljc
@@ -915,7 +915,7 @@
   (let [{{old-state :state} :parser} vt
         [new-state actions] (parse old-state input)]
     (-> vt
-        (assoc-in [:parser :state] new-state)
+        (update :parser assoc :state new-state)
         (execute-actions actions input))))

 (defn feed [vt inputs]


Updated method names.

Updated method names.

--- src/clj/mx/roads/forgotten/blog/social/twitter.clj
+++ src/clj/mx/roads/forgotten/blog/social/twitter.clj
@@ -12,19 +12,19 @@

 (defn get-app-consumer-key
   []
-  (util/read-home-file "~/.twitter/frmx/app-consumer-key"))
+  (util/home-file->str "~/.twitter/frmx/app-consumer-key"))

 (defn get-app-consumer-secret
   []
-  (util/read-home-file "~/.twitter/frmx/app-consumer-secret"))
+  (util/home-file->str "~/.twitter/frmx/app-consumer-secret"))

 (defn get-user-access-token
   []
-  (util/read-home-file "~/.twitter/frmx/user-access-token"))
+  (util/home-file->str "~/.twitter/frmx/user-access-token"))

 (defn get-user-access-token-secret
   []
-  (util/read-home-file "~/.twitter/frmx/user-access-token-secret"))
+  (util/home-file->str "~/.twitter/frmx/user-access-token-secret"))

 (defn get-creds
   []


add request

add request

--- src/ca_recipe/tnywb/core.clj
+++ src/ca_recipe/tnywb/core.clj
@@ -24,3 +24,6 @@
           path (http-request :path)
           handler (request-handlers path)]
       (execute-request filtered-request handler))))
+
+(def request {:path "/greeting" :body "Mike,Joe,John,Steve"})
+


Removed use byte-array statement

Removed use byte-array statement

--- ring-core/src/ring/middleware/multipart_params.clj
+++ ring-core/src/ring/middleware/multipart_params.clj
@@ -1,7 +1,6 @@
 (ns ring.middleware.multipart-params
   "Parse multipart upload into params."
-  (:use [ring.middleware.params :only (assoc-param)]
-        [ring.middleware.multipart-params.byte-array :only (byte-array-store)])
+  (:use [ring.middleware.params :only (assoc-param)])
   (:import [org.apache.commons.fileupload.util Streams]
            [org.apache.commons.fileupload
              RequestContext


Story ID: develop Summary: quick line numbers to help dave pinpoint error

--- src/untangled_spec/reporters/impl/browser.cljs
+++ src/untangled_spec/reporters/impl/browser.cljs
@@ -27,4 +27,6 @@

 (defn stack->trace [st] (parse-stacktrace {} st {} {}))

-(defn ?ø [x] (if (= x "ø") '*nil* x))
+(defn ?ø [x]
+  (if (= x "ø")
+    '*nil* x))


Re-enabled lookup of events tables.

Re-enabled lookup of events tables.

--- src/chronograph/handlers.clj
+++ src/chronograph/handlers.clj
@@ -153,8 +153,8 @@
   [domain]
   :available-media-types ["text/html"]
   :handle-ok (fn [ctx]
-               (let [;events (d/get-domain-events domain)
-                     events [] ; TODO currently replacing events with timelines
+               (let [events (d/get-domain-events domain)
+                     ; events [] ; TODO currently replacing events with timelines
                      timelines (d/get-domain-timelines domain)
                      timeline-dates (apply merge (map #(keys (:timeline %)) timelines))

@@ -199,9 +199,8 @@
   [subdomain]
   :available-media-types ["text/html"]
   :handle-ok (fn [ctx]
-               (let [;events (d/get-subdomain-events subdomain)
-
-                     events [] ; TODO currently replacing events with timelines
+               (let [events (d/get-subdomain-events subdomain)
+                     ; events [] ; TODO currently replacing events with timelines
                      timelines (d/get-subdomain-timelines subdomain)
                      timeline-dates (apply merge (map #(keys (:timeline %)) timelines))


Revert back to not storing actions, mongo can't serialize clojure fns. More work will be needed for this to work.

--- src/circle/backend/build.clj
+++ src/circle/backend/build.clj
@@ -56,7 +56,7 @@

 (def build-dissoc-keys
   ;; Keys on build that shouldn't go into mongo, for whatever reason
-  [:action-results])
+  [:actions :action-results])

 (defn insert! [b]
   (let [return (mongo/insert! build-coll (apply dissoc @b build-dissoc-keys))]


fix template

fix template

--- src/clj/salava/badge/pdf.clj
+++ src/clj/salava/badge/pdf.clj
@@ -120,15 +120,15 @@
                                                                 [:anchor {:target (:issuer_content_url %) :style{:family :times-roman :color [66 100 162]}}  (:issuer_content_url %)]]
                                                                [:paragraph.generic
                                                                 [:chunk.chunk (str (t :badge/IssuerContact ul)": ")] (:issuer_contact %)]
-                                                               (when-not (= "-" (:creator_description %))
-                                                                 [:paragraph.generic
-                                                                  [:chunk.chunk (str (t :badge/CreatorDescription ul)": ")] (:creator_description %)])
-                                                               (when-not (= "-" (:creator_url %))
-                                                                 [:paragraph.generic
-                                                                  [:chunk.chunk (str (t :badge/CreatorWebsite ul)": ")] [:anchor {:target (:creator_url %) :style{:family :times-roman :color [66 100 162]}} (:creator_url %)] "\n"])
-                                                               (when-not (= "-" (:creator_email %))
-                                                                 [:paragraph.generic
-                                                                  [:chunk.chunk (str (t :badge/CreatorContact ul)": ")] (:creator_email %)])
+
+                                                               (when-not (= "-" (and (:creator_description %) (:creator_url %) (:creator_email %) ))
+                                                                 [:paragraph
+                                                                  [:paragraph.generic
+                                                                   [:chunk.chunk (str (t :badge/CreatorDescription ul)": ")] (:creator_description %)]
+                                                                  [:paragraph.generic
+                                                                   [:chunk.chunk (str (t :badge/CreatorWebsite ul)": ")] [:anchor {:target (:creator_url %) :style{:family :times-roman :color [66 100 162]}} (:creator_url %)] "\n"]
+                                                                  [:paragraph.generic
+                                                                   [:chunk.chunk (str (t :badge/CreatorContact ul)": ")] (:creator_email %)]])
                                                                (let [issuer-endorsement (replace-nils (select-issuer-endorsements {:id (:issuer_content_id %)} (u/get-db ctx)))]
                                                                  (when-not (empty? issuer-endorsement)
                                                                    [:paragraph.generic


Add zoom capability

Add zoom capability

--- src/clj_simple_chart/jfx.clj
+++ src/clj_simple_chart/jfx.clj
@@ -11,25 +11,67 @@
            (javafx.embed.swing SwingFXUtils)
            (javax.imageio ImageIO)
            (java.io File)
-           (javafx.concurrent Worker$State)))
+           (javafx.concurrent Worker$State)
+           (javafx.event EventHandler)
+           (javafx.scene.input KeyCode)))

 (defonce latch (CountDownLatch. 1))
+(defonce zoom (atom 1.0))
 (defonce webview (atom nil))
 (defonce stage (atom nil))
 (defonce engine (atom nil))
+(defonce scene (atom nil))
+
+(defonce input-height (atom nil))
+(defonce input-width (atom nil))
+
+(defn update-zoom! [zoomvalue]
+  (swap! zoom (fn [o] zoomvalue))
+  (Platform/runLater (fn [] (.setZoom @webview @zoom)))
+  (Platform/runLater (fn [] (.setPrefHeight @webview (* @zoom @input-height))))
+  (Platform/runLater (fn [] (.setPrefWidth @webview (* @zoom @input-width))))
+  (Platform/runLater (fn [] (.sizeToScene @stage))))
+
+(def zoom-handler
+  (reify EventHandler
+    (handle [_ v]
+      (update-zoom! (* @zoom (.getZoomFactor v))))))
+
+(def zoom-delta 0.025)
+
+(def key-released-handler
+  (reify EventHandler
+    (handle [_ v]
+      (cond (and (.isControlDown v)
+                 (= (.getText v) "0"))
+            (update-zoom! 1.0)
+
+            (and (.isControlDown v)
+                 (= (.getCode v) KeyCode/MINUS))
+            (update-zoom! (- @zoom zoom-delta))
+
+            (and (.isControlDown v)
+                 (= (.getCode v) KeyCode/EQUALS))
+            (update-zoom! (+ @zoom zoom-delta))
+
+            :else (do (println "unhandled" v))))))

 (defn -start [this internal-stage]
   (.setTitle internal-stage "SVG Output")
   (let [internal-webview (WebView.)
         internal-engine (.getEngine internal-webview)
         layout (VBox. 0.0)
+        internal-scene (Scene. layout)
         children (.getChildren layout)]
     (.loadContent internal-engine "about:blank")
     (.setAll children [internal-webview])
-    (.setScene internal-stage (Scene. layout))
+    (.setScene internal-stage internal-scene)
+    (.setOnZoom internal-scene zoom-handler)
+    (.setOnKeyReleased internal-scene key-released-handler)
     (.show internal-stage)
     (swap! engine (fn [x] internal-engine))
     (swap! stage (fn [x] internal-stage))
+    (swap! scene (fn [x] internal-scene))
     (swap! webview (fn [x] internal-webview)))
   (Platform/runLater (fn [] (.countDown latch))))

@@ -81,9 +123,12 @@
         width (:width attrs)
         height (:height attrs)
         s (hiccup.core/html (conj body svg))]
+    (swap! input-height (fn [o] height))
+    (swap! input-width (fn [o] width))
     (bootstrap)
-    (Platform/runLater (fn [] (.setPrefHeight @webview height)))
-    (Platform/runLater (fn [] (.setPrefWidth @webview width)))
+    (Platform/runLater (fn [] (.setZoom @webview @zoom)))
+    (Platform/runLater (fn [] (.setPrefHeight @webview (* @zoom height))))
+    (Platform/runLater (fn [] (.setPrefWidth @webview (* @zoom width))))
     (render-string s)
     (Platform/runLater (fn [] (.sizeToScene @stage)))
     (Platform/runLater (fn [] (.show @stage)))
@@ -99,11 +144,10 @@
     (Platform/runLater
       (fn []
         (let [snap (SnapshotParameters.)]
-          (.setViewport snap (Rectangle2D. 0 0 width height))
+          (.setViewport snap (Rectangle2D. 0 0 (* @zoom width) (* @zoom height)))
           (let [image (.snapshot @webview snap nil)
                 bufimage (SwingFXUtils/fromFXImage image nil)]
-            (ImageIO/write bufimage "png" (File. filename))
-            #_(println "\nwrote " filename #_"md5=" #_(digest/md5 (File. filename)))))))
+            (ImageIO/write bufimage "png" (File. filename))))))
     (Platform/runLater (fn [] (.countDown ll)))
     (.await ll)))


fix map-values -> all numbers to string

fix map-values -> all numbers to string

--- src/cljc/swarmpit/utils.cljc
+++ src/cljc/swarmpit/utils.cljc
@@ -32,6 +32,6 @@
                 (fn [x]
                   (cond
                     (map? x) (vals x)
-                    (integer? x) (str x)
+                    (number? x) (str x)
                     (boolean? x) (str x)
                     :else (identity x))) m)))))


Add active hexagon class

Add active hexagon class

--- src/cljs/db_quiz/layout.cljs
+++ src/cljs/db_quiz/layout.cljs
@@ -2,6 +2,7 @@
   (:require [db-quiz.config :refer [config]]
             [db-quiz.logic :as logic]
             [db-quiz.state :refer [app-state]]
+            [db-quiz.util :refer [join-by-space]]
             [clojure.string :as string]))

 (defn shade-colour
@@ -63,7 +64,7 @@
             availability (if (or loading? disabled? (not (#{"default" "missed"} ownership)))
                              "unavailable"
                              "available")]
-        [:g {:class (str "hexagon " availability)
+        [:g {:class (join-by-space "hexagon" availability (when (= ownership "active") "active"))
              :on-click (partial logic/pick-field id)}
          [:polygon.hex-outer {:fill (str "url(#" ownership "-outer)")
                               :points (hex-coords center size)}]


ideas

ideas

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -64,6 +64,7 @@
   [ai {:keys [scores] :as turn}]
   (minimax-step ai turn
     (fn [_ transition]
+      ;; TODO - Plug other ways to score (like counting available transitions)
       (eval-score ai (scores/update-scores scores transition))
       )))


ideas

ideas

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -52,7 +52,7 @@
 ;; Attempts minimax
 ;; -----------------------------------------

-;; TODO - How to add the custom scoring?
+;; TODO - How to add the custom scoring? How to keep the game? (use keys)
 (defn leaf-score
   [ai game]
   (:scores (game/current-turn game)))


Updated /reset to DELETE.

Updated /reset to DELETE.

--- src/cmr/graph/rest/route.clj
+++ src/cmr/graph/rest/route.clj
@@ -71,7 +71,7 @@
                  :get (handler/health httpd-component)
                  :options handler/ok}]
      ["/reset" {
-                :get (handler/reset conn)
+                :delete (handler/reset conn)
                 :options handler/ok}]
      ["/ping" {
                :get handler/ping


Fix output

Fix output

--- src/cyanite_remover/core.clj
+++ src/cyanite_remover/core.clj
@@ -203,7 +203,6 @@
                      (swap! stats-processed inc)
                      (when-not @clog/print-log?
                        (prog/tick))
-                     (clog/info (str "Removing path: " %))
                      (process-fn pstore options tenant %))
                   paths))
       (when-not @clog/print-log?
@@ -223,6 +222,7 @@
     (dry-mode-warn options)
     (process-paths tenant paths es-url options
                    (fn [pstore options tenant path]
+                     (clog/info (str "Removing path: " path))
                      (pstore/delete pstore tenant false false path))
                    "Removing paths" true)
     (catch Exception e


add :environments test

add :environments test

--- examples/test/project.clj
+++ examples/test/project.clj
@@ -7,7 +7,8 @@
                  [swank-clojure "1.2.1"]
                  [tokyocabinet "1.23-SNAPSHOT"]]
   :dev-dependencies [[clojure-complete "0.1.0"]
-                     [autodoc "0.7.1"]])
+                     [autodoc "0.7.1"]]
+  :environments {:qa {:foo 1 :bar 2}})

 (deftask bar
   (bake (:use useful)


Use seq instead of not-empty

Use seq instead of not-empty

--- src/foreclojure/settings.clj
+++ src/foreclojure/settings.clj
@@ -90,7 +90,7 @@
                  (err-msgs "settings.email-exists")]
           (do
             (update! :users {:user user}
-                     {:$set {:pwd (if (not-empty new-pwd) new-pwd-hash pwd) :user new-lower-user :email email
+                     {:$set {:pwd (if (seq new-pwd) new-pwd-hash pwd) :user new-lower-user :email email
                              :disable-code-box (boolean disable-codebox) :hide-solutions (boolean hide-solutions)}}
                      :upsert false)
             (session/session-put! :user new-lower-user)


update call to flare's start-fn

update call to flare's start-fn

--- src/galleon/applications.clj
+++ src/galleon/applications.clj
@@ -33,7 +33,7 @@
     :helmsman-context "navigator"
     :helmsman-definition navigator/helmsman-def}
    {:app-name "Flare"
-    :start-fn! flare.util/get-queues
+    :start-fn! flare.util/get-attaches
     :schema flare.schema/schema
     :helmsman-context "flare"
     :helmsman-definition flare.web/helmsman-definition}


init worker config on worker create

init worker config on worker create

--- src/hivewing_core/worker.clj
+++ src/hivewing_core/worker.clj
@@ -1,5 +1,6 @@
 (ns hivewing-core.worker
   (:require [hivewing-core.configuration :refer [sql-db]]
+            [taoensso.timbre :as logger]
             [hivewing-core.hive-image-notification :as hin]
             [hivewing-core.core :refer [ensure-uuid]]
             [hivewing-core.worker-events :refer :all]
@@ -63,9 +64,11 @@
                             :hive_uuid (ensure-uuid hive-uuid)
                             :apiary_uuid (ensure-uuid apiary-uuid)
                             :name  (or worker-name (namer/gen-name)))]
-    (let [res (first (jdbc/insert! sql-db :workers clean-params))]
-      (worker-config-set (:uuid res) {".tasks" ["workera" "workerb"]})
-      (hin/hive-images-notification-send-worker-update-message (:uuid res))
+    (let [res (first (jdbc/insert! sql-db :workers clean-params))
+          uuid (:uuid res)]
+      (logger/info "Setting initial worker configuration...")
+      (worker-config-set uuid {".tasks" ["workera" "workerb"]} :allow-system-keys true)
+      (hin/hive-images-notification-send-worker-update-message uuid)
       res)))

 (defn worker-join-hive


Patch for issue 92

Patch for issue 92

Adding support for specifying the dependency type, defaults to "jar"

--- src/leiningen/util/maven.clj
+++ src/leiningen/util/maven.clj
@@ -136,6 +136,7 @@
   (let [extras-map (apply hash-map extras)
         exclusions (:exclusions extras-map)
         classifier (:classifier extras-map)
+        type (:type extras-map)
         es (map make-exclusion exclusions)]
     (doto (Dependency.)
       ;; Allow org.clojure group to be omitted from clojure/contrib deps.
@@ -146,6 +147,7 @@
       (.setArtifactId (name dep))
       (.setVersion version)
       (.setClassifier classifier)
+      (.setType (or type "jar"))
       (.setExclusions es))))

 (defn make-repository [[id settings]]


test hook

test hook

--- src/main/cawala/api/read.clj
+++ src/main/cawala/api/read.clj
@@ -6,7 +6,7 @@
                      :person/relation :friend}
                  2  {:db/id 2 :person/name "Sally" :person/age 22
                      :person/relation :friend}
-                 3  {:db/id 3 :person/name "Allie" :person/age 56
+                 3  {:db/id 3 :person/name "Allie" :person/age 57
                      :person/relation :enemy}
                  4  {:db/id 4 :person/name "Zoe" :person/age 32
                      :person/relation :friend}


Rename link-to macro to render-link

Rename link-to macro to render-link

--- src/main/clojure/cascade.clj
+++ src/main/clojure/cascade.clj
@@ -71,7 +71,7 @@
   ([env function extra-path-info query-parameters]
     `(link-path ~env (link-map-from-function ~function ~extra-path-info ~query-parameters))))

-(defmacro link-to
+(defmacro render-link
   "Creates a hyperlink with an href as a link to a view or action function.
   Following the function, is an optional vector of extra path information, then
   an optional map of query parameters. Additional forms after that form an implicit template."


fixes #361

fixes #361

Former-commit-id: 1a317ffac2f8f8d3cbdda5d9240ba1216a832352

--- src/status_im/components/chat_icon/styles.cljs
+++ src/status_im/components/chat_icon/styles.cljs
@@ -68,7 +68,7 @@
   (merge chat-icon
          {:width         36
           :height        36
-          :border-radius 1}))
+          :border-radius 18}))

 (def online-view-wrapper
   {:position         :absolute


fix check for future-stem: only use it if the :infl is future.

--- src/babel/francais/morphology.cljc
+++ src/babel/francais/morphology.cljc
@@ -162,9 +162,12 @@
                (get-in word [infl number-and-person])

                true
-               (let [infinitive (if (get-in word [:future-stem])
-                                  (get-in word [:future-stem])
-                                  (get-in word [:français]))]
+               (let [infinitive (cond (and (= :future (get-in word [:infl]))
+                                           (get-in word [:future-stem]))
+                                      (get-in word [:future-stem])
+                                      ;; TODO: add checks for other -stem features, like :imperfect-stem.
+                                      true
+                                      (get-in word [:français]))]
                  (conjugate infinitive word))))

            (and


s/def/defonce/

s/def/defonce/

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -22,7 +22,7 @@
    [dag_unify.core :refer (copy dissoc-paths fail? get-in ref? strip-refs unify)]))

 ;; TODO: convert all morphology rules to this format used for prepositions:
-(def preposition-plus-article
+(defonce preposition-plus-article
   [["a il"   "al"]
    ["a lo"   "allo"]
    ["a la"   "alla"]
@@ -1307,14 +1307,14 @@
    true
    ""))

-(def ppa-tokens-to-surface
+(defonce ppa-tokens-to-surface
   (map (fn [pair]
          [(re-pattern
            (str "\\b" (first pair) "\\b"))
           (second pair)])
        preposition-plus-article))

-(def ppa-surface-to-tokens
+(defonce ppa-surface-to-tokens
   (map (fn [pair]
          [(re-pattern
            (str "\\b" (second pair) "\\b"))
@@ -1402,7 +1402,7 @@
                 lexeme))
         (get lexicon surface-form))))

-(def exceptions-rules
+(defonce exceptions-rules
   (concat verbs/exceptions-rules
           adjectives/exceptions-rules
           nouns/exceptions-rules))


no need for comment anymore, function name explains it

--- src/chat/client/views/threads.cljs
+++ src/chat/client/views/threads.cljs
@@ -61,7 +61,6 @@
         (fn []
           (when-not (thread :new?) ; need this here b/c get-node breaks if no refs???
             (when-let [messages (om/get-node owner "messages")]
-              ; scroll to bottom of messages
               (set! (.-scrollTop messages) (.-scrollHeight messages)))))]
     (reify
       om/IDidMount


Refactor bank csv handling into its own smaller functions so it will bea easier to support another bank

--- src/clj/my_money/routes/upload.clj
+++ src/clj/my_money/routes/upload.clj
@@ -1,30 +1,40 @@
 (ns my-money.routes.upload
-  (:require [my-money.db.core :as db]
+  (:require [clojure.string :as str]
+            [my-money.db.core :as db]
             [my-money.op-csv :refer :all]
             [clj-time.jdbc]
             [compojure.core :refer [defroutes POST]]
             [ring.util.http-response :as response]))
+
+(defn ->event [user-id raw-data]
+  {:transaction-id (:Arkistointitunnus raw-data)
+   :user-id user-id
+   :transaction-date (date-string->date (:Kirjauspäivä raw-data))
+   :amount (Integer/parseInt (str/replace (:MääräEUROA raw-data) "," ""))
+   :recipient (:Saaja/Maksaja raw-data)
+   :type (:Laji raw-data)})

 (defn- save-events [user-id events]
   (loop [events events
          total-rows 0]
     (if-let [event (first events)]
       (let [inserted-rows (db/create-event!
-                           {:transaction-id (:Arkistointitunnus event)
-                            :user-id user-id
-                            :transaction-date (date-string->date (:Kirjauspäivä event))
-                            :amount (Integer/parseInt (clojure.string/replace (:MääräEUROA event) "," ""))
-                            :recipient (:Saaja/Maksaja event)
-                            :type (:Laji event)})]
+                           (->event user-id event))]
         (recur (rest events) (+ total-rows inserted-rows)))
       (str total-rows))))
+
+(defn csv->clj [csv]
+  (-> csv
+      read-csv
+      csv-vec->map))
+
+(defn ->events [x]
+  (map (partial ->event 1) x))

 (defroutes upload-routes
   (POST "/upload" [file :as req]
     (let [user-id (:id (db/get-user-by-username {:username (:identity req)}))
           data (-> (:tempfile file)
                    (slurp :encoding "ISO-8859-1")
-                   (read-csv)
-                   (remove-columns-by-name ["Arvopäivä" "Laji"])
-                   (csv-vec->map))]
-      (-> (response/ok (save-events user-id data))))))
+                   csv->clj)]
+      (response/ok (save-events user-id data)))))


work arround http-kit bug so :cljs/quit doesn't leak memory like crazy

--- src/clj/shadow/devtools/server.clj
+++ src/clj/shadow/devtools/server.clj
@@ -90,8 +90,13 @@
           ([v]
             (when-not (nil? v)
               (recur (handle-client-data state v)))
-            )))))
-
+            )))
+
+      ;; ensure that the channel is closed
+      ;; http-kit seems to have a bug that leaves the server-loop running
+      ;; if the server is shutdown while still having a connected websocket
+      (hk/close channel)
+      ))

 (defn- ring-handler [server-control ring-request]
   (let [client-in (async/chan)
@@ -179,6 +184,9 @@
           ))))

 (defn shutdown-server [state]
+  (doseq [{:keys [out] :as client} (-> state :clients vals)]
+    (async/close! out))
+
   (when-let [instance (get-in state [:server :instance])]
     (try
       (instance)
@@ -390,6 +398,57 @@
     (throw (ex-info "no server loop?" {})))
   (<!! server-loop))

+
+(defn- server-tick [state server-control repl-input]
+  (alt!!
+    server-control
+    ([v]
+      (when-not (nil? v)
+        (try
+          (handle-server-control state v)
+          (catch Exception e
+            (prn [:server-error e v])
+            state
+            ))))
+
+    repl-input
+    ([v]
+      (when-not (nil? v)
+        (try
+          (let [[msg result-chan] v]
+            (handle-repl-input state msg result-chan))
+          (catch Exception e
+            (prn [:repl-error e v])
+            state
+            ))))
+
+    (timeout 500)
+    ([_]
+      (try
+        (handle-server-control state [:idle])
+        (catch Exception e
+          (prn [:idle-error e])
+          state))
+      )))
+
+(defn- server-loop [state server-control repl-input repl-output]
+  (loop [state state]
+    (if-let [next-state (server-tick state server-control repl-input)]
+      (recur next-state)
+      (do (shutdown-server state)
+
+          ;; no more output coming
+          (async/close! repl-output)
+
+          ;; don't really need to close these since we should be the only ones reading them
+          ;; and closing one of them is a way to shut us down .. still like it clean
+          (async/close! repl-input)
+          (async/close! server-control)
+
+          ;; return value of this channel is the last compiler-state (includes repl-state)
+          (:compiler-state state)
+          ))))
+
 (defn start
   ([state config]
    (start state config default-compile-callback))
@@ -410,66 +469,10 @@

          state (assoc state :compiler-state (callback (:compiler-state state) []))
          server-control (get-in state [:server :server-control])
-         server-thread
-         (thread
-           (loop [state state]
-             (alt!!
-               server-control
-               ([v]
-                 (when-not (nil? v)
-                   (recur
-                     (try
-                       (handle-server-control state v)
-                       (catch Exception e
-                         (prn [:server-error e v])
-                         state
-                         )))))
-
-               repl-input
-               ([v]
-                 (when-not (nil? v)
-                   (recur
-                     (try
-                       (let [[msg result-chan] v]
-                         (handle-repl-input state msg result-chan))
-                       (catch Exception e
-                         (prn [:repl-error e v])
-                         state
-                         )))))
-
-               (timeout 500)
-               ([_]
-                 (recur
-                   (try
-                     (handle-server-control state [:idle])
-                     (catch Exception e
-                       (prn [:idle-error e])
-                       state))
-                   ))))
-
-           (shutdown-server state)
-
-           ;; no more output coming
-           (async/close! repl-output)
-
-           ;; don't really need to close these since we should be the only ones reading them
-           ;; and closing one of them is a way to shut us down .. still like it clean
-           (async/close! repl-input)
-           (async/close! server-control)
-
-           ;; return value of this channel is the last compiler-state (includes repl-state)
-           (:compiler-state state))]
-
+         server-thread (thread (server-loop state server-control repl-input repl-output))]
      (assoc state :server-thread server-thread))))

 (def current-instance (atom {}))
-
-(defn start-nrepl [state config callback]
-  (let [{:keys [repl-output repl-input]} (start state config callback)]
-    (swap! current-instance merge {:repl-input repl-input
-                                   :repl-output repl-output})
-    ::nrepl
-    ))

 (defn start-loop
   ([state config]


put edit button first in group

put edit button first in group

--- src/clj_money/web/transactions.clj
+++ src/clj_money/web/transactions.clj
@@ -21,18 +21,18 @@
    [:td (:description transaction)]
    [:td
     [:div.btn-group
+     (glyph-button :pencil
+                   (format "/transactions/%s/edit" (:id transaction))
+                   {:level :info
+                    :size :extra-small
+                    :title "Click here to edit this transaction."})
      (glyph-button :remove
                    (format "/transactions/%s/delete" (:id transaction))
                    {:level :danger
                     :size :extra-small
                     :data-method :post
                     :data-confirm "Are you sure you want to delete this transaction?"
-                    :title "Click here to remove this transaction."})
-     (glyph-button :pencil
-                   (format "/transactions/%s/edit" (:id transaction))
-                   {:level :info
-                    :size :extra-small
-                    :title "Click here to edit this transaction."})]]])
+                    :title "Click here to remove this transaction."})]]])

 (defn index
   ([entity-id] (index entity-id {}))


Improve zoom logic (specifically on a 'click' assume the user just wants to zoom in on that area a bit

--- src/cljs/mandelbrot_cljs/core.cljs
+++ src/cljs/mandelbrot_cljs/core.cljs
@@ -15,28 +15,48 @@
 (defonce rendering-data-history (atom [initial-rendering-data]))

+(defn zoom-to!
+  [startx starty width height]
+  (swap!
+   app-state
+   (fn [{:as old-state :keys [mousedown-event overlay-canvas rendered-rectangle]}]
+     (let [{:keys [x0 y0 scale]} rendered-rectangle]
+       (-> old-state
+           (dissoc :mousedown-event)
+           (assoc :rendering-data {:x0 (+ x0 (/ startx scale))
+                                   :y0 (- y0 (/ starty scale))
+                                   :width (/ width scale)
+                                   :height (/ height scale)}))))))
+
+(defn modulus
+  [x]
+  (Math/sqrt (* x x)))
+
 (defn handle-mouseup
   "On mouseup, we zoom the mandelbrot to the specified box and remove the
    :mousedown-event key from the app-state"
   [e]
-  (swap!
-   app-state
-   (fn [{:as old-state :keys [mousedown-event canvas rendered-rectangle]}]

-     (let [{:keys [x0 y0 scale]}        rendered-rectangle
+  (let [startx  (aget (:mousedown-event @app-state) "pageX")
+        starty  (aget (:mousedown-event @app-state) "pageY")
+        finishx (aget e "pageX")
+        finishy (aget e "pageY")]

-           x*1                           (+ x0 (/ (aget e "pageX") scale))
-           y*1                           (- y0 (/ (aget e "pageY") scale))
+    (if (or (< (modulus (- startx finishx)) 10)
+            (< (modulus (- starty finishy)) 10)) ; Does this look like a click?

-           x*0                           (+ x0 (/ (aget mousedown-event "pageX") scale))
-           y*0                           (- y0 (/ (aget mousedown-event "pageY") scale))]
+      (do
+        (add-rectangle! (:overlay-canvas @app-state)
+                        (Math/max 0 (- startx 100))
+                        (Math/max 0 (- starty 100))
+                        (+ startx 100)
+                        (+ starty 100)
+                        :clear? true
+                        :color "red"
+                        :type :stroke)
+        (zoom-to! (Math/max 0 (- startx 100)) (Math/max 0 (- starty 100)) 200 200))

-       (-> old-state
-           (dissoc :mousedown-event)
-           (assoc :rendering-data {:x0     x*0
-                                   :y0     y*0
-                                   :width  (- x*1 x*0)
-                                   :height (- y*0 y*1)}))))))
+      (zoom-to! (Math/min startx finishx) (Math/min starty finishy) (modulus (- finishx startx)) (modulus (- finishy starty))))))

 (defn handle-mousemove
   "Draw a rectangle when we're zooming"


parens to square in frame

parens to square in frame

--- src/cljs/tictactoe/view/frame.cljs
+++ src/cljs/tictactoe/view/frame.cljs
@@ -9,5 +9,5 @@
    takes as input the callbacks to trigger events"
   [board callbacks]
   [:div
-   (panel/render-top-panel callbacks)
-   (board/render-board board callbacks)])
+   [panel/render-top-panel callbacks]
+   [board/render-board board callbacks]])


file-defs for :redef-in-file warnings

file-defs for :redef-in-file warnings

--- src/main/shadow/cljs/build.clj
+++ src/main/shadow/cljs/build.clj
@@ -869,6 +869,9 @@

     (binding [ana/*cljs-static-fns*
               static-fns
+
+              ana/*file-defs*
+              (atom #{})

               ;; initialize with default value
               ;; must set binding to it is thread bound, since the analyzer may set! it


add variable map import/export

add variable map import/export

--- src/main/shadow/cljs/build.clj
+++ src/main/shadow/cljs/build.clj
@@ -15,15 +15,15 @@
             [cognitect.transit :as transit]
             [shadow.cljs.util :as util]
             [shadow.cljs.log :as log]
-     [clojure.pprint :refer (pprint)]
+            [clojure.pprint :refer (pprint)]
             )
-  (:import [java.io File StringWriter FileOutputStream FileInputStream StringReader PushbackReader ByteArrayOutputStream BufferedReader]
+  (:import [java.io File StringWriter FileOutputStream FileInputStream StringReader PushbackReader ByteArrayOutputStream BufferedReader ByteArrayInputStream]
            [java.net URL]
            [com.google.javascript.jscomp JSModule SourceFile JSModuleGraph CustomPassExecutionTime]
            (java.util.jar JarFile JarEntry)
            (com.google.javascript.jscomp.deps JsFileParser)
            [java.util.concurrent Executors Future]
-           (com.google.javascript.jscomp ReplaceCLJSConstants CompilerOptions CommandLineRunner JSError ErrorFormat CheckLevel LightweightMessageFormatter SourceMapInput BasicErrorManager CompilerOptions$LanguageMode CompilerInput ProcessEs6Modules SourceMap SourceMap$LocationMapping)
+           (com.google.javascript.jscomp ReplaceCLJSConstants CompilerOptions CommandLineRunner JSError ErrorFormat CheckLevel LightweightMessageFormatter SourceMapInput BasicErrorManager CompilerOptions$LanguageMode CompilerInput ProcessEs6Modules SourceMap SourceMap$LocationMapping VariableMap)
            (java.security MessageDigest)
            (javax.xml.bind DatatypeConverter)
            (cljs.tagged_literals JSValue)))
@@ -111,9 +111,9 @@

          evt#
          (assoc msg#
-           :timing :enter
-           :start start#
-           :depth *time-depth*)]
+                :timing :enter
+                :start start#
+                :depth *time-depth*)]
      (log ~state evt#)
      (let [result#
            (binding [*time-depth* (inc *time-depth*)]
@@ -124,10 +124,10 @@

            evt#
            (assoc msg#
-             :timing :exit
-             :depth *time-depth*
-             :stop stop#
-             :duration (- stop# start#))]
+                  :timing :exit
+                  :depth *time-depth*
+                  :stop stop#
+                  :duration (- stop# start#))]
        (log (if (compiler-state? result#) result# ~state) evt#)
        result#)
      ))
@@ -216,7 +216,7 @@
                  (.parseFile name name @input))

         module-type
-        (.. deps (getLoadFlags) (get "module"))
+        (-> deps (.getLoadFlags) (.get "module"))

         ;; FIXME: bug in Closure that es6 files do not depend on goog?
         ;; doesn't hurt that it is missing though
@@ -282,24 +282,24 @@
                 ns-map))]

         (assoc ast
-          :require-order
-          (into [] (map rewrite-ns) require-order)
-          :requires
-          (rewrite-ns-map requires true)
-          :uses
-          (rewrite-ns-map uses false))
+               :require-order
+               (into [] (map rewrite-ns) require-order)
+               :requires
+               (rewrite-ns-map requires true)
+               :uses
+               (rewrite-ns-map uses false))
         ))))

 (defn update-rc-from-ns
   [state rc {:keys [name require-order] :as ast}]
   {:pre [(compiler-state? state)]}
   (assoc rc
-    :ns name
-    :ns-info (dissoc ast :env)
-    :provides #{name}
-    :macro-namespaces (macros-from-ns-ast state ast)
-    :requires (into #{} require-order)
-    :require-order require-order))
+         :ns name
+         :ns-info (dissoc ast :env)
+         :provides #{name}
+         :macro-namespaces (macros-from-ns-ast state ast)
+         :requires (into #{} require-order)
+         :require-order require-order))

 (defn peek-into-cljs-resource
   "looks at the first form in a .cljs file, analyzes it if (ns ...) and returns the updated resource
@@ -330,12 +330,12 @@
           ;; make best estimate guess what the file might provide based on name
           (let [guessed-ns (filename->ns name)]
             (assoc rc
-              :ns guessed-ns
-              :requires #{'cljs.core}
-              :require-order ['cljs.core]
-              :provides #{guessed-ns}
-              :type :cljs
-              )))))))
+                   :ns guessed-ns
+                   :requires #{'cljs.core}
+                   :require-order ['cljs.core]
+                   :provides #{guessed-ns}
+                   :type :cljs
+                   )))))))

 (defn inspect-resource
   [state {:keys [url name] :as rc}]
@@ -490,12 +490,12 @@
                       ;; mark rc as foreign and merge with externs instead of leaving externs as seperate rc
                       rc
                       (assoc rc
-                        :type :foreign
-                        :requires (set require-order)
-                        :require-order require-order
-                        :provides (set (map symbol provides))
-                        :externs externs
-                        :externs-source externs-source)]
+                             :type :foreign
+                             :requires (set require-order)
+                             :require-order require-order
+                             :provides (set (map symbol provides))
+                             :externs externs
+                             :externs-source externs-source)]

                   (-> result
                       (dissoc-all externs)
@@ -656,8 +656,8 @@
          (string? src-name)]}
   (-> state
       (assoc :deps-stack []
-        :deps-ordered []
-        :deps-visited #{})
+             :deps-ordered []
+             :deps-visited #{})
       (get-deps-for-src* src-name)
       :deps-ordered))

@@ -782,7 +782,7 @@
            ;; of the compiler state, instead they are in :compiler-options
            ;; still want the compiler-state accessible though
            (assoc (:compiler-options state)
-             :compiler-state state))
+                  :compiler-state state))
          (post-analyze state)))))

 (defn do-compile-cljs-string
@@ -956,16 +956,16 @@
               (throw (ex-info "cljs file did not provide a namespace" {:file name})))

             (assoc rc
-              :output js
-              :requires requires
-              :require-order require-order
-              :compiled-at (System/currentTimeMillis)
-              :provides #{ns}
-              :compiled true
-              :warnings warnings
-              :ast ast
-              :forms forms
-              :source-map source-map)))))))
+                   :output js
+                   :requires requires
+                   :require-order require-order
+                   :compiled-at (System/currentTimeMillis)
+                   :provides #{ns}
+                   :compiled true
+                   :warnings warnings
+                   :ast ast
+                   :forms forms
+                   :source-map source-map)))))))

 (defn get-cache-file-for-rc
@@ -1051,7 +1051,7 @@
             (-> (merge rc cache-data)
                 (dissoc :analyzer :cache-options :age-of-deps)
                 (assoc :cached true
-                  :output (slurp cache-js))))))
+                       :output (slurp cache-js))))))

       (catch Exception e
         (log state {:type :cache-error
@@ -1073,7 +1073,7 @@
               (-> rc
                   (dissoc :file :output :input :url :forms :ast)
                   (assoc :age-of-deps (make-age-map state ns)
-                    :analyzer (get-in @env/*compiler* [::ana/namespaces ns])))
+                         :analyzer (get-in @env/*compiler* [::ana/namespaces ns])))

               cache-options
               (reduce
@@ -1197,9 +1197,9 @@
         ;; remove all provides, otherwise it might end up being used despite the invalid name
         ;; enforce this behavior since the warning might get overlooked easily
         (let [invalid-src (assoc src
-                            :provides #{}
-                            :requires #{}
-                            :require-order [])]
+                                 :provides #{}
+                                 :requires #{}
+                                 :require-order [])]
           (assoc-in state [:sources name] invalid-src)))

     ;; do not merge files that are already present from a different source path
@@ -1303,8 +1303,8 @@
              state
              (if (.isDirectory file)
                (assoc-in state [:source-paths abs-path] (assoc path-opts
-                                                          :file file
-                                                          :path abs-path))
+                                                               :file file
+                                                               :path abs-path))
                state)]
          (merge-resources state resources))))))

@@ -1507,7 +1507,7 @@
           {}
           closure-defines)]

-     (json/write-str closure-defines :escape-slashes false)))
+    (json/write-str closure-defines :escape-slashes false)))

 (defn closure-defines [{:keys [public-path cljs-runtime-path] :as state}]
   (str "var CLOSURE_NO_DEPS = true;\n"
@@ -1829,9 +1829,9 @@
             (cond->
               source-map?
               (-> (assoc :source-map-json
-                    (let [sw (StringWriter.)]
-                      (.appendTo sm sw js-name)
-                      (.toString sw)))
+                         (let [sw (StringWriter.)]
+                           (.appendTo sm sw js-name)
+                           (.toString sw)))
                   (update :output str "\n//# sourceMappingURL=" (file-basename js-name) ".map\n"))))))))

@@ -2071,12 +2071,12 @@
             (str (clojure.core/name name) "-foreign-" md5 ".js")]

         (assoc mod
-          :foreign-files
-          [{:js-name foreign-name
-            :provides provides
-            :output output
-            :sources (into [] (map :name) foreign-srcs)
-            }])))
+               :foreign-files
+               [{:js-name foreign-name
+                 :provides provides
+                 :output output
+                 :sources (into [] (map :name) foreign-srcs)
+                 }])))
     ))

 (defn make-foreign-bundles [{:keys [build-modules] :as state}]
@@ -2093,8 +2093,8 @@
         modules
         (sort-and-compact-modules state)]
     (assoc state
-      :build-modules modules
-      :build-sources (into [] (mapcat :sources modules)))))
+           :build-modules modules
+           :build-sources (into [] (mapcat :sources modules)))))

 (defn compile-modules*
   "compiles source based on :build-modules (created by prepare-modules)"
@@ -2369,6 +2369,33 @@
 (defn closure-add-replace-constants-pass [cc ^CompilerOptions co state]
   (.addCustomPass co CustomPassExecutionTime/BEFORE_CHECKS (ReplaceCLJSConstants. cc)))

+(defn read-variable-map [{:keys [cache-dir] :as state} name]
+  (let [map-file (io/file cache-dir name)]
+    (when (.exists map-file)
+      (try
+        (VariableMap/load (.getAbsolutePath map-file))
+        (catch Exception e
+          (prn [:variable-map-load map-file e])
+          nil)))))
+
+(defn write-variable-map [{:keys [cache-dir] :as state} name map]
+  (let [map-file
+        (doto (io/file cache-dir name)
+          (io/make-parents))
+
+        bytes
+        (ByteArrayInputStream. (.toBytes map))]
+
+    (with-open [out (FileOutputStream. map-file)]
+      (io/copy bytes out))))
+
+(defn closure-add-variable-maps [cc co {:keys [cache-dir] :as state}]
+  (when-some [data (read-variable-map state "closure.property.map")]
+    (.setInputPropertyMap co data))
+
+  (when-some [data (read-variable-map state "closure.variable.map")]
+    (.setInputVariableMap co data)))
+
 (defn add-closure-configurator
   "adds a closure configurator 2-arity function that will be called before the compiler is invoked
    signature of the callback is (fn [compiler compiler-options])
@@ -2469,9 +2496,9 @@

              state
              (assoc state
-               :build-externs externs
-               :closure-compiler cc
-               :closure-compiler-options co)
+                    :build-externs externs
+                    :closure-compiler cc
+                    :closure-compiler-options co)

              _ (when source-map?
                  (add-input-source-maps state cc))
@@ -2551,8 +2578,11 @@
                                            {:source-map-json closure-json
                                             :source-map-name source-map-name}))))))))]

+             ;; see closure-add-variable-maps configurator which loads these before compiling
+             (write-variable-map state "closure.variable.map" (.-variableMap result))
+             (write-variable-map state "closure.property.map" (.-propertyMap result))
+
              (assoc state :closure-result result :optimized optimized-modules))))))))
-

 (defn- ns-list-string [coll]
   (->> coll
@@ -2737,8 +2767,8 @@
                                                        ;; must set sources and file to complete relative paths
                                                        ;; as the source map only contains local references without path
                                                        (assoc sm
-                                                         "sources" [src-name]
-                                                         "file" js-name))
+                                                              "sources" [src-name]
+                                                              "file" js-name))
                                                 })
                 ;; only have source-maps for cljs
                 src-map)
@@ -2922,8 +2952,8 @@
                      (if (<= new-mod last-modified)
                        result
                        (let [macro (assoc macro
-                                     :scan :macro
-                                     :last-modified new-mod)]
+                                          :scan :macro
+                                          :last-modified new-mod)]

                          (conj result macro)))))
                  []))
@@ -3145,6 +3175,7 @@
        stdout-log}

       (add-closure-configurator closure-add-replace-constants-pass)
+      (add-closure-configurator closure-add-variable-maps)
       ))

 (defn watch-and-repeat! [state callback]


Making tests work on localhost AMQP

Making tests work on localhost AMQP

--- test/muon_clojure/core_test.clj
+++ test/muon_clojure/core_test.clj
@@ -28,12 +28,12 @@
 (let [uuid (.toString (java.util.UUID/randomUUID))
       _ (println "!!!!!!! Before muon")
       ms (component/start
-          (micro-service {:rabbit-url :local
+          (micro-service {:rabbit-url "amqp://localhost" #_:local
                           :service-identifier uuid
                           :tags ["dummy" "test"]
                           :implementation (->TestMSImpl)}))
       _ (println "!!!!!!! After muon")]
-  (let [c (muon-client :local (str uuid "-client")
+  (let [c (muon-client "amqp://localhost" #_:local (str uuid "-client")
                        "dummy" "test" "client")]
     (let [get-val
           (with-muon c (request! (str "request://" uuid "/get-endpoint")


Riemann requires all tags to be strings

Riemann requires all tags to be strings

--- test/onyx/metrics/send_test.clj
+++ test/onyx/metrics/send_test.clj
@@ -162,6 +162,7 @@
                 (is (= expected (set (butlast results))))
                 (is (= :done (last results)))
                 (is (= valid-tag-combos (set (map (comp vec butlast :tags) @events))))
+                (is (nil? (some #(not (instance? java.lang.String %)) (mapcat :tags @events))))
                 (is (> (count @events) (* 3 ; number of tasks
                                           (/ (- end-time start-time) 1000)
                                           ;; only approximate because of brittle test on CI


Korjattu turnausten järjestys sisäänkirjautuneen etusivulla

--- mtg-pairings-server/src/mtg_pairings_server/players.clj
+++ mtg-pairings-server/src/mtg_pairings_server/players.clj
@@ -66,7 +66,9 @@
                                     (sql/subselect db/team-players
                                       (sql/join db/team (= :team.id :team_players.team))
                                       (sql/where {:team_players.player dci
-                                                  :team.tournament :tournament.id})))))]
+                                                  :team.tournament :tournament.id}))))
+                       (sql/order :day :DESC)
+                       (sql/order :id :DESC))]
       (-> tournament
         (add-players-data dci)
         add-newest-standings))))


Fix typos.

Fix typos.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -85,7 +85,9 @@
          :existing-board (api-common/rep new-board)
          :moving-board (api-common/rep old-board)
          :updated-entry (api-common/rep updated-entry)}
-        [false, {:updated-entry (api-common/rep updated-entry)}])) ; invalid update
+        (do
+         (println (lib-schema/valid? common-res/Entry updated-entry))
+         [false, {:updated-entry (api-common/rep updated-entry)}]))) ; invalid update

     true)) ; no existing entry, so this will fail existence check later

@@ -167,7 +169,6 @@
             new-entry (:new-entry ctx)
             entry-result (entry-res/create-entry! conn new-entry)] ; Add the entry
     (do
-      (handle-video-data conn entry-result ctx)
       (timbre/info "Created entry for:" entry-for "as" (:uuid entry-result))
       (when (= (:status entry-result) "published")
         (undraft-board conn (:user ctx) org board)
@@ -185,7 +186,7 @@
             user (:user ctx)
             entry (:existing-entry ctx)
             updated-entry (:updated-entry ctx)
-            updated-result (entry-res/update-entry! conn (:uuid updated-video) updated-entry user)]
+            updated-result (entry-res/update-entry! conn (:uuid entry) updated-entry user)]

     (let [old-board (:moving-board ctx)]
       ;; If we are moving the entry from a draft board, check if we need to remove the board itself.


Remove debug log entry

Remove debug log entry

--- src/onyx/plugin/bookkeeper.clj
+++ src/onyx/plugin/bookkeeper.clj
@@ -341,7 +341,6 @@
   (let [bytes (compress [ledger-id])
         node (str (log-zk/catalog-path onyx-id) "/" job-id "/" task-id)]
     (when-not (zk/create conn node :persistent? true :data bytes)
-      (info "Couldn't add, now updating")
       (while (try
                (let [current (zk/data conn node)
                      version (:version (:stat current))
@@ -378,5 +377,4 @@
         ledger-id (.getId ledger-handle)]
     (info "BookKeeper write-ledger: created new ledger:" ledger-id)
     (add-ledger-data! log onyx-id job-id task-id ledger-id)
-    (info "read ledgers " onyx-id job-id task-id (read-ledgers-data log onyx-id job-id task-id))
     (->BookKeeperWriteLedger client ledger-handle serializer-fn write-failed-code)))


fix uberjar lein task alias

fix uberjar lein task alias

--- src/leiningen/new/yawt/project.clj
+++ src/leiningen/new/yawt/project.clj
@@ -98,5 +98,5 @@
              :repl    {:resource-paths ["env-resources/repl"]
                        :source-paths   ["dev"]}}

- :aliases {"uberjar" ["do" "clean" "uberjar"]{{#webapp}}
+ :aliases {"uberjar" ["do" ["clean"] ["uberjar"]]{{#webapp}}
            "cljsdev" ["do" ["cljsbuild" "once"] ["cljsbuild" "auto"]]{{/webapp}}})


Remove unused imports, cosmetic.

Remove unused imports, cosmetic.

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -11,16 +11,15 @@
             [onyx.extensions :as extensions]
             [onyx.compression.nippy :refer [messaging-compress messaging-decompress]]
             [onyx.static.default-vals :refer [defaults arg-or-default]])
-  (:import [uk.co.real_logic.aeron Aeron Aeron$Context FragmentAssembler Publication Subscription AvailableImageHandler]
+  (:import [uk.co.real_logic.aeron Aeron Aeron$Context FragmentAssembler Publication Subscription]
            [uk.co.real_logic.aeron.driver MediaDriver MediaDriver$Context ThreadingMode]
            [uk.co.real_logic.aeron.logbuffer FragmentHandler]
-           [uk.co.real_logic.agrona ErrorHandler CloseHelper]
+           [uk.co.real_logic.agrona ErrorHandler]
            [uk.co.real_logic.agrona.concurrent
             UnsafeBuffer IdleStrategy BackoffIdleStrategy BusySpinIdleStrategy]
            [java.util.function Consumer]
            [java.util.concurrent TimeUnit]))

-
 (defn aeron-channel [addr port]
   (format "udp://%s:%s" addr port))

@@ -28,6 +27,7 @@
   [peer-group messaging-group publication-group short-circuitable? publications virtual-peers acking-daemon acking-ch
    send-idle-strategy compress-f]
   component/Lifecycle
+
   (start [component]
     (taoensso.timbre/info "Starting Aeron")
     (let [config (:config peer-group)


add remove-triple!, update signal-triple & collect-index to support removals, simplify collect-select, bugfix invalid result check in aggregate-select

--- src/thi/ng/fabric/triples.cljc
+++ src/thi/ng/fabric/triples.cljc
@@ -5,33 +5,46 @@
    [taoensso.timbre :refer [debug info warn error]]))

 (defprotocol ITripleGraph
-  (add-triple [_ t])
-  (add-query [_ id q])
-  (add-rule [_ id match production])
+  (add-triple! [_ t])
+  (remove-triple! [_ t])
+  (add-query! [_ id q])
+  (add-rule! [_ id match production])
   (query-result [_ id]))

 (defn signal-triple
-  [vertex _]
-  [(:id vertex) @vertex])
+  [vertex op]
+  [op (:id vertex) @vertex])

 (defn collect-index
   [spo]
   (f/simple-collect
    (fn [val incoming]
-     (info :update-index spo incoming)
+     ;;(info :update-index spo incoming)
      (transduce
-      (map (fn [[id t]] [id (nth t spo)]))
-      (completing (fn [acc [id x]] (update acc x (fnil conj #{}) id)))
+      (map (fn [[op id t]] [op id (nth t spo)]))
+      (completing
+       (fn [acc [op id x]]
+         (case op
+           :add    (update acc x (fnil conj #{}) id)
+           :remove (if-let [idx (acc x)]
+                     (if (= #{id} idx)
+                       (dissoc acc x)
+                       (update acc x disj id))
+                     acc)
+           (do (warn "ignoring unknown index signal op:" op)
+               acc))))
       val incoming))))

 (defn signal-select
   [vertex [idx sel]]
-  [idx (if sel (@vertex sel [nil]) (->> @vertex vals (mapcat identity)))])
+  [idx (if sel (@vertex sel [nil]) (->> @vertex vals (mapcat identity) (set)))])

 (def collect-select
   (f/simple-collect
    (fn [val incoming]
-     (reduce (fn [acc [idx res]] (update acc idx (fnil into #{}) res)) val incoming))))
+     (let [val (reduce (fn [acc [idx res]] (assoc acc idx res)) val incoming)]
+       ;;(info :coll-select val incoming)
+       val))))

 (defn score-aggregate-select
   [vertex]
@@ -42,8 +55,9 @@
   (f/simple-collect
    (fn [_ incoming]
      (let [res (vals (peek incoming))]
+       ;;(info :agg-incoming res)
        (delay
-        (when (every? #(not= #{nil} %) res)
+        (when (every? #(not= [nil] %) res)
           (->> res
                (map #(disj % nil))
                (set)
@@ -66,7 +80,7 @@
       (debug :additions adds)
       (doseq [t inferred]
         (info :add-triple t)
-        (add-triple g t))
+        (add-triple! g t))
       (swap! (:state vertex) update :val set/union in (set inferred)))))

 (defn- index-vertex
@@ -90,18 +104,29 @@
   (add-edge!
     [_ src dest sig opts] (f/add-edge! g src dest sig opts))
   ITripleGraph
-  (add-triple
+  (add-triple!
     [_ t]
     (or (@triples t)
         (let [{:keys [subj pred obj]} indices
               v (f/add-vertex! g {:val t})]
-          (f/add-edge! g v subj signal-triple nil)
-          (f/add-edge! g v pred signal-triple nil)
-          (f/add-edge! g v obj  signal-triple nil)
+          (f/add-edge! g v subj signal-triple :add)
+          (f/add-edge! g v pred signal-triple :add)
+          (f/add-edge! g v obj  signal-triple :add)
           (f/signal! v)
-          (swap! triples conj t)
+          (swap! triples assoc t v)
           v)))
-  (add-query
+  (remove-triple!
+    [_ t]
+    (if-let [v (@triples t)]
+      (let [{:keys [subj pred obj]} indices]
+        (f/add-edge! g v subj signal-triple :remove)
+        (f/add-edge! g v pred signal-triple :remove)
+        (f/add-edge! g v obj  signal-triple :remove)
+        (f/signal! v)
+        (swap! triples dissoc t)
+        v)
+      (warn "attempting to remove unknown triple:" t)))
+  (add-query!
     [_ id [s p o]]
     ;; TODO figure out way how to at to a running context
     ;; TODO remove vertices if query ID already exists
@@ -124,10 +149,10 @@
       {:acc acc :result res}))
   (query-result
     [_ id] (when-let [q (@queries id)] @@(:res q)))
-  (add-rule
+  (add-rule!
     [_ id query production]
     (let [qid (keyword (str "inf-" (name id)))
-          q   (add-query _ qid query)
+          q   (add-query! _ qid query)
           inf (f/add-vertex!
                g {:val #{}
                   ::f/collect-fn (collect-inference _ production)})]
@@ -141,12 +166,12 @@
    {:indices {:subj (index-vertex g 0)
               :pred (index-vertex g 1)
               :obj  (index-vertex g 2)}
-    :triples (atom #{})
+    :triples (atom {})
     :queries (atom {})
     :rules   (atom {})
     :g       g}))

-(defn add-counter
+(defn add-counter!
   [g src]
   (let [v (f/add-vertex!
            g {::f/collect-fn
@@ -160,18 +185,18 @@
 (defn start
   []
   (let [g (triple-graph (f/compute-graph))
-        toxi (:result (add-query g :toxi ['toxi nil nil]))
-        types (:result (add-query g :types [nil 'type nil]))
-        projects (:result (add-query g :projects [nil 'type 'project]))
-        all (:result (add-query g :all [nil nil nil]))
-        num-projects (add-counter g projects)
-        num-types (add-counter g types)
-        inf1 (add-rule g :knows [nil 'knows nil] (fn [[s p o]] [[s 'type 'person] [o 'type 'person] [o 'knows s]]))
+        toxi (:result (add-query! g :toxi ['toxi nil nil]))
+        types (:result (add-query! g :types [nil 'type nil]))
+        projects (:result (add-query! g :projects [nil 'type 'project]))
+        all (:result (add-query! g :all [nil nil nil]))
+        num-projects (add-counter! g projects)
+        num-types (add-counter! g types)
+        inf1 (add-rule! g :knows [nil 'knows nil] (fn [[s p o]] [[s 'type 'person] [o 'type 'person] [o 'knows s]]))

         ctx (f/async-context {:graph g :processor f/eager-vertex-processor :timeout nil})]
     (f/execute! ctx)
     (mapv
-     #(add-triple g %)
+     #(add-triple! g %)
      '[[toxi author fabric]
        [fabric type project]
        [toxi type person]])


Improve html formatting of the tasks.

Improve html formatting of the tasks.

Used some nice bootstrap.

--- src/todo_repl_webapp/views.clj
+++ src/todo_repl_webapp/views.clj
@@ -27,29 +27,28 @@
   "Given a task (map), return a div representing the task"
   [task-map]
   (core/html
-    [:div
       [:div.col-md-7.col-md-offset-1
         [:p.lead (:name task-map)]]
       [:div.col-md-2
         (if-not (nil? (:context task-map))
-          [:p (:context task-map)])]
+          [:p.text-muted (:context task-map)])]
       [:div.col-md-2
         (if-not (nil? (:due task-map))
-          [:p (:due task-map)])]]))
+          [:p.text-info (:due task-map)])]))

 (defn task-line-item
   "When given a single task (map), return a html table line representing the task"
   [task-map]
-  (core/html [:tr
-               [:td (task-item task-map)]]))
+  (core/html [:div.panel.panel-default
+               [:div.panel-body
+                 (task-item task-map)]]))

 (defn task-table
   "When given a vector of tasks (maps), return an html table representing those tasks"
   [task-vec]
   (core/html
-    [:table.table.table-bordered
       (clojure.string/join
-        (map task-line-item task-vec))]))
+        (map task-line-item task-vec))))

 (defn display [x & xs]
   (if-not (empty? x)


finished with private defn's in fake.clj

--- src/midje/internal_ideas/fakes.clj
+++ src/midje/internal_ideas/fakes.clj
@@ -19,7 +19,8 @@
                                                    with-altered-roots]]
         [midje.error-handling.exceptions :only [user-error]]
         [midje.internal-ideas.wrapping :only [with-wrapping-target]]
-        [midje.ideas.arrow-symbols])
+        [midje.ideas.arrow-symbols]
+        [clojure.tools.macro :only [macrolet]])
   (:require [clojure.zip :as zip])
   (:import midje.ideas.metaconstants.Metaconstant))

@@ -93,8 +94,16 @@
 (defn tag-as-background-fake [fake]
   (concat fake `(:background :background :times (~'range 0))))

+
 ;;; Binding

+(defn #^:tested-private usable-default-function? [fake]
+  (and (bound? (:lhs fake))
+    (let [stashed-value (var-get (:lhs fake))
+          unfinished-fun (:midje/unfinished-fun (meta (:lhs fake)))]
+      (and (extended-fn? stashed-value)
+        (or (nil? unfinished-fun)
+          (not= unfinished-fun stashed-value))))))

 (letfn [(var-handled-by-fake? [function-var fake]
           (= function-var (:lhs fake)))]
@@ -109,18 +118,10 @@
          (= (count actual-args) (count (:arg-matchers fake)))
          (extended-list-= actual-args (:arg-matchers fake))))

-  (defn #^:tested-private usable-default-function? [fake]
-    (and (bound? (:lhs fake))
-         (let [stashed-value (var-get (:lhs fake))
-               unfinished-fun (:midje/unfinished-fun (meta (:lhs fake)))]
-           (and (extended-fn? stashed-value)
-                (or (nil? unfinished-fun)
-                    (not= unfinished-fun stashed-value))))))
-

   (def ^:dynamic ^:private *call-action-count* (atom 0))

-  (defn- best-call-action [function-var actual-args fakes]
+  (defn- #^:tested-private best-call-action [function-var actual-args fakes]
     (when (= 2 @*call-action-count*)
       (throw (user-error "You seem to have created a prerequisite for"
                (str (pr-str function-var) " that interferes with that function's use in Midje's")
@@ -145,28 +146,28 @@

           :else (:value-at-time-of-faking (first possible-fakes)))))))

-(defmacro ^:private counting-nested-calls-calls [& forms]
-  `(try
-     (swap! *call-action-count* inc)
-     ~@forms
-     (finally (swap! *call-action-count* dec))))
-
-(defn- call-faker
-  "This is the function that handles all mocked calls."
+(defn- #^:tested-private call-faker
+  "This is the function that handles all mocked calls."
   [function-var actual-args fakes]
-  (let [action (counting-nested-calls-calls (best-call-action function-var actual-args fakes))]
-    (cond (nil? action)
-      (clojure.test/report {:type :mock-argument-match-failure
-                            :lhs function-var
-                            :actual actual-args
-                            :position (:position (first fakes))})
-
-      (extended-fn? action)
-      (apply action actual-args)
-
-      :else (do
-              (swap! (action :count-atom ) inc)
-              ((action :result-supplier ))))))
+  (macrolet [(counting-nested-calls [& forms]
+               `(try
+                  (swap! *call-action-count* inc)
+                  ~@forms
+                  (finally (swap! *call-action-count* dec))))]
+
+    (let [action (counting-nested-calls (best-call-action function-var actual-args fakes))]
+      (cond (nil? action)
+        (clojure.test/report {:type :mock-argument-match-failure
+                              :lhs function-var
+                              :actual actual-args
+                              :position (:position (first fakes))})
+
+        (extended-fn? action)
+        (apply action actual-args)
+
+        :else (do
+                (swap! (action :count-atom ) inc)
+                ((action :result-supplier )))))))

 ;; Binding map related