Handle counts in solver. Speed up tests.

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -4,7 +4,7 @@
             [cemerick.double-check.properties :as prop :include-macros true]
             [cemerick.pprng :as pprng]
             clojure.set)
-  (:require-macros [aurora.macros :refer [debug check apush apush-into apop-from amake aclear typeof set!! dofrom perf-time]]))
+  (:require-macros [aurora.macros :refer [debug check apush apush-into apop-from amake aclear typeof set!! dofrom perf-time for!]]))

 ;; COMPARISONS

@@ -156,6 +156,17 @@
           (if (key= mid-key key)
             mid
             (recur lo (- mid 1))))))))
+
+(defn prim= [a b]
+  (or (== a b)
+      (and (array? a) (array? b)
+           (== (alength a) (alength b))
+           (loop [i 0]
+             (if (< i (alength a))
+               (if (prim= (aget a i) (aget b i))
+                 (recur (+ i 1))
+                 false)
+               true)))))

 ;; TREES

@@ -203,7 +214,7 @@
            (.foreach root f))
   (elems [this]
        (let [results #js []]
-         (.foreach this #(apush results #js [%1 %2]))
+         (.foreach this #(do (apush results %1) (apush results %2)))
          results))
   (keys [this]
         (let [results #js []]
@@ -211,7 +222,7 @@
           results))
   ISeqable
   (-seq [this]
-        (seq (.elems this))))
+        (seq (map vec (partition 2 (.elems this))))))

 (deftype Node [parent parent-ix keys vals children ^:mutable lower ^:mutable upper]
   Object
@@ -414,6 +425,8 @@
   (reset [this key]
          (set! node (.-root tree))
          (set! ix 0))
+  (val [this]
+       (aget (.-vals node) ix))
   (seek-gt [this key]
            (loop []
              (if (and (instance? Node (.-parent node))
@@ -464,17 +477,23 @@

 ;; los and his are inclusive

-;; propagate updates the current lo/hi for each var and set the solver to failed
+;; propagate updates the current lo/hi for each var and may set the solver to failed
+;;   returns the val of the current key (only has to be correct when all its vars are fixed)
 ;; split-left either:
 ;;   breaks the solutions into two branches, sets the left branch, returns true
 ;;   has only one possible solution, does nothing, returns false
 ;; split-right:
 ;;   breaks the solutions into two branches, sets the right branch
+;; val returns the number of solutions with this key (assumes all vars are fixed)

 (deftype Contains [iterator vars scratch-key]
   Object
   (reset [this solver constraint]
          (.reset iterator))
+  (val [this solver constraints]
+       ;; TODO somewhat uncomfortable with the fact that this is stateful
+       ;; could store current key and check key= instead
+       (.val iterator))
   (propagate [this solver constraint]
              (let [los (.-los solver)
                    his (.-his solver)]
@@ -552,6 +571,8 @@
 (deftype Constant [c var]
   Object
   (reset [this solver constraint])
+  (val [this solver constraint]
+       1)
   (split-left [this solver constraint]
               false)
   (split-right [this solver constraint])
@@ -566,6 +587,8 @@
   (reset [this solver constraint]
          (dotimes [i (alength vars)]
            (.set-watch solver (aget vars i) constraint true)))
+  (val [this solver constraint]
+       1)
   (split-left [this solver constraint]
               false)
   (split-right [this solver constraint])
@@ -588,6 +611,8 @@
   (reset [this solver constraint]
          (dotimes [i (alength vars)]
            (.set-watch solver (aget vars i) constraint true)))
+  (val [this solver constraint]
+       1)
   (split-left [this solver constraint]
               false)
   (split-right [this solver constraint])
@@ -611,6 +636,8 @@
   (reset [this solver constraint]
          (dotimes [i (alength vars)]
            (.set-watch solver (aget vars i) constraint true)))
+  (val [this solver constraint]
+       1)
   (split-left [this solver constraint]
               false)
   (split-right [this solver constraint])
@@ -737,17 +764,23 @@
                 (do
                   (.split this)
                   (recur 0)))))))
-  (keys [this]
-       (let [results #js []]
-         (loop []
-           (let [result (.next this)]
-             (when-not (nil? result)
-               (apush results result)
-               (recur))))
+  (val [this]
+       (let [result 1]
+         (dotimes [constraint (alength constraints)]
+           (set!! result (* result (.val (aget constraints constraint) solver constraint))))
+         result))
+  (elems [this]
+         (let [results #js []]
+           (loop []
+             (let [result (.next this)]
+               (when-not (nil? result)
+                 (apush results result)
+                 (apush results (.val this))
+                 (recur))))
          results))
   ISeqable
   (-seq [this]
-        (seq (.keys this))))
+        (seq (map vec (partition 2 (.elems this))))))

 (defn solver [num-vars constraints]
   (let [los (least-key num-vars)
@@ -838,29 +871,31 @@

 (defn apply-to-tree [tree updates]
   [tree
-   (for [update updates]
-     (.update tree (nth update 1) (nth update 2)))])
+   (doall
+    (for [update updates]
+      (.update tree (nth update 1) (nth update 2))))])

 (defn apply-to-sorted-map [map updates]
   (let [map (atom map)
-        results (for [update updates]
-                  (let [key (nth update 1)
-                        delta (nth update 2)
-                        old-val (get @map key 0)
-                        new-val (+ old-val delta)]
-                    (if (== new-val 0)
-                      (swap! map dissoc key)
-                      (swap! map assoc key new-val))
-                    (cond
-                     (and (== old-val 0) (not (== new-val 0))) added
-                     (and (not (== old-val 0)) (not (== new-val 0))) changed
-                     (and (not (== old-val 0)) (== new-val 0)) deled)))]
+        results (doall
+                 (for [update updates]
+                   (let [key (nth update 1)
+                         delta (nth update 2)
+                         old-val (get @map key 0)
+                         new-val (+ old-val delta)]
+                     (if (== new-val 0)
+                       (swap! map dissoc key)
+                       (swap! map assoc key new-val))
+                     (cond
+                      (and (== old-val 0) (not (== new-val 0))) added
+                      (and (not (== old-val 0)) (not (== new-val 0))) changed
+                      (and (not (== old-val 0)) (== new-val 0)) deled))))]
     [@map results]))

 (defn run-building-prop [min-keys key-len updates]
   (let [[tree tree-results] (apply-to-tree (tree min-keys key-len) updates)
         [sorted-map sorted-map-results] (apply-to-sorted-map (sorted-map-by key-compare) updates)]
-    (and (= (seq (map vec tree)) (seq sorted-map))
+    (and (= (seq tree) (seq sorted-map))
          (= tree-results sorted-map-results)
          (.valid! tree))))

@@ -909,13 +944,17 @@
                 (run-iterator-prop min-keys key-len updates movements)))

 (defn run-self-join-prop [min-keys key-len updates]
-  (let [tree (apply-to-tree (tree min-keys key-len) updates)
+  (let [[tree _] (apply-to-tree (tree min-keys key-len) updates)
         solver (solver
                 key-len
                 #js [(contains (iterator tree) (into-array (range key-len)))
-                     (contains (iterator tree) (into-array (range key-len)))])]
-    (= (map vec (map first tree))
-       (map vec solver))))
+                     (contains (iterator tree) (into-array (range key-len)))])
+        tree-elems (.elems tree)]
+    (dotimes [i (alength tree-elems)]
+      (let [elem (aget tree-elems i)]
+        (when (number? elem)
+          (aset tree-elems i (* elem elem)))))
+    (prim= tree-elems (.elems solver))))

 (defn self-join-prop [key-len]
   (prop/for-all [min-keys gen/s-pos-int
@@ -924,24 +963,22 @@

 (defn run-product-join-prop [min-keys key-len updates]
   (let [product-tree (tree min-keys key-len)
-        tree (apply-to-tree (tree min-keys key-len) updates)
-        elems (into-array (map first tree))
+        [tree _] (apply-to-tree (tree min-keys key-len) updates)
+        elems (.elems tree)
         _ (dotimes [i (alength elems)]
             (dotimes [j (alength elems)]
-              (.assoc! product-tree (.concat (aget elems i) (aget elems j)) nil)))
+              (when (and (== 0 (mod i 2)) (== 0 (mod j 2)))
+                (.update product-tree (.concat (aget elems i) (aget elems j)) (* (aget elems (+ i 1)) (aget elems (+ j 1)))))))
         solver (solver
                 (* 2 key-len)
                 #js [(contains (iterator tree) (into-array (range 0 key-len)))
                      (contains (iterator tree) (into-array (range key-len (* 2 key-len))))])]
-    (= (map vec (map first product-tree))
-       (map vec solver))))
+    (prim= (.elems product-tree) (.elems solver))))

 (defn product-join-prop [key-len]
   (prop/for-all [min-keys gen/s-pos-int
                  updates (gen/vector (gen-update key-len))]
                 (run-product-join-prop min-keys key-len updates)))
-
-(run-building-prop 1 1 [[:update #js [0] -5] [:update #js [0] 5]])

 (comment
   (dc/quick-check 1000 (least-prop 1))


Fix next for interators

Fix next for interators

--- src/aurora/btree.cljs
+++ src/aurora/btree.cljs
@@ -31,6 +31,7 @@
           (apush result #js [(aget keys ix) (aget vals ix)]))
         (when-not (nil? children)
           (.into (aget children (alength keys)) result)))
+  ;; TODO worth doing binary search here when nodes are large
   (seek [this key ix]
         (let [len (alength keys)]
           (loop [ix ix]
@@ -75,25 +76,23 @@
             (assert (= (alength (.-keys right-node)) (alength (.-vals right-node)) (if (.-children right-node) (dec (alength (.-children right-node))) (alength (.-keys right-node))))))))

 (deftype Iterator [max-keys ^:mutable node ^:mutable ix]
+  ;; always points to before a valid key or to the root node
   Object
   (next [this]
-        (if (< ix (alength (.-keys node)))
-          (let [result #js [(aget (.-keys node) ix) (aget (.-vals node) ix)]]
-            (if-let [child (and (.-children node) (aget (.-children node) ix))]
-              (do
-                (set! node child)
-                (set! ix 0))
-              (set! ix (+ ix 1)))
-            result)
-          (let [parent (.-parent node)]
-            (if (instance? Node parent)
-              ;; jump into parent and start again
-              (do
-                (set! ix (+ (.-parent-ix node) 1))
-                (set! node parent)
-                (recur))
-              ;; end of tree
-              nil))))
+        (when (instance? Node node)
+          (if (nil? (.-children node))
+            (do
+              (set! ix (+ ix 1))
+              (loop []
+                (when (and (instance? Node node) (>= ix (alength (.-keys node))))
+                  (set! ix (.-parent-ix node))
+                  (set! node (.-parent node))
+                  (recur))))
+            (do
+              (set! node (aget (.-children node) (+ ix 1)))
+              (set! ix 0)))
+          (when (instance? Node node)
+            #js [(aget (.-keys node) ix) (aget (.-vals node) ix)])))
   (seek [this key] ;; move the iterator forwards until it reaches a key greater than this one
         ;; head across and upwards until we reach a greater key
         (loop []
@@ -138,7 +137,10 @@
           nil)))

 (defn iterator [tree]
-  (Iterator. (.-max-keys tree) (.-root tree) 0))
+  (loop [node (.-root tree)]
+    (if (nil? (.-children node))
+      (Iterator. (.-max-keys tree) node -1)
+      (recur (aget (.-children node) 0)))))

 (defn tree [min-keys]
   (let [node (Node. nil nil #js [] #js [] nil)
@@ -182,24 +184,43 @@
     (js/console.log tree)
     (seq tree))

-  (let [tree (Tree. max-keys (Node. nil nil #js [] #js [] #js[]))
+  (let [tree (tree 3)]
+    (dotimes [i 1000]
+      (.assoc! tree i (* 2 i)))
+    (= (map #(.apply vector nil %) (seq tree)) (for [i (range 1000)] [i (* 2 i)])))
+
+  (time
+   (let [tree (tree 1)]
+     (dotimes [i 100000]
+       (.assoc! tree i (* 2 i)))))
+
+  (time
+   (let [tree (tree 3)]
+     (dotimes [i 100000]
+       (.assoc! tree i (* 2 i)))))
+
+  (time
+   (let [tree (tree 10)]
+     (dotimes [i 100000]
+       (.assoc! tree i (* 2 i)))))
+
+  (time
+   (let [tree (tree 1000)]
+     (dotimes [i 100000]
+       (.assoc! tree i (* 2 i)))))
+
+  (let [tree (tree 3)
         iterator (iterator tree)]
-    (take-while identity (repeatedly #(.next iterator))))
-
-  (let [tree (Tree. max-keys (Node. nil nil #js [:a :b :c] #js [0 1 2] #js[]))
+    (take 2000 (take-while identity (repeatedly #(.next iterator)))))
+
+  (let [tree (tree 3)
+        _ (.assoc! tree :a 0)
         iterator (iterator tree)]
-    (take-while identity (repeatedly #(.next iterator))))
-
-  (let [branch (Node. nil nil #js [:a :d :e] #js [0 3 4] #js[])
-        _ (apush (.-children branch) (Node. branch 0 #js [:b :c] #js [1 2]))
-        tree (Tree. max-keys branch)
+    (take 2000 (take-while identity (repeatedly #(.next iterator)))))
+
+  (let [tree (tree 3)
+        _ (dotimes [i 1000]
+            (.assoc! tree i (* 2 i)))
         iterator (iterator tree)]
-    (take-while identity (repeatedly #(.next iterator))))
-
-  (let [branch (Node. nil nil #js [:a :d :f] #js [0 3 4] #js[])
-        _ (apush (.-children branch) (Node. branch 0 #js [:b :c] #js [1 2]))
-        tree (Tree. max-keys branch)
-        iterator (iterator tree)]
-    [(.seek iterator :0) (.seek iterator :c) (.seek iterator :a) (.seek iterator :e) (.seek iterator :e) (.seek iterator :p)])
-
+    (take 2000 (take-while identity (repeatedly #(.next iterator)))))
   )


abstract out (lexemes-before-phrases) probability function

--- src/babel/forest.cljc
+++ src/babel/forest.cljc
@@ -70,7 +70,13 @@
                         (add-complements-to-bolts [:head :head :comp]       :top grammar lexicon index morph)
                         (add-complements-to-bolts [:head :comp]             :top grammar lexicon index morph)
                         (add-complements-to-bolts [:comp]                   :top grammar lexicon index morph)))))))
-
+
+(defn lexemes-before-phrases []
+  ;; TODO: take depth as an argument; make phrases decreasingly likely as depth increases.
+  (let [result (= (rand-int 3) 0)]
+    (log/debug (str "lexemes-before-phrases => " result))
+    result))
+
 ;; TODO: add usage of rule-to-lexicon cache (rather than using lexicon directly)
 (defn lightning-bolt [grammar lexicon spec & [ depth index parent morph]]
   "Returns a lazy-sequence of all possible trees given a spec, where
@@ -166,7 +172,7 @@
                           )
                         )
                        candidate-parents))]
-        (if (= (rand-int 2) 0)
+        (if (lexemes-before-phrases)
           (lazy-cat lexical phrasal)
           (lazy-cat phrasal lexical))))))

@@ -233,10 +239,16 @@
                                (if is-fail? :fail result)))

                            ;; lazy-sequence of phrasal complements to pass one-by-one to the above (map)'s function.
-                           (let [phrasal-complements (generate-all spec grammar lexicon cache morph)]
-                             (if (= (rand-int 2) 0)
-                               (lazy-cat shuffled-candidate-lexical-complements phrasal-complements)
-                               (lazy-cat phrasal-complements shuffled-candidate-lexical-complements)))))]
+                           (do
+                             (log/debug (str "generating lexical complements with spec: " (strip-refs spec)))
+                             (let [phrasal-complements (generate-all spec grammar lexicon cache morph)]
+                               (if (lexemes-before-phrases)
+                                 (lazy-cat shuffled-candidate-lexical-complements phrasal-complements)
+                                 (do
+                                   (if (not (empty? phrasal-complements))
+                                     (log/debug (str "first phrasal complement for: " (get-in bolt [:rule]) ":" (morph (first phrasal-complements))))
+                                     (log/debug (str "no phrasal complements for: " (get-in bolt [:rule]) ".")))
+                                   (lazy-cat phrasal-complements shuffled-candidate-lexical-complements)))))))]
           (let [run-time (- (current-time) start-time)]
             (if (empty? return-val)


fixed parsing args with spaces

fixed parsing args with spaces

--- src/selmer/template_parser.clj
+++ src/selmer/template_parser.clj
@@ -14,9 +14,10 @@
 (defn get-tag-params [tag-id block-str]
   (-> block-str (split tag-id) second (split *tag-second-pattern*) first trim))

-(defn parse-defaults [defaults]
-  (when defaults
+(defn parse-defaults [defaults]
+  (when defaults
     (->> defaults
+         (interpose " ")
          (apply str)
          split-by-args
          (partition 2)


Fix missing use of createDom

Fix missing use of createDom

--- src/gitique/core.cljs
+++ src/gitique/core.cljs
@@ -153,9 +153,8 @@

 (defn- add-icon! [element]
   (let [parent (.-parentElement (.-parentElement element))
-        plusIcon (js/document.createElement "span")]
-    (.setAttribute plusIcon "class" "octicon octicon-diff-added")
-    (.insertBefore parent plusIcon (.-firstChild parent))))
+        plus-icon (dom/createDom "span" #js["octicon" "octicon-diff-added"])]
+    (.insertBefore parent plus-icon (.-firstChild parent))))

 (defn- add-icons! [commit-block]
   (dorun (map add-icon! (.querySelectorAll (:element commit-block) ".commit-id"))))


Cache control.

Cache control.


Minor improvement

Minor improvement

--- src/adventofcode1/four.clj
+++ src/adventofcode1/four.clj
@@ -22,6 +22,7 @@
   [name]
   (rest (re-find (re-matcher #"([-a-z]+)(\d+)\[(.+)\]" name))))

+;; Improve: using ::name both for "aaaaa-bbb-z-y-x-123[abxyz]" and "aaaaa-bbb-z-y-x-"
 (s/def ::name string?)
 (s/def ::checksum string?)
 (s/def ::sectorid integer?)
@@ -45,9 +46,11 @@
 (defn build-result
   "Checksum is the five most common letters in the encrypted name, in order, with ties broken by alphabetization."
   [acc distinct-keys checksum]
-  (if (empty? distinct-keys) acc
-      (let [res (filter (fn [[cnt char]] (= cnt (first distinct-keys))) checksum)]
-        (recur (concat acc res) (rest distinct-keys) checksum))))
+  (if (empty? distinct-keys)
+    ;; we cannot guarantee there will not be more than 5 chars, just keep the first ones
+    (take 5 acc)
+    (let [res (filter (fn [[cnt char]] (= cnt (first distinct-keys))) checksum)]
+      (recur (concat acc res) (rest distinct-keys) checksum))))

 (s/fdef checksum
         :args (s/cat :name ::name)
@@ -61,7 +64,7 @@
         ;; (distinct (map first checksum)) is the letters in occurrency order
         ;; (reverse checksum) is the order we are going to show them if tie
         res (build-result [] (reverse (distinct (map first checksum))) checksum)]
-    (clojure.string/join (map second (take 5 res)))))
+    (clojure.string/join (map second res))))

 (defn valid-room-name


set pub date for clips post

set pub date for clips post


one of those typical cases where you fix something that doesn't matter much and you broke the whole thing

--- src/setlista/core.clj
+++ src/setlista/core.clj
@@ -7,8 +7,7 @@
 (def setlist-api "http://api.setlist.fm/rest/0.1/search/setlists.json")

 (defn index []
-  {:headers {"Content-Type" "text/html"}
-   :body (io/resource "public/index.html")})
+  (io/resource "public/index.html"))

 (defn search
   [artist date]


Make promise aware of clojure dynamic context bindings.

--- src/promesa/impl/promise.cljc
+++ src/promesa/impl/promise.cljc
@@ -90,16 +90,26 @@

      pt/IPromise
      (-map [it cb]
-       (let [func (reify Function (apply [_ v] (cb v)))]
+       (let [binds (clojure.lang.Var/getThreadBindingFrame)
+             func (reify Function
+                    (apply [_ v]
+                      (clojure.lang.Var/resetThreadBindingFrame binds)
+                      (cb v)))]
          (.thenApplyAsync it ^Function func ^Executor +executor+)))

      (-bind [it cb]
-       (let [func (reify Function (apply [_ v] (cb v)))]
+       (let [binds (clojure.lang.Var/getThreadBindingFrame)
+             func (reify Function
+                    (apply [_ v]
+                      (clojure.lang.Var/resetThreadBindingFrame binds)
+                      (cb v)))]
          (.thenComposeAsync it ^Function func ^Executor +executor+)))

      (-catch [it cb]
-       (let [func (reify Function
+       (let [binds (clojure.lang.Var/getThreadBindingFrame)
+             func (reify Function
                     (apply [_ e]
+                      (clojure.lang.Var/resetThreadBindingFrame binds)
                       (if (instance? CompletionException e)
                         (cb (.getCause ^Exception e))
                         (cb e))))]


Added arguments indicating whether soot has to be run.

--- EkekoAspectJ/test/test/damp/ekeko/aspectj.clj
+++ EkekoAspectJ/test/test/damp/ekeko/aspectj.clj
@@ -146,10 +146,10 @@

 (deftest
   test-suite
-  (against-project-named "AJ-LMP-Precedence" aspect-test )
-  (against-project-named "AJ-LMP-Pointcuts" concretization-test)
-  (against-project-named "AJ-LMP-ITD" intertypemethod-unused-test)
-  (against-project-named "AJ-LMP-Precedence" overriden-implicit-precedence-test))
+  (against-project-named "AJ-LMP-Precedence" false aspect-test )
+  (against-project-named "AJ-LMP-Pointcuts" false concretization-test)
+  (against-project-named "AJ-LMP-ITD" true intertypemethod-unused-test)
+  (against-project-named "AJ-LMP-Precedence" false overriden-implicit-precedence-test))

 (defn
   test-ns-hook


+divide +forget +note +participate

+divide
+forget
+note
+participate

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -234,6 +234,9 @@
    "displace" {:synsem {:cat :verb
                 :sem {:pred :displace}}}

+   "divide" {:synsem {:cat :verb
+                      :sem {:pred :divide}}}
+
    "drink" {:synsem {:cat :verb
                      :sem {:pred :bere
                            :discrete false
@@ -313,6 +316,10 @@

    "fold" {:synsem {:cat :verb
                     :sem {:pred :fold}}}
+
+   "forget" {:synsem {:cat :verb
+                      :sem {:pred :forget}}
+             :english {:past "forgot"}}

    "form" {:synsem {:cat :verb
                     :sem {:pred :form}}}
@@ -670,6 +677,9 @@
                    :pred :io}
              :subcat '()}}

+   "note" {:synsem {:cat :verb
+                    :sem {:pred :note}}}
+
    "observe" {:synsem {:cat :verb
                 :sem {:pred :observe}}}

@@ -707,6 +717,9 @@
    "paint"  {:synsem {:cat :verb
                       :sem {:pred :dipingere}}}

+   "participate"  {:synsem {:cat :verb
+                            :sem {:pred :participate}}}
+
    ;; TODO: 3sing present exception used below to avoid "playies" is not an exception: it's a rule: y->ys.
    ;; the exceptional case is when "ys" is not used (e.g. "tries").
    "play" [{:comment "We are talking about playing games or sports."


s/.size/doall/

s/.size/doall/

--- src/babel/francais/writer.clj
+++ src/babel/francais/writer.clj
@@ -46,7 +46,7 @@
                    (.size root-verb-array)))

     ;; for debugging, change (pmap) to (map) so logging is easier to read: in-order rather than interleaved by multiple workers.
-    (.size (use-map-fn
+    (doall (use-map-fn
             (fn [verb]
               (log/trace (str "verb: " (strip-refs verb)))
               (let [root-form (get-in verb [:français :français])


Make sure md headings are lower than h1

Make sure md headings are lower than h1

so that they will be lower than the :editorial or :recommendation
heading

--- src/catalog/layout/dtbook.clj
+++ src/catalog/layout/dtbook.clj
@@ -24,9 +24,12 @@
 (defmethod to-dtbook :p [{content :content}] [:p content])
 (defmethod to-dtbook :a [{content :content {href :href} :attrs}]
   [:a {:href href} (if (not-empty content) content href)])
-(defmethod to-dtbook :h1 [{content :content}] [:h1 content])
-(defmethod to-dtbook :h2 [{content :content}] [:h2 content])
-(defmethod to-dtbook :h3 [{content :content}] [:h3 content])
+;; make sure the md headings are lower than h1. That way they will
+;; fit properly into the hierarchy, where :editorial is h1 and the
+;; actual md content is below
+(defmethod to-dtbook :h1 [{content :content}] [:h2 content])
+(defmethod to-dtbook :h2 [{content :content}] [:h3 content])
+(defmethod to-dtbook :h3 [{content :content}] [:h4 content])
 (defmethod to-dtbook :ul [{content :content}] [:list {:type "ul"} content])
 (defmethod to-dtbook :li [{content :content}] [:li content])
 (defmethod to-dtbook :em [{content :content}] [:em content])


fixed rain dependency.

fixed rain dependency.

--- src/clj/forma/source/rain.clj
+++ src/clj/forma/source/rain.clj
@@ -10,6 +10,7 @@
 (ns forma.source.rain
   (:use cascalog.api
         [forma.hadoop.io :only (get-bytes)]
+        [forma.hadoop.predicate :only (window->array)]
         [forma.source.modis :only (hv->tilestring)]
         [forma.reproject :only (project-to-modis
                                 dimensions-at-res)])


fix Franchise City / Film Critic interaction

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -201,8 +201,9 @@
                  :effect (effect (trash card) (lose :bad-publicity (:advance-counter card)))}]}

    "Franchise City"
-   {:events {:pre-steal-cost {:msg "add it to their score area and gain 1 agenda point"
-                              :effect (effect (as-agenda :corp card 1))}}}
+   {:events {:access {:req (req (= (:type target) "Agenda"))
+                      :msg "add it to their score area and gain 1 agenda point"
+                      :effect (effect (as-agenda :corp card 1))}}}

    "Ghost Branch"
    {:advanceable :always


Fix reflection warnings

Fix reflection warnings

--- src/clojure/neko/activity.clj
+++ src/clojure/neko/activity.clj
@@ -43,7 +43,7 @@
   (and (bound? #'*activity*)
        (activity? *activity*)))

-(defn get-decor-view
+(defn ^View get-decor-view
   "Returns the root view of the given activity."
   [^Activity activity]
   (.. activity getWindow getDecorView))
@@ -67,8 +67,8 @@
        (let [dv (get-decor-view activity)]
          (.setTag dv (java.util.HashMap.))
          (.setContentView activity
-                          (neko.ui/make-ui-element activity view
-                                                   {:id-holder dv}))))))
+                          ^View (neko.ui/make-ui-element activity view
+                                                         {:id-holder dv}))))))

 (defn request-window-features!
   "Requests the given features for the activity.  The features should be
@@ -182,7 +182,9 @@
              ~(when (and (not (:neko.init/release-build *compiler-options*))
                          def)
                 `(def ~(vary-meta def assoc :tag name) ~'this))
-             (.put all-activities ~(or key *ns*) ~'this)
+             (.put all-activities ~*ns* ~'this)
+             ~(when key
+                `(.put all-activities ~key ~'this))
              (neko.init/init (.getApplicationContext ~'this))
              (~on-create ~'this ~'savedInstanceState)))
        ~(when on-create-options-menu


Improve invalid screen checker

Improve invalid screen checker

--- src/clojure/nightmod/game.clj
+++ src/clojure/nightmod/game.clj
@@ -23,10 +23,9 @@
            (asset-manager! manager/manager :clear)
            (stop-timers!)
            ; make sure the game screens are valid
-           (doseq [screen game-screens
-                   required-key [:show :render :hide :pause :resize :resume]]
-             (when (or (not (map? screen))
-                       (not (contains? screen required-key)))
+           (doseq [screen game-screens]
+             (when-not (every? #(fn? (get screen %))
+                               [:show :render :hide :pause :resize :resume])
                (throw (Exception. "Invalid screen given to set-game-screen!"))))
            ; set the supplied screen(s) with the overlay screen added at the end
            (apply set-screen!


Changed ultra-pads-with-empties back to false.

--- src/clojush/pushgp/pushgp.clj
+++ src/clojush/pushgp/pushgp.clj
@@ -60,7 +60,7 @@
           :ultra-alignment-deviation 1 ;; When using ULTRA, the standard deviation of how far alternation may jump between indices when switching between parents
           :ultra-mutation-rate 0.1 ;; The probability of each token being mutated during ULTRA
           :use-ultra-no-paren-mutation false ; If true, ULTRA will use no-paren mutation, which means that parentheses won't be added or deleted during mutation.
-          :ultra-pads-with-empties true ;; If true then ULTRA pads the smaller parent with () and then removes them; if false then this is instead done using the symbol 'ultra-padding.
+          :ultra-pads-with-empties false ;; If true then ULTRA pads the smaller parent with () and then removes them; if false then this is instead done using the symbol 'ultra-padding.
           :gaussian-mutation-per-number-mutation-probability 0.5 ;; The probability that any given float literal will be affected by a pass of gaussian-mutate
           :gaussian-mutation-standard-deviation 0.1 ;; The standard deviation of a gaussian-mutated float
           :boolean-gsxover-new-code-max-points 20 ;; The maximum size of the random code fragment used in boolean-gsxover


Loosened constraint in check-genetic-operator-probabilities-add-to-one to allow for round-off errors.

--- src/clojush/pushgp/pushgp.clj
+++ src/clojush/pushgp/pushgp.clj
@@ -261,8 +261,9 @@
                                                               deletion-mutation-probability parentheses-addition-mutation-probability
                                                               tagging-mutation-probability tag-branch-mutation-probability))
         prob-map (select-keys argmap prob-keywords)]
-    (assert (== 1.0
-                (apply + (vals prob-map)))
+    (assert (< 0.99999
+               (apply + (vals prob-map))
+               1.00001)
             (str "Genetic operator probabilities do not sum to 1.0:\n"
                  (clojure.string/replace (str prob-map \newline)
                                          \,


CMR-609: Added namespace comment.

CMR-609: Added namespace comment.

--- src/cmr/indexer/data/bulk.clj
+++ src/cmr/indexer/data/bulk.clj
@@ -1,4 +1,5 @@
-(ns cmr.indexer.data.bulk)
+(ns cmr.indexer.data.bulk
+  "Implementation of elasitch bulk index preparation that supports _version and _version_type")

 (def ^:private special-operation-keys
   [:_index :_type :_version :_version_type :_id :_routing :_percolate :_parent :_timestamp :_ttl])


formatting

formatting

--- pp-cljs-client/project.clj
+++ pp-cljs-client/project.clj
@@ -4,13 +4,13 @@
   :url "http://example.com/FIXME"

   :dependencies [
-    [org.clojure/clojure "1.6.0"]
-    [org.clojure/clojurescript "0.0-2985"]
-    [cljsjs/react "0.12.2-7"]
-    [cljs-ajax "0.3.10"]
-    [sablono "0.3.4"]
-    [secretary "1.2.1"]
-    [quiescent "0.1.4"]]
+                 [org.clojure/clojure "1.6.0"]
+                 [org.clojure/clojurescript "0.0-2985"]
+                 [cljsjs/react "0.12.2-7"]
+                 [cljs-ajax "0.3.10"]
+                 [sablono "0.3.4"]
+                 [secretary "1.2.1"]
+                 [quiescent "0.1.4"]]

   :plugins [[lein-cljsbuild "1.0.4"]]

@@ -21,18 +21,18 @@
   :jvm-opts ["-Xmx384m"]

   :cljsbuild {
-    :builds {
-      :main {
-        :source-paths ["src-cljs"]
-        :compiler {
-          :output-to "public/js/pretty-print.js"
-          :output-dir "public/out"
-          :optimizations :whitespace}}
+              :builds {
+                       :main {
+                              :source-paths ["src-cljs"]
+                              :compiler {
+                                         :output-to "public/js/pretty-print.js"
+                                         :output-dir "public/out"
+                                         :optimizations :whitespace}}

-      :main-min {
-        :source-paths ["src-cljs"]
-        :compiler {
-          :output-to "public/js/pretty-print.min.js"
-          :output-dir "public/out-min"
-          :optimizations :advanced
-          :pretty-print false }}}})
+                       :main-min {
+                                  :source-paths ["src-cljs"]
+                                  :compiler {
+                                             :output-to "public/js/pretty-print.min.js"
+                                             :output-dir "public/out-min"
+                                             :optimizations :advanced
+                                             :pretty-print false}}}})


Cosmetic fixes on zoom related events.

Cosmetic fixes on zoom related events.

--- src/uxbox/data/workspace.cljs
+++ src/uxbox/data/workspace.cljs
@@ -140,7 +140,9 @@
 (defrecord IncreaseZoom []
   rs/UpdateEvent
   (-apply-update [_ state]
-    (let [increase #(nth zoom-levels (+ (index-of zoom-levels %) 1) (last zoom-levels))]
+    (let [increase #(nth zoom-levels
+                         (+ (index-of zoom-levels %) 1)
+                         (last zoom-levels))]
       (update-in state [:workspace :zoom] (fnil increase 1)))))

 (defn increase-zoom
@@ -152,7 +154,9 @@
 (defrecord DecreaseZoom []
   rs/UpdateEvent
   (-apply-update [_ state]
-    (let [decrease #(nth zoom-levels (- (index-of zoom-levels %) 1) (first zoom-levels))]
+    (let [decrease #(nth zoom-levels
+                         (- (index-of zoom-levels %) 1)
+                         (first zoom-levels))]
       (update-in state [:workspace :zoom] (fnil decrease 1)))))

 (defn decrease-zoom


Use sparkles for box-easy-to-buf!

Use sparkles for box-easy-to-buf!

--- src/caesium/crypto/box.clj
+++ src/caesium/crypto/box.clj
@@ -75,14 +75,14 @@
   "Encrypts ptext into out with `crypto_box_easy` using given nonce,
   public key and secret key.

+  All arguments must be `java.nio.ByteBuffer`.
+
   This function is only useful if you're managing your own output
   buffer, which includes in-place encryption. You probably
   want [[box-easy]]."
-  [^ByteBuffer out ^ByteBuffer ptext ^ByteBuffer nonce
-   ^ByteBuffer pk ^ByteBuffer sk]
-  (let [plen (long (bb/buflen ptext))]
-    (.crypto_box_easy b/sodium out ptext plen nonce pk sk)
-    out))
+  [c m n pk sk]
+  (b/✨ easy c m plen n pk sk)
+  c)

 (defn box-open-easy-to-buf!
   "Decrypts ptext into out with `crypto_box_open_easy` using given


removed some commented out code

removed some commented out code

--- src/chat/client/views.cljs
+++ src/chat/client/views.cljs
@@ -81,8 +81,6 @@

         (HeaderView. #js {:subscribe subscribe})

-        ;(om/build chat.client.views.header/header-view data)
-
         (case (get-in data [:page :type])
           :inbox (om/build inbox-page-view data)
           :recent (om/build recent-page-view data)


don't use future, prevents :cljs/quit, use Thread + bound-fn

--- src/clj/cljs/repl/node.clj
+++ src/clj/cljs/repl/node.clj
@@ -105,8 +105,8 @@
           proc (-> (ProcessBuilder. (into-array [(get opts :node-command "node")]))
                  (.redirectInput of)
                  .start)
-          _ (do (future (pipe proc (.getInputStream proc) *out*))
-                (future (pipe proc (.getErrorStream proc) *err*)))
+          _ (do (.start (Thread. (bound-fn [] (pipe proc (.getInputStream proc) *out*))))
+                (.start (Thread. (bound-fn [] (pipe proc (.getErrorStream proc) *err*)))))
           env  (ana/empty-env)
           core (io/resource "cljs/core.cljs")
           ;; represent paths as vectors so we can emit JS arrays, this is to


rotating cube

rotating cube

--- src/cljs/cezanne/core.cljs
+++ src/cljs/cezanne/core.cljs
@@ -3,6 +3,10 @@
 (enable-console-print!)

 (.log js/console "Kneel before the holy Kordano!")
+
+
+(def state (atom {}))
+

 (defn init-all []
   (let [scene (js/THREE.Scene.)
@@ -13,17 +17,27 @@
                     1000)
         renderer (js/THREE.WebGLRenderer.)
         geometry (js/THREE.BoxGeometry. 1 1 1)
-        material (js/THREE.MeshBasicMaterial. {"color" "0x00ff00"})
+        material (js/THREE.MeshBasicMaterial. (clj->js {:color 0x5555ff}))
         cube (js/THREE.Mesh. geometry material)]
     (.setSize renderer (.-innerWidth js/window) (.-innerHeight js/window))
     (.. js/document -body (appendChild (.-domElement renderer)))
     (.add scene cube)
     (set! (.. camera -position -z) 5)
-    {:scene scene
-     :camera camera
-     :renderer renderer}))
+    (reset! state
+          {:scene scene
+           :camera camera
+           :cube cube
+           :renderer renderer})))

-(defn render [{:keys [scene camera renderer] :as state}]
-  (js/requestAnimationFrame render state)
-  (.render renderer scene camera))
+
+(defn render []
+  (js/requestAnimationFrame render)
+  (.render (:renderer @state) (:scene @state) (:camera @state))
+  (set! (.. (:cube @state) -rotation -x) (+ (.. (:cube @state) -rotation -x) 0.1))
+  (set! (.. (:cube @state) -rotation -y) (+ (.. (:cube @state) -rotation -y) 0.1))
+  )
+
+
+(init-all)
+(render)


remove obsolete method

remove obsolete method

--- src/cljs/nickel/board.cljs
+++ src/cljs/nickel/board.cljs
@@ -35,12 +35,3 @@

 (defn ^boolean coord-visitable? [board coord]
   (= 1 (get-tile board coord)))
-
-(defn map-cells [f board]
-  (map-indexed
-    (fn [y row]
-      (map-indexed
-        (fn [x cell]
-          (f (get-tile board [x y]) x y))
-        row))
-    board))


DRY a little

DRY a little


Added unknown type

Added unknown type

--- src/lobos/migrations.clj
+++ src/lobos/migrations.clj
@@ -23,6 +23,7 @@

 (defmigration add-basic-types
               (up [] (sql/insert! lobos.config/db :types
+                                  {:id 1 :name "Unknown"}
                                   {:name "Bar"}
                                   {:name "Pub"}
                                   {:name "Take Away"} ))


Inlined lattice-from-layout

Inlined lattice-from-layout

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

--- src/conexp/layout/base.clj
+++ src/conexp/layout/base.clj
@@ -105,15 +105,10 @@
   [layout]
   (reflexive-transitive-closure (nodes layout) (connections layout)))

-(defn- lattice-from-layout
-  "Computes lattice from a given layout."
-  [layout]
-  (make-lattice (nodes layout) (order layout)))
-
 (def-layout-fn lattice
   "Returns lattice represented by layout."
   [layout]
-  (lattice-from-layout layout))
+  (make-lattice (nodes layout) (order layout)))

 ;;;


cleanup

cleanup

--- src/babel/italiano/morphology/determiners.cljc
+++ src/babel/italiano/morphology/determiners.cljc
@@ -34,6 +34,4 @@
     :u {:synsem {:cat :det
                  :agr {:number :sing
                        :gender :masc}}}}
-
-
    ])


divisors

divisors

--- stuf/src/sandbox/4clojure.clj
+++ stuf/src/sandbox/4clojure.clj
@@ -1126,4 +1126,14 @@
                   coords)
           (map #(apply str %))))))

-
+;;Veitch
+(defn torus [m]
+  (let [double-x (map #(vec (concat % %)) m)]
+    (vec (concat double-x double-x))))
+
+(defn get-in-tor [t [y x]]
+  (let [base (quot (count t) 2)]
+    (get-in t [(+ base y) (+ base x)])))
+
+(defn divs [x]
+  (for [i (range 1 (inc x)) j (range 1 (inc x)) :when (= x (* i j))] [i j]))


Rename from-parent new logging alias from log2

Since I'm no longer using clojure.tools.logging in there


More doc strings in grafter.rdf.sesame namespace.

--- src/grafter/rdf/sesame.clj
+++ src/grafter/rdf/sesame.clj
@@ -49,11 +49,14 @@
   (context [this] (.getContext this)))

 (defprotocol ISesameRDFConverter
-  (->sesame-rdf-type [this])
-  (sesame-rdf-type->type [this]))
+  (->sesame-rdf-type [this] "Convert a native type into a Sesame RDF Type")
+  (sesame-rdf-type->type [this] "Convert a Sesaem RDF Type into a Native Type"))

 (defn s
-  "Cast a string to an RDF literal"
+  "Cast a string to an RDF literal.  The second optional argument can
+  either be a keyword corresponding to an RDF language tag
+  e.g. :en, :en-gb, or :fr or a string or URI in which case it is
+  assumed to be a URI identifying the RDF type of the literal."
   ([str]
      {:pre [(string? str)]}
      (reify Object
@@ -72,9 +75,13 @@
                               lang-or-uri))))))

-(defmulti literal-datatype->type (fn [literal]
-                                   (when-let [datatype (-> literal .getDatatype)]
-                                     (str datatype))))
+(defmulti literal-datatype->type
+  "A multimethod to convert an RDF literal into a corresponding
+  Clojure type.  This method can be extended to provide custom
+  conversions."
+  (fn [literal]
+    (when-let [datatype (-> literal .getDatatype)]
+      (str datatype))))

 (defmethod literal-datatype->type nil [literal]
   (s (.stringValue literal) (.getLanguage literal)))
@@ -255,7 +262,9 @@
   (->sesame-rdf-type [this]
     (BNodeImpl. (name this))))

-(defn IStatement->sesame-statement [is]
+(defn IStatement->sesame-statement
+  "Convert a grafter IStatement into a Sesame statement."
+  [is]
   (if (:c is)
     (do
       (ContextStatementImpl. (->sesame-rdf-type (.s is))
@@ -266,7 +275,9 @@
                     (URIImpl. (.p is))
                     (->sesame-rdf-type (.o is)))))

-(defn sesame-statement->IStatement [st]
+(defn sesame-statement->IStatement
+  "Convert a sesame Statement into a grafter Quad."
+  [st]
   ;; TODO fix this to work properly with object & context.
   ;; context should return either nil or a URI
   ;; object should be converted to a clojure type.
@@ -373,20 +384,27 @@
        ;; them... otherwise.. ignore the graph param
        (pr/add this triples))))

-(defn memory-store []
+(defn memory-store
+  "Instantiate a sesame RDF MemoryStore."
+  []
   (MemoryStore.))

 (defn native-store
+  "Instantiate a sesame RDF NativeStore."
   ([datadir]
      (native-store (io/file datadir) "spoc,posc,cosp"))
   ([datadir indexes]
      (NativeStore. datadir indexes)))

 (defn http-repo [repo-url]
+  "Given a URL as a String return a Sesame HTTPRepository for e.g.
+  interacting with the OpenRDF Workbench."
   (doto (HTTPRepository. repo-url)
     (.initialize)))

 (defn sparql-repo
+  "Given a query-url and an optional update-url String return a Sesame
+  SPARQLRepository for communicating with remote repositories."
   ([query-url]
      (doto (SPARQLRepository. query-url)
        (.initialize)))
@@ -395,12 +413,18 @@
        (.initialize))))

 (defn repo
+  "Given a sesame Store of some type, return a sesame SailRepository."
   ([] (repo (MemoryStore.)))
   ([store]
      (doto (SailRepository. store)
        (.initialize))))

-(defn load-rdf [connection file base-uri-str format]
+(defn load-rdf
+  "Loads the specified RDF file into the supplied repository.
+
+  Takes a String or File (specifying a path to an RDF file) a base-uri
+  String and an RDFFormat."
+  [connection file base-uri-str format]
   (.add connection (io/file file) base-uri-str format (into-array Resource [])))

 (defn- query-bindings->map [qbs]
@@ -484,7 +508,8 @@
        (run-query))))

 (defprotocol IQueryEvaluator
-  (evaluate [this]))
+  (evaluate [this] "Low level protocol to evaluate a sesame RDF Query
+  object, and convert the results into a grafter representation."))

 (extend-protocol IQueryEvaluator
   BooleanQuery
@@ -503,12 +528,19 @@
   (evaluate [this]
     (.execute this)))

-(defn ->connection [repo]
+(defn ->connection
+  "Given a sesame repository return a connection to it."
+  [repo]
   (if (instance? RepositoryConnection repo)
     repo
     (.getConnection repo)))

 (defn prepare-query
+  "Low level function to prepare (parse, but not process) a sesame RDF
+  query.  Takes a repository a query string and an optional sesame
+  Dataset to act as a query restriction.
+
+  Prepared queries still need to be evaluated with evaluate."
   ([repo sparql-string] (prepare-query repo sparql-string nil))
   ([repo sparql-string dataset]
      (let [conn (->connection repo)]
@@ -518,6 +550,9 @@
          (.setDataset dataset)))))

 (defn prepare-update
+  "Prepare (parse but don't process) a SPARQL update request.
+
+  Prepared updates still need to be evaluated with evaluate."
   ([repo sparql-update-str] (prepare-update repo sparql-update-str nil))
   ([repo sparql-update-str dataset]
      (let [conn (->connection repo)]
@@ -588,7 +623,9 @@
   (let [dataset (mapply make-restricted-dataset (or options {}))]
     (query-dataset repo sparql dataset)))

-(defn format->parser [format]
+(defn ^:no-doc format->parser
+  "Convert a format into a sesame parser for that format."
+  [format]
   (let [table {RDFFormat/NTRIPLES NTriplesParserFactory
                RDFFormat/TRIX TriXParserFactory
                RDFFormat/TRIG TriGParserFactory
@@ -611,7 +648,7 @@
   (Rio/getParserFormatForFileName fname))

 ;; http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/
-(defn pipe
+(defn- pipe
   "Returns a pair: a seq (the read end) and a function (the write end).
   The function can takes either no arguments to close the pipe
   or one argument which is appended to the seq. Read is blocking."


Add support for FragmentSpread transformer

(transformer (parse "query hasConditionalFragment($condition: Boolean) {
  ...maybeFragment @include(if: $condition)
}

fragment maybeFragment on Query {
  me {
    name
  }
}"))

--- src/graphql_clj/parser.clj
+++ src/graphql_clj/parser.clj
@@ -93,10 +93,13 @@
                 {:named-type (second v)})
    :FragmentName (fn fragment-name [v]
                    (log/debug "FragmentName: " v)
-                   {:fragment-name (second v)})
-   :FragmentSpread (fn fragment-spread [v]
-                     (log/debug "FragmentSpread: " v)
-                     [:fragment-spread v])
+                   [:fragment-name (second v)])
+   :Directive (fn directive [& args]
+                (log/debug "Directive: " args)
+                [:directive (into {} args)])
+   :FragmentSpread (fn fragment-spread [& args]
+                     (log/debug "FragmentSpread: " args)
+                     [:fragment-spread (into {} args)])
    :InlineFragment (fn inline-fragment [& args]
                      (log/debug "InlineFragment: " args)
                      [:inline-fragment (into {} args)])})


Add personal note to the private section invitation email.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -324,7 +324,10 @@
         first-name (-> notice :inviter :first-name)
         last-name (-> notice :inviter :last-name)
         from (s/join " " [first-name last-name])
-        invite-message (if (s/blank? from) anonymous-board-invite-message (str (s/trim from) " " board-invite-message))]
+        invite-message (if (s/blank? from) anonymous-board-invite-message (str (s/trim from) " " board-invite-message))
+        from-avatar (-> notice :inviter :avatar-url)
+        note (:note notice)
+        note? (not (s/blank? note))]
     [:td
       (spacer 40)
       (when logo? (org-logo {:org-name org-name
@@ -339,6 +342,8 @@
       (spacer 28 "body-block" "body-spacer")
       (paragraph board-invite-explainer "body-block")
       (spacer 35 "body-block" "body-spacer")
+      (when note? (personal-note note from-avatar from))
+      (when note? (spacer 35 "body-block" "body-spacer"))
       (cta-button (str "View " board-name) board-url)
       (spacer 40 "body-block bottom" "body-spacer")
       (spacer 33)


Add todo, name test properly

Add todo, name test properly

--- src/onyx_jepsen/core.clj
+++ src/onyx_jepsen/core.clj
@@ -182,6 +182,7 @@
                       ledger-ids)
        job-num))

+;; TODO, merge jobs-data, ledger-handles, and ledger-ids atoms into one big atom map
 (defrecord WriteLogClient [client jobs-data ledger-handles ledger-handle ledger-ids onyx-client]
   client/Client
   (setup! [this test node]
@@ -338,6 +339,7 @@
     (merge tests/noop-test
            {:os os
             :db (setup version)
+            :name "onyx-basic"
             :client (write-log-client (atom {}) (atom []) (atom []))
             :model (->OnyxModel) ;; Currently not actually used for anything
             :checker (onyx-checker/->Checker peer-config n-peers n-jobs)


Fix alignment of code.

Fix alignment of code.

--- src/klangmeister/content.cljs
+++ src/klangmeister/content.cljs
@@ -10,36 +10,35 @@
   {:sine
    ["Sound is made up of pressure waves in the air.
    Here is the simplest possible synthesiser - a bare sine wave."
-   "(defn basic-synthesiser [note]
-     (sine (:pitch note)))
+"(defn basic-synthesiser [note]
+  (sine (:pitch note)))

-   (->> (phrase [1] [72])
-        (all :instrument basic-synthesiser))"]
+(->> (phrase [1] [72])
+  (all :instrument basic-synthesiser))"]
    :interference
    ["To prove sound is based on sine waves, let's add together two waves that are out of phase."
-   "(defn interference [note]
-     (add (sine (* 1.01 (:pitch note))) (sine (:pitch note))))
+"(defn interference [note]
+  (add (sine (* 1.01 (:pitch note))) (sine (:pitch note))))

-   (->> (phrase [1] [72])
-        (all :instrument interference))"]
+(->> (phrase [1] [72])
+  (all :instrument interference))"]
    :envelope
    ["The sound cuts off abruptly. In order to shape it into a real note, we need what's called an envelope. The simplest example of an envelope is a percussive envelope. A percussive envelope is defined by an attack - how long it takes the note to get to maximum loundness, and a decay - how long it takes the note to die away."
-    "(defn plink [note]
-     (connect-> (sine (:pitch note))
-                (percussive 0.05 0.2)))
+"(defn plink [note]
+  (connect-> (sine (:pitch note))
+             (percussive 0.05 0.2)))

-    (->> (phrase [1] [72])
-        (all :instrument plink))"]
+(->> (phrase [1] [72])
+  (all :instrument plink))"]
     :gain
    ["That's a bit loud. To control the volume of a sound, we alter the amplitude of the wave. To do that, we use something called a gain. A gain multiplies the amplitude by a specified factor."
-    "(defn quiet-plink [note]
-    (connect-> (sine (:pitch note))
-    (percussive 0.01 0.2)
-    (gain 0.4)))
+"(defn quiet-plink [note]
+  (connect-> (sine (:pitch note))
+             (percussive 0.01 0.2)
+             (gain 0.4)))

 (->> (phrase [1] [72])
-        (all :instrument quiet-plink))"]
-    })
+  (all :instrument quiet-plink))"]})

 (defn render [k handle! state-atom]
   (let [[text code] (steps k)]


move collide ns within overtone.sc

move collide ns within overtone.sc

--- src/overtone/sc/ugen.clj
+++ src/overtone/sc/ugen.clj
@@ -8,7 +8,7 @@
   (:require [overtone.sc.ugen.doc :as doc]))

 ;;Create a ns to store all ugens that collide with standard ugen fns
-(defonce ugen-collide-ns (create-ns 'overtone.ugen-collide))
+(defonce ugen-collide-ns (create-ns 'overtone.sc.ugen-collide))

 (defn- op-rate
   "Lookup the rate of an input ugen, otherwise use IR because the operand
@@ -279,19 +279,19 @@
 (defonce _ugens (intern-ugens))

 (defmacro with-ugens [& body]
-  `(let [~'+ overtone.ugen-collide/+
-         ~'- overtone.ugen-collide/-
-         ~'* overtone.ugen-collide/*
-         ~'< overtone.ugen-collide/<
-         ~'> overtone.ugen-collide/>
-         ~'= overtone.ugen-collide/=
-         ~'/ overtone.ugen-collide/binary-div-op
-         ~'>= overtone.ugen-collide/>=
-         ~'<= overtone.ugen-collide/<=
-;;TODO addme when available in gc  ~'!= overtone.ugen-collide/!=
-         ~'mod overtone.ugen-collide/mod
-         ~'min overtone.ugen-collide/min
-         ~'max overtone.ugen-collide/max]
+  `(let [~'+ overtone.sc.ugen-collide/+
+         ~'- overtone.sc.ugen-collide/-
+         ~'* overtone.sc.ugen-collide/*
+         ~'< overtone.sc.ugen-collide/<
+         ~'> overtone.sc.ugen-collide/>
+         ~'= overtone.sc.ugen-collide/=
+         ~'/ overtone.sc.ugen-collide/binary-div-op
+         ~'>= overtone.sc.ugen-collide/>=
+         ~'<= overtone.sc.ugen-collide/<=
+;;TODO addme when available in gc  ~'!= overtone.sc.ugen-collide/!=
+         ~'mod overtone.sc.ugen-collide/mod
+         ~'min overtone.sc.ugen-collide/min
+         ~'max overtone.sc.ugen-collide/max]
      ~@body))

 (defn combined-specs


mapper function of the workflow has been fixed

--- core/src/cljc/hellhound/system/impl/splitter.cljc
+++ core/src/cljc/hellhound/system/impl/splitter.cljc
@@ -10,7 +10,7 @@
   ;; TODO: Remove this binding and refactor the connect function
   ;;       To not use it
   {:hellhound.workflow/predicate #(identity %)
-   :hellhound.component/map      #(identity %)})
+   :hellhound.workflow/map      #(identity %)})

 (defn- transform-and-put
@@ -22,7 +22,7 @@
   ;;       function knows too much.
   (let [filter-fn (or (:hellhound.workflow/predicate node)
                       #(identity %))
-        map-fn (or (:hellhound.component/map node)
+        map-fn (or (:hellhound.workflow/map node)
                    #(identity %))]
     (when (filter-fn value)
       (map-fn value))))


Neaten get-latest function

Neaten get-latest function

--- src/leiningen/ancient/get.clj
+++ src/leiningen/ancient/get.clj
@@ -6,7 +6,8 @@
             [leiningen.ancient.utils.io :refer [with-output-settings]]
             [ancient-clj.verbose :refer :all]
             [ancient-clj.core :as anc]
-            [version-clj.core :as v]))
+            [version-clj.core :as v]
+            [ancient-clj.repository :refer [retrieve-latest-version-string!]]))

 (def ^:private ^:const WIDTH
   "Maximum width of labels for `:get`."
@@ -67,16 +68,10 @@
 (defn run-latest-vector-task!
   [project [package & args]]
   (if-not package
-    (println "':get' expects an artifact to retrieve version information for.")
-    (let [settings (-> (parse-cli args) (assoc :aggressive? true))
-          {:keys [artifact-id group-id] :as artifact} (anc/artifact-map [package "RELEASE"])
-          artifact-str (str group-id "/" artifact-id)]
+    (println "Expected an artifact to retrieve version information for")
+    (let [settings (assoc (parse-cli args) :aggressive? true)
+          artifact (anc/artifact-map [package "RELEASE"])]
       (with-output-settings settings
-        (let [repos (collect-repositories project)]
-          (let [vs (->> (anc/versions! settings repos artifact)
-                     (sort #(v/version-seq-compare (second %1) (second %2)))
-                     (reverse))]
-            (if-not (seq vs)
-              (println "No versions found.")
-              (let [releases (filter (complement (comp v/qualified? second)) vs)]
-                (println (str  "[" package " \""  (ffirst releases) "\"]") )))))))))
+        (if-let [latest (retrieve-latest-version-string! settings (collect-repositories project) (:group-id artifact) (:artifact-id artifact))]
+          (println (str  "[" package " \"" latest "\"]") )
+          (println "No versions found"))))))


added options to specify keypass and storepass for release build

--- src/leiningen/droid/build.clj
+++ src/leiningen/droid/build.clj
@@ -153,15 +153,20 @@
   Either a debug keystore key or a release key is used based on
   whether the build type is the debug one. Creates a debug keystore if
   it is missing."
-  [{{:keys [out-apk-path keystore-path key-alias]} :android :as project}]
+  [{{:keys [out-apk-path
+            keystore-path key-alias keypass storepass]} :android :as project}]
   (info "Signing APK...")
   (let [dev-build (dev-build? project)
         suffix (if dev-build "debug-unaligned" "unaligned")
         unaligned-path (append-suffix out-apk-path suffix)
-        storepass (if dev-build "android"
-                      (read-password "Enter storepass: "))
-        keypass (if dev-build "android"
-                    (read-password "Enter keypass: "))]
+        storepass (cond storepass storepass
+                        dev-build "android"
+                        :else
+                        (read-password "Enter storepass: "))
+        keypass (cond keypass keypass
+                      dev-build "android"
+                      :else
+                      (read-password "Enter keypass: "))]
     (when (and dev-build (not (.exists (io/file keystore-path))))
       ;; Create a debug keystore if there isn't one
       (create-debug-keystore keystore-path))


fix usage message

fix usage message

--- src/leiningen/new/wma_clj.clj
+++ src/leiningen/new/wma_clj.clj
@@ -30,15 +30,16 @@
      "park-filter" (park/clj-park-filter name)
      "web-app" (web-app/cljs-web-app name)
      "web-lib" (web-lib/cljs-web-lib name)
-     ;; TODO filter node-filter node-web-app web-app-filter
+     ;; TODO filter node-filter node-web-app web-app-filter
+     ;; TODO lein-template
+     ;; TODO +graphql +h2 +postgresql +rest +rum +sqlite
      (println "unrecognized type" type
               "\nusage:"
-              "\nlein new wma-clj app"
-              "\nlein new wma-clj cli"
-              "\nlein new wma-clj node-cli"
-              "\nlein new wma-clj node-lib"
-              "\nlein new wma-clj park-filter"
-              "\nlein new wma-clj lib"
-              "\nlein new wma-clj web-app"
-              "\nlein new wma-clj web-lib"))))
-
+              "\nlein new wma-clj foo # defaults to: foo lib"
+              "\nlein new wma-clj foo cli"
+              "\nlein new wma-clj foo node-cli"
+              "\nlein new wma-clj foo node-lib"
+              "\nlein new wma-clj foo park-filter"
+              "\nlein new wma-clj foo lib"
+              "\nlein new wma-clj foo web-app"
+              "\nlein new wma-clj foo web-lib"))))


stop on overflow in bursts

stop on overflow in bursts

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

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -286,7 +286,7 @@
 (defn init-burst [length]
   (core setAutoShutter (@state :init-auto-shutter))
   (swap! state assoc :burst-init-time (elapsed-time @state))
-  (core startSequenceAcquisition length 0 false))
+  (core startSequenceAcquisition length 0 true))

 (defn expose [event]
   (do (condp = (:task event)
@@ -315,7 +315,10 @@
                 :snap (collect-snap-image)
                 :init-burst (collect-burst-image)
                 :collect-burst (collect-burst-image))]
-    (.put out-queue (make-TaggedImage (annotate-image image event @state)))))
+    (if (. mmc isBufferOverflowed)
+      (do (swap! state assoc :stop true)
+          (ReportingUtils/showError "Circular buffer overflowed."))
+      (.put out-queue (make-TaggedImage (annotate-image image event @state))))))

 (defn compute-z-position [event]
   (if-let [z-drive (:z-drive event)]


Few extra overview notes

Few extra overview notes

--- src/polismath/server.clj
+++ src/polismath/server.clj
@@ -152,7 +152,13 @@

 ;; What follows is the guts of our responding and computing.
-;; The outline of what this looks like is as follows:
+
+;; We try to respond as soon as possible to the request.
+;; If the computation takes too long, we respond with a 202 and a Location pointing to a status url.
+;; When that url is pinged, it responds a 200 saying to check back later if it's not done.
+;; If the computation is complete, it responds with a 201, and a url at which the results can be downloaded.
+
+;; A more detailed outline of what this looks like in code is as follows:

 ;; get export params
 ;;   * notify-mongo (:started)
@@ -192,7 +198,6 @@

 ;; Requests for exported files in aws.
-;;

 (defn redirect-to-aws-url
   "Creates a redirection response, which redirects to the aws download link."


Debound hint update

Debound hint update

--- src/lt/objs/langs/clj.cljs
+++ src/lt/objs/langs/clj.cljs
@@ -605,6 +605,7 @@
                   :triggers #{:focus
                               :editor.eval.clj.result
                               :editor.eval.cljs.result}
+                  :debounce 1000
                   :reaction (fn [editor res]
                               (when (not= :hints (-> res :meta :result-type)) ;; dont recurse endlessly
                                 (when-let [default-client (-> @editor :client :default)] ;; dont eval unless we're already connected


Use plugin name instead of plugin folder to determine cljs output file

--- src/lt/objs/langs/clj.cljs
+++ src/lt/objs/langs/clj.cljs
@@ -23,7 +23,8 @@
             [lt.util.load :as load]
             [lt.util.cljs :refer [->dottedkw str-contains?]]
             [clojure.string :as string]
-            [lt.objs.command :as cmd])
+            [lt.objs.command :as cmd]
+            [lt.objs.plugins :as plugins])
   (:require-macros [lt.macros :refer [behavior defui]]))

 (def shell (load/node-module "shelljs"))
@@ -232,7 +233,7 @@
                   :triggers #{:cljs.compile.results}
                   :desc "Plugin: output compile results"
                   :reaction (fn [this res]
-                              (let [plugin-name (files/basename (:lt.objs.plugins/plugin-path @this))
+                              (let [plugin-name (-> (:lt.objs.plugins/plugin-path @this) plugins/plugin-info :name string/lower_case)
                                     final-path (files/join (:lt.objs.plugins/plugin-path @this) (str plugin-name "_compiled.js"))]
                                 (notifos/done-working (str "Compiled plugin to " final-path))
                                 (files/save final-path (:js res)))


don't append source maps if :source-map not set, cleanup load-macros

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -240,13 +240,9 @@
       (let [k (or (k reload)
                   (get-in reloads [k nsym])
                   (and (= nsym name) (:*reload-macros* bound-vars) :reload))]
-        (if k
-          (require bound-vars nsym k (assoc opts :macros-ns true)
-            (fn []
-              (load-macros bound-vars k (next macros) reload reloads opts cb)))
-          (require bound-vars nsym (assoc opts :macros-ns true)
-            (fn []
-              (load-macros bound-vars k (next macros) reload reloads opts cb))))
+        (require bound-vars nsym k (assoc opts :macros-ns true)
+          (fn []
+            (load-macros bound-vars k (next macros) reload reloads opts cb)))
         ;(intern-macros nsym k)
         ))
     (cb)))
@@ -416,8 +412,9 @@
                    (fn [_] (compile-loop)))
                  (recur)))
              (do
-               (append-source-map env/*compiler*
-                 name source sb @comp/*source-map-data* opts)
+               (when (:source-map opts)
+                 (append-source-map env/*compiler*
+                   name source sb @comp/*source-map-data* opts))
                (cb (.toString sb))))))))))

 (defn compile
@@ -495,8 +492,9 @@
                               :source js-source}]
                (when (:verbose opts)
                  (debug-prn js-source))
-               (append-source-map env/*compiler*
-                 name source sb @comp/*source-map-data* opts)
+               (when (:source-map opts)
+                 (append-source-map env/*compiler*
+                   name source sb @comp/*source-map-data* opts))
                (cb {:ns ns :value (*eval-fn* evalm)}))))))
       (:*cljs-ns* bound-vars))))


Add Windows condition to main-test

Add Windows condition to main-test

--- test/runbld/test/main_test.clj
+++ test/runbld/test/main_test.clj
@@ -57,10 +57,15 @@
                                   ;; to satisfy schema
                                   {})]
         (git/with-tmp-repo [d "tmp/git/main-test-2"]
-          (let [args ["-c" "test/config/main.yml"
-                      "-j" "elastic+foo+master"
-                      "-d" d
-                      "test/fail.bash"]
+          (let [args (concat
+                       ["-c" "test/config/main.yml"
+                         "-j" "elastic+foo+master"
+                         "-d" d]
+                       (if (.startsWith (io/os) "WINDOWS")
+                           ["-p" "CMD.EXE"
+                            "-a" "/C"
+                            "test/fail.bat"]
+                           ["test/fail.bash"]))
                 opts (opts/parse-args args)
                 res (apply main/-main args)]
             (is (= 1 (:exit-code res)))


70,71,72,73

--- src/sandbox/4clojure.clj
+++ src/sandbox/4clojure.clj
@@ -276,3 +276,20 @@
        (map (fn [[k v]] [k (reduce f (map second v))]))
        (into {})))

+;;70 Word Sorting
+(defn g [str] (sort-by #(.toLowerCase %) (re-seq #"\w+" str)))
+
+;;71 Rearranging Code: ->
+last
+
+;;72 Rearranging Code: ->>
+apply +
+
+;;73 Analyze a Tic-Tac-Toe Board
+(defn f [xo]
+  (let [d #(for [i (range 0 3)] (get-in (vec %) [i i]))
+        ox (apply mapv vector xo)]
+    (->> (concat xo ox [(d xo) (d (reverse xo))])
+         (map set)
+         (some #{#{:x} #{:o}})
+         (first))))


test `get-unbound-query` & `get-params`

test `get-unbound-query` & `get-params`

--- test/cellophane/next_test.clj
+++ test/cellophane/next_test.clj
@@ -86,4 +86,10 @@
       (is (= (cellophane/get-query ComponentWithQuery)
              [:foo :bar]))
       (is (= (cellophane/get-query cq)
-             [:foo :bar])))))
+             [:foo :bar]))
+      (is (= (cellophane/get-unbound-query cq)
+             [:foo :bar]))
+      (is (= (cellophane/get-unbound-query cqps)
+             '[:foo (:bar {:a ?a})]))
+      (is (= (cellophane/get-params cqps)
+             {:a 1})))))


cleanup

cleanup

--- test/clj/reitit/http_test.clj
+++ test/clj/reitit/http_test.clj
@@ -264,160 +264,159 @@
         (is (= {:status 200, :body [:olipa "debug" :kerran "debug" :avaruus "debug" :ok]}
                (app request)))))))

-#?(:clj
-   (deftest resource-handler-test
-     (let [redirect (fn [uri] {:status 302, :body "", :headers {"Location" uri}})
-           request (fn [uri] {:uri uri, :request-method :get})]
-       (testing "inside a router"
-
-         (testing "from root"
-           (let [app (http/ring-handler
-                       (http/router
-                         ["/*" (ring/create-resource-handler)])
-                       (ring/create-default-handler)
-                       {:executor sieppari/executor})]
-             (testing test
-               (testing "different file-types"
-                 (let [response (app (request "/hello.json"))]
-                   (is (= "application/json" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
-                 (let [response (app (request "/hello.xml"))]
-                   (is (= "text/xml" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
-
-               (testing "index-files"
-                 (let [response (app (request "/docs"))]
-                   (is (= (redirect "/docs/index.html") response)))
-                 (let [response (app (request "/docs/"))]
-                   (is (= (redirect "/docs/index.html") response))))
-
-               (testing "not found"
-                 (let [response (app (request "/not-found"))]
-                   (is (= 404 (:status response)))))
-
-               (testing "3-arity"
-                 (let [result (atom nil)
-                       respond (partial reset! result)
-                       raise ::not-called]
-                   (app (request "/hello.xml") respond raise)
-                   (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
-                   (is (get-in @result [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result)))))))))
-
-         (testing "from path"
-           (let [app (http/ring-handler
-                       (http/router
-                         ["/files/*" (ring/create-resource-handler)])
-                       (ring/create-default-handler)
-                       {:executor sieppari/executor})
-                 request #(request (str "/files" %))
-                 redirect #(redirect (str "/files" %))]
-             (testing test
-               (testing "different file-types"
-                 (let [response (app (request "/hello.json"))]
-                   (is (= "application/json" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
-                 (let [response (app (request "/hello.xml"))]
-                   (is (= "text/xml" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
-
-               (testing "index-files"
-                 (let [response (app (request "/docs"))]
-                   (is (= (redirect "/docs/index.html") response)))
-                 (let [response (app (request "/docs/"))]
-                   (is (= (redirect "/docs/index.html") response))))
-
-               (testing "not found"
-                 (let [response (app (request "/not-found"))]
-                   (is (= 404 (:status response)))))
-
-               (testing "3-arity"
-                 (let [result (atom nil)
-                       respond (partial reset! result)
-                       raise ::not-called]
-                   (app (request "/hello.xml") respond raise)
-                   (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
-                   (is (get-in @result [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result))))))))))
-
-       (testing "outside a router"
-
-         (testing "from root"
-           (let [app (http/ring-handler
-                       (http/router [])
-                       (ring/routes
-                         (ring/create-resource-handler {:path "/"})
-                         (ring/create-default-handler))
-                       {:executor sieppari/executor})]
-             (testing test
-               (testing "different file-types"
-                 (let [response (app (request "/hello.json"))]
-                   (is (= "application/json" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
-                 (let [response (app (request "/hello.xml"))]
-                   (is (= "text/xml" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
-
-               (testing "index-files"
-                 (let [response (app (request "/docs"))]
-                   (is (= (redirect "/docs/index.html") response)))
-                 (let [response (app (request "/docs/"))]
-                   (is (= (redirect "/docs/index.html") response))))
-
-               (testing "not found"
-                 (let [response (app (request "/not-found"))]
-                   (is (= 404 (:status response)))))
-
-               (testing "3-arity"
-                 (let [result (atom nil)
-                       respond (partial reset! result)
-                       raise ::not-called]
-                   (app (request "/hello.xml") respond raise)
-                   (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
-                   (is (get-in @result [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result)))))))))
-
-         (testing "from path"
-           (let [app (http/ring-handler
-                       (http/router [])
-                       (ring/routes
-                         (ring/create-resource-handler {:path "/files"})
-                         (ring/create-default-handler))
-                       {:executor sieppari/executor})
-                 request #(request (str "/files" %))
-                 redirect #(redirect (str "/files" %))]
-             (testing test
-               (testing "different file-types"
-                 (let [response (app (request "/hello.json"))]
-                   (is (= "application/json" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
-                 (let [response (app (request "/hello.xml"))]
-                   (is (= "text/xml" (get-in response [:headers "Content-Type"])))
-                   (is (get-in response [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
-
-               (testing "index-files"
-                 (let [response (app (request "/docs"))]
-                   (is (= (redirect "/docs/index.html") response)))
-                 (let [response (app (request "/docs/"))]
-                   (is (= (redirect "/docs/index.html") response))))
-
-               (testing "not found"
-                 (let [response (app (request "/not-found"))]
-                   (is (= 404 (:status response)))))
-
-               (testing "3-arity"
-                 (let [result (atom nil)
-                       respond (partial reset! result)
-                       raise ::not-called]
-                   (app (request "/hello.xml") respond raise)
-                   (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
-                   (is (get-in @result [:headers "Last-Modified"]))
-                   (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result)))))))))))))
+(deftest resource-handler-test
+  (let [redirect (fn [uri] {:status 302, :body "", :headers {"Location" uri}})
+        request (fn [uri] {:uri uri, :request-method :get})]
+    (testing "inside a router"
+
+      (testing "from root"
+        (let [app (http/ring-handler
+                    (http/router
+                      ["/*" (ring/create-resource-handler)])
+                    (ring/create-default-handler)
+                    {:executor sieppari/executor})]
+          (testing test
+            (testing "different file-types"
+              (let [response (app (request "/hello.json"))]
+                (is (= "application/json" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
+              (let [response (app (request "/hello.xml"))]
+                (is (= "text/xml" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
+
+            (testing "index-files"
+              (let [response (app (request "/docs"))]
+                (is (= (redirect "/docs/index.html") response)))
+              (let [response (app (request "/docs/"))]
+                (is (= (redirect "/docs/index.html") response))))
+
+            (testing "not found"
+              (let [response (app (request "/not-found"))]
+                (is (= 404 (:status response)))))
+
+            (testing "3-arity"
+              (let [result (atom nil)
+                    respond (partial reset! result)
+                    raise ::not-called]
+                (app (request "/hello.xml") respond raise)
+                (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
+                (is (get-in @result [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result)))))))))
+
+      (testing "from path"
+        (let [app (http/ring-handler
+                    (http/router
+                      ["/files/*" (ring/create-resource-handler)])
+                    (ring/create-default-handler)
+                    {:executor sieppari/executor})
+              request #(request (str "/files" %))
+              redirect #(redirect (str "/files" %))]
+          (testing test
+            (testing "different file-types"
+              (let [response (app (request "/hello.json"))]
+                (is (= "application/json" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
+              (let [response (app (request "/hello.xml"))]
+                (is (= "text/xml" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
+
+            (testing "index-files"
+              (let [response (app (request "/docs"))]
+                (is (= (redirect "/docs/index.html") response)))
+              (let [response (app (request "/docs/"))]
+                (is (= (redirect "/docs/index.html") response))))
+
+            (testing "not found"
+              (let [response (app (request "/not-found"))]
+                (is (= 404 (:status response)))))
+
+            (testing "3-arity"
+              (let [result (atom nil)
+                    respond (partial reset! result)
+                    raise ::not-called]
+                (app (request "/hello.xml") respond raise)
+                (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
+                (is (get-in @result [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result))))))))))
+
+    (testing "outside a router"
+
+      (testing "from root"
+        (let [app (http/ring-handler
+                    (http/router [])
+                    (ring/routes
+                      (ring/create-resource-handler {:path "/"})
+                      (ring/create-default-handler))
+                    {:executor sieppari/executor})]
+          (testing test
+            (testing "different file-types"
+              (let [response (app (request "/hello.json"))]
+                (is (= "application/json" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
+              (let [response (app (request "/hello.xml"))]
+                (is (= "text/xml" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
+
+            (testing "index-files"
+              (let [response (app (request "/docs"))]
+                (is (= (redirect "/docs/index.html") response)))
+              (let [response (app (request "/docs/"))]
+                (is (= (redirect "/docs/index.html") response))))
+
+            (testing "not found"
+              (let [response (app (request "/not-found"))]
+                (is (= 404 (:status response)))))
+
+            (testing "3-arity"
+              (let [result (atom nil)
+                    respond (partial reset! result)
+                    raise ::not-called]
+                (app (request "/hello.xml") respond raise)
+                (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
+                (is (get-in @result [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result)))))))))
+
+      (testing "from path"
+        (let [app (http/ring-handler
+                    (http/router [])
+                    (ring/routes
+                      (ring/create-resource-handler {:path "/files"})
+                      (ring/create-default-handler))
+                    {:executor sieppari/executor})
+              request #(request (str "/files" %))
+              redirect #(redirect (str "/files" %))]
+          (testing test
+            (testing "different file-types"
+              (let [response (app (request "/hello.json"))]
+                (is (= "application/json" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "{\"hello\": \"file\"}" (slurp (:body response)))))
+              (let [response (app (request "/hello.xml"))]
+                (is (= "text/xml" (get-in response [:headers "Content-Type"])))
+                (is (get-in response [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body response))))))
+
+            (testing "index-files"
+              (let [response (app (request "/docs"))]
+                (is (= (redirect "/docs/index.html") response)))
+              (let [response (app (request "/docs/"))]
+                (is (= (redirect "/docs/index.html") response))))
+
+            (testing "not found"
+              (let [response (app (request "/not-found"))]
+                (is (= 404 (:status response)))))
+
+            (testing "3-arity"
+              (let [result (atom nil)
+                    respond (partial reset! result)
+                    raise ::not-called]
+                (app (request "/hello.xml") respond raise)
+                (is (= "text/xml" (get-in @result [:headers "Content-Type"])))
+                (is (get-in @result [:headers "Last-Modified"]))
+                (is (= "<xml><hello>file</hello></xml>\n" (slurp (:body @result))))))))))))


clojure (pgraph-morphisms): more tweaks on Floyd-Warshall


whoops, debug instead of info

whoops, debug instead of info

--- test/metabase/http_client.clj
+++ test/metabase/http_client.clj
@@ -78,7 +78,7 @@
         ;; Now perform the HTTP request
         {:keys [status body]} (try (request-fn url request-map)
                                    (catch clojure.lang.ExceptionInfo e
-                                     (log/info method-name url)
+                                     (log/debug method-name url)
                                      (-> (.getData ^clojure.lang.ExceptionInfo e)
                                          :object)))]


fix tests

fix tests

--- test/pathfinder/core_test.clj
+++ test/pathfinder/core_test.clj
@@ -11,7 +11,7 @@
   :each
   (fn [f]
     (mount/start-with-states
-     {#'pathfinder.storage/tracks-saver #'pathfinder.test-utils/atom-saver})
+     {#'pathfinder.redis.storage/tracks-saver #'pathfinder.test-utils/atom-saver})
     (f)
     (mount/stop)))


Reformat test.streams/fold-interval

Reformat test.streams/fold-interval

--- test/riemann/test/streams.clj
+++ test/riemann/test/streams.clj
@@ -673,14 +673,26 @@
            (is (= (/ total interval) (:metric @output)))))

 (deftest fold-interval-test
-         (test-stream-intervals (riemann.streams/fold-interval 1 :metric incanter.stats/sd)
-                                [{:metric 2} 0.1 {:metric 4} 0.2 {:metric 2} 0.3 {:metric 4} 1.0 {:metric 100} 0.1 {:metric 100} 1.0]
-                                (em 1.1547005383792515 0.0)))
+         (test-stream-intervals
+           (riemann.streams/fold-interval 1 :metric incanter.stats/sd)
+           [{:metric 2} 0.1
+            {:metric 4} 0.2
+            {:metric 2} 0.3
+            {:metric 4} 1.0
+            {:metric 100} 0.1
+            {:metric 100} 1.0]
+           (em 1.1547005383792515 0.0)))

 (deftest fold-interval-metric-test
-         (test-stream-intervals (riemann.streams/fold-interval-metric 1 incanter.stats/sd)
-                                [{:metric 2} 0.1 {:metric 4} 0.2 {:metric 2} 0.3 {:metric 4} 1.0 {:metric 100} 0.1 {:metric 100} 1.0]
-                                (em 1.1547005383792515 0.0)))
+         (test-stream-intervals
+           (riemann.streams/fold-interval-metric 1 incanter.stats/sd)
+           [{:metric 2} 0.1
+            {:metric 4} 0.2
+            {:metric 2} 0.3
+            {:metric 4} 1.0
+            {:metric 100} 0.1
+            {:metric 100} 1.0]
+           (em 1.1547005383792515 0.0)))

 (deftest changed-test
          (let [output (ref [])


minor code style change

minor code style change

--- src/main/om_css/utils.cljc
+++ src/main/om_css/utils.cljc
@@ -34,9 +34,9 @@
               (keyword? cns))
             (let [cns' (map #(cond-> %
                                (and classes-seen
-                                 (if (true? classes-seen)
-                                   classes-seen
-                                   (get classes-seen %))) (format-class-name component-info))
+                                 (or (true? classes-seen)
+                                     (get classes-seen %)))
+                               (format-class-name component-info))
                          (if (sequential? cns) cns [cns]))]
               (if (sequential? cns)
                 (into [] cns')


Adding support for tagged reaps.

Adding support for tagged reaps.

--- Clojure/reap-sow.clj
+++ Clojure/reap-sow.clj
@@ -3,19 +3,28 @@
 ; Experiment to see if something like Mathematica's reap/sow can be done in Clojure
 ; http://reference.wolfram.com/mathematica/ref/Reap.html

-(def reap-store)
+(def reap-store {})

-(defn sow [v]
+(defn sow
     "Adds the given value to the result that will be returned
-    by the enclosing reap"
-    (set! reap-store (conj reap-store v)))
+    by the enclosing (or tagged) reap"
+    ([tag v] (let [r (reap-store tag)]
+        (dosync (ref-set r (conj @r v)))))
+    ([v] (sow :default-tag v)))

 (defn reap
     "Evaluates function 'f' ignoring the result.
     Calls to 'sow' by 'f' will store the sown value into
-    the collection returned by reap."
-    [f]
-    (binding [reap-store []] (f) reap-store))
+    the collection returned by reap.
+
+    Reaps are tagged, and for the result to appear in this
+    reap the call to sow must use a matching tag.  This allows
+    multiple reaps to overlap each other on the callstack without
+    confusion."
+    ([tag f] (let [r (ref [])]
+        (binding [reap-store (assoc reap-store tag r)] (f))
+        @r))
+    ([f] (reap :default-tag f)))

 ; Well that was easy..  now some tests..

@@ -45,3 +54,19 @@
             (sow :a)
             (sow :b)))))))))

+; Tagged nested reaps
+
+(println
+    (reap :foo (fn [] (do
+        (sow :foo 1)
+        (sow :foo 2)
+        (sow :foo
+            (reap :bar (fn [] (do
+                (sow :foo 3)
+                (sow :bar :x)
+                (sow :bar :y)
+                (sow :bar :z)
+                (sow :foo 4)))))
+        (sow :foo 5)))))
+
+


Gen class on core.clj

Gen class on core.clj

--- src/engulf/core.clj
+++ src/engulf/core.clj
@@ -1,4 +1,5 @@
 (ns engulf.core
+  (:gen-class)
   (:require [engulf.benchmark :as benchmark]
             [noir.server :as nr-server])
   (:use aleph.http


Use requires to include views for uberjar

--- src/engulf/core.clj
+++ src/engulf/core.clj
@@ -1,14 +1,15 @@
 (ns engulf.core
   (:gen-class)
   (:require [engulf.benchmark :as benchmark]
+            engulf.views.benchmarker
+            engulf.views.common
+            engulf.views.index
             [noir.server :as nr-server])
   (:use aleph.http
         noir.core
         lamina.core))

 (defn start-webserver [args]
-  (nr-server/load-views "src/engulf/views")
-
   (let [mode (keyword (or (first args) :prod))
           port (Integer. (or (System/getenv "PORT") "3000"))
           noir-handler (nr-server/gen-handler {:mode mode})]


Fix comment typo (@pnf)

Fix comment typo (@pnf)

--- src/taoensso/carmine.clj
+++ src/taoensso/carmine.clj
@@ -34,7 +34,7 @@
   [conn-opts & sigs]
   `(let [[pool# conn#] (conns/pooled-conn ~conn-opts)

-         ;; To support `wcar` nesting with req planning, we mimmick
+         ;; To support `wcar` nesting with req planning, we mimic
          ;; `with-replies` stashing logic here to simulate immediate writes:
          ?stashed-replies#
          (when protocol/*context*


Don't do blocking IO in `go`

Don't do blocking IO in `go`

--- src/neovim_client/nvim.clj
+++ src/neovim_client/nvim.clj
@@ -108,7 +108,7 @@
   "Returns a channel which will contain true if the buffer is currently
   visible."
   [nvim buffer-name]
-  (async/go
+  (async/thread
     (let [visible-buffers (map (comp #(buffer-get-name nvim %)
                                      #(window-get-buffer nvim %))
                                (vim-get-windows nvim))]


Functions to connect measures and generate musical pieces

--- src/tenor/constructs.clj
+++ src/tenor/constructs.clj
@@ -75,18 +75,49 @@
                        :note-value note-value
                        :sparseness sparseness))))

+(defn string-measures [measures note-count
+                       & {:keys [running-string running-count]
+                          :or {running-string '() running-count 0}}]
+  "String multiple measures together into a single piece."
+  (if (empty? measures)
+    running-string
+    (let [running-string (concat
+                           running-string
+                           (map #(+ running-count %) (first measures)))
+          running-count (+ running-count note-count)]
+      (string-measures (rest measures)
+                       note-count
+                       :running-string running-string
+                       :running-count running-count))))

-(defn map-measure [measure scale]
+;; --- Musical piece --- ;;;
+
+(defn map-entity [entity scale]
   "Create a list of hash-maps of positions as keys
   and musical notes as values."
-  (map #(hash-map :pos %, :note (rand-nth scale)) measure))
+  (map #(hash-map :pos %, :note (rand-nth scale)) entity))

-(defn generate-measure-map [note-count note-value]
-  "Take note count and note value, and generate a
-  measure map using map-measure."
-  (map-measure
-    (segment-measure (time-signature note-count))
-    (generate-random-scale)))
+(defn generate-entity-map [measure-count note-count
+                            & {:keys [note-value sparseness scale]
+                               :or {note-value 16
+                                    sparseness 1
+                                    scale (generate-random-scale)}}]
+  "Take measure count,note count and note value, and generate a
+  measure map using map-entity."
+  (map-entity
+    (generate-piece measure-count note-count note-value sparseness)
+    scale))
+
+(defn generate-piece [measure-count note-count note-value sparseness]
+  "Generate a musical piece with measure-count measures,
+  each of time signature with note-count and note-value."
+  (let [piece (repeatedly
+                measure-count
+                #(segment-measure
+                   (time-signature note-count)
+                   note-value
+                   sparseness))]
+    (string-measures piece note-count)))

 ;; --- Playback --- ;;


Fix Downloads summary window

Fix Downloads summary window

--- src-cljs/dakait/components.cljs
+++ src-cljs/dakait/components.cljs
@@ -103,8 +103,7 @@
                  [(dom/div #js {:className "col-sm-2 col-xs-4 sub pc"} (:percent-complete ds))
                   (dom/div #js {:className "col-sm-2 col-xs-4 sub rate"} (:rate ds))
                   (dom/div #js {:className "col-sm-2 col-xs-4 sub ds"} (:eta ds))]
-                 (dom/div #js {:className "col-sm-6 sub waiting"}
-                          "Waiting...")))
+                 [(dom/div #js {:className "col-sm-6 sub waiting"} "Waiting...")]))
         (dom/div (clj->js {:className "progress-bar"
                       :style (clj->js {:width (if (:download-status download)
                                            (get-in download [:download-status :percent-complete])


fix closure variable naming issue

fix closure variable naming issue

it chooses the same name for object.assign and object-assign npm
packages but builds quite frequently import both leading to
a conflicting error since the name must be unique.

--- src/main/shadow/build/npm.clj
+++ src/main/shadow/build/npm.clj
@@ -392,6 +392,23 @@
       (contains? asset-exts ext)
       )))

+(defn disambiguate-module-name
+  "the variable names chosen by closure are not unique enough
+   object.assign creates the same variable as object-assign
+   so this makes the name more unique to avoid the clash"
+  [name]
+  (let [slash-idx (str/index-of name "/")]
+    (if-not slash-idx
+      name
+      (let [module-name (subs name 0 slash-idx)]
+        (str (str/replace module-name #"\." "_DOT_")
+             (subs name slash-idx))))))
+
+(comment
+  (disambiguate-module-name "object.assign/index.js")
+  (disambiguate-module-name "object-assign/index.js")
+  )
+
 (defn get-file-info*
   "extract some basic information from a given file, does not resolve dependencies"
   [{:keys [compiler ^File node-modules-dir ^File project-dir] :as npm} ^File file]
@@ -421,6 +438,7 @@
           (->> (.relativize node-modules-path file-path)
                (str)
                (rc/normalize-name)
+               (disambiguate-module-name)
                (str "node_modules/"))
           (->> (.relativize abs-path file-path)
                (str)


大致功能完成

大致功能完成

--- src/zsh_history/core.clj
+++ src/zsh_history/core.clj
@@ -1,7 +1,41 @@
 (ns zsh-history.core
+  (:require [environ.core :refer [env]]
+            [clojure.string :as cs])
   (:gen-class))

+(defn history-line->command
+  [line]
+  (-> line
+      (cs/split #";")
+      second))
+
+(defn weight [_ count] count)
+
+(defn sort-by-weight
+  [m]
+  (->> (vec m)
+       (sort-by (partial apply weight))
+       reverse))
+
+(defn format-history-map
+  [history-map]
+  (letfn [(format-one [[command weight]]
+                      (format "%s => %d times\n" command weight))]
+    (cs/join (map format-one history-map))))
+
+(defn format-history-lines
+  [history-lines]
+  (->> (map history-line->command history-lines)
+       (frequencies)
+       (sort-by-weight)
+       (take 10)
+       (format-history-map)))
+
 (defn -main
-  "I don't do a whole lot ... yet."
   [& args]
-  (println "Hello, World!"))
+  (-> (env :home)
+      (str "/.zsh_history")
+      slurp
+      (cs/split #"\n")
+      format-history-lines
+      print))


added description to the load card that exercises follow-on remote read

--- src-cards/untangled/client/load_cards.cljs
+++ src-cards/untangled/client/load_cards.cljs
@@ -43,6 +43,20 @@
   (remote [env] true))

 (defcard load-with-follow-on-read
+  "# Sequential Processing
+
+  This card does a write (with a tempid) and a re-read of that as a follow-on read. This
+  exercises:
+
+  - tempid rewrites in the network queue
+    - The initial entity has a tempid (generated)
+    - The tempid is rewritten (to 1010)
+    - The follow-on read reads the correct thing (label should update to B)
+  - follow-on reads from a remote
+  - load marker placement and removal
+    - Should see a load marker appear IN the entity
+    - Should see no load markers at the end
+  "
   (untangled-app Root
     :networking (MockNetwork.)
     :started-callback (fn [{:keys [reconciler]}]


Improved `throws` documentation.

Improved `throws` documentation.

--- src/midje/checkers/simple.clj
+++ src/midje/checkers/simple.clj
@@ -58,21 +58,28 @@
 ;; Concerning Throwables

 (defmulti throws
-  "Checks for a thrown Throwable. Argumentss can occur in any order and
-   in any number, except for the specified Throwable class:
-   messages (or regexes), predicates, or 0 or 1 Throwable classes.
-
-   Ex. (fact (foo) => (throws IllegalArgumentException
-                              #(= bar (.getCause %))
-                              #(= baz (.getLocalizedMessage %))
-                              #\"^An exception described as: \"
-                              #\"was thrown.$\"  ))"
+  "Checks for a thrown Throwable.
+
+   The most common cases are:
+       (fact (foo) => (throws IOException)
+       (fact (foo) => (throws IOException #\"No such file\")
+
+   `throws` takes three kinds of arguments:
+   * A class argument requires that the Throwable be of that class.
+   * A string or regular expression requires that the `message` of the Throwable
+     match the argument.
+   * A function argument requires that the function, when applied to the Throwable,
+     return a truthy value.
+
+   Arguments can be in any order. Except for a class argument, they can be repeated.
+   So, for example, you can write this:
+       (fact (foo) => (throws #\"one part\" #\"another part\"))"
   (fn [& args]
-                   (set (for [arg args]
-                          (pred-cond arg
-                            fn?                        :predicate
-                            (some-fn-m string? regex?) :message
-                            class?                     :throwable )))))
+    (set (for [arg args]
+           (pred-cond arg
+                      fn?                        :predicate
+                      (some-fn-m string? regex?) :message
+                      class?                     :throwable )))))

 (defmethod throws #{:message } [& expected-msgs]
   (checker [^ICapturedThrowable wrapped-throwable]
@@ -89,4 +96,4 @@

 (def-many-methods throws [#{:throwable :predicate}, #{:message :predicate },
                           #{:throwable :message}, #{:throwable :message :predicate}] [& args]
-  (as-checker (apply every-pred-m (map throws args))))+  (as-checker (apply every-pred-m (map throws args))))