Prepare user-friendly samples #15 - color chooser

--- src/flatgui/samples/forms/colorchooserwin.clj
+++ src/flatgui/samples/forms/colorchooserwin.clj
@@ -14,14 +14,89 @@
             [flatgui.widgets.checkbox :as checkbox]
             [flatgui.widgets.window :as window]
             [flatgui.widgets.label :as label]
-            [flatgui.widgets.textfield :as textfield]
             [flatgui.widgets.spinner :as spinner]
-            [flatgui.widgets.slider :as slider])
-  (:import (java.text DecimalFormat)))
+            [flatgui.widgets.slider :as slider]))

-(def label-format (DecimalFormat. "###"))
+;;;
+;;; Spinner evolvers are overriden to receive values from sliders when needed
+;;;

+(fg/defevolverfn r-spinner-evolver :model
+  (if (= (fg/get-reason) [:_ :r-slider])
+    (let [num->str (get-property [:this] :num->str)
+          slider-val-str (num->str component (int (* 255.0 (- 1.0 (get-property [:_ :r-slider] :position)))))]
+      {:text slider-val-str :caret-pos 0 :selection-mark 0})
+    (spinner/spinner-model-evovler component)))
+
+(fg/defevolverfn g-spinner-evolver :model
+  (if (= (fg/get-reason) [:_ :g-slider])
+    (let [num->str (get-property [:this] :num->str)
+          slider-val-str (num->str component (int (* 255.0 (- 1.0 (get-property [:_ :g-slider] :position)))))]
+      {:text slider-val-str :caret-pos 0 :selection-mark 0})
+    (spinner/spinner-model-evovler component)))
+
+(fg/defevolverfn b-spinner-evolver :model
+ (if (= (fg/get-reason) [:_ :b-slider])
+   (let [num->str (get-property [:this] :num->str)
+         slider-val-str (num->str component (int (* 255.0 (- 1.0 (get-property [:_ :b-slider] :position)))))]
+     {:text slider-val-str :caret-pos 0 :selection-mark 0})
+   (spinner/spinner-model-evovler component)))
+
+;;;
+;;; Slider position evolvers are overriden here to "lock"
+;;; sliders when 'Gray' check box is checked; and also
+;;; to receive manually typed values from spinners
+;;;
+
+(defn- str->num [s]
+  (if (> (.length s) 0) (Double/valueOf s) 0))
+
+;;; NOTE: rounding is used in slider evolver because otherwise double math inaccuracy
+;;; produces false change which triggers re-entrant evolving, which in turn makes
+;;; slider/spinner value fall back to previous value when in certain positions.
+;;; Presicion of 1000 is used there according to the 1/255 value.
+(defn- round [n p] (/ (- (* n p) (mod n p)) p))
+
+(fg/defevolverfn r-slider-evolver :position
+  (if (and
+        (#{[:g-slider] [:b-slider] [:gray]} (fg/get-reason))
+        (get-property [:gray] :pressed))
+    (get-property [:g-slider] :position)
+    (if (= [:r-spinner :editor] (fg/get-reason))
+      (let [spinner-text (:text (get-property [:r-spinner :editor] :model))
+            spinner-val (str->num spinner-text)]
+        (round (- 1.0 (/ spinner-val 255.0)) 1000))
+      (flatgui.widgets.slider/slider-position-evolver component))))
+
+(fg/defevolverfn g-slider-evolver :position
+  (if (and
+        (#{[:b-slider] [:r-slider] [:gray]} (fg/get-reason))
+        (get-property [:gray] :pressed))
+    (get-property [:b-slider] :position)
+    (if (= [:g-spinner :editor] (fg/get-reason))
+      (let [spinner-text (:text (get-property [:g-spinner :editor] :model))
+            spinner-val (str->num spinner-text)]
+        (round (- 1.0 (/ spinner-val 255.0)) 1000))
+      (flatgui.widgets.slider/slider-position-evolver component))))
+
+(fg/defevolverfn b-slider-evolver :position
+  (if (and
+        (#{[:r-slider] [:g-slider] [:gray]} (fg/get-reason))
+        (get-property [:gray] :pressed))
+    (get-property [:r-slider] :position)
+    (if (= [:b-spinner :editor] (fg/get-reason))
+      (let [spinner-text (:text (get-property [:b-spinner :editor] :model))
+            spinner-val (str->num spinner-text)]
+        (round (- 1.0 (/ spinner-val 255.0)) 1000))
+      (flatgui.widgets.slider/slider-position-evolver component))))
+
+;; Takes r g b values from spinners for the color for indicator
+(fg/defevolverfn indicator-color-evolver :background
+  (let [r (str->num (:text (get-property [:r-spinner :editor] :model)))
+        g (str->num (:text (get-property [:g-spinner :editor] :model)))
+        b (str->num (:text (get-property [:b-spinner :editor] :model)))]
+    (awt/color (int r) (int g) (int b))))

 (def color-chooser-window
   (fg/defcomponent window/window :chooser
@@ -32,7 +107,8 @@
   (fg/defcomponent panel/panel :indicator
     {:clip-size (m/defpoint 2.5 2.0)
      :position-matrix (m/transtation 0.25 0.5)
-     :background (awt/color 0 0 0)})
+     :background (awt/color 0 0 0)
+     :evolvers {:background indicator-color-evolver}})

   (fg/defcomponent checkbox/checkbox :gray
     {:clip-size (m/defpoint 1.5 0.25)
@@ -57,128 +133,49 @@
   (fg/defcomponent slider/slider :r-slider
     {:clip-size (m/defpoint 0.5 3.0 0)
      :orientation :vertical
-     :position-matrix (m/transtation 0.25 3.5)})
+     :position-matrix (m/transtation 0.25 3.5)
+     :evolvers {:position r-slider-evolver}})

   (fg/defcomponent slider/slider :g-slider
     {:clip-size (m/defpoint 0.5 3.0 0)
      :orientation :vertical
-     :position-matrix (m/transtation 1.375 3.5)})
+     :position-matrix (m/transtation 1.375 3.5)
+     :evolvers {:position g-slider-evolver}})

   (fg/defcomponent slider/slider :b-slider
     {:clip-size (m/defpoint 0.5 3.0 0)
      :orientation :vertical
-     :position-matrix (m/transtation 2.5 3.5)})
+     :position-matrix (m/transtation 2.5 3.5)
+     :evolvers {:position b-slider-evolver}})

   (fg/defcomponent spinner/spinner :r-spinner
     {:clip-size (m/defpoint 0.75 0.375 0)
      :position-matrix (m/transtation 0.125 6.75)
+     :min 0
+     :max 255
      :step 1}
-    ;(fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model r-spinner-evolver}})
-    )
+    (fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model r-spinner-evolver}}))

   (fg/defcomponent spinner/spinner :g-spinner
     {:clip-size (m/defpoint 0.75 0.375 0)
      :position-matrix (m/transtation 1.125 6.75)
-     :step 1})
+     :min 0
+     :max 255
+     :step 1}
+    (fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model g-spinner-evolver}}))

   (fg/defcomponent spinner/spinner :b-spinner
     {:clip-size (m/defpoint 0.75 0.375 0)
      :position-matrix (m/transtation 2.125 6.75)
-     :step 1})
-
-    ))
+     :min 0
+     :max 255
+     :step 1}
+    (fg/defcomponent spinner/spinnereditor :editor {:evolvers {:model b-spinner-evolver}}))))

 (def root-panel
   (fg/defcomponent
     panel/panel
     :main
     {:clip-size (m/defpoint 40 23 0)
-     :background (awt/color (float (/ 9 255)) (float (/ 17 255)) (float (/ 26 255)))}
-    color-chooser-window))
-
-;
-;;
-;; Evolvers for Debug Window
-;;
-;
-;
-;(fg/defevolverfn s1text :text
-;                 (let [ pos (get-property [:slider1] :position)]
-;                   (.format label-format pos)))
-;
-;(fg/defevolverfn s2text :text
-;                 (let [ pos (get-property [:slider2] :position)]
-;                   (.format label-format pos)))
-;
-;; @todo
-;; super-evovler marco that would take evolver from parent type.
-;; Will have to keep the list of parent types in component.
-;; Throw exception if more than one found.
-;; One more way to call this macro - specifying exactly which type
-;; to take evovler from
-;
-;(fg/defevolverfn s1pos :position
-;                 (if (and
-;                       (#{[:slider2] [:lock-checkbox]} (fg/get-reason))
-;                       (get-property [:lock-checkbox] :pressed))
-;                   (get-property [:slider2] :position)
-;                   (flatgui.widgets.slider/slider-position-evolver component)))
-;
-;(fg/defevolverfn s2pos :position
-;                 (if (and
-;                       (#{[:slider1] [:lock-checkbox]} (fg/get-reason))
-;                       (get-property [:lock-checkbox] :pressed))
-;                   (get-property [:slider1] :position)
-;                   (flatgui.widgets.slider/slider-position-evolver component)))
-;
-;;
-;; Debug Window
-;;
-;
-;(def debug-window (fg/defcomponent w/window :debug {:clip-size (m/defpoint 3.5 5.5)
-;                                                    :position-matrix (m/transtation-matrix 10 7)
-;                                                    :text "Debug Panel"}
-;
-;                                   (fg/defcomponent w/label :s1-text
-;                                                    { :text "Slider 1:"
-;                                                     :clip-size (m/defpoint 1.0 0.5 0)
-;                                                     :position-matrix (m/transtation-matrix 0.25 0.5)})
-;
-;                                   (fg/defcomponent w/label :s2-text
-;                                                    { :text "Slider 2:"
-;                                                     :clip-size (m/defpoint 1.0 0.5 0)
-;                                                     :position-matrix (m/transtation-matrix 0.25 1.0)})
-;
-;                                   (fg/defcomponent w/label :s1-label
-;                                                    { :clip-size (m/defpoint 3 0.5 0)
-;                                                     :h-alignment :left
-;                                                     :position-matrix (m/transtation-matrix 1.28125 0.5)
-;                                                     :evolvers {:text s1text}})
-;
-;                                   (fg/defcomponent w/label :s2-label
-;                                                    { :clip-size (m/defpoint 3 0.5 0)
-;                                                     :h-alignment :left
-;                                                     :position-matrix (m/transtation-matrix 1.28125 1.0)
-;                                                     :evolvers {:text s2text}})
-;
-;
-;                                   (fg/defcomponent w/checkbox :lock-checkbox { :clip-size (m/defpoint 1.5 0.25 0)
-;                                                                               :text "Lock sliders"
-;                                                                               :position-matrix (m/transtation-matrix 0.25 1.75)})
-;
-;                                   (fg/defcomponent w/slider :slider1 { :clip-size (m/defpoint 0.5 3.0 0)
-;                                                                       :orientation :vertical
-;                                                                       :position-matrix (m/transtation-matrix 0.25 2.25)
-;                                                                       :evolvers {:position s1pos}})
-;
-;                                   (fg/defcomponent w/slider :slider2 { :clip-size (m/defpoint 0.5 3.0 0)
-;                                                                       :orientation :vertical
-;                                                                       :position-matrix (m/transtation-matrix 1.0 2.25)
-;                                                                       :evolvers {:position s2pos}})
-;
-;                                   (fg/defcomponent w/spinner :spn { :clip-size (m/defpoint 1.375 0.375 0)
-;                                                                    :position-matrix (m/transtation-matrix 1.625 2.25)})
-;
-;                                   ;  (fg/defcomponent w/menu :ctx { :clip-size (m/defpoint 4 6 0)
-;                                   ;                            :position-matrix (m/transtation-matrix 3.625 2.75)})
-;                                   ))
+     :background (awt/color 9 17 26)}
+    color-chooser-window))


passing missing opts

passing missing opts

--- src/remote/capistrano.clj
+++ src/remote/capistrano.clj
@@ -30,7 +30,7 @@
          (when (exists? (dest-path src dst))
            (throw+ {:type ::old-code :message "Old code found in place, cleanup first"}))
          (mkdirs dst)
-         (copy src dst)
+         (copy src dst {})
          (try
            (sh- "cap" "-T" {:dir (dest-path src dst)})
            (catch Throwable e


Different modifications

Different modifications

--- src/cyanite_fetcher/core.clj
+++ src/cyanite_fetcher/core.clj
@@ -170,10 +170,13 @@
        (if (empty? queries)
          query-results
          (let [[result channel] (async/alts! queries)]
-           ;;(println (count queries))
            (recur
-            (rest queries)
-            (into query-results result))))))))
+            (remove #{channel} queries)
+            (->> result
+                 (map detect-aggregate)
+                 (doall)
+                 (seq)
+                 (into query-results)))))))))

 (defn c-get-data
   "Get data from C*."
@@ -188,9 +191,8 @@
                                            rollup period from to)))]
         (newline)
         data)
-      (catch Exception e
-        (alia/shutdown cluster)
-        (throw e)))))
+      (finally
+        (alia/shutdown cluster)))))

 ;;------------------------------------------------------------------------------
 ;; ElasticSearch
@@ -410,9 +412,9 @@
     (newline)
     (let [paths (es-get-paths eshost path tenant)
           data (c-get-data par-fetch "par-fetch" chost paths tenant rollup period from to)
+          ;;data (c-get-data par-fetch-chan "par-fetch-chan" chost paths tenant rollup period from to)
           ;;fdata (flatter data (fn [data] (r/reduce into [] data)) "r/reduce")
           ]
-      (c-get-data par-fetch-async "par-fetch-async" chost paths tenant rollup period from to)
       ;;(flatter data (fn [data] (reduce into data)) "reduce")
       ;;(cleaner fdata (fn [data] (into [] (r/remove nil? data))) "r/remove")
       ;;(cleaner fdata (fn [data] (remove nil? data))  "remove")


Update tools.reader to 1.0.0-RC1

Update tools.reader to 1.0.0-RC1

--- planck-cljs/project.clj
+++ planck-cljs/project.clj
@@ -11,7 +11,7 @@
   :dependencies [[org.clojure/clojure "1.8.0"]
                  [org.clojure/clojurescript "1.9.562"]
                  [org.clojure/test.check "0.9.0"]
-                 [org.clojure/tools.reader "1.0.0-beta4"]
+                 [org.clojure/tools.reader "1.0.0-RC1"]
                  [com.cognitect/transit-clj "0.8.297"]
                  [com.cognitect/transit-cljs "0.8.239"]
                  [fipp "0.6.7"]


using fuse

using fuse

--- src/main/clojure/com/narkisr/couch_access.clj
+++ src/main/clojure/com/narkisr/couch_access.clj
@@ -7,7 +7,7 @@
     ))

 (def *host* "http://127.0.0.1:5984/")
-(def *db* "blog-import")
+(def *db* "fuse")

 (defmacro couch [fn & params]
   `(~fn ~*host* ~*db* ~@params))
@@ -24,5 +24,3 @@
 (defn couch-files []
   (reduce merge (map #(create-file-entry % (couch document-get %)) (all-ids))))

-
-;(couch-files (all-ids))


Allow clojure style for normal React elements

--- src/dmohs/react/core.cljs
+++ src/dmohs/react/core.cljs
@@ -68,6 +68,31 @@
   (aget instance "cljsLocals"))

+(defn- transform-keys [keyfn xs]
+  ;; Structure taken from js->clj source.
+  (let [f (fn thisfn [x]
+            (cond
+              (map? x)
+              (reduce-kv (fn [r k v] (assoc r (keyfn k) (thisfn v))) {} x)
+              (seq? x)
+              (doall (map thisfn x))
+              (coll? x)
+              (into (empty x) (map thisfn x))
+              :else x))]
+    (f xs)))
+
+
+(defn- camel-case-keys [m]
+  (transform-keys
+   (fn [k]
+     (if-not (keyword? k)
+       k
+       (let [words (clojure.string/split (name k) #"-")
+             cased (map #(str (clojure.string/upper-case (subs % 0 1)) (subs % 1)) (rest words))]
+         (keyword (apply str (first words) cased)))))
+   m))
+
+
 (defn create-element
   [type-or-vec props & children]
   (if (vector? type-or-vec)
@@ -86,7 +111,7 @@
                             x))
                         children)]
       (if (or tag? (not (aget (.-prototype type) "react-cljs?")))
-        (apply React.createElement type (clj->js props) children)
+        (apply React.createElement type (clj->js (camel-case-keys props)) children)
         (let [js-props #js{}
               {:keys [ref key]} props
               default-props (aget (.-constructor (.-prototype type)) "defaultProps")


Try using a kd-tree for nearest neighbour search.


fix typo

fix typo

--- dada-core/src/main/clojure/org/dada/core/SessionManagerImpl.clj
+++ dada-core/src/main/clojure/org/dada/core/SessionManagerImpl.clj
@@ -78,13 +78,13 @@
 	    (swap!
 	     mutable
 	     (fn [[exports]]
-		 (let [entry (exports model-name)]
-		   (if entry
-		     (let [[count view] entry]
-		       (if (= count 1)
-			 [(dissoc exports model-name) view]
-			 [(assoc exports model-name [(dec count) view])]))
-n		     [exports]))))]
+	       (let [entry (exports model-name)]
+		 (if entry
+		   (let [[count view] entry]
+		     (if (= count 1)
+		       [(dissoc exports model-name) view]
+		       [(assoc exports model-name [(dec count) view])]))
+		   [exports]))))]
 	(if view
 	  (.deregisterView model view)
 	  (.getData model)


Refactor save query function

Refactor save query function

--- src/day8/re_frame/trace.cljs
+++ src/day8/re_frame/trace.cljs
@@ -144,20 +144,27 @@
     (fn [trace]
       (< (:query query) (:duration trace)))))

-(defn render-traces [showing-traces filter-items trace-detail-expansions]
+(defn add-filter [filter-items filter-input filter-type from-mouse?]
+  (swap! filter-items conj {:id (random-uuid)
+                            :query (if from-mouse?
+                                     (str/lower-case (name filter-input))
+                                     (if (= @filter-type :contains)
+                                       (str/lower-case @filter-input)
+                                       (js/parseFloat @filter-input)))
+                            :filter-type (if from-mouse?
+                                           :contains
+                                           @filter-type)}))
+
+(defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
   (doall
     (for [{:keys [op-type id operation tags duration] :as trace} showing-traces]
       (let [padding          {:padding "0px 5px 0px 5px"}
             row-style        (merge padding {:border-top (case op-type :event "1px solid lightgrey" nil)})
-            show-row? (get-in @trace-detail-expansions [:overrides id]
-                        (:show-all? @trace-detail-expansions))
+            show-row?        (get-in @trace-detail-expansions [:overrides id]
+                               (:show-all? @trace-detail-expansions))
             op-name          (if (vector? operation)
                                (second operation)
                                operation)
-            save-query       (fn [filter-for-string]
-                               (swap! filter-items conj {:id (random-uuid)
-                                                         :query (str/lower-case (name filter-for-string))
-                                                         :filter-type :contains}))
             #_#__ (js/console.log (devtools/header-api-call tags))]
         (list [:tr {:key   id
                     :on-click (fn [ev]
@@ -175,15 +182,15 @@
                [:td {:style row-style}
                     [:div.op-string
                      [:span {:on-click (fn [ev]
-                                         (save-query op-type)
-                                         (.stopPropagation ev))
-                             :style    {:cursor "pointer"}} (str op-type)]]]
+                                         (add-filter filter-items (name op-type) :contains true)
+                                         (.stopPropagation ev))}
+                      (str op-type)]]]
                [:td {:style    row-style}
                     [:div.op-string
                      [:span {:on-click (fn [ev]
-                                         (save-query op-name)
-                                         (.stopPropagation ev))
-                             :style {:cursor "pointer"}}] op-name]]
+                                         (add-filter filter-items (name op-name) :contains true)
+                                         (.stopPropagation ev))}
+                      op-name]]]
                [:td
                 {:style (merge row-style {
                                           ; :font-weight (if (< slower-than-bold-int duration)
@@ -212,11 +219,9 @@
                                      (reset! input-error true)
                                      (do
                                        (reset! input-error false)
-                                       (swap! filter-items conj {:id (random-uuid)
-                                                                 :query (if (= @filter-type :contains)
-                                                                          (str/lower-case @filter-input)
-                                                                          (js/parseFloat @filter-input))
-                                                                 :filter-type @filter-type}))))]
+                                       (add-filter filter-items filter-input filter-type false))))]
+
+
         [:div {:style {:flex "1 0 auto" :width "100%" :height "100%" :display "flex" :flex-direction "column"}}
           [:div.filter-control
            [:div.filter-control-input
@@ -264,7 +269,7 @@
                (when (pos? (count @traces))
                  [:span "(" [:button.text-button {:on-click #(do (trace/reset-tracing!) (reset! traces []))} "clear"] ")"])]
              [:th "meta"]]
-            [:tbody (render-traces showing-traces filter-items trace-detail-expansions)]]]]))))
+            [:tbody (render-traces showing-traces filter-items filter-input trace-detail-expansions)]]]]))))

 (defn resizer-style [draggable-area]
   {:position "absolute" :z-index 2 :opacity 0


Bad paren

Bad paren

--- src/semantic_csv/core.clj
+++ src/semantic_csv/core.clj
@@ -278,7 +278,7 @@
         (?>> cast-fns (cast-with cast-fns))))
   ; Use all defaults
   ([rows]
-   (process {} rows))))
+   (process {} rows)))

 ;; Using this function, the code we've been building above is reduced to the following:
 ;;


Exercise 1.27

Exercise 1.27

--- src/sicp/chapter1/2_6.clj
+++ src/sicp/chapter1/2_6.clj
@@ -268,7 +268,17 @@
 ;; TODO

 ;; Exercise 1.27
-;; TODO
+(defn prime-by-fermat-test? [n]
+  (letfn [(try-it [a]
+            (== (expmod a n n) a))
+          (full-fermat-test [a]
+            (cond
+              (>= a n) true
+              (try-it a) (recur (inc a))
+              :else false))]
+    (full-fermat-test 1)))
+
+(map prime-by-fermat-test? [561 1105 1729 2465 2821 6601])

 ;; Exercise 1.28
 ;; TODO


Better configuration handling in the core module and by RING handler

--- src/emender_jenkins/core.clj
+++ src/emender_jenkins/core.clj
@@ -78,21 +78,27 @@
         ;cors-handler))

 (defn start-server-on-regular-machine
-    [port]
+    [ring-app port]
     (println "Starting the server at the port: " port)
-    (jetty/run-jetty app {:port (read-string port)}))
+    (jetty/run-jetty ring-app {:port (read-string port)}))

 (defn start-server-on-openshift
-    [port host]
+    [ring-app port host]
     (println "Starting the server on openshift at the port: " port " and host: " host)
-    (jetty/run-jetty app {:port (read-string port) :host host}))
+    (jetty/run-jetty ring-app {:port (read-string port) :host host}))

 (defn start-server
     "Start server on specified port."
-    [port openshift-port openshift-ip]
-    (if (and openshift-ip openshift-port)
-        (start-server-on-openshift openshift-port openshift-ip)
-        (start-server-on-regular-machine port)))
+    [configuration port openshift-port openshift-ip]
+    (let [ring-app
+        (-> server/handler            ; handle all events
+            (middleware/inject-configuration configuration) ; inject configuration structure into the parameter
+            cookies/wrap-cookies      ; we need to work with cookies
+            http-params/wrap-params   ; and to process request parameters, of course
+            all-cors)]
+        (if (and openshift-ip openshift-port)
+            (start-server-on-openshift       ring-app openshift-port openshift-ip)
+            (start-server-on-regular-machine ring-app port))))

 (defn get-and-check-port
     "Accepts port number represented by string and throws AssertionError
@@ -145,7 +151,9 @@
           openshift-ip        (System/getenv "OPENSHIFT_CLOJURE_HTTP_IP")
           openshift-port      (System/getenv "OPENSHIFT_CLOJURE_HTTP_PORT")]
         (print-environment-configuration)
-        ;(config/override-options-by-cli jenkins-url test-jobs-suffix)
+        (let [configuration (config/load-configuration-from-ini "config.ini")]
+            (config/override-options-by-cli configuration jenkins-url test-jobs-suffix)
+            (config/print-configuration configuration))
         (println "Finished")))

 (defn run-app
@@ -155,12 +163,9 @@
           test-jobs-suffix    (options :test-jobs-suffix)
           openshift-ip        (System/getenv "OPENSHIFT_CLOJURE_HTTP_IP")
           openshift-port      (System/getenv "OPENSHIFT_CLOJURE_HTTP_PORT")]
-       ;(config/load-all-configuration-options-if-necessary)
-       ;(config/override-options-by-cli jenkins-url preview-jobs-suffix stage-jobs-suffix portal-jobs-suffix)
-       ;(product-list/read-product-list-if-necessary config/load-product-list-from-database)
-       ;(job-data-fetcher/read-books-info)
-       ;(.start (Thread. job-data-fetcher/run-fetcher))
-        (start-server (get-port port) openshift-port openshift-ip)))
+        (let [configuration (config/load-configuration-from-ini "config.ini")]
+            (config/override-options-by-cli configuration jenkins-url test-jobs-suffix)
+        (start-server configuration (get-port port) openshift-port openshift-ip))))

 (defn -main
     "Entry point to the Emender service server."


Strings

Strings

--- src/sns_beanstalk_chat/handler.clj
+++ src/sns_beanstalk_chat/handler.clj
@@ -12,7 +12,7 @@
   (:gen-class))

 (defmulti handle-sns-request
-  (fn [{{:keys [x-amz-sns-message-type]} :headers}]
+  (fn [{{:strs [x-amz-sns-message-type]} :headers}]
     x-amz-sns-message-type))
 (defmethod handle-sns-request "SubscriptionConfirmation" [{:keys [body]}]
   (-> body :SubscribeURL http.client/get))


remove stray console.log

remove stray console.log

--- src-cljs/frontend/controllers/api.cljs
+++ src-cljs/frontend/controllers/api.cljs
@@ -345,7 +345,6 @@

 (defmethod api-event [:workflow-status :success]
   [target message status {:keys [resp]} state]
-  (js/console.log "workflow status" resp)
   state)

 (defmethod api-event [:cancel-build :success]


move root-verbs to where its used

move root-verbs to where its used

--- src/it.clj
+++ src/it.clj
@@ -3,8 +3,7 @@
 ;; lein run -m it/tutti
 ;; lein run -m it/tutti <num>

-(ns it
-  (:refer-clojure :exclude [get-in]))
+(ns it (:refer-clojure :exclude [get-in]))

 (require '[babel.writer :refer [fill-by-spec fill-verb process write-lexicon]])
 (require '[babel.english :as en])
@@ -15,22 +14,21 @@
 (require '[korma.core :refer :all])
 (require '[korma.db :refer :all])

-;; subset of the lexicon: only verbs which are infinitives and that can be roots:
-;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
-(def root-verbs
-  (zipmap
-   (keys @lexicon)
-   (map (fn [lexeme-set]
-          (filter (fn [lexeme]
-                    (and
-                     (= (get-in lexeme [:synsem :cat]) :verb)
-                     (= (get-in lexeme [:synsem :infl]) :top)
-                     (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
-                  lexeme-set))
-        (vals @lexicon))))
-
 (defn tutti [ & [count]]
-  (let [count (if count (Integer. count) 10)]
+  (let [count (if count (Integer. count) 10)
+        ;; subset of the lexicon: only verbs which are infinitives and that can be roots:
+        ;; (i.e. those that have a specific (non- :top) value for [:synsem :sem :pred])
+        root-verbs
+        (zipmap
+         (keys @lexicon)
+         (map (fn [lexeme-set]
+                (filter (fn [lexeme]
+                          (and
+                           (= (get-in lexeme [:synsem :cat]) :verb)
+                           (= (get-in lexeme [:synsem :infl]) :top)
+                           (not (= :top (get-in lexeme [:synsem :sem :pred] :top)))))
+                        lexeme-set))
+              (vals @lexicon)))]
     (write-lexicon "it" @it/lexicon)
     (log/info (str "done writing lexicon."))
     (log/info (str "generating with this many verbs: " (.size (reduce concat (vals root-verbs)))))


Fix for page sending

Fix for page sending

--- src/tango/http_server.clj
+++ src/tango/http_server.clj
@@ -87,6 +87,18 @@
   [{:keys [state query]} key params]
   {:value (do
             (log/info (str "app/results read"))
+            nil)})
+
+(defmethod reader :app/heat-page
+  [{:keys [state query]} key params]
+  {:value (do
+            (log/info (str "app/heat-page read"))
+            nil)})
+
+(defmethod reader :app/heat-page-size
+  [{:keys [state query]} key params]
+  {:value (do
+            (log/info (str "app/page read"))
             nil)})

 (def parser


Refine handling of variables.

Refine handling of variables.

Also have start messages restart cues that are currently ending.

--- src/afterglow/max/Cue.clj
+++ src/afterglow/max/Cue.clj
@@ -60,16 +60,26 @@
 ;; TODO: Should we detect changes in the cue stored at our cell, and shut down?

 (defn cue-variables
-  "Return the cue's variables, in sorted order by key name (regardless
-  of whether the key is a string or keyword)."
-  [this]
-  (sort-by (comp name :key) (get-in @(.state this) [:cue :variables])))
+  "Return the cue's variables."
+  [this]
+  (get-in @(.state this) [:cue :variables]))

 (defn cue-variable-names
-  "Return the user-oriented names of the cue's variable, in key
-  order."
+  "Return the user-oriented names of the cue's variables."
   [this]
   (map :name (cue-variables this)))
+
+(defn cue-variable-inlet-assist
+  "Return the tooltip text describing the cue variable inlets."
+  [this]
+  (for [n (cue-variable-names this)]
+    (str "float: Set " n "; bang: Report current value")))
+
+(defn cue-variable-outlet-assist
+  "Return the tooltip text describing the cue variable outlets."
+  [this]
+  (for [n (cue-variable-names this)]
+    (str "Output changed values of " n)))

 (defn cue-variable-type-string
   "Returns the type strings telling Max what kind of outlets each cue
@@ -92,26 +102,27 @@
   and outlets supported by this object, and registers our interest in
   cue state with Afterglow."
   [this x y]
-  (let [type-string (str "m" (cue-variable-type-string this))]
-    (.parentDeclareTypedIO this type-string type-string))
-  (.parentSetInletAssist this (into-array String (concat ["start, end, kill: control cue; end and kill can take id"]
-                                                         (cue-variable-names this))))
-  (.parentSetOutletAssist this (into-array String (concat ["reports changes in cue state and associated id values"]
-                                                          (cue-variable-names this))))
-  (.parentCreateInfoOutlet this false)
-  (swap! (.state this) assoc :f (fn [new-state _ id] ; TODO: Include readable effect name as another atom
-                                  (let [cue-name (get-in @(.state this) [:cue :name])]
+  (let [type-string (str "m" (cue-variable-type-string this))
+        cue-name (get-in @(.state this) [:cue :name])
+        first-inlet-assist (str "start, end, kill, bang: Control cue \"" cue-name "\"")]
+    (.parentDeclareTypedIO this type-string type-string)
+    (.parentSetInletAssist this (into-array String (concat [first-inlet-assist]
+                                                           (cue-variable-inlet-assist this))))
+    (.parentSetOutletAssist this (into-array String (concat ["Output changes in Cue state and associated id values"]
+                                                            (cue-variable-outlet-assist this))))
+    (.parentCreateInfoOutlet this false)
+    (swap! (.state this) assoc :f (fn [new-state _ id]
                                     (.outlet this 0 (name new-state)
                                              (into-array Atom [(Atom/newAtom id) (Atom/newAtom cue-name)])))))
   (controllers/add-cue-fn! (:cue-grid *show*) x y (:f @(.state this))))

-;; TODO: Start it over if it is ending.
 (defn- -start
-  "Start the cue if it is not already running."
+  "Start the cue if it is not already running (if it is in the process
+  of ending, start a new instance in its place)."
   [this]
   (let [{:keys [x y]} @(.state this)
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
-    (when-not active
+    (when-not (and active (not (:ending active)))
       (show/add-effect-from-cue-grid! x y))))

 (defn- -end
@@ -158,7 +169,6 @@
   (let [inlet (.parentGetInlet this)
         {:keys [x y cue]} @(.state this)
         [_ active] (show/find-cue-grid-active-effect *show* x y)]
-    (timbre/info "got banged on inlet" inlet)
     (if (zero? inlet)  ; Cue control inlet?
       (if active  ; Transition the cue to the next appropriate state.
         (show/end-effect! (:key cue))
@@ -188,10 +198,9 @@
   variable inlets has been set."
   [this new-value]
   (let [inlet (.parentGetInlet this)]
-    (timbre/info "received float" new-value "on inlet" inlet)
     (if (zero? inlet)  ; Only variable inlets accept floats, ignore attempts to send to 0, but complain.
-      (timbre/error "cue control inlet does not respond to numbers")
-      (let [v (nth (cue-variables this) inlet)
+      (timbre/error "Cue control inlet does not respond to numbers.")
+      (let [v (nth (cue-variables this) (dec inlet))
             new-value (max new-value (:min v))  ; Restrict range of variable values as per cue specs.
             new-value (min new-value (:max v))]
         (if (keyword? (:key v))


remove useless import

remove useless import

--- src/app/symbol_solver.clj
+++ src/app/symbol_solver.clj
@@ -4,8 +4,7 @@
   (:use [app.itemsOnLifecycle])
   (:use [app.utils])
   (:require [instaparse.core :as insta])
-  (:import [app.operations Operation]
-           [jdk.nashorn.internal.ir Symbol]))
+  (:import [app.operations Operation]))

 (import com.github.javaparser.JavaParser)
 (import com.github.javaparser.ast.CompilationUnit)


Add `rsp?` predicate.

Add `rsp?` predicate.

--- backend/src/uxbox/util/response.clj
+++ backend/src/uxbox/util/response.clj
@@ -67,3 +67,7 @@
   "A shortcut for create a response instance."
   [data]
   (Rsp. data))
+
+(defn rsp?
+  [v]
+  (instance? Rsp v))


Added some important symbols (apply, partial, take, ...)

--- src/cljs/cljs_repl_web/cljs_api/utils.cljs
+++ src/cljs/cljs_repl_web/cljs_api/utils.cljs
@@ -9,12 +9,13 @@
 (def custom-api-map
   {:sections [(Section. "Useful Macros" ""
                         [(Topic. "conditionals"
-                                 '(if if-let cond condp and or when when-let))
+                                 '(if if-not if-let cond condp and or not when when-let
+                                   when-not case))
                          (Topic. "nesting, chaining, and interop"
                                  '(-> ->> doto .. .))
                          (Topic. "defining things"
-                                 '(def defn fn let binding defmulti defmethod
-                                    deftype defrecord reify this-as))])
+                                 '(def defn fn let letfn binding defmulti defmethod
+                                    deftype defrecord reify this-as declare ns))])
               (Section. "Datatypes" ""
                         [(Topic. "maps " '({:key1 val1 :key2 val2}))
                          (Topic. "vectors" '([1 2 3] [:a :b :c]))
@@ -36,16 +37,21 @@
                          (Topic. "comparison"
                                  '(= == not= < > <= >=))
                          (Topic. "predicates"
-                                 '(nil? identical? zero? pos? neg? even? odd? true? false?))
+                                 '(nil? identical? zero? pos? neg? even? odd? true? false?
+                                   distinct? empty? every? not-every? some not-any?))
                          (Topic. "data processing"
-                                 '(map reduce filter partition split-at split-with))
+                                 '(map map-indexed mapcat reduce filter partition split-at
+                                   split-with))
                          (Topic. "data create"
-                                 '(vector vec hash-map set for list list*))
+                                 '(vector vec hash-map set for list list* repeat range iterate cycle))
                          (Topic. "data inspection"
-                                 '(first rest get get-in keys vals count nth contains? find))
+                                 '(first second last rest get get-in keys vals count nth contains? find
+                                   take take-while ))
                          (Topic. "data manipulation"
                                  '(seq into conj cons assoc assoc-in dissoc zipmap
-                                   merge merge-with select-keys update-in))])
+                                   merge merge-with select-keys update-in reverse))
+                         (Topic. "function creation"
+                                 '(apply partial comp complement juxt))])
               (Section. "JavaScript Interop" ""
                         [(Topic. "method call" '("(.the-method target-object args...)"))
                          (Topic. "property access" '("(.-property target-object -property)"))


Only format example when needed

Only format example when needed

--- src/cljs/gc_api_browser/schema_select.cljs
+++ src/cljs/gc_api_browser/schema_select.cljs
@@ -46,7 +46,9 @@
                     :links
                     (filter #(= (:title %) action))
                     first)]
-    (update-in action [:example] format-example)))
+    (if (#{"POST" "PUT"} (:method action))
+      (update-in action [:example] format-example)
+      action)))

 (defn schema->domain [schema]
   (get-in schema [:links 0 :href]))


Fix window resizing

Fix window resizing

--- src/zaffre/glterminal.clj
+++ src/zaffre/glterminal.clj
@@ -562,6 +562,7 @@
                            ^int texture-rows
                            font-textures
                            normal-font
+                           fbo-texture
                            antialias
                            character-map-cleared
                            character-map
@@ -627,6 +628,9 @@
         (log/info "screen size" screen-width "x" screen-height)
         (try
           (Display/setDisplayMode (DisplayMode. screen-width screen-height))
+          ;; resize FBO
+          (GL11/glBindTexture GL11/GL_TEXTURE_2D fbo-texture)
+          (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL11/GL_RGB screen-width screen-height 0 GL11/GL_RGB GL11/GL_UNSIGNED_BYTE nil)
           (swap! font-textures update (font-key @normal-font) (fn [m] (assoc m :font-texture (texture-id font-texture-image))))
           (catch Throwable t
             (log/error "Eror changing font" t))))
@@ -862,7 +866,7 @@
                                      char-height                (.getHeight font-metrics)
                                      screen-width               (* columns char-width)
                                      screen-height              (* rows char-height)
-                                     ;; create texture atlas as gl texture
+                                     ;; create texture atlas as Buffered texture
                                      {:keys [font-texture-width
                                              font-texture-height
                                              font-texture-image]} (make-glyph-image char-width char-height new-font)]
@@ -967,6 +971,7 @@
                            next-pow-2-rows
                            font-textures
                            normal-font
+                           fbo-texture
                            antialias
                            character-map-cleared
                            character-map
@@ -1138,9 +1143,9 @@
         (log/info "got key" (or (str @last-key) "nil"))
         ;; change font size on s/m/l keypress
         (case new-key
-          \s (zat/apply-font! terminal "Consolas" "Monospaced" 12 true)
-          \m (zat/apply-font! terminal "Consolas" "Monospaced" 18 true)
-          \l (zat/apply-font! terminal "Consolas" "Monospaced" 24 true)
+          \s (zat/apply-font! terminal "Consolas" "/home/santos/Downloads/cour.ttf" 12 true)
+          \m (zat/apply-font! terminal "Consolas" "/home/santos/Downloads/cour.ttf" 18 true)
+          \l (zat/apply-font! terminal "Consolas" "/home/santos/Downloads/cour.ttf" 24 true)
           \q (zat/destroy! terminal)
           nil)
         (if (= new-key :exit)


fix the session key

fix the session key

--- src/pc/profile.clj
+++ src/pc/profile.clj
@@ -26,7 +26,7 @@
     "localhost"))

 ;; TODO: move to secrets
-(def dev-session-key "iqhtXNfmVCEp69Gtz")
+(def dev-session-key "9WOdevDR9bsnpFXJ")
 (defn http-session-key []
   (or (System/getenv "HTTP_SESSION_KEY")
       dev-session-key))


store non-article origins

store non-article origins

--- src/clj/ceres/curator.clj
+++ src/clj/ceres/curator.clj
@@ -133,7 +133,9 @@
                    (map #(assoc % :article (-> (mc/find-one-as-map (:db @mongo-state) "articles" {:url (:url %)}) :_id)) expanded-urls))
         ancestors (trace-parent record [])]
     (if (nil? articles)
-      (store-origin (assoc % :record oid :ts ts :source source :ancestors ancestors))
+      (do
+        (store-origin (assoc % :record oid :ts ts :source source :ancestors ancestors))
+        nil)
       (doall
        (map
         #(if (:article %)
@@ -265,7 +267,7 @@

   (mc/ensure-index (:db @mongo-state) "articles" (array-map :ts 1))

-  (mc/ensure-index (:db @mongo-state) "urls" (array-map :article 1))
+  (mc/ensure-index (:db @mongo-state) "origins" (array-map :ts 1 :article 1))

   (mc/ensure-index (:db @mongo-state) "tweets" (array-map :id 1) {:unique true})

@@ -320,8 +322,7 @@
         clojure.pprint/pprint))

   (->> (mc/find-maps (:db @mongo-state) "origins")
-       (map #(count (:ancestors %)))
-       (remove #(< % 2))
-       clojure.pprint/pprint)
+       (filter #(nil? (-> % :article)))
+       )

   )


English locale

English locale

--- src/clj/sparqlab/i18n.clj
+++ src/clj/sparqlab/i18n.clj
@@ -55,4 +55,57 @@
                                 :search-query-constructs "Hledané SPARQL konstrukty"
                                 :title "Nalezená cvičení"}
                :sparql-syntax-error {:title "Chyba syntaxe dotazu"
-                                     :expected-label "Očekáváno"}}}})
+                                     :expected-label "Očekáváno"}}
+          :en {:missing "Missing English text"
+               :about {:title "About"}
+               :and "and"
+               :base {:beta-version "Beta version"
+                      :by-category "By categories"
+                      :by-difficulty "By difficulty"
+                      :by-language-constructs "By language constructs"
+                      :data-title "Data"
+                      :exercise "Exercises"
+                      :search "Search"
+                      :search-query "Search term"
+                      :sparql-endpoint "SPARQL endpoint"}
+               :close "Close"
+               :data {:title "Data"}
+               :endpoint {:title "SPARQL endpoint"
+                          :run-query "Run the query"}
+               :error {:title "Error"}
+               :error-modal {:label "Error in query execution"
+                             :message "There was an error in query execution."}
+               :evaluation {:confirm-reveal {:label "Confirm revealing of the solution"
+                                             :no "No"
+                                             :question "Are you sure you want to reveal the solution?"
+                                             :yes "Yes"}
+                            :correct-answer "Right answer"
+                            :incorrect-answer "Wrong answer"
+                            :missing-constructs "Missing constructs"
+                            :prohibited-constructs "Prohibited constructs"
+                            :results "Results"
+                            :reveal-solution "Reveal solution"
+                            :solution "Solution"
+                            :title "Exercise evaluation: %1"}
+               :exercises {:difficulty "difficulty"
+                           :note-title "Note"
+                           :prohibited-constructs "Prohibited constructs"
+                           :required-constructs "Required constructs"
+                           :revealed "Revealed"
+                           :similar-exercises "Related exercises"
+                           :solved "Solved"
+                           :submit "Submit"}
+               :exercises-by-category {:title "Exercises by category"}
+               :exercises-by-difficulty {:title "Exercises by difficulty"}
+               :exercises-by-language-constructs {:note "The exercises are sorted by the number of language constructs they require, starting with those that require the least constructs."
+                                                  :title "Exercises by language constructs"}
+               :internal-error {:message "Internal application error"
+                                :title "Application error"}
+               :loading "Loading"
+               :not-found {:title "Page not found"}
+               :search-results {:not-found "No exercises were found."
+                                :search-query "Search term"
+                                :search-query-constructs "Searched SPARQL constructs"
+                                :title "Exercises found"}
+               :sparql-syntax-error {:title "Invalid query syntax"
+                                     :expected-label "Expected"}}}})


Indentation in conn_mgr.clj

Indentation in conn_mgr.clj

--- src/clj_http/conn_mgr.clj
+++ src/clj_http/conn_mgr.clj
@@ -29,26 +29,26 @@
                        (isTrusted [_ _ _] true))
                      (reify X509HostnameVerifier
                        (^void verify [this ^String host ^SSLSocket sock]
-                         ;; for some strange reason, only TLSv1 really
-                         ;; works here, if you know why, tell me.
-                         (.setEnabledProtocols
-                          sock (into-array String ["TLSv1"]))
-                         (.setWantClientAuth sock false)
-                         (let [session (.getSession sock)]
-                           (when-not session
-                             (.startHandshake sock))
-                           (aget (.getPeerCertificates session) 0)
-                           ;; normally you'd want to verify the cert
-                           ;; here, but since this is an insecure
-                           ;; socketfactory, we don't
-                           nil))
+                        ;; for some strange reason, only TLSv1 really
+                        ;; works here, if you know why, tell me.
+                        (.setEnabledProtocols
+                         sock (into-array String ["TLSv1"]))
+                        (.setWantClientAuth sock false)
+                        (let [session (.getSession sock)]
+                          (when-not session
+                            (.startHandshake sock))
+                          (aget (.getPeerCertificates session) 0)
+                          ;; normally you'd want to verify the cert
+                          ;; here, but since this is an insecure
+                          ;; socketfactory, we don't
+                          nil))
                        (^void verify [_ ^String _ ^X509Certificate _]
-                         nil)
+                        nil)
                        (^void verify [_ ^String _ ^"[Ljava.lang.String;" _
                                       ^"[Ljava.lang.String;" _]
-                         nil)
+                        nil)
                        (^boolean verify [_ ^String _ ^SSLSession _]
-                         true))))
+                        true))))

 ;; New Generic Socket Factories that can support socks proxy
 (defn ^SSLSocketFactory SSLGenericSocketFactory


Remove an unnecessary import

Remove an unnecessary import

--- src/cljam/algo/pileup.clj
+++ src/cljam/algo/pileup.clj
@@ -6,8 +6,7 @@
             [cljam.io.sam.util.quality :as qual]
             [cljam.io.sam.util.refs :as refs]
             [cljam.io.pileup :as plpio])
-  (:import [java.io Closeable]
-           [cljam.io.protocols SAMAlignment]
+  (:import [cljam.io.protocols SAMAlignment]
            [cljam.io.pileup PileupBase LocusPile]))

 (defn- cover-locus? [^long pos ^SAMAlignment aln]


Add ability to configure year period of the economic model.

--- src/cljs/beatha/core.cljs
+++ src/cljs/beatha/core.cljs
@@ -669,8 +669,7 @@
     (init-state
       [_]
       {:config-changed (chan)
-       :width (:width data)
-       :height (:height data)
+       :year-period (:year-period data)
        :corp-quantity (:corp-quantity data)})
     om/IWillMount
     (will-mount [_]
@@ -678,11 +677,13 @@
             reset-c (om/get-state owner :reset)]
         (go
           (while true
-            (let [corp-quantity (<! config-c)]
-              (om/transact! data #(assoc % :corp-quantity corp-quantity))
+            (let [[corp-quantity year-period] (<! config-c)]
+              (om/transact! data #(assoc %
+                                    :corp-quantity corp-quantity
+                                    :year-period year-period))
               (put! reset-c true))))))
     om/IRenderState
-    (render-state [_ {:keys [corp-quantity config-changed
+    (render-state [_ {:keys [corp-quantity year-period config-changed
                              command-info-channel]
                       :as state}]
       (let [started (:started data)]
@@ -694,10 +695,16 @@
                :disabled started
                :onChange
                #(handle-int-config-change % owner state :corp-quantity)})
+         (dom/label nil "Year period (num. of iterations)")
+         (dom/input
+          #js {:type "text" :className "form-control" :value year-period
+               :disabled started
+               :onChange
+               #(handle-int-config-change % owner state :year-period)})
          (dom/button
           #js {:type "button" :className "btn btn-danger btn-lg btn-block"
                :disabled started
-               :onClick #(do (put! config-changed corp-quantity)
+               :onClick #(do (put! config-changed [corp-quantity year-period])
                              (put! command-info-channel
                                    {:type :change-corp-quantity
                                     :cmd corp-quantity}))}
@@ -730,12 +737,14 @@
     (automaton-output-handler [_ data owner msg]
       (let [corp-quantity
             (get-in @data [:automaton :specific :corp-quantity] 4)
+            year-period
+            (get-in @data [:automaton :specific :year-period] 12)
             corps (corps corp-quantity)
             competitor-count
             (count (filter (fn [[k v]] (>= v 0))
                            (dissoc (:capital msg) :government)))
             command-info-c (om/get-state owner :command-info-channel)]
-        (when (zero? (mod (:iteration msg) 6))
+        (when (zero? (mod (:iteration msg) (/ year-period 2)))
           (doseq [corp corps]
             (let [cmd
                   (update-in (a/conservative-corp
@@ -786,7 +795,8 @@
          (partial render-cellular-automaton
                   (gen-app-view
                    a/market-model market-model-customization)
-                  {:corp-quantity 4}))))))
+                  {:corp-quantity 4
+                   :year-period 12}))))))

 (defn render-menu-view
   []


correct no-arg interop invoke: note difference from Clojure!

--- src/cljs/cljs/reader.cljs
+++ src/cljs/cljs/reader.cljs
@@ -71,7 +71,7 @@
     (if (or (nil? ch)
             (whitespace? ch)
             (macro-terminating? ch))
-      (do (unread rdr ch) (.toString sb))
+      (do (unread rdr ch) (. sb (toString)))
       (recur (do (.append sb ch) sb) (read-char rdr)))))

 (defn- skip-line
@@ -213,7 +213,7 @@
     (if (or (nil? ch) (whitespace? ch) (contains? macros ch))
       (do
         (unread reader ch)
-        (match-number (.toString buffer)))
+        (match-number (. buffer (toString))))
       (recur (do (.append buffer ch) buffer) (read-char reader)))))

 (defn read-string
@@ -223,7 +223,7 @@
     (cond
      (nil? ch) (throw "EOF while reading string")
      (= "\\" ch) (recur (escape-char buffer reader) (read-char reader))
-     (= \" ch) (.toString buffer)
+     (= \" ch) (. buffer (toString))
      :default (recur (do (.append buffer ch) buffer) (read-char reader)))))

 (defn read-symbol


Documented the code file

Documented the code file

Identified sections of the code to make it easier to read and identify which
parts are state, functions / components, debugging & repl code.

--- src/cljs/kanban/core.cljs
+++ src/cljs/kanban/core.cljs
@@ -1,8 +1,18 @@
 (ns kanban.core
   (:require [reagent.core :as reagent]))

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; App located at:
+;; http://localhost:3451/index.html
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Debugging in the browser
 (enable-console-print!)

+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Model / State
 (def board
   (reagent/atom
    {:columns
@@ -13,7 +23,11 @@
       :cards [{:title "Following the Reagent tutorial"}
               {:title "Using Evil mode badly"
                :editing true}]
-      :editing true}]}))
+      }]}))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Actions

 (defn- update-title [card-cursor title]
   (swap! card-cursor assoc :title title))
@@ -24,19 +38,24 @@
 (defn- start-editing [card-cursor]
   (swap! card-cursor assoc :editing true))

+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Components
+
 (defn- Card [card-cursor]
   (let [{:keys [editing title]} @card-cursor]
     (if editing
-      [:div.card.editing [:input {:type "text"
-                                  :value title
-                                  :autoFocus true
-                                  :on-change #(update-title card-cursor (.. % -target -value))
-                                  :on-blur #(stop-editing card-cursor)
-                                  :on-key-press #(if (= (.-charCode %) 13)
-                                                   (stop-editing card-cursor))}]]
+      [:div.card.editing
+       [:input {:type "text"
+                :value title
+                :autoFocus true
+                :on-change #(update-title card-cursor (.. % -target -value))
+                :on-blur #(stop-editing card-cursor)
+                :on-key-press #(if (= (.-charCode %) 13)
+                                 (stop-editing card-cursor))}]]
       [:div.card {:on-click #(start-editing card-cursor)} title])))

-
+;; pull request welcome to make this a button :)
 (defn NewCard []
   [:div.new-card
    "+ add new card"])
@@ -61,12 +80,12 @@
      [Column (reagent/cursor board [:columns i])])
    [NewColumn]])

-;; (def cards-cursor
-;;   (reagent/cursor board [:columns 0 :cards]))
+(def cards-cursor
+  (reagent/cursor board [:columns 0 :cards]))

-;; @cards-cursor
+@cards-cursor

-;; (swap! cards-cursor conj {:title "New card in column 0"})
+(swap! cards-cursor conj {:title "New card in column 0"})

 (reagent/render [Board board] (js/document.getElementById "app"))


Added support for boxplots.

Added support for boxplots.

--- src/cljs/medusa/core.cljs
+++ src/cljs/medusa/core.cljs
@@ -191,10 +191,55 @@
                 [:h5.text-center {:ref "alert-title"} (.-title description)]]
                [:div {:ref "alert-description"}]])))))

+(defn alert-boxplot [{:keys [description date]} owner]
+  (let [draw-chart (fn []
+                     (let [data (google.visualization.arrayToDataTable #js [#js ["Label" "Min - Max, Q1 - Q3" "" "" "" date #js {"type" "string", "role" "annotation"}]
+                                                                            (clj->js (.-boxplot description))])
+                           formatter (google.visualization.NumberFormat. #js {"fractionDigits" 4})
+                           _ (do
+                               (.format formatter data 1)
+                               (.format formatter data 2)
+                               (.format formatter data 3)
+                               (.format formatter data 4)
+                               (.format formatter data 5))
+                           element (om/get-node owner "alert-description")
+                           chart (js/google.visualization.ComboChart. element)
+                           options #js {:height 500
+                                        :legend "none"
+                                        :series #js {"0" #js {"type" "candlesticks"}
+                                                     "1" #js {"type" "line"
+                                                              "pointSize" 10
+                                                              "lineWidth" 0
+                                                              "color" "red"}}}]
+                       (.draw chart data options)))
+        update-title (fn []
+                       (let [element (om/get-node owner "alert-title")
+                             title (.-title description)
+                             link (.-link description)]
+                         (aset element "innerHTML" (str "" title ""))))]
+    (reify
+      om/IDidMount
+      (did-mount [_]
+        (update-title)
+        (draw-chart))
+
+    om/IDidUpdate
+    (did-update [_ _ _]
+      (update-title)
+      (draw-chart))
+
+    om/IRender
+    (render [_]
+      (html [:a.list-group-item
+             [:div
+              [:h5.text-center {:ref "alert-title"} (.-title description)]]
+             [:div {:ref "alert-description"}]])))))
+
 (defn alert [{:keys [description date]} owner]
   (let [description (.parse js/JSON description)]
     (condp = (.-type description)
       "graph" (alert-graph {:date date, :description description} owner)
+      "boxplot" (alert-boxplot {:date date, :description description} owner)
       nil)))

 (defn alerts-list [{:keys [alerts metrics-filter]}]


fixed: headers can be nil

fixed: headers can be nil

--- src/ring/jetty.clj
+++ src/ring/jetty.clj
@@ -43,7 +43,7 @@
       (doseq [val val-or-vals]
         (.addHeader response key val))))
   ; Some headers must be set through specific methods
-  (when-let [content-type (headers "Content-Type")]
+  (when-let [content-type (get headers "Content-Type")]
     (.setContentType response content-type))
   ; Apply the body - the method depends on the given body type.
   (cond


(TK-110) Restrict timeout to positive values

--- src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
+++ src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
@@ -89,7 +89,8 @@
     (schema/optional-key :failure-callback-fn) (schema/pred ifn?)
     (schema/optional-key :request-buffer-size) schema/Int
     (schema/optional-key :follow-redirects) schema/Bool
-    (schema/optional-key :idle-timeout) schema/Int))
+    (schema/optional-key :idle-timeout) (schema/both schema/Int
+                                                     (schema/pred pos?))))

 (def ServerContext
   {:state     Atom


add some trivial tests

add some trivial tests

--- test/brainbot/nozzle/esconnect_test.clj
+++ test/brainbot/nozzle/esconnect_test.clj
@@ -33,3 +33,19 @@
   (testing "lastmodified->mtime"
     (is (= 0 (lastmodified->mtime "1970-01-01T00:00:00.000Z")))
     (is (= 1376987900 (lastmodified->mtime "2013-08-20T08:38:20.000Z")))))
+
+
+(deftest test-strip-mime-type-parameters
+  (is (= (strip-mime-type-parameters "text/plain") "text/plain"))
+  (is (= (strip-mime-type-parameters "text/plain ;encoding=utf8") "text/plain")))
+
+(deftest test-make-id
+  (is (= (make-id "foo" "bar" "//baz") "foo/bar/baz")))
+
+(deftest test-permset
+  (is (= (permset ["foo" "bar" "baz"]) #{"foo" "bar" "baz"}))
+  (is (= (permset "foo") #{"foo"})))
+
+(deftest test-get-tags-from-path
+  (is (= (get-tags-from-path "/foo/bar/foo/bar//baz")
+         ["bar" "baz" "foo"])))


Initial atom binding feature

Initial atom binding feature

--- src/dmohs/react/core.cljs
+++ src/dmohs/react/core.cljs
@@ -134,9 +134,28 @@
     (.apply m instance (to-array args))))

+(defn- bind-prop-atom
+  ([this prop-key] (bind-prop-atom this prop-key prop-key))
+  ([this prop-key state-key] (bind-prop-atom this prop-key state-key true))
+  ([this prop-key state-key follow?]
+   (let [props (props this)
+         _ (assert (contains? props prop-key) (str "No prop found at key: " prop-key))
+         a (get props prop-key)]
+     (assert (satisfies? IWatchable a) (str "No watchable atom found at key: " prop-key))
+     (add-watch a this (fn [_ _ old-value new-value]
+                         (swap! (state this) assoc state-key new-value)))
+     (let [bound-props (or (aget this "cljsBoundProps") {})]
+       (aset this "cljsBoundProps"
+             (if follow?
+               (assoc bound-props prop-key state-key)
+               (dissoc bound-props prop-key))))
+     {state-key @a})))
+
+
 (defn- default-arg-map [this]
   {:this this :props (props this) :state (state this) :refs (refs this) :locals (locals this)
-   :after-update (fn [callback] (.setState this #js{} callback))})
+   :after-update (fn [callback] (.setState this #js{} callback))
+   :bind-atom (partial bind-prop-atom this)})

 (defn- arg-map->js [arg-map]
@@ -225,6 +244,25 @@
     (assoc fn-map :get-initial-state wrapped)))

+(defn- wrap-component-will-receive-props [fn-map call-fn]
+  (let [{:keys [component-will-receive-props]} fn-map
+        wrapped (fn [next-props]
+                  (let [next-props (aget next-props "cljs")]
+                    (this-as
+                     this
+                     (when-let [bound-props (aget this "cljsBoundProps")]
+                       (doseq [[prop-key state-key] bound-props]
+                         (let [a (get next-props prop-key)]
+                           (swap! (state this) assoc state-key @a)
+                           (add-watch a this (fn [_ _ old-value new-value]
+                                               (swap! (state this) assoc state-key new-value))))))
+                     (when component-will-receive-props
+                       (call-fn :component-will-receive-props component-will-receive-props
+                                (assoc (default-arg-map this)
+                                       :next-props next-props))))))]
+    (assoc fn-map :component-will-receive-props wrapped)))
+
+
 (defn- wrap-render [fn-map call-fn]
   (let [{:keys [render]} fn-map
         wrapped (fn []
@@ -273,14 +311,7 @@
              #js{:cljsDefault (call-fn k f {})})))
         (wrap-if-present :component-will-mount (create-default-wrapper call-fn))
         (wrap-if-present :component-did-mount (create-default-wrapper call-fn))
-        (wrap-if-present
-         :component-will-receive-props
-         (fn [k f]
-           (fn [next-props]
-             (this-as
-              this
-              (call-fn k f (assoc (default-arg-map this)
-                                  :next-props (aget next-props "cljs")))))))
+        (wrap-component-will-receive-props call-fn)
         (wrap-if-present
          :should-component-update
          (fn [k f]


Add keybinds for word-by-word range selection actions

--- src/flense_nw/keymap.cljs
+++ src/flense_nw/keymap.cljs
@@ -22,6 +22,8 @@
    #{:alt :right} text/move-caret-right-by-word
    #{:shift :left} (some-fn text/adjust-range-left z/prev)
    #{:shift :right} (some-fn text/adjust-range-right z/next)
+   #{:alt :shift :left} text/adjust-range-left-by-word
+   #{:alt :shift :right} text/adjust-range-right-by-word
    #{:meta :shift :k} model/prev-placeholder
    #{:meta :shift :l} model/next-placeholder


extract common fns

extract common fns

--- test/clj_money/api/commodities_test.clj
+++ test/clj_money/api/commodities_test.clj
@@ -11,18 +11,14 @@
             [clj-money.factories.user-factory]
             [clj-money.serialization :as serialization]
             [clj-money.validation :as validation]
-            [clj-money.test-helpers :refer [reset-db
-                                            with-authentication
-                                            find-user
-                                            find-entity
-                                            find-commodity]]
+            [clj-money.test-helpers :as h]
             [clj-money.api.commodities :as api]
             [clj-money.models.commodities :as commodities])
   (:import clojure.lang.ExceptionInfo))

 (def storage-spec (env :db))

-(use-fixtures :each (partial reset-db storage-spec))
+(use-fixtures :each (partial h/reset-db storage-spec))

 (def ^:private commodities-context
   {:users (->> ["john@doe.com" "jane@doe.com"]
@@ -35,14 +31,21 @@
                   :symbol "USD"
                   :type :currency}]})

+(defn- find-user          [ctx] (h/find-user ctx "john@doe.com"))
+(defn- find-other-user    [ctx] (h/find-user ctx "jane@doe.com"))
+(defn- find-entity        [ctx] (h/find-entity ctx "Personal"))
+(defn- find-commodity     [ctx] (h/find-commodity ctx "USD"))
+(defn- select-commodities [ctx]
+  (commodities/search storage-spec {:entity-id (:id (find-entity ctx))}))
+
 (deftest-list get-a-list-of-commodities
   commodities-context
   {:resource-name "commodity"
    :storage storage-spec
-   :find-user-fn #(find-user % "john@doe.com")
-   :find-other-user-fn #(find-user % "jane@doe.com")
+   :find-user-fn find-user
+   :find-other-user-fn find-other-user
    :list-fn api/index
-   :params-fn #(hash-map :entity-id (:id (find-entity % "Personal")))
+   :params-fn #(hash-map :entity-id (:id (find-entity %)))
    :expectation-fn #(= #{"USD"} (->> %
                                      (map :symbol)
                                      (into #{})))})
@@ -57,21 +60,21 @@
   commodities-context
   {:resource-name "commodity"
    :storage storage-spec
-   :find-user-fn #(find-user % "john@doe.com")
-   :find-other-user-fn #(find-user % "jane@doe.com")
+   :find-user-fn find-user
+   :find-other-user-fn find-other-user
    :create-fn api/create
-   :create-params-fn #(assoc commodity-attributes :entity-id (:id (find-entity % "Personal")))
-   :select-resources-fn #(commodities/search storage-spec {:entity-id (:id (find-entity % "Personal"))})
+   :create-params-fn #(assoc commodity-attributes :entity-id (:id (find-entity %)))
+   :select-resources-fn select-commodities
    :compare-fn #(= (:symbol %) "AAPL")})

 (deftest-update update-a-commodity
   commodities-context
   {:resource-name "commodity"
    :storage storage-spec
-   :find-resource-fn #(find-commodity % "USD")
+   :find-resource-fn find-commodity
    :find-updated-resource-fn #(commodities/find-by-id storage-spec %)
-   :find-user-fn #(find-user % "john@doe.com")
-   :find-other-user-fn #(find-user % "jane@doe.com")
+   :find-user-fn find-user
+   :find-other-user-fn find-other-user
    :update-fn api/update
    :comparison-fn #(= (:name %) "US Doll Hairs")
    :update-params {:name "US Doll Hairs"
@@ -82,10 +85,8 @@
   commodities-context
   {:resource-name "commodity"
    :storage storage-spec
-   :find-resource-fn #(find-commodity % "USD")
-   :find-user-fn #(find-user % "john@doe.com")
-   :find-other-user-fn #(find-user % "jane@doe.com")
+   :find-resource-fn find-commodity
+   :find-user-fn find-user
+   :find-other-user-fn find-other-user
    :delete-fn api/delete
-   :select-resources-fn #(commodities/search
-                           storage-spec
-                           {:entity-id (:id (find-entity % "Personal"))}) })
+   :select-resources-fn select-commodities})


New defcontext syntax, no internal fns.

New defcontext syntax, no internal fns.

--- lazytest.clj
+++ lazytest.clj
@@ -34,7 +34,9 @@
 (deftype Context [parents before after])

 (deftype TestCase [contexts children] :as this
-  clojure.lang.IFn (invoke [] (run-test-case this))
+  clojure.lang.IFn
+  (invoke [] (run-test-case this))
+  (invoke [active] (run-test-case this active))
   TestInvokable (invoke-test [states active]
                              (run-test-case this active)))

@@ -110,20 +112,50 @@
     (let [active (reduce close-context active (:parents c))]
       (dissoc active c))))

+;; (let [m {:name name}
+;;         m (if (string? (first decl)) (assoc m :doc (first decl)) m)
+;;         decl (if (string? (first decl)) (next decl) decl)
+;;         bindings (first decl)
+;;         assertions (next decl)]
+;;     (assert (vector? bindings))
+;;     (assert (even? (count bindings)))
+;;     (let [locals (vec (map first (partition 2 bindings)))
+;;           contexts (vec (map (comp coerce-context second) (partition 2 bindings)))]
+;;       (assert (every? symbol locals))
+;;       `(def ~name
+;;             (with-meta (TestCase ~contexts
+;;                                  ~(loop [r [], as assertions]
+;;                                     (if (seq as)
+;;                                       (if (string? (first as))
+;;                                         (recur (conj r `(with-meta (assertion ~locals ~(next as))
+;;                                                           {:doc ~(first as)}))
+;;                                                (nnext as))
+;;                                         (recur (conj r `(assertion ~locals ~(first as))) (next as)))
+;;                                       r)))
+;;               '~m))))
+
 (defmacro defcontext
   "Defines a context.
-  decl => docstring? [parents*] before-fn after-fn?"
+  decl => docstring? [bindings*] before-body* (:after [state] after-body*)?"
   [name & decl]
   (let [m {:name name}
         m (if (string? (first decl)) (assoc m :doc (first decl)) m)
         decl (if (string? (first decl)) (next decl) decl)
-        parents (first decl)
-        m (assoc m :locals parents)
-        before (next decl)
-        after (next decl)]
-    (assert (vector? parents))
-    `(def ~name (with-meta (Context ~parents ~before ~after)
-                  '~m))))
+        bindings (first decl)
+        bodies (next decl)]
+    (assert (vector? bindings))
+    (assert (even? (count bindings)))
+    (let [locals (vec (map first (partition 2 bindings)))
+          contexts (vec (map (comp coerce-context second) (partition 2 bindings)))
+          before (take-while #(not= :after %) bodies)
+          after (next (drop-while #(not= :after %) bodies))
+          before-fn `(fn ~locals ~@before)]
+      (when after (assert (vector? (first after))))
+      (let [after-fn (when after
+                       `(fn ~(vec (concat (first after) locals))
+                          ~@after))]
+        `(def ~name (with-meta (Context ~contexts ~before-fn ~after-fn)
+                      '~m))))))

 ;;; TEST CASE HANDLING
@@ -164,6 +196,10 @@
         (TestResult t results))
       (catch Throwable e (TestThrown t e)))))

+(defn- coerce-context [c]
+  (if (and (symbol? c) (= ::Context (type (var-get (resolve c)))))
+    c (Context [] (fn [] c) nil)))
+
 (defmacro deftest
   "Defines a test case containing assertions that share the same contexts.
   decl => docstring? [binding*] assertion*
@@ -178,7 +214,7 @@
     (assert (vector? bindings))
     (assert (even? (count bindings)))
     (let [locals (vec (map first (partition 2 bindings)))
-          contexts (vec (map second (partition 2 bindings)))]
+          contexts (vec (map (comp coerce-context second) (partition 2 bindings)))]
       (assert (every? symbol locals))
       `(def ~name
             (with-meta (TestCase ~contexts
@@ -374,11 +410,17 @@
 (assert (= ::AssertionThrown (type (a5 "a" "b"))))

 ;; defcontext form
-(defcontext c7 "Context c7" [c5] (fn [s5] 7) (fn [s7 s5] nil))
+(defcontext c7 "Context c7" [s5 c5]
+  (assert (= s5 5))
+  7
+  :after [s7]
+  (assert (= s7 7)))
 (assert (= ::Context (type c7)))
 (assert (= 'c7 (:name (meta c7))))
 (assert (= "Context c7" (:doc (meta c7))))
 (assert (= [c5] (:parents c7)))
+(assert (fn? (:before c7)))
+(assert (fn? (:after c7)))

 ;; deftest form
 (deftest t10 "Test t10"


Exploring logic some more

Exploring logic some more

--- src/clj/algorithms_clj/ancestors.clj
+++ src/clj/algorithms_clj/ancestors.clj
@@ -71,6 +71,24 @@
     (run* [childs]
       (has-parent? childs))
     ))
+
+
+(defn test-dbg-3
+  "Emulation of logic program requires to create 'views' to store each side of a relation"
+  []
+  (def db
+    {:people #{:a :b :c :d}
+     :parent-rels #{[:a :b] [:a :c] [:b :c] [:b :d]}
+     })
+
+  (def parent-view (into {} (:parent-rels db)))
+  (def childs-view (into {} (map (comp vec reverse)) (:parent-rels db)))
+
+  (defn has-parent? [c]
+    (contains? childs-view c))
+
+  (keys childs-view))
+

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


Use `is-module-selected?` in place of equivalent expressions

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -830,7 +830,7 @@
    A random lesson group of each type of lesson (Lecture, Tutorial, etc) will
    be added."
   [moduleCode]
-  (if (not (contains? ModulesSelected moduleCode))
+  (if (not (is-module-selected? moduleCode))
       (let [lessonTypes     (get-all-lesson-types-for-module moduleCode)
             bgColorCssClass (get-next-lesson-bg-color-css-class)

@@ -1400,7 +1400,7 @@

    This deletes every lesson of the module from the timetable."
   [moduleCode]
-  (if (contains? ModulesSelected moduleCode)
+  (if (is-module-selected? moduleCode)
       (let [lessonTypes
             (keys (get ModulesSelected moduleCode))


CMR-663: Added message for failed option validation.

--- src/cmr/common/services/messages.clj
+++ src/cmr/common/services/messages.clj
@@ -2,7 +2,8 @@
   "This namespace provides functions to generate messages used for error reporting, logging, etc.
   Messages used in more than one project should be placed here."
   (:require [clojure.string :as str]
-            [cmr.common.services.errors :as errors]))
+            [cmr.common.services.errors :as errors]
+            [camel-snake-kebab :as csk]))

 (defn data-error [error-type msg-fn & args]
   "Utility method that uses throw-service-error to generate a response with a specific status code
@@ -56,4 +57,10 @@
 (defn invalid-or-opt-setting-msg
   "Creates a message saying which parameter is not allowed to use the 'or' option."
   [param]
-  (format "'or' option is not valid for parameter [%s]" param))+  (format "'or' option is not valid for parameter [%s]" param))
+
+(defn invalid-opt-for-param
+  "Creates a message saying supplied option is not allowed for parameter."
+  [param option]
+  (str "Option [" (csk/->snake_case_string option)
+       "] is not supported for param [" (csk/->snake_case_string param) "]"))


tidy up formatting

tidy up formatting

--- src/overtone/sc/synth.clj
+++ src/overtone/sc/synth.clj
@@ -57,8 +57,7 @@
 ;   UGen that is higher up in the list.
 (defn- with-inputs
   "Returns ugen object with its input ports connected to constants and
-  upstream ugens according to the arguments in the initial
-  definition."
+  upstream ugens according to the arguments in the initial definition."
   [ugen ugens constants grouped-params]
   (when-not (contains? ugen :args)
     (if-not (sc-ugen? ugen)
@@ -69,41 +68,41 @@
                       (:name ugen))))))
   (when-not (every? #(or (sc-ugen? %) (number? %) (string? %)) (:args ugen))
     (throw (IllegalArgumentException.
-             (format "The %s ugen has an invalid argument: %s"
-                     (:name ugen)
-                     (first (filter
-                              #(not (or (sc-ugen? %) (number? %)))
-                              (:args ugen)))))))
+            (format "The %s ugen has an invalid argument: %s"
+                    (:name ugen)
+                    (first (filter
+                            #(not (or (sc-ugen? %) (number? %)))
+                            (:args ugen)))))))

   (let [inputs (flatten
-                 (map (fn [arg]
-                        (cond
-                          ; constant
-                          (number? arg)
-                          {:src -1 :index (index-of constants (float arg))}
-
-                          ; control
-                          (control-proxy? arg)
-                          (param-input-spec grouped-params arg)
-
-                          ; output proxy
-                          (output-proxy? arg)
-                          (let [src (ugen-index ugens (:ugen arg))]
-                            {:src src :index (:index arg)})
-
-                          ; child ugen
-                          (sc-ugen? arg)
-                          (let [src (ugen-index ugens arg)
-                                updated-ugen (nth ugens src)]
-                            (inputs-from-outputs src updated-ugen))))
-                      (:args ugen)))
+                (map (fn [arg]
+                       (cond
+                                        ; constant
+                         (number? arg)
+                         {:src -1 :index (index-of constants (float arg))}
+
+                                        ; control
+                         (control-proxy? arg)
+                         (param-input-spec grouped-params arg)
+
+                                        ; output proxy
+                         (output-proxy? arg)
+                         (let [src (ugen-index ugens (:ugen arg))]
+                           {:src src :index (:index arg)})
+
+                                        ; child ugen
+                         (sc-ugen? arg)
+                         (let [src (ugen-index ugens arg)
+                               updated-ugen (nth ugens src)]
+                           (inputs-from-outputs src updated-ugen))))
+                     (:args ugen)))
         ugen (assoc ugen :inputs inputs)]
     (when-not (every? (fn [{:keys [src index]}]
-                    (and (not (nil? src))
-                         (not (nil? index))))
-                  (:inputs ugen))
+                        (and (not (nil? src))
+                             (not (nil? index))))
+                      (:inputs ugen))
       (throw (Exception.
-               (format "Cannot connect ugen arguments for %s ugen with args: %s" (:name ugen) (str (seq (:args ugen)))))))
+              (format "Cannot connect ugen arguments for %s ugen with args: %s" (:name ugen) (str (seq (:args ugen)))))))

     ;;Add link back to MaxLocalBufs ugen (always at root of tree) if
     ;;ugen is a local-buf.
@@ -163,8 +162,8 @@
         (recur (assoc done group-rate ctl-proxy) (rest todo) (+ offset group-size))))))

 (defn- group-params
-  "Groups params by rate.  Groups a list of parameters into a
-   list of lists, one per rate."
+  "Groups params by rate.  Groups a list of parameters into a list of
+   lists, one per rate."
   [params]
   (let [by-rate (reduce (fn [mem param]
                           (let [rate (:rate param)
@@ -200,11 +199,10 @@
     (throw (IllegalArgumentException. (str "Your synth argument list is not a vector. Instead I found " (type l) ": " l)))))

 (defn- mapify-params
-  "Converts a list of param name val pairs to a param map. If the val
-  of a param is a vector, it assumes it's a pair of [val rate] and
-  sets the rate of the param accordingly. If the val is a plain
-  number, it sets the rate to DEFAULT-RATE. All names are converted to
-  strings"
+  "Converts a list of param name val pairs to a param map. If the val of
+  a param is a vector, it assumes it's a pair of [val rate] and sets the
+  rate of the param accordingly. If the val is a plain number, it sets
+  the rate to DEFAULT-RATE. All names are converted to strings"
   [params]
   (for [[p-name p-val] (partition 2 params)]
     (let [param-map
@@ -328,8 +326,8 @@

 (defn normalize-synth-args
   "Pull out and normalize the synth name, parameters, control proxies
-   and the ugen form from the supplied arglist resorting to defaults
-   if necessary."
+   and the ugen form from the supplied arglist resorting to defaults if
+   necessary."
   [args]
   (let [[sname args]       (if (or (string? (first args))
                                    (symbol? (first args)))
@@ -562,9 +560,9 @@

 (defmacro defsynth
   "Define a synthesizer and return a player function. The synth
-  definition will be loaded immediately, and a :new-synth event will
-  be emitted. Expects a name, an optional doc-string, a vector of
-  synth params, and a ugen-form as it's arguments.
+  definition will be loaded immediately, and a :new-synth event will be
+  emitted. Expects a name, an optional doc-string, a vector of synth
+  params, and a ugen-form as it's arguments.

   (defsynth foo [freq 440]
     (out 0 (sin-osc freq)))
@@ -598,9 +596,7 @@
   (foo :position :head :target 2 440 0.3)

   These can also be abbreviated:
-  (foo :tgt 2 :pos :head)
-
-  "
+  (foo :tgt 2 :pos :head)"
   [s-name & s-form]
   {:arglists '([name doc-string? params ugen-form])}
   (let [[s-name params ugen-form] (synth-form s-name s-form)]
@@ -615,8 +611,8 @@

 (defmacro run
   "Run an anonymous synth definition for a fixed period of time.
-  Useful for experimentation. Does NOT add an out ugen - see #'demo
-  for that. You can specify a timeout in seconds as the first argument
+  Useful for experimentation. Does NOT add an out ugen - see #'demo for
+  that. You can specify a timeout in seconds as the first argument
   otherwise it defaults to *demo-time* ms.

   (run (send-reply (impulse 1) \"/foo\" [1] 43)) ;=> send OSC messages"
@@ -631,10 +627,10 @@

 (defmacro demo
   "Listen to an anonymous synth definition for a fixed period of time.
-  Useful for experimentation.  If the root node is not an out ugen,
-  then it will add one automatically.  You can specify a timeout in
-  seconds as the first argument otherwise it defaults to *demo-time*
-  ms. See #'run for a version of demo that does not add an out ugen.
+  Useful for experimentation.  If the root node is not an out ugen, then
+  it will add one automatically.  You can specify a timeout in seconds
+  as the first argument otherwise it defaults to *demo-time* ms. See
+  #'run for a version of demo that does not add an out ugen.

   (demo (sin-osc 440))      ;=> plays a sine wave for *demo-time* ms
   (demo 0.5 (sin-osc 440))  ;=> plays a sine wave for half a second"
@@ -650,9 +646,8 @@
     `((synth "audition-synth" ~body))))

 (defn active-synths
-  "Return a seq of the actively running synth nodes.  If a synth or
-  inst are passed as the filter it will only return nodes of that
-  type.
+  "Return a seq of the actively running synth nodes.  If a synth or inst
+  are passed as the filter it will only return nodes of that type.

   (active-synths) ;=> [{:type synth :name \"mixer\" :id 12} {:type
                         synth :name \"my-synth\" :id 24}]


totally removed the use of :offset , :line, :col and :end-offset from paredit

--- src/paredit/loc_utils.clj
+++ src/paredit/loc_utils.clj
@@ -1,6 +1,13 @@
 (ns paredit.loc-utils
   (:require [clojure.zip :as zip])
   (:require [clojure.contrib.zip-filter :as zf]))
+
+(defn loc-text [loc]
+  (apply str (map zip/node
+               (filter (comp string? zip/node) (zf/descendants loc)))))
+
+(defn loc-count [loc]
+  (.length ^String (loc-text loc)))

 (defn ^String loc-tag [loc]
   (and loc
@@ -48,13 +55,17 @@
   [loc]
   (and loc (remove zip/branch? (take-while (complement nil?) (iterate zip/prev (zip/prev loc))))))

-(defn loc-text [loc]
-  (apply str (map zip/node
-               (filter (comp string? zip/node) (zf/descendants loc)))))
+(defn start-offset [loc]
+  (cond
+    (nil? loc) 0
+    :else
+      (if-let [l (zip/left loc)]
+        (+ (start-offset l) (loc-count l))
+        (start-offset (zip/up loc)))))

-(declare end-offset)
+#_(declare end-offset)

-(defn start-offset [loc]
+#_(defn start-offset [loc]
   (cond
     (nil? loc) 0
     (string? (zip/node loc))
@@ -65,7 +76,7 @@
       (-> loc zip/node :offset)))

 (defn end-offset [loc]
-  (+ (start-offset loc) (.length ^String (loc-text loc))))
+  (+ (start-offset loc) (loc-count loc)))

 (defn loc-col [loc]
   (loop [loc (zip/prev loc) col 0]
@@ -75,13 +86,9 @@
       (string? (zip/node loc))
         (if (.contains (zip/node loc) "\n")
           (+ col (dec (-> (zip/node loc) (.substring (.lastIndexOf (zip/node loc) "\n")) .length)))
-          (recur (zip/prev loc) (+ col (.length (zip/node loc)))))
+          (recur (zip/prev loc) (+ col (loc-count loc))))
       :else
         (recur (zip/prev loc) col))))
-
-(defn loc-count [loc]
-  (.length ^String (loc-text loc)))
-

 (defn loc-parse-node [loc] ; wrong name, and also, will return (foo) if located at ( or at ) ... so definitely wrong name ...
   (if (string? (zip/node loc))


Shrink netty executor to 1 thread per core, not 100.

--- src/riemann/transport.clj
+++ src/riemann/transport.clj
@@ -83,9 +83,10 @@
     (isSharable [] true)))

 (defn event-executor
-  "Creates a new netty execution handler."
+  "Creates a new netty execution handler for processing events. Defaults to 1
+  thread per core."
   []
-  (DefaultEventExecutorGroup. 100))
+  (DefaultEventExecutorGroup. (.. Runtime getRuntime availableProcessors)))

 (defonce ^DefaultEventExecutorGroup shared-event-executor
   (event-executor))


remnants of the second part

remnants of the second part

--- src/riemann/transport.clj
+++ src/riemann/transport.clj
@@ -3,9 +3,9 @@
   here since netty is the preferred method of providing transports"
   (:use     [slingshot.slingshot :only [try+]]
             [riemann.common      :only [decode-inputstream]]
-            [riemann.core        :only [core]])
-  (:require [riemann.query    :as query]
-            [riemann.protocol :as p])
+            [riemann.core        :only [core]]
+            [riemann.index       :only [search]])
+  (:require [riemann.query    :as query])
   (:import
    [org.jboss.netty.channel ChannelPipelineFactory ChannelPipeline]
    [org.jboss.netty.buffer ChannelBufferInputStream]
@@ -58,7 +58,7 @@
      ;; Handle query
      (let [ast (query/ast (:string (:query msg)))]
        (if-let [i (deref (:index core))]
-         {:ok true :events (p/search i ast)}
+         {:ok true :events (search i ast)}
          {:ok false :error "no index"}))

       {:ok true})


Uses :browser-session in :authorizarion-server

--- src/cylon/oauth/impl/authorization_server.clj
+++ src/cylon/oauth/impl/authorization_server.clj
@@ -20,7 +20,7 @@
    [clj-jwt.core :refer (to-str sign jwt)]
    [ring.middleware.params :refer (wrap-params)]
    [ring.middleware.cookies :refer (cookies-request)]
-   [cylon.session :refer (create-session! assoc-session! ->cookie get-session-value get-session-id get-session cookies-response-with-session get-session-from-cookie)]
+   [cylon.session :refer (create-session! assoc-session! ->cookie get-session-value get-session-id get-session cookies-response-with-session get-session-from-cookie assoc-data! create-and-attach! get-data exists?)]
    [ring.middleware.cookies :refer (wrap-cookies cookies-request cookies-response)]
    [ring.util.response :refer (redirect)]
    [cylon.oauth.encoding :refer (decode-scope encode-scope as-query-string)]))
@@ -32,8 +32,17 @@
     (s/with-fn-validation
       (h req))))

-
-
+(defn init-authentication [component req]
+  (do
+      (debugf "Not authenticated, must authenticate first with %s" (:authenticator component))
+      (create-and-attach! (:browser-session component) req
+                          (initiate-authentication-interaction (:authenticator component) req {})
+                          {:client-id (-> req :query-params (get "client_id"))
+                           :requested-scopes (decode-scope (-> req :query-params (get "scope")))
+                           :state (-> req :query-params (get "state"))
+                           :response-type  "code"})))
+
+;; TODO: review why we need to call "init-authentication" twice in this code (this fn and ::authorization-endpoint handler)
 (defn authorize-client [session component req store]
   (if-let [auth-interaction-session-result (get-result (:authenticator component) req)]
     ;; the session can be authenticated or maybe we are
@@ -53,9 +62,8 @@
                       requires-user-acceptance?
                       required-scopes] :as client}
               (lookup-client+ (:client-registry component) client-id)]
-
-          (assoc-session! (:session-store component) (get-session-id req SESSION-ID) :cylon/authenticated? true)
-          (assoc-session! (:session-store component) (get-session-id req SESSION-ID) :code code)
+          (assoc-data!  (:browser-session component) req {:cylon/authenticated? true :code code})
+

           ;; Remember the code for the possible exchange - TODO expire these
           (swap! store assoc
@@ -113,18 +121,9 @@
           (initiate-authentication-interaction (:authenticator component) req {}))))

     ;; You are not authenticated, so let's authenticate first.
-    (do
-      (debugf "Not authenticated, must authenticate first with %s" (:authenticator component))
-      (let [auth-session
-            (create-session!
-             (:session-store component)
-             {:client-id (-> req :query-params (get "client_id"))
-              :requested-scopes (decode-scope (-> req :query-params (get "scope")))
-              :state (-> req :query-params (get "state"))
-              :response-type  "code"})]
-        (cookies-response-with-session
-         (initiate-authentication-interaction (:authenticator component) req {})
-         SESSION-ID auth-session)))))
+    (init-authentication component req)
+    ))
+

 (defrecord AuthorizationServer [store scopes iss]
@@ -143,21 +142,21 @@
            ;; (Can we do this in a go block however?)

            (debugf "OAuth2 authorization server: Authorizing request")
-
-           (let [session (get-session-from-cookie req SESSION-ID (:session-store component))
-                 {response-type "response_type" client-id "client_id"} (:query-params req)
-                 r-t (or response-type (:response-type session))
-                 ]
-             (case r-t
-               "code" (authorize-client
-                       session
-                       component req store)
-
-               ;; Unknown response_type
-               {:status 400
-                :body (format "Bad response_type parameter: '%s'" response-type)}
-               )
-             ))
+           (if-not (exists? (:browser-session component) req)
+            (init-authentication component req)
+            (let [{response-type "response_type" client-id "client_id"} (:query-params req)
+                  r-t (or response-type (get-data (:browser-session component) req :response-type))
+                  ]
+              (case r-t
+                "code" (authorize-client
+                        (get-data (:browser-session component) req)
+                        component req store)
+
+                ;; Unknown response_type
+                {:status 400
+                 :body (format "Bad response_type parameter: '%s'" response-type)}
+                )
+              )))
          wrap-params
          wrap-schema-validation)

@@ -168,7 +167,7 @@
       ;; TODO I'm worred about the fact we must ensure that the session
       ;; represents a true authenticated user
       (fn [req]
-        (let [session (get-session-from-cookie req SESSION-ID (:session-store component))]
+        (let [session (get-data (:browser-session component) req)]
           (if (:cylon/authenticated? session)
             (let [permitted-scopes (set (map
                                          (fn [x] (apply keyword (str/split x #"/")))
@@ -299,7 +298,7 @@
        map->AuthorizationServer
        (<- (component/using
             [:access-token-store
-             :session-store
+             :browser-session
              :user-domain
              :client-registry
              :authenticator]))))


Refactor buffer tests

Refactor buffer tests

--- src/test/cljc/mikron/runtime/buffer_test.cljc
+++ src/test/cljc/mikron/runtime/buffer_test.cljc
@@ -3,65 +3,30 @@
             [clojure.test.check.clojure-test :as tc.test #?@(:cljs [:include-macros true])]
             [clojure.test.check.properties :as tc.prop #?@(:cljs [:include-macros true])]
             [clojure.test.check.generators :as tc.gen #?@(:cljs [:include-macros true])]
+            [mikron.compiler.schema :as compiler.schema]
             [mikron.runtime.buffer :as buffer]
             [mikron.runtime.test-generators :as test-generators]
             [mikron.runtime.test-util :as test-util]))

-(def processors
-  {:byte    {:packer    buffer/put-byte
-             :unpacker  buffer/take-byte
-             :generator (test-generators/value-generator [:byte])}
-   :short   {:packer    buffer/put-short
-             :unpacker  buffer/take-short
-             :generator (test-generators/value-generator [:short])}
-   :int     {:packer    buffer/put-int
-             :unpacker  buffer/take-int
-             :generator (test-generators/value-generator [:int])}
-   :long    {:packer    buffer/put-long
-             :unpacker  buffer/take-long
-             :generator (test-generators/value-generator [:long])}
-   :ubyte   {:packer    buffer/put-ubyte
-             :unpacker  buffer/take-ubyte
-             :generator (test-generators/value-generator [:ubyte])}
-   :ushort  {:packer    buffer/put-ushort
-             :unpacker  buffer/take-ushort
-             :generator (test-generators/value-generator [:ushort])}
-   :uint    {:packer    buffer/put-uint
-             :unpacker  buffer/take-uint
-             :generator (test-generators/value-generator [:uint])}
-   :varint  {:packer    buffer/put-varint
-             :unpacker  buffer/take-varint
-             :generator (test-generators/value-generator [:varint])}
-   :float   {:packer    buffer/put-float
-             :unpacker  buffer/take-float
-             :generator (test-generators/value-generator [:float])}
-   :double  {:packer    buffer/put-double
-             :unpacker  buffer/take-double
-             :generator (test-generators/value-generator [:double])}
-   :boolean {:packer    buffer/put-boolean
-             :unpacker  buffer/take-boolean
-             :generator (test-generators/value-generator [:boolean])}
-   :binary  {:packer    buffer/put-binary
-             :unpacker  buffer/take-binary
-             :generator (test-generators/value-generator [:binary])}})
-
 (tc.test/defspec buffer-test 100
-  (tc.prop/for-all
-    [[schemas values]
-     (tc.gen/bind (tc.gen/vector (tc.gen/elements (keys #?(:clj  processors
-                                                           :cljs (dissoc processors :float))))
-                                 1 1000)
-                  (fn [schemas]
-                    (tc.gen/tuple (tc.gen/return schemas)
-                                  (apply tc.gen/tuple (map (comp :generator processors) schemas)))))]
-    (let [buffer (buffer/allocate 100000)]
-      (doall (map (fn [schema-name value]
-                    ((:packer (processors schema-name)) buffer value))
-                  schemas
-                  values))
-      (buffer/finalize buffer)
-      (buffer/reset buffer)
-      (test-util/equal? values
-                        (mapv (fn [schema-name]
-                                ((:unpacker (processors schema-name)) buffer))
-                              schemas)))))
+  (let [primitive-schemas (disj (compiler.schema/leaf-descendants compiler.schema/hierarchy :primitive)
+                                #?(:cljs :float))]
+    (tc.prop/for-all
+      [[schemas values]
+       (tc.gen/bind (tc.gen/vector (tc.gen/elements primitive-schemas) 1 1000)
+                    (fn [schemas]
+                      (tc.gen/tuple (tc.gen/return schemas)
+                                    (->> schemas
+                                         (map (comp test-generators/value-generator vector))
+                                         (apply tc.gen/tuple)))))]
+      (let [buffer (buffer/allocate 100000)]
+        (doall (map (fn [schema value]
+                      (buffer/put-value schema buffer value))
+                    schemas
+                    values))
+        (buffer/finalize buffer)
+        (buffer/reset buffer)
+        (test-util/equal? values
+                          (map (fn [schema]
+                                 (buffer/take-value schema buffer))
+                               schemas))))))


add deprecation note in test

add deprecation note in test

--- test/clj/lambdacd/internal/execution_test.clj
+++ test/clj/lambdacd/internal/execution_test.clj
@@ -140,7 +140,7 @@
   (testing "that in doubt, the static output overlays the async output"
     (is (= {:outputs {[0 0] {:status :success } } :status :success }
            (execute-step {} [(some-ctx-with :step-id [0 0]) some-step-that-sends-failure-on-ch-returns-success]))))
-  (testing "that we can pass in a channel that gets a copy of the result-channel messages"
+  (testing "that we can pass in a channel that gets a copy of the result-channel messages (deprecated)"
     (let [result-channel (async/chan 100)]
       (execute-step {} [(some-ctx) some-step-writing-to-the-result-channel] :result-channel result-channel)
       (is (= [[:out "hello world"]] (slurp-chan result-channel)))))


add react :key for module lists

add react :key for module lists

--- src/thi/ng/site/core.cljs
+++ src/thi/ng/site/core.cljs
@@ -295,7 +295,7 @@
     (mapcat
      (fn [{:keys [id uri desc]}]
        [[:dt {:key (str name id)} [:a {:href uri} id]]
-        [:dd desc]])
+        [:dd {:key (str name id "desc")} desc]])
      modules)]])

 (defn project-section


No need to run the update handler on every start up

--- src/tropefest/handler.clj
+++ src/tropefest/handler.clj
@@ -69,7 +69,9 @@
       (->
         (p/load-resource-url "http://tvtropes.org/pmwiki/pmwiki.php/Anime/SamuraiFlamenco")
         p/save-page-links!))
-    (update-handler nil nil)
+    ; Uncomment to update the link count. Not necessary unless for some
+    ; reason you have an incomplete database.
+    ; (update-handler nil nil)
     (timbre/info "Done seeding.")))