Работа над обобщением создания простых форм по id и диалогов для них

--- src-cljs/ixinfestor/omut.cljs
+++ src-cljs/ixinfestor/omut.cljs
@@ -248,19 +248,19 @@
                       :className (str "form-control " class+)}))))

 (defn input-form-group  [app owner {:keys [label
-                                           class+
                                            type
                                            spec-input]
                                     :or {label "Метка"
-                                         class+ ""
                                          spec-input {}}}]
   (reify
     om/IRender
     (render [this]
       (dom/div #js {:className (str "form-group " (input-css-string-has? app))}
-               (dom/label #js {:className (str "control-label " class+)} label)
-               (om/build input app {:opts spec-input})
-               (om/build helper-p app {}) ))))
+               (dom/label #js {:className "control-label col-sm-4 col-md-4 col-lg-4"} label)
+               (dom/div #js {:className "col-sm-8 col-md-8 col-lg-8"}
+                        (om/build input app {:opts spec-input})
+                        (om/build helper-p app {})
+                        )))))

@@ -322,19 +322,18 @@
                          }))))

 (defn textarea-form-group  [app owner {:keys [label
-                                              class+
                                               type
                                               spec-textarea]
                                        :or {label "Метка"
-                                            class+ ""
                                             spec-textarea {}}}]
   (reify
     om/IRender
     (render [this]
       (dom/div #js {:className (str "form-group " (input-css-string-has? app))}
-               (dom/label #js {:className (str "control-label " class+)} label)
-               (om/build textarea app {:opts spec-textarea})
-               (om/build helper-p app {}) ))))
+               (dom/label #js {:className "control-label col-sm-4 col-md-4 col-lg-4"} label)
+               (dom/div #js {:className "col-sm-8 col-md-8 col-lg-8"}
+                        (om/build textarea app {:opts spec-textarea})
+                        (om/build helper-p app {}) )))))

@@ -376,18 +375,16 @@

 (defn toggle-button-form-group [app owner {:keys [label
-                                                  class+
                                                   type
                                                   spec-toggle-button]
                                            :or {label "Метка"
-                                                class+ ""
                                                 spec-toggle-button {}}}]
   (reify
     om/IRender
     (render [this]
       (dom/div #js {:className (str "form-group " (input-css-string-has? app))}
-               (dom/label #js {:className (str "control-label " class+)} (str label " "))
-               (dom/div {:className "input-group"}
+               (dom/label #js {:className "control-label col-sm-4 col-md-4 col-lg-4"} label)
+               (dom/div #js {:className "col-sm-8 col-md-8 col-lg-8"}
                         (om/build toggle-button app {:opts spec-toggle-button})
                         (om/build helper-p app {}) )))))

@@ -834,21 +831,29 @@

-(def thumbinal-edit-form-app-init
-  {:id nil
-   :top_description input-app-init
-   :description textarea-app-init
-   :galleria toggle-button-app-init
-   })
-
-(defn thumbnails-edit-form [app owner {:keys [chan-load-for-id
-                                              uri
-                                              chan-load-row
-                                              chan-save
-                                              uri-save
-                                              post-save-fn
-                                              ]
-                                       :or {}}]
+
+(def edit-form-for-id-app-init
+  {:id nil})
+
+(defn edit-form-for-id [app owner {:keys [chan-load-for-id
+                                          uri
+                                          chan-load-row
+                                          chan-save
+                                          uri-save
+                                          post-save-fn
+                                          form-body
+                                          fill-app-fn
+                                          app-to-row-fn
+                                          ]
+                                   :or {fill-app-fn
+                                        (fn [row]
+                                          (println "Функция (fill-app-fn) формирования зароса не определена!"
+                                                   " Пришел ответ вида: " row))
+                                        app-to-row-fn
+                                        (fn []
+                                          (println "Функция (app-to-row-fn) формирования зароса не определена!")
+                                          {})
+                                        }}]
   (reify
     om/IInitState
     (init-state [_]
@@ -877,19 +882,9 @@
         (when chan-init-row
           (go
             (while true
-              (let [{:keys [id
-                            top_description
-                            description
-                            galleria]} (<! chan-init-row)]
-                (om/transact! app
-                              (fn [app]
-                                (-> app
-                                    ;; Заполнение формы
-                                    (assoc :id id)
-                                    (assoc-in [:top_description :value] top_description)
-                                    (assoc-in [:description :value] description)
-                                    (assoc-in [:galleria :value] galleria))))
-                ))))
+              (let [row (<! chan-init-row)]
+                (om/update! app :id (:id row))
+                (fill-app-fn row)))))

         (when chan-save
           (go
@@ -900,11 +895,7 @@
                   ;; если указан то сохранять в сеть
                   (ixnet/get-data
                    uri-save
-                   (-> {}
-                       (assoc :id              (@app :id))
-                       (assoc :top_description (get-in @app [:top_description :value]))
-                       (assoc :description     (get-in @app [:description :value]))
-                       (assoc :galleria        (get-in @app [:galleria :value])))
+                   (assoc (app-to-row-fn) :id (@app :id))
                    (fn [result]
                      (when post-save-fn (post-save-fn result))))
                   ;; иначе альтернитиваная функция
@@ -917,29 +908,23 @@
        #js {:className "row"}
        (dom/form
         #js {:className "form-horizontal col-sm-12 col-md-12 col-lg-12"}
-        (dom/fieldset
-         nil
-         (dom/legend nil "Основные данные")
-
-         (om/build input-form-group (get-in app [:top_description])
-                   {:opts {:label "Наименование"
-                           :spec-input {:onChange-valid?-fn
-                                        input-vldfn-not-empty}}})
-
-         (om/build toggle-button-form-group (get-in app [:galleria])
-                   {:opts{:label "Отображать в галерее"}})
-
-         (om/build textarea-form-group (get-in app [:description])
-                   {:opts {:label "Описание"}})
-         ))))))
-
-
-
-(def thumbnails-modal-edit-form-app-init
-  (merge modal-app-init thumbinal-edit-form-app-init))
-
-(defn thumbnails-modal-edit-form [app _ {:keys [opts-thumbnails-edit-form]
-                                         :or {}}]
+        (if form-body
+          form-body
+          (dom/h1 nil "Элементы формы еще не определены")))))))
+
+
+(def modal-edit-form-for-id--YN--app-init
+  (merge modal-app-init edit-form-for-id-app-init))
+
+(defn modal-edit-form-for-id--YN- [app _ {:keys [edit-form-for-id]
+                                          :or {edit-form-for-id
+                                               (fn [_ _]
+                                                 (reify
+                                                   om/IRender
+                                                   (render [_]
+                                                     (dom/h1 nil "Форма диалога еще не указана"))))
+                                               }
+                                          :as opts}]
   (reify
     om/IInitState
     (init-state [_]
@@ -947,15 +932,15 @@
     om/IRenderState
     (render-state [_ {:keys[chan-save]}]
       (om/build modal app
-                {:opts {:modal-size :sm
+                {:opts {;;:modal-size :lg
                         :body
-                        (om/build thumbnails-edit-form app
-                                  {:opts (assoc opts-thumbnails-edit-form
+                        (om/build edit-form-for-id app
+                                  {:opts (assoc opts
                                                 :chan-save chan-save
                                                 :post-save-fn
                                                 (fn [r]
                                                   (modal-hide app)
-                                                  (when-let [post-save-fn-2 (:post-save-fn opts-thumbnails-edit-form)]
+                                                  (when-let [post-save-fn-2 (:post-save-fn opts)]
                                                     (post-save-fn-2 r))))})
                         :footer
                         (dom/div nil
@@ -973,6 +958,81 @@

+
+
+
+
+
+
+
+
+(def thumbinal-edit-form-app-init
+  (merge edit-form-for-id-app-init
+         {:top_description input-app-init
+          :description textarea-app-init
+          :galleria toggle-button-app-init
+          }))
+
+
+(defn thumbnails-edit-form [app owner {:keys [chan-load-for-id
+                                              uri
+                                              chan-load-row
+                                              chan-save
+                                              uri-save
+                                              post-save-fn
+                                              ]
+                                       :as opts}]
+  (reify
+    om/IRender
+    (render [_]
+      (om/build
+       edit-form-for-id app
+       {:opts
+        (merge opts {:fill-app-fn
+                     (fn [{:keys [top_description
+                                  description
+                                  galleria]}]
+                       (om/transact!
+                        app
+                        (fn [app]
+                          (-> app
+                              ;; Заполнение формы
+                              (assoc-in [:top_description :value] top_description)
+                              (assoc-in [:description :value] description)
+                              (assoc-in [:galleria :value] galleria)))))
+                     :app-to-row-fn
+                     (fn []
+                       {:id              (get @app :id)
+                        :top_description (get-in @app [:top_description :value])
+                        :description     (get-in @app [:description :value])
+                        :galleria        (get-in @app [:galleria :value])})
+                     :form-body
+                     (dom/fieldset
+                      nil
+                      (dom/legend nil "Основные данные")
+
+                      (om/build input-form-group (get-in app [:top_description])
+                                {:opts {:label "Наименование"}})
+
+                      (om/build toggle-button-form-group (get-in app [:galleria])
+                                {:opts{:label "Отображать в галерее"}})
+
+                      (om/build textarea-form-group (get-in app [:description])
+                                {:opts {:label "Описание"}})
+                      )
+                     })
+        }))))
+
+
+(def thumbnails-modal-edit-form-app-init
+  (merge modal-edit-form-for-id--YN--app-init thumbinal-edit-form-app-init))
+
+(defn thumbnails-modal-edit-form [app _ opts]
+  (reify
+    om/IRender
+    (render [_]
+      (om/build modal-edit-form-for-id--YN- app
+                {:opts (assoc opts :edit-form-for-id thumbnails-edit-form)}))))

 (def thumbnails-view-app-init
@@ -1019,13 +1079,12 @@
                  (:list app)))

                (om/build thumbnails-modal-edit-form (:modal app)
-                         {:opts {:opts-thumbnails-edit-form
-                                 {:chan-load-for-id chan-thumbnails-modal-edit-form-open-for-id
-                                  :uri      "/files/find/transit"
-                                  :uri-save "/files/edit/transit"
-                                  :post-save-fn #(do
+                         {:opts {:chan-load-for-id chan-thumbnails-modal-edit-form-open-for-id
+                                 :uri      "/files/find/transit"
+                                 :uri-save "/files/edit/transit"
+                                 :post-save-fn #(do
                                                   (when chan-update
                                                     (put! chan-update (:last-params @app)))
-                                                  1)}}})
+                                                  1)}})

                ))))


* src/clj/cljs/compiler.clj: remove old code

--- src/clj/cljs/compiler.clj
+++ src/clj/cljs/compiler.clj
@@ -550,8 +550,6 @@
     (doseq [fld fields]
       (println (str "this." fld " = " fld ";")))
     (println (str "if(arguments.length>" (- (count fields) 2) "){"))
-    ;; (println (str "this.__meta = arguments[" (count fields) "];"))
-    ;; (println (str "this.__extmap = arguments[" (inc (count fields)) "];"))
     (println (str "this.__meta = __meta;"))
     (println (str "this.__extmap = __extmap;"))
     (println "} else {")


modfiy prop unemployement,unemployement services


cosmetic changes

cosmetic changes

--- dada-demo/src/main/clojure/org/dada/demo/whales.clj
+++ dada-demo/src/main/clojure/org/dada/demo/whales.clj
@@ -150,8 +150,7 @@

 (def num-whales 1000)

-(def some-whales
-     (doall (pmap (fn [id] (whale id)) (range num-whales))))
+(def some-whales (doall (pmap (fn [id] (whale id)) (range num-whales))))

 (def some-whales2
      (let [#^Creator creator (.getCreator whale-metadata)]
@@ -169,7 +168,7 @@
 	 ))
        ))

-(time (doall (pmap (fn [whale] (insert whales-model whale)) some-whales)))
+(do (time (doall (pmap (fn [whale] (insert whales-model whale)) some-whales))) nil)

 (println "LOADED")

@@ -255,5 +254,5 @@

 (? [(split :type)] all-whales)
 (? [(split :ocean nil [(ccount)])] all-whales)
-(? [(pivot :ocean oceans :count(*))(split :ocean nil [(ccount)])] all-whales)
-;; (? [(union "count/type/ocean")(split :type nil [(pivot :ocean oceans (keyword (count-value-key nil)))(ccount)(split :ocean )])] all-whales)+(? [(pivot :ocean oceans (keyword (count-value-key nil)))(ccount)(split :ocean)] all-whales)
+(? [(union "count/type/ocean")(split :type nil [(pivot :ocean oceans (keyword (count-value-key nil)))(ccount)(split :ocean )])] all-whales)


Etusivun route

Etusivun route

--- mtg-pairings-server/src/mtg_pairings_server/server.clj
+++ mtg-pairings-server/src/mtg_pairings_server/server.clj
@@ -43,7 +43,7 @@
   (let [tournament-routes (tournament-api/routes db)]
     (c/routes
       (r/resources "/")
-      (c/GET "/" [] "Hello World")
+      (c/GET "/" [] (response (slurp "resources/public/index.html")))
       (c/POST "/login" [:as req]
         (login req))
       (c/POST "/logout" []


unused security group

unused security group

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -518,14 +518,6 @@
                    })

-             (cluster-security-group "dns" {}
-                                     {:port 53
-                                      :protocol "udp"
-                                      :cidr_blocks [vpc/vpc-cidr-block]}
-                                     {:port 53
-                                      :protocol "tcp"
-                                      :cidr_blocks [vpc/vpc-cidr-block]})
-
              (local-deploy-scripts {:cluster-name cluster-name
                                     :name-fn cluster-unique
                                     :min-number-of-slaves min-number-of-slaves


OO: Add docstrings

OO: Add docstrings

--- src/hatti/utils/style.cljs
+++ src/hatti/utils/style.cljs
@@ -2,7 +2,9 @@
   (:require [clojure.string :refer [join split]]
             [hatti.ona.forms :as form-utils]))

-(def user-customizable-styles #{"color"})
+(def user-customizable-styles
+  "Set of CSS properties that can be modified by a user"
+  #{"color"})

 (def qualitative-palette
   "Saturated qualitative palette from colorbrewer.
@@ -27,6 +29,7 @@
   "#d9d9d9")

 (defn customizable-style?
+  "Check if a user can customize a style"
   [[style-name _]]
   (contains? user-customizable-styles style-name))

@@ -49,10 +52,12 @@
        (apply merge)))

 (defn- style-map->color-map
+  "Returns only the color property of the style map, with the answer as the key"
   [[answer {:keys [color]}]]
   {answer color})

 (defn group-user-defined-colors-by-answer
+  "Return a map of answers to their associated colors"
   [field]
   (->> field
        group-user-defined-styles-by-answer
@@ -78,6 +83,9 @@
     (form-utils/select-all? field) (repeat "#f30")))

 (defn answer->color
+  "Given a field and set of answers, return a mapping of answer to color
+   defaulting to an inbuilt palette if the field is not a select-one or
+   any of the choices lack an appearance attribute"
   [{:keys [children] :as field} answers]
   (cond
     (and (form-utils/select-one? field)


Store primary bytes as plain byte array.

--- src/vault/data/format.clj
+++ src/vault/data/format.clj
@@ -16,8 +16,7 @@
       PushbackReader
       Reader
       Writer)
-    java.nio.charset.Charset
-    java.nio.ByteBuffer))
+    java.nio.charset.Charset))

 ;; CONSTANTS & CONFIGURATION
@@ -107,10 +106,7 @@
         reader (PushbackReader. (capturing-reader reader copy-writer))
         value (edn/read {:readers tag-readers} reader)]
     (.flush copy-writer)
-    (vector value (-> copy-bytes
-                      .toByteArray
-                      ByteBuffer/wrap
-                      .asReadOnlyBuffer))))
+    (vector value (.toByteArray copy-bytes))))

 (defn- read-secondary-values!


rearrange/simplify code slightly

rearrange/simplify code slightly

--- ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/app/main.clj
+++ ssclj/jar/src/main/clojure/com/sixsq/slipstream/ssclj/app/main.clj
@@ -1,21 +1,22 @@
 (ns com.sixsq.slipstream.ssclj.app.main
   (:gen-class)
   (:require
-    [com.sixsq.slipstream.ssclj.app.server :refer [start stop]]))
+    [com.sixsq.slipstream.ssclj.app.server :as server]))

 (def ^:const default-port 8200)

-(defn- create-shutdown-hook
+(defn- hook
+  "A JVM shutdown hook is just a Thread that runs a function
+   in the 'run' method."
   [stop-fn]
-  (proxy [Thread] [] (run [] (stop stop-fn))))
+  (proxy [Thread] [] (run [] (server/stop stop-fn))))

 (defn register-shutdown-hook
   "Registers a shutdown hook in the JVM to shutdown the application
    container cleanly."
   [stop-fn]
-  (let [hook (create-shutdown-hook stop-fn)]
-    (.. (Runtime/getRuntime)
-        (addShutdownHook hook))))
+  (.. (Runtime/getRuntime)
+      (addShutdownHook (hook stop-fn))))

 (defn parse-port
   "Parses the given string into an port value (int).  If the input
@@ -33,5 +34,5 @@
   [& [port]]
   (-> (parse-port port)
       (or default-port)
-      (start)
+      (server/start)
       (register-shutdown-hook)))


Bump JSLint version to the 0.6.5

Bump JSLint version to the 0.6.5

--- src/lein_jslint/plugin.clj
+++ src/lein_jslint/plugin.clj
@@ -9,7 +9,7 @@
 ; Internal API: Configuration

 (def ^:private DEF_JSLINT_DEP "jslint")
-(def ^:private DEF_JSLINT_VER ">=0.6.2")
+(def ^:private DEF_JSLINT_VER ">=0.6.5")

 ; Internal API: Middlewares


Tweaks to status messages

Tweaks to status messages

--- src/leiningen/amp/impl.clj
+++ src/leiningen/amp/impl.clj
@@ -177,7 +177,7 @@
     ; Now zip the AMP
     (zip-directory! tgt-amp-file tgt-amp)

-    (println "Created module" module-id "version" module-version "in" (str tgt-amp-file))))
+    (println "Created AMP" module-id "version" module-version "in" (str tgt-amp-file))))

 (defn deploy-amp!


Just a minor cosmetic change

Just a minor cosmetic change

--- src/leiningen/amp/impl.clj
+++ src/leiningen/amp/impl.clj
@@ -69,16 +69,12 @@

 (defn- replace-parameters
   [project value]
-  (s/replace
-    (s/replace
-      (s/replace
-        (s/replace
-          value
-          "${project.name}" (str (if (nil? (:group project)) "" (str (:group project) "."))
-                                 (:name project)))
-        "${project.title}" (:title project))
-      "${project.version}" (fix-snapshot-version (:version project)))
-    "${project.description}" (:description project)))
+  (-> value
+      (s/replace "${project.name}"        (str (if (nil? (:group project)) "" (str (:group project) "."))
+                                               (:name project)))
+      (s/replace "${project.title}"       (:title project))
+      (s/replace "${project.version}"     (fix-snapshot-version (:version project)))
+      (s/replace "${project.description}" (:description project))))

 (defn- read-module-properties
   [project module-properties-file]
@@ -188,4 +184,3 @@
 (defn deploy-amp!
   [project args]
   (main/abort "AMP deployment is not yet implemented. Sorry!"))
-


Releasing lein-template

Releasing lein-template

--- 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.6.6"
+(defproject modular/lein-template "0.6.7"
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}


whitespace

whitespace

--- src/babel/espanol/lexicon.clj
+++ src/babel/espanol/lexicon.clj
@@ -348,7 +348,7 @@
              :synsem {:cat :verb
                       :sem {:pred :think}}}

-    "pintar" {:synsem {:cat :verb
+   "pintar" {:synsem {:cat :verb
                       :sem {:pred :paint}}}

    "quedarse" (let [subject-semantics (ref {:animate true})


still good

still good

--- src/bluebell/utils/symset.clj
+++ src/bluebell/utils/symset.clj
@@ -47,9 +47,6 @@
 (defn initialize-element [set-registry element]
   (update-in set-registry [:element-map element] #(or % empty-element-entry)))

-(defn initialize-set [set-registry set-id]
-  (update-in set-registry [:set-map set-id] #(or % empty-set-entry)))
-
 (defn register-membership [set-registry element set-id]
   (-> set-registry
       (update-in [:element-map element :set-ids] #(conj % set-id))))
@@ -75,6 +72,7 @@
    clojure.set/union
    #{}
    (:generators set-registry)))
+

 (declare subset-of)
@@ -97,6 +95,16 @@
                (clojure.set/union (rest unseen-sets) supersets-of-first)
                seen-sets)))))))

+(declare all-sets)
+
+(defn initialize-set [set-registry set-id]
+  (let [new-registry (update-in set-registry [:set-map set-id] #(or % empty-set-entry))]
+    (if (= new-registry set-registry)
+      set-registry
+      (generate-supersets new-registry
+                          (all-sets set-registry)
+                          #{set-id}))))
+
 (defn add-superset-generator-sub [set-registry key generator]
   (update set-registry :generators #(assoc % key generator)))


using fnil and decreasing only when > 0

using fnil and decreasing only when > 0

--- src/celestial/persistency.clj
+++ src/celestial/persistency.clj
@@ -118,7 +118,7 @@

 (defn quota-change [user spec amount]
   (when (quota-exists? user)
-    (update-quota (update-in (get-quota user) [:quotas (figure-virt spec) :used] + amount))))
+    (update-quota (update-in (get-quota user) [:quotas (figure-virt spec) :used] (fnil + 0) amount))))

 (defn increase-use
   "increases user quota use"
@@ -129,4 +129,5 @@
 (defn decrease-use
   "decreases user usage"
   [user spec]
-  (quota-change user spec -1))
+  (when (> (get-in (get-quota user) [:quotas (figure-virt spec) :used]) 0)
+    (quota-change user spec -1)))


implement Itinerant Protesters

implement Itinerant Protesters

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -261,6 +261,19 @@
    "Inside Job"
    {:prompt "Choose a server" :choices (req servers) :effect (effect (run target))}

+   "Itinerant Protesters"
+   {:effect (req (lose state :corp :max-hand-size (:bad-publicity corp))
+                 (add-watch state :itin
+                   (fn [k ref old new]
+                     (let [bpnew (get-in new [:corp :bad-publicity])
+                           bpold (get-in old [:corp :bad-publicity])]
+                       (when (> bpnew bpold)
+                         (lose state :corp :max-hand-size (- bpnew bpold)))
+                       (when (< bpnew bpold)
+                         (gain state :corp :max-hand-size (- bpold bpnew)))))))
+    :leave-play (req (remove-watch state :itin)
+                     (gain state :corp :max-hand-size (:bad-publicity corp)))}
+
    "Knifed"
    {:prompt "Choose a server" :choices (req servers) :effect (effect (run target))}


partial Immolation Script

partial Immolation Script

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -177,6 +177,9 @@
     :trash-effect {:req (req (#{:meat :net} target))
                    :effect (effect (draw :runner 3)) :msg "draw 3 cards"}}

+   "Immolation Script"
+   {:effect (effect (run :archives))}
+
    "Indexing"
    {:effect (effect (run :rd {:replace-access
                               {:msg "rearrange the top 5 cards of R&D"


Add algebra/point-to-line-dist fn

Add algebra/point-to-line-dist fn

--- src/clj/genartlib/algebra.clj
+++ src/clj/genartlib/algebra.clj
@@ -1,7 +1,7 @@
 (ns genartlib.algebra
   (:require
     [genartlib.util :refer [between?]]
-    [quil.core :refer [HALF-PI PI TWO-PI atan2 cos sin dist]]))
+    [quil.core :refer [PI atan2 cos sin dist sqrt abs]]))

 (defn avg
   "Returns the average of the arguments"
@@ -109,9 +109,10 @@
   [slope x1 y1]
   (- y1 (* slope x1)))

-(defn angle [x1 y1 x2 y2]
+(defn angle
   "Returns the angle between two points in radians. Values are between
    0 and 2 * PI."
+  [x1 y1 x2 y2]
   (let [a (atan2 (- y2 y1) (- x2 x1))]
     (if (neg? a)
       (+ a (* PI 2.0))
@@ -134,3 +135,17 @@
   "Returns the euclidean distance between two points"
   [[x1 y1] [x2 y2]]
   (dist x1 y1 x2 y2))
+
+(defn point-to-line-dist
+  "[x1 y1] and [x2 y2] define the line, [x0 y0] defines
+   the point"
+  [[x1 y1] [x2 y2] [x0 y0]]
+  (let [denom (sqrt (+ (Math/pow (- y2 y1) 2)
+                       (Math/pow (- x2 x1) 2)))]
+    (if (zero? denom)
+      0
+      (/ (abs (+ (*  1 (* (- y2 y1) x0))
+                 (* -1 (* (- x2 x1) y0))
+                 (*  1 (* x2 y1))
+                 (* -1 (* y2 x1))))
+         denom))))


changing source paths should bust the cache

--- src/clj/shadow/cljs/build.clj
+++ src/clj/shadow/cljs/build.clj
@@ -739,20 +739,21 @@
         ;; compile again .. since we were compiled today the min-age is today
         ;; which is larger than v2 release date thereby using cache if only checking one timestamp

-        (when (= age-of-deps (:age-of-deps cache-data))
-          (when (= (cljs-util/clojurescript-version) (:version cache-data))
-            (log-progress logger (format "[CACHE] read: \"%s\"" name))
-
-            ;; restore analysis data
-            (let [ana-data (:analyzer cache-data)]
-
-              (swap! env/*compiler* assoc-in [::ana/namespaces (:ns cache-data)] ana-data)
-              (util/load-macros ana-data))
-
-            ;; merge resource data & return it
-            (-> (merge rc cache-data)
-                (dissoc :analyzer :version)
-                (assoc :output (slurp cache-js)))))))))
+        (when (and (= (cljs-util/clojurescript-version) (:version cache-data))
+                   (= (:source-path cache-data) (:source-path rc))
+                   (= age-of-deps (:age-of-deps cache-data)))
+          (log-progress logger (format "[CACHE] read: \"%s\"" name))
+
+          ;; restore analysis data
+          (let [ana-data (:analyzer cache-data)]
+
+            (swap! env/*compiler* assoc-in [::ana/namespaces (:ns cache-data)] ana-data)
+            (util/load-macros ana-data))
+
+          ;; merge resource data & return it
+          (-> (merge rc cache-data)
+              (dissoc :analyzer :version)
+              (assoc :output (slurp cache-js))))))))

 (defn write-cached-cljs-resource
   [{:keys [logger cache-dir cljs-runtime-path] :as state} {:keys [ns name js-name] :as rc}]


Format end game screen

Format end game screen

--- src/cljc/robinson/render.cljc
+++ src/cljc/robinson/render.cljc
@@ -1547,13 +1547,13 @@
                                  (<= will-to-live 0)   "just giving up on life"
                                  :else                 "mysterious causes"))]
           ;; Title
-          (put-string (state :screen) 10 1 (format "%s: %s." player-name madlib))
-          (put-string (state :screen) 18 2 (format "Survived for %d %s. (%d turns)" days-survived (if (> 1 days-survived) "days" "day") turns-survived))
-          (put-string (state :screen) 18 3 (format "Died from %s." cause-of-death))
-          (put-string (state :screen) 10 4 (format "Points: %s." points))
-          (put-string (state :screen) 10 5 "Inventory:")
+          (put-string (state :screen) 10 1 (format "%s: %s" player-name madlib))
+          (put-string (state :screen) 10 3 (format "Survived for %d %s. (%d turns)" days-survived (if (> 1 days-survived) "days" "day") turns-survived))
+          (put-string (state :screen) 10 4 (format "Died from %s" cause-of-death))
+          (put-string (state :screen) 10 6 (format "Points: %s." points))
+          (put-string (state :screen) 10 8 "Inventory:")
           (doall (map-indexed
-            (fn [idx item] (put-string (state :screen) 18 (+ idx 6) (item :name)))
+            (fn [idx item] (put-string (state :screen) 20 (+ idx 8) (item :name)))
             (-> state :world :player :inventory)))
           (put-chars (state :screen) (markup->chars 10 22 "Play again? [<color fg=\"highlight\">y</color>/<color fg=\"highlight\">n</color>]")))
       :game-over-rescued


Fixed server path

Fixed server path

--- src/cljs/bookmarx/common.cljs
+++ src/cljs/bookmarx/common.cljs
@@ -29,8 +29,9 @@

 (defn server-path "Create a url to the service with the path from the environment."
   [& args]
-  (let [{:keys [:protocol :host :port :path]} (url (-> js/window .-location .-href))]
-    (str/join (concat [protocol "://" host (when port (str ":" port)) (when-not (= path "/"))] args))))
+  (let [{:keys [:protocol :host :port]} (url (-> js/window .-location .-href))]
+    (str protocol "://" host (if (> port 0) (str ":" port) "")
+         (str/join (cons (get-cookie :prefix) args)))))

 (defn sort-folder-children "Sort the children of a folder by a sort function."
   [folder sort-fn]


Big ol' refactor of go-loop in app component

--- src/cljs/iframe_app/core.cljs
+++ src/cljs/iframe_app/core.cljs
@@ -95,33 +95,56 @@
       (conj cleaned-conditions new-condition)
       cleaned-conditions)))

+(defn master-field-and-values-selected? [{:keys [master-field field-value]}]
+  (every? (comp not nil?) [master-field field-value]))
+
+
+
+:slave-fields (let [{:keys [master-field field-value] :as selections} (:selections @app-state)
+                    conditions (:conditions @app-state)
+                    master-and-value-selected? (every? (comp not nil?) [master-field field-value])]
+                (when master-and-value-selected?
+                  (let [updated-conditions (update-conditions conditions selections)]
+                    (om/update! app-state [:conditions] updated-conditions))))
+
+(defn reset-irrelevant-selections
+  "When someone selects a master field (e.g.) we want to deselect the value
+   and slave fields that were selected (because they only applied to that
+   field. Likewise when someone selects a new value."
+  [selections selection-to-update]
+  (case selection-to-update
+    :master-field (assoc selections :field-value nil
+                                    :slave-fields #{})
+    :field-value (assoc selections :slave-fields #{})
+    selections))

 (defcomponent app [app-state owner]
+  (init-state [_]
+    {:selections (:selections app-state)})
   (will-mount [_]
-    (let [{:keys [pick-channel]} (om/get-shared owner)]
-      (go-loop []
-        ; handle updates from the three picker components
-        (let [{:keys [selection-to-update new-value]} (<! pick-channel)]
-          (om/update! app-state [:selections selection-to-update] new-value)
-
-          (case selection-to-update
-            :master-field (put! pick-channel {:selection-to-update :field-value
-                                              :new-value           nil})
-            :field-value (put! pick-channel {:selection-to-update :slave-fields
-                                             :new-value           #{}})
-            :slave-fields (let [{:keys [master-field field-value] :as selections} (:selections @app-state)
-                                conditions (:conditions @app-state)
-                                master-and-value-selected? (every? (comp not nil?) [master-field field-value])]
-                            (when master-and-value-selected?
-                              (let [updated-conditions (update-conditions conditions selections)]
-                                (om/update! app-state [:conditions] updated-conditions))))))
-        (recur))))
+    (go-loop []
+      ; handle updates from the three picker components
+      (let [pick-channel (om/get-shared owner :pick-channel)
+            {:keys [selection-to-update new-value]} (<! pick-channel)
+            new-selections (-> (om/get-state owner :selections)
+                               (assoc selection-to-update new-value)
+                               (reset-irrelevant-selections selection-to-update))]
+        (om/update! app-state :selections new-selections)
+        (om/set-state! owner :selections new-selections)
+
+        (when (= selection-to-update :slave-fields)
+          (let [updated-conditions (update-conditions (:conditions app-state) new-selections)]
+            (om/update! app-state [:conditions] updated-conditions))))
+
+      (recur)))
   (render-state [_ {:keys [selected-field-id slave-fields-picker-chan
                            selected-value]}]
     (html
       [:section.ember-view.apps.app-554.apps_nav_bar.app_pane.main_panes
        [:header
         [:h3 "Conditional Fields"]]
+
+

        [:div.cfa_navbar
         {:data-main 1}
@@ -174,10 +197,13 @@
               [:td.selected
                [:div.values
                 [:div.separator "Available"]
-                (om/build slave-fields-picker (:selections app-state))]]]]]]]]
+                (om/build slave-fields-picker (:selections app-state))]]]]]]]
+         ]

         [:footer
          [:div.pane
+          [:div
+           (prn-str (clj->js (:selections app-state)))]
           [:button.delete.text-error.deleteAll
            {:style {:display :none}}
            "Delete all conditional rules for this form"]
@@ -194,7 +220,7 @@
     app
     app-state
     {:target (. js/document (getElementById "app"))
-     :shared {:pick-channel (chan)
+     :shared {:pick-channel  (chan)
               :ticket-fields dummy-ticket-fields}}))


navigation with dropdown

navigation with dropdown

--- src/clojento/views/common.clj
+++ src/clojento/views/common.clj
@@ -34,8 +34,11 @@
 			[:ul.left
 				[:li.divider]
 				[:li [:a {:href (url-for clojento.views.products/index)} "Products"]]
-				[:li [:a {:href (url-for clojento.views.admin/users_index)} "Users"]]
-				[:li [:a {:href (url-for clojento.views.admin/roles_index)} "Roles"]]
+				[:li.has-dropdown
+					[:a "Admin"]
+					[:ul.dropdown
+						[:li [:a {:href (url-for clojento.views.admin/users_index)} "Users"]]
+						[:li [:a {:href (url-for clojento.views.admin/roles_index)} "Roles"]]]]
 			]
 		]
 	])


Fix the Clojure integration

Fix the Clojure integration

--- src/clojure/fault/service.clj
+++ src/clojure/fault/service.clj
@@ -53,31 +53,53 @@
   (valAt [this key] (.valAt this key nil))
   (valAt [_ key default]
     (case key
-      :errors (.getMetricCountForTimePeriod metrics Metric/ERROR seconds-tracked)
-      :successes (.getMetricCountForTimePeriod metrics Metric/SUCCESS seconds-tracked)
-      :timeouts (.getMetricCountForTimePeriod metrics Metric/TIMEOUT seconds-tracked)
+      :errors (.getMetricCountForTimePeriod metrics
+                                            Metric/ERROR
+                                            seconds-tracked
+                                            TimeUnit/SECONDS)
+      :successes (.getMetricCountForTimePeriod metrics
+                                               Metric/SUCCESS
+                                               seconds-tracked
+                                               TimeUnit/SECONDS)
+      :timeouts (.getMetricCountForTimePeriod metrics
+                                              Metric/TIMEOUT
+                                              seconds-tracked
+                                              TimeUnit/SECONDS)
       :circuit-open (.getMetricCountForTimePeriod metrics
-                                             Metric/CIRCUIT_OPEN
-                                             seconds-tracked)
+                                                  Metric/CIRCUIT_OPEN
+                                                  seconds-tracked
+                                                  TimeUnit/SECONDS)
       :queue-full (.getMetricCountForTimePeriod metrics
-                                           Metric/QUEUE_FULL
-                                           seconds-tracked)
+                                                Metric/QUEUE_FULL
+                                                seconds-tracked
+                                                TimeUnit/SECONDS)
       :max-concurrency-level-exceeded (.getMetricCountForTimePeriod
                                         metrics
                                         Metric/MAX_CONCURRENCY_LEVEL_EXCEEDED
-                                        seconds-tracked)
+                                        seconds-tracked
+                                        TimeUnit/SECONDS)
       default))
   Object
   (toString [this]
-    (str {:errors (.getMetricCountForTimePeriod metrics Metric/ERROR seconds-tracked)
-          :successes (.getMetricCountForTimePeriod metrics Metric/SUCCESS seconds-tracked)
-          :timeouts (.getMetricCountForTimePeriod metrics Metric/TIMEOUT seconds-tracked)
+    (str {:errors (.getMetricCountForTimePeriod metrics
+                                                Metric/ERROR
+                                                seconds-tracked
+                                                TimeUnit/SECONDS)
+          :successes (.getMetricCountForTimePeriod metrics Metric/SUCCESS
+                                                   seconds-tracked
+                                                   TimeUnit/SECONDS)
+          :timeouts (.getMetricCountForTimePeriod metrics
+                                                  Metric/TIMEOUT
+                                                  seconds-tracked
+                                                  TimeUnit/SECONDS)
           :circuit-open (.getMetricCountForTimePeriod metrics
-                                                 Metric/CIRCUIT_OPEN
-                                                 seconds-tracked)
+                                                      Metric/CIRCUIT_OPEN
+                                                      seconds-tracked
+                                                      TimeUnit/SECONDS)
           :queue-full (.getMetricCountForTimePeriod metrics
-                                               Metric/QUEUE_FULL
-                                               seconds-tracked)
+                                                    Metric/QUEUE_FULL
+                                                    seconds-tracked
+                                                    TimeUnit/SECONDS)
           :max-concurrency-level-exceeded (.getMetricCountForTimePeriod
                                             metrics
                                             Metric/MAX_CONCURRENCY_LEVEL_EXCEEDED


Remove unnecessary arg

Remove unnecessary arg

--- src/clojure/nightcode/git.clj
+++ src/clojure/nightcode/git.clj
@@ -95,7 +95,7 @@
   (let [cancelled? (atom false)
         exception (atom nil)
         path (promise)
-        d (dialogs/progress-dialog (utils/get-string :cloning-project))]
+        d (dialogs/progress-dialog)]
     (future (try
               (clone! uri f (progress-monitor d cancelled?))
               (s/invoke-later (s/dispose! d))


Fixed small bug in homology sampling if both programs are empty.

--- src/clojush/pushgp/report.clj
+++ src/clojush/pushgp/report.clj
@@ -54,8 +54,10 @@
                 #(let [prog1 (random/lrand-nth instr-programs)
                        prog2 (random/lrand-nth instr-programs)
                        longer-length (max (count prog1) (count prog2))]
-                   (float (/ (levenshtein-distance prog1 prog2)
-                             longer-length))))))
+                   (if (zero? longer-length)
+                     0
+                     (float (/ (levenshtein-distance prog1 prog2)
+                               longer-length)))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; log printing (csv and json)


[#261 #203] Updated documentation on request function (@javahippie)

--- src/org/httpkit/client.clj
+++ src/org/httpkit/client.clj
@@ -99,7 +99,9 @@
 (defn request
   "Issues an async HTTP request and returns a promise object to which the value
   of `(callback {:opts _ :status _ :headers _ :body _})` or
-     `(callback {:opts _ :error _})` will be delivered.
+     `(callback {:opts _ :error _})` will be delivered.
+  The latter will be delivered on client errors only, not on http errors which will be
+  contained in the :status of the first.

   When unspecified, `callback` is the identity


opt for nrepl

opt for nrepl

--- src/otp_api_proxy/core.clj
+++ src/otp_api_proxy/core.clj
@@ -8,20 +8,27 @@
             [ring.middleware.params :refer [wrap-params]]
             [compojure.core :refer [defroutes context ANY]]
             [clojure.data.json :as json]
+            [environ.core :refer [env]] ;; environment variables
             [cheshire.core :as cheshire]
             [cheshire.generate :as cheshire-generate]
             [clj-http.client :as http-client]
             [clojure.walk :as walk]
             [clojure.java.javadoc]
-            [environ.core :refer [env]] ;; environment variables
             [otp-api-proxy.test-data :as test-data]
             [otp-api-proxy.web-service :as ws]
             ))

+(defn parse-int [s]
+ (try (Integer. s)
+   (catch Exception e nil)))
+
+
 (defonce hack-hack-hack-start-nrepl-server
-  (when-not (env :otp-api-proxy-skip-repl)
-    (nrepl-server/start-server :port 4101 :bind "127.0.0.1"
-                             :handler cider-nrepl-handler)))
+  (when (env :otp-api-proxy-nrepl-port)
+    (nrepl-server/start-server
+      :port (parse-int (env :otp-api-proxy-nrepl-port))
+      :bind "127.0.0.1"
+      :handler cider-nrepl-handler)))

 (defn ignore-trailing-slash
   "Modifies the request uri before calling the handler.  Removes a single


play stereo samples with stereo-player

play stereo samples with stereo-player

--- src/overtone/sc/sample.clj
+++ src/overtone/sc/sample.clj
@@ -123,8 +123,10 @@
   [path & args]
   (let [{:keys [path args] :as s} (apply load-sample path args)
         player (fn [& pargs]
-                 (let [id (:id (get @loaded-samples* [path args]))]
-                   (apply mono-player id pargs)))]
+                 (let [{:keys [id n-channels]} (get @loaded-samples* [path args])]
+                   (cond
+                    (= n-channels 1) (apply mono-player id pargs)
+                    (= n-channels 2) (apply stereo-player id pargs))))]
     (callable-map (merge {:player player} s)
                   player)))


Make multiple layers of life with different colors

--- src/petulant_life/main.clj
+++ src/petulant_life/main.clj
@@ -41,16 +41,24 @@

 ;; Running the simulation / graphics.
 (defn run [shader stepper]
-  (loop [board #{[2 0] [2 1] [2 2] [1 2] [0 1]}]
-   (when-not (Display/isCloseRequested)
-     (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
-     (r/draw-rectangles (life->screen 5 2 board)
-                        shader
-                        [0 1 0 1])
+  (let [colors [[1 0 0 1]
+                [0 1 0 1]
+                [0 0 1 1]]]
+   (loop [board [#{[2 0] [2 1] [2 2] [1 2] [0 1]}
+                 #{[4 12] [3 12] [4 10] [4 11] [2 11]}
+                 #{[9 25] [9 23] [9 24] [7 24] [8 25]}]]
+     (when-not (Display/isCloseRequested)
+       (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
+       (dorun
+        (map (fn [b c]
+               (r/draw-rectangles (life->screen 5 2 b)
+                                  shader
+                                  c))
+             board colors))

-     (Display/update)
-     (Thread/sleep 100)
-     (recur (stepper board)))))
+       (Display/update)
+       (Thread/sleep 100)
+       (recur (map stepper board))))))

 (defmacro with-cleanup [close-fn & body]
   `(try


Add translations for new search mechanism

--- src/discuss/translations.cljs
+++ src/discuss/translations.cljs
@@ -44,7 +44,10 @@
                      :find-statement "Finde Aussage in der Diskussion"
                      :clipboard  "Ziehe diese Referenzen in das Textfeld beim Erzeugen eines neuen Arguments, um die Referenz zu nutzen."
                      :ask-to-add "Möchten Sie Ihre Aussage durch eine Referenz von dieser Seite stützen? Dann markieren Sie einfach einen Teil des Textes mit der Maus."
-                     :disabled/tooltip "Du kannst dieses Feld nicht direkt modifizieren. Bitte markiere die gewünschte Stelle direkt auf der Webseite. Dieses Feld füllt sich dann automatisch."}}
+                     :disabled/tooltip "Du kannst dieses Feld nicht direkt modifizieren. Bitte markiere die gewünschte Stelle direkt auf der Webseite. Dieses Feld füllt sich dann automatisch."}
+        :search      {:reuse "Statement auswählen"
+                      :origin "Herkunft"
+                      :author "Autor"}}
    :en {:common     {:and              "and"
                      :author           "Author"
                      :back             "Back"
@@ -82,7 +85,10 @@
                      :where-used "Where has this reference been used?"
                      :clipboard "Drag these references into the input field when creating a new argument"
                      :ask-to-add "Do you want to add a reference from this site to your statement? Just select the desired text-passage and it will be inserted in this field."
-                     :disabled/tooltip "You can't modify this field. Please select the appropriate text-passage from the website. The selection will be automatically added to this field."}}})
+                     :disabled/tooltip "You can't modify this field. Please select the appropriate text-passage from the website. The selection will be automatically added to this field."}
+        :search      {:reuse "Select Statement"
+                      :origin "Origin"
+                      :author "Author"}}})

 (defn- prepend-translation
   "Lookup given key and prepend some string to it."


Add getter for items

Add getter for items

--- src/discuss/utils/common.cljs
+++ src/discuss/utils/common.cljs
@@ -83,6 +83,11 @@
     (number? issue) (first (filter #(= (str->int (:uid %)) issue) (get-issues)))
     (string? issue) (first (filter #(= (:title %) issue) (get-issues)))))

+(defn get-items
+  "Returns list of items from the discussion."
+  []
+  (get-in @app-state [:items]))
+
 (defn get-bubbles
   "Return message bubbles from DBAS."
   []


fixed missing quote

fixed missing quote

--- src/distillery/view/cloud.clj
+++ src/distillery/view/cloud.clj
@@ -27,7 +27,7 @@
             (sort-by :v1)
             (map (fn
                    [{:keys [id rect]}]
-                   (str "{id:' id "',r:{x:"(.x rect)",y:"(.y rect)",w:"(.width rect)",h:"(.height rect)"}},")))
+                   (str "{id:'" id "',r:{x:"(.x rect)",y:"(.y rect)",w:"(.width rect)",h:"(.height rect)"}},")))
             (apply str))
        "]"))


removed TODO for word distribution matrix

--- src/distillery/view/video.clj
+++ src/distillery/view/video.clj
@@ -68,8 +68,7 @@
                       (list-item (str "Erkannte Phrasen: " (:phrase-count video)))
                       (list-item (str "Erkannte Worte: " (:word-count video)))
                       (list-item (format "Mittlere Erkennungssicherheit: %1.1f%%" (* 100 (:confidence video))))])
-              (render-hitlist video)
-              (TODO "Word distribution matrix (frequency vs. confidence)")]))
+              (render-hitlist video)]))

 (defn- render-transcript
   "Creates the HTML for the transcript with all phrases."


New DB function to update product

New DB function to update product

--- src/hurvinek/db_interface.clj
+++ src/hurvinek/db_interface.clj
@@ -114,3 +114,16 @@
                 (println e)
                 e))))

+(defn update-product
+    [product-id product-name description]
+    (if (or (empty? product-name) (empty? description))
+        "Product name or description is empty"
+        (try
+            (jdbc/update! db-spec/hurvinek-db
+                          :product {:name product-name
+                                    :description description} ["id=?" product-id])
+            nil ; return value
+            (catch Exception e
+                (println e)
+                e))))
+


Need to load them once to handle :ret and :fn when instrumenting

--- src/adventofcode1/core.clj
+++ src/adventofcode1/core.clj
@@ -1,4 +1,7 @@
 (ns adventofcode1.core
+  (:require
+   adventofcode1.spec-test-instrument-debug
+   )
   (:gen-class))

 (defn -main


Send visual notification only from exceptions from boot-cljs task

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -118,8 +118,9 @@
               fileset (try
                         (next-task fileset)
                         (catch Exception e
-                          (send-visual! @pod {:exception (merge {:message (.getMessage e)}
-                                                                (ex-data e))})
+                          (if (= :boot-cljs (:from (ex-data e)))
+                            (send-visual! @pod {:exception (merge {:message (.getMessage e)}
+                                                                  (ex-data e))}))
                           (throw e)))]
           (let [warnings (apply merge (map :adzerk.boot-cljs/warnings (relevant-cljs-edn nil fileset ids)))]
             (send-visual! @pod {:warnings warnings})


Add audio player

Add audio player

--- src/airhead_cljs/core.cljs
+++ src/airhead_cljs/core.cljs
@@ -67,6 +67,8 @@

 (defn home-page []
   [:div [:h1 "Airhead"]
+   [:audio {:src "http://localhost:8000/airhead"
+            :controls "controls"}]
    [playlist-section]
    [tracks-section]])


remove colors, superfluous function

remove colors, superfluous function

--- src/bitsplit_cli/core.cljs
+++ src/bitsplit_cli/core.cljs
@@ -7,24 +7,14 @@
 (def prompt (js/require "prompt"))
 (set! (.-message prompt) "")
 (set! (.-delimiter prompt) "")
+(set! (.-colors prompt) false)

 (def storage (->File "FAKE"))
 ; (def client (->Bitcoind ""))

-(defn node->channel [function]
-    (fn [& args]
-        (let [return (chan 1)
-              into-chan
-                (fn [err result]
-                    (if-not (nil? err)
-                        (put! return {:error err})
-                        (put! return result)))]
-        (apply function (concat args [into-chan]))
-        return)))
-
-(defn read-prompt [p]
+(defn- read-prompt [message]
     (let [return (chan 1)]
-        (.get prompt p
+        (.get prompt message
             (fn [err input]
                 (put! return
                     (aget input p))))


renaming to action

renaming to action

--- src/celestial/api/jobs.clj
+++ src/celestial/api/jobs.clj
@@ -24,8 +24,6 @@
     [swag.core :refer (GET- POST- PUT- DELETE- defroutes- errors)]
     [celestial.security :refer (current-user)]
     [celestial.persistency.systems :as s]))
-
-;

 (import-logging)

@@ -98,9 +96,9 @@
       :notes "Runs adhoc remote opertions on system (like deployment, service restart etc)
               using matching remoting capable tool like Capisrano/Supernal/Fabric"}
        (let [{:keys [machine] :as system} (s/get-system id)]
-         (if-let [actions (find-action-for action (:type system))]
+         (if-let [action* (find-action-for action (:type system))]
            (schedule-job id "run-action" (<< "submitted ~{action} action")
-             [actions (merge args {:action (keyword action) :hostname (machine :hostname) :target (machine :ip) :system-id (Integer. id)})])
+             [action* (merge args {:action (keyword action) :hostname (machine :hostname) :target (machine :ip) :system-id (Integer. id)})])
            (bad-req {:msg (<< "No action ~{action} found for id ~{id}")})
            )))


Jumps to labels should be handled like jumps to names

--- src/clj/minijava/munch.clj
+++ src/clj/minijava/munch.clj
@@ -297,6 +297,10 @@
   [stm dst]
   (emit (jmp (munch dst))))

+(defmethod munchMap [:minijava.ir/Jump :minijava.temp/Label]
+  [stm dst]
+  (emit (jmp (munch dst))))
+
 ;; pass strings through
 (defmethod munchMap [java.lang.String]
   [x] x)


get dashboard info

get dashboard info

--- src/clj/salava/user/db.clj
+++ src/clj/salava/user/db.clj
@@ -14,7 +14,9 @@
             [salava.core.countries :refer [all-countries]]
             [salava.core.i18n :refer [t]]
             [salava.core.time :refer [unix-time]]
-            [salava.mail.mail :as m]))
+            [salava.mail.mail :as m]
+            [salava.badge.endorsement :as end]
+            [salava.social.db :as so]))

 (defqueries "sql/user/main.sql")

@@ -440,4 +442,22 @@

-
+(defn dashboard-info [ctx user-id]
+  (let [badges (->> (b/user-badges-all ctx user-id) (sort-by :mtime >))
+        pending-badges (b/user-badges-pending ctx user-id)
+        stats (b/badge-stats ctx user-id)
+        events (so/get-all-events-add-viewed ctx user-id)]
+  {:badges (->> badges (take 5))
+   :pending-badges (->> pending-badges (take 5))
+   :stats stats
+   :endorsing (->> (end/endorsements-given ctx user-id) count)
+   :endorsers (->> (end/endorsements-received ctx user-id) count)
+   :connections {:badges (->> (so/get-connections-badge ctx user-id) count)}
+   :events (->> events (take 5))
+   :events_count (count events)
+   :pages_count (->> (p/user-pages-all ctx user-id) count)
+   :files_count (->> (f/user-files-all ctx user-id) :files count)
+   :gallery (g/gallery-stats ctx)
+   }
+  ))
+


Use same format for old and new tweets

Use same format for old and new tweets

--- src/clj/skytwit/server.clj
+++ src/clj/skytwit/server.clj
@@ -73,6 +73,11 @@
        :last-tweet-id (-> user :status :id)})
     (catch Exception _ nil)))

+(defn format-tweet
+  [t]
+  {:id (:id t)
+   :tags (->> t :entities :hashtags (mapv :text))})
+
 (defn get-tweets-before-tweet-id
   [creds screen-name id]
   (let [get-raw-tweets
@@ -96,10 +101,7 @@
                              (twh/response-throw-error resp)))
                          twh/exception-rethrow)))
         tweets (->> (get-raw-tweets)
-                    (map (fn [m]
-                           {:id (:id m)
-                            :tags (->> m :entities :hashtags
-                                       (mapv :text))})))]
+                    (map format-tweet))]
     (if (= id (:id (first tweets)))
       (rest tweets)
       tweets)))
@@ -128,7 +130,7 @@
                                            twh/exception-rethrow))
         f (go-loop [s (json/parsed-seq r true)]
                    (when-not @end?
-                     (>! chan (first s))
+                     (>! chan [(format-tweet (first s))])
                      (recur (rest s))))]
     ;; TODO: There may be a small memory leak here: if statuses-filter
     ;;       is stopped in the middle of a JSON string, the lazy seq may


Added gcd computation

Added gcd computation

--- src/clj_mrazik/irc_bot.clj
+++ src/clj_mrazik/irc_bot.clj
@@ -75,6 +75,12 @@
     [n]
     (reduce *' (range 1 (inc n))))

+(defn gcd
+    [x y]
+    (if (zero? y)
+        x
+        (recur y (mod x y))))
+
 (defn print-factorial
     [input]
     (factorial (Integer/parseInt (subs input 0 (dec (count input))))))
@@ -83,9 +89,20 @@
     [input]
     (str input " = " (clojure.string/join " x " (primefactors (Integer/parseInt input)))))

+(defn print-gcd
+    [input]
+    (let [splitted (re-find #"([0-9]+)\s+([0-9]+)" input)
+          x (Integer/parseInt (nth splitted 1))
+          y (Integer/parseInt (nth splitted 2))]
+        (str "gcd(" x "," y ") = " (gcd x y))))
+
 (defn is-number?
     [input]
     (re-matches #"[0-9]+" input))
+
+(defn is-two-numbers?
+    [input]
+    (re-matches #"[0-9]+\s+[0-9]+" input))

 (defn is-factorial?
     [input]
@@ -109,9 +126,10 @@
                           "Good bot" "I know"
                           "Good bot." "I know"
                           (condp
-                              (is-number? input)    (print-prime-factors input)
-                              (is-factorial? input) (print-factorial input)
-                                                    (random-message)))]
+                              (is-number? input)      (print-prime-factors input)
+                              (is-two-numbers? input) (print-gcd input)
+                              (is-factorial? input)   (print-factorial input)
+                                                      (random-message)))]
         (str prefix response)))

 (defn on-incoming-message


render wp-style links

render wp-style links

--- src/cljs/unfolds/core.cljs
+++ src/cljs/unfolds/core.cljs
@@ -5,7 +5,8 @@
             [cljs.core.async :refer [put! chan <!]]))

 (defonce app-state (atom {:text "Hello!"
-                          :items ["foo" "bar"]}))
+                          :items ["foo"
+                                  "Foobar [[foo|blitz]] lolophone hoptigoff."]}))

 (defn add-item [app owner]
   (let [new-item (-> (om/get-node owner "new-item")
@@ -21,11 +22,28 @@
       (om/set-state! owner :text text)
       (om/set-state! owner :text value))))

+(def link-re #"\[\[([a-z]+)\|([a-z]+)\]\]")
+(defn link [href str] (dom/a #js {:href href} str))
+(defn link? [s] (if (re-find link-re s) true false))
+(defn get-href [s] (str (nth (re-find link-re s) 1)))
+(defn get-title [s] (str (nth (re-find link-re s) 2)))
+(defn split-words [s] (clojure.string/split s #"\s+"))
+
+(defn str-or-link [x]
+  (if (link? x)
+    (link (get-href x) (get-title x))
+    (str " " x " ")))
+
+(defn prepare-item [s]
+  (vec (map str-or-link (split-words s))))
+
 (defn item-view [item owner]
   (reify
     om/IRender
     (render [this]
-      (dom/li nil (str item)))))
+      (dom/li nil
+              (apply dom/div nil
+                     (prepare-item item))))))

 (defn app-view [app owner]
   (reify
@@ -43,7 +61,6 @@
                (apply dom/ul nil
                       (om/build-all item-view (:items app)))))))

-
 (defn main []
   (om/root app-view
            app-state


tailrecursion.boot ns cleanup

tailrecursion.boot ns cleanup

--- src/tailrecursion/boot.clj
+++ src/tailrecursion/boot.clj
@@ -1,11 +1,8 @@
 (ns tailrecursion.boot
   (:require [cemerick.pomegranate :as pom]
-            [cemerick.pomegranate.aether :refer [maven-central]]
             [clojure.java.io :as io]
             [tailrecursion.boot.tmpregistry :as tmp]
-            [tailrecursion.boot.dispatch :as dispatch]
-            [clojure.core :as core])
-  (:refer-clojure :exclude [get])
+            [tailrecursion.boot.dispatch :as dispatch])
   (:import java.lang.management.ManagementFactory
            [java.net URLClassLoader URL])
   (:gen-class))
@@ -29,7 +26,7 @@

 (defn exclude [syms coordinate]
   (if-let [idx (find-idx coordinate :exclusions)]
-    (let [exclusions (core/get coordinate (inc idx))]
+    (let [exclusions (get coordinate (inc idx))]
       (assoc coordinate (inc idx) (into exclusions syms)))
     (into coordinate [:exclusions syms])))

@@ -54,7 +51,7 @@

 (defn configure [{:keys [boot] :as cfg}]
   (install boot)
-  (add (core/get boot :directories))
+  (add (get boot :directories))
   (swap! env merge (dissoc cfg :boot))
   `(quote ~cfg))


Two voices, with synchronisation.

Two voices, with synchronisation.

--- src/kolmogorov_music/song.clj
+++ src/kolmogorov_music/song.clj
@@ -41,26 +41,30 @@
 (defmethod live/play-note :dux [{hertz :pitch}] (buzz hertz))
 (defmethod live/play-note :comes [{hertz :pitch seconds :duration}] (sing hertz seconds))

-(defn encode [[a b c d & digits]]
-  (if (zero? (* c d))
-    (encode digits)
-    (let [pitch (+ a b)
-          duration (/ c d)]
-      (cons {:time 0
-             :pitch pitch
-             :duration duration}
+(defn n [time duration pitch part]
+  {:time time
+   :pitch pitch
+   :duration duration
+   :part part})
+
+(defn encode [{:keys [dux comes] :as state} [a b c d & digits]]
+  (if (zero? (* a b))
+    (encode {:dux (max dux comes) :comes (max dux comes)} digits)
+    (let [part (if (<= dux comes) :dux :comes)
+          duration (/ a b)
+          pitch (+ c d)
+          time (part state)]
+      (cons (n time duration pitch part)
             (lazy-seq (->> digits
-                           encode
-                           (where :time (scale/from duration))))))))
+                           (encode (update-in state [part] (partial + duration)))))))))

 (def track
   (->>
-    (champernowne/word 10 4630330330231132330)
-    encode
-    (all :part :comes)
+    (champernowne/word 10 410033073307230713083309)
+    (encode {:dux 0 :comes 0})
     (wherever :pitch, :pitch (comp temperament/equal scale/A scale/minor scale/lower))
-    (where :time (bpm 160))
-    (where :duration (bpm 160))))
+    (where :time (bpm 120))
+    (where :duration (bpm 120))))

 (comment


Bump version of clojurescript.test 0.3.2 -> 0.3.3

Version 0.3.3 allows running tests with PhantomJS that access
localStorage

--- src/leiningen/new/reagent.clj
+++ src/leiningen/new/reagent.clj
@@ -34,7 +34,7 @@
 (defn test? [opts]
   (some #{"+test"} opts))

-(def test-plugin "com.cemerick/clojurescript.test \"0.3.2\"")
+(def test-plugin "com.cemerick/clojurescript.test \"0.3.3\"")

 (def test-source-paths "\"src/cljs\" \"test/cljs\"")


implementing hsb->rgb & rgb24->rgb fns

implementing hsb->rgb & rgb24->rgb fns

--- src/thi/ng/luxor/color.clj
+++ src/thi/ng/luxor/color.clj
@@ -2,24 +2,24 @@
   (:import
    [java.awt Color]))

-(defn rgbvec
+(def ^:const inv8bit (/ 1.0 255))
+
+(defn rgb24->rgb
   [rgb]
-  (let [i8 (/ 1.0 255)]
-    [(* i8 (bit-and (bit-shift-right rgb 16) 0xff))
-     (* i8 (bit-and (bit-shift-right rgb 8) 0xff))
-     (* i8 (bit-and rgb 0xff))]))
+  [(* inv8bit (bit-and (bit-shift-right rgb 16) 0xff))
+   (* inv8bit (bit-and (bit-shift-right rgb 8) 0xff))
+   (* inv8bit (bit-and rgb 0xff))])

 (defn hsb->rgb
   [[h s b]]
-  (let [rgb (bit-and (Color/HSBtoRGB (float h) (float s) (float b)) 0xffffff)
-        i8 (/ 1.0 255)]
-    [(* i8 (bit-and (bit-shift-right rgb 16) 0xff))
-     (* i8 (bit-and (bit-shift-right rgb 8) 0xff))
-     (* i8 (bit-and rgb 0xff))]))
+  (let [rgb (bit-and (Color/HSBtoRGB (float h) (float s) (float b)) 0xffffff)]
+    [(* inv8bit (bit-and (bit-shift-right rgb 16) 0xff))
+     (* inv8bit (bit-and (bit-shift-right rgb 8) 0xff))
+     (* inv8bit (bit-and rgb 0xff))]))

 (defn scaled-absorption-at-depth
   [x scale d]
-  (* (/ (Math/log (max x 1e-30)) d) scale (if (= x 1.0) 1 -1)))
+  (* (/ (Math/log (max x 1e-30)) d) (if (= x 1.0) scale (- scale))))

 (defn scaled-absorption-color-at-depth
   [rgb scale d]


Improve move-shape event constructor docstring.

--- src/uxbox/data/shapes.cljs
+++ src/uxbox/data/shapes.cljs
@@ -103,9 +103,8 @@
       (update-in state [:shapes-by-id id] merge shape))))

 (defn move-shape
-  "Mark a shape selected for drawing in the canvas."
+  "Move shape using relative position (delta)."
   [sid delta]
-  {:pre [(gpt/point? delta)]}
   (reify
     udp/IPageUpdate
     rs/UpdateEvent


OO: Include additional offsets due to tab height changing at smaller screen sizes

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -305,18 +305,32 @@

 (defn get-table-view-height
   []
-  (let [body-height (-> "body"
-                        js/document.querySelector
-                        .-clientHeight)
+  (let [body (-> "body"
+                 js/document.querySelector)
+        body-height (.-clientHeight body)
+        body-width (.-clientWidth body)
         main-navigation-height (-> "#dataview-menu"
                                    js/document.querySelector
                                    .-clientHeight)
-        tab-navigation-height (-> ".tab-bar"
+        tab-navigation-height (-> ".tab-bar a.clicked"
                                   js/document.querySelector
-                                  .-clientHeight)]
+                                  .-clientHeight)
+        record-summary-container-height
+        (-> ".tab-bar .rec-summary"
+            js/document.querySelector
+            .-clientHeight)
+        tablet-width 1024
+        phablet-width 704
+        submission-view-y-top-offset 2]
     (- body-height
        (+ main-navigation-height
-          tab-navigation-height))))
+          tab-navigation-height
+          (if (> body-width phablet-width)
+            0
+            tab-navigation-height)
+          (if (> body-width tablet-width)
+            0
+            submission-view-y-top-offset)))))

 (defn set-window-resize-handler
   [owner]


Redirect on error.

Redirect on error.

--- src/ombs/handler/addevent.clj
+++ src/ombs/handler/addevent.clj
@@ -51,6 +51,8 @@
       (println (str "rates " user-rates " pp " party-pay " users " users))
       (redirect "/addevent")
       )
-    (println (str "Wrong. Is Error?" (vld/errors? :ename :eprice :edate :event)))
+    (do (println (str "Wrong. Is Error:" (vld/errors? :ename :eprice :edate :event)))
+      (redirect "/")
+      )
     )
   )


Update newrelic.clj

Update newrelic.clj

--- src/onyx/metrics/newrelic.clj
+++ src/onyx/metrics/newrelic.clj
@@ -47,7 +47,6 @@
 (defn newrelic-sender [{:keys [newrelic/batch-size newrelic/batch-timeout newrelic/license-key]} ch shutdown?]
   (let [batch-size (or batch-size 50)
         batch-timeout (or batch-timeout 500)
-        timeout-count (atom 0)
         license-key (or (System/getenv "NEW_RELIC_LICENSE_KEY")
                         license-key
                         (throw (Exception. "NewRelic license key must be supplied via the NEW_RELIC_LICENSE_KEY environment variable or :newrelic/license-key")))]
@@ -56,11 +55,13 @@
                   (not @shutdown?))
         (let [events (read-batch ch batch-size batch-timeout)
               events-by-period (group-by (juxt :job-name :period) events)]
-          (when-not (empty? events)
-            (loop [sleep 0]
+          (if (empty? events)
+            (Thread/sleep batch-timeout)
+            (loop [timeout-count 0
+                   sleep 0]
               ;; Exponential backoff to rate limit errors
               (when-not (zero? sleep)
-                (info (format "Message send timeout count %s. Backing off %s." @timeout-count sleep))
+                (info (format "Message send timeout count %s. Backing off %s." timeout-count sleep))
                 (Thread/sleep sleep))

               (let [result (try
@@ -80,5 +81,4 @@
                               (warn-failure e events)
                               ::exception))]
                 (when (#{::exception} result)
-                  (swap! timeout-count inc)
-                  (recur (next-sleep-time sleep)))))))))))
+                  (recur (inc timeout-count) (next-sleep-time sleep)))))))))))


Make all props of bulkhead instance namespace qualified

--- src/promesa/exec/bulkhead.clj
+++ src/promesa/exec/bulkhead.clj
@@ -83,11 +83,11 @@
     (case key
       ::executor           executor
       ::semaphore          semaphore
-      :queue-size          (-> this meta ::queue-size)
-      :concurrency         (-> this meta ::concurrency)
-      :current-queue-size  (.size ^BlockingQueue queue)
-      :current-concurrency (- (-> this meta ::concurrency)
-                              (.availablePermits ^Semaphore semaphore))
+      ::queue-size          (-> this meta ::queue-size)
+      ::concurrency         (-> this meta ::concurrency)
+      ::current-queue-size  (.size ^BlockingQueue queue)
+      ::current-concurrency (- (-> this meta ::concurrency)
+                               (.availablePermits ^Semaphore semaphore))
       nil))

   (valAt [this key default]


Use let binding instead of calling a function again

--- src/reabledit/components.cljs
+++ src/reabledit/components.cljs
@@ -144,12 +144,12 @@
      (if edited?
        [(or (:editor column) default-editor)
         (get-in @state [:edit :updated])
-        (:key column)
+        column-key
         #(swap! state assoc-in [:edit :updated] %)
         move-to-cell!]
        [(or (:view column) (string-view))
         row-data
-        (:key column)
+        column-key
         enable-edit!])]))

 (defn data-table-row


Allow for not using `index-suffix`

Allow for not using `index-suffix`

--- src/riemann/elasticsearch.clj
+++ src/riemann/elasticsearch.clj
@@ -73,7 +73,9 @@
             es-endpoint (format "%s/%s%s/%s"
                                 (:es-endpoint opts)
                                 (:es-index opts)
-                                (time-format/unparse (time-format/formatter (:index-suffix opts)) (datetime-from-event event))
+                                (if (empty? (:index-suffix opts))
+                                  ""
+                                  (time-format/unparse (time-format/formatter (:index-suffix opts)) (datetime-from-event event)))
                                 (:type opts))
             http-options {}]
         (post


Make sure we always call destroy!

Make sure we always call destroy!

--- src/petulant_life/main.clj
+++ src/petulant_life/main.clj
@@ -26,6 +26,12 @@
 (defn destroy []
   (Display/destroy))

+(defmacro with-cleanup [close-fn & body]
+  `(try
+     (do ~@body)
+     (finally
+       (~close-fn))))
+
 ; Running the simulation / graphics.
 (defn run []
   (loop [running true]
@@ -41,6 +47,6 @@

 ; Entry point.
 (defn -main [& args]
-  (create)
-  (run)
-  (destroy))
+  (with-cleanup destroy
+    (create)
+    (run)))


initialize on first generate

initialize on first generate

--- src/proxmox/generators.clj
+++ src/proxmox/generators.clj
@@ -111,31 +111,33 @@
         (doseq [ip (range s (+ 1 e))]
           (car/zadd "ips" 0 ip))))))

-(initialize-range)

 (defn generate-ip
   "Fetches an available ip address from range"
   []
-  {:pre [(= 1 (wcar (car/exists "ips")))]}
+  {:pre []}
+  (when (= 0 (wcar (car/exists "ips")))
+    (initialize-range))
   (some->
     (wcar
       (car/lua-script
         "local next = redis.call('zrangebyscore', _:ips,0,0, 'LIMIT', 0,1) -- next available ip
-         redis.call('zadd',_:ips,_:used, next[1]) -- mark as used
-         return next[1]"
+        redis.call('zadd',_:ips,_:used, next[1]) -- mark as used
+        return next[1]"
         {:ips "ips"} {:used "1"}))
-      Long/parseLong long-to-ip
+    Long/parseLong long-to-ip
     ))

 (defn release-ip [ip]
-   (wcar
+  (wcar
     (car/lua-script
       "redis.call('zadd', 'ips', 0, _:ip)
-       return _:ip"
-     {:ips "ips"} {:ip (ip-to-long ip)})))
+      return _:ip"
+      {:ips "ips"} {:ip (ip-to-long ip)})))

-;; (release-ip "192.168.5.91" )
-;; (generate-ip)
-;; (wcar (car/del "ips"))
+(comment
+  (release-ip "192.168.5.91")
+  (generate-ip)
+  (wcar (car/del "ips")))

 (test #'long-to-ip)


Remove unneeded info logging

Remove unneeded info logging

--- src/riemann/logentries.clj
+++ src/riemann/logentries.clj
@@ -85,5 +85,4 @@

     (fn [event]
       (with-pool [client pool claim-timeout]
-        (info "Event message: " (event-to-le-format event))
         (send-line client (event-to-le-format event))))))


figwheel.main: add "-pc" and "-fwo" flags and print better errors when reading edn

--- figwheel-main/src/figwheel/main.cljc
+++ figwheel-main/src/figwheel/main.cljc
@@ -12,6 +12,9 @@
         [clojure.java.io :as io]
         [clojure.pprint :refer [pprint]]
         [clojure.string :as string]
+        [clojure.edn :as edn]
+        [clojure.tools.reader.edn :as redn]
+        [clojure.tools.reader.reader-types :as rtypes]
         [figwheel.core :as fw-core]
         [figwheel.main.ansi-party :as ansip]
         [figwheel.main.logging :as log]
@@ -158,6 +161,25 @@
 ;; Additional cli options
 ;; ----------------------------------------------------------------------------

+(defn figwheel-opts-opt
+  [cfg ropts]
+  (let [ropts (string/trim ropts)
+        edn   (if (string/starts-with? ropts "{")
+                (try
+                  (edn/read-string ropts)
+                  (catch Throwable e
+                    (throw (ex-info (str
+                                     (.getMessage e) "\n"
+                                     "Error reading EDN from command line: -fwo " (pr-str ropts))
+                                    {::error true}
+                                    e))))
+                (cljs.cli/load-edn-opts ropts))]
+    (validate-config! edn "Error validating figwheel options EDN provided to -fwo CLI flag")
+    (update cfg ::config merge edn)))
+
+(defn print-config-opt [cfg opt]
+  (assoc-in cfg [::config :pprint-config] (not (#{"false"} opt))))
+
 (defn- watch-opt
   [cfg path]
   (when-not (.exists (io/file path))
@@ -176,15 +198,21 @@
 (defn figwheel-opt [cfg bl]
   (assoc-in cfg [::config :figwheel-core] (not= bl "false")))

+(defn read-edn-file [f]
+  (try (redn/read
+        (rtypes/source-logging-push-back-reader (io/reader f) 1 f))
+       (catch Throwable t
+         (log/syntax-exception t)
+         (throw
+          (ex-info (str "Couldn't read the file:" f)
+                   {::error true} t)))))
+
 (defn get-build [bn]
   (let [fname (str bn ".cljs.edn")
-        build (try (read-string (slurp fname))
-                   (catch Throwable t
-                     ;; TODO use error parsing here to create better error message
-                     (throw
-                      (ex-info (str "Couldn't read the build file: " fname " : " (.getMessage t))
-                               {:cljs.main/error :invalid-arg}
-                               t))))]
+        build (if-not (.isFile (io/file fname))
+                (throw (ex-info (str "Unable to find build file: " fname)
+                                {:filename fname}))
+                (read-edn-file fname))]
     (when (meta build)
       (when-not (false? (:validate-config (meta build)))
         (log/debug "Validating metadata in build: " fname)
@@ -199,11 +227,6 @@
               end-parts (fw-util/path-parts (:relative-path source))]
           (when (= end-parts (take-last (count end-parts) res))
             (str (apply io/file (drop-last (count end-parts) res)))))))))
-
-(defn watch-dirs-from-build [{:keys [main] :as build-options}]
-  (let [watch-dirs (-> build-options meta :watch-dirs)
-        main-ns-dir (and main (watch-dir-from-ns (symbol main)))]
-    (not-empty (filter #(.exists (io/file %)) (cons main-ns-dir watch-dirs)))))

 (def default-main-repl-index-body
   (str
@@ -260,9 +283,11 @@
 (defn repl-main-opt [repl-env-fn args cfg]
   (let [target-on-classpath?
         (when-let [target-dir
-                   (try (:target-dir (read-string (slurp "figwheel-main.edn")) "target")
-                        (catch Throwable t
-                          nil))]
+                   (:target-dir
+                    (try (read-string (slurp "figwheel-main.edn"))
+                         (catch Throwable t
+                           nil))
+                    "target")]
           (fw-util/dir-on-classpath? target-dir))
         temp-dir (when-not target-on-classpath?
                    (let [tempf (java.io.File/createTempFile "figwheel" "repl")]
@@ -320,6 +345,13 @@
           {:group :cljs.cli/compile :fn watch-opt
            :arg "path"
            :doc "Continuously build, only effective with the --compile main option"}
+          ["-fwo" "--fw-opts"]
+          {:group :cljs.cli/compile :fn figwheel-opts-opt
+           :arg "edn"
+           :doc (str "Options to configure figwheel.main, can be an EDN string or "
+                     "system-dependent path-separated list of EDN files / classpath resources. Options "
+                     "will be merged left to right.")}
+          ;; TODO uncertain about this
           ["-fw" "--figwheel"]
           {:group :cljs.cli/compile :fn figwheel-opt
            :arg "bool"
@@ -330,7 +362,11 @@
           ["-bb" "--background-build"]
           {:group :cljs.cli/compile :fn background-build-opt
            :arg "str"
-           :doc (str "The name of a build config to watch and build in the background.")}}
+           :doc "The name of a build config to watch and build in the background."}
+          ["-pc" "--pprint-config" "--print-config"]
+          {:group :cljs.cli/compile :fn print-config-opt
+           :doc "Instead of running the command print out the configuration built up by the command. Useful for debugging."}
+          }
    :main {["-b" "--build"]
           {:fn build-main-opt
            :arg "string"
@@ -387,19 +423,21 @@
     (cond-> main-edn
       handler (assoc :ring-handler handler))))

+
+
+;; use tools reader read-string for better error messages
+#_(redn/read-string)
 (defn fetch-figwheel-main-edn [cfg]
-  (try (read-string (slurp (io/file "figwheel-main.edn")))
-       (catch Throwable t
-         (throw (ex-info "Problem reading figwheel-main.edn" )))))
+  (read-edn-file "figwheel-main.edn"))

 (defn- config-figwheel-main-edn [cfg]
-  (if-not (.exists (io/file "figwheel-main.edn"))
+  (if-not (.isFile (io/file "figwheel-main.edn"))
     cfg
     (let [config-edn (or (::start-figwheel-options cfg)
                          (process-figwheel-main-edn
                           (fetch-figwheel-main-edn cfg)))]
       (-> cfg
-          (update ::config merge config-edn)))))
+          (update ::config #(merge config-edn %))))))

 (defn- config-merge-current-build-conf [{:keys [::extra-config ::build] :as cfg}]
   (update cfg
@@ -550,7 +588,6 @@

       (.contains url "[[server-port]]")
       (string/replace "[[server-port]]"     (str server-port)))))
-

 (defn add-to-query [uri query-map]
   (let [[pre query] (string/split uri #"\?")]
@@ -1087,6 +1124,24 @@
             (build-cljs i input options
                          (cljs.env/default-compiler-env options))))))))

+(defn fix-simple-bool-arg* [flags args]
+  (let [[pre post] (split-with (complement flags) args)]
+    (if (empty? post)
+      pre
+      (concat pre [(first post) "true"] (rest post)))))
+
+(defn fix-simple-bool-args [flags args]
+  (reverse
+   (reduce (fn [accum arg]
+             (if (and (flags (first accum))
+                      (not (#{"true" "false"} arg)))
+               (-> accum
+                   (conj "true")
+                   (conj arg))
+               (conj accum arg)))
+           (list)
+           args)))
+
 (defmacro build-once [& ids]
   (build-once* ids)
   nil)
@@ -1098,9 +1153,10 @@
 (defn -main [& args]
   (alter-var-root #'cli/default-commands cli/add-commands figwheel-commands)
   (try
-    (let [[pre post] (split-with (complement #{"-re" "--repl-env"}) args)
-          args' (if (empty? post) (concat ["-re" "figwheel"] args) args)
-          args' (if (empty? args) (concat args' ["-r"]) args')]
+    (let [args       (fix-simple-bool-args #{"-pc" "--pprint-config"} args)
+          [pre post] (split-with (complement #{"-re" "--repl-env"}) args)
+          args'      (if (empty? post) (concat ["-re" "figwheel"] args) args)
+          args'      (if (empty? args) (concat args' ["-r"]) args')]
       (with-redefs [cljs.cli/default-compile default-compile]
         (apply cljs.main/-main args')))
     (catch Throwable e


Fix  space before @ of mention after linkifying.


Add hot reloading example to edge app template

--- edge-app-template/resources/clj/new/app.template/main.cljs
+++ edge-app-template/resources/clj/new/app.template/main.cljs
@@ -1,5 +1,11 @@
-(ns {{root-ns}}.frontend.main)
+(ns ^:figwheel-hooks {{root-ns}}.frontend.main)

 (js/console.log "Hello, world")

-(set! (.-innerText (js/document.getElementById "app")) "Loaded {{name}}!")
+;; This is called once
+(defonce init
+  (do (set! (.-innerText (js/document.getElementById "app")) "Loaded {{name}}!") true))
+
+;; This is called every time you make a code change
+(defn ^:after-load reload []
+  (set! (.-innerText (js/document.getElementById "app")) "Reloaded {{name}}!"))


CMR-1051: Made performance improvement when adding acl enforcement fields during a search with concept ids. It avoids apply regular expression if possible and uses pmap.

--- search-app/src/cmr/search/services/transformer.clj
+++ search-app/src/cmr/search/services/transformer.clj
@@ -61,7 +61,7 @@
   (info "Transforming" (count concepts-tuples) "concept(s) to" format)
   (let [mdb-context (context->metadata-db-context context)
         [t1 concepts] (u/time-execution
-                        (metadata-db/get-concepts mdb-context concepts-tuples allow-missing?))
+                        (doall (metadata-db/get-concepts mdb-context concepts-tuples allow-missing?)))
         [t2 values] (u/time-execution
                       (doall (pmap #(concept->value-map context % format) concepts)))]
     (debug "get-concept-revisions time:" t1
@@ -84,9 +84,13 @@

 (defmethod extract-access-value "application/echo10+xml"
   [concept]
-  (when-let [[_ restriction-flag-str] (re-matches #"(?s).*<RestrictionFlag>(.+)</RestrictionFlag>.*"
-                                                  (:metadata concept))]
-    (Double. ^String restriction-flag-str)))
+  (let [^String metadata (:metadata concept)]
+    ;; This contains check is a performance enhancement. This saves a lot of time versus the regular
+    ;; expression below when the metadata is a large string.
+    (when (.contains metadata "Restriction")
+      (when-let [[_ restriction-flag-str] (re-matches #"(?s).*<RestrictionFlag>(.+)</RestrictionFlag>.*"
+                                                      metadata)]
+        (Double. ^String restriction-flag-str)))))

 (defmethod extract-access-value "application/dif+xml"
   [concept]
@@ -128,14 +132,14 @@
    (info "Getting latest version of" (count concept-ids) "concept(s) in" format "format")
    (let [mdb-context (context->metadata-db-context context)
          [t1 concepts] (u/time-execution
-                         (metadata-db/get-latest-concepts mdb-context concept-ids true))
+                         (doall (metadata-db/get-latest-concepts mdb-context concept-ids true)))
          [t2 concepts] (u/time-execution (if skip-acls?
                                            concepts
-                                           (acl-service/filter-concepts
-                                             context
-                                             (map add-acl-enforcement-fields concepts))))
+                                           (doall (acl-service/filter-concepts
+                                                    context
+                                                    (pmap add-acl-enforcement-fields concepts)))))
          ;; Filtering deleted concepts
-         [t3 concepts] (u/time-execution (filter #(not (:deleted %)) concepts))
+         [t3 concepts] (u/time-execution (doall (filter #(not (:deleted %)) concepts)))
          [t4 values] (u/time-execution
                        (doall (pmap #(concept->value-map context % format) concepts)))]
      (debug "get-latest-concepts time:" t1
@@ -143,3 +147,6 @@
             "tombstone-filter time:" t3
             "concept->value-map time:" t4)
      values)))
+
+
+


Story ID: GEM-226 Summary: - begin writing tests to figure out bug for :without

--- spec/untangled/client/data_fetch_spec.cljs
+++ spec/untangled/client/data_fetch_spec.cljs
@@ -36,25 +36,51 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (specification "Data states"
-  (let [ready-marker (dfi/ready-state
+  (behavior "are properly initialized."
+    (is (df/data-state? (dfi/make-data-state :ready)))
+    (try (dfi/make-data-state :invalid-key)
+         (catch :default e
+           (is (= (.-message e) "INVALID DATA STATE TYPE: :invalid-key")))))
+
+  (behavior "can by identified by type."
+    (is (df/ready? (dfi/make-data-state :ready)))
+    (is (df/failed? (dfi/make-data-state :failed)))
+    (is (df/loading? (dfi/make-data-state :loading)))
+
+    (is (not (df/ready? (dfi/make-data-state :failed))))
+    (is (not (df/failed? "foo")))))
+
+(specification "Processed ready states"
+  (let [ready-marker-1 (dfi/ready-state
                        :ident [:item/by-id 1]
                        :field :comments
                        :without #{:author}
-                       :query (om/focus-query (om/get-query Item) [:comments]))]
-
-    (behavior "are properly initialized."
-      (is (df/data-state? ready-marker))
-      (try (dfi/make-data-state :invalid-key)
-           (catch :default e
-             (is (= (.-message e) "INVALID DATA STATE TYPE: :invalid-key")))))
-
-    (behavior "can by identified by type."
-      (is (df/ready? ready-marker))
-      (is (df/failed? (dfi/make-data-state :failed)))
-      (is (df/loading? (dfi/make-data-state :loading)))
-
-      (is (not (df/ready? (dfi/make-data-state :failed))))
-      (is (not (df/failed? "foo"))))))
+                       :query (om/focus-query (om/get-query Item) [:comments]))
+        ready-marker-2 (dfi/ready-state
+                         :ident [:item/by-id 1]
+                         :field :comments
+                         :without #{:username}
+                         :query (om/focus-query (om/get-query Item) [:comments]))
+        ready-marker-3 (dfi/ready-state
+                         :ident [:item/by-id 1]
+                         :field :comments
+                         :without #{}
+                         :query (om/focus-query (om/get-query Item) [:comments]))
+        ]
+
+
+    (assertions
+      "remove the :without portion of the query on joins"
+      (:untangled.client.impl.data-fetch/query ready-marker-1) => [{:comments [:db/id :title]}]
+
+      "remove the :without portion of the query on props"
+      (:untangled.client.impl.data-fetch/query ready-marker-2) => [{:comments [:db/id :title {:author [:db/id :name]}]}]
+
+      ;ready-marker => {:untangled.client.impl.data-fetch/type     :ready
+      ;                 :untangled.client.impl.data-fetch/ident    [:item/by-id 1]
+      ;                 :untangled.client.impl.data-fetch/field    :comments
+      ;                 :untangled.client.impl.data-fetch/callback nil}
+      )))

 (specification "Lazy loading"
   (component "Loading a field within a component"


atom instead of volatile! local reference

--- Clojure-Websockets/src/clj/birdwatch/twitterclient/processing.clj
+++ Clojure-Websockets/src/clj/birdwatch/twitterclient/processing.clj
@@ -20,20 +20,20 @@

 (defn- log-count [last-received]
   (fn [step]
-    (let [cnt (volatile! 0)]
+    (let [cnt (atom 0)]
       (fn [r x]
         (when (zero? (mod @cnt 1000)) (log/info "processed" @cnt "since startup"))
-        (vswap! cnt inc)
+        (swap! cnt inc)
         (reset! last-received (t/now))
         (step r x)))))

 (defn- streaming-buffer []
   (fn [step]
-    (let [buff (volatile! "")]
+    (let [buff (atom "")]
       (fn [r x]
         (let [json-lines (str/split-lines (str/replace (str @buff x) #"\}\{" "}\r\n{"))
               to-process (butlast json-lines)]
-          (vreset! buff (last json-lines))
+          (reset! buff (last json-lines))
           (if to-process (step r to-process) r))))))

 (defn- tweet? [data]


fix(mesh): update `canonicalize-vertices`

--- src/thi/ng/geom/mesh/ops.cljc
+++ src/thi/ng/geom/mesh/ops.cljc
@@ -51,13 +51,13 @@
   [mesh eps]
   (let [[tree dupes] (unique-point-tree (g/vertices mesh) eps)
         finder (find-in-tree eps)]
-    [(reduce (fn [m f] (g/add-face m (mapv #(finder tree %) f))) (g/clear* mesh) (g/faces mesh))
-     ;;(g/into (g/clear* mesh) (map (fn [f] (mapv #(finder tree %) f)) (g/faces mesh)))
+    [(reduce (fn [m [f]] (g/add-face m [(mapv #(finder tree %) f)])) (g/clear* mesh) (g/faces mesh true))
      dupes]))

 (defn face-permutations
   [f] (take (count f) (iterate #(d/rotate-left 1 %) f)))

+;; FIXME currently broken to due MeshFace wrapper
 (defn remove-internal
   "Takes a mesh and removes all faces which have coincident vertices,
   but opposite orientation. Returns updated mesh."
@@ -72,6 +72,7 @@
         (set (g/faces mesh)))
        (assoc mesh :faces)))

+;; FIXME currently broken to due MeshFace wrapper
 (defn remove-internal-with-edges
   [mesh]
   (let [mesh (g/compute-face-normals mesh)]


Une première solution à l'exercice "nucleotide count" de exercism dans la track Clojure

--- exercism/clojure/nucleotide-count/src/nucleotide_count.clj
+++ exercism/clojure/nucleotide-count/src/nucleotide_count.clj
@@ -1,9 +1,21 @@
 (ns nucleotide-count)

-(defn count [nucleotide strand] ;; <- Arglist goes here
-  ;; your code goes here
+(def possible-nucleotides #{\A \C \G \T})
+
+(defn count [nucleotide strand]
+  (if (possible-nucleotides nucleotide)
+    (clojure.core/count (filter #(= nucleotide %) (seq strand)))
+    (throw (IllegalArgumentException. "The provided nucleotide does not exist"))
+  )
 )

-(defn nucleotide-counts [strand] ;; <- Arglist goes here
-  ;; your code goes here
+;; We could have just built and returned directly the following map
+;;{
+;; \A (nucleotide-count/count \A strand)
+;; \C (nucleotide-count/count \C strand)
+;; \G (nucleotide-count/count \G strand)
+;; \T (nucleotide-count/count \T strand)
+;; }
+(defn nucleotide-counts [strand]
+  (apply hash-map (flatten (map #(list % (nucleotide-count/count % strand)) possible-nucleotides)))
 )


Round to float cue vars to specified resolution.

--- src/afterglow/controllers/ableton_push.clj
+++ src/afterglow/controllers/ableton_push.clj
@@ -1473,7 +1473,8 @@
                                          raw-resolution))
         delta (* (sign-velocity (:velocity message)) resolution)
         adjusted (+ value delta)
-        normalized (if (= :integer (:type v)) (Math/round (float adjusted)) (float adjusted))]
+        normalized (if (= :integer (:type v)) (Math/round (float adjusted))
+                       (float (* (Math/round (/ adjusted resolution)) resolution)))]
     (cues/set-cue-variable! cue v (max low (min high normalized)) :show (:show controller) :when-id effect-id)))

 (defn- draw-boolean-gauge