[#10732] Remove message spinners and 'Sent' status

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/chat/message/message.cljs
+++ src/status_im/ui/screens/chat/message/message.cljs
@@ -202,11 +202,6 @@
         (:text content)]]
       [message-timestamp message]]]))

-(defn message-activity-indicator
-  []
-  [react/view style/message-activity-indicator
-   [react/activity-indicator {:animating true}]])
-
 (defn message-not-sent-text
   [chat-id message-id]
   [react/touchable-highlight
@@ -226,16 +221,10 @@
      [vector-icons/icon :main-icons/warning {:color colors/red}]]]])

 (defn message-delivery-status
-  [{:keys [chat-id message-id outgoing-status
-           first-outgoing? message-type]}]
-  (when (not= constants/message-type-private-group-system-message message-type)
-    (case outgoing-status
-      :sending  [message-activity-indicator]
-      :not-sent [message-not-sent-text chat-id message-id]
-      :sent     (when first-outgoing?
-                  [react/text {:style style/delivery-text}
-                   (i18n/label :t/status-sent)])
-      nil)))
+  [{:keys [chat-id message-id outgoing-status message-type]}]
+  (when (and (not= constants/message-type-private-group-system-message message-type)
+             (= outgoing-status :not-sent))
+    [message-not-sent-text chat-id message-id]))

 (defview message-author-name [from alias]
   (letsubs [contact-name [:contacts/raw-contact-name-by-identity from]]


wrapper decor now takes errors of the field into account

--- src/ez_form/decorate.clj
+++ src/ez_form/decorate.clj
@@ -1,15 +1,16 @@
 (ns ez-form.decorate
   (:require [clojure.string :as str]
             [clojure.zip :as zip]
+            [ez-form.common :refer [get-field]]
             [ez-form.zipper :refer [zipper]]))

 (def ^:dynamic *materials* {:?wrapper {:class "error"}
                             :?text {:css {:class "text"}
                                     :wrapper :div}
-                            :?help {:css {:class "text"}
+                            :?help {:css {:class "help"}
                                     :wrapper :div}
-                            :?error {:css {:class "text"}
+                            :?error {:css {:class "error"}
                                      :wrapper :div}})

 (defn add-decor [decor field]
@@ -78,10 +79,13 @@
 (defmethod decor :?help [form loc] (wrap-decor form loc))
 (defmethod decor :?wrapper [form loc]
   (let [node (zip/node loc)
-        base-material (material node)
-        options (get-material form node base-material)]
-    (if options
-      (zip/replace loc options)
+        field (get-field form node :wrapper)]
+    (if-not (empty? (:errors field))
+      (let [base-material (material node)
+            options (get-material form node base-material)]
+        (if options
+          (zip/replace loc options)
+          (zip/remove loc)))
       (zip/remove loc))))
 (defmethod decor :default [_ loc] loc)


Small changes for conexp-clj.clj

Small changes for conexp-clj.clj

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

--- src/scripts/conexp-clj.clj
+++ src/scripts/conexp-clj.clj
@@ -21,7 +21,7 @@
     (println doc)
     ;;
     (contains? options :gui)
-    (reply/launch
+    (reply/launch-standalone
      {:custom-eval '(do
                       (use 'conexp.main)
                       (use 'clojure.repl)
@@ -30,7 +30,8 @@
                       (alter-var-root
                        (var gui/*main-frame*)
                        (fn [_]
-                         (conexp.contrib.gui/gui :default-close-operation :exit))))})
+                         (conexp.contrib.gui/gui
+                          :default-close-operation :exit))))})
     ;;
     (contains? options :load)
     (do (when (not (options :load))
@@ -40,7 +41,7 @@
         (load-file (options :load)))
     ;;
     true
-    (do (reply/launch
+    (do (reply/launch-standalone
          {:custom-eval '(do (use 'conexp.main) (use 'clojure.repl))}))))

 (System/exit 0)


Various code cleanups; no changes to functionality

--- src/useful.clj
+++ src/useful.clj
@@ -4,10 +4,9 @@
 (defmacro assoc-if
   "Create mapping from keys to values in map if test returns true."
   [map test & kvs]
-  (let [assoc (cons 'assoc (cons map kvs))]
-    `(if ~test
-       ~assoc
-       ~map)))
+  `(if ~test
+     (assoc ~map ~@kvs)
+     ~map))

 (defn assoc-or
   "Create mapping from each key to val in map only if existing val is nil."
@@ -161,9 +160,8 @@

 (defmacro defm [name & fdecl]
   "Define a function with memoization. Takes the same arguments as defn."
-  `(let [var (defn ~name ~@fdecl)]
-     (alter-var-root var (fn [f#] (with-meta (memoize f#) (meta f#))))
-     var))
+  `(doto (defn ~name ~@fdecl)
+     (alter-var-root #(with-meta (memoize %) (meta %)))))

 (defmacro cond-let
   "An implementation of cond-let that is as similar as possible to if-let. Takes multiple
@@ -245,27 +243,25 @@
     (mapcat #(deref %)
             (map #(future (map f %)) (slice n coll)))))

-(defn assoc-in!
-  "Associates a value in a nested associative structure, where ks is a sequence of keys
-  and v is the new value and returns a new nested structure. The associative structure
-  can have transients in it, but if any levels do not exist, non-transient hash-maps will
-  be created."
-  [m [k & ks] v]
-  (let [assoc (if (instance? clojure.lang.ITransientCollection m) assoc! assoc)]
-    (if ks
-      (assoc m k (assoc-in! (get m k) ks v))
-      (assoc m k v))))
-
 (defn update-in!
   "'Updates' a value in a nested associative structure, where ks is a sequence of keys and
   f is a function that will take the old value and any supplied args and return the new
   value, and returns a new nested structure. The associative structure can have transients
   in it, but if any levels do not exist, non-transient hash-maps will be created."
   [m [k & ks] f & args]
-  (let [assoc (if (instance? clojure.lang.ITransientCollection m) assoc! assoc)]
-    (if ks
-      (assoc m k (apply update-in! (get m k) ks f args))
-      (assoc m k (apply f (get m k) args)))))
+  (let [assoc (if (instance? clojure.lang.ITransientCollection m) assoc! assoc)
+        val (get m k)]
+    (assoc m k (if ks
+                 (apply update-in! val ks f args)
+                 (apply f val args)))))
+
+(defn assoc-in!
+  "Associates a value in a nested associative structure, where ks is a sequence of keys
+  and v is the new value and returns a new nested structure. The associative structure
+  can have transients in it, but if any levels do not exist, non-transient hash-maps will
+  be created."
+  [m ks v]
+  (update-in! m ks (constantly v)))

 (defn thrush
   "Takes the first argument and applies the remaining arguments to it as functions from left to right.
@@ -291,14 +287,14 @@
       map
       (let [arg  (first args)
             args (rest args)]
-       (cond
-         (nil?  arg) (recur args map)
-         (map?  arg) (recur args (merge map arg))
-         (coll? arg) (recur (into args (reverse arg)) map)
-         :else       (recur (rest args) (assoc map arg (first args))))))))
+       (condp #(%1 %2) arg
+         nil?  (recur args map)
+         map?  (recur args (merge map arg))
+         coll? (recur (into args (reverse arg)) map)
+         (recur (rest args) (assoc map arg (first args))))))))

 (defn position
-  "Returns a map from item to the position of its first occurance in coll."
+  "Returns a map from item to the position of its first occurence in coll."
   [coll]
   (into {} (reverse (map-indexed #(vector %2 %1) coll))))

@@ -349,8 +345,7 @@
   [f]
   (.addShutdownHook
    (Runtime/getRuntime)
-   (proxy [Thread] []
-     (run [] (f)))))
+   (Thread. f)))

 (defn- parse-opt [default opts arg]
   (let [m re-matches, key (comp keyword str)]


Change HTTP Method of Query Form from POST to GET

Queries are really safe and don't need POST. I only used POST because
I wanted the query expr in the HTTP body. But for normal queries,
encoding them in the URI is ok. The length should not go above 2000
chars which is the usual maximum.

--- src/lens/routes.clj
+++ src/lens/routes.clj
@@ -37,7 +37,7 @@
     :forms
     {:lens/query
      {:action "/query"
-      :method "POST"
+      :method "GET"
       :title "Query"
       :params
       {:expr
@@ -518,7 +518,7 @@

    (GET "/code-lists/:id" [db id] (code-list db id))

-   (POST "/query" [db expr] (query db expr))
+   (GET "/query" [db expr] (query db expr))

    (fn [_] (ring-resp/not-found
              {:links {:up {:href "/"}}


Add more casts

Add more casts

--- src/mbeanz/core.clj
+++ src/mbeanz/core.clj
@@ -24,8 +24,15 @@
 (defn cast-type [[type-name arg]]
   (match [type-name]
          ["int"] (int (Integer/parseInt arg))
+         ["java.lang.Integer"] (Integer/parseInt arg)
          ["long"] (long (Long/parseLong arg))
+         ["java.lang.Long"] (Long/parseLong arg)
          ["boolean"] (boolean (Boolean/parseBoolean arg))
+         ["java.lang.Boolean"] (Boolean/parseBoolean arg)
+         ["double"] (double (Double/parseDouble arg))
+         ["java.lang.Double"] (Double/parseDouble arg)
+         ["float"] (float (Float/parseFloat arg))
+         ["java.lang.Float"] (Float/parseFloat arg)
          ["java.lang.String"] arg
          :else (throw (IllegalArgumentException. (str "Unsupported argument type " type-name)))))


Code ordering. Fixes unresolved var.

Code ordering. Fixes unresolved var.

--- src/onyx/schema.clj
+++ src/onyx/schema.clj
@@ -135,6 +135,12 @@
    (s/optional-key :trigger/fire-all-extents?) s/Bool
    (s/optional-key :trigger/doc) s/Str
    s/Keyword s/Any})
+
+(def JobScheduler
+  s/Keyword)
+
+(def TaskScheduler
+  s/Keyword)

 (def Job
   {:catalog Catalog
@@ -165,12 +171,6 @@

 (def AeronIdleStrategy
   (s/enum :busy-spin :low-restart-latency :high-restart-latency))
-
-(def JobScheduler
-  s/Keyword)
-
-(def TaskScheduler
-  s/Keyword)

 (def Messaging
   (s/enum :aeron :dummy-messenger))


Fix schema of muon options

Fix schema of muon options

--- src/photon/muon.clj
+++ src/photon/muon.clj
@@ -50,7 +50,7 @@
         (let [stream-manager (:manager stream-manager)
               impl (PhotonMicroservice. stream-manager)
               projections (:proj-ch stream-manager)
-              conf {:rabbit-url (:amqp.url options)
+              conf {:url (:amqp.url options)
                     :service-name (:microservice.name options)
                     :tags ["photon" "eventstore"]
                     :implementation impl}


Fix PersistentHashSet -conj

Fix PersistentHashSet -conj

--- lib/shin/cljs/cljs/core.cljs
+++ lib/shin/cljs/cljs/core.cljs
@@ -2068,19 +2068,20 @@
 (deftype PersistentHashSet [h]
   ICollection
   (-conj [coll entry]
-    (instance? PersistentHashSet entry)
-    (let [keys (hamt/keys (.-h entry))
-          len (alength keys)]
-      (loop [i 0
-             h h]
-        (if (< i len)
-          (let [k (aget keys i)]
-            (recur (inc i) (hamt/set k true h)))
-          (PersistentHashSet. h))))
-
-    :else
-    (let [h (hamt/set entry true h)]
-      (PersistentHashSet. h)))
+    (cond
+      (instance? PersistentHashSet entry)
+      (let [keys (hamt/keys (.-h entry))
+            len (alength keys)]
+        (loop [i 0
+               h h]
+          (if (< i len)
+            (let [k (aget keys i)]
+              (recur (inc i) (hamt/set k true h)))
+            (PersistentHashSet. h))))
+
+      :else
+      (let [h (hamt/set entry true h)]
+        (PersistentHashSet. h))))

   IEquiv
   (-equiv [coll other]


Disable window resizing when in opengl mode as resizing in this mode appears to crash things horribly.

--- src/quil/applet.clj
+++ src/quil/applet.clj
@@ -61,21 +61,24 @@
                       JFrame/EXIT_ON_CLOSE
                       JFrame/DISPOSE_ON_CLOSE)]
        (reset! (:frame m)
-               (doto (JFrame. (or (:title m) "Processing-core"))
-                 (.addWindowListener  (reify WindowListener
-                                        (windowActivated [this e])
-                                        (windowClosing [this e]
-                                          (future (applet-close applet)))
-                                        (windowDeactivated [this e])
-                                        (windowDeiconified [this e])
-                                        (windowIconified [this e])
-                                        (windowOpened [this e])
-                                        (windowClosed [this e])))
-                 (.setDefaultCloseOperation close-op)
-                 (.setSize width height)
-                 (.add applet)
-                 (.pack)
-                 (.show))))))
+               (let [f (JFrame. (or (:title m) "Processing-core"))]
+                 (doto f
+                   (.addWindowListener  (reify WindowListener
+                                          (windowActivated [this e])
+                                          (windowClosing [this e]
+                                            (future (applet-close applet)))
+                                          (windowDeactivated [this e])
+                                          (windowDeiconified [this e])
+                                          (windowIconified [this e])
+                                          (windowOpened [this e])
+                                          (windowClosed [this e])))
+                   (.setDefaultCloseOperation close-op)
+                   (.setSize width height)
+                   (.add applet)
+                   (.pack))
+                 (when (= mode :opengl)
+                   (.setResizable f false))
+                 (.show f))))))

 (def ^{:private true}
   renderer-modes {:p2d    P2D
@@ -145,10 +148,13 @@
                                   :mouse-released :mouse-moved :mouse-dragged
                                   :focus-gained :focus-lost :mouse-entered
                                   :mouse-exited :mouse-clicked :setup)
+        mode              (if (< 2 (count (:size options)))
+                            (nth (:size options) 2)
+                            :p2d)
         fns               (merge {:draw (fn [] nil)} fns)
         key-pressed-fn    (or (:key-pressed options) (fn [] nil))
         key-released-fn   (or (:key-released options) (fn [] nil))
-        key-typed-fn   (or (:key-typed options) (fn [] nil))
+        key-typed-fn      (or (:key-typed options) (fn [] nil))
         mouse-pressed-fn  (or (:mouse-pressed options) (fn [] nil))
         mouse-released-fn (or (:mouse-released options) (fn [] nil))
         mouse-moved-fn    (or (:mouse-moved options) (fn [] nil))
@@ -271,7 +277,7 @@
                                   {}
                                   methods)]
     (update-proxy prx bound-meths)
-    (applet-run prx)
+    (applet-run prx mode)
     prx))

 (defmacro defapplet


test time should be a float

test time should be a float

--- bake/bake/test.clj
+++ bake/bake/test.clj
@@ -60,8 +60,8 @@
   (when (:autotest opts)
     (wait-for-reload (* 1000 (Integer. (or (get *config* "autotest.interval") 5)))))
   (let [start    (System/currentTimeMillis)
-        failures (count (remove not (map (partial run-ns-tests opts)
-                                         namespaces)))]
+        results  (map (partial run-ns-tests opts) namespaces)
+        failures (count (remove not results))]
     (when (= 0 failures)
       (when (and (:autotest opts)
                  (< @last-passed @last-tested))
@@ -70,4 +70,4 @@
     (reset! last-tested start)
     (when-not (:autotest opts)
       (println "----")
-      (println "Finished in" (/ (- (System/currentTimeMillis) start) 1000) "seconds.\n"))))
+      (println "Finished in" (/ (- (System/currentTimeMillis) start) 1000.0) "seconds.\n"))))


Coding style fix

Coding style fix

--- test/cmr/system_int_test/search/granule_search_format_test.clj
+++ test/cmr/system_int_test/search/granule_search_format_test.clj
@@ -284,9 +284,7 @@
                                                                     :start-orbit-number 3.0
                                                                     :stop-orbit-number 4.0
                                                                     :equator-crossing-longitude -45.0
-                                                                    :equator-crossing-date-time "2011-01-01T12:00:00.000Z"}]
-                                })
-        ]
+                                                                    :equator-crossing-date-time "2011-01-01T12:00:00.000Z"}]})]

     (index/refresh-elastic-index)


Typo in Chloé's name.

Typo in Chloé's name.

--- src-cljs/frontend/components/about.cljs
+++ src-cljs/frontend/components/about.cljs
@@ -206,7 +206,7 @@
     :github ""
     :email ""
     :bio "Jia is the one of the first Account Managers to join the CircleCi team. When she's not busy figuring out customer pain points, you can find her hiking, running half marathons or finding the best new vegetarian restaurant in the Bay."}
-   {:name "Chloé Arthrus"
+   {:name "Chloé Arthurs"
     :img-path (scaled-image-path "")
     :role "Account Mananger"
     :github ""


[gateway] Minor refactor, simplify logic

--- src/braid/core/client/gateway/helpers.cljs
+++ src/braid/core/client/gateway/helpers.cljs
@@ -155,10 +155,10 @@
   (reg-sub
     (with-ns ns :fields-valid?)
     (fn [state [_ fields]]
-      (->> fields
-           (map (fn [field]
-                  (and
-                    (empty? (get-in state [k :fields field :errors]))
-                    (= 0 (get-in state [k :fields field :validations-left]))
-                    (not (get-in state [k :fields field :typing?])))))
-           (every? true?)))))
+      (every?
+        (fn [field]
+          (and
+            (empty? (get-in state [k :fields field :errors]))
+            (= 0 (get-in state [k :fields field :validations-left]))
+            (not (get-in state [k :fields field :typing?]))))
+        fields))))


remove output from jobs page

remove output from jobs page

--- src-cljs/frontend/components/pages/run.cljs
+++ src-cljs/frontend/components/pages/run.cljs
@@ -255,20 +255,4 @@
                                  {:selected? (= (:job/name job-data)
                                                 (:job/name selected-job))})))
                         jobs))]
-                [:.jobs-and-output
-                 [:.output
-                  [:div.output-header
-                   [:.output-title
-                    [:span (gstring/format "%s #%s"
-                                           selected-job-name
-                                           (:build/number selected-job-build-id))]]]
-                  (when selected-job-build-id
-                    (build-legacy build-page
-                                  {:app (:legacy/state (om-next/props this))
-                                   :job-build selected-job-build-id
-                                   :current-tab (:route-params/tab route-params)
-                                   :tab-href #(routes/v1-job-path
-                                               id
-                                               selected-job-name
-                                               (assoc route-params
-                                                      :route-params/tab %))}))]]])))})))))
+                ])))})))))


too much cargo culting

too much cargo culting

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -1012,11 +1012,11 @@
       (assoc-in state/invite-email-path value)))

 (defmethod control-event :email-invite-submitted
-  [browser-state message {:keys [value]} state]
+  [browser-state message _ state]
   (assoc-in state state/invite-email-path nil))

 (defmethod post-control-event! :email-invite-submitted
-  [browser-state message {:keys [value]} previous-state current-state]
+  [browser-state message _ previous-state current-state]
   (let [email (get-in previous-state state/invite-email-path)
         doc-id (:document/id previous-state)]
     (sente/send-msg (:sente current-state) [:frontend/send-invite {:document/id doc-id


Update language(pun intended)

Update language(pun intended)

--- src/cljs/koeeoadi/components/language.cljs
+++ src/cljs/koeeoadi/components/language.cljs
@@ -22,6 +22,6 @@
                 :id         "code-picker"
                 :onChange   #(code-change code-map %)}
     (util/widget-title "Language")
-    (dom/label nil "Current language:")
+    (dom/label nil "Choose language:")
     (apply dom/select nil
       (map #(code-option % code-name) (vals code-map)))))


Fix Clojure 1.9 exception

Fix Clojure 1.9 exception

--- src/clojure/zensols/actioncli/resource.clj
+++ src/clojure/zensols/actioncli/resource.clj
@@ -104,7 +104,7 @@

   * **:create** if `:file` then create the director(ies) on the
   file system, otherwise if `:dir` then create all parent directories"
-  ([key child-file & {:keys [create] :or {:create nil}}]
+  ([key child-file & {:keys [create] :or {create nil}}]
    (let [parent (resolve-function key false)
          path (resolve-resource (cond (instance? File parent) :file
                                       (function? parent) :function


De-reflect

De-reflect

--- modules/clojure/src/main/clojure/wunderboss/util.clj
+++ modules/clojure/src/main/clojure/wunderboss/util.clj
@@ -56,4 +56,4 @@
   (catch Exception _))

 (when-not (WunderBoss/inContainer)
-  (.addShutdownHook (Runtime/getRuntime) (Thread. exit!)))
+  (.addShutdownHook (Runtime/getRuntime) (Thread. ^Runnable exit!)))


kill leftover println

kill leftover println

--- src/riemann/bin.clj
+++ src/riemann/bin.clj
@@ -9,7 +9,7 @@
   (:gen-class :name riemann.bin))

 (def config-file
-  "The configuration file loaded by the bin tool"
+  "The configuration file loaded by the bin tool"
   (atom nil))

 (def reload-lock (Object.))
@@ -50,7 +50,6 @@
       (get (re-find #"^(\d+).*" name) 1)
       (catch Exception e name))))

-(println "loading bin")(flush)
 (defn -main
   "Start Riemann. Loads a configuration file from the first of its args."
   ([]


fix mistake

fix mistake

--- src/survey/core.clj
+++ src/survey/core.clj
@@ -130,8 +130,8 @@
                                           :handle-ok (ring-response {:headers {"Content-Encoding" "gzip"} :body (input-stream "resources/public/questionmark.js.gz")})))
   (ANY "/aalto.svg" [] (resource :available-media-types ["image/svg+xml"]
                                  :handle-ok (slurp "resources/aalto.svg")))
-  (ANY "/aalto.png" [] (resource :available-media-types ["image/png"]
-                                          :handle-ok (ring-response {:body (input-stream "resources/aaltosmall.png")})))
+  (ANY "/aaltosmall.png" [] (resource :available-media-types ["image/png"]
+                                          :handle-ok (ring-response {:body (input-stream "resources/aalto.png")})))
   (ANY "/favicon.ico" [] (resource :available-media-types ["image/x-icon"]
                                           :handle-ok (ring-response {:body (input-stream "resources/favicon.ico")})))
   )


Fixing custom AI ID

Fixing custom AI ID

--- src/cljs/zetawar/players/ai/custom.cljs
+++ src/cljs/zetawar/players/ai/custom.cljs
@@ -38,7 +38,7 @@

       0)))

-(defmethod players/new-player ::players/reference-ai
+(defmethod players/new-player ::players/custom-ai
   [{:as app-ctx :keys [ev-chan notify-pub]} player-type faction-color]
   (let [fns {:score-actor #'score-actor
              :score-base-action #'score-base-action


Add log->csv formatting.

Add log->csv formatting.

--- src/clojure/my/stuff/fitlogger/main.clj
+++ src/clojure/my/stuff/fitlogger/main.clj
@@ -50,6 +50,18 @@
 (defn format-listing [lst]
   (->> (map (fn [[_ measurements]]
             (format "%s" (format-measurements measurements)))
+          lst)
+     (join "\n")))
+
+(defn measurement->csv [m]
+  (->> (map (fn [[k v]]
+            (format "%s" v))
+          m)
+     (join ", ")))
+
+(defn listing->csv [lst]
+  (->> (map (fn [[_ measurements]]
+            (format "%s" (measurement->csv measurements)))
           lst)
      (join "\n")))

@@ -120,13 +132,6 @@
    [:button {:text "Add log",
              :on-click (fn [_]
                          (add-event activity))}]
-   [:button {:text "Write file",
-             :on-click (fn [_]
-                         (write-file activity "arst"))}]
-   [:button {:text "Read file",
-             :on-click (fn [_]
-                         (read-file activity))}]
-   [:text-view {:id ::test}]
    [:text-view {:text (format-listing @listing),
                 :id ::listing}]])


Bugfix

Bugfix

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -136,7 +136,7 @@
                          (apush output-facts&vals 1)
                          (set!! current-key key)
                          (aclear inputs)))
-                     (apush inputs (aget key prefix-len))))
+                     (apush inputs (.slice key prefix-len))))
          (when (> (alength inputs) 0)
            (let [output-key (aclone current-key)]
              (aset output-key prefix-len (aggregate-function inputs))
@@ -355,7 +355,11 @@
               (apush output-fields fields)

               ;; ensure indexes exist
-              (let [filtered-fields (into-array (filter #(not (or (nil? %) (= aggregate-key %))) fields))
+              (let [filtered-fields (make-array num-vars)
+                    _ (doseq [[_ field-type key val] clause-fields
+                              :when (= field-type "variable")]
+                        (aset filtered-fields (var->ix val) key))
+                    filtered-fields (into-array (filter #(not (nil? %)) filtered-fields))
                     ;; make sure aggregate-variables are last
                     _ (when-not (nil? aggregate-key)
                         (doseq [[ix [key var]] ix->aggregate-keys&vars]


initial work on parsing nested ul-li elements, tests not yet passing

--- src/watney/core.clj
+++ src/watney/core.clj
@@ -9,6 +9,11 @@
       java.io.StringReader.
       html/html-resource))

+(defn ^:private contains-node?
+  "Given an enlive tree, tells if a given element is contained in the first level"
+  [html-tree element]
+  (some #(= element (:tag %)) html-tree))
+
 (defn ^:private convert-entity
   "Returns Markdown when given an Enlive data tree."
   [html-tree]
@@ -19,7 +24,11 @@
                 :h2 (str "## " (first (:content node)))
                 :h3 (str "### " (first (:content node)))
                 :h4 (str "#### " (first (:content node)))
-                :li (str "* " (first (:content node)))
+
+                ;; if any of the children of this :li is a :ul, then return 2 spaces here
+                :li (if (contains-node? (:content node) :ul)
+                      (str "  " (convert-entity (:content node)))
+                      (str "* " (first (:content node))))
                 (convert-entity (:content node)))))
        (remove empty?)
        (str/join "\n")))


[core] Add 'merge-peer-state fn.

[core] Add 'merge-peer-state fn.

'merge-peer-state merges gossip received from a peer.

--- src/birdie_tell/core.clj
+++ src/birdie_tell/core.clj
@@ -106,6 +106,35 @@
                difference
                identified-peer-host-ports)))

+(defn- merge-peer-state
+  "Take my current 'my-state map and 'peer-state, a complete state map from a peer.
+
+  Merge the :peers from 'peer-state with :peers in 'my-state, ignoring
+  myself, adding any new :identified peers, and updating :data,
+  :version, and :host-port for :identified peers with higher versions
+  than I have.
+
+  TODO: consider :name changes
+  TODO: think about merging :potential peers in case this peer can reach a host-port another peer cannot
+  "
+  [my-state peer-state]
+  (util/debug :merge-peer-state :my-state my-state :peer-state peer-state)
+  (let [my-uuid (:uuid my-state)
+        peer-identified-peers (-> peer-state :peers :identified (dissoc my-uuid))
+        my-identified-peers (-> my-state :peers :identified)
+        version-check (fn [old new]
+                        (if (>= (:version old) (:version new))
+                          old
+                          (merge old (select-keys new [:data :version :host-port]))))
+        dirty-state (assoc-in my-state
+                              [:peers :identified]
+                              (merge-with version-check
+                                          my-identified-peers
+                                          peer-identified-peers))
+        new-state (clean-potential-peers dirty-state)]
+    (util/debug :new-state new-state)
+    new-state))
+
 (defn- update-peer!
   "Update a peer's state in the specified 'peers atom.


Log persistance

Log persistance

--- src/buildviz/storage.clj
+++ src/buildviz/storage.clj
@@ -1,10 +1,12 @@
 (ns buildviz.storage
   (:require [clojure.java.io :as io]
-            [taoensso.nippy :as nippy]))
+            [taoensso.nippy :as nippy]
+            [clojure.tools.logging :as log]))

 (import '[java.io DataInputStream DataOutputStream])

 (defn store-jobs! [jobs filename]
+  (log/info (format "Persisting to %s" filename))
   (with-open [w (io/output-stream filename)]
     (nippy/freeze-to-out! (DataOutputStream. w) jobs)))


Separate Authentication from Cors in schema

--- src/yada/schema.clj
+++ src/yada/schema.clj
@@ -258,25 +258,24 @@
     (s/optional-key :allow-methods) (s/conditional fn? ContextFunction :else Keywords)
     (s/optional-key :allow-headers) (s/conditional fn? ContextFunction :else Strings)}})

+(def CorsMappings
+  (merge HeaderMappings {ContextFunction as-fn}))
+
 (def Realm s/Str)

-(s/defschema AccessControl
-  (merge Cors
-         {(s/optional-key :authentication)
-          {(s/optional-key :realms)
-           {Realm {:schemes [{(s/optional-key :scheme) s/Str
-                              (s/optional-key :authenticator) s/Any}]}}}}))
-
-(def AccessControlMappings
-  (merge HeaderMappings {ContextFunction as-fn}))
-
-(s/defschema ResourceDocumentation
-  CommonDocumentation)
+(s/defschema Authentication
+  {(s/optional-key :authentication)
+   {(s/optional-key :realms)
+    {Realm {:schemes [{(s/optional-key :scheme) s/Str
+                       (s/optional-key :authenticator) s/Any}]}}}})
+
+(s/defschema ResourceDocumentation CommonDocumentation)

 (s/defschema ResourceBase
   (merge {(s/optional-key :id) s/Any}
          ResourceDocumentation
-         AccessControl
+         Authentication
+         Cors
          Properties
          ResourceParameters
          Produces
@@ -297,7 +296,7 @@
   (merge PropertiesMappings
          RepresentationSeqMappings
          MethodsMappings
-         AccessControlMappings))
+         CorsMappings))

 (def resource-coercer (sc/coercer Resource ResourceMappings))

@@ -312,3 +311,5 @@
    :known-methods {s/Keyword s/Any}
    :interceptor-chain [(s/=> Context Context)]
    (s/optional-key :path-info?) s/Bool})
+
+


Trying for some actx namespacing.

Trying for some actx namespacing.

--- src/cbfg/fence.cljs
+++ src/cbfg/fence.cljs
@@ -73,17 +73,17 @@
 ;; ------------------------------------------------------------

 (defn add-two [x delay]
-  (ago add-two nil
+  (ago test_add-two nil
        (<! (timeout delay))
        (+ x 2)))

 (defn range-to [s e delay]
   (let [c (achan nil)]
-    (ago range-to nil
+    (ago test_range-to nil
          (doseq [n (range s e)]
            (<! (timeout delay))
-           (aput range-to c n))
-         (aclose range-to c))
+           (aput test_range-to c n))
+         (aclose test_range-to c))
     c))

 (defn test []
@@ -116,8 +116,8 @@
   (let [in (achan-buf nil in-ch-size)
         out (achan-buf nil out-ch-size)
         fdp (make-fenced-pump nil in out max-inflight)
-        gch (ago-loop test-helper nil [acc nil]
-              (let [result (atake test-helper out)]
+        gch (ago-loop test_helper nil [acc nil]
+              (let [result (atake test_helper out)]
                 (if result
                   (do (println "Output result: " result)
                       (recur (conj acc result)))


Rename local var.

Rename local var.

--- src/cli4clj/cli.clj
+++ src/cli4clj/cli.clj
@@ -72,16 +72,16 @@
                          (fn [v k]
                            (let [fn-args (get-in cmds [k :fn-args])
                                  completion-hint (get-in cmds [k :completion-hint])
-                                 hint-completion-vec [(str "Arguments: " fn-args "\n")]]
+                                 arg-completion-vec [(str "Arguments: " fn-args "\n")]]
                              (if (or (not (nil? fn-args))
                                      (not (nil? completion-hint)))
                                (conj v
                                      (ArgumentCompleter.
                                        [(StringsCompleter. (conj (vec (map name (cmd-aliases k))) (name k)))
                                         (StringsCompleter. (if (not (nil? completion-hint))
-                                                             (conj hint-completion-vec
+                                                             (conj arg-completion-vec
                                                                (str "Hint: " completion-hint))
-                                                             hint-completion-vec))])))))
+                                                             arg-completion-vec))])))))
                          []
                          (keys cmd-aliases))
         _ (doseq [arg-compl arg-completers]


update ankha for new om, still too slow

update ankha for new om, still too slow

--- frontend/components/app.cljs
+++ frontend/components/app.cljs
@@ -1,6 +1,5 @@
 (ns frontend.components.app
-  (:require [ankha.core :as ankha]
-            [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
+  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
             [frontend.components.build :as build-com]
             [frontend.components.dashboard :as dashboard]
             [frontend.components.add-projects :as add-projects]
@@ -12,6 +11,7 @@
             [frontend.components.common :as common]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
+            [ankha.core :as ankha]
             [sablono.core :as html :refer-macros [html]]))

 (def keymap


Parrallelize

Parrallelize

--- euler-clj/src/euler_clj/core.clj
+++ euler-clj/src/euler_clj/core.clj
@@ -1,8 +1,5 @@
 (ns euler-clj.core
   (:gen-class))
-
-(defn divisors [x]
-  (filter #(= 0 (mod x %)) (range 1 (Math/sqrt (inc x)))))

 (defn divisors-fast [x]
   (loop [d 1
@@ -15,17 +12,21 @@
 (defn count-divisors [x]
   (count (divisors-fast x)))

-(defn euler12 [triangle-num n d]
-  (if (>= (count-divisors triangle-num) d)
-    (list triangle-num n)
-    (recur (+ (inc n) triangle-num) (inc n) d)))
-
 (defn next-triangle-number [[n t]]
   [(inc n) (+ (inc n) t)])

 (defn triangle-numbers []
   (map #(nth % 1) (iterate next-triangle-number [0 0])))

+(defn triangle-numbers-with-divisors-count []
+  (pmap (fn [triangle-num] (list (count-divisors triangle-num) triangle-num))
+       (triangle-numbers)))
+
+(defn euler12 [d]
+  (nth
+   (first (filter (fn [[dc tn]] (> dc d)) (triangle-numbers-with-divisors-count)))
+   1))
+
 (defn -main
   "I don't do a whole lot ... yet."
   [& args]


CLJS-1071: support symbol keys in :closure-defines

munge and convert symbol keys to strings

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1311,7 +1311,14 @@
        (deps/-foreign? js)))

 (defn add-implicit-options [opts]
-  (let [{:keys [libs foreign-libs externs]} (get-upstream-deps)]
+  (let [opts (cond-> opts
+               (:closure-defines opts)
+               (assoc :closure-defines
+                 (into {}
+                   (map (fn [[k v]]
+                          [(if (symbol? k) (str (comp/munge k)) k) v])
+                     (:closure-defines opts)))))
+        {:keys [libs foreign-libs externs]} (get-upstream-deps)]
     (cond->
       (-> opts
         (assoc


another ordered approach

another ordered approach

--- src/clj/signet/graph.clj
+++ src/clj/signet/graph.clj
@@ -1,5 +1,6 @@
 (ns signet.graph
-  (:require [aprint.core :refer [aprint]]))
+  (:require [clojure.set :refer [difference]]
+            [aprint.core :refer [aprint]]))

 (def test-cg
   {:causal-order {10 []
@@ -12,24 +13,72 @@
                   80 [30]
                   90 [80]
                   100 [70]
-                  110 [100]}
+                  110 [100]
+                  120 [50]}
    :branches {"master" 110
-              "fix" 50
+              "fix" 120
               "dev" 90}})

-(defn commit-graph->order
-  [{:keys [causal-order branches] :as cg}]
-  (let [heads (into #{} (vals branches))]
-    (sort-by second #(> (count %1) (count %2))
-             (for [[k v] branches]
-               (loop [parents (get causal-order v)
-                      order (list v)]
-                 (if (empty? parents)
-                   [k order]
-                   (if (< 2 (count parents))
-                     (recur (get causal-order (first parents)) (conj order (first parents)))
-                     (let [next-node (first (remove heads parents))]
-                       (recur (get causal-order next-node) (conj order next-node))))))))))

-;; maximum in the middle
-(commit-graph->order test-cg)
+(defn link-order [c causal-order heads]
+  (loop [parents (get causal-order c)
+         node c
+         order (list [c])]
+    (if (empty? parents)
+      order
+      (if (< 2 (count parents))
+        (recur (get causal-order  (first parents))
+               (first parents)
+               (conj order [(first parents) node ]))
+        (let [next-node (first (remove heads parents))]
+          (recur (get causal-order next-node)
+                 next-node
+                 (conj order [next-node node ])))))))
+
+
+(defn commit-graph->links [cg]
+  (let [{:keys [branches causal-order]} cg
+        heads (into #{} (vals branches))]
+    (loop [[b c] (first branches)
+           b-list (rest branches)
+           result []]
+      (if-not b
+        (sort-by second #(> (count %1) (count %2)) result)
+        (recur (first b-list)
+               (rest b-list)
+               (conj result [b (link-order c causal-order heads)]))))))
+
+(defn distinct-links [g]
+  (loop [[b l-order] (first g)
+         b-list (rest g)
+         links []]
+    (if (empty? b-list)
+      (into {} (conj links [b l-order]))
+      (let [branch-diffs (map (fn [[k v]] [k (difference (set v) (set l-order))]) b-list)]
+        (recur
+         (first branch-diffs)
+         (rest branch-diffs)
+         (conj links [b (set l-order)]))))))
+
+
+(defn distinct-nodes [g]
+  (into {} (map (fn [[k v]] [k (mapv first v)]) g)))
+
+
+
+(defn commit-graph->order [cg]
+  (let [g (commit-graph->links cg)
+        links (distinct-links g)]
+    {:nodes (distinct-nodes g)
+     :links links
+     :x-order (map first links)
+     :y-order (loop [old (map first links)
+                     new (list)
+                     i false]
+                (if (empty? old)
+                  new
+                  (recur (rest old)
+                         (if i
+                           (concat new (list (first old)))
+                           (concat (list (first old)) new))
+                         (not i))))}))


Half of playlist docstrings done.

Half of playlist docstrings done.

--- src/clj_spotify/core.clj
+++ src/clj_spotify/core.clj
@@ -9,6 +9,7 @@

 (def spotify-api-url "https://api.spotify.com/v1/")

+;TODO - add http response header type as meta-data.
 (defn response-to-map
   "Parse body of http respose to json"
   [response]
@@ -44,6 +45,7 @@
     )))

 ;TODO - better doc string
+;TODO - rename to def-spotify-api-call
 (defmacro spotify-api-call
   "Creates a function f with doc-string d that calls the http-verb verb for url url."
   [f verb url doc-string]
@@ -60,6 +62,8 @@
           (response-to-map)
           )))))

+;TODO - Replace all comma separated strings with maps?
+
 ;Albums
 (spotify-api-call get-an-album client/get (str spotify-api-url "albums/id")
 " Takes two arguments, a map m with query parameters and an optional oauth-token t.
@@ -270,8 +274,29 @@
     Example: (check-users-saved-tracks {:ids \"28nlyt9KhVZQ0lGQsg8Yht,09ZGF6mwJVzw5jxqbtT53E\"} \"BQBw-JtC..._7GvA\")")

 ;Playlists
-(spotify-api-call get-a-list-of-a-users-playlists client/get (str spotify-api-url "users/user_id/playlists") "")
-(spotify-api-call get-a-playlist client/get (str spotify-api-url "users/user_id/playlists/playlist_id") "")
+(spotify-api-call get-a-list-of-a-users-playlists client/get (str spotify-api-url "users/user_id/playlists")
+" Takes two arguments, a map m with query parameters and an optional oauth-token t.
+    Compulsory key in  m is :user_id, optional keys are :limit and :offset.
+    :user_id is the users spotify id.
+    :limit is the maxium number of tracks to return, default is 20.
+    :offset is the index of the first track to return, default is 0.
+
+    Example: (get-a-list-of-a-users-playlists {:user_id \"elkalel\" :limit 50 :offset 50} \"BQBw-JtC..._7GvA\")")
+
+;TODO - Can you pass :limit and :offset here? Let's assume you can.
+;TODO - Change this fields string to be a map?
+(spotify-api-call get-a-playlist client/get (str spotify-api-url "users/user_id/playlists/playlist_id")
+" Takes two arguments, a map m with query parameters and an optional oauth-token t.
+    Compulsory key in  m is :user_id and :playlist_id, optional keys are :fields, :market, :limit and :ffset.
+    :user_id is the users spotify id.
+    :playlist_id is the playlist spotify id.
+    :fields is a comma-separated string of fields to return from the playlist.
+     See developer.spotify.com for a full list of field names.
+    :limit is the maxium number of tracks to return, default is 20.
+    :offset is the index of the first track to return, default is 0.
+
+    Example: (get-a-playlist {:user_id \"elkalel\" :playlist_id \"6IIjEBw2BrRXbrSLerA7A6\" :fields \"href,name,owner\":limit 50 :offset 50} \"BQBw-JtC..._7GvA\")  ")
+
 (spotify-api-call get-a-playlists-tracks client/get (str spotify-api-url "users/user_id/playlists/playlist_id/tracks") "")
 (spotify-api-call create-a-playlist client/post (str spotify-api-url "users/user_id/playlists") "")
 (spotify-api-call add-tracks-to-a-playlist client/post (str spotify-api-url "users/user_id/playlists/playlist_id/tracks") "")


Improve `cljam.bam.reader/light-read-alignment` using ByteBuffer

--- src/cljam/bam/reader.clj
+++ src/cljam/bam/reader.clj
@@ -165,29 +165,24 @@
        :cigar cigar, :rnext rnext, :pnext pnext, :tlen tlen, :seq seq,
        :qual qual, :options options})))

-;; TODO: improve performance using ByteBuffer
 (defn- light-read-alignment [^BAMReader bam-reader refs]
   (let [rdr (.data-reader bam-reader)
-        ^Integer block-size (lsb/read-int rdr)]
-    (when (< block-size fixed-block-size)
-      (throw (Exception. (str "Invalid block size:" block-size))))
-    (let [ref-id      (lsb/read-int rdr)
-          rname       (if (= ref-id -1) "*" (:name (nth refs ref-id)))
-          pos         (inc (lsb/read-int rdr))
-          l-read-name (lsb/read-ubyte rdr)
-          _           (lsb/skip rdr 3)
-          n-cigar-op  (lsb/read-ushort rdr)
-          _           (lsb/skip rdr 2)
-          l-seq       (lsb/read-int rdr)
-          _           (lsb/skip rdr (+ 13 (dec (int l-read-name))))
-          cigar       (decode-cigar (lsb/read-bytes rdr (* n-cigar-op 4)))
-          _           (lsb/skip rdr (+ l-seq
-                                       (/ (inc l-seq) 2)
-                                       (options-size block-size
-                                                     l-read-name
-                                                     n-cigar-op
-                                                     l-seq)))]
-      {:rname rname, :pos pos, :cigar cigar})))
+        block-size (lsb/read-int rdr)]
+    (when (< block-size fixed-block-size)
+      (throw (Exception. (str "Invalid block size: " block-size))))
+    (let [buffer ^ByteBuffer (ByteBuffer/allocate block-size)]
+      (lsb/read-bytes rdr (.array buffer) 0 block-size)
+      (let [ref-id      (lsb/read-int buffer)
+            rname       (if (= ref-id -1) "*" (:name (nth refs ref-id)))
+            pos         (inc (lsb/read-int buffer))
+            l-read-name (int (lsb/read-ubyte buffer))
+            _           (lsb/skip buffer 3)
+            n-cigar-op  (lsb/read-ushort buffer)
+            _           (lsb/skip buffer 2)
+            l-seq       (lsb/read-int buffer)
+            _           (lsb/skip buffer (+ 13 (dec l-read-name)))
+            cigar       (decode-cigar (lsb/read-bytes buffer (* n-cigar-op 4)))]
+        {:rname rname, :pos pos, :cigar cigar}))))

 (defn- pointer-read-alignment [^BAMReader bam-reader refs]
   (let [rdr (.data-reader bam-reader)


Change placement of glTF sampler keys so it's easy to pass through to gamma-driver

--- src/cljs/gampg/gltf.cljs
+++ src/cljs/gampg/gltf.cljs
@@ -217,6 +217,13 @@
                                                 :sampler             sampler
                                                 :target              target
                                                 :type                type}
+                                               ;; Merging this here as
+                                               ;; well so it conforms
+                                               ;; with Gamma's view of
+                                               ;; texture
+                                               ;; :filter/:wrap key
+                                               ;; placement
+                                               sampler
                                                src)})) (:textures gltf)))))

 (defn process-shaders [gltf]
@@ -262,11 +269,11 @@
                           ;; XXX Check if this is a vector or a map,
                           ;; and change accordingly (right now
                           ;; hard-coding for the duck)
+                          ;; XXX: Map this over every value rather than just diffuse
                           diffuse (get-in gltf [:textures (keyword (:diffuse values))])]
                       {material-name {:values (merge values
                                                      (when diffuse {:diffuse diffuse}))
-                                      :name   (:name material-description)
-                                      }})) (:materials gltf)))))
+                                      :name   (:name material-description)}})) (:materials gltf)))))

 (defn process-attr [gltf [attr-name accessor-name]]
   (let [accessor (get-in gltf [:accessors (keyword accessor-name)])


Raise height

Raise height

--- src/dactyl_keyboard/dactyl-manuform.clj
+++ src/dactyl_keyboard/dactyl-manuform.clj
@@ -122,7 +122,7 @@
                           (translate column-offset))]
     (->> placed-shape
          (rotate (/ π 12) [0 1 0])
-         (translate [0 0 13]))))
+         (translate [0 0 23]))))

 (def key-holes
   (apply union
@@ -196,7 +196,7 @@
 ;;;;;;;;;;;;
 ;; Thumbs ;;
 ;;;;;;;;;;;;
-(def thumborigin [-23 -34 35])
+(def thumborigin [-23 -34 45])

 (defn deg2rad [degrees]
   (* (/ degrees 180) pi))


remove erroneous titles in version error message

--- src/main/cljs_api_gen/cljsdoc/validate.clj
+++ src/main/cljs_api_gen/cljsdoc/validate.clj
@@ -218,20 +218,15 @@
 ;;--------------------------------------------------------------------------------

 (defn unrecognized-version-error-msg
-  [version titles]
+  [version]
   (let [pass? (or (nil? version) ;; nil means apply to all versions
                   (@published-cljs-tag? (cljs-version->tag version)))]
     (when-not pass?
-      (str "Version '" version "' for titles "
-           (join ", " (map #(str "'" % "'") titles))
-           " is not a recognized published version."))))
+      (str "Version '" version "' is not a recognized published version."))))

 (defn unrecognized-versions-error-msg
   [doc]
-  (let [msgs (keep #(unrecognized-version-error-msg
-                      (first %)
-                      (keys (second %)))
-                   (:docs doc))]
+  (let [msgs (keep unrecognized-version-error-msg (keys (:docs doc)))]
     (when (seq msgs)
       (join "\n" msgs))))


more macro example

more macro example

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -38,6 +38,7 @@
     ;; (println (add-m x y))
     ;; (println (add-m-2 x y))

+    ;; TODO - Does not do what I think it does
     ;; This however works, but only with add-m-2
     (defmacro x1 [] 1)
     (defmacro x2 [] 2)
@@ -69,6 +70,7 @@
     ;; (println (average-m coll)) ;; Would not compile
     (println (average-m [1 2 3]))

+    ;; TODO - Does not do what you think it does
     ;; This however works
     (defmacro coll-m [] [1 2 3])
     (println (average-m (coll-m)))
@@ -77,13 +79,28 @@

 ;; --------------------------------------------------------
 ;; Example 2-b: Compute frequency map at compile time
-;;
-;; TODO - Ok, collections, but also maps
-;; And there you are in troube with C++ constexpr
-;; And that's the thing: 1 language to learn, not 2
-;; --------------------------------------------------------
-
-;; TODO
+;; - Ok, collections, but also maps
+;; - And there you are in troube with C++ constexpr
+;; - And that's the thing: 1 language to learn, not 2
+;; --------------------------------------------------------
+
+(defn freq-map
+  [coll]
+  (reduce
+    (fn [freqs val] (update freqs val (fnil + 0) 1))
+    {}
+    coll))
+
+(defmacro freq-map-m
+  [coll]
+  (freq-map coll))
+
+(defn test-freq-map
+  []
+  (let [inputs [1 2 1 4 1 3]]
+    (println (freq-map inputs))
+    (println (freq-map-m [1 2 1 4 1 3]))
+    ))

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


Formatting

Formatting

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -16,8 +16,8 @@
   "Main namespace for working with CQL, prepared statements. Convenience functions
    for key operations built on top of CQL."
   (:refer-clojure :exclude [update])
-  (:require [qbits.hayt.cql :as hayt]
-            [clojurewerkz.cassaforte.query :as q]
+  (:require [qbits.hayt.cql                 :as hayt]
+            [clojurewerkz.cassaforte.query  :as q]
             [clojurewerkz.cassaforte.client :as cc])
   (:import com.datastax.driver.core.Session))


Prepare user-friendly samples #15 - get rid of :use, cleanup

--- src/flatgui/samples/forms/bookpanelmain.clj
+++ src/flatgui/samples/forms/bookpanelmain.clj
@@ -576,8 +576,8 @@
                                :evolvers { :clip-size blotter-table-cs-evolver
                                            }}
     (deftableheader
-      (defcolumn :symbol [:sorting :filtering :grouping] {:clip-size (defpoint 2 DFLT_ROW_HEIGHT)})
-      (defcolumn :side [:sorting :filtering :grouping] {:clip-size (defpoint 2 DFLT_ROW_HEIGHT)})
+      (defcolumn :symbol [:sorting :filtering :grouping] {:clip-size (defpoint 2 default-row-height)})
+      (defcolumn :side [:sorting :filtering :grouping] {:clip-size (defpoint 2 default-row-height)})
       (defcolumn :id [:sorting])
       (defcolumn :qty [:sorting])
       (defcolumn :price [:sorting])


Fixed incorrect run

Fixed incorrect run

--- src/overtunes/songs/canone_alla_quarta.clj
+++ src/overtunes/songs/canone_alla_quarta.clj
@@ -49,7 +49,7 @@

 (def development
   {:time (concat [3/4] (repeat 12 1/4) [1/2 1 1/2] (repeat 12 1/4) [3])
-   :pitch (concat [4] (run 4 -2) [-1 -2 0] (run 3 5) (repeat 3 1) [2] (run -1 1) [0 -1] (run 5 0))})
+   :pitch (concat [4 4] (run 2 -3) [-1 -2 0] (run 3 5) (repeat 3 1) [2] (run -1 1) [0 -1] (run 5 0))})

 (defn lower [v] (- v 7))
 (def bass (update-all
@@ -81,7 +81,7 @@

 (defn play# []
   (let [from-now #(translate % 0 (now))
-        beat (from-now (bpm 90))
+        beat (from-now (bpm 100))
         with-beat (update :time (partial connect beat))
         in-key (update :pitch (partial connect g-major))
         after-a-half (after 1/2)


Make it clearer that demo# is dealing with a seq of points in time/pitch.

--- src/overtunes/songs/canone_alla_quarta.clj
+++ src/overtunes/songs/canone_alla_quarta.clj
@@ -12,16 +12,16 @@
     (->> notes (map play-at#) dorun)))

 (defn demo# [pitches]
-  (loop [play-at (now), [current & still-to-play] pitches]
-    (at play-at (piano# current))
-    (if still-to-play
-      (recur (+ 300 play-at) still-to-play))))
+  (let [note-length 300
+        start (now)
+        end (+ (* note-length (count pitches) start))
+        timing (range start end note-length)
+        notes (map vector timing pitches)]
+    (play# notes)
+    notes))

 ;(piano# 50)
 ;(demo# (range 60 73))
-
-
-

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(PE-2406) rename function to 'get-config-source'

--- src/puppetlabs/trapperkeeper/bootstrap.clj
+++ src/puppetlabs/trapperkeeper/bootstrap.clj
@@ -62,7 +62,7 @@
       (string/replace #"(?:#|;).*$" "")
       (string/trim)))

-(defn- open-config-file
+(defn- get-config-source
   [config-path]
   (let [config-file (file config-path)]
     (if (.exists config-file)
@@ -93,7 +93,7 @@
               (satisfies? IOFactory %))]}
   (when (contains? cli-data :bootstrap-config)
     (when-let [config-path (cli-data :bootstrap-config)]
-      (let [config-file (open-config-file config-path)]
+      (let [config-file (get-config-source config-path)]
         (log/debug (str "Loading bootstrap config from specified path: '"
                         config-path "'"))
         config-file))))


Added cisi caching

Added cisi caching

--- streamable.clj
+++ streamable.clj
@@ -25,6 +25,7 @@
         ids
         (:episode_id record)
         {:imdb (:imdb_id record)
+         :cisi (:cisi_id record)
          :rt (:rt_id record)}))
     {}
     (kcore/select movies)))
@@ -74,31 +75,47 @@
     (last
       (clojure.string/split url #"/"))))

-(defn assoc-media-id [ep]
-  (println "Getting id for" (:media-title ep))
+(defn get-cisi-id [ep imdb-id]
+  (println "Attempting to add CISI id for" (:title ep))
   (let [resp (http/get
                "http://www.canistream.it/services/search"
                {:query-params {:movieName (:media-title ep)}
                 :accept :json
-                :as :json})
-        imdb-id (-> ep :episode-id episode-ids :imdb)]
-    (if-let [matching-result (when
-                               imdb-id
-                               (first
-                                 (filter
-                                   #(= imdb-id (extract-imdb-id %))
-                                   (:body resp))))]
-      (assoc
-        ep
-        :media-id
-        (:_id matching-result))
-      (println "*** No match found for" (:title ep) "***"))))
+                :as :json})]
+    (if-let [matching-result (first
+                               (filter
+                                 #(= imdb-id (extract-imdb-id %))
+                                 (:body resp)))]
+      (do
+        (kcore/update movies
+          (kcore/set-fields {:cisi_id (:_id matching-result)})
+          (kcore/where {:episode_id (:episode-id ep)}))
+        (assoc
+          ep
+          :cisi-id
+          (:_id matching-result)))
+      (println "*** No CISI ID found for" (:title ep) "***"))))
+
+(def throttled-id (throttle-fn get-cisi-id 1 :second))
+
+(defn assoc-cisi-id [ep]
+  (let [ep-ids (-> ep :episode-id episode-ids)]
+    (cond
+      (:cisi ep-ids) (assoc ep :cisi-id (:cisi ep-ids))
+      (:imdb ep-ids) (throttled-id ep (:imdb ep-ids))
+      ep-ids (println "*** No IMDB ID found for" (:title ep) "***")
+      (:episode-id ep) (do
+                         (kcore/insert movies
+                           (kcore/values {:episode_id (:episode-id ep)
+                                          :title (:title ep)}))
+                         (println "Adding empty entry for" (:title ep)))
+      :else (println "Skipping" (:title ep)))))

 (defn assoc-streaming-options [ep]
   (println "Getting options for" (:media-title ep))
   (let [resp (http/get
                "http://www.canistream.it/services/query"
-               {:query-params {:movieId (:media-id ep)
+               {:query-params {:movieId (:cisi-id ep)
                                :attributes true
                                :mediaType "streaming"}
                 :accept :json
@@ -108,7 +125,6 @@
       :streaming-options
       (->> resp :body vals (map :friendlyName) set))))

-(def throttled-id (throttle-fn assoc-media-id 1 :second))
 (def throttled-options (throttle-fn assoc-streaming-options 1 :second))

 (defn format-results [eps]
@@ -135,7 +151,7 @@
               "\n")))))))

 (let [results (->> (get-episodes)
-                   (map throttled-id)
+                   (map assoc-cisi-id)
                    (filter identity)
                    (map throttled-options)
                    (remove (comp empty? :streaming-options)))]


delaney.clj: use m instead of v values when reading and writing DSymbols.

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -203,14 +203,14 @@

 (defmethod print-method DSymbol [ds ^Writer w]
   (let [images (fn [i] (map #(or (s ds i %) 0) (orbit-reps ds [i])))
-        spins (fn [i] (map #(or (v ds i (inc i) %) 0)
-                           (orbit-reps ds [i (inc i)])))
+        m-vals (fn [i] (map #(or (m ds i (inc i) %) 0)
+                            (orbit-reps ds [i (inc i)])))
         ops-str (s/join "," (map #(s/join " " (images %)) (indices ds)))
-        vs-str (s/join "," (map #(s/join " " (spins %)) (range (.dim ds))))
+        ms-str (s/join "," (map #(s/join " " (m-vals %)) (range (.dim ds))))
         dims-str (if (= 2 (.dim ds))
                    (str (.size ds))
                    (str (.size ds) " " (.dim ds)))
-        code (str "<1.1:" dims-str ":" ops-str ":" vs-str ">")]
+        code (str "<1.1:" dims-str ":" ops-str ":" ms-str ">")]
     (if *print-readably*
       (print-simple (str "(dsymbol \"" code "\")") w)
       (print-simple code w))))
@@ -238,12 +238,14 @@
           ds
           (range (count gluings))))

-(defn- with-spins [ds spins]
+(defn- with-m-vals [ds spins]
   (reduce (fn [ds i]
-            (reduce (fn [ds [D v]] (spin ds i (inc i) D v))
-                    ds
-                    (filter (fn [[D v]] (> v 0))
-                      (zipmap (orbit-reps ds [i (inc i)]) (nth spins i)))))
+            (let [j (inc i)]
+              (reduce (fn [ds [D m]]
+                        (spin ds i j D (/ m (r ds i j D))))
+                      ds
+                      (filter (fn [[D m]] (> m 0))
+                              (zipmap (orbit-reps ds [i j]) (nth spins i))))))
           ds
           (range (count spins))))

@@ -254,7 +256,7 @@
         [size dim] (parse-numbers (first data))
         d-set (with-gluings (DSymbol. (or dim 2) size {} {})
                 (parse-number-lists (nth data 1)))
-        d-sym (with-spins d-set
+        d-sym (with-m-vals d-set
                 (parse-number-lists (nth data 2)))]
     d-sym))


deploy automation

deploy automation

--- src/flatgui/samples/forms/tablewin2.clj
+++ src/flatgui/samples/forms/tablewin2.clj
@@ -17,7 +17,7 @@
             [flatgui.paint :as fgp]))

 (def col-count 30)
-(def row-count 300)
+(def row-count 60)

 (def header-model-pos
   [(mapv identity (range 0 col-count))
@@ -29,23 +29,10 @@

 (fgp/deflookfn cell-look (:theme :id :text)
- [                                                          ;(fgp/call-look flatgui.skins.flat/component-look)
-  (awt/setColor (awt/color 200 50 0) ;(:prime-2 theme)
-                )
-  (awt/drawRect 0 0 w- h-)
-  (awt/drawRect 5 5 10 10)
+ [;(fgp/call-look flatgui.skins.flat/component-look)
   (awt/setColor (:prime-1 theme))
-  (awt/drawRoundRect 0 0 w- h- 0.125)
-  (awt/drawString text 0.375 0.375)
-  (awt/setColor (awt/color 255 0 0))
-  (awt/drawRect 7 7 12 12)
-  (awt/drawLine 0 0 w h)])
-
-(fgp/deflookfn test-look (:theme :id :text)
-               [(fgp/call-look flatgui.skins.flat/component-look)
-                (awt/setColor (awt/color 255 0 0))
-                (awt/drawLine 0 0 w h)])
-
+  (awt/drawRoundRect (awt/+px 0 2) (awt/+px 0 2) (awt/-px w- 4) (awt/-px h- 4) 0.125)
+  (awt/drawString text 0.375 0.375)])

 (fg/defevolverfn cell-text-evolver :text
   (let [mc (get-property [:this] :model-coord)]
@@ -58,25 +45,21 @@
                  :text "?"
                  :evolvers {:text cell-text-evolver}}))

-(fg/defevolverfn :clip-size (get-property [] :clip-size))
+;(fg/defevolverfn :clip-size (get-property [] :clip-size))

 (fg/defevolverfn scroll-cs-evolver :clip-size
   (let [ win-size (get-property [] :clip-size)]
     (m/defpoint (- (m/x win-size) 0.25) (- (m/y win-size) 0.625))))

-(def table-component
-  (fg/defcomponent table/table :table
-    {:header-model-pos header-model-pos
-     :header-model-size header-model-size
-     :cell-prototype democell
-     :position-matrix m/identity-matrix
-     :clip-size (m/defpoint 1 1)
-     :background (awt/color 32 16 8)
-     :look test-look
-     :evolvers {:clip-size clip-size-evolver}}))
-
-(fg/defevolverfn scroll-contentsize-evolver :content-size
-  (get-property [:this :table] :content-size))
+(fg/defwidget "demotable"
+  {:header-model-pos header-model-pos
+   :header-model-size header-model-size
+   :cell-prototype democell
+   :position-matrix m/identity-matrix
+   ;:clip-size (m/defpoint 1 1)
+   :background (awt/color 32 16 8)
+   :evolvers {:clip-size scrollpanel/scrollpanelcontent-clip-size-evolver}} ;TODO bug: this evolver is not taken from scrollpanelcontent
+  scrollpanel/scrollpanelcontent table/table)

 (def table-window
   (fg/defcomponent window/window :table-window
@@ -88,5 +71,4 @@
       {:position-matrix (m/translation 0.125 0.5)
        :clip-size (m/defpoint 1 1)
        :evolvers {:clip-size scroll-cs-evolver}
-       :children {:content-pane (fg/defcomponent scrollpanel/scrollpanelcontent :content-pane {:evolvers {:content-size scroll-contentsize-evolver}
-                                                                                :children {:table table-component}})}})))+       :children {:content-pane (fg/defcomponent demotable :content-pane {})}})))


largest-series-product: Add a case where all spans contain 0

This is distinct from the existing case because there are nonzero digits
in this string as well.

--- largest-series-product/test/largest_series_product_test.clj
+++ largest-series-product/test/largest_series_product_test.clj
@@ -29,5 +29,6 @@
   (is (= 1 (lsp/largest-product 0 "123")))
   (is (thrown? Throwable (lsp/largest-product 1 "")))
   (is (thrown? Throwable (lsp/largest-product 4 "123")))
-  ;; edge case :)
+  ;; if all spans contain zero, result is zero.
+  (is (= 0 (lsp/largest-product 3 "99099")))
   (is (= 0 (lsp/largest-product 2 "00"))))


Tweak Midje autotest stuff

Tweak Midje autotest stuff

--- dev/user.clj
+++ dev/user.clj
@@ -38,6 +38,10 @@

 (comment

-  (do (autotest :stop) (autotest :filter (complement :slow)))
+  #_{:clj-kondo/ignore [:duplicate-require]} ; because we have copied this from a general place
+  (do (require 'midje.repl)
+      (midje.repl/autotest :stop)
+      (midje.repl/autotest :files "dev" "src" "test"
+                           :filter (complement :slow)))

   )


Add missing docstring

Add missing docstring

--- src/main/cljc/mikron/compiler/core.cljc
+++ src/main/cljc/mikron/compiler/core.cljc
@@ -13,6 +13,7 @@
             [mikron.compiler.processor.interp]))

 (defn compile-schema
+  "Returns a compiled schema for the given args."
   [& args]
   (let [{:keys [schema processor-types] :as opts}
         (util/enforce-spec ::core-specs/compile-schema-args args)


misc fixes

misc fixes

--- pigpen-cascading/src/main/clojure/pigpen/cascading/core.clj
+++ pigpen-cascading/src/main/clojure/pigpen/cascading/core.clj
@@ -108,9 +108,15 @@

 (s/defmethod command->flowdef :store
   [command :- m/Store
-   [{:keys [^Pipe pipe]}]
+   [{:keys [^Pipe pipe ancestor]}]
    ^FlowDef flowdef]
-  (let [^Tap sink (get-tap command)]
+  (let [^Tap sink (get-tap command)
+        fields (:fields ancestor)
+        ; The tap needs the incoming field name to match (without the namespace
+        ; added to all field symbols).
+        pipe (if-let [tap-fields (seq (map symbol (.getSinkFields sink)))]
+               (Rename. pipe (cfields fields) (cfields tap-fields))
+               pipe)]
     ;; side effect
     (.addTailSink flowdef pipe sink)
     nil))
@@ -190,7 +196,7 @@
   [{:keys [id projections fields]} :- m/Project
    [{:keys [^Pipe pipe ancestor]}]
    _]
-  (let [context (pr-str `'{:ancestor ~(update-in ancestor [:opts] dissoc :tap)
+  (let [context (pr-str `'{:ancestor ~(clojure.walk/postwalk #(if (map? %) (dissoc % :tap) %) ancestor)
                            :projections ~(prepare-projections projections)
                            :fields ~fields})]
     (case (:type ancestor)


simulate multiple random walks

simulate multiple random walks

--- src/sybil_graph/controllers/randomwalk.clj
+++ src/sybil_graph/controllers/randomwalk.clj
@@ -16,6 +16,23 @@
                   (randomwalk/clean-visited-flags graphName)
                   {:stepsTaken i :node currentNode})))))

+(defn get-nodes-by-factor
+  [nodes factor]
+  (let [nodeCount (int nodes)]
+    (cond
+      (= "log" factor) (Math/round (Math/log nodeCount))
+      :else (int (* (read-string factor) nodeCount)))))
+
 (defn simulate-randomwalk
   [params]
-  ())
+  (let [nodeCount (int (read-string (:nodes params)))
+        steps (get-nodes-by-factor nodeCount (:stepfactor params))
+        seedCount (int (read-string (:seeds params)))]
+    (loop [i 0
+           resultArray []]
+        (if (<= i seedCount)
+          (recur
+            (inc i)
+            (let [results (walk-n-steps (:graphName params) (rand-int nodeCount) steps)]
+              (conj resultArray {:steps (:stepsTaken results) :node (get-in results [:node :data])})))
+          resultArray))))


Prevent http requests on cache hit.

Prevent http requests on cache hit.

When the cache is hit, do not invoke any other middleware.
slurp the body as it is a stream that will be closed after being read by middleware.

--- examples/caching_middleware.clj
+++ examples/caching_middleware.clj
@@ -11,14 +11,16 @@
      (if (cache/has? @http-cache cache-key)
        (do
          (println "CACHE HIT")
-         (client req (reset! http-cache (cache/hit @http-cache cache-key)) nil ) )
+         (reset! http-cache (cache/hit @http-cache cache-key)) ; update cache stats
+         (cache/lookup @http-cache cache-key)) ; return cached value
+         ; do not invoke further middleware
        (do
          (println "CACHE MISS")
-         (let [resp (client req)]
+         (let [resp (update (client req) :body slurp)]
            (if (http/success? resp)
              (do
-               (reset! http-cache (cache/miss @http-cache cache-key resp))
-               (client req resp nil))
+               (reset! http-cache (cache/miss @http-cache cache-key resp)) ; update cache value
+               (client req resp nil)) ; invoke next middleware
              (do
                (client req resp nil)))))))))


A tentative solution to #157

A tentative solution to #157

--- src/midje/ideas/reporting/string_format.clj
+++ src/midje/ideas/reporting/string_format.clj
@@ -153,7 +153,7 @@
   (println ( (if (pos? (:fail-count result)) color/fail color/pass)
              (last (:lines result)))))

-(defn print-midje-summary-line [result]
+(defn- print-something-actually-happened-summary-results [result]
   (let [midje-failure-message (condp = (:fail result)
                                 0 (color/pass (format "All claims (%d) have been confirmed." (:pass result)))
                                 1 (str (color/fail "FAILURE:")
@@ -168,6 +168,15 @@

         midje-consolation (if (pos? (:fail result)) potential-consolation "")]
     (println midje-failure-message midje-consolation)))
+
+(defn print-nothing-was-tried-summary-results []
+  (println (color/note "No claims were checked. Is that what you wanted?")))
+
+(defn print-midje-summary-line [result]
+  (if (pos? (+ (:fail result) (:pass result)))
+    (print-something-actually-happened-summary-results result)
+    (print-nothing-was-tried-summary-results)))
+

 (defn report-strings-summary
   ([midje-result clojure-test-result]


Make aware of scroll the selrect component.

--- src/uxbox/ui/workspace/canvas/selrect.cljs
+++ src/uxbox/ui/workspace/canvas/selrect.cljs
@@ -69,11 +69,14 @@
               (reset! selrect-pos nil)))

           (init []
-            (as-> wb/interactions-b $
-              (rx/filter #(not= % :draw/selrect) $)
-              (rx/take 1 $)
-              (rx/take-until $ wb/mouse-s)
-              (rx/subscribe $ on-value nil on-complete)))]
+            (let [stoper (->> wb/interactions-b
+                              (rx/filter #(not= % :draw/selrect))
+                              (rx/take 1))
+                  pos (gpt/add @wb/mouse-a @wb/scroll-a)]
+              (reset! selrect-pos {:start pos :current pos})
+              (as-> wb/mouse-s $
+                (rx/take-until stoper $)
+                (rx/subscribe $ on-value nil on-complete))))]

     (as-> wb/interactions-b $
       (rx/dedupe $)


Started writing some documentation

Started writing some documentation

--- test/demo.cljs
+++ test/demo.cljs
@@ -64,17 +64,25 @@

 (defn simple-component []
   [:div
-   [:h3 "I am a component!"]
+   [:p "I am a component!"]
    [:p.someclass
     "I have " [:strong "bold"]
-    [:span {:style {:color "red"}} " and red "]
-    "text."]])
+    [:span {:style {:color "red"}} " and red "] "text."]])

-(defn demo-simple []
+(defn simple-parent []
   [:div
-   [:h2 "This is a simple component"]
-   [demo-component {:comp simple-component
-                    :defs [:ns :simple-component]}]])
+   [:p "I include simple-component."]
+   [simple-component]])
+
+(defn lister [props]
+  [:ul
+   (for [item (:items props)]
+     [:li "Item " item])])
+
+(defn lister-user []
+  [:div
+   "Here is a list:"
+   [lister {:items (range 3)}]])

 (defn calc-bmi [{:keys [height weight bmi] :as params}]
   (let [h (/ height 100)]
@@ -113,6 +121,32 @@
       [:span {:style {:color color}} diagnose]
       [slider {:value bmi :min 10 :max 50 :key :bmi :clear :weight}]]]))

+(defn intro []
+  [:div
+
+   [:p "Cloact provides a minimalistic interface between ClojureScript
+and React. It allows you to define React components using nothing but
+plain ClojureScript functions, that describe your UI using a
+Hiccup-like syntax."]
+
+   [:p "A very basic component may look something like this: "]
+   [demo-component {:comp simple-component
+                    :defs [:simple-component]}]
+
+   [:p "You can build new components using other components as
+   building blocks. That looks like this:"]
+   [demo-component {:comp simple-parent
+                    :defs [:simple-parent]}]
+
+   [:p "Data is passed to child components using a plain old Clojure
+   maps. For example, here is a component that shows items in a "
+   [:code "seq"] "." ]
+
+   [demo-component {:comp lister-user
+                    :defs [:lister :lister-user]}]
+   ])
+
+
 (defn bmi-demo []
   [:div
    [:h2 "Simple BMI calculator"]
@@ -123,6 +157,6 @@
 (defn demo []
   [:div
    [:h1 "This will become a demo"]
-   [demo-simple]
+   [intro]
    [bmi-demo]
    [:p "WIP"]])