Доработка компонента выбора из таблиц

Доработка компонента выбора из таблиц

--- src-cljs/ixinfestor/omut.cljs
+++ src-cljs/ixinfestor/omut.cljs
@@ -56,6 +56,65 @@

 ;; END Common functions and tools
+;;..................................................................................................
+
+;;**************************************************************************************************
+;;* BEGIN omut row spec
+;;* tag: <omut row spec>
+;;*
+;;* description: Данные для отображения строк
+;;*
+;;**************************************************************************************************
+
+
+(def omut-row-key :omut-row)
+
+(def omut-row-app-state {:selected false :collapsed {}})
+
+
+(defn omut-row-init [row]
+  (assoc row omut-row-key omut-row-app-state))
+
+(defn omut-row-if-not-init-init!! [app]
+  (om/transact! app omut-row-key
+                (fn [app]
+                  (if (omut-row-key app)
+                    app
+                    (omut-row-init app)))))
+
+(defn omut-row-row [row]
+  (dissoc row omut-row-key))
+
+
+
+(defn omut-row-set-selected! [app-row v]
+  (assoc-in app-row [omut-row-key :selected] v))
+
+(defn omut-row-set-selected!! [app-row v]
+  (om/update! app-row [omut-row-key :selected] v))
+
+(defn omut-row-set-selected-not!! [app-row]
+  (om/transact! app-row [omut-row-key :selected] not))
+
+(defn omut-row-selected? [app-row]
+  (get-in app-row [omut-row-key :selected] false))
+
+
+
+(defn omut-row-set-collapsed!! [app-row k v]
+  (om/update! app-row [omut-row-key :collapsed k] v))
+
+(defn omut-row-set-collapsed-not!! [app-row k]
+  (om/transact! app-row [omut-row-key :collapsed]
+                (fn [app-row]
+                  (if app-row (update-in app-row [k] not) {k false}))))
+
+(defn omut-row-collapsed? [app-row k]
+  (get-in app-row [omut-row-key :collapsed k] true))
+
+
+
+;; END omut-row
 ;;..................................................................................................

 ;;**************************************************************************************************
@@ -157,7 +216,7 @@

 (defn ui-button [{:keys [text
                          type
-                         lg?
+                         size
                          block?
                          disabled?
                          active?
@@ -172,7 +231,10 @@
                                      :warning "btn-warning"
                                      :danger  "btn-danger"
                                      :link    "btn-link"} type)
-                                   (if lg? " btn-lg" "")
+                                   (if size ({:lg " btn-lg"
+                                              :sm " btn-sm"
+                                              :xs " btn-xs"} size)
+                                       "")
                                    (if block? " btn-block" "")
                                    (if active? " active" "")
                                    )
@@ -472,6 +534,37 @@
 ;;..................................................................................................

+;;**************************************************************************************************
+;;* BEGIN Long text collapser
+;;* tag: <long text collapser>
+;;*
+;;* description: Компонент для отображение длянного текста
+;;*
+;;**************************************************************************************************
+
+
+(defn text-collapser [app owner {k :k}]
+  (reify
+    om/IWillMount
+    (will-mount [_]
+      (omut-row-if-not-init-init!! app))
+    om/IRender
+    (render [_]
+      (let [text (app k "")
+            text-count (count text)]
+        (dom/p nil
+               (ui-button {:text "..."
+                           :size :xs
+                           :active? (not (omut-row-collapsed? @app k))
+                           :on-click #(omut-row-set-collapsed-not!! app k)})
+
+               (if (and (omut-row-collapsed? @app k) (> text-count 90))
+                 (str (.substring text 0 89) "...")
+                 text))))))
+
+;; END Long text collapser
+;;..................................................................................................
+

@@ -998,7 +1091,7 @@
 ;;*
 ;;**************************************************************************************************

-(def key-tr-selected :tr-selected)
+

 (defn ui-table [{:keys [striped?
                         bordered?
@@ -1050,7 +1143,7 @@
             (when clear-selections-fn
               (clear-selections-fn))

-            (om/transact! app key-tr-selected not)
+            (omut-row-set-selected-not!! app)

             (when on-select-fn
               (on-select-fn @app))
@@ -1058,9 +1151,12 @@
             1)]

     (reify
+      om/IWillMount
+      (will-mount [_]
+        (omut-row-if-not-init-init!! app))
       om/IRender
       (render [_]
-        (apply dom/tr #js {:className  (if (key-tr-selected @app) "info" "")
+        (apply dom/tr #js {:className  (if (omut-row-selected? @app) "info" "")
                            :onClick    (partial on-click app)
                            :onTouchEnd (partial on-click app)}
                (app-to-tds-seq-fn app) )))))
@@ -1086,7 +1182,8 @@
                     (om/transact!
                      app
                      (fn [data]
-                       (vec (map #(assoc % key-tr-selected false) data))))))
+                       (println (map omut-row-key data))
+                       (vec (map #(omut-row-set-selected! % false) data))))))
            opts)})))))

@@ -1179,7 +1276,7 @@
 (defn search-view-app-data-selected [app]
   (->> @app
        :data
-       (filter key-tr-selected)))
+       (filter omut-row-selected?)))

 (defn search-view-app-data-selected-first [app]
   (first (search-view-app-data-selected app)))
@@ -1463,6 +1560,7 @@
                           (dom/a #js {:href href
                                       :onClick    (on-click i)
                                       :onTouchEnd (on-click i)
+                                      :data-toggle "dropdown"
                                       }
                                  (when glyphicon
                                    (dom/span #js {:style #js {:paddingRight 4}
@@ -1476,7 +1574,8 @@
 (defn ui-nav-tab [app i body]
   (dom/div #js {:style #js {:display
                             (if (= (:active-tab app) i)
-                              "" "none") }}
+                              "" "none") }
+                :data-toggle "dropdown"}
            body))

@@ -2259,7 +2358,9 @@
                                       ui-type--add-button--text
                                       selection-type
                                       disabled?
-                                      multiselect-row-render-fn]
+                                      multiselect-row-render-fn
+                                      row-pk-fiels
+                                      ]
                                :or {class+ ""
                                     selection-type :one
                                     label-one   "Выбрать ???"
@@ -2268,6 +2369,7 @@
                                     ui-type :input-select
                                     ui-type--add-button--type :default
                                     ui-type--add-button--text "Выбрать..."
+                                    row-pk-fiels [:id]
                                     }}]
   (fn [app _ {:keys [selection-type
                      ui-type
@@ -2343,7 +2445,7 @@
                                                            (multiselect-row-render-fn row)
                                                            (dom/td nil (str @row)))
                                                          (dom/td
-                                                          #js {:style #js {:width "15%"}}
+                                                          #js {:style #js {:width "5%"}}
                                                           (ui-button
                                                            {:text "Удалить"
                                                             :on-click
@@ -2351,12 +2453,12 @@
                                                               (om/transact!
                                                                app :sel
                                                                (fn [selected]
-                                                                 (let [row (dissoc @row key-tr-selected)]
+                                                                 (let [pk (select-keys @row row-pk-fiels)]
                                                                    (->> selected
                                                                         (filter
                                                                          #(not
-                                                                           (= (dissoc % key-tr-selected)
-                                                                              row)))
+                                                                           (= (select-keys % row-pk-fiels)
+                                                                              pk)))
                                                                         vec))))

                                                               1)}))))
@@ -2394,17 +2496,28 @@
                                                                     :modal
                                                                     :search-view
                                                                     :data
-                                                                    (filter key-tr-selected))]
+                                                                    (filter omut-row-selected?))]

                                                   (condp = selection-type
                                                     :multi (om/transact!
                                                             app :sel
                                                             (fn [app]
-                                                              (->> selected
-                                                                   (into app)
-                                                                   (map #(dissoc % key-tr-selected))
-                                                                   set
+                                                              (->> app
+                                                                   (map #(omut-row-set-selected! % false))
+                                                                   (into selected)
+                                                                   (reduce
+                                                                    #(assoc %1
+                                                                            (select-keys %2 row-pk-fiels)
+                                                                            %2)
+                                                                    {})
+                                                                   vals
+                                                                   (sort-by #(-> (select-keys % row-pk-fiels)
+                                                                                vals
+                                                                                sort
+                                                                                vec))
+                                                                   reverse
                                                                    vec)))
+
                                                     :one   (om/update! app :sel (vec selected)))

                                                   (modal-hide (:modal app))


Added dategroup to article.cljs

Added dategroup to article.cljs

--- src-cljs/rmfu_ui/article.cljs
+++ src-cljs/rmfu_ui/article.cljs
@@ -7,10 +7,11 @@
    [:h1.text-center
     "Article"]
    [:div.pre-scrollable.borderbox
-    [:h4.col-lg-9.articleheading
-     "New Legislation that will impact you!"]
-    [:p.col-lg-3.date
-     "October 1, 2015"]
+     [:div.dategroup
+      [:h4.articleheading
+       "New Legislation that will impact you!"]
+      [:p.date
+       "October 1, 2015"]]
     [:p
      "    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute\n              irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n              "
      [:br]


cleanup: remove dead code

cleanup: remove dead code

--- src/babel/core.cljc
+++ src/babel/core.cljc
@@ -1,5 +0,0 @@
-(ns babel.core
-  (:require
-   [dag_unify.core :refer (unify unifyc)]))
-
-(def foo 42)


more WARN logging

more WARN logging

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -122,7 +122,8 @@
           (if (not (= true head-pre-checks))
             (log/warn (str "moreover-head: pre-check missed: fail-path-between "
                            "parent:'" (get-in parent [:rule]) "' and child:"
-                           (get-in child [:rule] (get-in child [:synsem :sem :pred] :nopred)) ".")))
+                           (get-in child [:rule] (get-in child [:synsem :sem :pred] :nopred)) ":"
+                           (fail-path parent child))))
           (if (= *extra-diagnostics* true)
             (let [fail-path (get-fail-path (get-in parent [:head]) child)]
               (log/trace (str "moreover-head: failed to add head: '" (morph child) "' to parent: " (get-in parent [:rule])))


remove recursive (defn over-each-comp-child) and use a (mapcat) instead

--- src/babel/over.cljc
+++ src/babel/over.cljc
@@ -78,18 +78,6 @@
        (over-each-head-child parent (rest children))))
     (do
       (log/trace (str "over-each-head-child: done. returning nil."))
-      nil)))
-
-(defn over-each-comp-child [parent children]
-  (log/trace (str "over-each-comp-child: parent type: " (type parent)))
-  (log/trace (str "over-each-comp-child: comp children type: " (type children)))
-  (if (not (empty? children))
-    (let [each-child (first children)]
-      (lazy-cat
-       (overc parent each-child)
-       (over-each-comp-child parent (rest children))))
-    (do
-      (log/trace (str "over-each-comp-child: done. returning nil."))
       nil)))

 (def ^:dynamic *extra-diagnostics* false)
@@ -424,8 +412,9 @@
      (log/trace (str "comp is a seq - actual type is " (type comp)))
      (filter (fn [result]
                (not (fail? result)))
-             (over-each-comp-child parent comp-children)))
-
+             (mapcat (fn [child]
+                       (overc parent child))
+                     comp-children)))
    true
    (let [result (moreover-comp parent comp null-sem-impl)
          is-fail? (fail? result)]


tiny refactoring in scoped-counter

tiny refactoring in scoped-counter

--- test/duratom/scoped_counter_example.clj
+++ test/duratom/scoped_counter_example.clj
@@ -34,7 +34,7 @@
     (do (swap! dura pop)
         v)
     (let [start (-> dura meta :service-id)]
-      (println dura  "has run out of values => wrapping round...")
+      (println  (format "Service %s has run out of values => wrapping round..." start))
       (reset! dura (scoped-seq start end step))
       (recur end step dura))))

@@ -60,8 +60,8 @@
         generate (partial generate! end n-services)]
     ;; unleash them all!
     (dotimes [_ 15]
-      (doall (pmap #(do (println (generate %))
-                        (Thread/sleep (rand-int 1000)))
+      (doall (pmap #(do (Thread/sleep (rand-int 1000))
+                        (println (generate %)))
                    duratoms)))

     (doall (pmap core/destroy duratoms))


Dereferencing block gives content, if available.

--- src/blocks/data.clj
+++ src/blocks/data.clj
@@ -238,14 +238,7 @@
   ; TODO: what should this do?
   (deref
     [this]
-    (merge
-      _attrs
-      {:id id
-       :size size
-       :block/state
-       (cond content :literal
-             reader  :lazy
-             :else   :empty)}))
+    content)

   clojure.lang.IPending


removed inner defonce

removed inner defonce

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -297,21 +297,23 @@
     (raf-step! c)
     c))

+(defonce tick-loop (atom nil))

 (defn start! []
   (swap! app-state merge (make-game @app-state default-size))
-  (defonce tick-loop
-    (go-loop [tick 0]
-      (<! (timeout (:tick-ms @app-state)))
-      (<! raf-chan)
-      (let [app        @app-state
-            move-count (count (:moves app))
-            tick       (if (>= tick move-count) 0 tick)]
-        (swap! app-state assoc :tick tick)
-        (<! (paint-canvas! app tick))
-        (if (or (zero? move-count) (= tick (dec move-count)))
-          (recur 0)
-          (recur (inc tick)))))))
+  (when (nil? @tick-loop)
+    (reset! tick-loop
+            (go-loop [tick 0]
+              (<! (timeout (:tick-ms @app-state)))
+              (<! raf-chan)
+              (let [app        @app-state
+                    move-count (count (:moves app))
+                    tick       (if (>= tick move-count) 0 tick)]
+                (swap! app-state assoc :tick tick)
+                (<! (paint-canvas! app tick))
+                (if (or (zero? move-count) (= tick (dec move-count)))
+                  (recur 0)
+                  (recur (inc tick))))))))

 (defn get-camera! [skip-howto?]


remove `println` (debugging) expression

remove `println` (debugging) expression

--- src/chazel/core.clj
+++ src/chazel/core.clj
@@ -101,7 +101,6 @@
   ([creds]
    (with-creds creds (Config.)))
   ([{:keys [group-name group-password]} config]
-   (println group-name group-password )
    (let [group-config (GroupConfig. group-name group-password)]
      (condp instance? config
        Config       (.setGroupConfig ^Config config group-config)
@@ -171,8 +170,7 @@
      ci
      (try
        (info "connecting to: " (secrefy conf))
-       (reset! c-instance
-               (HazelcastClient/newHazelcastClient (client-config conf)))
+       (reset! c-instance (HazelcastClient/newHazelcastClient (client-config conf)))
        (catch Throwable t
          (warn "could not create hazelcast a client instance: " t))))))

@@ -233,12 +231,6 @@
   (-> instance
       local-member-by-instance
       (.setStringAttribute k v)))
-
-#_(defn members-by-instance
-  [instance]
-  (-> instance
-      (.getCluster)
-      (.getLocalMember)))

 (defn hz-list
   ([m]
@@ -545,27 +537,34 @@
     (onResponse [this response]
       (on-response response))))

-(defn task [fun & args]
+(defn task
+  [fun & args]
   (let [{:keys [^IExecutorService exec-svc members]} (apply task-args args)]
     (if (= :all members)
       (.executeOnAllMembers exec-svc (Rtask. fun))
       (.execute exec-svc (Rtask. fun)))))

-(defn ftask [fun & args]
-  (let [{:keys [^IExecutorService exec-svc members callback]} (apply task-args args)]
+(defn ftask
+  [fun & args]
+  (let [{:keys [^IExecutorService exec-svc members callback]} (apply task-args args)
+        ctask (Ctask. fun)]
     (if (= :all members)
-      (.submitToAllMembers exec-svc (Ctask. fun))    ;; TODO: add MultiExecutionCallback
+      (.submitToAllMembers exec-svc ctask)    ;; TODO: add MultiExecutionCallback
       (if callback
-        (.submit exec-svc
-                 (Ctask. fun)
-                 (execution-callback callback))
-        (.submit exec-svc
-                 (Ctask. fun))))))
-
-(defn mtake [n m]
-  (into {} (take n (hz-map m))))
-
-(defn ->mtake [n mname]                 ;; for clients
+        (.submit exec-svc ctask (execution-callback callback))
+        (.submit exec-svc ctask)))))
+
+(defn mtake
+  ([m]
+   (mtake :all m))
+  ([n m]
+   (let [xform (if (= :all n)
+                 (map identity)
+                 (take n))]
+     (into {} xform (hz-map m)))))
+
+(defn ->mtake
+  [n mname]                 ;; for clients
   @(ftask (partial mtake n mname)))

 ;; to be a bit more explicit about these tasks (their futures) problems


PLATFORM-2818: added tests for full-size webp images

--- test/vignette/http/integration_test.clj
+++ test/vignette/http/integration_test.clj
@@ -124,6 +124,18 @@
       (get (:headers response) "Cache-Control") => "public, max-age=31536000"
       (:body response) => nil?)

+    (let [response (client/get (format "http://localhost:%d/bucket/a/ab/beach.jpg/revision/latest" default-port) {:as :byte-array, :accept "image/webp"})]
+      (:status response) => 200
+      (get (:headers response) "Surrogate-Key") => "6f13d7df6b332e4945d90bd6785226b535f8b248"
+      (get (:headers response) "Content-Disposition") => "inline; filename=\"beach.jpg.webp\"; filename*=UTF-8''beach.jpg.webp"
+      (Integer/parseInt (get (:headers response) "Content-Length")) => (roughly 162350 50)
+      (get (:headers response) "Connection") => "close"
+      (get (:headers response) "Content-Type") => "image/webp"
+      (vec (:body response)) => (has-prefix riff-header)
+      (vec (:body response)) => (contains webp-header)
+      (get (:headers response) "Cache-Control") => "public, max-age=31536000")
+
+
     (let [response (client/get (format "http://localhost:%d/bucket/a/ab/beach.jpg/revision/latest/scale-to-width/200" default-port) {:as :byte-array, :accept "image/webp"})]
       (:status response) => 200
       (get (:headers response) "Surrogate-Key") => "6f13d7df6b332e4945d90bd6785226b535f8b248"


PLATFORM-2818: fixing tests

PLATFORM-2818: fixing tests

--- test/vignette/http/integration_test.clj
+++ test/vignette/http/integration_test.clj
@@ -127,7 +127,7 @@
     (let [response (client/get (format "http://localhost:%d/bucket/a/ab/beach.jpg/revision/latest" default-port) {:as :byte-array, :accept "image/webp"})]
       (:status response) => 200
       (get (:headers response) "Surrogate-Key") => "6f13d7df6b332e4945d90bd6785226b535f8b248"
-      (get (:headers response) "Content-Disposition") => "inline; filename=\"beach.jpg.webp\"; filename*=UTF-8''beach.jpg.webp"
+      (get (:headers response) "Content-Disposition") => "inline; filename=\"beach.webp\"; filename*=UTF-8''beach.webp"
       ;(Integer/parseInt (get (:headers response) "Content-Length")) => (roughly 162360 50)
       (get (:headers response) "Connection") => "close"
       (get (:headers response) "Content-Type") => "image/webp"
@@ -138,7 +138,7 @@
     (let [response (client/get (format "http://localhost:%d/bucket/a/ab/baboon.png/revision/latest" default-port) {:as :byte-array, :accept "image/webp"})]
       (:status response) => 200
       (get (:headers response) "Surrogate-Key") => "e77cd6979116303a6d50610962fa9790469574c2"
-      (get (:headers response) "Content-Disposition") => "inline; filename=\"baboon.png.webp\"; filename*=UTF-8''baboon.png.webp"
+      (get (:headers response) "Content-Disposition") => "inline; filename=\"baboon.webp\"; filename*=UTF-8''baboon.webp"
       ;(Integer/parseInt (get (:headers response) "Content-Length")) => (roughly 170350 50)
       (get (:headers response) "Connection") => "close"
       (get (:headers response) "Content-Type") => "image/webp"
@@ -159,7 +159,7 @@
     (let [response (client/get (format "http://localhost:%d/bucket/a/ab/baboon.png/revision/latest/scale-to-width/200" default-port) {:as :byte-array, :accept "image/webp"})]
       (:status response) => 200
       (get (:headers response) "Surrogate-Key") => "e77cd6979116303a6d50610962fa9790469574c2"
-      (get (:headers response) "Content-Disposition") => "inline; filename=\"baboon.png.webp\"; filename*=UTF-8''baboon.png.webp"
+      (get (:headers response) "Content-Disposition") => "inline; filename=\"baboon.webp\"; filename*=UTF-8''baboon.webp"
       (Integer/parseInt (get (:headers response) "Content-Length")) => (roughly 10030 50)
       (get (:headers response) "Connection") => "close"
       (get (:headers response) "Cache-Control") => "public, max-age=31536000"


only run affix code on when table is there

--- src/desdemona/ui/table.cljs
+++ src/desdemona/ui/table.cljs
@@ -56,33 +56,35 @@
         table-sticky (sel1 :#table-sticky)
         sticky-headers (sel [:.table-sticky :th])
         table-headers (sel [:.table-sorted :th])
-        page-header-height (get-el-height (sel1 :#page-nav))
-        page-header-margin-bot (d/px (sel1 :#page-nav) :margin-bottom)
+        page-nav (sel1 :#page-nav)
         page-scroll-y (.-pageYOffset js/window)]
-    ;set sticky-table width
-    (d/set-style! table-sticky
-                  :width
-                  (str (get-el-width table) "px"))
-    ;set table-headers widths
-    (doseq [[sticky-th table-th] (map vector
-                                      sticky-headers
-                                      table-headers)]
-      (d/set-style! sticky-th
+    (when (pos? (count sticky-headers))
+      ;set sticky-table width
+      (d/set-style! table-sticky
                     :width
-                    (str (get-el-width table-th) "px")))
-    ;set top position
-    (d/set-style! table-sticky
-                  :top
-                  (str (- page-scroll-y
-                          page-header-height
-                          page-header-margin-bot)
-                       "px"))
-    ;recur
-    (.requestAnimationFrame js/window set-sticky-table-widths)))
+                    (str (get-el-width table) "px"))
+        ;set table-headers widths
+      (doseq [[sticky-th table-th] (map vector
+                                        sticky-headers
+                                        table-headers)]
+        (d/set-style! sticky-th
+                      :width
+                      (str (get-el-width table-th) "px")))
+        ;set top position
+      (d/set-style! table-sticky
+                    :top
+                    (str (- page-scroll-y
+                            (get-el-height page-nav)
+                            (d/px page-nav :margin-bottom))
+                         "px"))
+      (.requestAnimationFrame js/window set-sticky-table-widths))))

 (def sticky-header-component
   (with-meta sticky-table-header
-    {:component-did-mount #(set-sticky-table-widths)}))
+    {:component-did-mount (fn [this]
+                            (.requestAnimationFrame
+                             js/window
+                             set-sticky-table-widths))}))

 (defn table-component
   []


Tweaked function names.

Tweaked function names.


Minimize use of :use in engulf.benchmark ns

--- src/engulf/benchmark.clj
+++ src/engulf/benchmark.clj
@@ -1,18 +1,13 @@
 (ns engulf.benchmark
   (:require [engulf.utils :as utils]
             [clojure.tools.logging :as log]
-            [engulf.ning-client :as ning-client])
+            [engulf.ning-client :as ning-client]
+            [engulf.recorder :as rec]
+            [engulf.worker :as wrkr])
   (:use clojure.tools.logging
         noir-async.utils
         lamina.core
-        [engulf.utils :only [send-bench-msg]]
-        [engulf.worker :only [work warmup create-single-url-worker]]
-        [engulf.recorder :only [create-recorder
-                                record-result
-                                record-error
-                                record-start
-                                processed-stats
-                                record-end]])
+        [engulf.utils :only [send-bench-msg]])
   (:import java.util.concurrent.atomic.AtomicLong
            java.net.URL))

@@ -36,9 +31,9 @@
     (if (not (compare-and-set! state :initialized :started))
       (io! (log/warn (str "Could not start from: @state")))
       (do
-        (record-start recorder)
+        (rec/record-start recorder)
         (doseq [worker @workers]
-          (if-let [res-ch (work worker)]
+          (if-let [res-ch (wrkr/work worker)]
             (handle-result this res-ch)))
         (compare-and-set! broadcast-task nil
                           (broadcast-at-interval this 200)))))
@@ -48,7 +43,7 @@
     (when (compare-and-set! state :started :stopped)
       (do
         (ning-client/close-client client)
-        (record-end recorder)
+        (rec/record-end recorder)
         (doseq [worker @workers]
           (swap! (:state worker) (fn [s] :stopped)))
         (broadcast-state this))))
@@ -72,13 +67,13 @@
     (on-success res-ch (fn [[result next-result]]
      (let [{:keys [worker-id]} result]
        (when (check-result-recordability? this)
-         (record-result recorder worker-id result)))
+         (rec/record-result recorder worker-id result)))
      (handle-result this next-result)))
     (on-error res-ch (fn [[result next-result]]
       (let [{:keys [worker-id error]} result]
         (log/warn error (str "Error received from worker" worker-id))
         (when (check-result-recordability? this)
-          (record-error recorder worker-id error))
+          (rec/record-error recorder worker-id error))
         (handle-result this next-result)))))

   (broadcast-state [this]
@@ -92,7 +87,7 @@
    (set-interval millis #(broadcast-state this)))

   (stats [this]
-    (processed-stats recorder)))
+    (rec/processed-stats recorder)))

 (defn create-workers-for-benchmark
   "Creates a vector of workers instantiated via worker-fn, which
@@ -106,7 +101,7 @@
 (defn create-benchmark
  "Create a new Benchmark record. This encapsulates the full benchmark state"
  [client url worker-count max-runs worker-fn]
- (let [recorder (create-recorder)
+ (let [recorder (rec/create-recorder)
        benchmark (Benchmark. (atom :initialized)
                              client
                              url
@@ -124,7 +119,7 @@
   "Create a new benchmark. You must call start on this to begin"
   [url concurrency requests]
   (let [client (ning-client/create-client {:max-conns-per-host concurrency})
-        worker-fn (partial create-single-url-worker client url)]
+        worker-fn (partial wrkr/create-single-url-worker client url)]
     (create-benchmark client url concurrency requests worker-fn)))

 (defn replace-current-benchmark


Better printing method for conf matrix.

Better printing method for conf matrix.

--- cortex/src/cortex/util.cljc
+++ cortex/src/cortex/util.cljc
@@ -672,14 +672,14 @@

 (defn get-or-new-array
-  "Gets an array from the associative dtata structure item, or returns a new empty array
+  "Gets an array from the associative dtata structure item, or returns a new empty array
    of the specified shape"
   [item kywd shape]
   (or (get item kywd)
       (b/new-array shape)))

 (defn get-or-array
-  "Gets an array from the associative dtata structure item, or returns a new mutable array
+  "Gets an array from the associative dtata structure item, or returns a new mutable array
    containing a clone of data"
   [item kywd data]
   (or (get item kywd)
@@ -734,13 +734,11 @@

 (defn print-confusion-matrix
   [conf-mat]
-  (let [ks (sort (keys conf-mat))
-        label-len (inc (int (apply max (map count ks))))
-        prefix (apply str (repeat label-len " "))
-        s-fmt (str "%" label-len "s")]
-    (apply println prefix ks)
-    (doseq [k ks]
-      (apply println (format s-fmt k) (map #(get-in conf-mat [k %]) ks)))))
+  (let [conf-rows (mapv (fn [[k v]]
+                          (merge v {:label k}))
+                        conf-mat)
+        label-row (vec (concat [:label] (keys conf-mat)))]
+    (pp/print-table label-row conf-rows)))

 ;;;; Time


remove extra assertions on screenshot

remove extra assertions on screenshot

--- src/crison/main.clj
+++ src/crison/main.clj
@@ -65,10 +65,8 @@
 (defn take-screenshot
   [driver f]
   (let [s-file (str (date) "_" (.getName f) "-screenshot.png")]
-    (is (string? (wc/get-screenshot driver :base64)))
-    (is (> (count (wc/get-screenshot driver :bytes)) 0))
-    (is (= (class (wc/get-screenshot driver :file)) java.io.File))
-    (is (= (class (wc/get-screenshot driver :file s-file)) java.io.File)))
+    (wc/get-screenshot driver :file s-file))
+

   ;; the following will throw an exception if deletion fails, hence our test
   ;(clojure.java.io/delete-file screenshot-file)


session mit stamm

session mit stamm

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -1,15 +1,33 @@
 ;; When executed, this file will run a basic web server
 ;; on http://localhost:8080.
+(ns hello-world.core
+  (:require [ring.middleware.params :as p]
+        [ring.util.response :as r]
+        [ring.adapter.jetty :as j]
+            [clojure.java.jdbc :as jdbc])
+  (:gen-class))

-(ns ring.example.params
-  (:use ring.middleware.params
-        ring.util.response
-        ring.adapter.jetty))
+(let [db-host "localhost"
+      db-port 3306
+      db-name "mgm_schema"]
+
+  (def mysql-db {:classname "com.mysql.jdbc.Driver" ; must be in classpath
+           :subprotocol "mysql"
+           :subname (str "//" db-host ":" db-port "/" db-name)
+           ; Any additional keys are passed to the driver
+           ; as driver-specific properties.
+           :user ""
+           :password ""}))
+
+
+(defn sqlquery [name]
+
+(first (jdbc/query mysql-db [(str "select * from konten where Name='" name "'")])))

 (defn page [name]
   (str ""
        (if name
-         (str "Nice to meet you, " name "!")
+  (str "Nice to meet you, " name "! \n" (sqlquery name) )
          (str "<form>"
               "Name: <input name='name' type='text'>"
               "<input type='submit'>"
@@ -17,34 +35,23 @@
        ""))

 (defn handler [{{name "name"} :params}]
-  (-> (response (page name))
-      (content-type "text/html")))
+  (-> (r/response (page name))
+      (r/content-type "text/html")))

 ;(def sqlquery
 ;    (j/query mysql-db ["select * from konten"]))

 (def app
-  (-> handler wrap-params))
+  (-> handler p/wrap-params))

-(require '[clojure.java.jdbc :as j])

-(let [db-host "localhost"
-      db-port 3306
-      db-name "mgm_schema"]
-
-  (def mysql-db {:classname "com.mysql.jdbc.Driver" ; must be in classpath
-           :subprotocol "mysql"
-           :subname (str "//" db-host ":" db-port "/" db-name)
-           ; Any additional keys are passed to the driver
-           ; as driver-specific properties.
-           :user ""
-           :password ""}))
-;geht:
-;(j/insert! mysql-db :konten
 ;           {:Kontonummer 11 :Kontostand 31}
 ;           {:Kontonummer 12 :Kontostand 11})

-(run-jetty app {:port 8080})
+(defn -main
+ "Kommentar."
+ [& args]
+ (j/run-jetty app {:port 8080}))
 ;(def server (run-jetty app {:port 8080 :join? false}))


Fixed about template for responsive styles.

--- src/sicpclojure/templates/about.clj
+++ src/sicpclojure/templates/about.clj
@@ -17,10 +17,12 @@
        css
        fonts])
     [:body
-     [:div.sidebar
-      [:nav
-       [:p [:a {:href "pages/contents.html"} "Contents"]]
-       [:p#colorscheme ]]
-      [:footer footer]]
-     [:div.content
-      [:div.chaptertext content]]]))
+     [:div.container
+      [:div.row
+       [:div {:class "sidebar span3"}
+        [:nav
+         [:p [:a {:href "pages/contents.html"} "Contents"]]
+         [:p#colorscheme ]]
+        [:footer footer]]
+       [:div {:class "content span9 offset3"}
+        [:div.chaptertext content]]]]]))


`check` should return the value of its last result

--- src/metabase/api/common.clj
+++ src/metabase/api/common.clj
@@ -66,8 +66,8 @@
                                       [[code-or-code-message-pair (first rest-args)] (rest rest-args)])]
      (when-not test
        (throw (ApiException. (int code) message)))
-     (when-not (empty? rest-args)
-       (recur (first rest-args) (second rest-args) (drop 2 rest-args))))))
+     (if (empty? rest-args) test
+         (recur (first rest-args) (second rest-args) (drop 2 rest-args))))))

 (defmacro require-params
   "Checks that a list of params are non-nil or throws a 400."


Added testing system for tests that need config only.


Switch to 250 random coordinate instead of glider

--- src/gol/client.cljs
+++ src/gol/client.cljs
@@ -32,7 +32,7 @@
 (def step (stepper neighbours #{3} #{2 3}))

 (def app-state
-  (atom {:gen #{[2 0] [2 1] [2 2] [1 2] [0 1]}}))
+  (atom {:gen (set (take 250 (distinct (partition 2 (repeatedly #(rand-int 50))))))}))

 (defn cell
   [cell owner]


add 'Juan'

add 'Juan'

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -399,6 +399,16 @@
          :synsem {:cat :verb
                   :sem {:subj {:animate true}
                         :pred :go}}}
+
+   "Juan" {:synsem {:cat :noun
+                    :pronoun false
+                    :propernoun true
+                    :case :nom
+                    :agr {:gender :masc
+                          :number :sing}
+                    :sem {:human true
+                          :pred :Juan}
+                    :subcat '()}}
     "Juan y yo"
       [{:synsem {:cat :noun
                  :pronoun true


handle irregular preterito

handle irregular preterito

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -107,13 +107,13 @@

    "dar" {:espanol  {:present {:1sing "doy"
-                               :2plur "dais"}}
+                               :2plur "dais"}
                      :preterito {:1sing "di"
                                  :2sing "diste"
                                  :3sing "diò"
                                  :1plur "dimos"
                                  :2plur "disteis"
-                                 :3plur "dieron"}
+                                 :3plur "dieron"}}
           :synsem {:cat :verb
                    :sem {:pred :give}}}


prevent js error when embed content has no image

--- src/braid/ui/views/embed.cljs
+++ src/braid/ui/views/embed.cljs
@@ -6,19 +6,19 @@
   (str "rgb(" (arr 0) "," (arr 1) "," (arr 2) ")"))

 (defn- website-embed-view [content]
-  (let [img (get-in content [:images 0])]
-    [:div.content.loaded.website
+  [:div.content.loaded.website
+   (if-let [img (get-in content [:images 0])]
      [:img.image {:src (img :url)
                   :style {:background-color
                           (arr->rgb (get-in img [:colors 0 :color]))}}]
-
-     [:div.about
-      [:div.provider
-       [:div.favicon {:style {:background-image
-                              (str "url(" (:favicon_url content) ")")}}]
-       [:div.name (:provider_name content)]]
-      [:div.title (:title content)]
-      [:div.url (:url content)]]]))
+     [:img.image {:src (:favicon_url content)}])
+   [:div.about
+    [:div.provider
+     [:div.favicon {:style {:background-image
+                            (str "url(" (:favicon_url content) ")")}}]
+     [:div.name (:provider_name content)]]
+    [:div.title (:title content)]
+    [:div.url (:url content)]]])

 (defn- video-overlay-view [content]
   [:div.content
@@ -29,14 +29,14 @@

 (defn- video-embed-view [content]
   [:div.video
-   (let [img (get-in content [:images 0])]
+   (when-let [img (get-in content [:images 0])]
      [:img {:src (img :url)
             :style {:background-color
                     (arr->rgb (get-in img [:colors 0 :color]))}}])])

 (defn- image-embed-view [content]
   [:div.image
-   (let [img (get-in content [:images 0])]
+   (when-let [img (get-in content [:images 0])]
      [:img {:src (img :url)
             :style {:background-color
                     (arr->rgb (get-in img [:colors 0 :color]))}}])])
@@ -68,6 +68,8 @@
                [video-embed-view @content]
                (= "photo" (get-in @content [:media :type]))
                [image-embed-view @content]
+               (@content :url)
+               [website-embed-view @content]
                :else
-               [website-embed-view @content])]
+               nil)]
             [:div.content.loading])])})))


prevent spurious log message

prevent spurious log message

--- src/io/exo/jobs.clj
+++ src/io/exo/jobs.clj
@@ -40,4 +40,5 @@
 (defn -main
   "Start the API"
   [& args]
-  (server/run-server (mksite job-api) {:port 8080}))
+  (server/run-server (mksite job-api) {:port 8080})
+  nil)


openstack swagger model

openstack swagger model

--- src/celestial/api/systems.clj
+++ src/celestial/api/systems.clj
@@ -37,6 +37,7 @@
   :machine {:type "Machine"}
   :aws {:type "Aws" :description "An EC2 based system"}
   :physical {:type "Physical" :description "A physical machine"}
+  :openstack {:type "Openstack" :description "An openstack based instance"}
   :proxmox {:type "Proxmox" :description "A Proxmox based system"}
   :vcenter {:type "Vcenter" :description "A vCenter based system"})

@@ -54,6 +55,10 @@
 (defmodel physical :mac :string)

 (defmodel aws :instance-type :string :key-name :string :endpoint :string)
+
+(defmodel openstack
+  :flavor :string :key-name :string :tenant :string
+  :security-groups {:type "List"} :networks {:type "List"})

 (defmodel vcenter :pool :string :datacenter :string :hostsystem :string :disk-format :string)


Nitpick - if you use %2 then use %1 instead of %

--- src/overcode/introvert.cljs
+++ src/overcode/introvert.cljs
@@ -76,11 +76,11 @@
    (cond
     (and (arr? val1) (arr? val2))
     (and (= (count val1) (count val2))
-         (every? identity (map #(deep= % %2 visited) val1 val2)))
+         (every? identity (map #(deep= %1 %2 visited) val1 val2)))

     (and (obj? val1) (obj? val2))
     (and (= (obj-size val1) (obj-size val2))
-         (every? identity (map #(deep= % %2 visited) (js/Object.keys val1) (js/Object.keys val2)))
+         (every? identity (map #(deep= %1 %2 visited) (js/Object.keys val1) (js/Object.keys val2)))
          (every? #(deep= (aget val1 %) (aget val2 %) visited) (js/Object.keys val1)))

     :else (= val1 val2)))


fix bug in DiskOut ugen - it has one arg rather than 0 :-)

--- src/overtone/sc/ugen/io.clj
+++ src/overtone/sc/ugen/io.clj
@@ -27,7 +27,6 @@
        :args [{:name "bufnum"}
               {:name "channelsArray" :mode :append-sequence}],
        :rates #{:ar},
-       :num-outs 0
        :check (all-but-first-input-ar "channelsArray must all be audio rate")
        :doc "stream audio out to disk file"}


add call-self function

add call-self function

Signed-off-by: Yen-Chin Lee <082d453d72dce940e12089a4ad48b97cfe1f3ec4@gmail.com>

--- src/clj/brains_brain/core.clj
+++ src/clj/brains_brain/core.clj
@@ -4,6 +4,7 @@
             [seesaw.border :refer [line-border]]
             [clojure.string :as str])
   (:use [clojure.pprint])
+  (:refer-clojure :exclude [make-array])
   (:gen-class))

 (native!)
@@ -39,7 +40,67 @@
       (aset board x y (if (< (rand-int 100) 50) :off :on)))
     board))

+(defn neighbors [[x y]]
+  (for [dx [-1 0 1]
+        dy (if (zero? dx)
+             [-1 1]
+             [-1 0 1])]
+    [(+ dx x) (+ dy y)]))
+
+
+(defn create-world
+  "Creates rectangular world with the specified width and height.
+  Optionally takes coordinates of living cells."
+  [w h & living-cells]
+  (vec (for [y (range w)]
+         (vec (for [x (range h)]
+                (if (contains? (first living-cells) [y x]) "X" " "))))))
+
+
+
+(defn create-world2
+  "Creates rectangular world with the specified width and height.
+  Optionally takes coordinates of living cells."
+  ([w h] (create-world2 w h #{}))
+  ([w h living-cells]
+   (for [y (range w)]
+     (for [x (range h)]
+       (if (contains? living-cells [y x]) :on :off)))))
+
+(def create-world
+  "Creates rectangular world with the specified width and height.
+  Optionally takes coordinates of living cells."
+  (fn self
+    ([w h] (self w h #{}))
+    ([w h living-cells]
+     (for [y (range w)]
+       (for [x (range h)]
+         (if (contains? living-cells [y x]) :on :off))))))
+
+
+(create-world2 4 4)
+(create-world2 4 4 #{[0 0], [1 1], [2 2], [3 3]})
+
+(first #{[0 0], [1 1], [2 2], [3 3]})
+(contains? #{[0 0], [1 1], [2 2], [3 3]} [ 1])
+
+(defn neighbours
+  "Determines all the neighbours of a given coordinate"
+  [[x y]]
+  (for [dx [-1 0 1] dy [-1 0 1] :when (not= 0 dx dy)]
+    [(+ dx x) (+ dy y)]))
+
+(neighbours [1 1])
+
+(frequencies (mapcat neighbors #{[1 1] [1 0]}))
+
+(def a (create-world2 4 4 #{[0 0], [1 1], [2 2], [3 3]}))
+
+(a [0 1])
+
 (def a (make-board))
+
+(mapcat neighbors a)

 (defn draw-grid [c g]
   (doseq [x (range 0 board-size)


Updated keep-fire? docstring per Aaron's comment about tile edges

--- src/clj/forma/source/fire.clj
+++ src/clj/forma/source/fire.clj
@@ -193,7 +193,11 @@
        (= field-count (count fire-fields)))))

 (defn keep-fire?
-  "Returns true if the latlon for the fire falls within a tile in tile-set."
+  "Returns true if the latlon for the fire falls within a tile in tile-set.
+
+   Note that latlons falling on edges of tiles will be assigned to a tile
+   based on the behavior of the forma.reproject namespace. Most fires will
+   have an unambiguous assignment, however."
   [s-res tile-set lat lon]
   (let [[mod-h mod-v _ _] (r/latlon->modis s-res lat lon)]
     (contains? tile-set [mod-h mod-v])))


Fix spec

Fix spec

--- src/clj/nightcode/editors.clj
+++ src/clj/nightcode/editors.clj
@@ -201,7 +201,7 @@
   :ret string?)

 (fdef editor-pane
-  :args (s/cat :pref-state-atom spec/atom? :runtime-state-atom spec/atom? :file spec/file? :eval-fn fn?)
+  :args (s/cat :pref-state-atom spec/atom? :runtime-state-atom spec/atom? :file spec/file? :eval-fn (s/nilable fn?))
   :ret spec/pane?)

 (fdef get-bridge


make ns guessing .cljc safe

make ns guessing .cljc safe

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -137,7 +137,7 @@

 (defn cljs-file->ns [name]
   (-> name
-      (str/replace #"\.cljs$" "")
+      (str/replace #"\.clj(s|c)$" "")
       (str/replace #"_" "-")
       (str/replace #"[/\\]" ".")
       (symbol)))


test for Chairman Hiro

test for Chairman Hiro

--- src/clj/test/cards-assets.clj
+++ src/clj/test/cards-assets.clj
@@ -11,8 +11,7 @@
       (take-credits state :corp 2)
       (take-credits state :runner)
       (is (= 6 (get-in @state [:corp :credit])))
-      (is (= 9 (get-in (refresh ac) [:counter])))
-      )))
+      (is (= 9 (get-in (refresh ac) [:counter]))))))

 (deftest aggressive-secretary
   (do-game
@@ -36,10 +35,7 @@
       (prompt-choice :corp "Done")
       ;There should be one Cache left
       (is (= 3 (get-in @state [:corp :credit])))
-      (is (=
-            2
-            (count (get-in @state [:runner :rig :program]))))
-      )))
+      (is (= 2 (count (get-in @state [:runner :rig :program])))))))

 (deftest alix-t4lb07
   (do-game
@@ -56,8 +52,29 @@
       (is (= 2 (get-in (refresh alix) [:counter])))
       (is (= 4 (get-in @state [:corp :credit])))
       (card-ability state :corp alix 0)
-      (is (= 8 (get-in @state [:corp :credit])))
-      )))
+      (is (= 8 (get-in @state [:corp :credit]))))))
+
+(deftest chairman-hiro
+  "Chairman Hiro - Reduce Runner max hand size; add as 2 agenda points if Runner trashes him"
+  (do-game
+    (new-game (default-corp [(qty "Chairman Hiro" 2)]) (default-runner))
+    (play-from-hand state :corp "Chairman Hiro" "New remote")
+    (play-from-hand state :corp "Chairman Hiro" "Server 1")
+    (is (= 1 (count (:discard (get-corp)))))
+    (is (= 0 (:agenda-point (get-runner))) "No points for Runner if trashed by Corp")
+    (let [hiro (first (get-in @state [:corp :servers :remote1 :content]))]
+      (core/rez state :corp hiro)
+      (is (= 3 (:max-hand-size (get-runner))) "Runner max hand size reduced by 2")
+      (take-credits state :corp)
+      (take-credits state :runner 3)
+      (core/click-run state :runner {:server :remote1})
+      (core/no-action state :corp nil)
+      (core/successful-run state :runner nil)
+      (prompt-choice :runner "Yes") ; trash Hiro
+      (is (= 2 (:credit (get-runner))) "Runner paid 6 credits to trash")
+      (is (= 5 (:max-hand-size (get-runner))) "Runner max hand size restored to 5")
+      (is (= 1 (count (get-in @state [:runner :scored]))) "Chairman Hiro added to Runner score area")
+      (is (= 2 (:agenda-point (get-runner))) "Runner gained 2 agenda points"))))

 (deftest eve-campaign
   (do-game
@@ -70,8 +87,7 @@
       (take-credits state :corp 2)
       (take-credits state :runner)
       (is (= 4 (get-in @state [:corp :credit])))
-      (is (= 14 (get-in (refresh eve) [:counter])))
-      )))
+      (is (= 14 (get-in (refresh eve) [:counter]))))))

 (deftest franchise-city
   (do-game
@@ -117,8 +133,7 @@
       (take-credits state :corp 2)
       (take-credits state :runner)
       (is (= 8 (get-in @state [:corp :credit])))
-      (is (= 4 (get-in (refresh launch) [:counter])))
-      )))
+      (is (= 4 (get-in (refresh launch) [:counter]))))))

 (deftest public-support
   "Public support scoring and trashing"
@@ -160,8 +175,7 @@
       (is (= (:zone (refresh publics1) :scored)))
       (is (= (:zone (refresh publics2) :discard)))
       (is (= "Public Support" (:title (first (get-in @state [:corp :scored])))))
-      (is (= 1 (:agendapoints (first (get-in @state [:corp :scored])))))
-      )))
+      (is (= 1 (:agendapoints (first (get-in @state [:corp :scored]))))))))

 (deftest sundew
   "Sundew"


Fix markup and night shading for light-producing cells

--- src/cljc/robinson/render.cljc
+++ src/cljc/robinson/render.cljc
@@ -161,6 +161,10 @@
                :bamboo-water-collector :solar-still
                :freshwater-hole :saltwater-hole} cell-type))

+(defn light-producing?
+  [cell-type]
+  (contains? #{:fire :lava} cell-type))
+
 (defn move-cursor
   [rstate x y]
   (log/info "moving cursor to" x y)
@@ -192,23 +196,20 @@
   ([s x y]
    (str->chars s x y :white :black))
   ([s x y fg bg]
-   (let [fg-rgb (rcolor/color->rgb fg)
-         bg-rgb (rcolor/color->rgb bg)]
+   (let [fg-rgb (mapv int (rcolor/color->rgb fg))
+         bg-rgb (mapv int (rcolor/color->rgb bg))]
    (map-indexed (fn [i c] {:x (+ x i) :y y :c c :fg fg-rgb :bg bg-rgb}) s))))

 (defn markup->chars
   ([x y s]
    (markup->chars x y s :white :black))
   ([x y s fg bg]
-   (markup->chars x y s fg bg #{}))
-  ([x y s fg bg style]
    (if (re-find #"^\s*$" s)
      (map (fn [idx] {:c     \space
                      :x     (+ x idx)
                      :y     y
                      :fg    (rcolor/color->rgb fg)
-                     :bg    (rcolor/color->rgb bg)
-                     :style style})
+                     :bg    (rcolor/color->rgb bg)})
           (range (count s)))
      (let [body    (str "<body>" s "</body>")
            z       (zip-str body)
@@ -217,11 +218,11 @@
                                 (cond
                                   (string? v)
                                     (concat characters
-                                            (str->chars v x y fg bg ))
+                                            (str->chars v (+ x (count characters)) y fg bg))
                                   (map? v)
                                     (concat characters
                                             (str->chars (-> v :content first)
-                                                        x y
+                                                        (+ x (count characters)) y
                                                         (if (= (get v :tag) :color)
                                                           (keyword (get-in v [:attrs :fg] fg))
                                                           fg)
@@ -230,6 +231,7 @@
                                                           bg)))))
                               []
                               content)]
+      (log/info "markup->chars" (vec characters))
       characters))))

 (defn markup->length
@@ -353,11 +355,8 @@
                    (left-justify-markup line width))
         [fg bg]  (if invert
                    [bg fg]
-                   [fg bg])
-        style    (if underline
-                   #{:underline}
-                   #{})]
-    (let [characters (markup->chars (int (rmath/ceil x)) (int (rmath/ceil y)) s fg bg style)]
+                   [fg bg])]
+    (let [characters (markup->chars (int (rmath/ceil x)) (int (rmath/ceil y)) s fg bg )]
       (put-chars rstate layer-id characters)))))

 (def single-border
@@ -486,7 +485,7 @@
                                word)
               characters     (concat characters
                                      word
-                                     [{:c " "
+                                     [{:c \space
                                        :x (+ @nchars (count word) x)
                                        :y @line
                                        :fg (rcolor/color->rgb fg)
@@ -509,8 +508,9 @@
         lines    (rc/wrap-line 28 text)
         characters (markup->chars x (inc y) text :black :white #{})
         characters (wrap-chars x (inc y) width height characters :black :white #{})]
-     (put-chars rstate (wrap-chars x y  width 1 (markup->chars x y title :black :white #{}) :black :white #{}))
-     (put-chars rstate characters)))
+     (-> rstate
+       (put-chars (wrap-chars x y  width 1 (markup->chars x y title :black :white) :black :white))
+       (put-chars characters))))
      ;;(render-list rstate x y width height items)))

 (defn render-multi-select
@@ -534,7 +534,7 @@
   ([rstate title selected-hotkeys items]
    (render-multi-select rstate title selected-hotkeys items 40 0 40 22))
   ([rstate title selected-hotkeys items x y width height]
-   (render-multi-select rstate title selected-hotkeys items x y width height #{}))
+   (render-multi-select rstate title selected-hotkeys items 40 0 40 22 #{}))
   ([rstate title selected-hotkeys items x y width height style]
    ;; items is list of {:s "string" :fg :black :bg :white}
    (let [{:keys [use-applicable
@@ -546,7 +546,7 @@
          items    (map (fn [item] {:s (format #?(:clj  "<color fg=\"highlight\">%c</color>%c%s%s %s %s"
                                                  :cljs "<color fg=\"highlight\">%s</color>%s%s%s %s %s")
                                               (or (item :hotkey)
-                                                  \ )
+                                                  \space)
                                               (if (contains? selected-hotkeys (item :hotkey))
                                                 \+
                                                 \-)
@@ -570,8 +570,7 @@
                                                (get item :applicable))
                                          :black
                                          :gray)
-                                   :bg :white
-                                   :style #{}})
+                                   :bg :white})
                        items)
          ;; if width is :auto calc width by using max item length
          width    (if (= width :auto)
@@ -585,7 +584,7 @@
                     (when title
                       (format "  %s" title)))
          items    (if title
-                     (concat [{:s title :fg :black :bg :white :style #{:underline :bold}}]
+                     (concat [{:s title :fg :black :bg :white}]
                               items)
                      items)]
      (render-list rstate :ui x y width height items))))
@@ -622,13 +621,13 @@
         ;; render atmo
         (render-atmo state 37 21)
         ;; render statuses
-        (put-chars :ui [{:x 37 :y 23 :c \      :fg gray-rgb :bg gray-rgb}
+        (put-chars :ui [{:x 37 :y 23 :c \space :fg gray-rgb :bg gray-rgb}
                         {:x 38 :y 23 :c \u2665 :fg (if (player-wounded? state) red-rgb black-rgb) :bg gray-rgb}
-                        {:x 39 :y 23 :c \      :fg gray-rgb :bg gray-rgb}
+                        {:x 39 :y 23 :c \space :fg gray-rgb :bg gray-rgb}
                         {:x 40 :y 23 :c \u2665 :fg (if (player-poisoned? state) green-rgb black-rgb) :bg gray-rgb}
-                        {:x 41 :y 23 :c \      :fg gray-rgb :bg gray-rgb}
+                        {:x 41 :y 23 :c \space :fg gray-rgb :bg gray-rgb}
                         {:x 42 :y 23 :c \u2665 :fg (if (player-infected? state) yellow-rgb black-rgb) :bg gray-rgb}
-                        {:x 43 :y 23 :c \      :fg gray-rgb :bg gray-rgb}])
+                        {:x 43 :y 23 :c \space :fg gray-rgb :bg gray-rgb}])
         ((fn [rstate]
           (if (= (current-state state) :sleep)
             (put-string rstate 38 20 :ui (format "Zzz%s" (apply str (repeat (mod (get-time state) 3) "." ))) #{} {:mask #{:rain :transform}}))
@@ -692,7 +691,7 @@
         (if (= (get (rw/get-cell state x y) :discovered) current-time)
           (let [bg (rcolor/color->rgb (rand-nth [:beige :temple-beige :light-brown]))]
           ;; TODO implement
-            (conj characters {:x x :y y :c \  :fg [0 0 0] :bg bg}))
+            (conj characters {:x x :y y :c \space :fg [0 0 0] :bg bg}))
           characters))
         (keys (get trap :locations))))))

@@ -789,16 +788,15 @@
               (fn [ability]
                 [{:s (format "<color fg=\"highlight\">%s</color> - %s" (get ability :hotkey) (get ability :name))
                   :fg :black
-                  :bg :white
-                  :style #{}}
-                 {:s (format "    %s" (get ability :description)) :fg :black :bg :white :style #{}}
-                 {:s "" :fg :black :bg :white :style #{}}])
+                  :bg :white}
+                 {:s (format "    %s" (get ability :description)) :fg :black :bg :white}
+                 {:s "" :fg :black :bg :white}])
               abilities)
-            [{:s "" :fg :black :bg :white :style #{}}
-             {:s "Select hotkey or press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white :style #{}}])
-          [{:s "No abilities." :fg :black :bg :white :style #{}}
-           {:s "" :fg :black :bg :white :style #{}}
-           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white :style #{}}]))
+            [{:s "" :fg :black :bg :white}
+             {:s "Select hotkey or press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white}])
+          [{:s "No abilities." :fg :black :bg :white}
+           {:s "" :fg :black :bg :white}
+           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white}]))

       (render-rect-double-border 16 3 43 height :black :white)
       (put-string :ui 33 3 "Abilities" :black :white))))
@@ -815,13 +813,12 @@
             (fn [ability]
               [{:s (format "<color fg=\"highlight\">%s</color> - %s" (get ability :hotkey) (get ability :name))
                 :fg :black
-                :bg :white
-                :style #{}}
-               {:s (format "    %s" (get ability :description)) :fg :black :bg :white :style #{}}
-               {:s "" :fg :black :bg :white :style #{}}])
+                :bg :white}
+               {:s (format "    %s" (get ability :description)) :fg :black :bg :white}
+               {:s "" :fg :black :bg :white}])
             abilities)
-          [{:s "" :fg :black :bg :white :style #{}}
-           {:s "Select hotkey." :fg :black :bg :white :style #{}}]))
+          [{:s "" :fg :black :bg :white}
+           {:s "Select hotkey." :fg :black :bg :white}]))
       (render-rect-double-border 16 3 43 height :black :white)
       (put-string :ui 29 3 "Choose New Ability" :black :white))))

@@ -840,15 +837,14 @@
               (fn [ability]
                 [{:s (format "<color fg=\"highlight\">%s</color> - %s" (get ability :hotkey) (get ability :name))
                   :fg :black
-                  :bg :white
-                  :style #{}}
-                 {:s "" :fg :black :bg :white :style #{}}])
+                  :bg :white}
+                 {:s "" :fg :black :bg :white}])
               abilities)
-            [{:s "" :fg :black :bg :white :style #{}}
-             {:s "Select hotkey or press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white :style #{}}])
-          [{:s "Nothing to do." :fg :black :bg :white :style #{}}
-           {:s "" :fg :black :bg :white :style #{}}
-           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white :style #{}}]))
+            [{:s "" :fg :black :bg :white}
+             {:s "Select hotkey or press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white}])
+          [{:s "Nothing to do." :fg :black :bg :white}
+           {:s "" :fg :black :bg :white}
+           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white}]))

       (render-rect-double-border 16 3 43 height :black :white)
       (put-string :ui 30 3 "Choose Action" :black :white))))
@@ -870,16 +866,16 @@
         toughness     (rp/get-player-attribute state :toughness)]
     (-> rstate
       (render-list :ui (inc x) (inc y) 43 height
-          [{:s (format "Name:      %s" player-name) :fg :black :bg :white :style #{}}
-           {:s (format "Level:     %d (%d/%d)" level xp xp-next-level) :fg :black :bg :white :style #{}}
-           {:s "" :fg :black :bg :white :style #{}}
-           {:s (format "Max HP:    %d" max-hp ) :fg :black :bg :white :style #{}}
-           {:s "" :fg :black :bg :white :style #{}}
-           {:s (format "Strength:  %d" strength ) :fg :black :bg :white :style #{}}
-           {:s (format "Dexterity: %d" dexterity ) :fg :black :bg :white :style #{}}
-           {:s (format "Toughness: %d" toughness ) :fg :black :bg :white :style #{}}
-           {:s "" :fg :black :bg :white :style #{}}
-           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white :style #{}}])
+          [{:s (format "Name:      %s" player-name) :fg :black :bg :white}
+           {:s (format "Level:     %d (%d/%d)" level xp xp-next-level) :fg :black :bg :white}
+           {:s "" :fg :black :bg :white}
+           {:s (format "Max HP:    %d" max-hp ) :fg :black :bg :white}
+           {:s "" :fg :black :bg :white}
+           {:s (format "Strength:  %d" strength ) :fg :black :bg :white}
+           {:s (format "Dexterity: %d" dexterity ) :fg :black :bg :white}
+           {:s (format "Toughness: %d" toughness ) :fg :black :bg :white}
+           {:s "" :fg :black :bg :white}
+           {:s "Press <color fg=\"highlight\">Esc</color> to exit." :fg :black :bg :white}])
       (render-rect-double-border x y 43 height :black :white)
       (put-string :ui (+ x 16) y "Player Info" :black :white))))

@@ -997,7 +993,7 @@
                         :name "Sell"}]
         last-response ((or (last (get-in state [:world :dialog-log])) {:text ""}) :text)
         response-wrapped (wrap-line (- 30 17) last-response)
-        style {:fg :black :bg :white :styles #{:bold}}]
+        style {:fg :black :bg :white}]
     (put-string rstate :ui 0 16 (format "Doing business with %-69s" (get npc :name)) :black :white #{:bold})
     (doall (map (fn [y] (put-string rstate :ui 12 y "                    " :black :white #{:bold}))
                 (range 17 (+ 17 6))))
@@ -1023,7 +1019,7 @@
         _ (log/debug "last-response" last-response)
         response-wrapped (wrap-line (- 30 17) last-response)
         _ (log/debug "response-wrapped" response-wrapped)
-        style {:fg :black :bg :white :styles #{:bold}}]
+        style {:fg :black :bg :white}]
     (put-string rstate :ui 0 16 (format "Doing business with %-69s" (get npc :name)) :black :white #{:bold})
     (doall (map (fn [y] (put-string rstate :ui 12 y "                    " :black :white #{:bold}))
                 (range 17 (+ 17 6))))
@@ -1046,7 +1042,7 @@
         _ (log/debug "last-response" last-response)
         response-wrapped (wrap-line (- 30 17) last-response)
         _ (log/debug "response-wrapped" response-wrapped)
-        style {:fg :black :bg :white :styles #{:bold}}]
+        style {:fg :black :bg :white}]
     (put-string rstate :ui 0 16 (format "Doing business with %-69s" (get npc :name)) :black :white #{:bold})
     (doall (map (fn [y] (put-string rstate :ui 12 y "                    " :black :white #{:bold}))
                 (range 17 (+ 17 6))))
@@ -1080,7 +1076,7 @@
   ;; render recipes
   (render-list rstate :ui 11 6 29 15
     (concat
-      [{:s (name recipe-type) :fg :black :bg :white :style #{:underline}}]
+      [{:s (name recipe-type) :fg :black :bg :white}]
        (map (fn [recipe]
               {:s (format #?(:clj  "%c-%s"
                              :cljs "%s-%s")
@@ -1105,10 +1101,10 @@
       (log/info "exhaust" exhaust "have" have)
       (render-list rstate :ui 41 6 29 15
       (concat
-        [{:s "" :fg :black :bg :white :style #{}}
-         {:s "Consumes" :fg :black :bg :white :style #{}}]
+        [{:s "" :fg :black :bg :white}
+         {:s "Consumes" :fg :black :bg :white}]
         (if (empty? exhaust)
-          [{:s "N/A" :fg :black :bg :white :style #{}}]
+          [{:s "N/A" :fg :black :bg :white}]
           (let [idx-ids (mapcat (fn [ids]
                            (map-indexed vector ids))
                          (partition-by identity (sort exhaust)))]
@@ -1116,17 +1112,17 @@
             (reduce (fn [lines [idx id]]
                       (conj lines
                             (if (< idx (get inventory-id-freqs id 0))
-                              {:s (id->name id) :fg :black :bg :white :style #{}}
-                              {:s (id->name id) :fg :gray :bg :white :style #{}})))
+                              {:s (id->name id) :fg :black :bg :white}
+                              {:s (id->name id) :fg :gray :bg :white})))
                    []
                    idx-ids)))
-        [{:s "" :fg :black :bg :white :style #{}}
-         {:s "Required tools" :fg :black :bg :white :style #{}}]
+        [{:s "" :fg :black :bg :white}
+         {:s "Required tools" :fg :black :bg :whit}]
         (if (empty? have)
-          [{:s "N/A" :fg :black :bg :white :style #{}}]
-          (map (fn [id] {:s (id->name id) :fg :black :bg :white :style #{}}) have)))))
+          [{:s "N/A" :fg :black :bg :white}]
+          (map (fn [id] {:s (id->name id) :fg :black :bg :white}) have)))))
     (render-list rstate :ui 41 6 29 15
-        [{:s "Select a recipe" :fg :black :bg :white :style #{}}]))
+        [{:s "Select a recipe" :fg :black :bg :white}]))
   (render-rect-single-border rstate 10 5 60 15 :black :white)
   (render-vertical-border rstate 40 6 15 :black :white)
   (put-string rstate :ui 40 20 "\u2534" :black :white)
@@ -1169,7 +1165,7 @@
     (-> rstate
       (render-list :ui 16 4 width 6
         (concat
-          [{:s "" :fg :black :bg :white :style #{}}]
+          [{:s "" :fg :black :bg :white}]
           (map
             (fn [line] {:s line :fg :black :bg :white :style #{:center}})
             (remove empty? (clojure.string/split-lines start-text)))
@@ -1190,7 +1186,7 @@
     (-> rstate
       (render-list :ui popover-x popover-y width (inc height)
         (concat
-          [{:s "" :fg :black :bg :white :style #{}}]
+          [{:s "" :fg :black :bg :white}]
           (map
             (fn [line] {:s line :fg :black :bg :white :style #{:center}})
             lines)))
@@ -1208,11 +1204,11 @@
     (-> rstate
       (render-list :ui popover-x popover-y width (+ 4 height)
         (concat
-          [{:s "" :fg :black :bg :white :style #{}}]
+          [{:s "" :fg :black :bg :white}]
           (map
             (fn [line] {:s line :fg :black :bg :white :style #{:center}})
             (remove empty? lines))
-          [{:s "" :fg :black :bg :white :style #{}}
+          [{:s "" :fg :black :bg :white}
            {:s "  Press <color fg=\"highlight\">space</color> to continue." :fg :black :bg :white :style #{:center}}]))
       (render-rect-double-border (dec popover-x) popover-y (inc width) (+ 4 height) :black :white))))

@@ -1237,7 +1233,7 @@
     (-> rstate
       (render-list :ui 27 4 width 6
         (concat
-          [{:s "" :fg :black :bg :white :style #{}}]
+          [{:s "" :fg :black :bg :white}]
           (map
             (fn [line] {:s line :fg :black :bg :white :style #{:center}})
             ["You died."
@@ -1251,7 +1247,7 @@
     (-> rstate
       (render-list :ui 16 4 53 6
         (concat
-          [{:s "" :fg :black :bg :white :style #{}}]
+          [{:s "" :fg :black :bg :white}]
           (map
             (fn [line] {:s line :fg :black :bg :white :style #{:center}})
             ["Rescue!"
@@ -1350,10 +1346,12 @@
               place-npcs))))

 (defn render-lighting [rstate sight-distance]
-  (let [bg         (rcolor/lighting sight-distance)
-        characters (for [x (range 80)
-                         y (range 24)]
-                     {:x x :y y :c \  :fg [0 0 0] :bg bg})]
+  (let [bg                  (rcolor/lighting sight-distance)
+        light-producing-xys (set (map (juxt :x :y) (get rstate :light-producing-cells)))
+        characters          (for [x (range 80)
+                                  y (range 24)
+                                  :when (not (contains? light-producing-xys [x y]))]
+                              {:x x :y y :c \space :fg [0 0 0] :bg bg})]
     (put-chars rstate :lighting characters)))

 (defn draw-log [rstate state]
@@ -1632,6 +1630,15 @@
              (assoc cell :x vx :y vy))
            cells-vxy-wxy))))

+(defn concat-light-producing-cells [rstate cells-vxy-wxy]
+  (rc/concat-in
+    rstate
+    [:light-producing-cells]
+    (filter (comp light-producing? :type)
+      (map (fn [[cell vx vy _ _]]
+             (assoc cell :x vx :y vy))
+           cells-vxy-wxy))))
+
 (defn cell->char [current-time sight-distance lantern-on [cell vx vy wx wy]]
    #_(when (= (get cell :discovered 0) current-time)
      (println "render-cell" (select-keys cell [:type :discovered]) vx vy wx wy))
@@ -1743,6 +1750,7 @@
       (put-chars :map characters)
       (log-render state "debug" "0-map-chars.xp")
       (concat-palette-cells fov-cells)
+      (concat-light-producing-cells fov-cells)
     ;; draw character
     ;(log/debug (-> state :world :player))
       (draw-player state current-time vx vy player player-x player-y)
@@ -1921,12 +1929,12 @@
 (defn cp437->unicode
   [c]
   (case (int c)
-      0 \
+      0 \space
       3 \u2665
     179 \u2502
     219 \u2588
     220 \u2584
-    249 "·"
+    249 \·
     250 \u00B7
     c))

@@ -1944,7 +1952,7 @@
       (put-chars :ui
         (doseq [i (range 7)]
           {:c (get single-border :vertical)  :x x :y (+ y i 1) :fg (rcolor/color->rgb :white) :bg (rcolor/color->rgb :black)}))
-      (put-chars :ui [{:c (get single-border :bottom-left)  :x x :y (+ y 8) :fg (rcolor/color->rgb :white) :bg (rcolor/color->rgb :black) :style #{}}])
+      (put-chars :ui [{:c (get single-border :bottom-left)  :x x :y (+ y 8) :fg (rcolor/color->rgb :white) :bg (rcolor/color->rgb :black)}])
       ;; print title
       (put-chars :ui (markup->chars x y title))
       ;; print bars
@@ -2074,11 +2082,12 @@
                    :fx       []
                    :lighting []
                    :ui       []}
-                 :fov           #{} ; fov in screen-space
-                 :lantern       [0 0 0]
-                 :night         [255 255 255]
-                 :palette-cells []
-                 :events        [] ; seq of state events translated into draw cmds
+                 :fov                   #{} ; fov in screen-space
+                 :lantern               [0 0 0]
+                 :night                 [255 255 255]
+                 :palette-cells         []
+                 :light-producing-cells []
+                 :events                [] ; seq of state events translated into draw cmds
                }
         cs     (current-state state)]
     (cond


Renaming upstream <-> downstream variables in the client

--- src/clojure/picard/client.clj
+++ src/clojure/picard/client.clj
@@ -26,10 +26,10 @@
      chunked?
      chunk-trailer?
      expects-100?
+     next-dn-fn
      next-up-fn
-     next-dn-fn
+     downstream
      upstream
-     downstream
      last-write
      aborted?])

@@ -49,7 +49,7 @@

 (defn- finalize-request
   [current-state]
-  (when (= request-complete (.next-up-fn current-state))
+  (when (= request-complete (.next-dn-fn current-state))
     (netty/on-complete
      (.last-write current-state)
      (fn [_]
@@ -82,14 +82,14 @@
          state
          (fn [current-state]
            (cond
-            (nil? (.next-dn-fn current-state))
+            (nil? (.next-up-fn current-state))
             (assoc current-state
-              :next-up-fn request-complete
+              :next-dn-fn request-complete
               :last-write (or last-write (.last-write current-state)))

             :else
             (assoc current-state
-              :next-up-fn response-pending
+              :next-dn-fn response-pending
               :last-write (or last-write (.last-write current-state)))))
          finalize-request))
       (let [last-write (.write ch (mk-netty-chunk val))]
@@ -100,21 +100,21 @@

 (defn- stream-or-finalize-response
   [state ^HttpChunk msg args]
-  (let [downstream-fn (.downstream args)
-        upstream-fn   (.upstream args)]
+  (let [upstream-fn   (.upstream args)
+        downstream-fn (.downstream args)]
     (if (.isLast msg)
       (do (swap-then!
            state
            (fn [current-state]
              (if (= response-pending (.next-up-fn current-state))
                (assoc current-state
-                 :next-up-fn request-complete
-                 :next-dn-fn nil)
+                 :next-dn-fn request-complete
+                 :next-up-fn nil)
                (assoc current-state
-                 :next-dn-fn nil)))
+                 :next-up-fn nil)))
            finalize-request)
-          (downstream-fn upstream-fn :done nil))
-      (downstream-fn upstream-fn :body (.getContent msg)))))
+          (upstream-fn downstream-fn :done nil))
+      (upstream-fn downstream-fn :body (.getContent msg)))))

 (defn- initial-response
   [state ^HttpResponse msg current-state]
@@ -122,8 +122,8 @@
   (when (and (is-100-continue? msg) (not (.expects-100? current-state)))
     (throw (Exception. "Not expecting a 100 Continue response.")))

-  (let [downstream-fn (.downstream current-state)
-        upstream-fn   (.upstream current-state)]
+  (let [upstream-fn   (.upstream current-state)
+        downstream-fn (.downstream current-state)]
     (swap-then!
      state
      (fn [current-state]
@@ -138,23 +138,23 @@
           (.isChunked msg)
           (assoc current-state
             :keepalive? keepalive?
-            :next-dn-fn stream-or-finalize-response)
+            :next-up-fn stream-or-finalize-response)

           ;; If the exchange is waiting for the response to complete then
           ;; finish everything up
-          (= response-pending (.next-up-fn current-state))
+          (= response-pending (.next-dn-fn current-state))
           (assoc current-state
             :keepalive? keepalive?
-            :next-up-fn request-complete
-            :next-dn-fn nil)
+            :next-dn-fn request-complete
+            :next-up-fn nil)

           ;; Otherwise, just mark the request as done
           :else
           (assoc current-state
             :keepalive? keepalive?
-            :next-dn-fn nil))))
+            :next-up-fn nil))))
      finalize-request)
-    (downstream-fn upstream-fn :response (netty-resp->resp msg))))
+    (upstream-fn downstream-fn :response (netty-resp->resp msg))))

 (defn- initial-write-succeeded
   [state current-state]
@@ -165,18 +165,18 @@
       ;; If the body is chunked, the next events will
       ;; be the HTTP chunks
       (.chunked? current-state)
-      (assoc current-state :next-up-fn stream-or-finalize-request)
+      (assoc current-state :next-dn-fn stream-or-finalize-request)

       ;; If the body is not chunked, then the request is
       ;; finished. If the response has already been completed
       ;; then we must finish up the request
-      (nil? (.next-dn-fn current-state))
-      (assoc current-state :next-up-fn request-complete)
+      (nil? (.next-up-fn current-state))
+      (assoc current-state :next-dn-fn request-complete)

       ;; Otherwise, the exchange state is to be awaiting
       ;; the response to complete.
       :else
-      (assoc current-state :next-up-fn response-pending)))
+      (assoc current-state :next-dn-fn response-pending)))
    finalize-request)
   ;; The connected event is only sent downstream when the
   ;; request body is marked as chunked because that's the
@@ -187,17 +187,17 @@
   ;;       all downstream function calls happen on the same
   ;;       thread.
   (when (.chunked? current-state)
-    ((.downstream current-state) (.upstream current-state) :connected nil)))
+    ((.upstream current-state) (.downstream current-state) :connected nil)))

 (defn- handle-ch-interest-change
   [state current-state writable?]
-  (let [downstream-fn (.downstream current-state)
-        upstream-fn   (.upstream current-state)
+  (let [upstream-fn   (.upstream current-state)
+        downstream-fn (.downstream current-state)
         ch            (.ch current-state)]
-    (when (and downstream-fn (not= (.isWritable ch) @writable?))
+    (when (and upstream-fn (not= (.isWritable ch) @writable?))
       (swap-then!
        writable? not
-       #(try (downstream-fn upstream-fn (if % :resume :pause) nil)
+       #(try (upstream-fn downstream-fn (if % :resume :pause) nil)
              (catch Exception err
                (throw (Exception. "Not implemented yet"))))))))

@@ -207,12 +207,12 @@
    state
    (fn [current-state]
      (assoc current-state
-       :next-up-fn request-complete
+       :next-dn-fn request-complete
        :aborted?   true))
    (fn [current-state]
-     (when (.downstream current-state)
+     (when (.upstream current-state)
        (try
-         ((.downstream current-state) (.upstream current-state) :abort err)
+         ((.upstream current-state) (.downstream current-state) :abort err)
          (catch Exception ex
            (.printStackTrace ex)))
        (finalize-request current-state)))))
@@ -226,28 +226,28 @@
          (when-not (.aborted? current-state)
            (cond-let
             [msg (netty/message-event evt)]
-            ((.next-dn-fn current-state) state msg current-state)
+            ((.next-up-fn current-state) state msg current-state)

             ;; The channel interest has changed to writable
             ;; or not writable
             [[ch-state val] (netty/channel-state-event evt)]
             (cond
              (and (nil? val) (= ch-state ChannelState/CONNECTED)
-                  (not= request-complete (.next-up-fn current-state)))
+                  (not= request-complete (.next-dn-fn current-state)))
              (handle-err state (Exception. "Connection reset by peer") current-state)

              (= ch-state ChannelState/INTEREST_OPS)
              (handle-ch-interest-change state current-state writable?))

             [_ (netty/write-completion-event evt)]
-            (when (and (= write-pending (.next-up-fn current-state))
+            (when (and (= write-pending (.next-dn-fn current-state))
                        (.. evt getFuture isSuccess))
               (initial-write-succeeded state current-state))

             [err (netty/exception-event evt)]
             (do (.printStackTrace err)))))))))

-(defn- mk-upstream-fn
+(defn- mk-downstream-fn
   [state]
   (fn [evt val]
     (let [current-state @state]
@@ -269,12 +269,12 @@
            (.setReadable (.ch current-state) true)

            :else
-           ((.next-up-fn current-state) state evt val current-state)))))))
+           ((.next-dn-fn current-state) state evt val current-state)))))))

 (defn- mk-initial-state
-  [pool [hdrs body :as  req] downstream-fn]
+  [pool [hdrs body :as  req] upstream-fn]
   (let [state       (atom nil)
-        upstream-fn (mk-upstream-fn state)]
+        downstream-fn (mk-downstream-fn state)]
     (swap!
      state
      (fn [_] (State. pool               ;; The connection pool
@@ -285,20 +285,18 @@
                        "chunked")
                     (= (hdrs "expect") ;; Does the request expect 100 continue?
                        "100-continue")
+                    initial-response   ;; Next downstream event handler
                     connection-pending ;; Next upstream event handler
-                    initial-response   ;; Next downstream event handler
+                    downstream-fn      ;; Downstream handler (passed in)
                     upstream-fn        ;; Upstream handler (external interface)
-                    downstream-fn      ;; Downstream handler (passed in)
                     nil                ;; Last write
                     nil)))             ;; Aborted?
-    [state upstream-fn]))
+    [state downstream-fn]))

 (defn- initialize-request
   [state addr request]
   (let [current-state @state
-        pool          (.pool current-state)
-        upstream-fn   (.upstream current-state)
-        downstream-fn (.downstream current-state)]
+        pool (.pool current-state)]
     (pool/checkout-conn
      pool addr (netty-bridge state)
      ;; When a connection to the remote host has been established.
@@ -315,7 +313,7 @@
               current-state
               (assoc current-state
                 :ch         ch-or-err
-                :next-up-fn write-pending)))
+                :next-dn-fn write-pending)))
           (fn [current-state]
             (if (.aborted? current-state)
               ;; Return to the connection pool
@@ -344,12 +342,12 @@
 (def mk-pool pool/mk-pool)

 (defn request
-  ([addr req downstream-fn]
-     (request GLOBAL-POOL addr req downstream-fn))
-  ([pool addr request downstream-fn]
+  ([addr req upstream-fn]
+     (request GLOBAL-POOL addr req upstream-fn))
+  ([pool addr request upstream-fn]
      ;; Create an atom that contains the state of the request
-     (let [[state upstream-fn] (mk-initial-state pool request downstream-fn)]
+     (let [[state downstream-fn] (mk-initial-state pool request upstream-fn)]
        ;; TODO: Handle cases where the channel returned is open but
        ;;       writes to it will fail.
        (initialize-request state addr request)
-       upstream-fn)))
+       downstream-fn)))


Tweak a debug message

Tweak a debug message

--- src/clojure/picard/client.clj
+++ src/clojure/picard/client.clj
@@ -375,7 +375,7 @@
      pool addr (netty-bridge state)
      ;; When a connection to the remote host has been established.
      (fn [^Channel ch-or-err fresh?]
-       (debug {:msg   (str "Checked out channel: " ch-or-err)
+       (debug {:msg   (str "Checked out channel: " ch-or-err " " fresh?)
                :event [:request request]})
        (if (instance? Exception ch-or-err)
          ;; Handle exceptions


Clarified comment

Clarified comment

--- src/clojurebot/connection.clj
+++ src/clojurebot/connection.clj
@@ -63,7 +63,7 @@
   (write conn (str "USER " (:nick user) " 0 * :" (:name user))))

 (defn quit [conn]
-  ;; This will send a :Closing link: message
+  ;; This cause a :Closing link: message to be sent
   (write conn "QUIT"))

 (defn join [conn channel]


make comp-paths work on lazyseqs for cljs

--- src/com/rpl/specter/impl.cljx
+++ src/com/rpl/specter/impl.cljx
@@ -223,6 +223,9 @@
   #+cljs (coerce-path [this]
            (coerce-path (vec this)))
   #+cljs cljs.core/List
+  #+cljs (coerce-path [this]
+           (coerce-path (vec this)))
+  #+cljs cljs.core/LazySeq
   #+cljs (coerce-path [this]
            (coerce-path (vec this)))


Fix missed merging issues.

Fix missed merging issues.

--- dev/kixi/hecuba/dev/etl.clj
+++ dev/kixi/hecuba/dev/etl.clj
@@ -192,7 +192,7 @@
                                      "application/json"
                                      (jsonify {:measurements
                                                (map
-                                                (fn [x] (update-in x [:timestamp] #(tf/unparse (:date-time-no-ms tf/formatters)  (clj-time.coerce/from-date %))))
+                                                (fn [x] (update-in x [:timestamp] #(tf/unparse custom-formatter  (clj-time.coerce/from-date %))))
                                                 (mapcat generators/measurements sensors))}))]
                   )

@@ -205,7 +205,7 @@
               (let [sensors (generators/generate-sensor-sample "INSTANT" 3)

                     response
-                    @(post-resource
+                    (post-resource
                       (format "http://%s:%d%s" host port
                               (path-for (-> system :hecuba/routing :jig.bidi/routes)
                                         (-> system :amon/handlers :devices) :entity-id entity-id))
@@ -226,7 +226,7 @@

                 ;; POST to URL a JSON block
                 (let [response
-                      @(post-resource (format "http://%s:%d%s" host port measurements-uri)
+                      (post-resource (format "http://%s:%d%s" host port measurements-uri)
                                       "application/json"
                                       (jsonify {:measurements
                                                 (map
@@ -241,7 +241,7 @@
               (let [sensors (generators/generate-sensor-sample "CUMULATIVE" 1)

                     response
-                    @(post-resource
+                    (post-resource
                       (format "http://%s:%d%s" host port
                               (path-for (-> system :hecuba/routing :jig.bidi/routes)
                                         (-> system :amon/handlers :devices) :entity-id entity-id))
@@ -261,7 +261,7 @@

                 ;; POST to URL a JSON block
                 (let [response
-                      @(post-resource (format "http://%s:%d%s" host port measurements-uri)
+                      (post-resource (format "http://%s:%d%s" host port measurements-uri)
                                       "application/json"
                                       (jsonify {:measurements
                                                 (map
@@ -275,7 +275,7 @@
               (let [sensors (generators/generate-sensor-sample "PULSE" 1)

                     response
-                    @(post-resource
+                    (post-resource
                       (format "http://%s:%d%s" host port
                               (path-for (-> system :hecuba/routing :jig.bidi/routes)
                                         (-> system :amon/handlers :devices) :entity-id entity-id))
@@ -295,7 +295,7 @@

                 ;; POST to URL a JSON block
                 (let [response
-                      @(post-resource (format "http://%s:%d%s" host port measurements-uri)
+                      (post-resource (format "http://%s:%d%s" host port measurements-uri)
                                       "application/json"
                                       (jsonify {:measurements
                                                 (map
@@ -307,7 +307,8 @@
                 )))

-                ))))
+                )))
+    system)

   (stop [_ system] system))


correct spelling of leave-one-out cross-validation

--- src/r_incantations/core.clj
+++ src/r_incantations/core.clj
@@ -304,7 +304,7 @@

 (defn ch09-ml-null-model
   "This is a null-model for the Euclidian-distance ML algorithm from
-  the book, prepped for leave-one-out-cross-validation.
+  the book, prepped for leave-one-out cross-validation.

    * Use with ch09-ml-validate.
    * Assumes test-sel is a single row index.
@@ -339,7 +339,7 @@

 (defn ch09-ml-book
   "This is same Euclidian-distance ML algorithm from the book, prepped
-   for leave-one-out-cross-validation.
+   for leave-one-out cross-validation.

    * Use with ch09-ml-validate.
    * Assumes test-sel is a single row index.
@@ -362,7 +362,7 @@
         (:proc test-data) (:mem test-data)))))

 (defn ch09-ml-validate
-  "Does leave-one-out-cross-validation on memproc data.
+  "Does leave-one-out cross-validation on memproc data.
    http://en.wikipedia.org/wiki/Cross-validation_(statistics)#Leave-one-out_cross-validation.

    ex: (ch09-ml-validate ch09-ml-null-model)


issue #1: trim summary if it is more than 500 chars

--- src/readlature/articles.clj
+++ src/readlature/articles.clj
@@ -20,6 +20,8 @@
               Query$FilterOperator
               Query$SortDirection)))

+(def summary-max-length 500)
+
 (defmulti article-key class)
 (defmethod article-key String [id]
   (KeyFactory/createKey "Article" (Long. id)))
@@ -28,11 +30,18 @@

 (defn now [] (java.util.Date.))

+(defn trim
+  "Trim summary if it is too long and append '...'"
+  [summary length]
+  (if (< (.length summary) length)
+    summary
+    (str (.substring summary 0 (- length 4)) "...")))
+
 (defn create-article [location title summary user]
-  (ds/create {:kind "Article"
+  (ds/create {:kind       "Article"
               :location   location
               :title      title
-              :summary    summary
+              :summary    (trim summary summary-max-length)
               :unread     true
               :starred    false
               :user       user


Fix typo in problem52.clj

Fix typo in problem52.clj

--- euler_clojure/src/euler/problem52.clj
+++ euler_clojure/src/euler/problem52.clj
@@ -6,7 +6,7 @@
 ;; Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
 ;; contain the same digits.

-(ns euler.problem51)
+(ns euler.problem52)

 (defn multiples [x]
   (for [i (range 2 7)] (* i x)))


Use apply str instead of join

Use apply str instead of join

See http://stackoverflow.com/questions/11395691/concatenation-of-the-strings-vector-in-clojure#comment51374914_11395733

--- src/github_changelog/util.clj
+++ src/github_changelog/util.clj
@@ -1,7 +1,7 @@
 (ns github-changelog.util
-  (:require [clojure.string :refer [join ends-with?]]))
+  (:require [clojure.string :refer [ends-with?]]))

-(defn str-map [f & sqs] (join (apply map f sqs)))
+(defn str-map [f & sqs] (apply str (apply map f sqs)))

 (defn extract-params [query-string]
   (into {} (for [[_ k v] (re-seq #"([^&=]+)=([^&]+)" query-string)]
@@ -11,5 +11,5 @@
   ([s] (strip-trailing s "/"))
   ([s end]
    (if (ends-with? s end)
-     (recur (join (drop-last s)) end)
+     (recur (apply str (drop-last s)) end)
      s)))


RR: add title for when mapping threshold reached.

--- src/hatti/views/dataview.cljs
+++ src/hatti/views/dataview.cljs
@@ -17,6 +17,8 @@
             [hatti.views.settings]
             [hatti.views.overview]
             [hatti.utils :refer [click-fn pluralize-number]]))
+
+(def mapping-threshold 10000)

 (def dataview-map
   {:overview {:view :overview
@@ -104,9 +106,18 @@
                            (map dataview-map) (remove nil?))
             dv->link (fn [{:keys [view label]}]
                        (let [active? (some #(= view %) (-> app-state :views :active))]
-                         (if (and (= view :map) no-geodata?)
+                         (cond
+                           (and (= view :map) no-geodata?)
                            [:a {:class "inactive" :title "No geodata"}
                             (name view)]
+                           (and (= view :map)
+                                (> (-> app-state :dataset-info
+                                              :num_of_submissions)
+                                   mapping-threshold))
+                           [:a {:class "inactive"
+                                :title (str "Map does not support more than 10,000 points.")}
+                            (name view)]
+                           :else
                            [:a
                             {:href (when active? (str "#/" (name view)))
                              :class (if active? (view->cls view)


refactored main view to use new profile-path function (now consistent with the usage of avatar-path)

--- src/statuses/views/main.clj
+++ src/statuses/views/main.clj
@@ -5,7 +5,7 @@
             [hiccup.form :refer [form-to hidden-field text-field]]
             [statuses.configuration :refer [config]]
             [statuses.routes :refer [avatar-path update-path
-                                     updates-path]]
+                                     updates-path profile-path]]
             [statuses.views.common :as common :refer [icon]]
             [statuses.views.layout :as layout]))

@@ -41,7 +41,7 @@
 (defn update [is-current {:keys [id text author time in-reply-to conversation can-delete?]}]
   (list
     [:div.avatar
-     (link-to (str (config :profile-url-prefix) author) [:img {:src (avatar-path author) :alt author}])]
+     (link-to (profile-path author) [:img {:src (avatar-path author) :alt author}])]
     [:div.meta
      [:span.author (link-to (str (updates-path) "?author=" author) author)]
      (if in-reply-to


Random UUIDs using Java

Random UUIDs using Java

--- src/test_utils/sandbox.cljc
+++ src/test_utils/sandbox.cljc
@@ -2,7 +2,15 @@
   #?(:cljs (:require [test-utils.core :as tuc]
                      [test-utils.word-source :as ws])
      :clj (:require (test-utils [core :as tuc]
-                                [word-source :as ws]))))
+                                [word-source :as ws])
+                    [clojure.string :as clj-str])))

 ;; Stuff I'm trying out

+(defn random-uuid []
+  (java.util.UUID/randomUUID))
+
+(defn hex-uuid
+  ([] (hex-uuid (random-uuid)))
+  ([uuid] (clj-str/join (map #(Long/toHexString %) [(.getMostSignificantBits uuid) (.getLeastSignificantBits uuid)]))))
+


Log to pass all arguments to println

Log to pass all arguments to println

--- src/trustroots/helpers.cljs
+++ src/trustroots/helpers.cljs
@@ -6,12 +6,12 @@

 (defn set-info! [] (reset! debug-level :info))

-(defn log [thing]
+(defn log [& thing]
   "Log to console, if goog.DEBUG is true"
   (when goog.DEBUG
-    (println thing))
+    (apply println thing)
   ;;TODO write to device logs
-  )
+  ))

 (defn info [thing]
   "Log to console, if goog.DEBUG is true and log level is :info"


ns cleanup

ns cleanup

--- src/useful/experimental.clj
+++ src/useful/experimental.clj
@@ -1,6 +1,5 @@
 (ns useful.experimental
   (:use [useful.utils :only [split-vec]]
-        [useful.map :only [into-map]]
         [useful.seq :only [alternates]]
         [useful.fn :only [any]]))


fix partial snapshot causing problems with subsequent snapshot

--- src/wb_es/snapshot/core.clj
+++ src/wb_es/snapshot/core.clj
@@ -19,14 +19,16 @@
        (throw (Exception. "Cannot connect to elasticsearch snapshot repository"))))))

 (defn get-lateset-snapshot-id
-  [repository-name release-id]
+  [repository-name release-id & {:keys [partial?]
+                                 :or {partial? false}}]
   (let [response (http/get (format "%s/_cat/snapshots/%s?format=json" es-base-url repository-name))
         all-snapshots (json/parse-string (:body response) true)
         id-pattern (re-pattern (format "snapshot_%s(_v(\\d+))?" release-id))]
     (->> all-snapshots
          (filter (fn [snapshot]
                    (and
-                    (= "SUCCESS" (:status snapshot))
+                    (or partial?
+                        (= "SUCCESS" (:status snapshot)))
                     (re-matches id-pattern (:id snapshot)))))
          (sort-by (fn [snapshot]
                     (let [[_ _ version-id] (re-matches id-pattern (:id snapshot))]
@@ -37,7 +39,7 @@
 (defn get-next-snapshot-id
   [repository-name release-id]
   (let [pattern (re-pattern (format "snapshot_%s(_v(\\d+))?" release-id))
-        current-id (get-lateset-snapshot-id repository-name release-id)
+        current-id (get-lateset-snapshot-id repository-name release-id :partial? true)
         next-version-id (if current-id
                           (->> (re-matches pattern current-id)
                                (last)


Temp turn off capture

Temp turn off capture

--- desktop/src-common/ds3/main_screen.clj
+++ desktop/src-common/ds3/main_screen.clj
@@ -122,7 +122,8 @@
                         entities)
       :capture-ship (do
                       (prn :capture-ship)
-                      (remove #(:ship? %) (conj entities (ship/create-ghost-entity! screen (:ship-x screen) (c/screen-to-world (/ c/game-height 15))))))
+                      ;(remove #(:ship? %) (conj entities (ship/create-ghost-entity! screen (:ship-x screen) (c/screen-to-world (/ c/game-height 15)))))
+                      entities)
       ;default pulls a function/args map and executes it - see mini enemies
       (let [to-do ((:id screen) screen)
             new-entity (apply (:f to-do) (:args to-do))]


updating to 1.8.0 of clojure and 0.2.395 of core.async

--- queen-of-hearts/project.clj
+++ queen-of-hearts/project.clj
@@ -1,7 +1,7 @@
-(defproject queen-of-hearts "0.1.0-SNAPSHOT"
+(defproject queen-of-hearts "1.0.0"
   :description "FIXME: write description"
   :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/core.async "0.1.346.0-17112a-alpha"]])
+  :dependencies [[org.clojure/clojure "1.8.0"]
+                 [org.clojure/core.async "0.2.395"]])


fix run

fix run

--- src/neuseg/fann.clj
+++ src/neuseg/fann.clj
@@ -28,7 +28,7 @@
   (jna/to-fn Integer fann/fann_save))

 (def ^:private -run
-  (jna/to-fn Integer fann/fann_run))
+  (jna/to-fn Pointer fann/fann_run))

 (def ^:private -destroy
   (jna/to-fn Integer fann/fann_destroy))
@@ -94,6 +94,6 @@
   (-destroy fann))

 (defn run [fann input]
-  (-run fann input))
+  (vec (.getFloatArray (-run fann (float-array input)) 0 2)))


Adhere to 80 chars

Adhere to 80 chars

--- src/qcast/cache.clj
+++ src/qcast/cache.clj
@@ -26,10 +26,10 @@
 (defn init []
   (info "Initializing cache")
   (db/create-table db-spec :presentations
-                   [:id            :TEXT "PRIMARY KEY" "NOT NULL"]
-                   [:creation_date :DATETIME "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"]
-                   [:publish_date  :DATETIME "NOT NULL"]
-                   [:data          :BLOB "NOT NULL"]))
+    [:id            :TEXT     "NOT NULL" "PRIMARY KEY"]
+    [:creation_date :DATETIME "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"]
+    [:publish_date  :DATETIME "NOT NULL"]
+    [:data          :BLOB     "NOT NULL"]))

 (defn put [item]
   (try ;; Protect against existing entries


revert placeholder pattern

revert placeholder pattern

--- src/rester/core.clj
+++ src/rester/core.clj
@@ -23,7 +23,7 @@
 (def ^:const fields [:suite :test :url :verb :headers :payload :params :exp-status :exp-body
                      :exp-headers :options :extractions])

-(def ^:const placeholder-pattern #"\$(\p{Alpha}\w*)")
+(def ^:const placeholder-pattern #"\$(\p{Alpha}\w*)\$")

 (defn placeholders [s]
   (set (map second (re-seq placeholder-pattern s))))