Removing renamed file

Removing renamed file

--- src/intro/card-id-gen.clj
+++ src/intro/card-id-gen.clj
@@ -1,127 +0,0 @@
-(ns card-id-gen.core)
-
-(use 'clojure.stacktrace)
-
-(import 'java.security.NoSuchAlgorithmException)
-
-(import 'java.security.SecureRandom)
-
-(import 'java.lang.Math)
-
-(import 'java.lang.Integer)
-
-(import 'java.lang.Character)
-
-(def CHARS "0123456789BCDFGHJKLMNPQRSTVWXZ")
-
-(def ALPHA "BCDFGHJKLMNPQRSTVWXZ")
-
-(def NUMBERS "0123456789")
-
-(def VOWELS "AEIOUY")
-
-(def secureRandom (try
-
-                    (SecureRandom/getInstance "SHA1PRNG")
-
-                    (catch NoSuchAlgorithmException e
-                      (throw (RuntimeException. "error initializing" e)))))
-
-(defn getNextRandomString [length maxAdjacentAlphas]
-
-  (let [builder (StringBuilder.)]
-
-    (try
-      ;Generate a String of the desired length by randomly selecting characters from CHAR
-      ;and inserting them at random indexes after starting with a random char.
-      (let [num (Math/abs (.nextInt secureRandom))
-            retValue (atom (Integer/toString num 36))]
-
-        (while (< (.length @retValue) length)
-
-          (let [pos (.nextInt secureRandom (.length @retValue))
-                character (.charAt CHARS
-                                   (.nextInt secureRandom
-                                             (.length CHARS)))
-                pre (.substring @retValue 0 pos)
-                post (.substring @retValue pos)]
-
-            (swap! retValue (constantly (str pre character post)))))
-
-        ;Builds a new String out of the existing characters while ensuring that there
-        ;are no more successive alphabetic characters than specified in the params.
-        (let [charsSinceLastDigit (atom 0)]
-
-          (doseq [i (range 0 (.length @retValue))]
-
-            (let [curr (atom (.charAt @retValue i))]
-
-              (println "curr" @curr)
-
-              (if (Character/isDigit @curr)
-
-                (swap! charsSinceLastDigit (constantly 0))
-
-                (do
-                  (swap! charsSinceLastDigit inc)
-
-                  (cond
-                   (> @charsSinceLastDigit maxAdjacentAlphas)
-                   (swap! curr
-                          (constantly (.charAt NUMBERS (.nextInt secureRandom 9))))
-
-                   (< (. VOWELS (int @curr)) 0)
-                   (swap! curr
-                          (constantly (.charAt ALPHA (.nextInt secureRandom (.length ALPHA))))))))
-
-              (.append builder @curr)))))
-      (catch RuntimeException e (print-stack-trace e)))
-
-    (.toUpperCase (.toString builder))))
-
-
-
-(getNextRandomString 100 5)
-
-;A better implementation
-
-;Numbers and letters sans \O and \I
-(def allowedChars "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ")
-
-(defn randomChar [] (get allowedChars (rand-int 34)))
-
-(defn randomDigit [] (get allowedChars (rand-int 10)))
-
-(defn addNumber
-  "Returns the given sequence with the first letter replaced with a random digit."
-  [s]
-  (cons (randomDigit) (rest s)))
-
-(defn breakSequentialLetters
-  "Takes a list assumed to be full of letters
-  and breaks it up into lists of the size requested by params.
-  It then ensures each list of letters contains a digit."
-  [maxAdjacentAlphas c]
-  (if (> (count c) maxAdjacentAlphas)
-    (mapcat addNumber (partition-all (inc maxAdjacentAlphas) c))
-    c))
-
-(defn removeAdjacentAlphas
-  "Ensures the given seq does not contain more adjacent alphas than the param requests.
-  Returns a lazy seq."
-  [maxAdjacentAlphas c]
-  (->>
-   (partition-by #(Character/isLetter %) c)
-   (mapcat #(if (Character/isLetter (first %))
-              (breakSequentialLetters maxAdjacentAlphas %)
-              %))))
-
-(defn randomChars
-  "Returns a lazy seq pf random chars"
-  [] (repeatedly randomChar))
-
-(defn randomCharsWithMaxAdjacentAlphas [n]
-  (removeAdjacentAlphas n (randomString)))
-
-(apply str (take 8 (randomStringWithMaxAdjacentAlphas 3)))
-


Revert diff back to correct check

Revert diff back to correct check

--- test/onyx/log/accept_join_cluster_test.clj
+++ test/onyx/log/accept_join_cluster_test.clj
@@ -23,7 +23,7 @@
   (fact (get-in new-replica [:pairs :d]) => :b)
   (fact (get-in new-replica [:accepted]) => {})
   (fact (last (get-in new-replica [:peers])) => :d)
-  (fact diff => {:observer :b :subject :d})
+  (fact diff => {:observer :a :subject :d})
   (fact (rep-reactions old-replica new-replica diff {}) => nil))

 (let [entry (create-log-entry :accept-join-cluster


Up gen test.

Up gen test.

--- test/onyx/log/grouping_generative_test.clj
+++ test/onyx/log/grouping_generative_test.clj
@@ -194,7 +194,7 @@
               job-3
               (planning/discover-tasks (:catalog job-3) (:workflow job-3)))]
     (checking "The job is killed after a peer drops out of the grouping task."
-     100
+     1000
      [{:keys [replica log peer-choices]}
       (log-gen/apply-entries-gen
        (gen/return


lein-release plugin: preparing 0.1.1 release

--- backend/project.clj
+++ backend/project.clj
@@ -1,4 +1,4 @@
-(defproject lambdaui "0.1.1-SNAPSHOT"
+(defproject lambdaui "0.1.1"
   :description "LambdaCD-Plugin that provides a modern UI for your pipeline."
   :url "https://github.com/sroidl/lambda-ui"
   :license {:name "Apache License 2.0"


Test generation and navigation of a real scale on a TinkerGraph.

--- test/xn/graph/scale/core_test.clj
+++ test/xn/graph/scale/core_test.clj
@@ -1,7 +1,9 @@
 (ns xn.graph.scale.core-test
   (:use xn.graph.scale.core
         criterium.core)
-  (import java.math.BigDecimal)
+  (import java.math.BigDecimal
+          (com.tinkerpop.blueprints Graph Direction Edge Element Vertex)
+          com.tinkerpop.blueprints.impls.tg.TinkerGraph)
   (:require [clojure.test :refer [deftest is]]
             [clojure.test.check.clojure-test :refer [defspec]]
             [clojure.test.check :as tc]
@@ -92,6 +94,33 @@

+(let [g (TinkerGraph.)
+      v0 (generate-scale g -500 500 0.1M)
+      label (into-array String ["next_1"])
+      actual (loop [actual {} v v0]
+               (if v
+                 (recur (assoc actual (value v) v) (first (.getVertices v Direction/OUT label)))
+                 actual))]
+  (defspec
+    navagate-a-real-scale
+    1000
+    (prop/for-all
+      [[start offset tolerance] (->> (gen/tuple gen/int gen/int gen/ratio)
+                                     (gen/fmap
+                                       (fn [[s o t]]
+                                         (if (neg? t) [s o (- t)] [s o t])))
+                                     (gen/such-that
+                                       (fn [[s o t]]
+                                         (and (<= -500 s 500)
+                                              (<= -500 (+ s o (- t)) (+ s o t) 500)))))]
+      (let [start (BigDecimal. (str start))
+            s (actual start)
+            expected (actual (+ start offset))
+            tolerance (BigDecimal. (str (double tolerance)))
+            f (scale-range -500 500 0.1M (BigDecimal. (str offset)) tolerance tolerance)
+            r (f s)]
+        (is (some #{expected} r))))))
+

 (deftest inline-tests
   (test #'tests))


Support `optional-lens` in `clause-lens`.

--- src/active/clojure/match.clj
+++ src/active/clojure/match.clj
@@ -227,6 +227,8 @@
       (path-matches-clause? clause) path-matches-lens
       (key-exists-clause? clause)   key-exists-lens
       (path-exists-clause? clause)  path-exists-lens
+      (optional-clause? clause)     (lens/>> optional-clause-clause ((clause-lens key-matches-lens path-matches-lens key-exists-lens path-exists-lens)
+                                                                     (optional-clause-clause clause)))
       :else
       (c/assertion-violation `clause-lens "not a valid clause" clause))))

@@ -248,7 +250,7 @@

 (def path-lens
   "Returns a function that when applied to a clause, returns a lens focusing on
-  the matcher of the clause."
+  the path of the clause."
   (clause-lens key-matches-clause-key
                path-matches-clause-path
                key-exists-clause-key


Mention :test-selectors in sample.project.clj.

--- sample.project.clj
+++ sample.project.clj
@@ -47,6 +47,10 @@
   ;; Load these namespaces on startup to pick up hooks from
   ;; them. Hooks are generally included in plugins.
   :hooks [leiningen.hooks.difftest]
+  ;; Predicates to determine whether to run a test or not. See tutorial.
+  :test-selectors {:default (fn [t] (not (or (:integration v) (:regression v))))
+                   :integration :integration
+                   :regression :regression}
   ;; Set this to true to search the classpath for hooks. Will load all
   ;; namespaces matching leiningen.hooks.*. Warning: this will cause
   ;; Leiningen to start slowly, especially with many dependencies.


Improved diffing

Improved diffing

--- src/bluebell/utils/debug.clj
+++ src/bluebell/utils/debug.clj
@@ -44,8 +44,9 @@

 (defn explain-diff-maps [a b]
   (str "\nBoth are maps"
-       (let [ks (set (keys a))]
-         (if (= ks (set (keys b)))
+       (let [aks (set (keys a))
+             bks (set (keys b))]
+         (if (= aks bks)
            (str "\n with the same set of keys"
                 (let [f (first
                          (filter (complement :eq)
@@ -53,15 +54,14 @@
                                         (cmp-ab {:key k
                                                  :a (get a k)
                                                  :b (get b k)}))
-                                      ks)))]
+                                      aks)))]
                   (str "\nBut different values at "
                        (with-out-str
                          (clojure.pprint/pprint (:key f)))
                        "Compare them there:"
                        (explain-diff (:a f) (:b f)))))
-           (str "\n with different set of keys"
-                "\n  a: " (with-out-str (pp/pprint (sort (keys a))))
-                "\n  b: " (with-out-str (pp/pprint (sort (keys b)))))))))
+           (str "\n with different set of keys:"
+                (explain-diff aks bks))))))

 (defn explain-diff-sequentials [a b]


split long comment

split long comment

--- src/braid/client/events.cljs
+++ src/braid/client/events.cljs
@@ -64,7 +64,8 @@
   (-> content
       (string/replace util/sigiled-nickname-re
                       (fn [[m nick]]
-                        ; sometimes need leading whitespace, because javascript regex doesn't have lookbehind
+                        ; sometimes need leading whitespace, because javascript
+                        ; regex doesn't have lookbehind
                         (str (second (re-matches #"^(\s).*" m))
                              "@"
                              (if-let [user-id (:id (nickname->user state nick))]
@@ -74,7 +75,8 @@
                                    nick))))
       (string/replace util/sigiled-tag-name-re
                       (fn [[m tag-name]]
-                        ; sometimes need leading whitespace, because javascript regex doesn't have lookbehind
+                        ; sometimes need leading whitespace, because javascript
+                        ; regex doesn't have lookbehind
                         (str (second (re-matches #"^(\s).*" m))
                              "#" (or (name->open-tag-id state tag-name)
                                       tag-name))))))


Fix default exception footer link

Fix default exception footer link

--- src/yada/body.clj
+++ src/yada/body.clj
@@ -241,8 +241,9 @@
              [:pre s])))])

     [:div
-     [:p.footer [:span.yada
-          [:a {:href "https://yada.juxt.pro"} "yada"]]
+     [:p.footer
+      [:span.yada
+       [:a {:href "https://juxt.pro/yada"} "yada"]]
       " by "
       [:a {:href "https://juxt.pro"} "JUXT"]]]]))


fixed a small issue with unknown words when capitalized

--- src/ziad/pos.cljc
+++ src/ziad/pos.cljc
@@ -173,7 +173,8 @@
    exist in the model"
   [toks model]
   (map (fn [{:keys [word] :as tok-map}]
-         (if-not (get-in model [:word-model word])
+         (if-not (or (get-in model [:word-model word])
+                     (get-in model [:word-model (str/lower-case word)]))
            (assoc tok-map :unknown-word true)
            tok-map))
     toks))


remove terrible attempt at serialization

--- src/mediakeys/sockets.clj
+++ src/mediakeys/sockets.clj
@@ -11,37 +11,22 @@
         (tap mult return)
         return))

-(def channels (atom { }))
-(defn start! [conn channel]
-    (swap! channels assoc
-        (.toString conn) channel)
-    (print @channels))
-(defn stop! [conn]
-    (close! (@channels conn))
-    (swap! channels dissoc
-        (.toString conn))
-    (print @channels))
-
 (defn keypresses [incoming]
     (proxy [WebSocketHandler] []
         (onOpen [c]
             (let [channel (clone incoming)]
-                (dochan channel (send! c))
-                (start! c channel)))
+                (dochan channel (send! c))))
         (onClose [c]
-            (println "closed" c)
-            (stop! c))
+            (println "closed" c))
         (onMessage [c j] )))

 (defn controls [new-keys incoming-changes]
     (proxy [WebSocketHandler] []
         (onOpen [c]
             (let [channel (clone incoming-changes)]
-                (dochan channel (send! c))
-                (start! c channel)))
+                (dochan channel (send! c))))
         (onClose [c]
-            (println "closed changes" c)
-            (stop! c))
+            (println "closed changes" c))
         (onMessage [c message]
             (put! new-keys message))))

@@ -49,8 +34,6 @@
     (proxy [WebSocketHandler] []
         (onOpen [c]
            (let [channel (clone incoming-errors)]
-                (dochan channel (send! c))
-                (start! c channel)))
-        (onClose [c]
-            (stop! c))
+                (dochan channel (send! c))))
+        (onClose [c])
         (onMessage[c j])))


whoops, this shoud be cascade-delete :sob:

--- src/metabase/api/dash.clj
+++ src/metabase/api/dash.clj
@@ -63,7 +63,7 @@
   "Delete a `Dashboard`."
   [id]
   (write-check Dashboard id)
-  (del Dashboard :id id))
+  (cascade-delete Dashboard :id id))

 (defendpoint POST "/:id/cards"
   "Add a `Card` to a `Dashboard`."


baseline - something that works

baseline - something that works

--- src/om_tutorial/core.cljs
+++ src/om_tutorial/core.cljs
@@ -2,256 +2,111 @@
   (:require
     [goog.dom :as gdom]
     [om.next :as om :refer-macros [defui]]
-    [om.dom :as dom]
-    [cljs.pprint :as pprint]
-    [thosmos.core :as ts]
     [datascript.core :as d]
-    ;[shodan.console :as l :include-macros true]
-    )
+    [om.dom :as dom])
   (:require-macros
-    [cljs-log.core :as l :refer [debug info warn severe]])
-  )
+    [cljs-log.core :as l :refer [debug info warn severe]]))

 (enable-console-print!)

-(def conn
-  (d/create-conn
-    {:db/id          {:db/unique :db.unique/identity}
-     :db/ident       {:db/unique :db.unique/identity}
-     :list/items     {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many}
-     :dashboard/list {:db/valueType :db.type/ref :db/cardinality :db.cardinality/one}
-     :type           {:db/index true}
-     :content/type   {:db/index true}}))
+;; -----------------------------------------------------------------------------
+;; DB
+
+(def init-data (d/create-conn {:root  {:db/unique :db.unique/identity}
+                               :items {:db/valueType :db.type/ref :db/cardinality :db.cardinality/many}
+                               :current-user {:db/valueType :db.type/ref :db/cardinality :db.cardinality/one}
+                               :current-user/email {:db/unique :db.unique/identity}}))
+
+(d/transact! init-data
+  [{:db/id -1
+    :title "Foo"}
+   {:db/id -2
+    :title "Bar"}
+   {:db/id -3
+    :title "Baz"}
+   {:db/id -4
+    :email "bob.smith@gmail.com"}
+   {:root  "my app root"
+    :items [-1 -2 -3]
+    :current-user -4}])
+
+;; At this point, we could link the current-user entity to every item.
+;; But this is not a solution. We want to access the current-user entity
+;; by query-lookup and not via attribute we have to add to every item entity.

-(d/transact! conn
-  [{:db/id        -1
-    :type         :type/content
-    :content/type :blog/post
-    :author       "Laura Smith"
-    :title        "A Post!"
-    :content      "Lorem ipsum dolor sit amet, quem atomorum te quo"
-    :favorites    0}
-   {:db/id        -2
-    :type         :type/content
-    :content/type :asset/photo
-    :title        "A Photo!"
-    :image        "photo.jpg"
-    :caption      "Lorem ipsum"
-    :favorites    0}
-   {:db/id        -3
-    :type         :type/content
-    :content/type :blog/post
-    :author       "Jim Jacobs"
-    :title        "Another Post!"
-    :content      "Lorem ipsum dolor sit amet, quem atomorum te quo"
-    :favorites    0}
-   {:db/id        -4
-    :type         :type/content
-    :content/type :asset/graphic
-    :title        "Charts and Stufff!"
-    :image        "chart.jpg"
-    :favorites    0}
-   {:db/id        -5
-    :type         :type/content
-    :content/type :blog/post
-    :author       "May Fields"
-    :title        "Yet Another Post!"
-    :content      "Lorem ipsum dolor sit amet, quem atomorum te quo"
-    :favorites    0}
-   {:db/id      -6
-    :db/ident   :content/list
-    :type       :type/list
-    :list/title "A List of Various Media"
-    :list/items [-1 -2 -3 -4 -5]
-    :list/type  :type/content}
-   {:db/id           -7
-    :db/ident        :dashboard/root
-    :type            :type/app
-    :dashboard/title "The Root"
-    :dashboard/list  -6}])
-
-;(d/q '[:find [?e] :where [?e :content/type :blog/post]] (d/db conn))
-
-(debug "LOADING ...")
+;; -----------------------------------------------------------------------------
+;; read

 (defmulti read om/dispatch)

+
 (defmethod read :default
-  [{:keys [state query] :as env} k _]
-  (let [db (d/db state)]                                    ;; CACHING!!!
-    (l/debug "READ DEFAULT key" k)
-    (l/debug "READ DEFAULT query" query)
-    ;(debug (keys env))
-    ;(d/q '[:find [(pull ?e [*]) ...] :where [?e :type :type/content]] (d/db conn))
-    {:value nil}
-    ))
+  [{:keys [query state ast]} k _]
+  (let [p (js/console.log "read :default" k query)]
+    {:value :default-value})
+  )

-;;; assumed to be called with a query or :type lookup key, otherwise it would return everything in the DB
-(defmethod read :db/id
-  [{:keys [state query] :as env} key params]
-  (l/debug "READ DB/ID query" query)
-  (l/debug "READ DB/ID params" params)
-  {:value nil}
-)
+(defmethod read :items
+  [{:keys [query state ast]} k _]
+  (let [_ (debug "read :items" query)]
+    {:value
+     ;; Now comes the question - how to do this in datascript?
+     ;; simple datascript pull ? nope! -> [:current-user _] is not valid pull syntax
+     ;; (get (d/pull st [{k query}] [:root "my app root"]) k) is not a solution
+     ;; Solutions:
+     ;; - rewrite db->tree for use with datascript
+     ;; - rewirte d/pull to use the om.next patterns
+     ;; - ?
+     [{:db/id "1" :title "default value"}]}))

-;;; assumed to be called with a query or :type lookup key, otherwise it would return everything in the DB
-(defmethod read :db/ident
-  [{:keys [state query] :as env} key params]
-  (l/debug "DB/IDENT ast" (:ast env))
-  (l/debug "DB/IDENT query" query)
-  (l/debug "DB/IDENT params" params)
-  (let [value (d/pull (d/db state) query [:db/ident (:ident-ref params)])]
-    (debug "DB/IDENT result" value)
-    {:value value})
-  )
-;(if (contains? st k)
-;  {:value (get st k)}
-;  {:remote true})

-;(defmethod read :posts
-;  [{:keys [state query] :as env} k _]
-;  (let [db (d/db state)]                                    ;; CACHING!!!
-;    (debug "READ :posts query" query)
-;    (debug "env keys " (keys env))
-;
-;    (let [posts (d/q '[:find [(pull ?e ?query) ...] :in $ ?query :where [?e :content/type :blog/post]] (d/db conn) query)]
-;      (debug "query results:" posts)
-;      {:value posts})))
+;; -----------------------------------------------------------------------------
+;; Components
+
+(defui Item
+  static om/Ident
+  (ident [_ {:keys [:db/id]}] id)
+  static om/IQuery
+  (query [_]
+    '[:db/id :title [:current-user _]]) ;; NEW STUFF
+  Object
+  (render [this]
+    (let [{:keys [title current-user]} (om/props this)]
+      (dom/li nil
+        (dom/div nil title)
+        (dom/div nil (:email current-user))))))
+
+(def item (om/factory Item))
+
+(defui ItemTwo
+  static om/IQuery
+  (query [_]
+    '[:db/id :title])
+  Object
+  (render [this]
+    (let [{:keys [:db/id title]} (om/props this)]
+      (dom/li nil
+        (dom/div nil (str id " - " title))))))
+
+(defui SomeList
+  static om/IQuery
+  (query [_]
+    [{:items (om/get-query ItemTwo)}])
+  Object
+  (render [this]
+    (dom/div
+      (dom/h2 nil "A List!")
+      (dom/ul nil
+        (map (om/factory ItemTwo) (-> this om/props :items))
+        ))))
+
+;; -----------------------------------------------------------------------------
+;; Setup

 (def reconciler
   (om/reconciler
-    {:state  conn
-     ;:normalize true
+    {:state init-data
      :parser (om/parser {:read read})}))
-;:send      (util/transit-post "/api")

-
-(defui Post
-  static om/Ident
-  (ident [this {:keys [:db/id] :as props}]
-    (let [_ (debug "Post Ident" id "params:" props)]
-      id))
-  static ts/ITypeKey
-  (type-key [this] {:content/type :blog/post})
-  static om/IQuery
-  (query [this]
-    ;'[*]
-    [:db/id :type :content/type :title :author :content])
-  Object
-  (render [this]
-    (let [query (om/get-query Post)
-          {:keys [title] :as props} (om/props this)]
-      (l/debug "Post props" props)
-      (l/debug "Post query" query)
-      (dom/div nil title
-        (dom/ul nil
-          (for [prop props]
-            (dom/li nil
-              (str (key prop) ": " (val prop)))))
-
-        ))))
-
- (defui Photo
-   static om/Ident
-   (ident [this {:keys [:db/id]}] id)
-   static ts/ITypeKey
-   (type-key [this] {:content/type :asset/photo})
-   static om/IQuery
-   (query [this]
-     [:db/id :type :title :image :caption])
-   Object
-   (render [this]
-     (dom/div nil "Photo")))
-
- (defui Graphic
-   static om/Ident
-   (ident [this {:keys [:db/id]}] id)
-   static ts/ITypeKey
-   (type-key [this] {:content/type :asset/graphic})
-   static om/IQuery
-   (query [this]
-     [:db/id :type :title :image])
-   Object
-   (render [this]
-     (dom/div nil "Graphic")))
-
- (defui ItemList
-   ;static om/Ident
-   ;(ident [this props] [:db/ident :content/list])
-   ;static ts/ITypeKey
-   ;(type-key [this] {:type :type/list})
-   ;static ts/ICollTypeKey
-   ;(coll-key [this] :content/type)
-   ;static om/IQueryParams
-   ;(params [this] {:id-ref nil})
-   static om/IQuery
-   (query [this]
-     ;[:db/id :list/title {:list/items (ts/get-union (with-meta [Post Photo Graphic] {:coll-key (ts/get-coll-key this)}) [:favorites])}]
-     `[
-       ;({:db/id [:db/id :list/title]} {:id-ref ?id-ref})
-      {:list/items
-       ;(ts/get-union )
-       {:post    ~(om/get-query Post)
-        :photo   ~(om/get-query Photo)
-        :graphic ~(om/get-query Graphic)}}])
-   Object
-   (render [this]
-     (dom/div nil
-       (get (om/props this) :list/title)
-       ;(ts/render this :list/items)
-       )))
-
- (defui Dashboard
-   static om/Ident
-   (ident [this props] [:db/ident :dashboard/root])
-   static om/IQuery
-   (query [this]
-     `[({:db/ident [:dashboard/title]} {:ident-ref :dashboard/root}) {:list/items ~(om/get-query ItemList)}])
- ;{:dashboard/list (ts/get-query ItemList)}
-   Object
-   (render [this]
-     (dom/div nil
-       (dom/div nil "TypeKey experiment")
-       (dom/br nil nil)
-       (dom/div nil (get-in (om/props this) [:db/ident :dashboard/title])))))
-       ;(ts/render this ItemList)
-
- (def dashboard (om/factory Dashboard))
-
-(defui App
-  static om/IQuery
-  (query [this]
-    [{:posts (om/get-query Post)}])
-  Object
-  (render [this]
-    (let [posts (:posts (om/props this))]
-      (dom/div nil
-        (dom/div nil "TypeKey experiment")
-        (dom/br nil nil)
-        ((om/factory ItemList))
-        (debug "ItemList QUERY" (om/get-query ItemList))
-        ;(for [post posts] ((om/factory Post) post))
-        ))))
-;(dashboard)
-; (js/console.log "component?"))))
-; (om/component?
-;   (om/factory Post))))))
-;(dashboard {:dashboard/title "yes"}))))))
-
-(def app (om/factory App))
-
-(om/add-root! reconciler Dashboard (gdom/getElement "app"))
-
-
-;(defui Campaign
-;  static om/Ident
-;  (ident [this {:keys [id]}] [:db/id id])
-;  static ts/ITypeKey
-;  (type-key [this] :dt/type)
-;  static om/IQuery
-;  (query [this]
-;    [:db/id :dt/type :c/name :c/desc :c/goal])
-;  Object
-;  (render [this]
-;    (dom/div nil "Campaign")))
+(om/add-root! reconciler SomeList (gdom/getElement "app"))


Add hiccup dependency

Add hiccup dependency

--- src/orbitingnews/core.clj
+++ src/orbitingnews/core.clj
@@ -2,6 +2,7 @@
   (:use compojure.core)
   (:use org.httpkit.server)
   (:use org.httpkit.timer)
+  (:use hiccup.core)
   (:require [org.httpkit.client :as http]
             [compojure.route :as route]
             [orbitingnews.config :as config]
@@ -42,6 +43,10 @@
   (let [tweets (map #(.getText %) (twitter/search "#clojurecup"))]
     (dom/html (tweets-page tweets))))

+(defn home []
+  (html [:span {:class "foo"} "bar"])
+)
+
 (defroutes app-routes
   (GET "/" [] root-handler)
   (GET "/ws" [] handler))


more logging in elephantdb loading

more logging in elephantdb loading

--- src/clj/elephantdb/shard.clj
+++ src/clj/elephantdb/shard.clj
@@ -1,5 +1,5 @@
 (ns elephantdb.shard
-  (:use [elephantdb util config])
+  (:use [elephantdb util config log])
   (:import [elephantdb Utils]))

 (defstruct shard-index ::hosts-to-shards ::shards-to-hosts)
@@ -12,6 +12,7 @@

 (defn compute-host-to-shards [domain hosts numshards replication]
+  (log-message "host to shards" domain hosts numshards replication)
   (when (> replication (count hosts))
     (throw (IllegalArgumentException. "Replication greater than number of servers")))
   (let [shards (repeat-seq replication (range numshards))
@@ -20,20 +21,23 @@
     ))

 (defn shard-domain [domain hosts numshards replication]
+  (log-message "sharding domain " domain hosts numshards replication)
   (let [hosts-to-shards (compute-host-to-shards domain hosts numshards replication)]
       (struct shard-index hosts-to-shards (map-mapvals set (reverse-multimap hosts-to-shards)))
     ))

 (defn shard-domains [fs global-config]
+  (log-message "shard-domains" global-config)
   (into {}
-    (dofor [[domain remote-location] (:domains global-config)]
-      (let [domain-spec (read-domain-spec fs remote-location)]
-        [domain (shard-domain
-                  domain
-                  (:hosts global-config)
-                  (:num-shards domain-spec)
-                  (:replication global-config))]
-          ))))
+        (dofor [[domain remote-location] (:domains global-config)]
+               (let [domain-spec (read-domain-spec fs remote-location)]
+                 (println "shard-domains domain-spec" domain-spec)
+                 [domain (shard-domain
+                          domain
+                          (:hosts global-config)
+                          (:num-shards domain-spec)
+                          (:replication global-config))]
+                 ))))

 (defn host-shards [index host]
   ((::hosts-to-shards index) host))


adjust core to db connection

adjust core to db connection

--- src/clj/lesezeichen/core.clj
+++ src/clj/lesezeichen/core.clj
@@ -28,21 +28,22 @@
     (catch Exception e "FAILED")))

-(defn fetch-url-title [url]
+(defn fetch-url-title
   "fetch url and extract title"
+  [url]
   (let [res (fetch-url url)]
     (if (= "FAILED" res)
       url
-      (-> res
-       (enlive/select [:head :title])
-       first
-       :content
-       first))))
+      (-> res (enlive/select [:head :title]) first :content first))))
+

 (defn dispatch [{:keys [topic data]}]
   (case topic
-    :get-user-bookmarks {:topic topic :data (get-user-bookmarks data)}
-    :add-bookmark {:topic topic :data (add-bookmark (assoc data :title (fetch-url-title (:url data))))}
+    :get-user-bookmarks {:topic topic
+                         :data (get-user-bookmarks (:conn @server-state) data)}
+    :add-bookmark {:topic topic
+                   :data (add-bookmark (:conn @server-state)
+                                       (assoc data :title (fetch-url-title (:url data))))}
     {:topic :error :data :unknown-request}))

@@ -68,30 +69,30 @@
   state)

+(defn init-db [state]
+  (swap! state #(assoc %1 :conn %2) (db-conn))
+  state)
+
 (defn init
   "Read in config file, create sync store and peer"
   [state path]
-  (-> state (read-config path)))
-
-
-(defn start-server [port]
-  (do
-    (run-server (site #'handler) {:port port :join? false})))
+  (-> state
+      (read-config path)
+      init-db))

 (defn -main [& args]
   (init server-state (first args))
   (init-schema (:schema @server-state))
-  (start-server (:port @server-state)))
+  (run-server (site #'handler) {:port (:port @server-state) :join? false}))

 (comment

   (init server-state "resources/server-config.edn")

+  ;; on first startup initialize datomic schema
   (init-schema (:schema @server-state))
-
-  (add-user {:email "eve@topiq.es"})

   (def server (start-server (:port @server-state)))


Added units indicator.

Added units indicator.

--- src/cljs/clj_forms/core.cljs
+++ src/cljs/clj_forms/core.cljs
@@ -27,7 +27,7 @@

 (defn weight-form
   [weight-atom]
-  (input-and-prompt "Weight:" "weight" "number" weight-atom [prompt-message "What's your weight?"]))
+  (input-and-prompt "Weight(lbs):" "weight" "number" weight-atom [prompt-message "What's your weight?"]))

 (defn home-page []
   (let [weight (atom nil)]


Clear dummy user data

Clear dummy user data

--- src/cljs/geoforms/forms.cljs
+++ src/cljs/geoforms/forms.cljs
@@ -73,11 +73,7 @@
 ;; forms

 (defonce user-doc
-  (atom {:person {:first-name       "Blake"
-                  :last-name        "Hake"
-                  :email            "blake@hake.fake.com"
-                  :age              :18-24
-                  :alert-ideas?     true
+  (atom {:person {:alert-ideas?     true
                   :alert-volunteer? true
                   :alert-districts? true}}))


resolve references in catalog

resolve references in catalog

--- src/cljs_api_gen/catalog.clj
+++ src/cljs_api_gen/catalog.clj
@@ -1,6 +1,24 @@
 (ns cljs-api-gen.catalog
   (:require
-    [me.raynes.fs :refer [mkdir exists?]]
+    [me.raynes.fs :refer [mkdir]]
+    [cljs-api-gen.config :refer [docs-repo-dir
+                                 *output-dir*]]
+    [cljs-api-gen.parse :refer [*repo-version*
+                                parse-all]]
+    [cljs-api-gen.repo-cljs :refer [clone-or-fetch-repos
+                                    get-versions-to-parse
+                                    verify-docs-repo-sync!
+                                    checkout-version!
+                                    get-repo-version
+                                    cljs-tag->version]]
+    [cljs-api-gen.repo-docs :refer [prepare-docs-repo!
+                                    clear-docs-repo!
+                                    commit-docs-repo!]]
+    [cljs-api-gen.history :refer [get-symbol-history
+                                  update-history!
+                                  attach-history-to-items]]
+    [cljs-api-gen.write :refer [dump-api-docs!]]
+
     ))

 (defn create-catalog!


Work on island-fn

Work on island-fn

--- src/cljx/robinson/prism.cljx
+++ src/cljx/robinson/prism.cljx
@@ -132,26 +132,27 @@
 (defn sample-island
   [n x y]
   (let [c  ((coerce (scale 4.3 (offset (vnoise n) (radius)))) x y)
-        c1 ((coerce (offset [0.5 0.5] (s+ -0.5 (scale 0.6 (noise n))))) x y)
-        c2 ((coerce (offset [-110.5 -640.5] (s+ -0.5 (scale 0.8 (noise n))))) x y)]
+        c1 ((coerce (s+ -0.5 (offset [0.5 0.5] (scale 0.6 (noise n))))) x y)
+        c2 ((coerce (s+ -0.5 (offset [-110.5 -640.5] (scale 0.8 (noise n))))) x y)
+        cgt (> c1 c2)]
     (cond
       ;; interior biomes
       (> 0.55  c)
         (cond
-          (and (pos? c1) (pos? c2) (> c1 c2))
+          (and (pos? c1) (pos? c2) cgt)
           ;; interior jungle
           :jungle
           (and (pos? c1) (pos? c2))
           :heavy-forest
-          (and (pos? c1) (neg? c2) (> c1 c2))
+          (and (pos? c1) (neg? c2) cgt)
           :light-forest
           (and (pos? c1) (neg? c2))
           :bamboo-grove
-          (and (neg? c1) (pos? c2) (> c1 c2))
+          (and (neg? c1) (pos? c2) cgt)
           :meadow
           (and (neg? c1) (pos? c2))
           :rocky
-          (and (neg? c1) (neg? c2) (> c1 c2))
+          (and (neg? c1) (neg? c2) cgt)
           :swamp
           :else
           :dirt)


Refactor for readability

Refactor for readability

--- src/clojars/routes/group.clj
+++ src/clojars/routes/group.clj
@@ -1,90 +1,98 @@
 (ns clojars.routes.group
-  (:require [clojars
-             [auth :as auth]
-             [db :as db]]
-            [clojars.web.group :as view]
-            [compojure.core :as compojure :refer [GET POST DELETE]]))
+  (:require
+   [clojars.auth :as auth]
+   [clojars.db :as db]
+   [clojars.web.group :as view]
+   [compojure.core :as compojure :refer [GET POST DELETE]]))
+
+(defn- get-members [db groupname]
+  (let [actives (seq (db/group-actives db groupname))]
+    (when (seq actives)
+      (auth/try-account
+        #(view/show-group db % groupname actives)))))
+
+(defn- toggle-or-add-member [db groupname username make-admin?]
+  (let [actives (seq (db/group-actives db groupname))
+        membernames (->> actives
+                      (filter (complement view/is-admin?))
+                      (map :user))
+        adminnames (->> actives
+                     (filter view/is-admin?)
+                     (map :user))]
+    (when (seq actives)
+      (auth/try-account
+        (fn [account]
+          (auth/require-admin-authorization
+            db
+            account
+            groupname
+            (if make-admin?
+              #(cond
+                 (= account username)
+                 (view/show-group db account groupname actives
+                   "Cannot change your own membership!")
+
+                 (some #{username} adminnames)
+                 (view/show-group db account groupname actives
+                   "They're already an admin!")
+
+                 (db/find-user db username)
+                 (do (db/add-admin db groupname username account)
+                     (view/show-group db account groupname
+                       (into (remove (fn [active] (= username (:user active))) actives) [{:user username :admin true}])))
+
+                 :else
+                 (view/show-group db account groupname actives
+                   (str "No such user: "
+                     username)))
+              #(cond
+                 (= account username)
+                 (view/show-group db account groupname actives
+                   "Cannot change your own membership!")
+
+                 (some #{username} membernames)
+                 (view/show-group db account groupname actives
+                   "They're already a member!")
+
+                 (db/find-user db username)
+                 (do (db/add-member db groupname username account)
+                     (view/show-group db account groupname
+                       (into (remove (fn [active] (= username (:user active))) actives) [{:user username :admin false}])))
+
+                 :else
+                 (view/show-group db account groupname actives
+                   (str "No such user: "
+                     username))))))))))
+
+(defn- remove-member [db groupname username]
+  (let [actives (seq (db/group-actives db groupname))]
+    (when (seq actives)
+      (auth/try-account
+        (fn [account]
+          (auth/require-admin-authorization
+            db
+            account
+            groupname
+            #(cond
+               (= account username)
+               (view/show-group db account groupname actives
+                 "Cannot remove yourself!")
+
+               (some #{username} (map :user actives))
+               (do (db/inactivate-member db groupname username account)
+                   (view/show-group db account groupname
+                     (remove (fn [active] (= username (:user active))) actives)))
+
+               :else
+               (view/show-group db account groupname actives
+                 (str "No such member: "
+                   username)))))))))

 (defn routes [db]
   (compojure/routes
-   (GET ["/groups/:groupname", :groupname #"[^/]+"] [groupname]
-     (let [actives (seq (db/group-actives db groupname))]
-        (when (seq actives)
-          (auth/try-account
-           #(view/show-group db % groupname actives)))))
-   (POST ["/groups/:groupname", :groupname #"[^/]+"] [groupname username admin]
-     (let [make-admin? (= "1" admin)
-           actives (seq (db/group-actives db groupname))
-           membernames (->> actives
-                            (filter (complement view/is-admin?))
-                            (map :user))
-           adminnames (->> actives
-                           (filter view/is-admin?)
-                           (map :user))]
-       (when (seq actives)
-           (auth/try-account
-             (fn [account]
-               (auth/require-admin-authorization
-                 db
-                 account
-                 groupname
-                 (if make-admin?
-                   #(cond
-                      (= account username)
-                      (view/show-group db account groupname actives
-                        "Cannot change your own membership!")
-
-                      (some #{username} adminnames)
-                      (view/show-group db account groupname actives
-                        "They're already an admin!")
-
-                      (db/find-user db username)
-                      (do (db/add-admin db groupname username account)
-                        (view/show-group db account groupname
-                          (into (remove (fn [active] (= username (:user active))) actives) [{:user username :admin true}])))
-
-                      :else
-                      (view/show-group db account groupname actives
-                        (str "No such user: "
-                          username)))
-                   #(cond
-                      (= account username)
-                      (view/show-group db account groupname actives
-                        "Cannot change your own membership!")
-
-                      (some #{username} membernames)
-                      (view/show-group db account groupname actives
-                        "They're already a member!")
-
-                      (db/find-user db username)
-                      (do (db/add-member db groupname username account)
-                        (view/show-group db account groupname
-                          (into (remove (fn [active] (= username (:user active))) actives) [{:user username :admin false}])))
-
-                      :else
-                      (view/show-group db account groupname actives
-                        (str "No such user: "
-                          username))))))))))
-   (DELETE ["/groups/:groupname", :groupname #"[^/]+"] [groupname username]
-     (let [actives (seq (db/group-actives db groupname))]
-       (when (seq actives)
-           (auth/try-account
-             (fn [account]
-               (auth/require-admin-authorization
-                 db
-                 account
-                 groupname
-                 #(cond
-                    (= account username)
-                    (view/show-group db account groupname actives
-                      "Cannot remove yourself!")
-
-                    (some #{username} (map :user actives))
-                    (do (db/inactivate-member db groupname username account)
-                      (view/show-group db account groupname
-                        (remove (fn [active] (= username (:user active))) actives)))
-
-                    :else
-                    (view/show-group db account groupname actives
-                      (str "No such member: "
-                        username)))))))))))
+    (GET ["/groups/:groupname", :groupname #"[^/]+"] [groupname]
+      (get-members db groupname))
+    (POST ["/groups/:groupname", :groupname #"[^/]+"] [groupname username admin]
+      (toggle-or-add-member db groupname username (= "1" admin)))
+    (DELETE ["/groups/:groupname", :groupname #"[^/]+"] [groupname username]
+      (remove-member db groupname username))))


Reconstruct proto object using clj->proto

--- src/clojure_fabric/proto.clj
+++ src/clojure_fabric/proto.clj
@@ -293,7 +293,8 @@
   (clj->proto [this]
     (-> (Configtx$ConfigValue/newBuilder)
         (.setVersion version)
-        (.setValue value)
+        (.setValue (with-default-empty-byte-string [value]
+                     value))
         (.setModPolicy mod-policy)
         (.build))))

@@ -331,16 +332,17 @@
   (clj->proto [this]
     (-> (Configtx$ConfigGroup/newBuilder)
         (.setVersion version)
-        (.putAllGroups groups)
-        (.putAllValues values)
-        (.putAllPolicies policies)
+        (.putAllGroups (utils/map-vals #(clj->proto %) groups))
+        (.putAllValues (utils/map-vals #(clj->proto %) values))
+        (.putAllPolicies (utils/map-vals #(clj->proto %) policies))
         (.setModPolicy mod-policy)
         (.build))))

 (defn make-config-group
-  [& {:keys [version groups values poilices mod-policy]}]
+  [& {:keys [version groups values policies mod-policy]
+      :or {groups {} values {} policies {}}}]
   (map->ConfigGroup {:version version :groups groups :values values
-                     :poilices poilices :mod-policy mod-policy}))
+                     :policies policies :mod-policy mod-policy}))

 (defrecord ConfigUpdate [channel-id read-set write-set type isolated-data]
   ICljToProto
@@ -354,7 +356,8 @@
         (.build))))

 (defn make-config-update
-  [& {:keys [channel-id read-set write-set type isolated-data]}]
+  [& {:keys [channel-id read-set write-set type isolated-data]
+      :or {isolated-data {}}}]
   (map->ConfigUpdate {:channel-id channel-id :read-set read-set
                       :write-set write-set :type type
                       :isolated-data isolated-data}))
@@ -522,7 +525,8 @@
     (make-config-group :version (.getVersion this)
                        :groups (utils/map-vals #(proto->clj % nil) (.getGroups this))
                        :values (utils/map-vals #(proto->clj % nil) (.getValues this))
-                       :poilices (utils/map-vals #(proto->clj % nil) (.getPolicies this))
+                       :policies (or (utils/map-vals #(proto->clj % nil) (.getPolicies this))
+                                     {})
                        :mod-policy (.getModPolicy this)))

   Configtx$ConfigUpdate


Removed unused code.

Removed unused code.

--- src/cmr/opendap/ous/core.clj
+++ src/cmr/opendap/ous/core.clj
@@ -58,41 +58,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;   Utility/Support Functions   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-;; XXX This next horrible function was created to replace the subsets.forEach
-;; call made at the end of processVariable in the ous.js file. Peter L. Smith
-;; had this to say, after I commented/asked about it's somewhat anti-intuitive
-;; behaviour:
-;;    "The code in the forEach just computes the indices into the data
-;;     arrays when start/end lat or long values are provided, and yep -
-;;     if you specify multiple lat (or long) pairs, it will effectively
-;;     just take the last."
-
-(defn spatial-subset->arrays
-  [subset]
-  )
-
-(defn ->pixels
-  [{x-dim :x y-dim :y} [lon-lo lat-lo lon-hi lat-hi]]
-  (let [x-pixel-size (/ (- lon-hi lon-lo) x-dim)
-        y-pixel-size (/ (- lat-hi lat-lo) y-dim)]
-    ;; XXX Note that the x and y offsets were added here simply due to the
-    ;;     fact that these were defined in the Node.js version; upon closer
-    ;;     inspection of the Node code, it seems that these values were
-    ;;     never actually used ... let's come back and clean this up, once
-    ;;     the port has been completed.
-    ;; XXX Followup: x and y pixel sizes are only ever used in the Node.js code
-    ;;     when calculating the offsets, and those were never used ... so maybe
-    ;;     we can delete this whole function?
-    {:x {:pixel-size x-pixel-size
-         :offset (Math/floor (/ lon-lo x-pixel-size))}
-     :y {:pixel-size y-pixel-size
-         :offset (Math/floor (/ lat-lo y-pixel-size))}}))
-
-(defn bounding-info->pixels
-  [bounding-info]
-  (map #(->pixels (:dimensions %) (:bounds %)) bounding-info))
-

 (defn bounding-info->opendap-lat-lon
   [{var-name :name opendap-bounds :opendap}]


Update popovers.cljs

Update popovers.cljs

Fixed reference to popover-body-wrapper

--- src/re_demo/popovers.cljs
+++ src/re_demo/popovers.cljs
@@ -123,7 +123,7 @@
                                               [:li [:code ":position"] " - A keyword specifying the popover's position relative to the anchor. See the demo to the right for the values."]
                                               [:li [:code ":anchor"] " - The anchor component to wrap."]
                                               [:li [:code ":popover"] " - The popover body component (what gets shown in the popover)."]]]
-                                            [p "You should use the " [:code "popover-body-wrapper"] " component to wrap the body content. The main arguments are:"
+                                            [p "You should use the " [:code "popover-content-wrapper"] " component to wrap the body content. The main arguments are:"
                                              [:ul
                                               [:li [:code ":title"] " - Title of the popover. Can be ommitted."]
                                               [:li [:code ":close-button?"] " - Add close button in the top right. Default is true."]


Forgot to rename conexp.tests.layouts

Forgot to rename conexp.tests.layouts

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

--- src/conexp/tests/layouts.clj
+++ src/conexp/tests/layouts.clj
@@ -6,7 +6,7 @@
 ;; the terms of this license.
 ;; You must not remove this notice, or any other, from this software.

-(ns conexp.tests.layout
+(ns conexp.tests.layouts
   (:use conexp.base))

 ;;;


Move cosm loading into cosm-list will-mount

--- src/core/cljs/virt/core.cljs
+++ src/core/cljs/virt/core.cljs
@@ -59,6 +59,12 @@

 (defn cosm-list [app owner]
   (reify
+    om/IWillMount
+    (will-mount [_]
+      (go
+        (let [response (<! (http/get "/api/cosms"))
+              body (:body response)]
+          (om/update! app body))))
     om/IRenderState
     (render-state [_ {:keys [comm]}]
       (dom/div #js {:id "cosm-content"}
@@ -87,11 +93,4 @@
         (dom/div #js {:id "content"}
           (om/build cosm-list app {:init-state {:comm comm}}))))))

-(defn init-page []
-  (go
-    (let [response (<! (http/get "/api/cosms"))
-          body (:body response)]
-      (reset! app-state body)
-      (om/root main app-state {:target (.getElementById js/document "app")}))))
-
-(init-page)
+(om/root main app-state {:target (.getElementById js/document "app")})


Fix errors

Fix errors

--- src/cyanite_fetcher/core.clj
+++ src/cyanite_fetcher/core.clj
@@ -227,8 +227,8 @@
           rreduce-fdata (flatter data (fn [data] (r/reduce into [] data)) "r/reduce")
           flatten-fdata (flatter data (fn [data] (flatten data)) "flatten")
           rflatten-fdata (flatter data (fn [data] (into [] (r/flatten data))) "r/flatten")
-          remove-cdata (cleaner (fn [data] (remove nil? data)) reduce-fdata "remove")
-          rremove-cdata (cleaner (fn [data] (r/remove nil? data)) reduce-fdata)]) "r/remove")
+          remove-cdata (cleaner reduce-fdata (fn [data] (remove nil? data))  "remove")
+          rremove-cdata (cleaner reduce-fdata (fn [data] (r/remove nil? data)) "r/remove")])
   (println "Finish time:" (tl/format-local-time (tl/local-now) :rfc822)))

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


fix last-txes

fix last-txes

--- src/datomic/dodc/repl_ui.clj
+++ src/datomic/dodc/repl_ui.clj
@@ -202,7 +202,7 @@
   ([conn n]
      (let [db (d/db conn)
            e->ident (e->ident-map db)
-           t (- (:t db) n)]
+           t (max 0 (- (:t db) n))]
        (into
         []
         (comp (map :tx-data) cat (map #(identify % e->ident)))


make a change but it's making things slow

--- src/degasolv/pkgsys/core.clj
+++ src/degasolv/pkgsys/core.clj
@@ -49,11 +49,14 @@
                   (fn merg [c v]
                     (update-in c [(:id v)] conj v))
                   initial-repository
-                  (map
-                    read-card!
+                  (->> search-directory
+                    (io/file)
+                    (file-seq)
                     (filter #(and (.isFile ^java.io.File (io/file %))
-                                  (= "dscard" (st/replace % #"[^.]*[.]" "")))
-                            (file-seq (io/file search-directory))))))))))
+                                  (= "dscard" (st/replace % #"[^.]*[.]" ""))))
+                    (map (fn [^java.io.File f] (.getAbsolutePath f)))
+                    (map read-card!)
+                           )))))))

 (defn slurp-degasolv-repo
   [url]


allow specifying root-key on server-side render

--- src/rum/server_render.clj
+++ src/rum/server_render.clj
@@ -214,8 +214,10 @@
   (-render-html [this parent path]
     ""))

-(defn render-html [src]
-  (let [result   (-render-html src nil ["." 0])
-        checksum (Adler32/calc result)]
-    (str/replace-first result ">"
-      (str " data-react-checksum=\"" checksum "\">"))))
+(defn render-html
+  ([src] (render-html src nil))
+  ([src opts]
+    (let [result   (-render-html src nil ["." (:root-key opts 0)])
+          checksum (Adler32/calc result)]
+      (str/replace-first result ">"
+        (str " data-react-checksum=\"" checksum "\">")))))


Remove double background from buttons

Remove double background from buttons

--- src/airhead_frontend/components.cljs
+++ src/airhead_frontend/components.cljs
@@ -93,12 +93,12 @@
 (defn playlist-add-button [track]
   [:button.pure-button.track-action
    {:on-click #(req/playlist-add! (:uuid track))}
-   [:i.fa.fa-plus-square]])
+   [:i.fa.fa-plus]])

 (defn playlist-remove-button [track]
   [:button.pure-button.track-action
    {:on-click #(req/playlist-remove! (:uuid track))}
-   [:i.fa.fa-minus-square]])
+   [:i.fa.fa-minus]])

 (defn track-tr [track action-button]
   [:tr.track


Make run-code side-effect-less, so that ajax and static can both insert only the side effects they need

--- src/foreclojure/problems.clj
+++ src/foreclojure/problems.clj
@@ -154,31 +154,40 @@
         (doall (take-while (complement #{end})
                            (repeatedly #(read *in* false end))))))))

-(defn run-code [id raw-code]
-  (let [code (.trim raw-code)
-        {:keys [tests restricted] :as problem} (get-problem id)
-        sb-tester (get-tester restricted)]
-    (session/flash-put! :code code)
-    (try
-      (let [user-forms (s/join " " (map pr-str (read-string-safely code)))]
-        (if (empty? user-forms)
-          ["Empty input is not allowed" *url*]
-          (loop [[test & more] tests
-                 i 0]
-            (session/flash-put! :failing-test i)
-            (if-not test
-              (mark-completed problem code)
-              (let [testcase (s/replace test "__" user-forms)]
-                (if (sb sb-tester (first (read-string-safely testcase)))
-                  (recur more (inc i))
-                  ["You failed the unit tests." *url*]
-                  ))))))
-      (catch Exception e
-        [(.getMessage e) *url*]))))
+(defn run-code
+  "Run the specified code-string against the test cases for the problem with the
+specified id.
+
+Return a vector of [message-to-display url-to-display-at num-tests-passed]."
+  [id raw-code]
+  (try
+    (let [code (.trim raw-code)
+          {:keys [tests restricted] :as problem} (get-problem id)
+          sb-tester (get-tester restricted)
+          user-forms (s/join " " (map pr-str (read-string-safely code)))
+          results (if (empty? user-forms)
+                    ["Empty input is not allowed."]
+                    (for [test tests]
+                      (try
+                        (when-not (->> user-forms
+                                       (s/replace test "__")
+                                       read-string-safely
+                                       first
+                                       (sb sb-tester))
+                          "You failed the unit tests")
+                        (catch Throwable t (.getMessage t)))))
+          [passed [fail-msg]] (split-with nil? results)]
+      (conj (if fail-msg
+              [fail-msg *url*]
+              (mark-completed problem code))
+            (count passed)))
+    (catch Throwable t [(.getMessage t), *url*, 0])))

 (defn static-run-code [id raw-code]
-  (binding [*url* (str *url* "#prob-desc")]
-    (apply flash-msg (run-code id raw-code))))
+  (let [[message url failure-index] (binding [*url* (str *url* "#prob-desc")]
+                                      (run-code id raw-code))]
+    (session/flash-put! :failing-test failure-index)
+    (flash-msg message url)))

 (defn render-test-cases [tests]
   [:table {:class "testcases"}
@@ -214,8 +223,8 @@
         [:span#graph-link "View Chart"]]])))

 (defn rest-run-code [id raw-code]
-  (let [[message url] (run-code id raw-code)]
-    (json-str {:failingTest (session/flash-get :failing-test)
+  (let [[message url failure-index] (run-code id raw-code)]
+    (json-str {:failingTest failure-index
                :message message
                :golfScore (html (render-golf-score))
                :golfChart (html (render-golf-chart))})))


Mixed case username bug fix

Mixed case username bug fix

--- src/foreclojure/register.clj
+++ src/foreclojure/register.clj
@@ -39,7 +39,7 @@
                  {:user lower-user
                   :pwd (.encryptPassword (StrongPasswordEncryptor.) pwd)
                   :email email})
-        (session/session-put! :user user)
+        (session/session-put! :user lower-user)
         (response/redirect "/"))
       (flash-error why "/register"))))


add reference about planned secondary flare "app" to handle notifications

--- src/galleon/applications.clj
+++ src/galleon/applications.clj
@@ -33,7 +33,10 @@
    {:app-name "Gangway"
     :start-fn! gw-util/start-queues!
     :helmsman-context "gangway"
-    :helmsman-definition gangway.web/helmsman-definition}])
+    :helmsman-definition gangway.web/helmsman-definition}
+   #_
+   {:app-name "Flare: Notifier"
+    :start-fn! nil}])

 (defn make-app-context
   [db-conn app]


Improve CORS

Improve CORS

--- src/lens/middleware/cors.clj
+++ src/lens/middleware/cors.clj
@@ -1,12 +1,18 @@
 (ns lens.middleware.cors)

 (defn assoc-header [response]
-  (assoc-in response [:headers "Access-Control-Allow-Origin"] "*"))
+  (-> (assoc-in response [:headers "Access-Control-Allow-Origin"] "*")
+      (assoc-in [:headers "Access-Control-Expose-Headers"] "ETag")))

 (defn wrap-cors
   "Adds an Access-Control-Allow-Origin header with the value * to responses."
   [handler]
   (fn [request]
-    (-> request
-        (handler)
-        (assoc-header))))
+    (if (= :options (:request-method request))
+      {:status 204
+       :headers {"Access-Control-Allow-Origin" "*"
+                 "Access-Control-Allow-Methods" "GET, POST, PUT"
+                 "Access-Control-Allow-Headers" "Authorization, Accept, If-Match"
+                 "Access-Control-Max-Age" "3600"}}
+      (-> (handler request)
+          (assoc-header)))))


changed ModuleStatus component to be initialized lazily so that React is loaded first

--- src/routom/core.cljs
+++ src/routom/core.cljs
@@ -48,27 +48,29 @@
             (recur (butlast p) new-params new-query))))
       )))

-(defui ModuleStatus
-  Object
-  (initLocalState [_]
-    {:status :loading})
-  (componentWillMount
-    [this]
-    (let [{:keys [module-id]} (om/props this)
-          manager (module-manager/getInstance)]
-      (if-let [module (.getModuleInfo manager module-id)]
-        (let [on-error (.registerErrback module (fn [_] (om/update-state! this assoc :status :error)))
-              on-load (.registerCallback module (fn [_] (om/update-state! this assoc :status :success)))]
-          (om/update-state! this assoc :on-err on-error)
-          (om/update-state! this assoc :on-load on-load)))))
-  (componentWillUnmount [this]
-    (let [{:keys [on-error on-load]} (om/get-state this)]
-      (when on-error (.abort on-error))
-      (when on-load (.abort on-load))))
-  (render [this]
-    (let [{:keys [render-status module-id]} (om/props this)
-          {:keys [status]} (om/get-state this)]
-      (when render-status (render-status status module-id)))))
+(defn module-status
+  [render-status]
+  (ui
+    Object
+    (initLocalState [_]
+                    {:status :loading})
+    (componentWillMount
+      [this]
+      (let [{:keys [module-id]} (om/props this)
+            manager (module-manager/getInstance)]
+        (if-let [module (.getModuleInfo manager module-id)]
+          (let [on-error (.registerErrback module (fn [_] (om/update-state! this assoc :status :error)))
+                on-load (.registerCallback module (fn [_] (om/update-state! this assoc :status :success)))]
+            (om/update-state! this assoc :on-err on-error)
+            (om/update-state! this assoc :on-load on-load)))))
+    (componentWillUnmount [this]
+                          (let [{:keys [on-error on-load]} (om/get-state this)]
+                            (when on-error (.abort on-error))
+                            (when on-load (.abort on-load))))
+    (render [this]
+            (let [{:keys [module-id]} (om/props this)
+                  {:keys [status]} (om/get-state this)]
+              (when render-status (render-status status module-id))))))

 (defn get-element-tree
   [route-map path root-props render-module-status]
@@ -81,8 +83,8 @@

         (if module-id
           (recur (butlast p)
-                 (when (some? render-module-status)
-                   ((om/factory ModuleStatus)
+                 (when render-module-status
+                   ((om/factory render-module-status)
                      {:module-id     module-id
                       :render-status render-module-status})))
           (let [fac (if ui #(om/factory ui) #(om/factory route))
@@ -117,6 +119,8 @@
      (add-watch routes :route/hierarchy (fn [_ _ _ next-state]
                                           (reset! route-hierarchy (u/create-hierarchy next-state))))
      (let [set-active-route! #(reset! active-route %1)
+           ModuleStatus (when render-module-status
+                          (module-status render-module-status))
            AppRoot
            (ui
              static om/IQueryParams
@@ -155,7 +159,7 @@
                                root-props (merge
                                             props
                                             active-route)
-                               element-tree (get-element-tree @routes path root-props render-module-status)]
+                               element-tree (get-element-tree @routes path root-props ModuleStatus)]
                            element-tree))
                        )))]
        {:root-class           AppRoot


add lz77 compression

add lz77 compression

--- src/sandbox/lz77.clj
+++ src/sandbox/lz77.clj
@@ -27,12 +27,24 @@
         (sort-by #(count (first %)))
         (last))))

-(defn LZ77-STEP [window look-ahead]
+(defn LZ77-STEP [[window look-ahead]]
   (if-let [longest (longest-match-w-beginning window look-ahead)]
-    {:distance (-  (count window) (second longest))
-     :length (count longest)
-     :char (first (subvec look-ahead (count longest)))}
-    {:distance 0
-     :length 0
+    {:length (count (first longest))
+     :char (conj [] (- (count window) (second longest)) (count (first longest)))}
+    {:length 1
      :char (first look-ahead)}))

+(defn slider [window xs]
+  (map #(conj [] (take-last window (take % xs)) (drop % xs)) (range 0 (count xs))))
+
+(defn compress [chunks]
+  (loop [chunks chunks res []]
+    (if (seq chunks)
+      (let [rc (LZ77-STEP (first chunks))]
+        (recur (drop (:length rc) chunks) (conj res rc)))
+      res)))
+
+(defn LZ77 [bytes-array window-size]
+  (->> (slider window-size bytes-array)
+       (compress)
+       (map :char)))


clear sync-start on track-complete

clear sync-start on track-complete

--- src/server/core.cljs
+++ src/server/core.cljs
@@ -24,6 +24,7 @@
   (rooms/get-all-music-info room-id
     (fn [room-music-info]
       (if-not (nil? room-music-info)
+
         (.emit socket "hotjoin-music-info" room-music-info)))))

 (defn connection [socket]
@@ -73,13 +74,11 @@
                   (if (= num-users num-users-ready)
                     (rooms/set-current-track-position room 0
                       (fn [track-position-info]
-                        (rooms/clear-ready-to-start room
-                          (fn []
-                            (let [track-position (+ (:position track-position-info)
-                                                    (- (.now js/Date)
-                                                       (:starttime track-position-info)))]
-                              (println "starting at: " track-position)
-                              (.emit (.to io room) "start-track" track-position)))))))))))))))
+                        (let [track-position (+ (:position track-position-info)
+                                                (- (.now js/Date)
+                                                    (:starttime track-position-info)))]
+                          (println "starting at: " track-position)
+                          (.emit (.to io room) "start-track" track-position)))))))))))))

   (.on socket "pause"
     (fn [position]
@@ -115,13 +114,15 @@
               (rooms/user-track-complete (.-id socket)
                 (fn [num-users-track-complete]
                   (if (= num-users num-users-track-complete)
-                    (rooms/clear-track-complete room
+                    (rooms/clear-ready-to-start room
                       (fn []
-                        (rooms/next-track room
-                          (fn [track-id]
-                            (if (nil? track-id)
-                              (.emit (.to io room) "play-next-upload")
-                              (.emit (.to io room) "track-change" track-id)))))))))))))))
+                        (rooms/clear-track-complete room
+                          (fn []
+                            (rooms/next-track room
+                              (fn [track-id]
+                                (if (nil? track-id)
+                                  (.emit (.to io room) "play-next-upload")
+                                  (.emit (.to io room) "track-change" track-id)))))))))))))))))

   (.on (new socketio-stream socket) "file-upload"
     (fn [stream original-filename file-size]


Using new schema jar (#302)

Using new schema jar (#302)

--- server/project.clj
+++ server/project.clj
@@ -21,7 +21,7 @@
                  [org.slf4j/log4j-over-slf4j "1.7.21"]
                  [com.stuartsierra/component "0.3.1"]
                  [clojurewerkz/machine_head "1.0.0-beta9"]
-                 [com.boundlessgeo/schema "0.8"]
+                 [com.boundlessgeo/schema "0.9"]
                  ; todo: the protobuf dependency should be packaged into the schema artifact
                  [com.google.protobuf/protobuf-java "3.1.0"]
                  [buddy "1.1.0"]


readability edit

readability edit

--- src/lseq_tree/lseq_node.cljc
+++ src/lseq_tree/lseq_node.cljc
@@ -29,8 +29,9 @@
         ; if the path does not exist
         (assoc next-this
                :children
-               (into []
-                     (sorted :triple (cons other n-children))))
+               (->> (cons other n-children)
+                    (sorted :triple)
+                    (into [])))
         ; if the path does exist
         (if (= (count o-children) 0)
           ; if the other node does not have children


Käyttäjän aktiivisen turnauksen playerid:n passaus käyttäjää haettaessa

--- src/shl/dao/user.clj
+++ src/shl/dao/user.clj
@@ -37,10 +37,14 @@
     (s/format (get-users-sql))))

 (defn- get-user-sql [username]
-  (s/build :select [:u.* [:r.name "role"]]
+  (s/build :select [:u.* [:r.name "role"] [:p.id "playerid"]]
            :from [[:user_ :u]]
            :join [[:role :r] [:= :r.id :u.roleid]]
-           :where [:= :u.username username]))
+           :left-join [[:player :p] [:= :p.userid :u.id]
+                       [:conference :c] [:= :c.id :p.conferenceid]
+                       [:tournament :t] [:and [:= :t.id :c.tournamentid] [:= :t.active true]]]
+           :where [:= :u.username username]
+           :limit 1))

 (defn get-user [username]
   (first(j/query db/db


Replace dec->int100 function with an anonymous function.

--- src/clj/forma/postprocess/output.clj
+++ src/clj/forma/postprocess/output.clj
@@ -54,19 +54,15 @@
   [series]
   (cons (first series) (rest (reductions max series))))

-(defn dec->int100
-  [coll]
-  (map (comp int round (partial * 100)) coll))
-
 (defn clean-probs
-  "smooth the probabilities with a backward-looking moving average, make the
+  "Smooth the probabilities with a backward-looking moving average, make the
   series monotonically increasing, and finally make each probability 0->1 an
   integer 0->100"
   [coll]
   (let [window 3]
-    [(vec (-> (backward-looking-mavg window coll)
-              (mono-inc)
-              (dec->int100)))]))
+    [(vec (->> (backward-looking-mavg window coll)
+               (mono-inc)
+               (map #(round (* % 100)))))]))

 (defn date-no-sep
   [date-str]


Add liquids recoverable property

Add liquids recoverable property

--- src/clj_simple_chart/ncs/reserve.clj
+++ src/clj_simple_chart/ncs/reserve.clj
@@ -42,18 +42,20 @@

 (def data-parsed (->> data
                       (csv/read-string-columns numeric-columns)
-                      (csv/number-or-throw-columns numeric-columns)))
+                      (csv/number-or-throw-columns numeric-columns)
+                      (mapv #(assoc % :fldRecoverableLiquids (reduce + 0 (mapv % [:fldRecoverableOil :fldRecoverableCondensate :fldRecoverableNGL]))))))

 (def field-names (map :fldName data))

 (defn get-reserve [field-name kind]
   {:pre [(or (some #{field-name} field-names)
              (some #{field-name} ["SINDRE" "33/9-6 DELTA"]))
-         (some #{kind} [:fldRecoverableOE :fldRecoverableOil :fldRecoverableGas])]}
+         (some #{kind} [:fldRecoverableOE :fldRecoverableOil :fldRecoverableGas :fldRecoverableLiquids])]}
   (cond (not (some #{field-name} field-names))
-        (let [prop (get {:fldRecoverableOE  :prfPrdOeNetMillSm3
-                         :fldRecoverableOil :prfPrdOilNetMillSm3
-                         :fldRecoverableGas :prfPrdGasNetBillSm3} kind)]
+        (let [prop (get {:fldRecoverableOE      :prfPrdOeNetMillSm3
+                         :fldRecoverableOil     :prfPrdOilNetMillSm3
+                         :fldRecoverableLiquids :prfPrdLiquidsNetMillSm3
+                         :fldRecoverableGas     :prfPrdGasNetBillSm3} kind)]
           (->> raw-production/data
                (filter #(= field-name (:prfInformationCarrier %)))
                (mapv prop)
@@ -63,4 +65,11 @@
         :else
         (-> (filter #(= (:fldName %) field-name) data-parsed)
             first
-            (get kind))))+            (get kind))))
+
+(test/is (not (some #{"SINDRE"} field-names)))
+(test/is (not (some #{"33/9-6 DELTA"} field-names)))
+
+(test/is (= 8.6 (get-reserve "JOHAN SVERDRUP" :fldRecoverableGas)))
+(test/is (= 282.3 (get-reserve "JOHAN SVERDRUP" :fldRecoverableOil)))
+(test/is (= 286.1 (get-reserve "JOHAN SVERDRUP" :fldRecoverableLiquids)))


[REFACTOR] Remove redundant `(not (nil? ))` test for nil

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -659,7 +659,7 @@
                          (<= endTime timeIdx))
                     ttLessonInfo

-                    (and (not (nil? selectedTTLessonInfo))
+                    (and selectedTTLessonInfo
                          (<= endTime timeIdx)
                          (> endTime (:endTime selectedTTLessonInfo)))
                     ttLessonInfo


Don't update in add-locations if there are no new locations to added

This should prevent one direction from spinning endlessly trying to
load locations that don't exist.

--- src/cljs/comic_reader/ui/reader.cljs
+++ src/cljs/comic_reader/ui/reader.cljs
@@ -36,7 +36,9 @@
    (location-sorted-set)))

 (defn add-locations [app-db locations]
-  (update app-db :locations conj-locations locations))
+  (if (seq locations)
+    (update app-db :locations conj-locations locations)
+    app-db))

 (defn setup! []
   (trace-forms {:tracer (tracer :color "green")}


Give names to all the anonymous functions in reader ns

--- src/cljs/comic_reader/ui/reader.cljs
+++ src/cljs/comic_reader/ui/reader.cljs
@@ -40,42 +40,36 @@

 (defn setup! []
   (trace-forms {:tracer (tracer :color "green")}
-    (re-frame.core/reg-event-db
-     :set-locations
-     (fn [app-db [_ locations]]
-       (assoc app-db :locations locations)))
-
     (re-frame/reg-event-db
      :set-current-location
-     (fn [app-db [_ current-location]]
+     (fn set-current-version-event [app-db [_ current-location]]
        (assoc app-db :current-location current-location)))

     (re-frame/reg-event-db
      :add-locations
-     (fn [app-db [_ locations]]
-       (add-locations app-db locations))))
+     (fn add-locations-event [app-db [_ locations]]
+       (add-locations app-db locations)))
+
+    (re-frame/reg-event-db
+     :set-buffer-size
+     (fn set-buffer-size-event [app-db [_ n]]
+       (assoc app-db :buffer-size n))))

   (trace-forms {:tracer (tracer :color "brown")}
     (re-frame/reg-sub
      :locations
-     (fn [app-db _]
+     (fn locations [app-db _]
        (:locations app-db)))

     (re-frame/reg-sub
      :current-location
-     (fn [app-db _]
+     (fn current-location [app-db _]
        (:current-location app-db)))

     (re-frame/reg-sub
      :buffer-size
-     (fn [app-db _]
+     (fn buffer-size [app-db _]
        (:buffer-size app-db)))
-
-    (re-frame/reg-event-db
-     :set-buffer-size
-     (fn [app-db [_ n]]
-       (assoc app-db :buffer-size n)))
-

     ;; Level two subscription

@@ -83,28 +77,28 @@
      :partitioned-locations
      :<- [:locations]
      :<- [:current-location]
-     (fn [[locations current-location] _]
+     (fn partitioned-locations [[locations current-location] _]
        (partitioned-locations (seq locations) current-location)))

     (re-frame/reg-sub
      :comic-coordinates
      :<- [:site-id]
      :<- [:comic-id]
-     (fn [[site-id comic-id] _]
+     (fn comic-coordinates [[site-id comic-id] _]
        {:site-id site-id
         :comic-id comic-id}))

     (re-frame/reg-sub
      :first-image-location
      :<- [:locations]
-     (fn [locations _]
+     (fn first-image-location [locations _]
        (when locations
          (first (seq locations)))))

     (re-frame/reg-sub
      :last-image-location
      :<- [:locations]
-     (fn [locations _]
+     (fn last-image-location [locations _]
        (when locations
          (first (rseq locations)))))

@@ -114,13 +108,13 @@
     (re-frame/reg-sub
      :before-locations-count
      :<- [:partitioned-locations]
-     (fn [[before _ _] _]
+     (fn before-locations-count [[before _ _] _]
        (count before)))

     (re-frame/reg-sub
      :after-locations-count
      :<- [:partitioned-locations]
-     (fn [[_ _ after] _]
+     (fn after-locations-count [[_ _ after] _]
        (count after)))

     (re-frame/reg-sub
@@ -129,7 +123,7 @@
      :<- [:buffer-size]
      :<- [:first-image-location]
      :<- [:before-locations-count]
-     (fn [[comic-coord buffer-size first-location before-buffer-size] _]
+     (fn loading-before-buffer [[comic-coord buffer-size first-location before-buffer-size] _]
        (when (> buffer-size before-buffer-size)
          (api/get-prev-locations (:site-id comic-coord)
                                  (:comic-id comic-coord)
@@ -144,7 +138,7 @@
      :<- [:buffer-size]
      :<- [:last-image-location]
      :<- [:after-locations-count]
-     (fn [[comic-coord buffer-size last-location after-buffer-size] _]
+     (fn loading-after-buffer [[comic-coord buffer-size last-location after-buffer-size] _]
        (when (> buffer-size after-buffer-size)
          (api/get-next-locations (:site-id comic-coord)
                                  (:comic-id comic-coord)
@@ -157,7 +151,7 @@
      :current-locations
      :<- [:partitioned-locations]
      :<- [:buffer-size]
-     (fn [[partitioned-locations buffer-size] _]
+     (fn current-locations [[partitioned-locations buffer-size] _]
        (current-locations partitioned-locations buffer-size)))))

 (defn- location-id [location]


don't explode on nil metrics

don't explode on nil metrics

--- src/com/billpiel/sayid/profiling.clj
+++ src/com/billpiel/sayid/profiling.clj
@@ -22,22 +22,22 @@
   (util/apply-to-map-vals (fn [metrics]
                             (let [arg-cardinality (-> metrics :arg-set count)
                                   call-count (:count metrics)
-                                  gross-time-sum (:gross-time-sum metrics)
+                                  gross-time-sum (or (:gross-time-sum metrics) 0)
                                   repeat-arg-pct (- 1 (/ arg-cardinality
                                                          call-count
                                                          1.0))]
                               (-> metrics
                                   (dissoc :arg-set)
                                   (assoc :gross-time-avg (/ gross-time-sum
-                                                             call-count
-                                                             1.0)
-                                          :net-time-avg  (/ (:net-time-sum metrics)
                                                             call-count
                                                             1.0)
-                                          :arg-cardinality arg-cardinality
-                                          :repeat-arg-pct repeat-arg-pct
-                                          :gross-of-repeats (* gross-time-sum
-                                                               repeat-arg-pct)))))
+                                         :net-time-avg  (/ (or (:net-time-sum metrics) 0)
+                                                           call-count
+                                                           1.0)
+                                         :arg-cardinality arg-cardinality
+                                         :repeat-arg-pct repeat-arg-pct
+                                         :gross-of-repeats (* gross-time-sum
+                                                              repeat-arg-pct)))))
                           fn-ms))

 (defn get-fn-metrics


Eduction did not implement both -reduce arities

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -8934,17 +8934,18 @@
      (filter (fn [_] (< (rand) prob)) coll)))

 (deftype Eduction [xform coll]
-   ISequential
-
-   ISeqable
-   (-seq [_] (seq (sequence xform coll)))
-
-   IReduce
-   (-reduce [_ f init] (transduce xform f init coll))
-
-   IPrintWithWriter
-   (-pr-writer [coll writer opts]
-     (pr-sequential-writer writer pr-writer "(" " " ")" opts coll)))
+  ISequential
+
+  ISeqable
+  (-seq [_] (seq (sequence xform coll)))
+
+  IReduce
+  (-reduce [_ f] (transduce xform f coll))
+  (-reduce [_ f init] (transduce xform f init coll))
+
+  IPrintWithWriter
+  (-pr-writer [coll writer opts]
+    (pr-sequential-writer writer pr-writer "(" " " ")" opts coll)))

 (es6-iterable Eduction)


Use new driver/format-custom-field-name method in tests [ci drivers]

--- test/metabase/query_processor_test/expression_aggregations_test.clj
+++ test/metabase/query_processor_test/expression_aggregations_test.clj
@@ -1,12 +1,13 @@
 (ns metabase.query-processor-test.expression-aggregations-test
   "Tests for expression aggregations and for named aggregations."
   (:require [expectations :refer :all]
+            [metabase.driver :as driver]
             [metabase.models.metric :refer [Metric]]
             [metabase.query-processor :as qp]
             [metabase.query-processor.expand :as ql]
             [metabase.query-processor-test :refer :all]
             [metabase.test.data :as data]
-            [metabase.test.data.datasets :as datasets, :refer [*engine*]]
+            [metabase.test.data.datasets :as datasets, :refer [*engine* *driver*]]
             [metabase.test.util :as tu]
             [metabase.util :as u]))

@@ -167,7 +168,7 @@
              [3  52]
              [4  30]]
    :columns [(data/format-name "price")
-             (if (= *engine* :redshift) "new price" "New Price")]} ; Redshift annoyingly always lowercases column aliases
+             (driver/format-custom-field-name *driver* "New Price")]} ; Redshift annoyingly always lowercases column aliases
   (format-rows-by [int int]
     (rows+column-names (data/run-query venues
                          (ql/aggregation (ql/named (ql/sum (ql/+ $price 1)) "New Price"))
@@ -180,7 +181,7 @@
              [3  -2]
              [4 -17]]
    :columns [(data/format-name "price")
-             (if (= *engine* :redshift) "sum-41" "Sum-41")]}
+             (driver/format-custom-field-name *driver* "Sum-41")]}
   (format-rows-by [int int]
     (rows+column-names (data/run-query venues
                          (ql/aggregation (ql/named (ql/- (ql/sum $price) 41) "Sum-41"))
@@ -208,7 +209,7 @@
              [3  39]
              [4  24]]
    :columns [(data/format-name "price")
-             (if (= *engine* :redshift) "my cool metric" "My Cool Metric")]}
+             (driver/format-custom-field-name *driver* "My Cool Metric")]}
   (tu/with-temp Metric [metric {:table_id   (data/id :venues)
                                 :definition {:aggregation [:sum [:field-id (data/id :venues :price)]]
                                              :filter      [:> [:field-id (data/id :venues :price)] 1]}}]
@@ -226,7 +227,7 @@
              [3  39]
              [4  24]]
    :columns [(data/format-name "price")
-             (if (= *engine* :redshift) "my cool metric" "My Cool Metric")]}
+             (driver/format-custom-field-name *driver* "My Cool Metric")]}
   (tu/with-temp Metric [metric {:table_id   (data/id :venues)
                                 :definition {:aggregation [[:sum [:field-id (data/id :venues :price)]]]
                                              :filter      [:> [:field-id (data/id :venues :price)] 1]}}]
@@ -240,7 +241,7 @@

 ;; check that named aggregations come back with the correct column metadata (#4002)
 (datasets/expect-with-engines (engines-that-support :expression-aggregations)
-  (let [col-name (if (= *engine* :redshift) "count of things" "Count of Things")]
+  (let [col-name (driver/format-custom-field-name *driver* "Count of Things")]
     (assoc (aggregate-col :count)
       :name         col-name
       :display_name col-name))


Tests for namespaced tags and default-tag-parser

--- test/cljs/cljs/reader_test.cljs
+++ test/cljs/cljs/reader_test.cljs
@@ -73,6 +73,14 @@

   (assert (= [1 2] (reader/read-string "#foo [1 2]")))

+  ;; tag elements with prefix component
+  (reader/register-tag-parser! 'foo.bar/baz identity)
+  (assert (= [1 2] (reader/read-string "#foo.bar/baz [1 2]")))
+
+  ;; default tag parser
+  (reader/register-default-tag-parser! (fn [tag val] val))
+  (assert (= [1 2] (reader/read-string "#a.b/c [1 2]")))
+
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;; Unicode Tests


[ Summary ] Handle resources for both junction and symlink on windows. (#400)

[ Root Cause ]
After shadow-cljs 2.6.15, on windows,
PathResourceManager.getResource(String) will return null if the path is a junction,
it's because PathResourceManager.getSymlinkBase(String, Path) returns null.

[ Solution ]
To solve this problem for both junction and symlink,
we may set the property caseSensitive of PathResourceManager.Builder to be true.

[ Result ]
Test Cases(on windows):
1. PathResourceManager.getSymlinkBase(String, Path) will return non-null if the path is a symlink, and PathResourceManager.getResource(String) returns non-null.
2. PathResourceManager.getResource(Path, String , Path, String) will return non-null if the path is a junction and caseSensitive is false.

--- src/main/shadow/undertow.clj
+++ src/main/shadow/undertow.clj
@@ -139,6 +139,8 @@
             (.setFollowLinks true)
             ;; must not be nil, empty == followAll
             (.setSafePaths (into-array String []))
+            ;; handle both junction and symlink on windows, refer to SystemUtils in Apache commons-lang3
+            (.setCaseSensitive (not (.startsWith (System/getProperty "os.name") "Windows")))
             (.build))

         handler


assume policy doesn’t take resources

assume policy doesn’t take resources

--- src/terraboot/cluster.clj
+++ src/terraboot/cluster.clj
@@ -102,8 +102,10 @@
                      "elasticloadbalancing:DescribeLoadBalancers"]}))

 (def default-assume-policy
-  (policy {"Action" "sts:AssumeRole"
-           "Principal" {"Service" ["ec2.amazonaws.com"]}}))
+  (to-json {"Statement" [{"Action" ["sts:AssumeRole"]
+                          "Effect" "Allow"
+                          "Principal" {"Service" ["ec2.amazonaws.com"]}}]
+            "Version" "2012-10-17" }))

 (defn cluster-infra
   [vpc-name cluster-name]


Run test-s3-logs only when log-bucket-url is configured (#889)

--- waiter/integration/waiter/kubernetes_scheduler_integration_test.clj
+++ waiter/integration/waiter/kubernetes_scheduler_integration_test.clj
@@ -76,57 +76,57 @@
 (deftest ^:parallel ^:integration-slow ^:resource-heavy test-s3-logs
   (testing-using-waiter-url
     (when (using-k8s? waiter-url)
-      (let [log-bucket-url (-> waiter-url get-kubernetes-scheduler-settings :log-bucket-url)
-            headers {:x-waiter-name (rand-name)
-                     :x-waiter-concurrency-level 1
-                     :x-waiter-distribution-scheme "simple"
-                     :x-waiter-max-instances 2
-                     :x-waiter-scale-up-factor 0.99
-                     :x-waiter-scale-down-factor 0.99}
-            _ (log/info "making canary request...")
-            {:keys [cookies instance-id service-id]} (make-request-with-debug-info headers #(make-kitchen-request waiter-url %))]
-
-        (with-service-cleanup
-          service-id
-          (assert-service-on-all-routers waiter-url service-id cookies)
-
-          ;; Test that the active instances' logs are available.
-          (let [active-instances (get-in (service-settings waiter-url service-id :cookies cookies)
-                                         [:instances :active-instances])
-                log-url (:log-url (first active-instances))
-                make-request-fn (fn [url] (make-request url "" :verbose true))
-                {:keys [body] :as logs-response} (make-request-fn log-url)
-                _ (assert-response-status logs-response 200)
-                log-files-list (walk/keywordize-keys (json/read-str body))
-                stdout-file-link (:url (first (filter #(= (:name %) "stdout") log-files-list)))
-                stderr-file-link (:url (first (filter #(= (:name %) "stderr") log-files-list)))]
-            (is (every? #(string/includes? body %) ["stderr" "stdout"])
-                (str "Live directory listing is missing entries: stderr and stdout, got response: " logs-response))
-            (doseq [file-link [stderr-file-link stdout-file-link]]
-              (if (string/starts-with? (str file-link) "http")
-                (assert-response-status (make-request-fn file-link) 200)
-                (log/warn "test-s3-logs did not verify file link:" file-link))))
-
-          ;; Get a service with at least one killed instance.
-          (log/info "starting parallel requests")
-          (let [async-create-headers (assoc headers :x-kitchen-delay-ms 60000)
-                async-request-fn (fn [] (->> #(make-kitchen-request waiter-url % :method :get :path "/async/request")
-                                             (make-request-with-debug-info async-create-headers)))
-                async-responses (->> async-request-fn (repeatedly 2) vec)
-                instance-ids (->> async-responses (map :instance-id) set)]
-            (assert-response-status (first async-responses) 202)
-            (assert-response-status (second async-responses) 202)
-            (is (> (count instance-ids) 1) (str instance-ids))
-            ;; Canceling both of the async requests should scale down to 1 by killing 1 instance.
-            (doseq [async-response async-responses]
-              (let [status-endpoint (response->location async-response)
-                    cancel-response (make-kitchen-request waiter-url headers :method :delete :path status-endpoint)]
-                (assert-response-status cancel-response 204)))
-            (log/info "waiting for at least one instance to get killed")
-            (is (wait-for #(->> (get-in (service-settings waiter-url service-id) [:instances :killed-instances])
-                                (map :id) distinct seq)
-                          :interval 2 :timeout 45)
-                (str "no killed instances found for " service-id)))
+      (when-let [log-bucket-url (-> waiter-url get-kubernetes-scheduler-settings :log-bucket-url)]
+        (let [headers {:x-waiter-concurrency-level 1
+                       :x-waiter-distribution-scheme "simple"
+                       :x-waiter-max-instances 2
+                       :x-waiter-name (rand-name)
+                       :x-waiter-scale-down-factor 0.99
+                       :x-waiter-scale-up-factor 0.99}
+              _ (log/info "making canary request...")
+              {:keys [cookies instance-id service-id]} (make-request-with-debug-info headers #(make-kitchen-request waiter-url %))]
+
+          (with-service-cleanup
+            service-id
+            (assert-service-on-all-routers waiter-url service-id cookies)
+
+            ;; Test that the active instances' logs are available.
+            (let [active-instances (get-in (service-settings waiter-url service-id :cookies cookies)
+                                           [:instances :active-instances])
+                  log-url (:log-url (first active-instances))
+                  make-request-fn (fn [url] (make-request url "" :verbose true))
+                  {:keys [body] :as logs-response} (make-request-fn log-url)
+                  _ (assert-response-status logs-response 200)
+                  log-files-list (walk/keywordize-keys (json/read-str body))
+                  stdout-file-link (:url (first (filter #(= (:name %) "stdout") log-files-list)))
+                  stderr-file-link (:url (first (filter #(= (:name %) "stderr") log-files-list)))]
+              (is (every? #(string/includes? body %) ["stderr" "stdout"])
+                  (str "Live directory listing is missing entries: stderr and stdout, got response: " logs-response))
+              (doseq [file-link [stderr-file-link stdout-file-link]]
+                (if (string/starts-with? (str file-link) "http")
+                  (assert-response-status (make-request-fn file-link) 200)
+                  (log/warn "test-s3-logs did not verify file link:" file-link))))
+
+            ;; Get a service with at least one killed instance.
+            (log/info "starting parallel requests")
+            (let [async-create-headers (assoc headers :x-kitchen-delay-ms 120000)
+                  async-request-fn (fn [] (->> #(make-kitchen-request waiter-url % :method :get :path "/async/request")
+                                               (make-request-with-debug-info async-create-headers)))
+                  async-responses (->> async-request-fn (repeatedly 2) vec)
+                  instance-ids (->> async-responses (map :instance-id) set)]
+              (assert-response-status (first async-responses) 202)
+              (assert-response-status (second async-responses) 202)
+              (is (> (count instance-ids) 1) (str instance-ids))
+              ;; Canceling both of the async requests should scale down to 1 by killing 1 instance.
+              (doseq [async-response async-responses]
+                (let [status-endpoint (response->location async-response)
+                      cancel-response (make-kitchen-request waiter-url headers :method :delete :path status-endpoint)]
+                  (assert-response-status cancel-response 204)))
+              (log/info "waiting for at least one instance to get killed")
+              (is (wait-for #(->> (get-in (service-settings waiter-url service-id) [:instances :killed-instances])
+                                  (map :id) distinct seq)
+                            :interval 2 :timeout 45)
+                  (str "no killed instances found for " service-id)))

             (log/info "waiting for at least one instance to get killed")
             (is (wait-for #(->> (get-in (service-settings waiter-url service-id) [:instances :killed-instances])
@@ -134,43 +134,43 @@
                           :interval 2 :timeout 45)
                 (str "no killed instances found for " service-id))

-          (log/info "waiting for at least one instance to get killed")
-          (is (wait-for #(->> (get-in (service-settings waiter-url service-id) [:instances :killed-instances])
-                              (map :id)
-                              set
-                              seq)
-                        :interval 2 :timeout 45)
-              (str "No killed instances found for " service-id))
-
-          ;; Test that the killed instances' logs were persisted to S3.
-          ;; This portion of the test logic was modified from the active-instances tests above.
-          (let [log-bucket-url (-> waiter-url get-kubernetes-scheduler-settings :log-bucket-url)
-                killed-instances (get-in (service-settings waiter-url service-id :cookies cookies)
-                                         [:instances :killed-instances])
-                log-url (:log-url (first killed-instances))
-                make-request-fn (fn [url] (make-request url "" :verbose true))
-                _ (do
-                    (log/info "waiting s3 logs to appear")
-                    (is (wait-for
-                          #(let [{:keys [body] :as logs-response} (make-request-fn log-url)]
-                             (string/includes? body log-bucket-url))
-                          :interval 1 :timeout 60)
-                        (str "Log URL never pointed to S3 bucket " log-bucket-url)))
-                _ (log/debug "Log Url Killed:" log-url)
-                {:keys [body] :as logs-response} (make-request-fn log-url)
-                _ (assert-response-status logs-response 200)
-                _ (log/debug "Response body:" body)
-                log-files-list (walk/keywordize-keys (json/read-str body))
-                stdout-file-link (:url (first (filter #(= (:name %) "stdout") log-files-list)))
-                stderr-file-link (:url (first (filter #(= (:name %) "stderr") log-files-list)))]
-            (is (wait-for
-                  #(every? (partial string/includes? body) ["stderr" "stdout"])
-                  :interval 1 :timeout 30)
-                (str "Killed directory listing is missing entries: stderr and stdout, got response: " logs-response))
-            (doseq [file-link [stderr-file-link stdout-file-link]]
-              (if (string/starts-with? (str file-link) "http")
-                (assert-response-status (make-request-fn file-link) 200)
-                (log/warn "test-s3-logs did not verify file link:" file-link)))))))))
+            (log/info "waiting for at least one instance to get killed")
+            (is (wait-for #(->> (get-in (service-settings waiter-url service-id) [:instances :killed-instances])
+                                (map :id)
+                                set
+                                seq)
+                          :interval 2 :timeout 45)
+                (str "No killed instances found for " service-id))
+
+            ;; Test that the killed instances' logs were persisted to S3.
+            ;; This portion of the test logic was modified from the active-instances tests above.
+            (let [log-bucket-url (-> waiter-url get-kubernetes-scheduler-settings :log-bucket-url)
+                  killed-instances (get-in (service-settings waiter-url service-id :cookies cookies)
+                                           [:instances :killed-instances])
+                  log-url (:log-url (first killed-instances))
+                  make-request-fn (fn [url] (make-request url "" :verbose true))
+                  _ (do
+                      (log/info "waiting s3 logs to appear")
+                      (is (wait-for
+                            #(let [{:keys [body] :as logs-response} (make-request-fn log-url)]
+                               (string/includes? body log-bucket-url))
+                            :interval 1 :timeout 60)
+                          (str "Log URL never pointed to S3 bucket " log-bucket-url)))
+                  _ (log/debug "Log Url Killed:" log-url)
+                  {:keys [body] :as logs-response} (make-request-fn log-url)
+                  _ (assert-response-status logs-response 200)
+                  _ (log/debug "Response body:" body)
+                  log-files-list (walk/keywordize-keys (json/read-str body))
+                  stdout-file-link (:url (first (filter #(= (:name %) "stdout") log-files-list)))
+                  stderr-file-link (:url (first (filter #(= (:name %) "stderr") log-files-list)))]
+              (is (wait-for
+                    #(every? (partial string/includes? body) ["stderr" "stdout"])
+                    :interval 1 :timeout 30)
+                  (str "Killed directory listing is missing entries: stderr and stdout, got response: " logs-response))
+              (doseq [file-link [stderr-file-link stdout-file-link]]
+                (if (string/starts-with? (str file-link) "http")
+                  (assert-response-status (make-request-fn file-link) 200)
+                  (log/warn "test-s3-logs did not verify file link:" file-link))))))))))

 (defn- check-pod-namespace
   [waiter-url headers expected-namespace]


Db-interface: read-operation-log, read-log, read-error-log, and read-requests-log

--- src/emender_service/db_interface.clj
+++ src/emender_service/db_interface.clj
@@ -70,6 +70,42 @@
             (println e)
             [])))

+(defn read-operation-log
+    []
+    (try
+        (jdbc/query db-spec/emender-service-db
+                    ["select * from job_operations order by id"])
+        (catch Exception e
+            (println e)
+            [])))
+
+(defn read-log
+    []
+    (try
+        (jdbc/query db-spec/emender-service-db
+                    ["select * from log order by id"])
+        (catch Exception e
+            (println e)
+            [])))
+
+(defn read-error-log
+    []
+    (try
+        (jdbc/query db-spec/emender-service-db
+                    ["select * from errors order by id"])
+        (catch Exception e
+            (println e)
+            [])))
+
+(defn read-requests-log
+    []
+    (try
+        (jdbc/query db-spec/emender-service-db
+                    ["select * from requests order by id"])
+        (catch Exception e
+            (println e)
+            [])))
+
 (defn record-error
     [job-name repo-url branch datetime message stacktrace]
     (try