Fixing the in memory acl hash impl.

Fixing the in memory acl hash impl.

--- src/cmr/ingest/data/provider_acl_hash.clj
+++ src/cmr/ingest/data/provider_acl_hash.clj
@@ -1,7 +1,7 @@
 (ns cmr.ingest.data.provider-acl-hash
   "Stores and retrieves the hashes of the ACLs for a provider."
-  (:require [sqlingvo.core :as s :refer [insert values select from where with order-by desc delete as]]
-            [cmr.oracle.connection]
+  (:require [cmr.oracle.connection]
+            [cmr.common.lifecycle :as lifecycle]
             [clojure.java.jdbc :as j]
             [clojure.edn :as edn]))

@@ -12,13 +12,27 @@

 (defrecord InMemoryAclHashStore
   [data-atom]
+
+  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   AclHashStore
+
   (save-acl-hash
     [this acl-hash]
     (reset! (:data-atom this) acl-hash))
+
   (get-acl-hash
     [this]
-    (-> this :data-atom deref)))
+    (-> this :data-atom deref))
+
+  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+  lifecycle/Lifecycle
+
+  (start
+    [this system]
+    this)
+  (stop
+    [this system]
+    this))

 (defn create-in-memory-acl-hash-store
   []


clean up

clean up

--- src/com/billpiel/sayid/string_output2.clj
+++ src/com/billpiel/sayid/string_output2.clj
@@ -375,7 +375,7 @@
            [start end $]))

-(defn token-prop-grouper4
+(defn tkn-prop-grouper4
   [pos-pairs start end]
   (if (empty? pos-pairs) {:last-start start :last-end end :pairs []}
       (let [{:keys [last-start last-end pairs]} pos-pairs]
@@ -386,18 +386,18 @@
                  :last-end end
                  :pairs (conj pairs [last-start last-end]))))))

-(defn token-prop-grouper3
+(defn tkn-prop-grouper3
   [start end]
   (fn [agg pos-pairs]
-    (update-in agg pos-pairs token-prop-grouper4 start end)))
-
-(defn token-prop-grouper2
+    (update-in agg pos-pairs tkn-prop-grouper4 start end)))
+
+(defn tkn-prop-grouper2
   [agg [start end props]]
-  (reduce (token-prop-grouper3 start end)
+  (reduce (tkn-prop-grouper3 start end)
           agg
           props))

-(defn token-prop-grouper6
+(defn tkn-prop-grouper6
   [pairs]
   (reduce (fn [agg [start end]]
             (update-in agg
@@ -406,13 +406,13 @@
           {}
           pairs))

-(defn token-prop-grouper5
+(defn tkn-prop-grouper5
   [m]
   (reduce (fn [agg [a b c]]
             (if b
               (assoc-in agg
                         [a b]
-                        (token-prop-grouper6 c))
+                        (tkn-prop-grouper6 c))
               agg))
           {}
           (for [[k kv] m
@@ -421,9 +421,9 @@

 (defn tkn-prop-grouper
   [triples]
-  (token-prop-grouper5 (reduce token-prop-grouper2
-                               {}
-                               triples)))
+  (tkn-prop-grouper5 (reduce tkn-prop-grouper2
+                             {}
+                             triples)))

 (defn split-text-tag-coll
   [tokens]


Focus management #38

Focus management #38

--- src/flatgui/samples/forms/fdemowindow.clj
+++ src/flatgui/samples/forms/fdemowindow.clj
@@ -18,20 +18,22 @@
             [flatgui.widgets.component :as component]
             [flatgui.paint :as fgp]))

-(fgp/deflookfn container-look (:theme)
+
+(fgp/deflookfn container-look (:theme :focus-state)
   [(fgp/call-look component/component-look)
-   (awt/setColor :prime-2)
-   (awt/drawRect 0 0 w- h-)])
+   (awt/setColor (:prime-2 theme))
+   (awt/drawRect 0 0 w- h-)
+   (awt/drawString (str (:mode focus-state) "/" (:focused-child focus-state)) (awt/px) 0.25)])

 (fg/defevolverfn tf-model-evolver :model
-                 (if (= (fg/get-reason) [:this])
-                   {:text (let [focus-state (get-property [:this] :focus-state)]
-                            (str (:mode focus-state) "/" (:focused-child focus-state)))
-                    :caret-pos 0
-                    :selection-mark 0}
-                   (textfield/text-model-evolver component)))
+  (if (= (fg/get-reason) [:this])
+    {:text (let [focus-state (get-property [:this] :focus-state)]
+             (str (:mode focus-state) "/" (:focused-child focus-state)))
+     :caret-pos 0
+     :selection-mark 0}
+    (textfield/text-model-evolver component)))

 ;; Panel 1 for win 1
@@ -44,23 +46,19 @@
      :position-matrix (m/translation 1 2)}

     (fg/defcomponent textfield/textfield :entry1
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 0.75)
-                      :evolvers {:model tf-model-evolver}
-                      })
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 0.75)
+       :evolvers {:model tf-model-evolver}})

     (fg/defcomponent textfield/textfield :entry2
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 1.25)
-                      :evolvers {:model tf-model-evolver}})
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 1.25)
+       :evolvers {:model tf-model-evolver}})

     (fg/defcomponent textfield/textfield :entry3
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 1.75)
-                      :evolvers {:model tf-model-evolver}})
-
-    ))
-
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 1.75)
+       :evolvers {:model tf-model-evolver}})))

 ;; Window 1
@@ -74,8 +72,8 @@
 (def title-2 "Focus Example - 2 - ")

 (fg/defevolverfn window-text-evolver-2 :text
-                 (let [focus-state (get-property [:this] :focus-state)]
-                   (str title-1 (:mode focus-state) "/" (:focused-child focus-state))))
+  (let [focus-state (get-property [:this] :focus-state)]
+    (str title-2 (:mode focus-state) "/" (:focused-child focus-state))))

 (def focus-window
   (fg/defcomponent
@@ -89,8 +87,7 @@
     (fg/defcomponent textfield/textfield :entry1
       {:clip-size (m/defpoint 3.0 0.375)
        :position-matrix (m/translation 0.25 0.75)
-       :evolvers {:model tf-model-evolver}
-       })
+       :evolvers {:model tf-model-evolver}})

     (fg/defcomponent textfield/textfield :entry2
       {:clip-size (m/defpoint 3.0 0.375)
@@ -102,7 +99,45 @@
        :position-matrix (m/translation 0.25 1.75)
        :evolvers {:model tf-model-evolver}})

-    ))
+    (fg/defcomponent panel/panel :panel1
+      {:clip-size (m/defpoint 3.0 3.0)
+       :position-matrix (m/translation 0.25 2.5)
+       :look container-look})
+
+    (fg/defcomponent panel/panel :panel2
+      {:clip-size (m/defpoint 3.0 3.0)
+       :position-matrix (m/translation 3.5 2.5)
+       :look container-look}
+
+         (fg/defcomponent panel/panel :panel2-1
+           {:clip-size (m/defpoint 2.75 1.0)
+            :position-matrix (m/translation 0.125 0.5)
+            :look container-look}
+
+           (fg/defcomponent textfield/textfield :entry1
+             {:clip-size (m/defpoint 1.125 0.375)
+              :position-matrix (m/translation 0.125 0.5)
+              :evolvers {:model tf-model-evolver}})
+
+           (fg/defcomponent textfield/textfield :entry2
+             {:clip-size (m/defpoint 1.125 0.375)
+              :position-matrix (m/translation 1.5 0.5)
+              :evolvers {:model tf-model-evolver}}))
+
+         (fg/defcomponent panel/panel :panel2-2
+           {:clip-size (m/defpoint 2.75 1.0)
+            :position-matrix (m/translation 0.125 1.625)
+            :look container-look}
+
+           (fg/defcomponent textfield/textfield :entry1
+             {:clip-size (m/defpoint 1.125 0.375)
+              :position-matrix (m/translation 0.125 0.5)
+              :evolvers {:model tf-model-evolver}})
+
+           (fg/defcomponent textfield/textfield :entry2
+             {:clip-size (m/defpoint 1.125 0.375)
+              :position-matrix (m/translation 1.5 0.5)
+              :evolvers {:model tf-model-evolver}})))))

 (def focus-window-2
   (fg/defcomponent
@@ -114,22 +149,59 @@
      :evolvers {:text window-text-evolver-2}}

     (fg/defcomponent textfield/textfield :entry1
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 0.75)
-                      :evolvers {:model tf-model-evolver}
-                      })
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 0.75)
+       :evolvers {:model tf-model-evolver}})

     (fg/defcomponent textfield/textfield :entry2
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 1.25)
-                      :evolvers {:model tf-model-evolver}})
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 1.25)
+       :evolvers {:model tf-model-evolver}})

     (fg/defcomponent textfield/textfield :entry3
-                     {:clip-size (m/defpoint 3.0 0.375)
-                      :position-matrix (m/translation 0.25 1.75)
-                      :evolvers {:model tf-model-evolver}})
-
-    ))
+      {:clip-size (m/defpoint 3.0 0.375)
+       :position-matrix (m/translation 0.25 1.75)
+       :evolvers {:model tf-model-evolver}})
+
+    (fg/defcomponent panel/panel :panel1
+      {:clip-size (m/defpoint 6.5 4.0)
+       :position-matrix (m/translation 0.25 2.5)
+       :look container-look}
+
+      (fg/defcomponent textfield/textfield :entry1
+        {:clip-size (m/defpoint 1.5 0.375)
+         :position-matrix (m/translation 0.125 0.5)
+         :evolvers {:model tf-model-evolver}})
+
+      (fg/defcomponent textfield/textfield :entry2
+        {:clip-size (m/defpoint 1.5 0.375)
+         :position-matrix (m/translation 1.75 0.5)
+         :evolvers {:model tf-model-evolver}})
+
+           (fg/defcomponent panel/panel :panel1-1
+             {:clip-size (m/defpoint 6.25 2.75)
+              :position-matrix (m/translation 0.125 1.125)
+              :look container-look}
+
+             (fg/defcomponent panel/panel :panel1-1-1
+               {:clip-size (m/defpoint 3.0 2.25)
+                :position-matrix (m/translation 0.125 0.375)
+                :look container-look})
+
+             (fg/defcomponent panel/panel :panel1-1-2
+               {:clip-size (m/defpoint 2.875 2.25)
+                :position-matrix (m/translation 3.25 0.375)
+                :look container-look}
+
+               (fg/defcomponent panel/panel :panel1-1-2-1
+                 {:clip-size (m/defpoint 2.625 1.5)
+                  :position-matrix (m/translation 0.125 0.5)
+                  :look container-look}
+
+               (fg/defcomponent textfield/textfield :entry1
+                 {:clip-size (m/defpoint 1.5 0.375)
+                  :position-matrix (m/translation 0.125 0.5)
+                  :evolvers {:model tf-model-evolver}})))))))

 (def root-panel
@@ -139,6 +211,7 @@
     {:clip-size (m/defpoint 40 25)
      :background (awt/color 9 17 26)

+     ;; TODO this should be a part defroot probably
      :closed-focus-root true
      :focus-state {:mode :has-focus
                    :focused-child nil}}


refactored drawing

refactored drawing

--- src/sormilla/core.clj
+++ src/sormilla/core.clj
@@ -2,7 +2,7 @@
   (:require [sormilla.gui :as gui]
             [sormilla.leap :as leap]
             [sormilla.math :as math])
-  (:import [java.awt Color Graphics2D RenderingHints Rectangle]
+  (:import [java.awt Color Graphics2D RenderingHints Rectangle BasicStroke]
            [java.awt.geom Ellipse2D$Double]))

 (set! *warn-on-reflection* true)
@@ -18,16 +18,21 @@
                            :lo       (Color.  255   64  64    64)}})

 (def quality-colors [(Color.  255   64  64   192)
-                     (Color.  192   64  64    64)
-                     (Color.  192   64  64    32)
-                     (Color.  192  192  64    32)
-                     (Color.   64  192  64    32)
-                     (Color.   64  192  64    64)])
+                     (Color.  255   64  64   192)
+                     (Color.  255   64  64   192)
+                     (Color.  192   64  64   128)
+                     (Color.   64  192  64   128)
+                     (Color.   64  192  64   255)])
+
+(def stroke-0 (BasicStroke. 0.0))
+(def stroke-1 (BasicStroke. 1.0))

 (defmacro with-trans [^Graphics2D g & body]
-  `(let [t# (.getTransform ~g)]
+  `(let [t# (.getTransform ~g)
+         c# (.getClip ~g)]
      ~@body
-     (.setTransform ~g t#)))
+     (.setTransform ~g t#)
+     (.setClip ~g c#)))

 (defn pitcher []
   (comp
@@ -54,67 +59,79 @@
   (let [pitch (pitcher)
         yaw (yawer)
         roll (roller)]
-    (fn [^Graphics2D g w h hand]
+    (fn [^Graphics2D g hand]
+
+      ; clear background
+      (.setColor g background-color)
+      (.fillRect g 0 0 100 100)
+
+      ; draw grid
+      (.setColor g hud-color)
+      (.setStroke g stroke-0)
+      (doseq [n (range -40 50 10)]
+        (.drawLine g -50 n 50 n)
+        (.drawLine g n -50 n 50))
+
+      ; draw zero axis
+      (.setColor g hud-hi-color)
+      (.drawLine g -50 0 50 0)
+      (.drawLine g 0 -50 0 50)
+
+      ; draw quality boxes
+      (let [quality (:quality hand 0)]
+        (.setColor g (nth quality-colors quality))
+        (doseq [y (range 5)]
+          (when (>= y quality) (.setColor g hud-lo-color))
+          (.fillRect g -48 (- 48 (* y 3)) 8 2)))
+
       (when hand
-        (.setColor g (nth quality-colors (:quality hand)))
-        (doseq [n (range 5 (* 10 (:quality hand)) 10)]
-          (.fillRect g 5 n 23 8))
-        (.setColor g hud-color)
-        (doseq [n (range 5 50 10)]
-          (.drawRect g 5 n 23 5))
-        (.setColor g norm)
-        (.setClip g (Rectangle. 0 0 (/ w 2) h))
-        (with-trans g
-          (.translate g (double (/ w 4)) (double (/ h 2)))
-          (.scale g (double (/ (/ w 4) 100.0)) (double (/ (/ h 2) 100.0)))
-          (.translate g (double (yaw hand)) (double (pitch hand)))
-          (.rotate g (roll hand))
-          (.setColor g lo)
-          (.fillOval g -75 -10 150 20)
-          (.setColor g norm)
-          (.drawOval g -75 -10 150 20)
-          (.drawLine g -200 0 200 0)
-          (.drawLine g 0 -200 0 200))))))
+        (.translate g ^double (yaw hand) ^double (pitch hand))
+        (.rotate g (roll hand))
+        (.setStroke g stroke-1)
+        (.setColor g lo)
+        (.fillOval g -75 -10 150 20)
+        (.drawOval g -75 -10 150 20)
+        (.drawLine g -200 0 200 0)
+        (.drawLine g 0 -200 0 200)))))

 (def draw-left-hand (hand-drawer (:left hand-colors)))
 (def draw-right-hand (hand-drawer (:right hand-colors)))

 (defn render [^Graphics2D g ^long w ^long h frame]
+  (.setRenderingHint g RenderingHints/KEY_ANTIALIASING RenderingHints/VALUE_ANTIALIAS_ON)
   (.setColor g background-color)
   (.fillRect g 0 0 w h)
-  (.setRenderingHint g RenderingHints/KEY_ANTIALIASING RenderingHints/VALUE_ANTIALIAS_ON)
-  (let [[left-hand right-hand] frame]
+  (let [w2 (/ w 2.0)
+        w4 (/ w 4.0)
+        h2 (/ h 2.0)]
+    (with-trans g
+      (.translate g w4 h2)
+      (.scale g (/ w2 100.0) (/ h 100.0))
+      (.setClip g (Rectangle. -50 -50 100 100))
+      (draw-left-hand g (first frame)))
+    (with-trans g
+      (.translate g (+ w2 w4) h2)
+      (.scale g (/ w2 100.0) (/ h 100.0))
+      (.setClip g (Rectangle. -50 -50 100 100))
+      (draw-right-hand g (second frame)))
     (.setColor g hud-color)
-    (.drawLine g (/ w 2 ) 0 (/ w 2) h)
-    (.setColor g hud-lo-color)
-    (doseq [x (map (fn [v] (int (* v (/ w 20.0)))) (range 20))]
-      (.drawLine g x 0 x h))
-    (doseq [x (map (fn [v] (int (* v (/ w 100.0)))) (range 100))]
-      (.drawLine g x (- (/ h 2) 5) x (+ (/ h 2) 5)))
-    (doseq [y (map (fn [v] (int (* v (/ h 10.0)))) (range 10))]
-      (.drawLine g 0 y w y))
-    (doseq [y (map (fn [v] (int (* v (/ h 50.0)))) (range 50))]
-      (.drawLine g (- (/ w 4) 5) y (+ (/ w 4) 5) y)
-      (.drawLine g (- (* 3 (/ w 4)) 5) y (+ (* 3 (/ w 4)) 5) y))
-    (draw-left-hand g w h (nth frame 0))
-    (.setClip g (Rectangle. 0 0 (inc w) (inc h)))
-    (.translate g (double (/ w 2)) (double 0.0))
-    (draw-right-hand g w h (nth frame 1))))
+    (.setStroke g (BasicStroke. 1.0))
+    (.drawLine g w2 0 w2 h)))

 (defn dummy-source []

-  [{:quality    3
+  [{:quality    5
     :pitch      0.0
     :yaw        0.0
     :roll       0.0}

-   {:quality   0
+   {:quality   5
     :pitch     0.2
     :yaw       0.2
-    :roll     -0.0}]
+    :roll     -0.2}]

-  (leap/frame)
+  #_(leap/frame)

   )


Remove cruft

Remove cruft

--- src/squelch/core.cljs
+++ src/squelch/core.cljs
@@ -1,5 +1 @@
 (ns squelch.core)
-
-(enable-console-print!)
-
-(println "Hello world!")


Add check for a caller passing in a bogus accumulator.

--- src/main/clojure/clara/rules/compiler.clj
+++ src/main/clojure/clara/rules/compiler.clj
@@ -10,7 +10,8 @@
             [schema.core :as sc]
             [schema.macros :as sm])
   (:import [clara.rules.engine ProductionNode QueryNode JoinNode NegationNode TestNode
-                               AccumulateNode AlphaNode LocalTransport LocalSession]))
+                               AccumulateNode AlphaNode LocalTransport LocalSession
+                               Accumulator]))

 ;; Protocol for loading rules from some arbitrary source.
 (defprotocol IRuleSource
@@ -572,18 +573,24 @@
            (compile-beta-tree children all-bindings))

           :accumulator
-          (eng/->AccumulateNode
-           id
-           ;; Create an accumulator structure for use when examining the node or the tokens
-           ;; it produces.
-           {:accumulator (:accumulator beta-node)
-            :from condition}
-           ;; We create an accumulator that accepts the environment for the beta node
-           ;; into its context, hence the function with the given environment.
-           ((eval (compile-accum (:accumulator beta-node) (:env beta-node))) (:env beta-node))
-           (:result-binding beta-node)
-           (compile-beta-tree children all-bindings)
-           join-bindings)
+          ;; We create an accumulator that accepts the environment for the beta node
+          ;; into its context, hence the function with the given environment.
+          (let [compiled-accum ((eval (compile-accum (:accumulator beta-node) (:env beta-node))) (:env beta-node))]
+
+            ;; Ensure the compiled accumulator has the expected structure
+            (when (not (instance? Accumulator compiled-accum))
+              (throw (IllegalArgumentException. (str (:accumulator beta-node) " is not a valid accumulator."))))
+
+            (eng/->AccumulateNode
+              id
+              ;; Create an accumulator structure for use when examining the node or the tokens
+              ;; it produces.
+              {:accumulator (:accumulator beta-node)
+               :from condition}
+              compiled-accum
+              (:result-binding beta-node)
+              (compile-beta-tree children all-bindings)
+              join-bindings))

           :production
           (eng/->ProductionNode


mistypping

mistypping

--- src/todos/storage.clj
+++ src/todos/storage.clj
@@ -6,7 +6,7 @@
   "Load data from data-file-name."
   [default-data]
   (try (read-string
-         (clojure.strin/replace
+         (clojure.string/replace
            (slurp data-file-name)
            #"\s+"
            " "


(maint) Add log message for finishing lifecycle function

Previously trapperkeeper would log a message when beginning to run a
lifecycle function, but not when the lifecycle function had returned.
This means that when debugging failures it can be challenging to tell
if a service has died mid-lifecycle function (depending on how much
logging that service has implemented). To alleviate that somewhat, this
commit adds a log message at debug level for when the lifecycle function
has finished.

--- src/puppetlabs/trapperkeeper/internal.clj
+++ src/puppetlabs/trapperkeeper/internal.clj
@@ -231,7 +231,10 @@
                          lifecycle-fn
                          lifecycle-fn-name
                          service-id
-                         s))
+                         s)
+      (log/debug (i18n/trs "Finished running lifecycle function ''{0}'' for service ''{1}''"
+                           lifecycle-fn-name
+                           service-id)))
     (catch Throwable t
       (log/error t (i18n/trs "Error during service {0}!!!" lifecycle-fn-name))
       (throw t))))


Define a string lexicon.

Define a string lexicon.

--- test/kolmogorov_music/test/kolmogorov.clj
+++ test/kolmogorov_music/test/kolmogorov.clj
@@ -48,3 +48,22 @@
   (enterprise inc) => 0
   (enterprise baz) => 7
   (enterprise enterprise) => 25)
+
+(def charset (map char (range 65 (+ 65 26))))
+
+(defn lex [strings]
+  (for [s strings c charset]
+    (conj s c)))
+
+(defn lexicon []
+  (->> (lexicon)
+       lex
+       lazy-seq
+       (cons [])))
+
+(defn lexicon-s []
+  (map (partial apply str) (lexicon)))
+
+(fact "We can construct all strings as a lazy sequence."
+  (->> (lexicon-s) (take 5)) => ["" "A" "B" "C" "D"]
+  (->> (lexicon-s) (drop 26) (take 5)) => ["Z" "AA" "AB" "AC" "AD"])


Removed test pool and added ca service to repl util

--- test/puppetlabs/master/testutils/repl.clj
+++ test/puppetlabs/master/testutils/repl.clj
@@ -4,6 +4,7 @@
             [puppetlabs.master.services.handler.request-handler-service :refer [request-handler-service]]
             [puppetlabs.master.services.jruby.jruby-puppet-service :refer [jruby-puppet-pooled-service]]
             [puppetlabs.master.services.config.jvm-puppet-config-service :refer [jvm-puppet-config-service]]
+            [puppetlabs.master.services.ca.certificate-authority-service :refer [certificate-authority-service]]
             [puppetlabs.trapperkeeper.core :as tk]
             [puppetlabs.trapperkeeper.app :as tka]
             [clojure.tools.namespace.repl :refer (refresh)]))
@@ -18,11 +19,10 @@
                          master-service
                          jruby-puppet-pooled-service
                          request-handler-service
-                         jvm-puppet-config-service]
+                         jvm-puppet-config-service
+                         certificate-authority-service]
                         {:global {:logging-config "./test-resources/logback-dev.xml"}
                          :jruby-puppet { :jruby-pools  [{:environment "production"
-                                                         :size 1}
-                                                        {:environment "test"
                                                          :size 1}]
                                          :load-path    ["./ruby/puppet/lib"
                                                         "./ruby/facter/lib"]


Fix typo.

Fix typo.

--- test/workshop/jobs/challenge_6_0_test.clj
+++ test/workshop/jobs/challenge_6_0_test.clj
@@ -132,7 +132,7 @@
             job-id (:job-id (onyx.api/submit-job peer-config job))]
         (assert job-id "Job was not successfully submitted")
         (feedback-exception! peer-config job-id)
-        ;; Wait for promise p to be deliver, which indicates
+        ;; Wait for promise p to be delivered, which indicates
         ;; that the computation is finished. Then we check
         ;; the results.
         @p


Newlines between tests.

Newlines between tests.

--- test/cljs/go_test.clj
+++ test/cljs/go_test.clj
@@ -40,7 +40,7 @@
             :let [ast (-> [actual] (cljs->ast (assoc (cljs.analyzer/empty-env) :context :expr)))]]
       (test-comment actual (first ast))
       (printf "\tassert.Equal(t,\n %s,\n %s)\n" expected (ast->go ast)))
-    (printf "}\n")))
+    (printf "}\n\n")))

 (defn emit-test [package file tests]
   (go-get "github.com/stretchr/testify/assert")


[#2824] Update backend specs

[#2824] Update backend specs

--- backend/specs/akvo/lumen/specs/postgres.clj
+++ backend/specs/akvo/lumen/specs/postgres.clj
@@ -5,7 +5,7 @@
             [akvo.lumen.specs.db.dataset-version.column :as db.dsv.column]
             [clojure.spec.alpha :as s]))

-(s/def ::postgres.filter/strategy (s/nilable #{"isHigher" "isLower" "is" "isEmpty"}))
+(s/def ::postgres.filter/strategy (s/nilable #{"isHigher" "isLower" "is" "isEmpty" "contains" "not_contains"}))

 (s/def ::postgres.filter/operation (s/nilable #{"keep"  "remove"}))


handles invalid method on keyword during websocket close (#270)

--- waiter/src/waiter/websocket.clj
+++ waiter/src/waiter/websocket.clj
@@ -374,7 +374,7 @@
                         correlation-id
                         (if (integer? status-code-or-exception)
                           (close-client-session! request status-code-or-exception close-message)
-                          (let [ex-message (.getMessage status-code-or-exception)]
+                          (let [ex-message (or (some-> status-code-or-exception .getMessage) close-message)]
                             (close-client-session! request server-termination-on-unexpected-condition ex-message))))))))
               ;; close client and backend channels
               (close-requests! request response request-state-chan))))))
@@ -397,10 +397,11 @@
       ;; force close connection
       ;; - a day after the auth cookie expires if it is available, or
       ;; - a day after the unauthenticated request is made
-      (let [expiry-start-time (:waiter/auth-expiry-time request 0)
+      (let [current-time-ms (System/currentTimeMillis)
+            expiry-start-time (:waiter/auth-expiry-time request current-time-ms)
             one-day-in-millis (-> 1 t/days t/in-millis)
             expiry-time-ms (+ expiry-start-time one-day-in-millis)
-            time-left-ms (max (- expiry-time-ms (System/currentTimeMillis)) 0)]
+            time-left-ms (max (- expiry-time-ms current-time-ms) 0)]
         (async/go
           (let [timeout-ch (async/timeout time-left-ms)
                 [_ selected-chan] (async/alts! [request-close-promise-chan timeout-ch] :priority true)]
@@ -409,11 +410,11 @@
                 ;; close connections if the request is still live
                 (confirm-live-connection-with-abort)
                 (log/info "cookie has expired, triggering closing of websocket connections")
-                (async/>! request-close-promise-chan :cookie-expired)
+                (async/>! request-close-promise-chan [:cookie-expired nil nil "Cookie Expired"])
                 (catch Exception _
                   (log/debug "ignoring exception generated from closed connection")))))))
       (catch Exception e
-        (async/>!! request-close-promise-chan :process-error)
+        (async/>!! request-close-promise-chan [:process-error nil e "Unexpected error"])
         (log/error e "error while processing websocket response"))))
   ;; return an empty response map to maintain consistency with the http case
   {})


now we have a decent foundation w/gol load

--- spinning/src/app/core.cljs
+++ spinning/src/app/core.cljs
@@ -47,6 +47,7 @@
   (atom
    {:app {:name "Spinning"
           :version "0.1.0"
+          :count-frames? false
           :measure-fps? false
           :rendering? false
           }
@@ -54,13 +55,13 @@
           :env-mouse-click nil
           :env-mouse-move nil
           }
-    :env {:frames-per-second nil
+    :env {:frame-count 0
+          :frames-per-second 0
           :keyboard-key nil
           :mouse-move nil
           :time nil
           }
     :gui {:cells nil
-          :frame 0
           :generation 0
           }}))

@@ -93,6 +94,10 @@

 ;; -----------------------------------------------------------------------------
 ;; Event Handlers
+
+(defn on-env-animation-frame [timestamp]
+  (swap! state update-in [:env :frame-count] inc)
+  (get-in @state [:app :count-frames?]))

 (defn on-env-frames-per-second [fps]
   (swap! state assoc-in [:env :frames-per-second] fps)
@@ -119,13 +124,18 @@
 ;; Event Subscriptions

 (defn setup-event-subscriptions! []
+  (swap! state assoc-in [:app :count-frames?] true)
+  (poly/listen-animation-frame! on-env-animation-frame)
   (swap! state assoc-in [:app :measure-fps?] true)
   (poly/listen-fps! on-env-frames-per-second)
   (poly/take-back! (get-event-channel :env-keyboard-key) on-env-keyboard-key)
   (poly/take-back! (get-event-channel :env-mouse-move) on-env-mouse-move))

 (defn teardown-event-subscriptions! []
-  (swap! state assoc-in [:app :measure-fps?] false))
+  (swap! state assoc-in [:app :count-frames?] false)
+  (swap! state assoc-in [:env :frame-count] 0))
+  (swap! state assoc-in [:app :measure-fps?] false)
+  (swap! state assoc-in [:env :frames-per-second] 0)

 ;; -----------------------------------------------------------------------------
@@ -139,12 +149,6 @@
 ;; Conway's Game of Life Cellular Automata

 (def acorn #{[70 62] [71 60] [71 62] [73 61] [74 62] [75 62] [76 62]})
-
-(defn setup-gol! []
-  (swap! state assoc-in [:gui :cells] acorn))
-
-(defn teardown-gol! []
-  (swap! state assoc-in [:gui :cells] false))

 (defn neighbors [[x y]]
   (map vector
@@ -159,32 +163,44 @@
    (let [[c1 c2 c3] (map #(:color %1) (keep #(get cells %1) (neighbors k)))]
      {:age 0 :color {:r (:r c1) :g (:g c2) :b (:b c3)}})))

+(defn create-cells [seed]
+  (into {} (for [k seed] [k (create-cell)])))
+
 (defn step [cells]
   (into {} (for [[k n] (->> (keys cells) (mapcat neighbors) (frequencies))
                  :let [cell (or (get cells k) (create-cell k cells))]
                  :when (or (= n 3) (and (= n 2) (contains? cells k)))]
              [k (update-in cell [:age] inc)])))

-
-;; -----------------------------------------------------------------------------
-;; Update / Render Cycle
+(defn setup-gol! []
+  (swap! state assoc-in [:gui :cells] (create-cells acorn)))
+
+(defn teardown-gol! []
+  (swap! state assoc-in [:gui :cells] nil))
+
+
+;; -----------------------------------------------------------------------------
+;; Update / Render / Cycle

 (defn update! []
-  (swap! state update-in [:gui :generation] inc))
+  (swap! state update-in [:gui :generation] inc)
+  (swap! state update-in [:gui :cells] step))

 (defn render! [timestamp state]
   (let [app-name (get-in state [:app :name])
         env-time (get-in state [:env :time])
-        fps (get-in state [:env :frames-per-second])
+        f-count (str "F: " (get-in state [:env :frame-count]))
+        fps (str "FPS: " (get-in state [:env :frames-per-second]))
         mouse-move (get-in state [:env :mouse-move])
         mouse-x (:client-x mouse-move)
         mouse-y (:client-y mouse-move)
-        mouse-pos (str "[" mouse-x ":" mouse-y "]")
-        gen (get-in state [:gui :generation])
-        display [gen fps env-time timestamp mouse-pos]]
+        mouse-pos (str "M: [" mouse-x ":" mouse-y "]")
+        generation (str "G: " (get-in state [:gui :generation]))
+        population (str "P: " (count (get-in state [:gui :cells])))
+        display [f-count fps generation population]]
     (set! (.-innerText (app-div)) (string/join ", " display))))

-(defn on-env-animation-frame [timestamp]
+(defn cycle! [timestamp]
   (update!)
   (render! timestamp @state)
   (get-in @state [:app :rendering?]))
@@ -192,7 +208,7 @@
 (defn start-rendering! []
   (console/info "start rendering")
   (swap! state assoc-in [:app :rendering?] true)
-  (poly/listen-animation-frame! on-env-animation-frame))
+  (poly/listen-animation-frame! cycle!))

 (defn stop-rendering! []
   (console/info "stop rendering")


Fix compilation problem.

Fix compilation problem.

Can't create step parameter without default show or explicit metronome.

--- src/afterglow/examples.clj
+++ src/afterglow/examples.clj
@@ -345,10 +345,10 @@
                                   (cues/function-cue :snowball-sound :sound-active (show/fixtures-named "snowball")
                                                      :color :cyan)))

-(def step-param
-  "A step parameter for controlling example chase cuse. Redefine it to
-  experiment with other kinds of timing and fades."
-  (params/build-step-param :fade-fraction 0.3 :fade-curve :sine))
+(defonce ^{:doc "A step parameter for controlling example chase cues.
+  Change it to experiment with other kinds of timing and fades."}
+  step-param
+  (atom nil))

 (defn make-cues
   "Create a bunch of example cues for experimentation."
@@ -825,6 +825,9 @@
                :variables [{:key "position" :min -0.5 :max 10.5 :start 0.0 :name "Position"}]
                :color :purple))

+    ;; Set up an initial value for our step parameter
+    (reset! step-param (params/build-step-param :fade-fraction 0.3 :fade-curve :sine))
+
     (ct/set-cue!
      (:cue-grid *show*) 1 13
      (cues/cue :chase (fn [var-map]
@@ -833,7 +836,7 @@
                                    (global-color-effect :green :lights (show/fixtures-named "blade"))
                                    (global-color-effect :blue :lights (show/fixtures-named "hex"))
                                    (global-color-effect :white :lights (show/all-fixtures))]
-                                  step-param :beyond :loop))
+                                  @step-param :beyond :loop))
                :color :magenta))

     ;; Some compound cues


remove unused code

remove unused code

--- worker/src/worker/dispatch.cljs
+++ worker/src/worker/dispatch.cljs
@@ -35,6 +35,3 @@
 (defn run [f]
   (.unbounded-unshift tasks f)
   (queue-dispatcher))
-
-(defn queue-delay [f delay]
-  (js/setTimeout f delay))


guard against setting thread last-open for non-existant thread

--- src/chat/client/store.cljs
+++ src/chat/client/store.cljs
@@ -157,11 +157,12 @@
   (transact! [:new-thread-id] (fn [_] (uuid/make-random-squuid))))

 (defn update-thread-last-open-at [thread-id]
-  (let [latest-message (->> (get-in @app-state [:threads thread-id :messages])
-                            (map :created-at)
-                            (reduce max (js/Date. 0)))
-        new-last-open (js/Date. (inc (.getTime latest-message)))]
-    (transact! [:threads thread-id :last-open-at] (constantly new-last-open))))
+  (when-let [thread (get-in @app-state [:threads thread-id])]
+    (let [latest-message (->> (thread :messages)
+                              (map :created-at)
+                              (reduce max (js/Date. 0)))
+          new-last-open (js/Date. (inc (.getTime latest-message)))]
+      (transact! [:threads thread-id :last-open-at] (constantly new-last-open)))))

 (defn set-open-threads! [threads]
   (transact! [:threads] (constantly (key-by-id threads)))


First pass at making canon explore the full tree of code recursively.

--- src/clj/minijava/canon.clj
+++ src/clj/minijava/canon.clj
@@ -4,20 +4,22 @@
         clojure.contrib.seq)
   (:require [minijava.temp :as tm]))

+(declare canon)
+
 (defn remove-double-eseq
   "(ExpSeq s1 (ExpSeq s2 e)) -> [s1 s2 e]"
   [tree]
-  (let [s1 (get tree :seqs)
-        s2 (get-in tree [:exp :seqs])
-        e  (get-in tree [:exp :exp])]
+  (let [s1 (canon (:seqs tree ))
+        s2 (canon (get-in tree [:exp :seqs]))
+        e  (canon  (get-in tree [:exp :exp]))]
     (conj (vec (concat s1 s2))
           e)))

 (defn remove-eseq-left
   "(BinaryOp op (ExpSeq stmt expr) e2) -> [stmt (BinaryOp op expr e2)]"
-  [tree]
-  (let [stmt (get-in tree [:exp1 :seqs])
-        expr (get-in tree [:exp1 :exp])]
+  [tree]
+  (let [stmt (canon (get-in tree [:exp1 :seqs]))
+        expr (canon (get-in tree [:exp1 :exp]))]
     (conj (vec stmt)
           (merge tree [:exp1 expr]))))

@@ -27,9 +29,9 @@
 (defn remove-eseq-commute
   "(BinaryOp op e1 (ExpSeq s2 e2)) -> [s2 (BinaryOp op e1 e2)]"
   [tree]
-  (let [e1 (get tree :exp1)
-        s2 (get-in tree [:exp2 :seqs])
-        e2 (get-in tree [:exp2 :exp])]
+  (let [e1 (canon (get tree :exp1))
+        s2 (canon (get-in tree [:exp2 :seqs]))
+        e2 (canon (get-in tree [:exp2 :exp]))]
     (conj (vec s2)
           (merge tree [:exp2 e2]))))

@@ -37,9 +39,9 @@
   "(BinaryOp op e1 (ExpSeq s2 e2))
      -> [(Move e1 (Temp t)) s2 (BinaryOp op (Temp t e2))]"
   [tree]
-  (let [e1 (get tree :exp1)
-        s1 (get-in tree [:exp2 :seqs])
-        e2 (get-in tree [:exp2 :exp])
+  (let [e1 (canon (get tree :exp1))
+        s1 (canon (get-in tree [:exp2 :seqs]))
+        e2 (canon (get-in tree [:exp2 :exp]))
         t  (tm/temp)]
     (concat [(Move e1 (Temp t))]
             s1
@@ -135,24 +137,34 @@

 (defn canon
   "Converts a Seq to linear IR form."
-  [seqs]
-  (flatten
-   (for [s (:seqs seqs)]
-    (cond
-     (matches-eseq-left? s) (remove-eseq-left s)
-     (matches-double-eseq? s) (remove-double-eseq s)
-     (matches-eseq-commute? s)
-       (if (commutes? s)
-         (remove-eseq-commute s)
-         (remove-eseq-no-commute s))
-			;;If s contains Call as an argument, and s is NOT a move, then construct a new ESeq node moving the result of the call into the return value register.
-			;;Then recurse on the newly created node.
-		 (contains-call? s)
-				(reorganize-call s)
-     (isit? s :minijava.ir/Seq) (canon s)
-     (isit? s :minijava.ir/ExpSeq)
-       (list (canon (:seqs s)) (:exp s))
-     :else s))))
+  [s]
+	    (cond
+			 (matches-eseq-left? s) (remove-eseq-left s)
+			 (matches-double-eseq? s) (remove-double-eseq s)
+			 (matches-eseq-commute? s)
+			       (if (commutes? s)
+			         (remove-eseq-commute s)
+			         (remove-eseq-no-commute s))
+						;;If s contains Call as an argument, and s is NOT a move, then construct a new ESeq node moving the result of the call into the return value register.
+						;;Then recurse on the newly created node.
+					 (contains-call? s)
+							(reorganize-call s)
+		(= :minijava.ir/Seq (type s))
+				(flatten;;run canon on each element of the sequence
+					  (for [s (:seqs s)] (canon s)))
+		(= :minijava.ir/ExpSeq (type s)) ;;is this right?
+			   (list (canon (:seqs s)) (canon (:exp s)))
+		(= :minijava.ir/BinaryOp (type s))
+				(BinaryOp (:op s) (canon (:exp1 s))  (canon (:exp2 s)))
+		(= :minijava.ir/Conditional (type s))
+				(Conditional (:op s) (canon (:exp1 s))  (canon (:exp2 s)) (:t s) (:f s))
+		(= :minijava.ir/Call (type s))
+				(Call (:lbl s) (canon (:args s)))
+		(= :minijava.ir/Statement (type s))
+				(Statement (canon (:exp s)))
+		:else
+				s;;no changes or recursion needed for Consts, Jmps, NoOps,Temp, Name, etc
+))

 ;; BASIC BLOCKS


Partially complete call reorganization for canon. This isn't finished yet, but its getting there.

--- src/clj/minijava/canon.clj
+++ src/clj/minijava/canon.clj
@@ -82,6 +82,49 @@
   [a b]
   (or (isNop a) (isit? b :minijava.ir/Name) (isit? b :minijava.ir/Const)))

+(defn contains-call? [s]
+	(or (and  (= :minijava.ir/BinaryOp (type s)) ;;if either argument (or both) of a binop are calls
+						(or (= :minijava.ir/Call (type (:exp1 s)))  (= :minijava.ir/Call (type (:exp2 s))) ))
+ 			(and  (= :minijava.ir/ExpSeq (type s))
+						(= :minijava.ir/Call (type (:exp s)) ))
+ 			(and  (= :minijava.ir/Conditional (type s))
+						(= :minijava.ir/Call (type (:exp1 s)) ))
+ 			(and  (= :minijava.ir/Conditional (type s))
+						(= :minijava.ir/Call (type (:exp2 s)) ))
+ 			(and  (= :minijava.ir/Mem (type s))
+						(= :minijava.ir/Call (type (:adr s)) ))
+	)
+)
+
+(defn reorganize-call [s]
+	(cond (= :minijava.ir/BinaryOp (type s))
+					;;s is a binary op, and one or both arguments are calls
+					(let [arg1 (if (not (= :minijava.ir/Call (type (:exp1 s)))) (:exp1 s)
+											;;exp1 is a call, so wrap it in an eseq
+											(let [t (tm/temp)] (ExpSeq (Move (:exp1 s) t) t)))
+								arg2 (if (not (= :minijava.ir/Call (type (:exp2 s)))) (:exp2 s)
+											;;;exp2 is a call, so wrap it in an eseq
+											(let [t (tm/temp)] (ExpSeq (Move (:exp2 s) t) t)))]
+								(canon (BinaryOp (:op s) arg1 arg2)));;ok; now create a new binop with these arguments, and run canon on it
+				(= :minijava.ir/ExpSeq (type s))
+					;;s is an expseq, and its expression is a call
+					(canon (ExpSeq (:seqs s)
+								 (let [t (tm/temp)] (ExpSeq (Move (:exp s) t) t))))
+			(= :minijava.ir/Conditional (type s))
+							;;s is an conditional, and one or both arguments are calls
+							(let [arg1 (if (not (= :minijava.ir/Call (type (:exp1 s)))) (:exp1 s)
+											;;exp1 is a call, so wrap it in an eseq
+											(let [t (tm/temp)] (ExpSeq (Move (:exp1 s) t) t)))
+								arg2 (if (not (= :minijava.ir/Call (type (:exp2 s)))) (:exp2 s)
+											;;;exp2 is a call, so wrap it in an eseq
+											(let [t (tm/temp)] (ExpSeq (Move (:exp2 s) t) t)))]
+								(canon (Conditional (:op s) arg1 arg2 (:t s) (:f s))));;ok; now create a new binop with these arguments, and run canon on it
+			(= :minijava.ir/Mem (type s))
+					;;s is an Mem, and its adress is a call
+					(canon (Mem (let [t (tm/temp)] (ExpSeq (Move (:exp s) t) t))))
+
+				:else s
+))
 ;; commutes? s is whether the children of s commute (as opposed to
 ;; whether s commutes with something else.  s is assumed to have two
 ;; child functions here - other wise it wouldn't match the Eseq form so
@@ -102,6 +145,10 @@
        (if (commutes? s)
          (remove-eseq-commute s)
          (remove-eseq-no-commute s))
+			;;If s contains Call as an argument, and s is NOT a move, then construct a new ESeq node moving the result of the call into the return value register.
+			;;Then recurse on the newly created node.
+		 (contains-call? s)
+				(reorganize-call s)
      (isit? s :minijava.ir/Seq) (canon s)
      (isit? s :minijava.ir/ExpSeq)
        (list (canon (:seqs s)) (:exp s))


Pop implicit object arg as well.

Pop implicit object arg as well.

--- src/clj/minijava/munch.clj
+++ src/clj/minijava/munch.clj
@@ -159,7 +159,7 @@
       (emit (pushl f)))
     (emit (call (munch label)))
     (emit (movl (tm/temp :EAX) ret))
-    (emit (addl (CONST (* (count formals) 4)) (tm/temp :ESP)))
+    (emit (addl (CONST (* (inc (count formals)) 4)) (tm/temp :ESP)))
     ;; want to return the return value as a temp from this function.
     ;; liveness analysis will probably remove this movl instruction
     ;; later, but for now, thats what we'll do.  this depends upon the


Fix activated status on registration

Fix activated status on registration

--- src/clj/salava/user/db.clj
+++ src/clj/salava/user/db.clj
@@ -82,7 +82,7 @@
         (if (and activated (< mtime (- (unix-time) 86400)))
           {:status "error" :message "user/Passwordresetlinkexpired"}
           (do
-            (if (= primary_address 1)
+            (if (or (true? primary_address) (= primary_address 1))
               (do
                 (update-user-password-and-activate! {:pass (hash-password password) :id user-id} (get-db ctx))
                 (update-set-primary-email-address-verification-key-null! {:user_id user-id} (get-db ctx))
@@ -97,14 +97,14 @@
   "Check if user exists and password matches. User account must be activated. Email address must be user's primary address and verified."
   [ctx email plain-password]
   (try+
-    (let [{:keys [id pass activated verified primary_address]} (select-user-by-email-address {:email email} (into {:result-set-fn first} (get-db ctx)))]
-      (if (and id pass activated verified primary_address (check-password plain-password pass))
-        (do
-          (update-user-last_login! {:id id} (get-db ctx))
-          {:status "success" :id id})
-        {:status "error" :message  "user/Loginfailed"}))
-    (catch Object _
-      {:status "error" :message "user/Loginfailed"})))
+   (let [{:keys [id pass activated verified primary_address]} (select-user-by-email-address {:email email} (into {:result-set-fn first} (get-db ctx)))]
+     (if (and id pass activated verified primary_address (check-password plain-password pass))
+       (do
+         (update-user-last_login! {:id id} (get-db ctx))
+         {:status "success" :id id})
+       {:status "error" :message  "user/Loginfailed"}))
+   (catch Object _
+     {:status "error" :message "user/Loginfailed"})))

 (defn edit-user
   "Edit user information."


Extract unmanaged session mgmt from refreshing

--- src/clj/shale/sessions.clj
+++ src/clj/shale/sessions.clj
@@ -288,10 +288,10 @@
     (hset-all (session-capabilities-key id) capabilities)))

 (s/defn ^:always-validate save-session-diff-to-redis
+  "For any key present in the session arg, write that value to redis."
   [pool :- SessionPool
    id   :- s/Str
    session]
-  "For any key present in the session arg, write that value to redis."
   (car/wcar (:redis-conn pool)
     (hset-all
       (session-key id)
@@ -612,21 +612,18 @@
           (destroy-session pool id)))))
   true)

-(def ^:private  refresh-sessions-lock {})
-
-(s/defn ^:always-validate refresh-sessions
-  [pool :- SessionPool
-   ids  :- [s/Str]]
-  (locking refresh-sessions-lock
+(def ^:private unmanaged-session-lock {})
+
+(s/defn ^:always-validate destroy-unmanaged-sessions!
+  "Destroy any webdrivers on managed nodes without backing Redis records."
+  [pool :- SessionPool]
+  (locking unmanaged-session-lock
     (let [redis-conn (:redis-conn pool)
           node-pool (:node-pool pool)]
       (car/wcar redis-conn
-        (debug "Refreshing sessions...")
+        (debug "Destroying unmanaged sessions...")
         (car/watch session-set-key)
-        (doall
-          (pmap (partial refresh-session pool)
-                (or ids (view-model-ids pool))))
-        ; destroy any webdrivers on managed nodes that we don't have records for
+
         (let [known-webdrivers (->> (view-models pool)
                                     (map :webdriver-id)
                                     (into #{}))]
@@ -642,5 +639,17 @@
                                               (second %)
                                               (first %)
                                               false
-                                              nil))))))))
-    true))
+                                              nil))))))))))
+
+(s/defn ^:always-validate refresh-sessions
+  [pool :- SessionPool
+   ids  :- [s/Str]]
+  (let [redis-conn (:redis-conn pool)]
+    (car/wcar redis-conn
+              (debug "Refreshing sessions...")
+              (car/watch session-set-key)
+              (doall
+                (pmap (partial refresh-session pool)
+                      (or ids (view-model-ids pool))))
+              (destroy-unmanaged-sessions! pool)))
+  true)


Removing DataScript schema from util namespace #8

--- src/cljs/zetawar/data.cljs
+++ src/cljs/zetawar/data.cljs
@@ -1,41 +1,6 @@
 (ns zetawar.data)

-;; TODO: use components where appropriate
 ;; TODO: add unit/terrain
-(def schema
-  {:db/ident                     {:db/unique      :db.unique/identity}
-   :app/game                     {:db/valueType   :db.type/ref}
-   :game/id                      {:db/unique      :db.unique/identity}
-   :game/map                     {:db/valueType   :db.type/ref}
-   :game/factions                {:db/valueType   :db.type/ref
-                                  :db/cardinality :db.cardinality/many
-                                  :db/isComponent true}
-   :game/current-faction         {:db/valueType   :db.type/ref}
-   :faction/next-faction         {:db/valueType   :db.type/ref}
-   :faction/units                {:db/valueType   :db.type/ref
-                                  :db/cardinality :db.cardinality/many
-                                  :db/isComponent true
-                                  :db/index       true}
-   :unit/type                    {:db/valueType   :db.type/ref}
-   :unit/game-pos-idx            {:db/unique      :db.unique/identity}
-   :unit/attacked-units          {:db/valueType   :db.type/ref
-                                  :db/cardinality :db.cardinality/many}
-   :unit-type/id                 {:db/unique      :db.unique/identity}
-   :unit-type/name               {:db/unique      :db.unique/identity}
-   :map/starting-faction         {:db/valueType   :db.type/ref}
-   :map/terrains                 {:db/valueType   :db.type/ref
-                                  :db/cardinality :db.cardinality/many
-                                  :db/isComponent true}
-   :terrain/owner                {:db/valueType   :db.type/ref}
-   :terrain/type                 {:db/valueType   :db.type/ref}
-   :terrain/game-pos-idx         {:db/unique      :db.unique/identity}
-   :terrain-type/id              {:db/unique      :db.unique/identity}
-   :terrain-type/name            {:db/unique      :db.unique/identity}
-   :unit-strength/unit-type      {:db/valueType   :db.type/ref}
-   :terrain-effect/unit-type     {:db/valueType   :db.type/ref
-                                  :db/index       true}
-   :terrain-effect/terrain-type  {:db/valueType   :db.type/ref
-                                  :db/index       true}})

 (def terrains
   {:plains        {:name "Plains"


Get vault config path from environment.

Get vault config path from environment.

--- tool/vault/system.clj
+++ tool/vault/system.clj
@@ -7,6 +7,7 @@
     [clojure.repl :refer :all]
     [clojure.string :as str]
     [clojure.tools.namespace.repl :refer [refresh]]
+    [environ.core :refer [env]]
     (puget
       [data]
       [printer :as puget])
@@ -21,14 +22,14 @@

 ;; GENERAL CONFIG

-(puget.data/extend-tagged-map vault.blob.store.Blob 'vault.repl/blob)
+(puget.data/extend-tagged-map vault.blob.store.Blob 'vault.tool/blob)

 ;; VAULT SYSTEM

 (def config
-  (config/load-configs "dev/config"))
+  (config/load-configs (env :vault-config "dev/config")))

 (def blobs


removed unnecessary prints

removed unnecessary prints

--- src/frontend/renderer.cljs
+++ src/frontend/renderer.cljs
@@ -74,8 +74,6 @@
 (defn user-upload-progress [data]
   (let [upload (first data)
         upload-info (second data)]
-    (println "UPLOADERID" (js->clj upload-info))
-    (println ((:users @app-state/app-state) (.-uploaderid upload-info)) "NAMEQ")
     (dom/div #js {:className "track-view"}
              (when-not (nil? upload)
                (dom/button #js {:onClick #(core/cancel-upload (.-id upload-info))}       "CANCEL")


:fire: Remove commented code.

:fire: Remove commented code.

--- frontend/src/uxbox/main/data/workspace.cljs
+++ frontend/src/uxbox/main/data/workspace.cljs
@@ -202,7 +202,6 @@
         user (if (string? (:color user))
                user
                (assoc user :color color))]
-    (prn "assign-user-color" user-id)
     (assoc-in state [:workspace-users :by-id user-id] user)))

 (defn handle-who
@@ -211,7 +210,6 @@
   (ptk/reify ::handle-who
     ptk/UpdateEvent
     (update [_ state]
-      (prn "handle-who" users)
       (as-> state $$
         (assoc-in $$ [:workspace-users :active] users)
         (reduce assign-user-color $$ users)))))
@@ -234,7 +232,6 @@
     (watch [_ state stream]
       (let [local (:workspace-local state)]
         (when (= (:page-id local) page-id)
-          (prn "handle-page-snapshot" msg)
           (rx/of (shapes-changes-commited msg)))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -989,7 +986,6 @@
                     :version (:version page)
                     :operations operations}]
         (->> (rp/mutation :update-project-page params)
-             (rx/tap #(prn "KAKAKAKA" %))
              (rx/map shapes-changes-commited))))))

 (s/def ::shapes-changes-commited
@@ -997,7 +993,6 @@

 (defn shapes-changes-commited
   [{:keys [page-id version operations] :as params}]
-  (prn "shapes-changes-commited" params)
   (s/assert ::shapes-changes-commited params)
   (ptk/reify ::shapes-changes-commited
     ptk/UpdateEvent


:tada: Auto select pasted objects

:tada: Auto select pasted objects

--- frontend/src/uxbox/main/data/workspace.cljs
+++ frontend/src/uxbox/main/data/workspace.cljs
@@ -2056,6 +2056,8 @@
                (rx/ignore)))))))

+(declare select-pasted-objs)
+
 (defn- paste-impl
   [{:keys [selected objects] :as data}]
   (letfn [(prepare-changes [state delta]
@@ -2129,7 +2131,8 @@
                           rchanges)]
         (rx/of (commit-changes (vec rchanges)
                                (vec (reverse uchanges))
-                               {:commit-local? true})))))))
+                               {:commit-local? true})
+               (select-pasted-objs rchanges)))))))

 (def paste
   (ptk/reify ::paste
@@ -2144,6 +2147,13 @@
                        (js/console.error "Clipboard blocked:" err)
                        (rx/empty)))))))

+(defn select-pasted-objs
+  [rchanges]
+  (ptk/reify ::select-pasted-objs
+    ptk/UpdateEvent
+    (update [_ state]
+      (assoc-in state [:workspace-local :selected]
+                (map #(get-in % [:obj :id]) rchanges)))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Page Changes Reactions


:lipstick: Minor improvements on text edition shape.

--- frontend/src/uxbox/main/ui/shapes/text.cljs
+++ frontend/src/uxbox/main/ui/shapes/text.cljs
@@ -99,7 +99,8 @@
        :fontStyle font-style
        :margin "0px"
        :padding "0px"
-       :border "0px"}
+       :border "0px"
+       :resize "none"}
       (when user-select {:userSelect "auto"})
       (when line-height {:lineHeight line-height})
       (when letter-spacing {:letterSpacing letter-spacing})))))


Update resource.clj

Update resource.clj

--- src/iyye/bios/resource.clj
+++ src/iyye/bios/resource.clj
@@ -70,8 +70,8 @@

 (def num-days (ref 0))

-(defrecord DayRoutine [day-start day-time threshold function task-future])
-(defrecord NightRoutine [day night-start night-time threshold function task-future])
+(defrecord DayRoutine [name day-start day-time threshold function task-future parent])
+(defrecord NightRoutine [name day night-start night-time threshold function task-future parent])

 (def awake-or-sleep (ref false))
 (defn is-awake? [] @awake-or-sleep)
@@ -82,10 +82,10 @@
 (def DAY_THRESHOLD 0.1)

 (defn create-day []
-  (DayRoutine. (System/currentTimeMillis) DAY_TIME DAY_THRESHOLD #(Thread/sleep 1000) (ref 0)))
+  (DayRoutine. "iyye.bios.day-task" (System/currentTimeMillis) DAY_TIME DAY_THRESHOLD #(Thread/sleep 1000) (ref 0) "iyye.bios.main" ))

 (defn create-night [day]
-  (NightRoutine. day (System/currentTimeMillis) DAY_TIME DAY_THRESHOLD #(Thread/sleep 1000) (ref 0)))
+  (NightRoutine. "iyye.bios.night-task" day (System/currentTimeMillis) DAY_TIME DAY_THRESHOLD #(Thread/sleep 1000) (ref 0) "iyye.bios.main" ))

 (defn start-day [day]
   (doall


cleaned up contains-options?

cleaned up contains-options?

--- src/karras/spec_parser.clj
+++ src/karras/spec_parser.clj
@@ -6,8 +6,10 @@
 (defn filter-spec [f spec]
   (filter f (partition 2 spec)))

-(defn contains-option? [attr kw]
-  (contains? (attr-options attr) kw))
+(defn contains-options? [attr & keywords]
+  (let [options (attr-options attr)]
+    (reduce #(and %1 (contains? options %2))
+            keywords)))

 (defn required-attrs [spec]
   (filter-spec #(= :required (:type (attr-options %)))
@@ -18,23 +20,22 @@
                spec))

 (defn pair-attrs [spec]
-  (filter-spec #(and (not (contains-option? % :enums))
-                     (not (contains-option? % :type)))
+  (filter-spec #(not (contains-options? % :enums :type))
                spec))

 (defn attrs-with-defaults [spec]
-  (filter-spec #(contains-option? % :default)
+  (filter-spec #(contains-options? % :default)
               spec))

-(defn pair-field? [spec token]
+(defn pair-field [spec token]
   (some #(if (= token (attr-name %)) %) (pair-attrs spec)))

-(defn enum-field? [spec token]
+(defn enum-field [spec token]
   (some #(if (contains? (:enums (attr-options %)) token) %)
         (enum-attrs spec)))

 (defn enum-name [spec val]
-  (attr-name (get-enum val spec)))
+  (attr-name (enum-field spec val)))

 (defn parse-pair [spec parsed key [value & tail]]
   [(assoc parsed key value) tail])
@@ -47,8 +48,8 @@
   [parsed tail])

 (defn choose-parser [spec token]
-  (cond (pair-field? spec token) parse-pair
-        (enum-field? spec token) parse-enum
+  (cond (pair-field spec token) parse-pair
+        (enum-field spec token) parse-enum
         :default parse-ignore))

 (defn parse-options [spec item init-results init-unparsed]
@@ -82,20 +83,19 @@
 (defn parse-items [spec items]
   (map #(parse-item spec %) items))

-(comment
-  (def demographic-spec
-       [:name {:type :required}
-        :age  {:type :required}
-        :gender {:enums #{:male :female}}])
+(def demographic-spec
+     [:name {:type :required}
+      :age  {:type :required}
+      :gender {:enums #{:male :female}}])

-  (def dick ["dick" 1 :male  ])
-  (def jane ["jane" 1 :female])
+(def dick ["dick" 1 :male  ])
+(def jane ["jane" 1 :female])

-  (asert (= (parse-item demographic-spec dick)
-            {:gender :male, :age 1, :name "dick"}))
+(assert (= (parse-item demographic-spec dick)
+           {:gender :male, :age 1, :name "dick"}))

-  (assert (= (parse-items demographic-spec [dick jane])
-             [{:gender :male, :age 1, :name "dick"}
-              {:gender :female, :age 1, :name "jane"}])))
+(assert (= (parse-items demographic-spec [dick jane])
+           [{:gender :male, :age 1, :name "dick"}
+            {:gender :female, :age 1, :name "jane"}]))


CMR-6138: Deleted force indexing test as it is no longer supported in ES 7.5.2

--- system-int-test/test/cmr/system_int_test/search/acls/collection.clj
+++ system-int-test/test/cmr/system_int_test/search/acls/collection.clj
@@ -390,31 +390,7 @@
       (index/wait-until-indexed)

       ;; Search after reindexing
-      (d/assert-refs-match [coll1 coll2-2 coll4] (search/find-refs :collection {})))
-
-    ;; Tests reindexing using the force current version option
-    (testing "Force version reindex all collections"
-      ;; Verify we can find coll2 with the lastest data
-      (d/assert-refs-match [coll2-2] (search/find-refs :collection {:short-name "short2"}))
-
-      ;; Delete the latest version of coll2
-      (is (= 200 (:status (mdb/force-delete-concept (:concept-id coll2-2) 2 true))))
-      (index/wait-until-indexed)
-
-      ;; After deleting the latest version of coll2 we will still find that.
-      (d/assert-refs-match [coll2-2] (search/find-refs :collection {:short-name "short2"}))
-
-      ;; Reindexing all the collections doesn't solve the problem
-      (ingest/reindex-all-collections)
-      (index/wait-until-indexed)
-      (d/assert-refs-match [coll2-2] (search/find-refs :collection {:short-name "short2"}))
-
-      ;; A force reindex all collections will make elastic take the earlier version of the
-      ;; collections.
-      (ingest/reindex-all-collections {:force-version false})
-      (index/wait-until-indexed)
-      (d/assert-refs-match [] (search/find-refs :collection {:short-name "short2"}))
-      (d/assert-refs-match [coll2-1] (search/find-refs :collection {:short-name "short1"})))))
+      (d/assert-refs-match [coll1 coll2-2 coll4] (search/find-refs :collection {})))))

 ;; Verifies that tokens are cached by checking that a logged out token still works after it was
 ;; used. This isn't the desired behavior. It's just a side effect that shows it's working.


More work on populating the amp directory

--- src/leiningen/amp/impl.clj
+++ src/leiningen/amp/impl.clj
@@ -13,23 +13,47 @@
   (:require [clojure.java.io   :as io]
             [leiningen.uberjar :as uj]))

+(def ^:private default-web-resources "web-resources")
+(def ^:private default-amp-resources "amp-resources")
+
 (defn package-amp!
   [project args]
-  (let [target       (io/file (:target-path project))
-        amp-file     (io/file target
-                              (or (get-in project [:amp :name])
-                                  (str (:name project) "-" (:version project) ".amp")))
-        _            (println "#### STEP 1: Construct uberjar...")
-        uberjar-file (uj/uberjar project)
-        _            (println "#### uberjar =" uberjar-file)]
+  (let [project-home       (io/file (:root project))
+        web-resources      (io/file project-home (:web-resource-path project default-web-resources))
+        amp-resources-name (:amp-resource-path project default-amp-resources)
+        module-properties  (io/file project-home (str amp-resources-name "/module.properties"))
+        file-mappings      (io/file project-home (str amp-resources-name "/file-mapping.properties"))
+        target             (io/file (:target-path project))
+        amp-file           (io/file target
+                                    (or (get-in project [:amp :name])
+                                        (str (:name project) "-" (:version project) ".amp")))
+        _                  (println "#### STEP 1: Construct uberjar...")
+        uberjar-file       (io/file (uj/uberjar project))
+        _                  (println "#### uberjar =" uberjar-file)
+        amp                (io/file target "amp/.")
+        amp-config         (io/file target "amp/config/.")
+        amp-lib            (io/file target "amp/lib/.")
+        amp-licenses       (io/file target "amp/licenses/.")
+        amp-web            (io/file target "amp/web/.")]

     (println "#### STEP 2: Create AMP directory structure...")
-    (io/make-parents (io/file target "amp/config/."))   ; Note: the final "." is needed as make-parents doesn't create the final path element as a directory
-    (io/make-parents (io/file target "amp/lib/."))
-    (io/make-parents (io/file target "amp/licenses/."))
-    (io/make-parents (io/file target "amp/web/."))
+    (io/make-parents amp)
+    (io/make-parents amp-config)
+    (io/make-parents amp-lib)
+    (io/make-parents amp-licenses)
+    (io/make-parents amp-web)

     (println "#### STEP 3: Populate AMP directory structure...")
+    (if (.exists ^java.io.File module-properties)
+      (io/copy module-properties (io/file amp (.getName ^java.io.File module-properties)))
+      (throw (RuntimeException. "Module doesn't have a module.properties file.")))    ;####TODO: Make this more pleasant
+
+    (if (.exists ^java.io.File file-mappings)
+      (io/copy file-mappings (io/file amp (.getName ^java.io.File file-mappings))))
+
+    (if (.exists ^java.io.File uberjar-file)
+      (io/copy uberjar-file (io/file amp-lib (.getName ^java.io.File uberjar-file))))
+
     ;####TODO!!!!

     (println "#### STEP 4: Create AMP..." amp-file)


Clean out previous builds (if any)

Clean out previous builds (if any)

--- src/leiningen/amp/impl.clj
+++ src/leiningen/amp/impl.clj
@@ -140,6 +140,10 @@
                                         (or (get-in project [:amp-name])
                                             (str (:name project) "-" (:version project) ".amp")))]

+    ; Cleanup anything left from a prior build
+    (if (fexists tgt-amp)
+      (fs/delete-dir tgt-amp))
+
     ; ${AMP}/
     (mkdir-p tgt-amp)
     (write-module-properties! tgt-module-properties module-properties)


[#672] Updated doc string on  to better reflect code

--- backend/src/akvo/lumen/import/csv.clj
+++ backend/src/akvo/lumen/import/csv.clj
@@ -9,11 +9,12 @@

 (defn transform-value
   "Transforms the given value according to its associated type label.
+  Blank strings are cast to nil.
   Numeric strings are cast to numbers, only if the type label matches."
-  [[value type-label]]
+  [[value psql-type]]
   (cond
     (string/blank? value) nil
-    (and (string/numeric? value) (= "double precision" type-label)) (Double/parseDouble value)
+    (and (string/numeric? value) (= "double precision" psql-type)) (Double/parseDouble value)
     :else value))

 (defn transform-rows


Update update.clj

Update update.clj

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -49,8 +49,7 @@
                                      :reason [reason]}))

 (defn- apply-transformation-log [conn table-name importer-columns original-dataset-columns last-transformations dataset-id version]
-  (let [importer-columns (mapv (fn [{:keys [title id type key caddisflyResourceUuid
-                                            multiple-id multiple-type] :as column}]
+  (let [importer-columns (mapv (fn [{:keys [title id type key multiple-id multiple-type] :as column}]
                                  (cond-> {"type" (name type)
                                           "title" title
                                           "columnName" (name id)


fix bad example

fix bad example

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -790,9 +790,9 @@
       (println res)))

   (cljs/compile st "(defprotocol IFoo (foo [this]))"
-    (fn [js-source]
+    (fn [{:keys [value]}]
       (println "Source:")
-      (println js-source)))
+      (println value)))

   (cljs/eval-str st
     "(defn foo [a b] (+ a b))


adding logs with macros

adding logs with macros

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -12,8 +12,12 @@
 (defmacro report
   [body]
   `(let [result# ~body]
-     (println (expension-report ~body) "is" result#)
+     (println (expension-report ~body) "=>" result#)
      ))
+
+(defmacro constexpr
+  [fct & args]
+  (eval `(~fct ~@args)))

 ;; --------------------------------------------------------
 ;; Example 1: equivalent with constexpr
@@ -37,8 +41,12 @@
 (defmacro add-m-3
   "Summing two integers known at compile time"
   [a b]
-  ;; TODO - How to get rid of eval???
+  ;; TODO - How to get rid of eval??? constexpr
   (eval `(+ ~a ~b)))
+
+(defmacro add-m-4
+  [a b]
+  `(constexpr add ~a ~b))

 (defn test-add
   []
@@ -59,6 +67,7 @@
     ;; (println (add-m (x1) (x2)))
     (report (add-m-2 (x1) (x2)))
     (report (add-m-3 (x1) (x2)))
+    (report (add-m-4 (x1) (x2)))
     ))

@@ -75,18 +84,17 @@
 (defmacro average-m
   "Average of numbers known at compile time"
   [coll]
-  ;; TODO - How to get rid of eval???
-  (eval `(average ~coll)))
+  `(constexpr average ~coll))

 (defn test-average
   []
-  (let [coll [1 2 3]]
+  (let [coll [1 2 3 4]]
     (report (average coll))
     ;; (println (average-m coll)) ;; Would not compile
-    (report (average-m [1 2 3]))
+    (report (average-m [1 2 3 4]))

     ;; This however works
-    (defmacro coll-m [] [1 2 3])
+    (defmacro coll-m [] [1 2 3 4])
     (report (average-m (coll-m)))
     ))

@@ -107,8 +115,7 @@

 (defmacro freq-map-m
   [coll]
-  ;; TODO - How to get rid of eval???
-  (eval `(freq-map ~coll)))
+  `(constexpr freq-map ~coll))

 (defn test-freq-map
   []
@@ -143,6 +150,7 @@

 ;; --------------------------------------------------------
 ;; Example 3-b: repeat a side-effectful call N times
+;; - This time, we add the argument in the call
 ;; --------------------------------------------------------

 (defmacro times
@@ -179,6 +187,25 @@
 ;; Example 4-a: Adding logs around functions
 ;; --------------------------------------------------------

+(defmacro defn-log
+  [name bindings body]
+  `(defn ~name
+     ~bindings
+     (println "Entering the function with args:" ~@bindings)
+     ~body))
+
+(defn-log add-log
+  [a b]
+  (+ a b))
+
+(defn test-add-log
+  []
+  (add-log 1 2))
+
+;; --------------------------------------------------------
+;; Example 4-b: Adding logs based on run time option (no overhead)
+;; --------------------------------------------------------
+
 ;; TODO

 ;; --------------------------------------------------------
@@ -186,7 +213,6 @@
 ;; --------------------------------------------------------

 ;; TODO
-

 ;; --------------------------------------------------------
 ;; Example 5: Generating some code based on data structure


4clojure: fixed the HOF version of GCD: dont forget to call recursive within the reduce inner function

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -969,16 +969,17 @@
         smallest-divisibles (filter (partial divisible? smallest) (range 1 (inc smallest)))]
      (letfn [(find-gcds
                  [possible-divisibles xs]
-                   (reduce (fn [sm-div each]
-                      (if (divisible? each (last sm-div))
-                        sm-div
-                        (butlast sm-div)))
+                   (reduce (fn rec-find [sm-div each]
+                              (if (divisible? each (last sm-div))
+                                    sm-div
+                                   (recur (butlast sm-div) each)))
                     possible-divisibles xs))]
        (last (find-gcds smallest-divisibles nums)))))

 ;; demo:
 (gcd 3 5 9) ;1
 (gcd 8 12) ;4
+(gcd 1023 858) ; 33

 ;; tries:
 (seq [1]) ;(1)
@@ -997,13 +998,13 @@
                         (find-gcd-rec min-nums (rest tail-nums))
                         (find-gcd-rec (butlast min-nums) tail-nums))
                     (last min-nums)))]
-
     ;; invoke recursive func
     (find-gcd-rec min-num-divisibles nums))))

 ;; demo:
 (gcd 3 5 9) ;1
 (gcd 8 12) ;4
+(gcd 1023 858) ; 33

 ;; tries:
@@ -1015,3 +1016,10 @@
 ;; another way of writing core [iterate] without the literal func, but using partial
 ;; that returns the curried back having the curried take one argument.
 (iterate (partial inc) 1) ; (1 2 3 4 ...)
+
+;; alin's solution to this:
+(fn gcd [a b]
+	(if (< a b)
+		(recur b a)
+		(first (filter #(= 0 (rem a %) (rem b %)) (iterate dec b)))))
+


Hopefully this is the correct solution to problem in previous commit

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

 (defn scan-all-votes-after [url hosts first-index cycle-number cycle-type]


Oops, wanted a ref, not an atom.

Oops, wanted a ref, not an atom.

--- src/net/dishevelled/mailindex/fieldpool.clj
+++ src/net/dishevelled/mailindex/fieldpool.clj
@@ -1,7 +1,7 @@
 (ns net.dishevelled.mailindex.fieldpool
   (:import (org.apache.lucene.document Field Field$Store Field$Index)))

-(def *field-pools* (atom {}))
+(def *field-pools* (ref {}))

 (defn- new-pool [name store tokenize]
   "Create a new pool of Field objects for a given field type."
@@ -19,8 +19,9 @@

 (defn- make-field [name store tokenize]
   "Return a new field object."
-  (when-not (@*field-pools* name)
-    (swap! *field-pools* assoc name (new-pool name store tokenize)))
+  (dosync
+   (when-not (@*field-pools* name)
+     (alter *field-pools* assoc name (new-pool name store tokenize))))

   (next-field (@*field-pools* name)))


Return created-at/modified-at metadata with coordinate.

--- src/onyx/log/zookeeper.clj
+++ src/onyx/log/zookeeper.clj
@@ -708,8 +708,12 @@
     #(clean-up-broken-connections
       (fn []
         (let [node (latest-checkpoint-path tenancy-id job-id)
-              coordinate (zookeeper-decompress (:data (zk/data conn node)))]
-          coordinate)))
+              data (zk/data conn node)
+              coordinate (zookeeper-decompress (:data data))]
+          (if coordinate
+            (assoc coordinate
+                   :modified-at (:mtime (:stat data))
+                   :created-at (:ctime (:stat data)))))))
     #(let [args {:event :zookeeper-read-checkpoint-coordinate :id job-id :latency %}]
        (extensions/emit monitoring args))))


Correctly seek directly to origin position on bad log read.

--- src/onyx/log/zookeeper.clj
+++ src/onyx/log/zookeeper.clj
@@ -244,12 +244,32 @@
   (try
     (let [entry (extensions/read-log-entry log position)]
       (assert entry)
-      (>!! ch entry))
+      (>!! ch entry)
+      (inc position))
     (catch KeeperException$NoNodeException e
       (seek-to-new-origin! log ch))
     (catch KeeperException$NodeExistsException e
       (seek-to-new-origin! log ch))))

+(defn await-entry! [{:keys [conn opts prefix kill-ch] :as log} ch path position]
+  (loop []
+    (let [read-ch (chan 2)]
+      (zk/children conn (log-path prefix) :watcher (fn [_] (offer! read-ch true)))
+      ;; Log entry may have been added in between initial check and when we
+      ;; added the watch.
+      (when (zk/exists conn path)
+        (offer! read-ch true))
+      (let [[_ active-ch] (alts!! [read-ch kill-ch])]
+        (cond (= active-ch kill-ch)
+              :killed
+              (= active-ch read-ch)
+              (do
+               (close! read-ch)
+               ;; Requires one more check. Watch may have been triggered by a delete
+               ;; from a GC call.
+               (if (zk/exists conn path)
+                 (seek-and-put-entry! log position ch)
+                 (recur))))))))

 (defmethod extensions/subscribe-to-log ZooKeeper
   [{:keys [conn opts prefix kill-ch] :as log} ch]
@@ -263,25 +283,13 @@
          (>!! rets (merge (:replica origin) log-parameters))
          (close! rets)
          (loop [position starting-position]
-           (let [path (str (log-path prefix) "/entry-" (pad-sequential-id position))]
-             (if (zk/exists conn path)
-               (seek-and-put-entry! log position ch)
-               (loop []
-                 (let [read-ch (chan 2)]
-                   (zk/children conn (log-path prefix) :watcher (fn [_] (offer! read-ch true)))
-                   ;; Log entry may have been added in between initial check and when we
-                   ;; added the watch.
-                   (when (zk/exists conn path)
-                     (offer! read-ch true))
-                   (let [[_ active-ch] (alts!! [read-ch kill-ch])]
-                     (when (= active-ch read-ch)
-                       (close! read-ch)
-                       ;; Requires one more check. Watch may have been triggered by a delete
-                       ;; from a GC call.
-                       (if (zk/exists conn path)
-                         (seek-and-put-entry! log position ch)
-                         (recur)))))))
-             (recur (inc position)))))
+           (let [path (str (log-path prefix) "/entry-" (pad-sequential-id position))
+                 new-position (if (zk/exists conn path)
+                                (seek-and-put-entry! log position ch)
+                                (await-entry! log ch path position))]
+             (when-not (= new-position :killed)
+               (assert (integer? new-position) new-position)
+               (recur new-position)))))
        (catch java.lang.IllegalStateException e
          (trace e)
          ;; Curator client has been shutdown, pass exception along


Fix queue bootstrapping.

Fix queue bootstrapping.

--- src/onyx/queue/hornetq.clj
+++ src/onyx/queue/hornetq.clj
@@ -230,7 +230,7 @@
 (defmethod extensions/bootstrap-queue HornetQConnection
   [queue task]
   (let [session (extensions/create-tx-session queue)
-        producer (extensions/create-producer queue session (:ingress-queues task))]
+        producer (extensions/create-producer queue session (:self (:ingress-queues task)))]
     (extensions/produce-message queue producer session (.array (fressian/write {})))
     (extensions/produce-message queue producer session (.array (fressian/write :done)))
     (extensions/commit-tx queue session)


Recover the 2arity forms for task bundles

--- src/onyx/tasks/datomic.clj
+++ src/onyx/tasks/datomic.clj
@@ -1,28 +1,47 @@
 (ns onyx.tasks.datomic
   (:require [schema.core :as s]
-            [onyx.schema :as os]
-            [taoensso.timbre :refer [info debug fatal]]))
-
-;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;
-;; task schemas
+            [onyx.schema :as os]))

 (def UserTaskMapKey
   (os/build-allowed-key-ns :datomic))

+
 (def DatomicReadLogTaskMap
-  (s/->Both [os/TaskMap
-             {:datomic/uri s/Str
+  (s/->Both [os/TaskMap
+             {:datomic/uri (s/pred (fn [s]
+                                     (let [[_ type] (clojure.string/split s #":")]
+                                       (not= "mem" type)))
+                                   "not using in-memory datomic")
+              :checkpoint/force-reset? s/Bool
               (s/optional-key :datomic/log-start-tx) s/Int
               (s/optional-key :datomic/log-end-tx) s/Int
               (s/optional-key :checkpoint/key) s/Str
-              :checkpoint/force-reset? s/Bool
               (s/optional-key :onyx/max-peers) (s/enum 1)
               (s/optional-key :onyx/n-peers) (s/enum 1)
               UserTaskMapKey s/Any}]))

+(s/defn ^:always-validate read-log
+  ([task-name :- s/Keyword opts]
+   {:task {:task-map (merge {:onyx/name task-name
+                             :onyx/plugin :onyx.plugin.datomic/read-log
+                             :onyx/type :input
+                             :onyx/medium :datomic
+                             }
+                            opts)
+           :lifecycles [{:lifecycle/task task-name
+                         :lifecycle/calls :onyx.plugin.datomic/read-log-calls}]}
+    :schema {:task-map DatomicReadLogTaskMap
+             :lifecycles [os/Lifecycle]}})
+  ([task-name :- s/Keyword
+    uri :- s/Str
+    force-reset? :- s/Bool
+    task-opts :- {s/Any s/Any}]
+   (read-log task-name (merge {:datomic/uri uri
+                               :checkpoint/force-reset? force-reset?}
+                              task-opts))))
+
 (def DatomicReadDatomsTaskMap
-  (s/->Both [os/TaskMap
+  (s/->Both [os/TaskMap
              {:datomic/uri s/Str
               :datomic/t s/Int
               :datomic/datoms-index s/Keyword
@@ -32,9 +51,32 @@
               (s/optional-key :onyx/n-peers) (s/enum 1)
               UserTaskMapKey s/Any}]))

+(s/defn ^:always-validate read-datoms
+  ([task-name :- s/Keyword opts]
+   {:task {:task-map (merge {:onyx/name task-name
+                             :onyx/plugin :onyx.plugin.datomic/read-datoms
+                             :onyx/type :input
+                             :onyx/medium :datomic}
+                            opts)
+           :lifecycles [{:lifecycle/task task-name
+                         :lifecycle/calls :onyx.plugin.datomic/read-datoms-calls}]}
+    :schema {:task-map DatomicReadDatomsTaskMap
+             :lifecycles [os/Lifecycle]}})
+  ([task-name :- s/Keyword
+    uri :- s/Str
+    t :- s/Int
+    datoms-index :- s/Keyword
+    datoms-per-segment :- s/Int
+    task-opts :- {s/Any s/Any}]
+   (read-datoms task-name
+                (merge {:datomic/uri uri
+                        :datomic/t t
+                        :datomic/datoms-index datoms-index
+                        :datomic/datoms-per-segment datoms-per-segment}
+                       task-opts))))

 (def DatomicReadIndexRangeTaskMap
-  (s/->Both [os/TaskMap
+  (s/->Both [os/TaskMap
              {:datomic/uri s/Str
               :datomic/t s/Int
               :datomic/index-attribute s/Any
@@ -45,78 +87,71 @@
               (s/optional-key :onyx/n-peers) (s/enum 1)
               UserTaskMapKey s/Any}]))

+(s/defn ^:always-validate read-index-range
+  ([task-name :- s/Keyword opts]
+   {:task {:task-map (merge {:onyx/name task-name
+                             :onyx/plugin :onyx.plugin.datomic/read-index-range
+                             :onyx/type :input
+                             :onyx/medium :datomic}
+                            opts)
+           :lifecycles [{:lifecycle/task task-name
+                         :lifecycle/calls :onyx.plugin.datomic/read-index-range-calls}]}
+    :schema {:task-map DatomicReadIndexRangeTaskMap
+             :lifecycles [os/Lifecycle]}})
+  ([task-name :- s/Keyword
+    uri :- s/Str
+    t :- s/Int
+    index-attribute :- s/Any
+    index-range-start :- s/Any
+    index-range-end :- s/Any
+    datoms-per-segment :- s/Int
+    task-opts :- {s/Any s/Any}]
+   (read-index-range task-name (merge {:datomic/uri uri
+                                       :datomic/t t
+                                       :datomic/index-attribute index-attribute
+                                       :datomic/index-range-start index-range-start
+                                       :datomic/index-range-end index-range-end
+                                       :datomic/datoms-per-segment datoms-per-segment}
+                                      task-opts))))
+
 (def DatomicWriteDatomsTaskMap
-  (s/->Both [os/TaskMap
+  (s/->Both [os/TaskMap
              {:datomic/uri s/Str
               (s/optional-key :datomic/partition) (s/either s/Int s/Keyword)
+              (s/optional-key :onyx/max-peers) (s/enum 1)
+              (s/optional-key :onyx/n-peers) (s/enum 1)
               UserTaskMapKey s/Any}]))

-(s/defn read-log
-  [task-name :- s/Keyword opts]
-  {:task {:task-map (merge {:onyx/name task-name
-                            :onyx/plugin :onyx.plugin.datomic/read-log
-                            :onyx/type :input
-                            :onyx/medium :datomic
-                            :onyx/max-peers 1
-                            :onyx/doc "Reads a sequence of datoms from the d/log API"}
-                           opts)
-          :lifecycles [{:lifecycle/task task-name
-                        :lifecycle/calls :onyx.plugin.datomic/read-log-calls}]}
-   :schema {:task-map (merge os/TaskMap DatomicReadLogTaskMap)
-            :lifecycles [os/Lifecycle]}})
+(s/defn ^:always-validate write-bulk-tx-datoms
+  ([task-name :- s/Keyword opts]
+   {:task {:task-map (merge {:onyx/name task-name
+                             :onyx/plugin :onyx.plugin.datomic/write-bulk-datoms
+                             :onyx/type :output
+                             :onyx/medium :datomic}
+                            opts)
+           :lifecycles [{:lifecycle/task task-name
+                         :lifecycle/calls :onyx.plugin.datomic/write-bulk-tx-calls}]}
+    :schema {:task-map DatomicWriteDatomsTaskMap
+             :lifecycles [os/Lifecycle]}})
+  ([task-name :- s/Keyword
+    uri :- s/Str
+    task-opts :- {s/Any s/Any}]
+   (write-bulk-tx-datoms task-name (merge {:datomic/uri uri}
+                                          task-opts))))

-(s/defn read-datoms
-  [task-name :- s/Keyword opts]
-  {:task {:task-map (merge {:onyx/name task-name
-                            :onyx/plugin :onyx.plugin.datomic/read-datoms
-                            :onyx/type :input
-                            :onyx/medium :datomic
-                            :datomic/datoms-per-segment 20
-                            :onyx/max-peers 1
-                            :onyx/doc "Reads a sequence of datoms from the d/log API"}
-                           opts)
-          :lifecycles [{:lifecycle/task task-name
-                        :lifecycle/calls :onyx.plugin.datomic/read-datoms-calls}]}
-   :schema {:task-map (merge os/TaskMap DatomicReadDatomsTaskMap)
-            :lifecycles [os/Lifecycle]}})
-
-(s/defn read-index-range
-  [task-name :- s/Keyword opts]
-  {:task {:task-map (merge {:onyx/name task-name
-                            :onyx/plugin :onyx.plugin.datomic/read-index-range
-                            :onyx/type :input
-                            :onyx/medium :datomic
-                            :datomic/datoms-per-segment 20
-                            :onyx/max-peers 1
-                            :onyx/doc "Reads a sequence of datoms from the d/log API"}
-                           opts)
-          :lifecycles [{:lifecycle/task task-name
-                        :lifecycle/calls :onyx.plugin.datomic/read-index-range-calls}]}
-   :schema {:task-map (merge os/TaskMap DatomicReadIndexRangeTaskMap)
-            :lifecycles [os/Lifecycle]}})
-
-(s/defn write-datoms
-  [task-name :- s/Keyword opts]
-  {:task {:task-map (merge {:onyx/name task-name
-                            :onyx/plugin :onyx.plugin.datomic/write-datoms
-                            :onyx/type :output
-                            :onyx/medium :datomic
-                            :onyx/doc "Transacts segments to storage"}
-                           opts)
-          :lifecycles [{:lifecycle/task task-name
-                        :lifecycle/calls :onyx.plugin.datomic/write-tx-calls}]}
-   :schema {:task-map (merge os/TaskMap DatomicWriteDatomsTaskMap)
-            :lifecycles [os/Lifecycle]}})
-
-(s/defn write-bulk-tx-datoms
-  [task-name :- s/Keyword opts]
-  {:task {:task-map (merge {:onyx/name task-name
-                            :onyx/plugin :onyx.plugin.datomic/write-bulk-datoms
-                            :onyx/type :output
-                            :onyx/medium :datomic
-                            :onyx/doc "Transacts segments to storage"}
-                           opts)
-          :lifecycles [{:lifecycle/task task-name
-                        :lifecycle/calls :onyx.plugin.datomic/write-bulk-tx-calls}]}
-   :schema {:task-map (merge os/TaskMap DatomicWriteDatomsTaskMap)
-            :lifecycles [os/Lifecycle]}})
+(s/defn ^:always-validate write-datoms
+  ([task-name :- s/Keyword opts]
+   {:task {:task-map (merge {:onyx/name task-name
+                             :onyx/plugin :onyx.plugin.datomic/write-datoms
+                             :onyx/type :output
+                             :onyx/medium :datomic}
+                            opts)
+           :lifecycles [{:lifecycle/task task-name
+                         :lifecycle/calls :onyx.plugin.datomic/write-tx-calls}]}
+    :schema {:task-map DatomicWriteDatomsTaskMap
+             :lifecycles [os/Lifecycle]}})
+  ([task-name :- s/Keyword
+    uri :- s/Str
+    task-opts :- {s/Any s/Any}]
+   (write-datoms task-name (merge {:datomic/uri uri}
+                                  task-opts))))


Negate y-zoom. This makes the scope plot correctly (i.e. positive vals at the top, neg vals at the bottom)

--- src/overtone/viz/scope.clj
+++ src/overtone/viz/scope.clj
@@ -66,7 +66,7 @@
         (.drawRect 0 0 width height)
         (.setColor ^Color color)
         (.translate 0 y-shift)
-        (.scale 1 y-zoom)
+        (.scale 1 (* -1 y-zoom))
         (.drawPolyline ^ints x-array ^ints y-a width)))))

 (defn scope-panel [id width height]


Add a run function for visualizing the nth step of the glider example board

--- src/petulant_life/life.clj
+++ src/petulant_life/life.clj
@@ -1,4 +1,5 @@
-(ns petulant-life.life)
+(ns petulant-life.life
+  (:require [clojure.pprint :refer [pprint]]))

 ;; This code was taken from Clojure Programming by Chas Emerick, Brian
 ;; Carper, and Christophe Grand (O’Reilly).
@@ -44,3 +45,10 @@
 (def rect-step (stepper rect-neighbours  #{3} #{2 3}))

 (def hex-step  (stepper hex-neighbours   #{2} #{3 4}))
+
+(defn run [step-n]
+  (->> (iterate rect-step #{[2 0] [2 1] [2 2] [1 2] [0 1]})
+       (drop (dec step-n))
+       first
+       (populate (empty-board 6 6))
+       pprint))


Renamed namespace to suppress "single segment namespace" compiler warnings.

--- src/reagent_bootstrap.cljs
+++ src/reagent_bootstrap.cljs
@@ -1,4 +1,4 @@
-(ns reagent-bootstrap
+(ns reagent-bootstrap.core
   "This namespace contains some basic reagent bootstrap components"
   (:require [reagent.core :as reagent :refer [atom]]
             [cljs-uuid.core :as uuid]))


Rewrote remove function for scenes

Rewrote remove function for scenes

  - The new version now handles removing of nested nodes

--- src/retro_fever/scene.cljs
+++ src/retro_fever/scene.cljs
@@ -41,9 +41,13 @@
         (assoc id (with-meta element {:se-id id :parent destination-id}))
         (update-in [destination-id] add-child-id id)))
   (remove [this id]
-    (-> this
-        (update-in [(:parent (meta (id this)))] remove-child-id id)
-        (dissoc this id)))
+    (let [element (get this id)
+          scene (if (= (type element) Node)
+                  (reduce #(remove %1 %2) this (get-children-ids element))
+                  this)]
+      (-> scene
+        (update-in [(:parent (meta element))] remove-child-id id)
+        (dissoc id))))
   (move-to [this id destination-id]
     (-> this
         (update-in [(:parent (meta (id this)))] remove-child-id id)


Improve :assoc-fn tests

Improve :assoc-fn tests

In preparation for TCLI-90

--- src/test/clojure/clojure/tools/cli_test.clj
+++ src/test/clojure/clojure/tools/cli_test.clj
@@ -50,7 +50,7 @@
             [nil nil nil "DESC"]
             ["-f" "--foo" "FOO" "desc"]])))
   (testing "parses --[no-]opt style flags to a proper id"
-    (is (= (-> (compile-option-specs [["-f" "--[no-]foo" ]])
+    (is (= (-> (compile-option-specs [["-f" "--[no-]foo"]])
                first
                (select-keys [:id :short-opt :long-opt]))
            {:id :foo,
@@ -159,9 +159,11 @@
                   [["-a" nil
                     :id :alpha
                     :default true
+                    ;; same as (update-in m [k] not)
                     :assoc-fn (fn [m k v] (assoc m k (not v)))]
                    ["-v" "--verbose"
                     :default 0
+                    ;; same as (update-in m [k] inc)
                     :assoc-fn (fn [m k _] (assoc m k (inc (m k))))]])]
       (is (= (parse-option-tokens specs [])
              [{:alpha true :verbose 0} []]))
@@ -171,6 +173,25 @@
                                          [:short-opt "-v"]
                                          [:long-opt "--verbose"]])
              [{:alpha true :verbose 3} []]))
+      (is (= (parse-option-tokens specs [[:short-opt "-v"]] :no-defaults true)
+             [{:verbose 1} []]))))
+  (testing "associates :id and value with :assoc-fn, without :default"
+    (let [specs (compile-option-specs
+                  [["-a" nil
+                    :id :alpha
+                    ;; use fnil to have an implied :default true
+                    :assoc-fn (fn [m k v] (update-in m [k] (fnil not true)))]
+                   ["-v" "--verbose"
+                    ;; use fnil to have an implied :default 0
+                    :assoc-fn (fn [m k _] (update-in m [k] (fnil inc 0)))]])]
+      (is (= (parse-option-tokens specs [])
+             [{} []]))
+      (is (= (parse-option-tokens specs [[:short-opt "-a"]])
+             [{:alpha false} []]))
+      (is (= (parse-option-tokens specs [[:short-opt "-v"]
+                                         [:short-opt "-v"]
+                                         [:long-opt "--verbose"]])
+             [{:verbose 3} []]))
       (is (= (parse-option-tokens specs [[:short-opt "-v"]] :no-defaults true)
              [{:verbose 1} []]))))
   (testing "can deal with negative flags"
@@ -288,5 +309,4 @@
       (clojure.java.shell/sh
         "phantomjs"
         "target/runner.js"
-        "target/cli_test.js")))
-  )
+        "target/cli_test.js"))))


CMR-543: Updated downloadable test for new error message.

--- test/cmr/system_int_test/search/granule_search_downloadable_test.clj
+++ test/cmr/system_int_test/search/granule_search_downloadable_test.clj
@@ -34,7 +34,7 @@
       (let [references (search/find-refs :granule {:downloadable "unset"})]
         (is (d/refs-match? [gran1 gran2 gran3 gran4 gran5 gran6] references))))
     (testing "search by downloadable wrong value"
-      (is (= {:status 422 :errors ["Parameter :downloadable must take value of true of false, but was wrong"]}
+      (is (= {:status 422 :errors ["Parameter :downloadable must take value of true, false, or unset, but was wrong"]}
              (search/find-refs :granule {:downloadable "wrong"}))))))

 (deftest search-by-online-only
@@ -61,5 +61,5 @@
       (let [references (search/find-refs :granule {:online-only "unset"})]
         (is (d/refs-match? [gran1 gran2 gran3 gran4 gran5 gran6] references))))
     (testing "search by online only wrong value"
-      (is (= {:status 422 :errors ["Parameter :downloadable must take value of true of false, but was wrong"]}
+      (is (= {:status 422 :errors ["Parameter :downloadable must take value of true, false, or unset, but was wrong"]}
              (search/find-refs :granule {:online-only "wrong"}))))))


add letter spacing and line height inputs

--- src/uxbox/ui/workspace/sidebar/options.cljs
+++ src/uxbox/ui/workspace/sidebar/options.cljs
@@ -533,6 +533,7 @@
        [:div.element-set {:key (str (:id menu))}
         [:div.element-set-title (:name menu)]
         [:div.element-set-content
+
          [:span "Font family"]
          [:div.row-flex
           [:select.input-select {:value (pr-str family)
@@ -540,6 +541,7 @@
            (for [font library/+fonts+]
              [:option {:value (pr-str (:id font))
                        :key (:id font)} (:name font)])]]
+
          [:span "Size and Weight"]
          [:div.row-flex
           [:input.input-text
@@ -555,6 +557,23 @@
                  :let [data (mapv #(get style %) [:weight :style])]]
              [:option {:value (pr-str data)
                        :key (:name style)} (:name style)])]]
+
+         [:span "Line height and Letter spacing"]
+         [:div.row-flex
+          [:input.input-text
+           {:placeholder "Line height"
+            :type "number"
+            :step "0.1"
+            :min "0"
+            :max "200"
+            :defaultValue "1.5"}]
+          [:input.input-text
+           {:placeholder "Letter spacing"
+            :type "number"
+            :step "0.1"
+            :min "0"
+            :max "200"
+            :defaultValue "1"}]]

          [:span "Text align"]
          [:div.row-flex.align-icons
@@ -569,8 +588,7 @@
            i/align-center]
           [:span {:class (when (= align "justify") "current")
                   :on-click #(on-font-align-change % "justify")}
-           i/align-justify]
-          ]]]))))
+           i/align-justify]]]]))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Components


Fix strange behavior of opacity range inputs.

--- src/uxbox/ui/workspace/sidebar/options.cljs
+++ src/uxbox/ui/workspace/sidebar/options.cljs
@@ -86,7 +86,8 @@
               (change-stroke {:width value})))
           (on-opacity-change [event]
             (let [value (dom/event->value event)
-                  value (parse-float value 1)]
+                  value (parse-float value 1)
+                  value (/ value 10000)]
               (change-stroke {:opacity value})))
           (on-color-change [event]
             (let [value (dom/event->value event)]
@@ -139,9 +140,9 @@
         [:input.slidebar
          {:type "range"
           :min "0"
-          :max "1"
-          :value (:stroke-opacity shape "1")
-          :step "0.0001"
+          :max "10000"
+          :value (* 10000 (:stroke-opacity shape 1))
+          :step "1"
           :on-change on-opacity-change}]]]])))

 (defmethod -render-menu :menu/fill
@@ -154,7 +155,8 @@
               (change-fill {:color value})))
           (on-opacity-change [event]
             (let [value (dom/event->value event)
-                  value (parse-float value 1)]
+                  value (parse-float value 1)
+                  value (/ value 10000)]
               (change-fill {:opacity value})))
           (on-color-picker-event [color]
             (change-fill {:color color}))]
@@ -186,9 +188,9 @@
         [:input.slidebar
          {:type "range"
           :min "0"
-          :max "1"
-          :value (:fill-opacity shape "1")
-          :step "0.0001"
+          :max "10000"
+          :value (* 10000 (:fill-opacity shape 1))
+          :step "1"
           :on-change on-opacity-change}]]]])))

 (defmethod -render-menu :menu/rect-measures


Get rid of gets

Get rid of gets

--- src/timetracker/models.clj
+++ src/timetracker/models.clj
@@ -60,14 +60,14 @@
   (let [f (first tasks)
         s (second tasks)
         r (rest tasks)
-        d (time_difference (get f :time) (get s :time))]
+        d (time_difference (:time f) (:time s))]
     (if (>= (count r) 1)
-      (do (update_duration (get f :_id) (str d))
+      (do (update_duration (:_id f) (str d))
           (process_duration r)))))

 (defn process []
   ;(println "process called")
   (doseq [x (read_project_file)]
-    (process_project (get x :text) (get x :code)))
+    (process_project (:text x) (:code x)))
   (process_duration (find_all)))