filtering text start

filtering text start

--- src/cljs/mahtable/core.cljs
+++ src/cljs/mahtable/core.cljs
@@ -86,8 +86,16 @@
                       ;; показывать ли текстовый фильтр
                       :show-text-filter? false

-                      ;; показываемые чекбоксы для текст.фильтра
+                      ;; показываемые чекбоксы для текст.фильтра (должны быть в векторе!)
                       :current-filter-checkboxes nil
+                      ;; пример мэпа для чекбокса:
+                      ;; [{:index 1
+                      ;;  :name ""
+                      ;;  :checked? true/false}]
+                      ;; кнопка "выбрать все"
+                      :select-all-checkbox {:name "Выбрать все"
+                                            :checked? true
+                                            :indeterminate? false}
                       }))

 (defn app-cursor
@@ -165,7 +173,10 @@
     (reset! rows-cursor sorted-rows)))

+;;; -------------------------------------------
+;;; Фильтрование
 (defn filter-rows-numeric
+  "Отфильтровать строки по числу"
   [rows filter-cond field-name value]
   (filter #((case filter-cond ; получаем оператор сравнения
               :gt >
@@ -175,24 +186,43 @@
           rows))

+(defn filter-rows-text
+  "Отфильтровать строки по тексту"
+  [rows field-name value]
+  (filter #(re-find (re-pattern value) (get % field-name)) rows))
+
+
+(defn get-filtered-rows
+  "Получить отфильтрованные строки из общего списка строк и параметров"
+  [init-rows filter-params]
+  (if (u/nil-or-empty? filter-params)
+    init-rows
+    (reduce-kv (fn [rows flt-index flt-params]
+                 (println "flt-params: " flt-params)
+                 (-> rows
+                     (#(if (:search-str flt-params)
+                         (case (:filter-type flt-params)
+                           :numeric (filter-rows-numeric %
+                                                         (:filter-cond flt-params)
+                                                         (:field-name flt-params)
+                                                         (:search-str flt-params))
+                           :text (filter-rows-text %
+                                                   (:field-name flt-params)
+                                                   (:search-str flt-params)))
+                         %))))
+               init-rows
+               filter-params)))
+;;; -------------------------------------------
+
 (defn filter-rows!
   [filter-params]
   (println "filter-rows!")
+  (println filter-params)
   (let [init-rows @init-rows
-        filtered-rows (if (u/nil-or-empty? filter-params)
-                        init-rows
-                        (reduce-kv (fn [rows flt-index flt-params]
-                                     (-> rows
-                                         (#(if (:search-str flt-params)
-                                             (filter-rows-numeric %
-                                                                  (:filter-cond flt-params)
-                                                                  (:field-name flt-params)
-                                                                  (:search-str flt-params))
-                                             %))))
-                                   init-rows
-                                   filter-params))]
+        filtered-rows (get-filtered-rows init-rows filter-params)]
     (when (= filtered-rows init-rows) (loading-off!))
-    (reset! (rum/cursor-in app-state [:rows]) filtered-rows)))
+    (reset! (rum/cursor-in app-state [:rows]) filtered-rows)
+    ))

@@ -205,12 +235,17 @@
              :sort-redraw (sort-rows! @(app-cursor :sort-params))
              :filter-redraw (do
                               (filter-rows! @(app-cursor :active-col-filters))
-                              (sort-rows! @(app-cursor :sort-params)))))))
+                              (sort-rows! @(app-cursor :sort-params))))
+           ;; если нет строк, таблица не будет перерисовываться
+;;            (when (u/nil-or-empty? @(app-cursor :rows))
+;;              (loading-off!))
+           )))

 (defn start-redrawing-table
   [redraw-type]
   (loading-on!)
   (deselect-row)
+  (reset! (app-cursor :show-text-filter?) false)
   (js/moveBodyScrollUp)
   (am/go (a/>! redraw-table-ch redraw-type)))

@@ -228,9 +263,14 @@
            (fn [k a old-s new-s]
              (println ":filters-watcher")
              (println new-s)
-             (when (or (some #(not (nil? (get-in % [1 :search-str]))) new-s)
-                       (u/nil-or-empty? new-s))
-               (start-redrawing-table :filter-redraw))
+             ;; если есть какое-то значение для числового поиска
+;;              (when (or (some #(and (not (nil? (get-in % [1 :search-str])))
+;;                                    (= :numeric (get-in % [1 :filter-type])))
+;;                              new-s)
+;;                        ;; если обнулили
+;;                        (u/nil-or-empty? new-s))
+               (start-redrawing-table :filter-redraw)
+;;              )
 ;;                ;; фильтруем
 ;;                (filter-rows! new-s)
 ;;                ;; заодно сортируем
@@ -249,15 +289,6 @@
    :margin (rand-int 8000000)
    :tmzSales (rand-int 80000) :tmzAmount (rand-int 800)
    :salesPercent (rand 100)})
-
-;; (let [rows (for [x (range 5)]
-;;              (random-row))
-;;       sorted-rows (get-sorted-rows rows
-;;                                    :brand
-;;                                    :numeric
-;;                                    :desc)]
-;;   (println rows)
-;;   (println sorted-rows))

@@ -306,18 +337,45 @@
   )

-(defn change-col-filter-search-str
-  [column value]
-  (println "change-col-filter-search-str " value)
+(defn change-numeric-filter-search-str
+  [column active-col-filter value]
+  (println "change-NUM-filter-search-str " value)
   (swap! (rum/cursor-in app-state [:active-col-filters])
          #(assoc-in % [(:index column) :search-str] value))
 ;;   (println @(rum/cursor-in app-state [:active-col-filters]))
   )

+(defn change-text-filter-search-str
+  [column active-col-filter value]
+  (println "change-TEXT-filter-search-str " value)
+  (swap! (rum/cursor-in app-state [:active-col-filters])
+         ;; если уже был фильтр на эту колонну
+         #(if active-col-filter
+            ;; изменяем одно поле
+            (assoc-in % [(:index column) :search-str] value)
+            ;; иначе создаем первоначальную инфу по фильтру
+            (assoc % (:index column)
+              (assoc (column->init-col-filter column)
+                                     :search-str value))))
+;;   (println @(rum/cursor-in app-state [:active-col-filters]))
+  )
+
+
+(defn current-filter-checkboxes-to-column
+  "Получить список чекбоксов для фильтра для конкр.столбца"
+  [column]
+  (let [c-rows (get-filtered-rows @init-rows
+                                  @(app-cursor :active-col-filters))]
+    (into [] (map-indexed (fn[i r]
+                            {:index i
+                             :name (get r (:field-name column))
+                             :checked? true})
+                         c-rows))))
+

 (defn show-filter-popup
   "Показать контекстное меню для добавления записи в категорию"
-  [evt]
+  [evt column]
   (do
     (println "show-filter-popup!")
     (let [top-offset (-> (.-target evt)
@@ -334,6 +392,9 @@
                           (str "px"))]
       (.css (js/$. ".text-filter-window") #js {:top top-offset
                                                :left left-offset}))
+    ;; обновляем список чекбоксов для этого столбца
+    (reset! (app-cursor :current-filter-checkboxes) (current-filter-checkboxes-to-column column))
+    ;; ставим признак, чтобы показывать попап
     (reset! (app-cursor :show-text-filter?) true)
     (println (app-cursor :show-text-filter?))))

@@ -344,14 +405,48 @@
   (reset! (app-cursor :show-text-filter?) false))

-(defn current-filter-checkboxes-from-rows
+(defn click-select-all-checkbox
+  "Клик по 'выбрать все' чекбоксу"
   []
-  (let [rows @(app-cursor :rows)]
-    (map #(-> {:id (:id %)
-              :name (:brand %)
-              :checked? false})
-           @(app-cursor :rows))
+  (let [select-all-checkbox @(app-cursor :select-all-checkbox)
+        checkboxes @(app-cursor :current-filter-checkboxes)
+        toggle-all-to (fn [check?]
+                        (do
+                          (swap! (app-cursor :select-all-checkbox)
+                                 #(-> %
+                                      (assoc :checked? check?)
+                                      (assoc :indeterminate? false)))
+                          (swap! (app-cursor :current-filter-checkboxes)
+                                 #(into [] (map (fn[chm](assoc chm :checked? check?)) %)))))]
+    (toggle-all-to (not (:checked? select-all-checkbox)))))
+
+
+
+(defn click-filter-checkbox
+  "Клик по чекбоксу из списка"
+  [checkbox]
+  ;; находим в списке и меняем щелкнутый чекбокс
+  (swap! (app-cursor :current-filter-checkboxes)
+         #(assoc-in % [(:index checkbox) :checked?] (not (:checked? checkbox))))
+  ;; после этого делаем остальные проверки
+  (let [checkboxes @(app-cursor :current-filter-checkboxes)]
+    ;; если все выделены
+    (when-not (some #(not (:checked? %)) checkboxes)
+      (swap! (app-cursor :select-all-checkbox) #(-> %
+                                                    (assoc :checked? true)
+                                                    (assoc :indeterminate? false))))
+    ;; если все отключены
+    (when-not (some #(:checked? %) checkboxes)
+      (swap! (app-cursor :select-all-checkbox) #(-> %
+                                                    (assoc :checked? false)
+                                                    (assoc :indeterminate? false))))
+    ;; если часть включены, а часть нет
+    (when (and (some #(:checked? %) checkboxes)
+               (some #(not (:checked? %)) checkboxes))
+      (swap! (app-cursor :select-all-checkbox) #(assoc % :indeterminate? true)))
     ))
+
+

 ;; (defn show-filter-popup
 ;;   [evt]
@@ -387,7 +482,13 @@
    [:div.ui.dropdown.icon.label.filter-btn
     (if active-col-filter
       (if (= (:filter-cond active-col-filter) :gt) ">" "<")
-      [:i.filter.icon])
+
+;;       [:i.icons
+;;        [:i.filter.icon]
+;;        [:i.corner.pin.icon {:style {:font-size ".6em"}}]]
+      [:i.filter.icon]
+
+      )
     [:div.menu
      [:div.item {:class (if (= (:filter-cond active-col-filter) :gt) "active" "")
                  :on-click #(click-gt-filter column active-col-filter)}
@@ -404,8 +505,9 @@
             :disabled (nil? active-col-filter)
             :style {:text-align "right"}
             :value (u/value-or-empty-str (:search-str active-col-filter))
-            :on-change #(change-col-filter-search-str column
-                                                      (dom/target-value %))
+            :on-change #(change-numeric-filter-search-str column
+                                                          active-col-filter
+                                                          (dom/target-value %))
             }]])

 (rum/defc text-filter-view
@@ -413,12 +515,14 @@
   [column active-col-filter]
   [:div.ui.fluid.labeled.input
    [:div.ui.icon.label.filter-btn
-    {:on-click #(show-filter-popup %)}
+    {:on-click #(show-filter-popup % column)}
     [:i.filter.icon]]
    [:input {:type "text"
             :class "filter-input"
             :value (u/value-or-empty-str (:search-str active-col-filter))
-            :on-change #(println "text " (dom/target-value %))
+            :on-change #(change-text-filter-search-str column
+                                                       active-col-filter
+                                                       (dom/target-value %))
             }]])

@@ -464,23 +568,26 @@

 (rum/defc body-part-view < rum/reactive {:after-render (fn[state]
                                                          (notify-loaded)
-                                                         state) }
-  [columns rows-cursor selected-row-id-cursor]
+                                                         state)}
+  [columns rows-cursor selected-row-id-cursor loading-cursor]
   (println "body-part-view")
   (let [rows (rum/react rows-cursor)
+        loading? (rum/react loading-cursor)
         selected-row-id (rum/react selected-row-id-cursor)]
     [:div.table-body-div
-     [:table {:cellSpacing 0}
-      [:colgroup
-       (map #(-> [:col {:style {:width (str (:width %) "%")}
-                        :key (:index %)
-                        }])
-            columns)]
-      [:tbody
-       (map #(rum/with-key (row-view %
-                                     columns
-                                     (= selected-row-id (:id %)))
-                           (:id %)) rows)]]]))
+     (if (not (u/nil-or-empty? rows))
+       [:table {:cellSpacing 0}
+        [:colgroup
+         (map #(-> [:col {:style {:width (str (:width %) "%")}
+                          :key (:index %)
+                          }])
+              columns)]
+        [:tbody
+         (map #(rum/with-key (row-view %
+                                       columns
+                                       (= selected-row-id (:id %)))
+                             (:id %)) rows)]]
+       [:div.ui.center.aligned.basic.segment "Не найдено"])]))

 (rum/defc footer-part-view
@@ -543,7 +650,8 @@

     (body-part-view columns
                     (app-cursor :rows)
-                    (app-cursor :selected-row-id))
+                    (app-cursor :selected-row-id)
+                    (app-cursor :loading?))

     (footer-part-view columns)]))

@@ -567,57 +675,64 @@
 ;;      "zzz"]))

-(defn filters-on-render
-  [state]
-  (println "daf")
-  (.checkbox (js/$ ".ui.checkbox"))
-  (.checkbox (js/$ ".master.checkbox")
-             (js-obj "onChecked" (fn[_]
-                                   (this-as
-                                     this
-                                     (println "checked master")
-                                     (-> ".list.actual-items"
-                                         js/$
-                                         (.find ".checkbox")
-                                         (.checkbox "check"))
-                                     ))
-                     "onUnchecked" (fn[_]
-                                   (this-as
-                                     this
-                                     (println "unchecked master")
-                                     (-> ".list.actual-items"
-                                         js/$
-                                         (.find ".checkbox")
-                                         (.checkbox "uncheck"))
-                                     ))
-                     ))
-  (.resizable (js/$ ".text-filter-window")
-              (js-obj "minHeight" 200
-                      "minWidth" 200))
-  state)
-
-
-(rum/defc text-filter-popup-view  < rum/reactive {:after-render filters-on-render}
+
+(rum/defc filter-checkbox-view < {:did-update (fn[state]
+                                                (.checkbox (.find (dom/rcomp->js$ (:rum/react-component state))
+                                                                  ".ui.checkbox"))
+                                                state)}
+  "Вьюшка для чекбокса из списка"
+  [checkbox]
+  [:div.item
+   [:div.ui.checkbox
+    {:class (if (:checked? checkbox) "checked" "")
+     :on-click #(click-filter-checkbox checkbox)}
+    [:input {:type "checkbox" :name (:id checkbox) :checked (:checked? checkbox)}]
+    [:label (:name checkbox)]]])
+
+
+
+(rum/defc select-all-checkbox-view < {:did-update (fn[state]
+                                                    (let [$elem (dom/rcomp->js$ (:rum/react-component state))
+                                                          s-all-ch (first (:rum/args state))]
+                                                      (.checkbox $elem)
+                                                      (if (:indeterminate? s-all-ch)
+                                                        (.checkbox $elem "set indeterminate")
+                                                        (.checkbox $elem "set determinate"))
+                                                      state))}
+  "Вьюшка для 'выбрать все' чекбокса"
+  [select-all-checkbox]
+  [:div.ui.master.checkbox
+   {:class (if (:checked? select-all-checkbox) "checked" "")
+    :on-click click-select-all-checkbox}
+   [:input {:type "checkbox" :checked (:checked? select-all-checkbox)}]
+   [:label (:name select-all-checkbox)]])
+
+
+
+(rum/defc text-filter-popup-view  < rum/reactive {:after-render (fn[state]
+                                                                   (.resizable (js/$ ".text-filter-window")
+                                                                               (js-obj "minHeight" 200
+                                                                                "minWidth" 200))
+                                                                  state)}
   "Вьюшка для фильтра с галочками"
-  [show-cursor checkboxes-cursor]
-  (println "show-cursor: " show-cursor)
+  [show-cursor checkboxes-cursor select-all-checkbox-cursor]
+;;   (println "show-cursor: " show-cursor)
   (let [show-text-filter? (rum/react show-cursor)
-        checkboxes (rum/react checkboxes-cursor)]
+        checkboxes (rum/react checkboxes-cursor)
+        select-all-checkbox (rum/react select-all-checkbox-cursor)]
     [:div.text-filter-window
      {:style {:visibility (if show-text-filter? "visible" "hidden")}}
-     ;; список
+     ;; список с чекбоксами
      [:div.item-list
       [:div.ui.list
        [:div.item
-        [:div.ui.master.checkbox
-         [:input {:type "checkbox"} ]
-         [:label "Выбрать все"]]]]
+        ;; "выбрать все" чекбокс
+        (select-all-checkbox-view select-all-checkbox)]]
       [:div.ui.divider]
+      ;; остальные варианты
       [:div.ui.list.actual-items
-       (map #(-> [:div.item
-                 [:div.ui.checkbox {:class (if (:checked? %) "checked" "")}
-                  [:input {:type "checkbox" :name (:id %) :checked (:checked? %)}]
-                  [:label (:name %)]]])
+       (map #(rum/with-key
+               (filter-checkbox-view %) (:index %))
             checkboxes)
        ]]
      ;; кнопки
@@ -633,13 +748,14 @@
                     (random-row x))]
     (reset! init-rows rand-rows)
     (reset! (rum/cursor-in app-state [:rows]) @init-rows)
-    (reset! (app-cursor :current-filter-checkboxes) (current-filter-checkboxes-from-rows))
+    ;(reset! (app-cursor :current-filter-checkboxes) (current-filter-checkboxes-from-rows))
     (rum/mount (loading-label-view (app-cursor :loading?))
                (.getElementById js/document "loading-div"))
     (rum/mount (mahtable-view app-state)
                (.getElementById js/document "table-div"))
     (rum/mount (text-filter-popup-view (app-cursor :show-text-filter?)
-                                       (app-cursor :current-filter-checkboxes))
+                                       (app-cursor :current-filter-checkboxes)
+                                       (app-cursor :select-all-checkbox))
                (.getElementById js/document "textfilterpopup-div"))
     (rum/mount (rows-count-view (app-cursor :rows))
                (.getElementById js/document "rows-count-div"))))


Fix indentation

Fix indentation

--- src/com/puppetlabs/http.clj
+++ src/com/puppetlabs/http.clj
@@ -16,8 +16,8 @@
     (let [[prefix suffix] (.split candidate "/")
           wildcard        (str prefix "/*")
           types           (->> (clojure.string/split header #",")
-        (map #(.trim %))
-        (set))]
+                            (map #(.trim %))
+                            (set))]
       (or (types wildcard)
         (types candidate)))))


Removed old :phi_0 parameter from force layout

and also added conexp.layout.util to :use-d namespaces; forgot that last
time...

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/layout/force.clj
+++ src/conexp/layout/force.clj
@@ -1,6 +1,7 @@
 (ns conexp.layout.force
   (:use conexp.base
         conexp.fca.lattices
+	conexp.layout.util
 	conexp.layout.base
 	[conexp.math.util :only (with-doubles)]
 	conexp.math.optimize
@@ -270,8 +271,7 @@
 					    (first (lattice-upper-neighbours lattice n)))
 					  seq-of-inf-irrs),
 		     :inf-irrs seq-of-inf-irrs,
-		     :order (order lattice),
-		     :phi_0 (/ Math/PI 2.0)},
+		     :order (order lattice)}
 	edges    (edges lattice),

 	energy   (fn [& point-coordinates]
@@ -355,8 +355,7 @@
 (defn- test-gravitative-force
   "Testing gravitative forces with a tiny example."
   [pos-a]
-  (let [information {:upper-neighbours-of-inf-irrs {:a :b},
-		     :phi_0 (/ Math/PI 2)},
+  (let [information {:upper-neighbours-of-inf-irrs {:a :b}}
 	layout [{:a pos-a, :b [0 0]}, #{[:a :b]}]]
     [(gravitative-force layout :a 0 information),
      (gravitative-force layout :a 1 information)]))


removed test code

removed test code

--- src/selmer/validator.clj
+++ src/selmer/validator.clj
@@ -70,5 +70,3 @@
              (apply str "The template contains orphan tags: ")
              exception)))))

-
-(validate (.getAbsolutePath (java.io.File. "test/templates/validation-test.html")))


Function to run multiple pieces concurrently

--- src/tenor/constructs.clj
+++ src/tenor/constructs.clj
@@ -126,16 +126,21 @@
   and return overtone code that plays the note."
   `(list 'at ~time (list ~player ~entity)))

-(defmacro construct-measure [measure-maps base-time player pivot-time]
-  "Take a measure map and run construct-note on each
+(defmacro construct-piece [entity-maps base-time player pivot-time]
+  "Take an entity map and run construct-note on each
   note, creating a list of overtone playback code components."
   `(map #(construct-note (+ ~pivot-time (* (:pos %) ~base-time))
                          ~player (:note %))
-        ~measure-maps))
+        ~entity-maps))

-(defn play-measure [measure-maps base-time player
+(defn play-piece [entity-maps base-time player
                     & {:keys [pivot-time] :or {pivot-time (now)}}]
-  "Play the constructed measure with current time as start time."
+  "Play the constructed piece with current time as start time."
   `(let [time# ~pivot-time]
-     ~@(construct-measure measure-maps base-time player pivot-time)))
+     ~@(construct-piece entity-maps base-time player pivot-time)))

+;; --- Multiple voices --- ;;
+
+(defn generate-parallel-voices [& body]
+  (pmap #(eval %) `(list ~@body)))
+


Make sure exceptions do not leak from a Ring app.

--- src/containium/http_kit.clj
+++ src/containium/http_kit.clj
@@ -48,6 +48,17 @@
                                (when context-path context-test))))))

+(defn- wrap-try-catch
+  [handler]
+  (fn [request]
+    (try
+      (handler request)
+      (catch Throwable t
+        (println "Error handling request:" request)
+        (.printStackTrace t)
+        {:status 500 :body "Internal error."}))))
+
+
 (defn- make-app
   "Recreates the toplevel ring handler function, which routes the
   registered RingApps."
@@ -70,7 +81,7 @@
                                                       'request))))))))]
                     (partial (eval fn-form) sorted))
                   (constantly {:status 503 :body "no apps loaded"}))]
-    (alter-var-root #'app (constantly handler))))
+    (alter-var-root #'app (constantly (wrap-try-catch handler)))))

 ;;; Ring app registration.


finished with IMO a cleaner contract layout ... kontract

--- src/fogus/me/trammel.clj
+++ src/fogus/me/trammel.clj
@@ -39,50 +39,6 @@
                                (rest forms)
                                forms))]
     (list* 'fn name body)))
-
-
-(declare kollect-bodies build-kontract)
-
-(defmacro kontract [& forms]
-  (let [name (if (symbol? (first forms))
-               (first forms)
-               nil)
-        body (kollect-bodies (if name
-                               (rest forms)
-                               forms))]
-    `(quote ~body)))
-
-(defn- kollect-bodies [forms]
-  (let [bodies (->> (partition-by vector? forms)
-                    (partition 2))]
-    (for [body bodies]
-      (build-kontract (vec body)))))
-
-(defn- build-kontract [[[sig] expectations :as c]]
-  (let [[L R] (->> expectations
-                   (partition-by #{:requires :ensures})
-                   (partition 2))]
-    (println L)
-    (println)))
-
-(comment
-  (count (kontract doubler
-                   [x]
-                   #_:requires
-                   #_(pos? x)
-
-                   :ensures
-                   (= (* 2 x) %)
-
-                   [x y]
-                   :requires
-                   (pos? x)
-                   (pos? y)
-
-                   :ensures
-                   (= (* 2 (+ x y)) %))))
-
-
 ;; USAGE

 (comment
@@ -120,3 +76,75 @@
   ((partial doubler-contract #(+ %1 %1 %2 %2)) 2 3)

   ((partial doubler-contract #(* 3 (+ %1 %2))) 2 3))
+
+;; Experimentation
+
+(defn- build-kontract [[[sig] expectations :as c]]
+  (list
+    (into '[f] sig)
+    (apply merge
+           (let [parts (->> expectations
+                            (partition-by #{:requires :ensures})
+                            (partition 2))]
+             (for [[[dir] & [cnstr]] parts]
+               {(case dir
+                      :requires :pre
+                      :ensures  :post)
+                (vec cnstr)})))
+    (list* 'f sig)))
+
+
+(defn- kollect-bodies [forms]
+  (let [bodies (->> (partition-by vector? forms)
+                    (partition 2))]
+    (for [body bodies]
+      (build-kontract (vec body)))))
+
+
+(defmacro kontract [& forms]
+  (let [name (if (symbol? (first forms))
+               (first forms)
+               nil)
+        body (kollect-bodies (if name
+                               (rest forms)
+                               forms))]
+    (list* 'fn name body)))
+
+(comment
+  (def doubler-contract
+       (kontract doubler
+                 [x]
+                 :requires
+                 (pos? x)
+
+                 :ensures
+                 (= (* 2 x) %)
+
+                 [x y]
+                 :requires
+                 (pos? x)
+                 (pos? y)
+
+                 :ensures
+                 (= (* 2 (+ x y)) %)))
+
+  (def doubler-fn
+       (fn doubler
+         ([f x]
+            {:post [(= (* 2 x) %)],
+             :pre  [(pos? x)]}
+            (f x))
+         ([f x y]
+            {:post [(= (* 2 (+ x y)) %)],
+             :pre  [(pos? x) (pos? y)]}
+            (f x y))))
+
+  ((partial doubler-contract #(* 2 (+ %1 %2))) 2 3)
+
+  ((partial doubler-contract #(+ %1 %1 %2 %2)) 2 3)
+
+  ((partial doubler-contract #(* 3 (+ %1 %2))) 2 3)
+
+  ((partial doubler-contract #(* 2 %)) 3)
+
+  ((partial doubler-contract #(* 3 %)) 3))


placeholder fuer user und password

placeholder fuer user und password

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -16,8 +16,8 @@
            :subname (str "//" db-host ":" db-port "/" db-name)
            ; Any additional keys are passed to the driver
            ; as driver-specific properties.
-           :user ""
-           :password ""}))
+           :user "usernameplaceholder"
+           :password "passwordplaceholder"}))

 (defn sqlquery [name]
@@ -44,10 +44,6 @@
 (def app
   (-> handler p/wrap-params))

-
-;           {:Kontonummer 11 :Kontostand 31}
-;           {:Kontonummer 12 :Kontostand 11})
-

 (defn -main
  "Kommentar."


Comment out failing function with a TODO via #160.

--- test/clj/forma/hadoop/jobs/cdm_test.clj
+++ test/clj/forma/hadoop/jobs/cdm_test.clj
@@ -4,13 +4,14 @@
   (:use [midje sweet]
         forma.hadoop.jobs.cdm))

-(tabular
- (fact "Test hansen-latlon->cdm function.  A valid lat-lon should produce the
-specified row; but an invalid lat-lon will not produce a row."
-   (hansen-latlon->cdm ?src ?zoom ?tres) => (produces ?row))
- ?src ?zoom ?tres ?row
- [["-87.65005229999997,41.850033,1"]] 16 "32" [[16811 24364 16 131]]
- [["2000,2000,1"]] 16 "32" [])
+;; TODO: Fix this. See: https://github.com/reddmetrics/forma-clj/issues/160
+;; (tabular
+;;  (fact "Test hansen-latlon->cdm function.  A valid lat-lon should produce the
+;; specified row; but an invalid lat-lon will not produce a row."
+;;    (hansen-latlon->cdm ?src ?zoom ?tres) => (produces ?row))
+;;  ?src ?zoom ?tres ?row
+;;  [["-87.65005229999997,41.850033,1"]] 16 "32" [[16811 24364 16 131]]
+;;  [["2000,2000,1"]] 16 "32" [])

 (fact "Test that the output of `forma->cdm` correspond to the proper
 common data model for upload into CartoDB.  Note that only the pixels


fix typo in comment

fix typo in comment

--- src/dalap/html/selector.clj
+++ src/dalap/html/selector.clj
@@ -134,7 +134,7 @@
       visitor)

     :else
-    ;; else it's straigh-up replacement value rather than a func
+    ;; else it's straight-up replacement value rather than a func
     (fn replacement-value-visitor [_node _w] visitor)))

 (defn compile-selector-visitor-pairs [selectors+visitors]


Pre: remove exec_repl.cljc.

Pre: remove exec_repl.cljc.

--- src/datomish/exec_repl.cljc
+++ src/datomish/exec_repl.cljc
@@ -1,111 +0,0 @@
-;; This Source Code Form is subject to the terms of the Mozilla Public
-;; License, v. 2.0. If a copy of the MPL was not distributed with this
-;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-(ns datomish.exec-repl
-  #?(:cljs
-     (:require-macros
-      [datomish.util :refer [while-let]]
-      [datomish.pair-chan :refer [go-pair <?]]
-      [cljs.core.async.macros :refer [go]]))
-  (:require
-     [datomish.db-factory]
-     [datomish.db :as db]
-     [datomish.sqlite :as s]
-     [datomish.sqlite-schema :as ss]
-     [datomish.query :as dq]
-     #?@(:clj
-           [[datomish.jdbc-sqlite]
-            [datomish.pair-chan :refer [go-pair <?]]
-            [datomish.util :refer [while-let]]
-            [clojure.core.async :refer [<!]]])
-     #?@(:cljs
-           [[datomish.promise-sqlite]
-            [datomish.pair-chan]
-            [datomish.util]
-            [cljs.core.async :refer [<!]]])))
-
-#?(:clj
-   (defn pair-channel->lazy-seq
-     "Returns a blocking lazy sequence of items taken from the provided channel."
-     [channel]
-     (lazy-seq
-       (when-let [v (clojure.core.async/<!! channel)]
-         (if (second v)
-           (cons v nil)
-           (cons v (pair-channel->lazy-seq channel)))))))
-
-#?(:clj
-(defn run-to-pair-seq
-  "Given an open database, returns a lazy sequence of results.
-   When fully consumed, underlying resources will be released."
-  [db find]
-  (pair-channel->lazy-seq (db/<?run db find))))
-
-#_
-(defn xxopen []
-    (datomish.pair-chan/go-pair
-      (let [d (datomish.pair-chan/<? (s/<sqlite-connection "/tmp/import.sqlite"))]
-        (clojure.core.async/<!! (ss/<ensure-current-version d))
-        (def db d))))
-
-;; With an open DB…
-#_(run-to-pair-seq
-    db
-    '[:find ?page :in $ :where [?page :page/starred true ?t]])
-
-;; In a Clojure REPL with no open DB…
-#_(clojure.core.async/<!!
-    (datomish.exec-repl/<open-and-run-to-seq-promise
-      "/tmp/foo.sqlite"
-      '[:find ?page :in $ :where [?page :page/starred true ?t]]))
-
-#_(require 'datomish.exec-repl)
-#_(in-ns 'datomish.exec-repl)
-#_
-(go-pair
-  (let [connection (<? (s/<sqlite-connection "/tmp/bigport.db"))
-        d (<? (datomish.db-factory/<db-with-sqlite-connection connection))]
-    (def db d)))
-
-#_
-(go-pair
-  (println (count (first (time
-    (<! (db/<?q db
-                '[:find ?url ?title :in $ :where
-                  [?page :page/visitAt ?v] [(> ?v 1438748166567751)] [?page :page/title ?title] [?page :page/url ?url] ] {})))))))
-
-
-#_
-(go-pair
-  (let [connection (<? (s/<sqlite-connection "/tmp/foo.sqlite"))
-        dd (<? (datomish.db-factory/<db-with-sqlite-connection connection))]
-    (def *db* dd)))
-#_
-(clojure.core.async/<!!
-(go-pair
-(let [now -1
-      forms (mapcat (fn [i]
-                      (map (fn [j]
-                             [:db/add i :x j true])
-                           (range 1000 (* i 2000) i)))
-                    (range 1 10))]
-  (println "Adding" (count forms) "forms")
-  (<? (transact/<transact! *db* forms nil now)))))
-
-#_
-(go-pair
-  (let [connection (<? (s/<sqlite-connection "/tmp/foo.sqlite"))
-        dd (<? (db/<with-sqlite-connection connection))]
-    (println
-       (count
-         (<? (db/<?q dd
-                     '[:find ?e ?v :in $ :where
-                       [?e :x ?v]
-                       #_[(> ?v 1000)]] {}))))))
-
-(dq/parse '[:find ?entity ?tx ?score
- :in $ ?search
- :where [(foobar $ :artist/name ?search) [[?entity _ ?tx ?score]]]])
-
-(honeysql.core/format {:select [:?foo] :from [:foo] :where [:match :foo.x "Bar"]})


delete-untracked -> delete_untracked

delete-untracked -> delete_untracked

--- src/duffel/ext/impl/put.clj
+++ src/duffel/ext/impl/put.clj
@@ -16,7 +16,7 @@
         (mkdir-p abs)
         (force-perms abs owner group chmod))

-      (when (meta-get dtree "delete-untracked")
+      (when (meta-get dtree "delete_untracked")
         (let [present   (set (ls abs))
               tracked   (rest (tree-contents-map #(tree-get % :real-name) dtree))
               untracked (apply disj present tracked)]


Add settings link to project wf runs page

--- src-cljs/frontend/components/pages/workflow.cljs
+++ src-cljs/frontend/components/pages/workflow.cljs
@@ -156,6 +156,18 @@

 (def workflow-runs (om-next/factory WorkflowRuns))

+(defn- settings-link
+  "An Om Next compatible version of frontend.components.header/settings-link"
+  [vcs-type org repo]
+  (html
+   [:div.btn-icon
+    [:a.header-settings-link.project-settings
+     {:href (routes/v1-project-settings-path {:vcs_type vcs-type
+                                              :org org
+                                              :repo repo})
+      :title "Project settings"}
+     [:i.material-icons "settings"]]]))
+
 (defui ^:once Page
   static om-next/IQuery
   (query [this]
@@ -196,4 +208,5 @@
                  :username org-name
                  :project project-name
                  :vcs_type vcs-type}]
+       :header-actions (settings-link vcs-type org-name project-name)
        :main-content (workflow-runs route-data)}))))


make-transformer function has been added to component ns

--- core/src/cljc/hellhound/component.cljc
+++ core/src/cljc/hellhound/component.cljc
@@ -113,6 +113,22 @@
       :hellhound.component/stop-fn    hellhound.components.defaults/stop-fn
       :hellhound.component/depends-on []
       :hellhound.component/fn         ~(list* `fn body)}))
+
+
+(defn make-transformer
+  [component-name f]
+  {:hellhound.component/name       component-name
+   :hellhound.component/start-fn   default-start-fn
+   :hellhound.component/stop-fn    default-stop-fn
+   :hellhound.component/depends-on []
+   :hellhound.component/fn
+   (fn [component]
+     (streams/consume
+      (fn [v]
+        (let [processed-v (f component v)]
+          (when processed-v
+            (streams/>> (output component) processed-v))))
+      (input component)))})

 (defmacro deftransform


Fix render test

Fix render test

--- test/zaffre/components/render_test.cljc
+++ test/zaffre/components/render_test.cljc
@@ -64,8 +64,6 @@
     (let [element (zc/csx [hello-world-label-csx {:value "world"}])
           rendered-element (zcr/render-recursively nil nil element)
           re-rendered-element (zcr/render-recursively rendered-element nil element)]
-      (inspect-tree rendered-element)
-      (inspect-tree re-rendered-element)
       (is (= re-rendered-element rendered-element)))))

 (deftest should-extract-native-elements


removed leftover file

removed leftover file

--- src/ctia/stores/sql/ttp.clj
+++ src/ctia/stores/sql/ttp.clj
@@ -1,158 +0,0 @@
-(ns ctia.stores.sql.ttp
-  (:import org.joda.time.DateTime
-           java.util.UUID)
-  (:require
-   [schema.core :as s]
-   [korma.core :as k]
-   [korma.db :as db]
-   [clojure.string :as str]
-   [clj-time.core :as t]
-   [ctia.schemas.common :refer [timestamp]]
-   [ctia.schemas.ttp :refer [TTP
-                            NewTTP
-                            realize-TTP]]
-   [ctia.stores.sql.common :refer [create-entity-record
-                                  get-entity-record
-                                  get-entity-records
-                                  delete-entity-record]]))
-
-(k/defentity ttp)
-(k/defentity ttp_exploit_targets)
-(k/defentity ttp_related_ttps)
-(k/defentity ttp_indicators)
-
-
-(defn- make-id [schema j]
-  (str "ttp" "-" (UUID/randomUUID)))
-
-
-(def ttp-identity-config
-  {:entity ttp
-   :relations [{:entity ttp_exploit_targets
-                :local-id :indicator_id
-                :foreign-id :exploit_target_id
-                :field :exploit_targets
-                :field-foreign-id :exploit_target}
-
-               {:entity indicator_types
-                :local-id :indicator_id
-                :foreign-id :type_id
-                :field :type}
-
-               {:entity indicator_judgements
-                :local-id :indicator_id
-                :foreign-id :judgement_id
-                :field :judgements
-                :field-foreign-id :judgement
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_composite_indicator_expression
-                :local-id :indicator_id
-                :foreign-id :related_indicator_id
-                :field :composite_indicator_expression
-                :field-foreign-id :indicator
-                :metas [:operator
-                        :confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_indicated_ttp
-                :local-id :indicator_id
-                :foreign-id :ttp_id
-                :field :indicated_TTP
-                :field-foreign-id :ttp
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_suggested_coas
-                :local-id :indicator_id
-                :foreign-id :coa_id
-                :field :suggested_COAs
-                :field-foreign-id :coa
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_sightings
-                :local-id :indicator_id
-                :foreign-id :sighting_id
-                :field :sightings
-                :field-foreign-id :sighting
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_related_indicators
-                :local-id :indicator_id
-                :foreign-id :related_indicator_id
-                :field :related_indicators
-                :field-foreign-id :indicator
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_related_campaigns
-                :local-id :indicator_id
-                :foreign-id :campaign_id
-                :field :related_campaigns
-                :field-foreign-id :campaign
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_related_coas
-                :local-id :indicator_id
-                :foreign-id :coa_id
-                :field :related_COAs
-                :field-foreign-id :COA
-                :metas [:confidence
-                        :source
-                        :relationship]}
-
-               {:entity indicator_kill_chain_phases
-                :local-id :indicator_id
-                :foreign-id :kill_chain_phase_id
-                :field :kill_chain_phases
-                :field-foreign-id :kill_chain_phase}
-
-               {:entity indicator_test_mechanisms
-                :local-id :indicator_id
-                :foreign-id :test_mechanism_id
-                :field :test_mechanisms
-                :field-foreign-id :test_mechanism}]})
-
-(s/defn handle-create-indicator [state :- s/Any
-                                 new-indicator :- NewIndicator]
-
-  (let [id (make-id Indicator new-indicator)
-        realized (realize-indicator new-indicator id)]
-    (create-entity-record indicator-identity-config realized)
-    (get-entity-record indicator-identity-config id)))
-
-(s/defn handle-update-indicator [state :- s/Any
-                                 id :- s/Int
-                                 new-indicator :- NewIndicator]
-
-  (let [realized (realize-indicator new-indicator id)]
-    (delete-entity-record indicator-identity-config id)
-    (create-entity-record indicator-identity-config
-                          (merge realized new-indicator))))
-
-(s/defn handle-read-indicator [state :- (s/atom Indicator)
-                               id :- String]
-  (get-entity-record indicator-identity-config id))
-
-(s/defn handle-delete-indicator [state :- (s/atom Indicator)
-                                 id :- String]
-  (delete-entity-record indicator-identity-config id))
-
-(s/defn handle-list-indicators [state :- (s/atom Indicator)
-                                filter-map :- {}]
-  (get-entity-records indicator-identity-config filter-map))
-
-(s/defn handle-list-indicators-sightings
-  [state :- (s/atom Indicator)
-   filter-map :- {}])


Add debian bullseye images

Add debian bullseye images

--- src/docker_clojure/core.clj
+++ src/docker_clojure/core.clj
@@ -39,11 +39,11 @@
 (def default-jdk-version 11)

 (def distros
-  #{:debian/buster :debian-slim/slim-buster :alpine/alpine})
+  #{:debian/buster :debian-slim/slim-buster :debian/bullseye :debian-slim/slim-bullseye :alpine/alpine})

 ;; The default distro to use for tags that don't specify one, keyed by jdk-version.
 (def default-distros
-  {:default :debian-slim/slim-buster})
+  {:default :debian-slim/slim-bullseye})

 (def build-tools
   {"lein"       "2.9.6"


Next lein-template snapshot

Next lein-template snapshot

--- lein-template/project.clj
+++ lein-template/project.clj
@@ -1,7 +1,7 @@
 ;; Copyright © 2014 JUXT LTD.

 ;; We call this project modular to make the invocation: lein new modular appname
-(defproject modular/lein-template "0.5.1"
+(defproject modular/lein-template "0.5.2-SNAPSHOT"
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}


rwrite tiff to disk using memory mapping

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

--- plugins/OMETiff/src/org/micromanager/ometiff/core.clj
+++ plugins/OMETiff/src/org/micromanager/ometiff/core.clj
@@ -5,12 +5,15 @@
 (defn create-header
   "Creates a big-endian tiff image file header."
   []
-  (byte-array (map byte [77 77 0 42 0 0 0 8])))
+  [77 77 0 42 0 0 0 8])

 (defn make-bytes [val n]
-  (reverse
-    (map #(bit-and 0xFF %)
-         (take n (iterate #(bit-shift-right % 8) val)))))
+  (let [chars
+        (reverse
+          (map #(bit-and 0xFF %)
+           (take n (iterate #(bit-shift-right % 8) val))))]
+    (for [char chars]
+      (if (> char 0x7F) (- char 0xFF) char))))

 (def tag-codes
   {
@@ -29,16 +32,20 @@

 (def type-codes {:byte 1, :ascii 2, :short 3, :long 4, :rational 5})

+(def type-length {:byte 1, :ascii 1, :short 2, :long 4, :rational 8})
+
 (defn make-tag
   "Create a big-endian tiff image IFD entry"
   [tag type count value]
   (let [tag-code (tag tag-codes)
-        type-code (type type-codes)]
+        type-code (type type-codes)
+        type-length (type type-length)]
     (concat
       (make-bytes tag-code 2)
       (make-bytes type-code 2)
       (make-bytes count 4)
-      (make-bytes value 4))))
+      (make-bytes value type-length)
+      (make-bytes 0 (- 4 type-length)))))

 (defn rational-value [x]
   (apply concat
@@ -53,28 +60,32 @@
   "Create a big-endian tiff image IFD."
   [current-offset width height bits-per-pixel
    pixel-size-um final-image?]
-  (let [pixel-size-cm (* 1e-4 pixel-size-um)
-        pixel-size-offset (+ 2 (* 12 11) current-offset)
-        image-offset (+ pixel-size-offset 8)
-        pixels-per-image (* width height)
-        bytes-per-image (* width height (bit-shift-right bits-per-pixel 1))]
-    (concat
-      (make-bytes 1 2)
-      (apply concat
-        (map #(apply make-tag %)
-          [[:ImageWidth :long 1 width]
-           [:ImageWidth :long 1 height]
-           [:BitsPerSample :short 1 bits-per-pixel]
-           [:Compression :short 1 1] ; No compression
-           [:PhotometricInterpretation :short 1 1] ; (Black=0;White=Max)
-           [:StripOffsets :long 1 image-offset]
-           [:RowsPerStrip :long 1 height]
-           [:StripByteCounts :long 1 (* width height)]
-           [:XResolution :rational 1 pixel-size-offset]
-           [:YResolution :rational 1 pixel-size-offset]
-           [:ResolutionUnit :short 1 (if pixel-size-cm 3)]]))
-       (make-bytes (if final-image? 0 (+ image-offset bytes-per-image)) 4)
-       (rational-value pixel-size-cm))))
+  (flatten
+    (let [ifd-entry-count 11
+          pixel-size-cm (* 1e-4 pixel-size-um)
+          pixels-per-image (* width height)
+          bytes-per-image (* width height (bit-shift-right bits-per-pixel 1))
+          pixel-size-offset (+ 2 (* 12 ifd-entry-count) current-offset)
+          image-offset (+ pixel-size-offset 8)
+          ifd-entries
+            (map #(apply make-tag %)
+              [[:ImageWidth :long 1 width]
+               [:ImageLength :long 1 height]
+               [:BitsPerSample :short 1 bits-per-pixel]
+               [:Compression :short 1 1] ; No compression
+               [:PhotometricInterpretation :short 1 1] ; (Black=0;White=Max)
+               [:StripOffsets :long 1 image-offset]
+               [:RowsPerStrip :long 1 height]
+               [:StripByteCounts :long 1 (* width height)]
+               [:XResolution :rational 1 pixel-size-offset]
+               [:YResolution :rational 1 pixel-size-offset]
+               [:ResolutionUnit :short 1 (if pixel-size-cm 3)]])
+              ]
+      (concat
+        (make-bytes ifd-entry-count 2)
+        (list ifd-entries)
+        (make-bytes (if final-image? 0 (+ image-offset bytes-per-image)) 4)
+        (rational-value pixel-size-cm)))))

 ;; Memory-mapped files
@@ -85,22 +96,26 @@
         dsb (.asShortBuffer dbb)]
     {:rwChannel rwChannel :byte-buf dbb :short-buf dsb}))

-(defn write-header [mmap]
-  (.put (:byte-buf mmap) (create-header)))
+(defn write-seq [mmap byte-vals]
+  (.put (:byte-buf mmap) (byte-array (map byte byte-vals))))

-;(defn write-image [pix w h bits-per-pixel pixel-size-um final-image?]
-
+(defn write-bytes [mmap bytes]
+  (.put (:byte-buf mmap) bytes))
+
+(defn get-pos [mmap]
+  (.position (:byte-buf mmap)))
+
+(defn close-mmap [mmap]
+  (let [chan (:rwChannel mmap)]
+    (doto chan
+      (.truncate (get-pos mmap))
+      .close)))

 ; (.position dbb) <-- gets cursor pos
 ; (.position dbb 10) <-- sets cursor pos
-; (.put dbb (byte-array (map byte (range 10))))
-; (def q (byte-array 10))
 ; (.get dbb q) <-- read array
-; (.position dsb (bit-shift-right (.position dbb) 1))
-

 ;; testing
-

 ;;;; image generation

@@ -108,8 +123,23 @@
   (byte (- (rand-int 256) 128)))

 (defn rand-bytes [n]
-  (byte-array (repeatedly n rand-byte)))
+  (let [array (byte-array n)]
+    (doseq [i (range n)]
+      (aset-byte array i (rand-byte)))
+    array))

-(defn rand-image [w h nchannels bytes-per-pixel]
+(defn rand-byte-image [w h nchannels]
   (rand-bytes (* w h nchannels )))

+;; write minimal one-page tiff
+
+(defn write-one-page-tiff [pix w h]
+  (let [mmap (open-mmap "test1.tif" 1000000000)]
+    (write-seq mmap
+      (create-header))
+    (write-seq mmap
+      (create-IFD (get-pos mmap) w h 8 1.0 true))
+    (write-bytes mmap pix)
+    (close-mmap mmap)))
+
+


don't keep recomputing the same widgets

don't keep recomputing the same widgets

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas1.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas1.clj
@@ -260,6 +260,18 @@
           (first (drop-while #(-> % :type primitive-widgets not)
                      (iterate widget data)))))

+(defn memoize-simple [function]
+  (let [last-computation-atom (atom [::nothing nil])]
+    (fn [& args]
+      (let [[last-args last-result] @last-computation-atom]
+        (if (identical? args last-args)
+          last-result
+          (let [result (apply function args)]
+            (reset! last-computation-atom [args result])
+            result))))))
+
+(def expand-memo (memoize-simple expand))
+
 (defn transform-object [{:keys [transform l t x y w h
                          scale-x scale-y scale rotate] :as m}]
    (if (or x y w h rotate scale scale-x scale-y)
@@ -450,7 +462,7 @@
     (dorun
       (map #(with-g2d-state [g2d %]
                             (draw-primitive g2d %))
-           (denest (expand widgets))))))
+           (denest (expand-memo widgets))))))

 (defn draw-error [graphics e]
   (draw graphics
@@ -492,8 +504,7 @@

 (defn triggered-mouse-actions [action-type [x y] data]
   (->> data
-       expand
-       ;show
+       expand-memo
        (filter #(and (% action-type)
                      (-> (.createTransformedShape
                            (% :transform) (% :shape)) (.contains x y))))
@@ -528,8 +539,6 @@
                             (run-mouse-actions e :mouse-down reference))
           (mouseReleased [e] (stop-dragging! canvas)
                              (run-mouse-actions e :mouse-up reference))
-          (mouseEntered [e] (run-mouse-actions e :mouse-enter reference))
-          (mouseExited [e] (run-mouse-actions e :mouse-exit reference))
           (mouseDragged [e] (continue-dragging e canvas)))]
     (doto canvas
       (.addMouseListener mouse-adapter)


Ony using parallelization if the number of items is greater than the amount we'd split in a single thread.

--- src/cmr/metadata_db/services/concept_service.clj
+++ src/cmr/metadata_db/services/concept_service.clj
@@ -202,7 +202,7 @@
                           (for [[provider-id concept-type-tuples-map] split-tuples-map
                                 [concept-type tuples] concept-type-tuples-map]
                             ;; Retrieve the concepts for this type and provider id.
-                            (if (> parallel-chunk-size 0)
+                            (if (and (> parallel-chunk-size 0) (< parallel-chunk-size (count tuples)))
                               ;; retrieving chunks in parallel for faster read performance
                               (apply concat
                                      (cutil/pmap-n-all
@@ -240,7 +240,7 @@
                           (for [[provider-id concept-type-concept-id-map] split-concept-ids-map
                                 [concept-type cids] concept-type-concept-id-map]
                             ;; Retrieve the concepts for this type and provider id.
-                            (if (> parallel-chunk-size 0)
+                            (if (and (> parallel-chunk-size 0) (< parallel-chunk-size (count cids)))
                               ;; retrieving chunks in parallel for faster read performance
                               (apply concat
                                      (cutil/pmap-n-all


[#3036] Wait for background tread to finish before applying txs

--- backend/test/akvo/lumen/lib/transformation_test.clj
+++ backend/test/akvo/lumen/lib/transformation_test.clj
@@ -159,6 +159,7 @@
     (let [dataset-id (import-file *tenant-conn* *error-tracker* {:name "Transformation Test"
                                                                  :has-column-headers? true
                                                                  :file "transformation_test.csv"})
+          _ (tu/try-latest-dataset-version-2 *tenant-conn* dataset-id)
           [tag _] (last (for [transformation data-groups-ops]
                           (async-tx-apply {:tenant-conn *tenant-conn*} dataset-id {:type :transformation
                                                                                :transformation transformation})))]
@@ -168,10 +169,7 @@
             data-group (first (db.data-group/list-data-groups-by-dataset-version-id *tenant-conn*
                                                                                {:dataset-version-id (:id dsv)}))]
         (is (= '({:rnum 1, :c1 "A   ", :c2 "b   ", :c3 "c"})
-               (get-data *tenant-conn* {:table-name (:table-name data-group)})))
-
-        )
-      ))
+               (get-data *tenant-conn* {:table-name (:table-name data-group)}))))))
   (db.env/deactivate-flag *tenant-conn* "data-groups"))


Move a bit away from reagi

Move a bit away from reagi

Seems that reagi works not very well

--- src/ecregister/posts_ui.clj
+++ src/ecregister/posts_ui.clj
@@ -25,7 +25,18 @@
   (listen (select form [:#publish-btn])
           :mouse-clicked (fn [e]
                            (when-let [posts (config (select form [:#publish-btn]) :user-data)]
-                             (r/push! event-stream {:id :publish :value posts}))))
+                             (let [c (async/chan)]
+                               (when (not (empty? posts))
+                                 (posts/send-aw-posts-to-fa-server posts c)
+                                 (async/go
+                                   (let [res (async/<! c)]
+                                     (if (= :error (:id res))
+                                       (show! (pack!
+                                               (dialog :content
+                                                       (str "Failed to send: " (:value res)))))
+                                       (show! (pack!
+                                               (dialog :content
+                                                       (str "Successfully sent " (:value res) " posts"))))))))))))

   (let [fa-stream (r/filter #(= :fa-post (:id %)) event-stream)
         fa-post-stream (r/filter #(map? (:value %)) fa-stream)
@@ -75,29 +86,15 @@
                                       (recur (conj full-posts post)))
                    (= :end post) (do
                                    (prn "all posts fetched")
-                                   (r/push! event-stream {:id :posts-ready :value full-posts})))
+                                   (config! (select form [:#publish-btn]) :enabled? (not (empty? full-posts)))
+                                   (config! (select form [:#publish-btn]) :user-data full-posts)
+                                   ))
                   )
                 )
                ))
            fa-post-stream)
     (r/map (fn [e]
-             (prn "received posts ready event")
-             (when-let [posts (:value e)]
-               (config! (select form [:#publish-btn]) :enabled? true)
-               (config! (select form [:#publish-btn]) :user-data posts))
-             )
-           posts-ready-stream)
-    (r/map (fn [e]
-             (let [c (async/chan)]
-               (posts/send-aw-posts-to-fa-server (:value e) c)
-               (async/go
-                 (let [res (async/<! c)]
-                   (if (= :error (:id res))
-                     (show! (pack! (dialog :content (str "Failed to send: " (:value res)))))
-                     (show! (pack! (dialog :content (str "Successfully sent " (:value res) " posts"))))
-                     )

-                   )))
              )
            publish-request-stream)
     ))


downstream buffer on records query

downstream buffer on records query

--- src/er_cassandra/record.clj
+++ src/er_cassandra/record.clj
@@ -3,6 +3,7 @@
   (:require
    [plumbing.core :refer :all]
    [manifold.deferred :as d]
+   [manifold.stream :as s]
    [qbits.hayt :as h]
    [er-cassandra.key :refer [make-sequential extract-key-equality-clause]]
    [er-cassandra.session :as session])
@@ -47,7 +48,7 @@
     table
     key
     record-or-key-value
-    {:keys [row-generator] :as opts}]
+    opts]
    (session/execute
     session
     (select-statement table key record-or-key-value
@@ -55,7 +56,11 @@
     opts)))

 (defn select-buffered
-  "select records"
+  "select a stream of records
+
+   if :buffer-size opt is given, a *downstream* buffer will be applied to
+   the query stream. the query-buffer will be sized by the :fetch-size opt
+   if given"

   ([^Session session table key record-or-key-value]
    (select session table key record-or-key-value {}))
@@ -64,12 +69,17 @@
     table
     key
     record-or-key-value
-    {:keys [row-generator] :as opts}]
-   (session/execute-buffered
-    session
-    (select-statement table key record-or-key-value
-                      (dissoc opts :columns :where :only-if :order-by :limit))
-    opts)))
+    {:keys [buffer-size] :as opts}]
+   (let [strm (session/execute-buffered
+               session
+               (select-statement
+                table key record-or-key-value
+                (dissoc opts :columns :where :only-if :order-by :limit))
+               (-> opts
+                   (dissoc :buffer-size)))]
+     (if buffer-size
+       (s/buffer buffer-size strm)
+       strm))))

 (defn select-one
   "select a single record"


Изминения

Изминения

--- radiolamp-6P3S/src/ixinfestor/omut.cljs
+++ radiolamp-6P3S/src/ixinfestor/omut.cljs
@@ -311,6 +311,15 @@
 (declare ui-glyphicon)

+(defn ui-datetime [d]
+  (dom/span
+   #js {:className "text-muted"}
+   (ui-glyphicon "time") " "
+   (date-com-format-datetime d)))
+
+
+
+
 (defn ui-cdate-udate [{:keys [cdate udate]}]
   (dom/span
    #js {:className "text-muted"}
@@ -363,7 +372,8 @@
 ;;**************************************************************************************************

 (defn ui-glyphicon [name & [class+ size]]
-  (dom/span #js {:className   (str "glyphicon glyphicon-" name " " (or class+ ""))
+  (dom/span #js {:className   (str "glyphicon glyphicon-"
+                                   name " " (or class+ ""))
                  :style       #js {:fontSize size}
                  :aria-hidden "true"}))


added type hints

added type hints

--- src/gif_to_html/convert.clj
+++ src/gif_to_html/convert.clj
@@ -2,26 +2,26 @@
   (:require [hiccup.core :refer [html]]
             [hiccup.page :refer [html5]]
             [mikera.image.core :refer [scale-image]])
-  (:import javax.imageio.ImageIO
-           java.io.File
+  (:import [javax.imageio ImageReader ImageIO]
            [java.awt.image BufferedImage]
-           [java.awt Color RenderingHints]
-           javax.swing.ImageIcon))
+           java.awt.Color))
+
+(set! *warn-on-reflection* true)

 (def ascii [\# \A \@ \% \$ \+ \= \* \: \, \. \space])
 (def max-items (dec (count ascii)))

-(defn colors [img x y]
+(defn colors [^BufferedImage img ^Integer x ^Integer y]
   (let [c (Color. (.getRGB img x y))]
     [(.getRed c) (.getGreen c) (.getBlue c)]))

-(defn ascii-color [img y x]
+(defn ascii-color [^BufferedImage img ^Integer y ^Integer x]
   (let [[r g b :as rgb] (colors img x y)
         max-color (apply max rgb)
         idx (if (zero? max-color) max-items (int (+ (* max-items (/ max-color 255)) 0.5)))]
     (nth ascii (max idx 0))))

-(defn to-ascii [img]
+(defn to-ascii [^BufferedImage img]
   (let [width  (.getWidth img)
         height (.getHeight img)
         sb     (StringBuilder.)]
@@ -35,7 +35,7 @@
   (int (* (/ 100 a) b)))

 (defn gif->html [input]
-  (let [rdr  (.next (ImageIO/getImageReadersByFormatName "gif"))
+  (let [rdr  ^ ImageReader (.next (ImageIO/getImageReadersByFormatName "gif"))
         ciis (ImageIO/createImageInputStream input)]
     (.setInput rdr ciis false)
     (let [frame-count (.getNumImages rdr true)
@@ -49,6 +49,6 @@
                   [:pre
                    {:id (str "frame-" i)
                     :style "font-size:6pt; letter-spacing:1px; line-height:6pt; font-weight:bold; display: none;font-family:monospace;"}
-                   (to-ascii (scale-image (.read rdr i) w h))])
+                   (to-ascii (scale-image (.read ^ImageReader rdr i) w h))])
                (range frame-count))])
        :frames frame-count})))


CMR-5060 Cleanup.

CMR-5060 Cleanup.

--- umm-spec-lib/src/cmr/umm_spec/umm_g/data_granule.clj
+++ umm-spec-lib/src/cmr/umm_spec/umm_g/data_granule.clj
@@ -8,9 +8,10 @@
 (defn umm-g-data-granule->DataGranule
   "Returns the umm-lib granule model DataGranule from the given UMM-G DataGranule."
   [data-granule]
-  (when (seq data-granule)
+  (when data-granule
     (g/map->DataGranule
-      (let [{:keys [Identifiers DayNightFlag ProductionDateTime ArchiveAndDistributionInformation]} data-granule]
+      (let [{:keys [Identifiers DayNightFlag ProductionDateTime
+                    ArchiveAndDistributionInformation]} data-granule]
         {:day-night DayNightFlag
          :producer-gran-id (->> Identifiers
                                 (filter #(= "ProducerGranuleId" (:IdentifierType %)))
@@ -22,7 +23,7 @@
 (defn DataGranule->umm-g-data-granule
   "Returns the UMM-G DataGranule from the given umm-lib granule model DataGranule."
   [data-granule]
-  (when (seq data-granule)
+  (when data-granule
     (let [{:keys [producer-gran-id day-night production-date-time size]} data-granule]
       {:DayNightFlag day-night
        :Identifiers (when producer-gran-id


Verify gas production

Verify gas production

--- src/clj_simple_chart/bp/gas_production_per_capita.clj
+++ src/clj_simple_chart/bp/gas_production_per_capita.clj
@@ -14,11 +14,20 @@
 (def data (->> bpdata/most-recent-data-countries
                (filter :gas_production_bm3)
                (csv/keep-columns [:gas_production_bm3 :population :country :country_code])
-               (mapv #(assoc % :total (/ (* units/million (:gas_production_bm3 %)) (:population %))))
+               (mapv #(assoc % :total (/ (* units/billion (:gas_production_bm3 %))
+                                         (* 1000 (:population %)))))
                (csv/drop-columns [:gas_production_bm3])
                (filter #(pos? (:total %)))
                (sort-by :total)
                (take-last 20)))
+
+(def norway (first (filter #(= "Norway" (:country %)) data)))
+
+(def norway-gas-production-bill-sm3
+  (/ (* 1000 (:total norway) (:population norway))
+     units/billion))
+;; OD value: 116.649
+;; BP value: 116.649 (!)

 (def marg 10)
 (def two-marg (* 2 marg))


Add barrel coordinates

Add barrel coordinates

--- src/clojure/playasophy/wonderdome/geometry/layout.clj
+++ src/clojure/playasophy/wonderdome/geometry/layout.clj
@@ -108,7 +108,13 @@
           {:coord
            [(* radius (Math/cos theta))
             (* radius (Math/sin theta))
-            (- (* p pixel-vertical-spacing))]})))))
+            (- (* p pixel-vertical-spacing))]
+           :barrel-theta
+           theta
+           :barrel-z
+           (* p pixel-vertical-spacing)
+           :barrel-z-relative
+           (/ p (:pixels strip))})))))


Update component with nulled process data.

--- src/cmr/dev/env/manager/components/common/process.clj
+++ src/cmr/dev/env/manager/components/common/process.clj
@@ -31,7 +31,7 @@
       (log/trace "process:" (get-in component [:process-data :process]))
       (process/terminate! (:process-data component))
       (log/debugf "Stopped %s component." process-name)
-      component)))
+      (assoc component :process-data nil))))

 (defn create-process-runner-component
   ""


Add test for invalid client-auth value

Add test for invalid client-auth value

--- web/test/immutant/web/undertow_test.clj
+++ web/test/immutant/web/undertow_test.clj
@@ -54,4 +54,5 @@
        :want      SslClientAuthMode/REQUESTED
        :requested SslClientAuthMode/REQUESTED
        :need      SslClientAuthMode/REQUIRED
-       :required  SslClientAuthMode/REQUIRED))
+       :required  SslClientAuthMode/REQUIRED)
+  (is (thrown? IllegalArgumentException (options :client-auth :invalid))))


lexicographic ordering of launch-metrics (#926)

arrow operator code formatting

--- waiter/src/waiter/core.clj
+++ waiter/src/waiter/core.clj
@@ -108,8 +108,8 @@
                               ["/gc-services" :state-gc-for-services]
                               ["/gc-transient-metrics" :state-gc-for-transient-metrics]
                               ["/interstitial" :state-interstitial-handler-fn]
+                              ["/kv-store" :state-kv-store-handler-fn]
                               ["/launch-metrics" :state-launch-metrics-handler-fn]
-                              ["/kv-store" :state-kv-store-handler-fn]
                               ["/leader" :state-leader-handler-fn]
                               ["/local-usage" :state-local-usage-handler-fn]
                               ["/maintainer" :state-maintainer-handler-fn]
@@ -188,7 +188,7 @@
         (log/info "request received:"
                   (-> (dissoc request :body :ctrl :in :out :request-time :server-name :server-port :servlet-request
                               :ssl-client-cert :support-info :trailers-fn)
-                      (update :headers headers/truncate-header-values)))
+                    (update :headers headers/truncate-header-values)))
         (let [response (handler request)
               get-request-cid (fn get-request-cid [] request-cid)]
           (if (map? response)
@@ -206,8 +206,8 @@
   [{:keys [headers scheme ^ServletRequest servlet-request]}]
   (if servlet-request
     (or (some-> headers
-                (get "x-forwarded-proto-version")
-                str/upper-case)
+          (get "x-forwarded-proto-version")
+          str/upper-case)
         (.getProtocol servlet-request))
     (when scheme
       (str/upper-case
@@ -221,13 +221,13 @@
   [handler router-id support-info]
   (fn wrap-request-info-fn [{:keys [servlet-request] :as request}]
     (-> request
-        (assoc :client-protocol (request->protocol request)
-               :internal-protocol (some-> servlet-request .getProtocol)
-               :request-id (str (utils/unique-identifier) "-" (-> request utils/request->scheme name))
-               :request-time (t/now)
-               :router-id router-id
-               :support-info support-info)
-        handler)))
+      (assoc :client-protocol (request->protocol request)
+             :internal-protocol (some-> servlet-request .getProtocol)
+             :request-id (str (utils/unique-identifier) "-" (-> request utils/request->scheme name))
+             :request-time (t/now)
+             :router-id router-id
+             :support-info support-info)
+      handler)))

 (defn wrap-debug
   "Attaches debugging headers to requests when enabled.
@@ -296,7 +296,7 @@
           :acceptable-router? #(= dest-router-id %)
           :body (utils/clj->json {:instance instance :period-in-ms blacklist-period-ms :reason reason})
           :method :post)
-        (get dest-router-id))
+      (get dest-router-id))
     (catch Exception e
       (log/error e "error in making blacklist request"
                  {:instance instance :period-in-ms blacklist-period-ms :reason reason}))))
@@ -331,7 +331,7 @@
           kill-instance-endpoint
           :acceptable-router? #(= dest-router-id %)
           :method :post)
-        (get dest-router-id))
+      (get dest-router-id))
     (catch Exception e
       (log/error e "error in killing instance of" service-id))))

@@ -469,15 +469,15 @@
         request-config (update config :headers
                                (fn prepare-inter-router-requests-headers [headers]
                                  (-> headers
-                                     (assoc "accept" "application/json")
-                                     (update "x-cid"
-                                             (fn attach-inter-router-cid [provided-cid]
-                                               (or provided-cid
-                                                   (let [current-cid (cid/get-correlation-id)
-                                                         cid-prefix (if (or (nil? current-cid) (= cid/default-correlation-id current-cid))
-                                                                      "waiter"
-                                                                      current-cid)]
-                                                     (str cid-prefix "." (utils/unique-identifier)))))))))]
+                                   (assoc "accept" "application/json")
+                                   (update "x-cid"
+                                           (fn attach-inter-router-cid [provided-cid]
+                                             (or provided-cid
+                                                 (let [current-cid (cid/get-correlation-id)
+                                                       cid-prefix (if (or (nil? current-cid) (= cid/default-correlation-id current-cid))
+                                                                    "waiter"
+                                                                    current-cid)]
+                                                   (str cid-prefix "." (utils/unique-identifier)))))))))]
     (when (and (empty? router-id->endpoint-url')
                (not-empty router-id->endpoint-url))
       (log/info "no acceptable routers found to make request!"))
@@ -532,8 +532,8 @@
                    "/waiter-consent" "/waiter-interstitial"])
             (and (or (str/blank? host)
                      (valid-waiter-hostnames (-> host
-                                                 (str/split #":")
-                                                 first)))
+                                               (str/split #":")
+                                               first)))
                  (not-any? #(str/starts-with? (key %) headers/waiter-header-prefix)
                            (remove #(= "x-waiter-debug" (key %)) headers))))))))

@@ -806,7 +806,7 @@
                      (fn list-tokens-fn []
                        (let [{:keys [relative-path]} kv-config]
                          (->> (kv/zk-keys curator (str base-path "/" relative-path))
-                              (filter (fn [k] (not (str/starts-with? k "^"))))))))
+                           (filter (fn [k] (not (str/starts-with? k "^"))))))))
    :make-basic-auth-fn (pc/fnk []
                          (fn make-basic-auth-fn [uri username password]
                            (BasicAuthentication$BasicResult. (URI. uri) username password)))
@@ -1204,8 +1204,8 @@
                                                                             instance-request-properties determine-priority-fn ws/process-response!
                                                                             ws/abort-request-callback-factory local-usage-agent request))
                                            handler (-> process-request-fn
-                                                       (ws/wrap-ws-close-on-error)
-                                                       wrap-descriptor-fn)]
+                                                     (ws/wrap-ws-close-on-error)
+                                                     wrap-descriptor-fn)]
                                        (ws/request-handler password handler request))))
    :display-settings-handler-fn (pc/fnk [wrap-secure-request-fn settings]
                                   (wrap-secure-request-fn
@@ -1311,8 +1311,8 @@
                                    wrap-descriptor-fn wrap-secure-request-fn]
                             (-> (fn service-id-handler-fn [request]
                                   (handler/service-id-handler request kv-store store-service-description-fn))
-                                wrap-descriptor-fn
-                                wrap-secure-request-fn))
+                              wrap-descriptor-fn
+                              wrap-secure-request-fn))
    :service-list-handler-fn (pc/fnk [[:daemons router-state-maintainer]
                                      [:routines prepend-waiter-url router-metrics-helpers
                                       service-id->service-description-fn service-id->source-tokens-entries-fn]
@@ -1425,6 +1425,12 @@
                                       (wrap-secure-request-fn
                                         (fn state-interstitial-handler-fn [request]
                                           (handler/get-query-chan-state-handler router-id interstitial-query-chan request)))))
+   :state-kv-store-handler-fn (pc/fnk [[:curator kv-store]
+                                       [:state router-id]
+                                       wrap-secure-request-fn]
+                                (wrap-secure-request-fn
+                                  (fn kv-store-state-handler-fn [request]
+                                    (handler/get-kv-store-state router-id kv-store request))))
    :state-launch-metrics-handler-fn (pc/fnk [[:daemons launch-metrics-maintainer]
                                              [:state router-id]
                                              wrap-secure-request-fn]
@@ -1432,12 +1438,6 @@
                                         (wrap-secure-request-fn
                                           (fn state-launch-metrics-handler-fn [request]
                                             (handler/get-query-chan-state-handler router-id query-chan request)))))
-   :state-kv-store-handler-fn (pc/fnk [[:curator kv-store]
-                                       [:state router-id]
-                                       wrap-secure-request-fn]
-                                (wrap-secure-request-fn
-                                  (fn kv-store-state-handler-fn [request]
-                                    (handler/get-kv-store-state router-id kv-store request))))
    :state-leader-handler-fn (pc/fnk [[:curator leader?-fn leader-id-fn]
                                      [:state router-id]
                                      wrap-secure-request-fn]


Turns out clojure supports comments

Turns out clojure supports comments

--- support/dammit/src/main/clojure/immutant/try.clj
+++ support/dammit/src/main/clojure/immutant/try.clj
@@ -16,9 +16,14 @@
 ;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.

 (ns immutant.try
+  "Useful when unit tests (or any code not run inside Immutant) refer
+   to an Immutant ns that must compile when resources aren't
+   available."
   (:require [clojure.tools.logging :as log]))

-(defn- worked? [attempt]
+(defn- worked?
+  "Eval attempt and return true if it doesn't toss an exception, otherwise false"
+  [attempt]
   (try
     (if (symbol? attempt)
       (eval (eval attempt))
@@ -28,15 +33,21 @@
       (log/warn (.getMessage e))
       false)))

-(defmacro try-defn [attempt name & rest]
-  (let [fname (str name)]
+(defmacro try-defn
+  "Does exactly what defn does assuming eval'ing attempt doesn't throw
+   up. Otherwise, a dummy fn logging a warning is defined."
+  [attempt name & rest]
+  (let [fname (str *ns* "/" name)]      ; capture the ns-qualified name
     (if (worked? attempt)
       `(defn ~name ~@rest)
       `(defn ~name [& args#]
          (log/warn (str "The function, " ~fname ", is limited when run outside of Immutant"))
          nil))))

-(defmacro try-def [attempt name & rest]
+(defmacro try-def
+  "Does exactly what def does assuming eval'ing attempt doesn't throw
+   up. Otherwise, the var is set to nil."
+  [attempt name & rest]
   (if (worked? attempt)
     `(def ~name ~@rest)
     `(def ~name nil)))


Fix sorting bug in cartesian/sort-edges.

--- src/org/playasophy/wonderdome/geometry/cartesian.clj
+++ src/org/playasophy/wonderdome/geometry/cartesian.clj
@@ -82,5 +82,5 @@
 (defn sort-edges
   "Returns a sequence of edges, sorted by z, y, then x coordinates."
   [edges]
-  (let [edge-key (fn [[a b]] (vec (map sort (reverse (map vector a b)))))]
+  (let [edge-key (fn [[a b]] (vec (map (comp vec sort) (reverse (map vector a b)))))]
     (reverse (sort-by edge-key edges))))


scheduler: Add metrics for process-matches-for-backfill

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -141,6 +141,21 @@
 (meters/defmeter [cook-mesos scheduler tasks-failed-cpus])
 (histograms/defhistogram [cook-mesos scheduler hist-task-fail-times])
 (meters/defmeter [cook-mesos scheduler task-fail-times])
+
+(meters/defmeter [cook-mesos scheduler backfilled-count])
+(histograms/defhistogram [cook-mesos scheduler hist-backfilled-count])
+(meters/defmeter [cook-mesos scheduler backfilled-cpu])
+(meters/defmeter [cook-mesos scheduler backfilled-mem])
+
+(meters/defmeter [cook-mesos scheduler upgraded-count])
+(histograms/defhistogram [cook-mesos scheduler hist-upgraded-count])
+(meters/defmeter [cook-mesos scheduler upgraded-cpu])
+(meters/defmeter [cook-mesos scheduler upgraded-mem])
+
+(meters/defmeter [cook-mesos scheduler fully-processed-count])
+(histograms/defhistogram [cook-mesos scheduler hist-fully-processed-count])
+(meters/defmeter [cook-mesos scheduler fully-processed-cpu])
+(meters/defmeter [cook-mesos scheduler fully-processed-mem])

 (def success-throughput-metrics
@@ -486,6 +501,24 @@
         jobs-fully-processed (filter matched? jobs-before-backfilling)
         jobs-to-upgrade (filter previously-backfilled? jobs-before-backfilling)
         tasks-ids-to-upgrade (->> jobs-to-upgrade (mapv backfilled-ids-memo) (apply concat) vec)]
+
+    (let [resources-backfilled (util/sum-resources-of-jobs jobs-to-backfill)
+          resources-fully-processed (util/sum-resources-of-jobs jobs-fully-processed)
+          resources-upgraded (util/sum-resources-of-jobs jobs-to-upgrade)]
+      (meters/mark! backfilled-count (count jobs-to-backfill))
+      (histograms/update! hist-backfilled-count (count jobs-to-backfill))
+      (meters/mark! backfilled-cpu (:cpus resources-backfilled))
+      (meters/mark! backfilled-mem (:mem resources-backfilled))
+
+      (meters/mark! fully-processed-count (count jobs-fully-processed))
+      (histograms/update! hist-fully-processed-count (count jobs-fully-processed))
+      (meters/mark! fully-processed-cpu (:cpus resources-fully-processed))
+      (meters/mark! fully-processed-mem (:mem resources-fully-processed))
+
+      (meters/mark! upgraded-count (count jobs-to-upgrade))
+      (histograms/update! hist-upgraded-count (count jobs-to-upgrade))
+      (meters/mark! upgraded-cpu (:cpus resources-upgraded))
+      (meters/mark! upgraded-mem (:mem resources-upgraded)))

     {:fully-processed (mapv :job/uuid jobs-fully-processed)
      :upgrade-backfill tasks-ids-to-upgrade


Unclumsify selection of drivers in tests following PR comments

--- test/etaoin/api_test.clj
+++ test/etaoin/api_test.clj
@@ -23,15 +23,25 @@
 ; to a Clojure vector encoded as a string; for example:
 ;
 ;   ETAOIN_TEST_DRIVERS="[:firefox]" lein test
-;
+
+(defn get-drivers-from-env []
+  (when-let [override (System/getenv "ETAOIN_TEST_DRIVERS")]
+    (clojure.edn/read-string override)))
+
+(defn get-drivers-from-prop []
+  (case (first (str/split (System/getProperty "os.name") #"\s+"))
+    "Linux" [:firefox :chrome :phantom]
+    "Mac" [:firefox :chrome :phantom :safari]
+    "Windows" [:firefox :chrome :phantom :safari]
+    nil))
+
+(defn get-default-drivers []
+  [:firefox :chrome :phantom :safari])
+
 (def drivers
-  (if-let [override (System/getenv "ETAOIN_TEST_DRIVERS")]
-    (clojure.edn/read-string  override)
-    (case (first (str/split (System/getProperty "os.name") #"\s+"))
-      "Linux" [:firefox :chrome :phantom]
-      "Mac" [:firefox :chrome :phantom :safari]
-      "Windows" [:firefox :chrome :phantom :safari]
-      [:firefox :chrome :phantom :safari])))
+  (or (get-drivers-from-env)
+      (get-drivers-from-prop)
+      (get-default-drivers)))

 (def ^:dynamic *driver*)


Delete default test from lein

Delete default test from lein

--- test/fault/core_test.clj
+++ test/fault/core_test.clj
@@ -1,7 +0,0 @@
-(ns fault.core-test
-  (:require [clojure.test :refer :all]
-            [fault.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


Trying to pull :href value from string/map combo in returned collection. Destructuring might work better here...

--- scraper/src/scraper/core.clj
+++ scraper/src/scraper/core.clj
@@ -61,7 +61,7 @@
                            (first)
                            (by-tag :a))
                        )]
-    (map #(println (get-in [% :href])) the-factions)
+    (map #(get-in % [:href]) the-factions)
     ;(dotimes [i 10] (future (send-off url-col (parse "http://wiki.project1999.com/index.php?title=Category:Factions"))))
     )
   )


Add function to add a date header to a response

--- src/io/aviso/rook/utils.clj
+++ src/io/aviso/rook/utils.clj
@@ -1,10 +1,10 @@
 (ns io.aviso.rook.utils
   "Kitchen-sink of useful standalone utilities."
   (:import
-    (java.util UUID)
-    (javax.servlet.http HttpServletResponse))
+    (java.util UUID))
   (:require
     [ring.util.response :as r]
+    [ring.util.time :as t]
     [clojure.pprint :as pprint]))

 (defn new-uuid
@@ -24,6 +24,11 @@
   ([status body] (->
                    (r/response body)
                    (r/status status))))
+
+(defn date-header
+  "Adds a date header to the response, using the RFC-1123 format."
+  [response name date]
+  (r/header response name (t/format-date date)))

 (defn pretty-print
   "Pretty-prints the supplied object to a returned string."


don't show changelog in Enterprise

don't show changelog in Enterprise

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -492,12 +492,13 @@
               [:i.material-icons "chat"]
               [:div.nav-label "Support"]]

-           [:a.aside-item (open-ext {:data-placement "right"
-                                     :data-trigger "hover"
-                                     :title "Changelog"
-                                     :href "/changelog"})
-              [:i.material-icons "receipt"]
-              [:div.nav-label "Changelog"]]
+            (when-not (config/enterprise?)
+              [:a.aside-item (open-ext {:data-placement "right"
+                                        :data-trigger "hover"
+                                        :title "Changelog"
+                                        :href "/changelog"})
+               [:i.material-icons "receipt"]
+               [:div.nav-label "Changelog"]])

             [:hr]


Only delete old export files during export

--- android/src/clojure/net/nightweb/actions.clj
+++ android/src/clojure/net/nightweb/actions.clj
@@ -220,8 +220,7 @@
                                      (str slash user-zip-file))
                        ; if it's a content URI, copy to root of SD card
                        path (if (.startsWith uri-str "content://")
-                              (do (delete-file temp-path)
-                                  (copy-uri-to-path context uri-str temp-path)
+                              (do (copy-uri-to-path context uri-str temp-path)
                                   temp-path)
                               (.getRawPath (java.net.URI. uri-str)))
                        dest-path (get-user-dir)]


Add Jira ticket number for prismatic cleanup

--- src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
+++ src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
@@ -91,7 +91,7 @@
 (defn proxy-target?
   "A predicate that validates the format of a proxy target configuration map"
   [target]
-  ;; TODO: should probably be using prismatic schema here
+  ;; TODO: should probably be using prismatic schema here (PE-3409)
   (and
     (map? target)
     (string? (:host target))


Update outdated dependencies.

Update outdated dependencies.

--- project.clj
+++ project.clj
@@ -10,7 +10,7 @@
     [org.clojure/clojure "1.5.1"] ; Lisp on the JVM http://clojure.org/documentation
     [org.clojure/core.incubator "0.1.3"] ; functions proposed for inclusion in Clojure https://github.com/clojure/core.incubator
     [org.clojure/core.match "0.2.0"] ; Erlang-esque pattern matching https://github.com/clojure/core.match
-    [org.clojure/clojurescript "0.0-1913"] ; ClojureScript compiler https://github.com/clojure/clojurescript
+    [org.clojure/clojurescript "0.0-1934"] ; ClojureScript compiler https://github.com/clojure/clojurescript
     [cheshire "5.2.0"] ; JSON de/encoding https://github.com/dakrone/cheshire
     [org.flatland/ordered "1.5.1"] ; Ordered hash map https://github.com/flatland/ordered
     [ring/ring-jetty-adapter "1.2.0"] ; Web Server https://github.com/ring-clojure/ring
@@ -90,7 +90,7 @@
     [lein-ring "0.8.7"] ; common ring tasks https://github.com/weavejester/lein-ring
     [lein-environ "0.4.0"] ; Get environment settings from different sources https://github.com/weavejester/environ
     [lein-git-deps "0.0.1-SNAPSHOT"] ; dependencies from GitHub https://github.com/tobyhede/lein-git-deps
-    [lein-cljsbuild "0.3.3"] ; ClojureScript compiler https://github.com/emezeske/lein-cljsbuild
+    [lein-cljsbuild "0.3.4"] ; ClojureScript compiler https://github.com/emezeske/lein-cljsbuild
     [lein-cucumber "1.0.2"] ; BDD testing https://github.com/nilswloka/lein-cucumber
     [lein-midje "3.1.3-RC1"] ; Example-based testing https://github.com/marick/lein-midje
     [lein-bikeshed "0.1.3"] ; Check for code smells https://github.com/dakrone/lein-bikeshed


0.3.0 bugfix release.

0.3.0 bugfix release.

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject cljs-bach "0.3.0-SNAPSHOT"
+(defproject cljs-bach "0.3.0"
   :description "A Clojurescript wrapper for the Web Audio API."
   :license {:name "MIT" }
   :dependencies [[org.clojure/clojure "1.7.0"]


Upgrade core.async to 0.2.385

Upgrade core.async to 0.2.385

--- project.clj
+++ project.clj
@@ -13,7 +13,7 @@
   :main yetibot.core.init
   :profiles {:test {:resource-paths ["test/resources"]}}
   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/core.async "0.1.338.0-5c5012-alpha"]
+                 [org.clojure/core.async "0.2.385"]
                  [org.clojure/data.json "0.2.6"]
                  [org.clojure/tools.nrepl "0.2.12"]
                  [org.clojure/tools.trace "0.7.9"]


Unnecessary clojurescript Makefile flag.

--- project.clj
+++ project.clj
@@ -12,7 +12,7 @@
   :hooks [leiningen.cljsbuild]

   :source-paths ["src"]
-  :clojurescript? true
+
   :cljsbuild {
     :builds [{:id "ago"
               :source-paths ["src"]


Version 0.14.3

Version 0.14.3

--- project.clj
+++ project.clj
@@ -2,7 +2,7 @@
                        (System/getenv "CLOJURE_VERSION")
                        "1.8.0"))

-(defproject lambdacd "0.14.3-SNAPSHOT"
+(defproject lambdacd "0.14.3"
   :description "A library to create a continous delivery pipeline in code."
   :url "http://github.com/flosell/lambdacd"
   :license {:name "Apache License, version 2.0"


Version 4.0.6-SNAPSHOT

Version 4.0.6-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject com.lemondronor/pid "4.0.5"
+(defproject com.lemondronor/pid "4.0.6-SNAPSHOT"
   :description "PID controller in Clojure. Code for writing PID control loops."
   :url "http://github.com/wiseman/clj-pid"
   :license {:name "Eclipse Public License"


Version bump in master

Version bump in master

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject haunting-refrain "0.2.0-SNAPSHOT"
+(defproject haunting-refrain "0.2.0"
   :pedantic? :warn
   :dependencies [[org.clojure/clojure "1.9.0-alpha14"]
                  [org.clojure/clojurescript "1.9.293"]


Add minimum lein version constraint

Add minimum lein version constraint

--- project.clj
+++ project.clj
@@ -14,6 +14,7 @@
                  [ragtime "0.3.8"]
                  [com.cemerick/friend "0.2.1"]
                  [clj-time "0.9.0"]]
+  :min-lein-version "2.0.0"
   :plugins [[lein-ring "0.9.2"]
             [ragtime/ragtime.lein "0.3.8"]]


Joe - version number bump. breaking changes

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject clj-cctray "0.5.1"
+(defproject clj-cctray "0.6.0"
             :description "Clojure parser for cctray.xml"
             :url "https://github.com/build-canaries/clj-cctray"
             :license {:name "Eclipse Public License"


lein autotest and midje-notifier, the latter not working due to midje.emission.state java.lang.ClassNotFoundException

--- project.clj
+++ project.clj
@@ -8,7 +8,8 @@
   :profiles
     {:dev
       {:dependencies [[proto-repl "0.3.1"]
-                      [midje "1.8.3" :exclusions [org.clojure/clojure]]]
+                      [midje "1.8.3" :exclusions [org.clojure/clojure]]
+                      [midje-notifier "0.2.0"]]
        :plugins [[lein-shell "0.5.0"]
                  [lein-javac-resources "0.1.1"]
                  [lein-midje "3.2.1"]]
@@ -20,7 +21,8 @@
                       :map-coll-separator :line}}}
      :uberjar {:aot :all
                :omit-source true}}
-   :aliases {"test" ["midje"]}
+   :aliases {"test" ["midje"]
+             "autotest" ["midje" ":autotest"]}
    :main ephemeris.main
    :jar-name "ephemeris.jar"
    :uberjar-name "ephemerist.jar"


Increasing version

Increasing version

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject tropefest "0.0.1-SNAPSHOT"
+(defproject tropefest "0.0.2-SNAPSHOT"
             :description "FIXME: write description"
             :url "http://example.com/FIXME"


modify cljsbuild id, add :optimizations :none

--- project.clj
+++ project.clj
@@ -34,7 +34,7 @@
   :repl-options {:init-ns user}

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

                 :figwheel true
@@ -46,7 +46,8 @@
                            :output-to     "resources/public/js/main.js"
                            :output-dir    "resources/public/js"
                            :source-map-timestamp true
-                           :verbose true}}}}
+                           :verbose true
+                           :optimizations :none}}}}

   :figwheel {;; :http-server-root "public"       ;; serve static assets from resources/public/
              ;; :server-port 3449                ;; default


(maint) Bump ezbake to 2.2.1

(maint) Bump ezbake to 2.2.1

Ensures we use the right OutOfMemory cli flag based on the java version

--- project.clj
+++ project.clj
@@ -297,7 +297,7 @@
                                                ;; in the final package.
                                                [puppetlabs/puppetdb ~pdb-version]]
                       :name "puppetdb"
-                      :plugins [[puppetlabs/lein-ezbake "2.2.0"]]}
+                      :plugins [[puppetlabs/lein-ezbake "2.2.1"]]}
              :testutils {:source-paths ^:replace ["test"]
                          :resource-paths ^:replace []
                          ;; Something else may need adjustment, but


Version 0.1.5

Version 0.1.5

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject sbsk "0.1.5-SNAPSHOT"
+(defproject sbsk "0.1.5"
   :description "FIXME: write description"
   :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"


Version 0.0.8-SNAPSHOT

Version 0.0.8-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject pe-fp-core "0.0.7"
+(defproject pe-fp-core "0.0.8-SNAPSHOT"
   :description "A Clojure library encapsulating the various domain objects associated with the fuel purchase application."
   :url "https://github.com/evanspa/pe-fp-core"
   :license {:name "MIT"


lib update

lib update

--- project.clj
+++ project.clj
@@ -1,19 +1,20 @@
-(defproject org.rksm/cloxp-cljs "0.1.8"
+(defproject org.rksm/cloxp-cljs "0.1.9"
   :description "cloxp-cljs"
   :license {:name "MIT License"
             :url "http://opensource.org/licenses/MIT"}
-  :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/clojurescript "0.0-3211"]
+  :dependencies [[org.clojure/clojure "1.7.0"]
+                 [org.clojure/clojurescript "0.0-3308"]
                  [org.rksm/system-files "0.1.6"]
                  [org.rksm/cloxp-source-reader "0.1.8"]
                  [org.rksm/cloxp-repl "0.1.7"]
-                 [clojurescript-build/clojurescript-build "0.1.6"
+                 [clojurescript-build/clojurescript-build "0.1.7"
                   :exclusions [org.clojure/clojurescript
                                org.clojure/core.async]]
                  [org.rksm/cloxp-projects "0.1.9"]
-                 [lein-cljsbuild "1.0.5"]]
+                 [lein-cljsbuild "1.0.6"]]
   :source-paths ["src/clj" "src/cljs"]
   :test-paths ["src/test"]
+  :clean-targets ["cloxp-cljs-build" :target-path]
   :deploy-repositories [["releases" :clojars]]
   :hiera {:path "target/ns-hierarchy.png"
           :show-external true


oops, jvm-opts fix

oops, jvm-opts fix

--- project.clj
+++ project.clj
@@ -34,7 +34,7 @@
   :plugins [[lein-cljsbuild "1.1.5"]]
   :test-paths ["test/clj"]
   :profiles {:uberjar {:aot        :all
-                       :jvm-opts ["-Xms1024m -Xmx2048m"]
+                       :jvm-opts ["-Xms1024m" "-Xmx2048m"]
                        :prep-tasks ["compile" ["cljsbuild" "once" "prod"]]}
              :dev     [:dev-secrets {:source-paths ["dev" "test/clj"]
                                      :dependencies [[org.clojure/tools.namespace "0.2.11"]


change clojure/cljs dependencies to provided

--- project.clj
+++ project.clj
@@ -1,16 +1,16 @@
 (def VERSION (.trim (slurp "VERSION")))

 (defproject com.rpl/specter VERSION
-  :dependencies [[org.clojure/clojure "1.6.0"]
-                 [org.clojure/clojurescript "0.0-3211"]
-                 ]
   :jvm-opts ["-XX:-OmitStackTraceInFastThrow"] ; this prevents JVM from doing optimizations which can remove stack traces from NPE and other exceptions
   :source-paths ["src/clj"]
   :java-source-paths ["src/java"]
   :test-paths ["test", "target/test-classes"]
   :jar-exclusions [#"\.cljx"]
   :auto-clean false
-  :profiles {:dev {:dependencies
+  :profiles {:provided {:dependencies
+                        [[org.clojure/clojure "1.6.0"]
+                         [org.clojure/clojurescript "0.0-3211"]]}
+             :dev {:dependencies
                    [[org.clojure/test.check "0.7.0"]]
                    :plugins
                    [[com.keminglabs/cljx "0.6.0"]]


Version 0.4.14

Version 0.4.14

--- project.clj
+++ project.clj
@@ -1,6 +1,6 @@
 (def ks-version "1.0.0")

-(defproject puppetlabs/jdbc-util "0.4.14-SNAPSHOT"
+(defproject puppetlabs/jdbc-util "0.4.14"
   :description "Common JDBC helpers for use in Puppet Labs projects"
   :url "https://github.com/puppetlabs/jdbc-util"


Bumping to Clojure 1.6

Bumping to Clojure 1.6

--- project.clj
+++ project.clj
@@ -5,7 +5,7 @@
         :url "https://github.com/KeepSafe/measure"}
   :license {:name "Apache License, Version 2.0"
             :url "http://www.apache.org/licenses/LICENSE-2.0.html"}
-  :dependencies [[org.clojure/clojure "1.5.1"]
+  :dependencies [[org.clojure/clojure "1.6.0"]
                  [io.dropwizard.metrics/metrics-core "3.1.0"]
                  [io.dropwizard.metrics/metrics-graphite "3.1.0"]]


Increment version number

Increment version number

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject nightcode "1.0.1-SNAPSHOT"
+(defproject nightcode "1.0.1"
   :description "An IDE for Clojure and Java"
   :url "https://github.com/oakes/Nightcode"
   :license {:name "Public Domain"


Upgrade all artifact/plugins

Upgrade all artifact/plugins

--- project.clj
+++ project.clj
@@ -7,26 +7,26 @@
   :min-lein-version "2.6.1"

   :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
-                 [org.clojure/clojurescript "1.9.36" :scope "provided"]
-                 [org.clojure/core.async "0.2.374"]
-                 [reagent "0.5.1"]
-                 [reagent-forms "0.5.24"]
-                 [reagent-utils "0.1.8"]
-                 [re-frame "0.7.0"]
+                 [org.clojure/clojurescript "1.9.456" :scope "provided"]
+                 [org.clojure/core.async "0.2.395"]
+                 [reagent "0.6.0"]
+                 [reagent-forms "0.5.28"]
+                 [reagent-utils "0.2.0"]
+                 [re-frame "0.9.1"]
                  [secretary "1.2.3"]
-                 [prone "1.1.1"]
-                 [com.taoensso/timbre "4.3.1"]
-                 [figwheel-sidecar "0.5.3-2"]
+                 [prone "1.1.4"]
+                 [com.taoensso/timbre "4.8.0"]
+                 [figwheel-sidecar "0.5.8"]
                  [com.cemerick/piggieback "0.2.1"]
                  [garden "1.3.2"]
                  [jamesmacaulay/cljs-promises "0.1.0"]
-                 [prismatic/schema "1.1.1"]]
+                 [prismatic/schema "1.1.3"]]

-  :plugins [[lein-cljsbuild "1.1.3" :exclusions [org.apache.commons/commons-compress]]
-            [lein-figwheel "0.5.3-2"]
-            [lein-garden "0.2.6"]
+  :plugins [[lein-cljsbuild "1.1.5" :exclusions [org.apache.commons/commons-compress]]
+            [lein-figwheel "0.5.8"]
+            [lein-garden "0.3.0"]
             [lein-node-webkit-build "0.1.8" :exclusions [com.fasterxml.jackson.core/jackson-annotations]]
-            [lein-doo "0.1.6"]]
+            [lein-doo "0.1.7"]]

   :doo {:build "test"}

@@ -90,6 +90,7 @@
                 :source-paths ["src/cljs" "src/node" "env/prod/cljs"]
                 :compiler {:main "clchess.prod"
                            :output-to "resources/public/js/compiled/clchess.js"
+                           :output-dir "resources/public/js/compiled/out-prod"
                            :optimizations :advanced
                            :pretty-print false}}]}


updates client deps

updates client deps

--- project.clj
+++ project.clj
@@ -15,7 +15,7 @@
                  [bk/ring-gzip "0.3.0"]
                  [ring-basic-authentication "1.1.0"]
                  [base64-clj "0.1.1"]
-                 [camel-snake-kebab "0.4.1"]
+                 [camel-snake-kebab "0.4.2"]
                  [com.cemerick/url "0.1.1" :exclusions [com.cemerick/clojurescript.test]]
                  [ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]]
                  [org.slf4j/log4j-over-slf4j "1.7.30"]


Set version to 0.5.0

Set version to 0.5.0

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject buddy/buddy-auth "0.5.0-SNAPSHOT"
+(defproject buddy/buddy-auth "0.5.0"
   :description "Authentication and Authorization facilities for ring based web applications."
   :url "https://github.com/funcool/buddy-auth"
   :license {:name "Apache 2.0"


bumped up version

bumped up version

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject selmer "1.11.3"
+(defproject selmer "1.11.4"
   :description "Django style templates for Clojure"
   :url "https://github.com/yogthos/Selmer"
   :license {:name "Eclipse Public License"