First step in rework of views/remotes

First step in rework of views/remotes

--- src/wishlistd/views/wishlist.clj
+++ src/wishlistd/views/wishlist.clj
@@ -1,18 +1,22 @@
 (ns wishlistd.views.wishlist
   (:require [wishlistd.views.common :as common]
-            [wishlistd.json :as response])
-  (:use wishlistd.models.redis))
+            [wishlistd.json :as response]
+            [wishlistd.models.redis :as model])
+  (:use noir.fetch.remotes))

 (defn main-page []
   (common/new-layout))

 (defn create-wishlist-json [wishlist]
-  (let [wishlist (create-wishlist wishlist)]
+  (let [wishlist (model/create-wishlist wishlist)]
     (response/json wishlist)))

 (defn get-wishlist-json [code]
-  (let [wishlist (read-wishlist code)]
+  (let [wishlist (model/read-wishlist code)]
     (response/json wishlist)))

 (defn update-wishlist-json [wishlist]
-  (response/json (update-wishlist wishlist)))+  (response/json (model/update-wishlist wishlist)))
+
+(defremote create-wishlist [wishlist]
+  (model/create-wishlist wishlist))


bug fix

bug fix

--- desktop/src-common/clo_runner/core.clj
+++ desktop/src-common/clo_runner/core.clj
@@ -25,7 +25,9 @@
                                                 (- (:x entity) player-speed)
                                                 0)
                                             (assoc entity :x (- (:x entity) player-speed))
-                                            (assoc entity :x 0))))
+                                            (assoc entity :x 0))
+    :else entity
+    ))

 (defn create-box []
@@ -89,34 +91,37 @@
       (throw (Exception. "Game over"))
       (conj (apply conj (conj [] backgr) boxes) player))))

+(defn first-screen [screen entities]
+  (update! screen :renderer (stage))
+  (add-timer! screen :spawn-enemy 0 2)
+  (let [
+        sheet (texture "bird.png")
+        birdy (texture! sheet :split (/ 506 3) (/ 918 5))
+
+        background (texture "background.jpg")
+        background (assoc background :x 0 :y 0 :width 800 :height 600)
+
+        player-image (texture (aget birdy 0 0))
+        ;;images (->
+        ;;       []
+        ;;     (conj (texture (aget birdy 0 0)))
+        ;;   (conj (texture (aget birdy 0 1)))
+                ;;   (conj (texture (aget birdy 0 2)))
+        ;;   (conj (texture (aget birdy 0 3)))
+        ;;   (conj (texture (aget birdy 0 4)))
+        ;;   (conj (texture (aget birdy 1 0)))
+                ;;   (conj (texture (aget birdy 1 1)))
+        ;;   (conj (texture (aget birdy 1 2)))
+        ;;   (conj (texture (aget birdy 1 3)))
+        ;;   (conj (texture (aget birdy 1 4))))
+        ;;     player-image (assoc player-image :moving (animation 0.15 images))
+        player-image (assoc player-image :x 10 :y 10 :width 59 :height 59)]
+    [background player-image]))
+
 (defscreen main-screen
   :on-show
   (fn [screen entities]
-    (update! screen :renderer (stage))
-    (add-timer! screen :spawn-enemy 0 2)
-    (let [
-          sheet (texture "bird.png")
-          birdy (texture! sheet :split (/ 506 3) (/ 918 5))
-
-          background (texture "background.jpg")
-          background (assoc background :x 0 :y 0 :width 800 :height 600)
-
-          player-image (texture (aget birdy 0 0))
-          ;;images (->
-            ;;       []
-              ;;     (conj (texture (aget birdy 0 0)))
-                ;;   (conj (texture (aget birdy 0 1)))
-                ;;   (conj (texture (aget birdy 0 2)))
-                ;;   (conj (texture (aget birdy 0 3)))
-                ;;   (conj (texture (aget birdy 0 4)))
-                ;;   (conj (texture (aget birdy 1 0)))
-                ;;   (conj (texture (aget birdy 1 1)))
-                ;;   (conj (texture (aget birdy 1 2)))
-                ;;   (conj (texture (aget birdy 1 3)))
-                ;;   (conj (texture (aget birdy 1 4))))
-     ;;     player-image (assoc player-image :moving (animation 0.15 images))
-          player-image (assoc player-image :x 10 :y 10 :width 59 :height 59)]
-      [background player-image]))
+    (first-screen screen entities))

   :on-render
   (fn [screen entities]
@@ -127,12 +132,18 @@
                  (moving entities)
                  (collision))
                (catch Exception e
-                 [(assoc (texture "gameover.jpg")
-                        :x 0 :y 0 :width 800 :height 600)]))))
+                 [(->
+                    (texture "gameover.jpg")
+                    (assoc :x 0 :y 0 :width 800 :height 600))
+                  ]))))

   :on-timer
   (fn [screen entities]
     :spawn-enemy (conj (conj (vec (drop-last entities)) (create-box)) (last entities)))
+
+  :on-touch-down
+  (fn [screen entities]
+    (first-screen screen entities))

   :on-key-down
   (fn [screen entities]
@@ -141,6 +152,7 @@
       (vec)
       (conj (move screen (last entities))))))

+

 (defgame clo-runner-game
   :on-create


test cleanup

test cleanup

--- test/protobuf_test.clj
+++ test/protobuf_test.clj
@@ -10,140 +10,155 @@
 (defn catbytes [& args]
   (.getBytes (apply str (map (fn [#^bytes b] (String. b)) args))))

-(deftest protobuf-simple
+(deftest test-conj
+  (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :doubles [1.2 3.4 5.6] :floats [0.01 0.02 0.03])]
+    (let [p (conj p {:label "bar"})]
+      (is (= 5     (:id p)))
+      (is (= "bar" (:label p)))
+      (is (= ["little" "yellow"] (:tags p)))
+      (is (= [1.2 3.4 5.6] (:doubles p)))
+      (is (= [(float 0.01) (float 0.02) (float 0.03)] (:floats  p)))
+      )
+    (let [p (conj p {:tags ["different"]})]
+      (is (= ["different"] (:tags p))))
+    (let [p (conj p {:tags ["little" "yellow" "different"] :label "very"})]
+      (is (= ["little" "yellow" "different"] (:tags p)))
+      (is (= "very" (:label p))))))

-  (testing "conj"
-    (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :doubles [1.2 3.4 5.6] :floats [0.01 0.02 0.03])]
-      (let [p (conj p {:label "bar"})]
-        (is (= 5     (:id p)))
-        (is (= "bar" (:label p)))
-        (is (= ["little" "yellow"] (:tags p)))
-        (is (= [1.2 3.4 5.6] (:doubles p)))
-        (is (= [(float 0.01) (float 0.02) (float 0.03)] (:floats  p)))
-        )
-      (let [p (conj p {:tags ["different"]})]
-        (is (= ["different"] (:tags p))))
-      (let [p (conj p {:tags ["little" "yellow" "different"] :label "very"})]
-        (is (= ["little" "yellow" "different"] (:tags p)))
-        (is (= "very" (:label p))))))
+(deftest test-append
+  (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :doubles [1.2] :floats [0.01])]
+    (let [p (append p {:label "bar"})]
+      (is (= 5     (:id p)))
+      (is (= "bar" (:label p)))
+      (is (= false (:deleted p)))
+      (is (= ["little" "yellow"] (:tags p))))
+    (let [p (append (assoc p :deleted true) p)]
+      (is (= true (:deleted p))))
+    (let [p (append p {:tags ["different"]})]
+      (is (= ["little" "yellow" "different"] (:tags p))))
+    (let [p (append p {:tags ["different"] :label "very"})]
+      (is (= ["little" "yellow" "different"] (:tags p)))
+      (is (= "very" (:label p))))
+    (let [p (append p {:doubles [3.4] :floats [0.02]})]
+      (is (= [1.2 3.4] (:doubles p)))
+      (is (= [(float 0.01) (float 0.02)] (:floats  p))))))

-  (testing "append"
-    (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :doubles [1.2] :floats [0.01])]
-      (let [p (append p {:label "bar"})]
-        (is (= 5     (:id p)))
-        (is (= "bar" (:label p)))
-        (is (= ["little" "yellow"] (:tags p))))
-      (let [p (append p {:tags ["different"]})]
-        (is (= ["little" "yellow" "different"] (:tags p))))
-      (let [p (append p {:tags ["different"] :label "very"})]
-        (is (= ["little" "yellow" "different"] (:tags p)))
-        (is (= "very" (:label p))))
-      (let [p (append p {:doubles [3.4] :floats [0.02]})]
-        (is (= [1.2 3.4] (:doubles p)))
-        (is (= [(float 0.01) (float 0.02)] (:floats  p))))))
+(deftest test-adjoin
+  (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :doubles [1.2] :floats [0.01])]
+    (let [p (adjoin p {:label "bar"})]
+      (is (= 5     (:id p)))
+      (is (= "bar" (:label p)))
+      (is (= false (:deleted p)))
+      (is (= ["little" "yellow"] (:tags p))))
+    (let [p (adjoin (assoc p :deleted true) p)]
+      (is (= false (:deleted p))))
+    (let [p (adjoin p {:tags ["different"]})]
+      (is (= ["little" "yellow" "different"] (:tags p))))
+    (let [p (adjoin p {:tags ["different"] :label "very"})]
+      (is (= ["little" "yellow" "different"] (:tags p)))
+      (is (= "very" (:label p))))
+    (let [p (adjoin p {:doubles [3.4] :floats [0.02]})]
+      (is (= [1.2 3.4] (:doubles p)))
+      (is (= [(float 0.01) (float 0.02)] (:floats  p))))))

-  (testing "assoc"
-    (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :foo-by-id {1 {:label "one"} 2 {:label "two"}})]
-      (let [p (assoc p :label "baz" :tags ["nuprin"])]
-        (is (= ["nuprin"] (:tags p)))
-        (is (= "baz"      (:label p))))
-      (let [p (assoc p "responses" [:yes :no :maybe :no "yes"])]
-        (is (= [:yes :no :maybe :no :yes] (:responses p))))
-      (let [p (assoc p :tags "aspirin")]
-        (is (= ["aspirin"] (:tags p))))
-      (let [p (assoc p :foo-by-id {3 {:label "three"} 2 {:label "two"}})]
-        (is (= {3 {:id 3, :label "three"} 2 {:id 2, :label "two"}} (:foo-by-id p))))))
+(deftest test-assoc
+  (let [p (protobuf Foo :id 5 :tags ["little" "yellow"] :foo-by-id {1 {:label "one"} 2 {:label "two"}})]
+    (let [p (assoc p :label "baz" :tags ["nuprin"])]
+      (is (= ["nuprin"] (:tags p)))
+      (is (= "baz"      (:label p))))
+    (let [p (assoc p "responses" [:yes :no :maybe :no "yes"])]
+      (is (= [:yes :no :maybe :no :yes] (:responses p))))
+    (let [p (assoc p :tags "aspirin")]
+      (is (= ["aspirin"] (:tags p))))
+    (let [p (assoc p :foo-by-id {3 {:label "three"} 2 {:label "two"}})]
+      (is (= {3 {:id 3, :label "three"} 2 {:id 2, :label "two"}} (:foo-by-id p))))))

-  (testing "dissoc"
-    (let [p (protobuf Foo :id 5 :tags ["fast" "shiny"] :label "nice")]
-      (let [p (dissoc p :label :tags)]
-        (is (= []  (:tags p)))
-        (is (= nil (:label p))))))
+(deftest test-dissoc
+  (let [p (protobuf Foo :id 5 :tags ["fast" "shiny"] :label "nice")]
+    (let [p (dissoc p :label :tags)]
+      (is (= nil (:tags p)))
+      (is (= nil (:label p))))))

-  (testing "string keys"
-    (let [p (protobuf Foo "id" 5 "label" "rad")]
-      (is (= 5 (p :id)))
-      (is (= 5 (p "id")))
-      (is (= "rad" (p :label)))
-      (is (= "rad" (p "label")))
-      (let [p (conj p {"tags" ["check" "it" "out"]})]
-        (is (= ["check" "it" "out"] (p :tags)))
-        (is (= ["check" "it" "out"] (p "tags"))))))
+(deftest test-string-keys
+  (let [p (protobuf Foo "id" 5 "label" "rad")]
+    (is (= 5 (p :id)))
+    (is (= 5 (p "id")))
+    (is (= "rad" (p :label)))
+    (is (= "rad" (p "label")))
+    (let [p (conj p {"tags" ["check" "it" "out"]})]
+      (is (= ["check" "it" "out"] (p :tags)))
+      (is (= ["check" "it" "out"] (p "tags"))))))

-  (testing "append bytes"
-    (let [p (protobuf Foo :id 5  :label "rad" :tags ["sweet"] :tag-set #{"foo" "bar" "baz"})
-          q (protobuf Foo :id 43 :tags ["savory"] :tag-set {"bar" false "foo" false "bap" true})
-          r (protobuf Foo :label "bad")
-          s (protobuf-load Foo (catbytes (protobuf-dump p) (protobuf-dump q)))
-          t (protobuf-load Foo (catbytes (protobuf-dump p) (protobuf-dump r)))]
-      (is (= 43 (s :id))) ; make sure an explicit default overwrites on append
-      (is (= 5  (t :id))) ; make sure a missing default doesn't overwrite on append
-      (is (= "rad" (s :label)))
-      (is (= "bad" (t :label)))
-      (is (= ["sweet"] (t :tags)))
-      (is (= ["sweet" "savory"] (s :tags)))
-      (is (= #{"foo" "bar" "baz"} (p :tag-set)))
-      (is (= #{"bap" "baz"} (s :tag-set)))))
+(deftest test-append-bytes
+  (let [p (protobuf Foo :id 5  :label "rad" :tags ["sweet"] :tag-set #{"foo" "bar" "baz"})
+        q (protobuf Foo :id 43 :tags ["savory"] :tag-set {"bar" false "foo" false "bap" true})
+        r (protobuf Foo :label "bad")
+        s (protobuf-load Foo (catbytes (protobuf-dump p) (protobuf-dump q)))
+        t (protobuf-load Foo (catbytes (protobuf-dump p) (protobuf-dump r)))]
+    (is (= 43 (s :id)))                 ; make sure an explicit default overwrites on append
+    (is (= 5  (t :id)))                 ; make sure a missing default doesn't overwrite on append
+    (is (= "rad" (s :label)))
+    (is (= "bad" (t :label)))
+    (is (= ["sweet"] (t :tags)))
+    (is (= ["sweet" "savory"] (s :tags)))
+    (is (= #{"foo" "bar" "baz"} (p :tag-set)))
+    (is (= #{"bap" "baz"} (s :tag-set)))))

-  (testing "coercing doubles and floats"
-    (let [p (protobuf Foo :lat 5 :long 6)]
-      (is (= 5.0 (p :lat)))
-      (is (= 6.0 (p :long))))
-    (let [p (protobuf Foo :lat (float 5.0) :long (double 6.0))]
-      (is (= 5.0 (p :lat)))
-      (is (= 6.0 (p :long))))
-    ))
+(deftest test-coercing
+  (let [p (protobuf Foo :lat 5 :long 6)]
+    (is (= 5.0 (p :lat)))
+    (is (= 6.0 (p :long))))
+  (let [p (protobuf Foo :lat (float 5.0) :long (double 6.0))]
+    (is (= 5.0 (p :lat)))
+    (is (= 6.0 (p :long)))))

-(deftest protobuf-extended
+(deftest test-create
+  (let [p (protobuf Foo :id 5 :tag-set #{"little" "yellow"} :attr-map {"size" "little", "color" "yellow", "style" "different"})]
+    (is (= #{"little" "yellow"} (:tag-set p)))
+    (is (associative? (:attr-map p)))
+    (is (= "different" (get-in p [:attr-map "style"])))
+    (is (= "little"    (get-in p [:attr-map "size" ])))
+    (is (= "yellow"    (get-in p [:attr-map "color"]))))
+  (let [p (protobuf Foo :id 1 :foo-by-id {5 {:label "five"}, 6 {:label "six"}})]
+    (let [five ((p :foo-by-id) 5)
+          six  ((p :foo-by-id) 6)]
+      (is (= 5      (five :id)))
+      (is (= "five" (five :label)))
+      (is (= 6      (six  :id)))
+      (is (= "six"  (six  :label))))))

-  (testing "create"
-    (let [p (protobuf Foo :id 5 :tag-set #{"little" "yellow"} :attr-map {"size" "little", "color" "yellow", "style" "different"})]
-      (is (= #{"little" "yellow"} (:tag-set p)))
-      (is (associative? (:attr-map p)))
-      (is (= "different" (get-in p [:attr-map "style"])))
-      (is (= "little"    (get-in p [:attr-map "size" ])))
-      (is (= "yellow"    (get-in p [:attr-map "color"]))))
-    (let [p (protobuf Foo :id 1 :foo-by-id {5 {:label "five"}, 6 {:label "six"}})]
-      (let [five ((p :foo-by-id) 5)
-            six  ((p :foo-by-id) 6)]
-        (is (= 5      (five :id)))
-        (is (= "five" (five :label)))
-        (is (= 6      (six  :id)))
-        (is (= "six"  (six  :label))))))
+(deftest test-map-by-with-required-field
+  (let [p (protobuf Foo :id 1 :item-map {"foo" {:exists true} "bar" {:exists false}})]
+    (is (= "foo" (get-in p [:item-map "foo" :item])))
+    (is (= "bar" (get-in p [:item-map "bar" :item])))))

-  (testing "map-by with required field"
-    (let [p (protobuf Foo :id 1 :item-map {"foo" {:exists true} "bar" {:exists false}})]
-      (is (= "foo" (get-in p [:item-map "foo" :item])))
-      (is (= "bar" (get-in p [:item-map "bar" :item])))))
+(deftest test-conj
+  (let [p (protobuf Foo :id 1 :foo-by-id {5 {:label "five", :tag-set ["odd"]}, 6 {:label "six" :tags ["even"]}})]
+    (let [p (conj p {:foo-by-id {5 {:tag-set ["prime" "odd"]} 6 {:tags ["odd"]}}})]
+      (is (= #{"prime" "odd"} (get-in p [:foo-by-id 5 :tag-set])))
+      (is (= ["odd"]          (get-in p [:foo-by-id 6 :tags])))
+      (is (= nil              (get-in p [:foo-by-id 6 :label]))))))

-  (testing "conj"
-    (let [p (protobuf Foo :id 1 :foo-by-id {5 {:label "five", :tag-set ["odd"]}, 6 {:label "six" :tags ["even"]}})]
-      (let [p (conj p {:foo-by-id {5 {:tag-set ["prime" "odd"]} 6 {:tags ["odd"]}}})]
-        (is (= #{"prime" "odd"} (get-in p [:foo-by-id 5 :tag-set])))
-        (is (= ["odd"]          (get-in p [:foo-by-id 6 :tags])))
-        (is (= nil              (get-in p [:foo-by-id 6 :label])))))))
+(deftest test-protofields
+  (let [fields {:id nil, :label {:a 1, :b 2, :c 3}, :tags nil, :parent nil, :responses nil, :tag-set nil, :deleted nil,
+                :attr-map nil, :foo-by-id nil, :groups nil, :doubles nil, :floats nil, :item-map nil, :lat nil, :long nil}]
+    (is (= fields (protofields Foo)))
+    (is (= fields (protofields clojure.protobuf.Test$Foo)))))

-(deftest protofields-and-defaults
-
-  (testing "protofields"
-    (let [fields {:id nil, :label {:a 1, :b 2, :c 3}, :tags nil, :parent nil, :responses nil, :tag-set nil,
-                  :attr-map nil, :foo-by-id nil, :groups nil, :doubles nil, :floats nil, :item-map nil, :lat nil, :long nil}]
-      (is (= fields (protofields Foo)))
-      (is (= fields (protofields clojure.protobuf.Test$Foo)))))
-
-  (testing "protodefault"
-    (is (= 43  (protodefault Foo :id)))
-    (is (= 0.0 (protodefault Foo :lat)))
-    (is (= 0.0 (protodefault Foo :long)))
-    (is (= ""  (protodefault Foo :label)))
-    (is (= []  (protodefault Foo :tags)))
-    (is (= nil (protodefault Foo :parent)))
-    (is (= []  (protodefault Foo :responses)))
-    (is (= #{} (protodefault Foo :tag-set)))
-    (is (= {}  (protodefault Foo :foo-by-id)))
-    (is (= {}  (protodefault Foo :groups)))
-    (is (= {}  (protodefault Foo :item-map)))
-    (is (= {}  (protodefault clojure.protobuf.Test$Foo :groups)))))
+(deftest test-protodefault
+  (is (= 43    (protodefault Foo :id)))
+  (is (= 0.0   (protodefault Foo :lat)))
+  (is (= 0.0   (protodefault Foo :long)))
+  (is (= ""    (protodefault Foo :label)))
+  (is (= []    (protodefault Foo :tags)))
+  (is (= nil   (protodefault Foo :parent)))
+  (is (= []    (protodefault Foo :responses)))
+  (is (= #{}   (protodefault Foo :tag-set)))
+  (is (= {}    (protodefault Foo :foo-by-id)))
+  (is (= {}    (protodefault Foo :groups)))
+  (is (= {}    (protodefault Foo :item-map)))
+  (is (= false (protodefault Foo :deleted)))
+  (is (= {}    (protodefault clojure.protobuf.Test$Foo :groups))))

 (deftest use-underscores
   (let [p (protobuf Foo {:tag_set ["odd"] :responses [:yes :not-sure :maybe :not-sure :no]})]


removed dead code

removed dead code

--- src/untangled/client/core.cljs
+++ src/untangled/client/core.cljs
@@ -57,23 +57,6 @@

 (defprotocol InitialAppState
   (initial-state [clz params] "Get the initial state to be used for this component in app state. You are responsible for composing these together."))
-
-(defn get-initial-state [clz params]
-  (let [state (initial-state clz params)
-        q (om/get-query clz)
-        to-one? (map? state)
-        to-many? (vector? state)
-        union? (map? q)
-        keys-of-interest (fn [s] (set/difference (set s) #{:union/default}))]
-    (if union?
-      (cond
-        to-one? (let [default-key (get state :union/default)]
-                  (assert (set/subset? (keys-of-interest state) (keys-of-interest q)) (str "Initial state for " clz " contains keys that are not in the query"))
-                  (assert default-key (str "Initial state for " clz " does not indicate which state is the :union/default."))
-                  )
-        to-many? (do)
-        :else (log/warn (str "Union on " clz " has a strange initial state")))
-      state)))

 (defprotocol UntangledApplication
   (mount [this root-component target-dom-id] "Start/replace the webapp on the given DOM ID or DOM Node.")


dry up find-closest-clear-spot

dry up find-closest-clear-spot

--- src/voke/system/collision.cljs
+++ src/voke/system/collision.cljs
@@ -41,35 +41,22 @@
                                      entity-shape)
                    collidable-entities))))

-
-; TODO dear god all the code i added in this commit is fuckin nuts and insane
-; TODO REFACTOR ALL THIS
-
 (sm/defn find-closest-clear-spot :- (s/maybe s/Num)
   [event :- Event
    contacted-entity :- Entity]
-
-  (let [; TODO AABBs for non-rect shapes
-        shape1 (get-in event [:entity :shape])
+  "Takes an :intended-movement event (for entity A) and the Entity that occupies the position that entity A
+  is trying to move to (entity B). Finds the closest x- or y-value (depending on the value of `(event :axis)`)
+  that entity A can occupy without contacting entity B and returns it if entity A fits there, or returns nil
+  if no open spot exists."
+  ; TODO - only supports rectangles
+  (let [shape1 (get-in event [:entity :shape])
         shape2 (contacted-entity :shape)
-        axis-value-to-try (match [(event :axis) (pos? (event :new-velocity))]
-                            ; TODO refactor
-                            [:x true] (- (shape2 :x)
-                                         (/ (shape2 :width) 2)
-                                         (/ (shape1 :width) 2)
-                                         0.01)
-                            [:x false] (+ (shape2 :x)
-                                          (/ (shape2 :width) 2)
-                                          (/ (shape1 :width) 2)
-                                          0.01)
-                            [:y true] (- (shape2 :y)
-                                         (/ (shape2 :height) 2)
-                                         (/ (shape1 :height) 2)
-                                         0.01)
-                            [:y false] (+ (shape2 :y)
-                                          (/ (shape2 :height) 2)
-                                          (/ (shape1 :height) 2)
-                                          0.01))]
+        arithmetic-fn (if (pos? (event :new-velocity)) - +)
+        field (if (= (event :axis) :x) :width :height)
+        axis-value-to-try (arithmetic-fn (shape2 (event :axis))
+                                         (/ (shape2 field) 2)
+                                         (/ (shape1 field) 2)
+                                         0.01)]
     (when-not (find-contacting-entity (assoc-in (event :entity)
                                                 [:shape (event :axis)]
                                                 axis-value-to-try)


Added Status identifier when calling cryptocompare API

--- src/status_im/utils/prices.cljs
+++ src/status_im/utils/prices.cljs
@@ -11,9 +11,10 @@
 ;; (get-prices "ETH" "USD" println print)

 (def api-url "https://min-api.cryptocompare.com/data")
+(def status-identifier "extraParams=Status.im")

 (defn- gen-price-url [fsyms tsyms]
-  (str api-url "/pricemultifull?fsyms=" fsyms "&tsyms=" tsyms))
+  (str api-url "/pricemultifull?fsyms=" fsyms "&tsyms=" tsyms "&" status-identifier))

 (defn- format-price-resp [from to resp]
   (let [raw (:RAW (types/json->clj resp))


Declare atom in 4/2.

Declare atom in 4/2.

--- src/workshop/challenge_4_2.clj
+++ src/workshop/challenge_4_2.clj
@@ -44,6 +44,8 @@

 ;;; Lifecycles ;;;

+(def state (atom nil))
+
 ;; <<< BEGIN FILL ME IN >>>

 (defn build-lifecycles [])


Explicitly check dirty dates.

Explicitly check dirty dates.

--- src/kixi/hecuba/data/misc.clj
+++ src/kixi/hecuba/data/misc.clj
@@ -64,9 +64,12 @@
 (defn start-end-dates
   "Given a sensor, table and where clause, returns start and end dates for (re)calculations."
   [column sensor where]
-  (let [range (-> sensor column)]
-    (when-not (empty? range)
-      {:start-date (tc/from-date (get range "start")) :end-date (tc/from-date (get range "end"))})))
+  (let [range (-> sensor column)
+        start (get range "start")
+        end   (get range "end")]
+    (when (and (not (nil? start))
+               (not (nil? end)))
+      {:start-date (tc/from-date start) :end-date (tc/from-date end)})))

 (defn min-max-dates [measurements]
   (let [parsed-dates (map #(tc/from-date (:timestamp %)) measurements)]


I really need to learn how to spell entities.

Fixed some misspelled paths.

--- src/kixi/hecuba/web_paths.clj
+++ src/kixi/hecuba/web_paths.clj
@@ -40,9 +40,9 @@
    :entity-profiles-resource "entities/%s/profiles/%s"

    ;; measurements
-   :entity-device-measurement-index "enitites/%s/devices/%s/measurements"
-   :entity-device-measurement-readingtype-index "enitites/%s/devices/%s/measurements/%s"
-   :entity-device-measurement-readingtype-resource "enitites/%s/devices/%s/measurements/%s/%s"
+   :entity-device-measurement-index "entities/%s/devices/%s/measurements"
+   :entity-device-measurement-readingtype-index "entities/%s/devices/%s/measurements/%s"
+   :entity-device-measurement-readingtype-resource "entities/%s/devices/%s/measurements/%s/%s"

    ;; hourly readings
    ;; FIXME: This should be a query parameter and not a separate resource (or rather the raw should force not choosing the hourly/daily)


Removed the templates facade. No need for that.

--- src/lambda_blog/templates.clj
+++ src/lambda_blog/templates.clj
@@ -1,2 +0,0 @@
-(ns lambda-blog.templates
-  (:use [lambda-blog.templates banner footer header nav static]))


Removing deref for profile (#114)

Removing deref for profile (#114)

--- src/kixi/datastore/metadatastore/migrators/dynamodb/migrator_2017031130_init.clj
+++ src/kixi/datastore/metadatastore/migrators/dynamodb/migrator_2017031130_init.clj
@@ -25,7 +25,7 @@
   [db]
   (let [profile (name @profile)
         conn (get-db-config db)
-        alert-conf (get-alerts-config @profile)]
+        alert-conf (get-alerts-config profile)]
     (far/create-table conn
                       (mdb/primary-metadata-table profile)
                       [(db/dynamo-col ::md/id) :s]


insights: don't use "class" in JS

insights: don't use "class" in JS

--- src-cljs/frontend/components/insights.cljs
+++ src-cljs/frontend/components/insights.cljs
@@ -71,11 +71,11 @@
                            :item-height 14   ; assume font is 14px
                            :spacing 4
                            }
-        left-legend [{:class "success"
+        left-legend [{:class_name "success"
                       :text "Passed"}
-                     {:class "failed"
+                     {:class_name "failed"
                       :text "Failed"}
-                     {:class "canceled"
+                     {:class_name "canceled"
                       :text "Canceled"}]
         right-legend [{:class "queue"
                       :text "Queue time"}]
@@ -115,7 +115,7 @@
           (.append "rect")
           (.attr #js {"width" (:square-size legend-dimensions)
                       "height" (:square-size legend-dimensions)
-                      "class" #(.-class %)
+                      "class" #(.-class_name %)
                       "transform"
                       (fn [item i]
                         (gstring/format "translate(%s,%s)" 0  (- (+ (:square-size legend-dimensions)))))}))
@@ -144,7 +144,7 @@
           (.append "rect")
           (.attr #js {"width" (:square-size legend-dimensions)
                       "height" (:square-size legend-dimensions)
-                      "class" #(.-class %)
+                      "class" #(.-class_name %)
                       "transform"
                       (fn [item i]
                         (gstring/format "translate(%s,%s)" 0  (- (+ (:square-size legend-dimensions)))))}))


Cleaned up the mechanism for associating entity objects with their parents (for entity group purposes).

--- src/appengine_magic/services/datastore.clj
+++ src/appengine_magic/services/datastore.clj
@@ -74,9 +74,8 @@
     "Returns nil if no tag is specified in the record definition, and no :key
      metadata exists. Otherwise returns a Key object. Specify optional entity
      group parent.")
-  (save! [this] [this parent]
-    "Writes the given entity to the data store. Specify optional entity group
-    parent."))
+  (save! [this]
+    "Writes the given entity to the data store."))

 (defn- unqualified-name [sym]
@@ -129,18 +128,17 @@
      ;; key property exists
      (not (nil? key-property-value))
      (if parent
-         (KeyFactory/createKey (get-key-object parent) kind key-property-value)
+         (if (instance? Key parent)
+             (KeyFactory/createKey parent kind key-property-value)
+             (KeyFactory/createKey (get-key-object parent) kind key-property-value))
          (KeyFactory/createKey kind key-property-value))
      ;; something's wrong
      :else (throw (RuntimeException.
                    "entity has no valid :key metadata, and has no fields marked :key")))))

-(defn save!-helper [entity-record kind &
-                    {:keys [parent]}]
-  (let [key-object (if parent
-                       (get-key-object entity-record parent)
-                       (get-key-object entity-record))
+(defn save!-helper [entity-record kind]
+  (let [key-object (get-key-object entity-record)
         entity (if key-object
                    (Entity. key-object)
                    (Entity. kind))]
@@ -187,9 +185,16 @@
        (get-key-object [this# parent#]
          (get-key-object-helper this# ~key-property ~kind :parent parent#))
        (save! [this#]
-         (save!-helper this# ~kind))
-       (save! [this# parent#]
-         (save!-helper this# ~kind :parent parent#)))))
+         (save!-helper this# ~kind)))))
+
+
+(defmacro new* [entity-record-type property-values & {:keys [parent]}]
+  (if parent
+      `(let [parent# ~parent
+             entity# (new ~entity-record-type ~@property-values)]
+         (if (nil? parent#)
+             entity#
+             (with-meta entity# {:key (get-key-object entity# parent#)})))))

 ;;; Note that the code relies on the API's implicit transaction tracking


Renamed the internal query* function to query-helper for consistency.

--- src/appengine_magic/services/datastore.clj
+++ src/appengine_magic/services/datastore.clj
@@ -427,12 +427,12 @@
              (throw err#))))))

-(defn query* [kind ancestor filters sorts keys-only?
-              count-only? in-transaction?
-              limit offset
-              start-cursor end-cursor
-              prefetch-size chunk-size
-              entity-record-type]
+(defn query-helper [kind ancestor filters sorts keys-only?
+                    count-only? in-transaction?
+                    limit offset
+                    start-cursor end-cursor
+                    prefetch-size chunk-size
+                    entity-record-type]
   (let [query-object (make-query-object kind ancestor filters sorts keys-only?)
         fetch-options-object (make-fetch-options-object limit offset prefetch-size chunk-size)
         prepared-query (if (and in-transaction? *current-transaction*)
@@ -504,9 +504,9 @@
                               (QuerySort. sort-property# sort-dir#))
                             (QuerySort. sort-spec# Query$SortDirection/ASCENDING)))
                       ~sort)]
-       (query* ~kind ~ancestor filter# sort# ~keys-only?
-               ~count-only? ~in-transaction?
-               ~limit ~offset
-               ~start-cursor ~end-cursor
-               ~prefetch-size ~chunk-size
-               ~entity-record-type))))
+       (query-helper ~kind ~ancestor filter# sort# ~keys-only?
+                     ~count-only? ~in-transaction?
+                     ~limit ~offset
+                     ~start-cursor ~end-cursor
+                     ~prefetch-size ~chunk-size
+                     ~entity-record-type))))


build textures efficiently

build textures efficiently

--- src/cljs/infinitelives/pixi/resources.cljs
+++ src/cljs/infinitelives/pixi/resources.cljs
@@ -84,34 +84,28 @@

 ;; setup a pixi texture cache keyed by the tail of its filename
 (defn- register!
-  [url img]
-  (let [linear (js/PIXI.Texture.fromImage
-                url true (aget js/PIXI.scaleModes "LINEAR"))
+  [url texture-hash]
+  (log "register!" url texture-hash)
+  (swap! !texture-store assoc (string/url-keyword url) texture-hash)
+  texture-hash)

-        ;; this is a hack adding # to the tail of a url so pixi doesnt use the other
-        ;; linear version
-        ;; SEE: https://github.com/GoodBoyDigital/pixi.js/issues/1724
-        nearest (js/PIXI.Texture.fromImage
-                 url)
-                 ;(str url "#") true (aget js/PIXI.scaleModes "NEAREST")
-
-
-        textures {:linear linear
-                  :nearest nearest
-                  :image img}]
-    (set! (.-scaleMode url) js/PIXI.SCALE_MODES.NEAREST)
-    (swap! !texture-store assoc (string/url-keyword url) textures)
-    textures))
-
-(defmethod resources/register! "png" [url img] (register! url img))
-(defmethod resources/register! "gif" [url img] (register! url img))
-(defmethod resources/register! "jpg" [url img] (register! url img))
+(defmethod resources/register! "png" [url texture-hash] (register! url texture-hash))
+(defmethod resources/register! "gif" [url texture-hash] (register! url texture-hash))
+(defmethod resources/register! "jpg" [url texture-hash] (register! url texture-hash))

 (defn load [url]
   (let [c (chan)
         i (js/Image.)]
-    (set! (.-onload i) #(put! c [url i]))
+    (set! (.-crossOrigin i) "")
+    (set! (.-onload i)
+          #(put! c [url
+                    {:linear (js/PIXI.Texture.
+                              (js/PIXI.BaseTexture. i js/PIXI.SCALE_MODES.LINEAR))
+                     :nearest (js/PIXI.Texture.
+                               (js/PIXI.BaseTexture. i js/PIXI.SCALE_MODES.NEAREST))
+                     :image i}
+                    ]))
     (set! (.-onerror i) #(put! c [url nil]))
     (set! (.-onabort i) #(js/alert "abort"))
     (set! (.-src i) url)


fixed bug by converting variance to scale of t distribution

--- src/distributions/normal-inverse-gamma.clj
+++ src/distributions/normal-inverse-gamma.clj
@@ -5,8 +5,8 @@

 (defrecord NormalInverseGamma [location lambda shape scale]
   random
-  (sample [d] (let [s2 (/ 1 (.sample (new GammaDistribution shape (/ 1 scale))))
-                    mu (.sample (new NormalDistribution location (sqrt (/ s2 lambda))))]
+  (sample [d] (let [s2 (sample (inverse-gamma shape scale))
+                    mu (sample (normal location (/ s2 lambda)))]
                 [mu s2]))
   (sample [d n] (take n (repeatedly #(sample d))))
   probability-function
@@ -53,8 +53,8 @@
          prior-location :location} prior]
     (t-distribution (* 2 prior-shape)
                     prior-location
-                    (/ (* prior-scale (+ 1 prior-lambda))
-                       (* prior-lambda prior-shape)))))
+                    (sqrt (/ (* prior-scale (+ 1 prior-lambda))
+                             (* prior-lambda prior-shape))))))

 (comment
 (sample (marginal (normal :mu :s2) (normal-inverse-gamma 2 3 1 2)))
@@ -68,7 +68,7 @@
 (def s22 1)
 (def prior-mean 3)
 (def prior-lambda 2)
-(def prior-shape 5)
+(def prior-shape 10)
 (def prior-scale 3)
 (- (log-pdf (posterior Y (normal :mu :s2) (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale)) [mu1 s21])
    (log-pdf (posterior Y (normal :mu :s2) (normal-inverse-gamma  prior-mean prior-lambda prior-shape prior-scale)) [mu2 s22]) )
@@ -86,4 +86,35 @@
                             (reduce + (map square (sub Y (mean Y))))) 2)))

 (double (:scale (posterior Y (normal :mu :s2) (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale))))
+
+
+(variance (t-distribution 4))
+(variance (t-distribution 4 0 10))
+
+(* (variance (t-distribution (* 2 prior-shape)))  (/ (* prior-scale (+ 1 prior-lambda)) (* prior-lambda prior-shape)))
+(variance (map (fn [[mu s2]] (sample (normal mu s2))) (sample (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale) 100000)))
+(variance (marginal (normal :mu :s2) (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale)))
+(variance (sample (marginal (normal :mu :s2) (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale)) 10000))
+
+(* (variance (t-distribution (* 2 prior-shape))) (/ (* prior-lambda prior-shape) prior-scale))
+(variance (map first
+               (sample (normal-inverse-gamma prior-mean prior-lambda prior-shape prior-scale) 10000)))
+
+(double (variance (inverse-gamma 10 10 )))
+(variance (sample (inverse-gamma 10 10) 100000))
+
+(def d (inverse-gamma 10 3))
+(double (variance d))
+(variance (sample d 100000))
+
+
+
+
+(variance (map (fn [[mu s2]] (sample (normal mu s2))) (sample (normal-inverse-gamma 4 2 1000 4) 100000)))
+(variance (map second (sample (normal-inverse-gamma 4 3 5 4) 10000)))
+(variance (inverse-gamma 5 4))
+(variance (sample (marginal (normal :mu :s2) (normal-inverse-gamma 4 2 1000 4)) 100000))
+(variance (marginal (normal :mu :s2) (normal-inverse-gamma 4 2 1000 4)))
+(variance (t-distribution 30000 3 10))
+
 )


use contains? to determine whether a dep is in the set of completed dependencies

--- src/overtone/dependencies.clj
+++ src/overtone/dependencies.clj
@@ -14,7 +14,7 @@
   [dep fun]
   (dosync
    (ensure completed-dependencies*)
-   (if (some #{dep} @completed-dependencies*)
+   (if (contains? @completed-dependencies* dep)
      (fun)
      (let [handlers (get @registered-handlers* dep [])]
        (alter registered-handlers* assoc dep (conj handlers fun))))))


removes println's

removes println's

--- src/main/clojure/pdok/featured/feature.clj
+++ src/main/clojure/pdok/featured/feature.clj
@@ -53,9 +53,7 @@
                             (map str/reverse x)
                             (reverse x))
            ns (create-ns (symbol ns))
-           _ (println ns)
-           class (ns-resolve ns (symbol class))
-           _ (println class)]
+            class (ns-resolve ns (symbol class))]
        (->NilAttribute class)))))

 (pg/register-transit-write-handler pdok.featured.feature.NilAttribute nil-attribute-writer)


Removed shifting scales because accidentals are a simpler way to do it for now.

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

 (defn translate [f x y] #(-> % (+ x) f (+ y)))
 (def major (scale [2 2 1 2 2 2 1]))
-(defn modulate [scale mode] (translate scale mode (- (scale 0) (scale mode))))
 (def g-major (translate major 0 74))
-(def scales (repeat (modulate g-major 0)))
-;(def scales (concat (repeat 9 g-major) (repeat 23 (modulate g-major 3)) (repeat 6 (modulate g-major 4)) (repeat g-major)))

 (defn bpm [per-minute] #(-> % (/ per-minute) (* 60) (* 1000)))
 (defn syncopate [timing durations] #(->> % (sum-n durations) timing))
@@ -42,7 +39,7 @@
 (def bass (map #(- % 7) (flatten (map #(repeat 3 %) (concat (run 0 -3) (run -5 -3) [-7])))))

 (defn melody# [timing notes]
-  (let [note# #(at (timing %1) (piano ((nth scales %1) %2)))]
+  (let [note# #(at (timing %1) (piano (g-major %2)))]
     (dorun (map-indexed note# notes))))

 (defn play# []


(PDB-1034) Honor local-repo for aether requests

The call to aether/resolve-artifacts wasn't honoring our :local-repo
override in our project. This patch will ensure we can use local-repo
and the effects will ripple into aether also.

Without this, when trying to do source based builds using the local
m2-local repositories, it will try and retrieve a copy of your projects
jar from maven for resource content, ignoring any local-repo setting you
might have defined. In short, this generally means any terminus files
and non-clojure items won't reflect the proper changes.

Signed-off-by: Ken Barber <470bc578162732ac7f9d387d34c4af4ca6e1b6f7@bob.sh>

--- src/puppetlabs/ezbake/dependency_utils.clj
+++ src/puppetlabs/ezbake/dependency_utils.clj
@@ -32,7 +32,8 @@
   {:post [(instance? JarFile %)]}
   (-> (aether/resolve-artifacts
         :coordinates [coords]
-        :repositories (:repositories lein-project))
+        :repositories (:repositories lein-project)
+        :local-repo (:local-repo lein-project))
       first
       meta
       :file


(maint) Include project's version in description

Change `dependency-utils/generate-manifest-string` to include the name
and version of the project itself, so it can be retrieved in the same
way as all the dependencies. This is mostly useful when staging
a SNAPSHOT version of a project.

--- src/puppetlabs/ezbake/dependency_utils.clj
+++ src/puppetlabs/ezbake/dependency_utils.clj
@@ -228,7 +228,9 @@

 (defn generate-manifest-string
   [lein-project]
-  (let [deps (get-relevant-deps lein-project)]
+  (let [deps (concat [[(symbol (:group lein-project) (:name lein-project))
+                       (:version lein-project)]]
+               (get-relevant-deps lein-project))]
     (str/join "," (map get-manifest-string deps))))

 (defn generate-dependency-tree-string


Fix alignment of sortable list properties

--- src/kanban/components/board_dialog.cljs
+++ src/kanban/components/board_dialog.cljs
@@ -47,11 +47,11 @@
                                    (map #(-> [:lane/by-id (:id %)]))
                                    (.update this :lanes)))
                  :items
-                  (for [lane lanes]
-                    {:key (:id lane)
-                     :data lane
-                     :element
-                     (dom/span #js {:className "lane-name"} (:name lane))})})))
+                 (for [lane lanes]
+                   {:key (:id lane)
+                    :data lane
+                    :element
+                    (dom/span #js {:className "lane-name"} (:name lane))})})))
           (dom/p #js {:className "dialog-buttons"}
             (dom/button #js {:onClick close-fn} "Close"))
           (dom/div #js {:className "help"}


Reuse a mail Session & share across threads

--- src/net/dishevelled/mailindex.clj
+++ src/net/dishevelled/mailindex.clj
@@ -265,6 +265,8 @@
             (.add doc (fieldpool/untokenized-field field value))))))))

+(def mail-session (Session/getDefaultInstance (Properties.)))
+
 (defn parse-message
   "Produce a Lucene document from an email message."
   [msg connection]
@@ -279,7 +281,7 @@
                                                 (-> msg :id :num)
                                                 source))))

-    (let [parsed-msg (MimeMessage. (Session/getDefaultInstance (Properties.))
+    (let [parsed-msg (MimeMessage. mail-session
                                    (ByteArrayInputStream. (:content msg)))]
       (load-headers doc parsed-msg)
       (load-body doc parsed-msg))


Eagerly remove items to control memory and heap consumption in working memory.

--- src/main/clojure/clara/rules/memory.clj
+++ src/main/clojure/clara/rules/memory.clj
@@ -87,25 +87,29 @@

 (defn remove-first-of-each
   "Remove the first instance of each item in the given set that
-   appears in the collection."
+  appears in the collection. This function does so eagerly since
+  the working memories with large numbers of insertions and retractions
+  can lazy sequences to become deeply nested."
   [set coll]
-  (lazy-seq
-
-   (loop [f (first coll)
-          r (rest coll)
-          to-remove set]
-
-     (when f
-       (if (to-remove f)
-
-         ;; The first item is to be removed, so do so and recur with rest of the items
-         ;; and it removed from our to-remove set.
-         (recur (first r)
-                (rest r)
-                (disj to-remove f))
-
-         ;; The first item didn't need to be removed, so continue with our lazy sequence.
-         (cons f (remove-first-of-each to-remove r)))))))
+  (loop [f (first coll)
+         r (rest coll)
+         to-remove set
+         result (transient [])]
+
+    (if f
+      (if (to-remove f)
+
+        (recur (first r)
+               (rest r)
+               (disj to-remove f)
+               result)
+
+        (recur (first r)
+               (rest r)
+               to-remove
+               (conj! result f)))
+
+      (persistent! result))))

 (declare ->PersistentLocalMemory)


Remove unused code from selrect.

Remove unused code from selrect.

--- src/uxbox/ui/workspace/canvas/selrect.cljs
+++ src/uxbox/ui/workspace/canvas/selrect.cljs
@@ -60,8 +60,7 @@

 (define-once :selrect-subscriptions
   (letfn [(on-value [pos]
-            (let [pos' (gpt/add pos @wb/scroll-a)]
-              (swap! selrect-pos assoc :current pos)))
+            (swap! selrect-pos assoc :current pos))

           (on-complete []
             (let [selrect (selrect->rect @selrect-pos)]


Add a with-fixtures helper for running tests in fixtures

Unfortunately, fixture execution is normally tied to `deftest`. Because
`deftest` can't be given a dynamic variable name, it can't really be
used in a loop to test multiple pieces of code that do the same thing.
`with-fixtures` is a new macro which separates invoking fixtures from
`deftest`. Any code inside a call to `with-fixtures` will be surrounded
by the fixtures for the current namespace.

--- test/com/puppetlabs/puppetdb/testutils.clj
+++ test/com/puppetlabs/puppetdb/testutils.clj
@@ -4,7 +4,8 @@
             [clojure.java.jdbc :as sql]
             [clojure.tools.logging.impl :as impl]
             [fs.core :as fs])
-  (:use     [com.puppetlabs.puppetdb.scf.storage :only [sql-current-connection-table-names]]))
+  (:use [clojure.test :only [join-fixtures]]
+        [com.puppetlabs.puppetdb.scf.storage :only [sql-current-connection-table-names]]))

 (defn test-db-config
   "This is a placeholder function; it is supposed to return a map containing
@@ -131,3 +132,9 @@
         (enabled? [_ level] true)
         (write! [_ lvl ex msg]
           (swap! output-atom conj [(str log-ns) lvl ex msg]))))))
+
+(defmacro with-fixtures
+  "Evaluates `body` wrapped by the `each` fixtures of the current namespace."
+  [& body]
+  `(let [fixture-fn# (join-fixtures (:clojure.test/each-fixtures (meta ~*ns*)))]
+     (fixture-fn# (fn [] ~@body))))


couple fixes for unit tests.

couple fixes for unit tests.

--- test/metabase/api/table_test.clj
+++ test/metabase/api/table_test.clj
@@ -292,10 +292,7 @@
        :active          true
        :id              (id :users)
        :db_id           (id)
-       :field_values    {(keyword (str (id :users :last_login)))
-                         user-last-login-date-strs
-
-                         (keyword (str (id :users :name)))
+       :field_values    {(keyword (str (id :users :name)))
                          ["Broen Olujimi"
                           "Conchúr Tihomir"
                           "Dwight Gresham"
@@ -390,10 +387,7 @@
        :active          true
        :id              (id :users)
        :db_id           (id)
-       :field_values    {(keyword (str (id :users :last_login)))
-                         user-last-login-date-strs
-
-                         (keyword (str (id :users :name)))
+       :field_values    {(keyword (str (id :users :name)))
                          ["Broen Olujimi"
                           "Conchúr Tihomir"
                           "Dwight Gresham"


fixes https://github.com/status-im/status-react/issues/964

--- src/status_im/profile/screen.cljs
+++ src/status_im/profile/screen.cljs
@@ -64,7 +64,7 @@
        [text {:style st/profile-activity-status-text}
         (online-text last-online)]])]])

-(defn profile-actions [{:keys [pending? whisper-identity]} chat-id]
+(defn profile-actions [{:keys [pending? whisper-identity dapp?]} chat-id]
   [view actions-list
    (if pending?
      [action-button (label :t/add-to-contacts)
@@ -76,10 +76,12 @@
    [action-button (label :t/start-conversation)
                   :chats_blue
                   #(message-user whisper-identity)]
-   [action-separator]
-   [action-button (label :t/send-transaction)
-                  :arrow_right_blue
-                  #(dispatch [:open-chat-with-the-send-transaction chat-id])]])
+   (when-not dapp?
+     [view
+      [action-separator]
+      [action-button (label :t/send-transaction)
+                     :arrow_right_blue
+                     #(dispatch [:open-chat-with-the-send-transaction chat-id])]])])

 (defn profile-info-item [{:keys [label value options text-mode empty-value?]}]
   [view st/profile-setting-item


refine trading lot test

refine trading lot test

--- test/clj_money/trading_test.clj
+++ test/clj_money/trading_test.clj
@@ -74,12 +74,17 @@
                                      :trade-date (t/local-date 2016 1 2)
                                      :shares 100M
                                      :value 1000M})
-        expected [{:trade-date (t/local-date 2016 1 2)
+        expected [{:purchase-date (t/local-date 2016 1 2)
                    :commodity-id (:id commodity)
                    :account-id (:id ira)
                    :shares-purchased 100M
                    :shares-owned 100M}]
-        actual (lots/select-by-commodity-id storage-spec (:id commodity))]
+        actual (map #(select-keys % [:purchase-date
+                                     :commodity-id
+                                     :account-id
+                                     :shares-purchased
+                                     :shares-owned])
+                    (lots/select-by-commodity-id storage-spec (:id commodity)))]
     (is (= expected actual) "The lot can be retrieved from the database")))

 (deftest a-purchase-creates-a-lot-transaction-recrd


Simplify the code a bit

Simplify the code a bit

--- 2017/reducers-transducers-async/clojure/reducers/src/reducers/async_transducer.clj
+++ 2017/reducers-transducers-async/clojure/reducers/src/reducers/async_transducer.clj
@@ -62,12 +62,10 @@
 (defn main-3
   []
   (let [c-sq (async/chan 1 (map #(* % %)))]
-    (do
-      (async/go
-        (async/onto-chan c-sq [2 3 4 5]))
-      (loop [n (async/<!! c-sq)]
-        (when n
-          (println n)
-          (recur (async/<!! c-sq)))))))
+    (async/onto-chan c-sq [2 3 4 5])
+    (loop [n (async/<!! c-sq)]
+      (when n
+        (println n)
+        (recur (async/<!! c-sq))))))

 (main-3)


updating statement specs, #68

updating statement specs, #68

--- src/org/libraryweasel/ligature/core.clj
+++ src/org/libraryweasel/ligature/core.clj
@@ -152,13 +152,15 @@

 (s/def ::object object?)

-(s/def ::triple triple?)
+(s/def ::graph graph?)

-(s/def ::quad quad?)
+(s/def ::triple (s/tuple ::subject ::predicate ::object))

-(s/def ::statement statement?)
+(s/def ::quad (s/tuple ::subject ::predicate ::object ::graph))

-(s/def ::statements statements?)
+(s/def ::statement (s/or ::triple ::quad))
+
+(s/def ::statements (s/coll-of ::statement))

 (defn subject
   "Accepts a Statement tuple and returns the Subject."


Implement synchronous queue to be used in test purposes

--- test/io/cyanite/test_helper.clj
+++ test/io/cyanite/test_helper.clj
@@ -44,6 +44,21 @@
   (deref [this]
     0))

+(defrecord SynchronousQueue [consumers]
+  component/Lifecycle
+  (start [this]
+    (let [q (assoc this :consumers (atom []))]
+      (assoc this :consumers (atom []) :ingestq q :writeq q)))
+  (stop [this]
+    (assoc this :consumers nil))
+  queue/QueueEngine
+  (shutdown! [this])
+  (add! [this e]
+    (doseq [f @consumers]
+      (f e)))
+  (consume! [this f]
+    (swap! consumers conj f)))
+
 (def ^:dynamic *system*)

 (defn make-test-system
@@ -51,7 +66,7 @@
   (-> config
       (update :clock  #(map->TimeTravellingClock %))
       (update :drift  #(component/using (map->NoOpDrift %) [:clock]))
-      (update :queues queue/map->BlockingMemoryQueue)
+      (update :queues map->SynchronousQueue)
       (update :index  index/build-index)
       (update :writer #(component/using (map->MemoryWriter %) [:index
                                                                :queues]))))


Improve brittlness of test for CI

Improve brittlness of test for CI

--- test/onyx/metrics/send_test.clj
+++ test/onyx/metrics/send_test.clj
@@ -122,6 +122,5 @@
                 (is (= :done (last results)))
                 (is (> (count @events) (* 3 ; number of tasks
                                           (/ (- end-time start-time) 1000)
-                                          ;; 4 events every second + 8 events ever 10 seconds, round down a little
-                                          ;; because of test brittleness
-                                          3.8)))))))))))
+                                          ;; only approximate because of brittle test on CI
+                                          3)))))))))))


fix paren & indentation

fix paren & indentation

--- test/semantic_csv/core_test.clj
+++ test/semantic_csv/core_test.clj
@@ -27,22 +27,22 @@
              [["// another comment"]])))
     (testing "remove-comments should take an optional comment designator"
       (is (= (remove-comments #"^//" data)
-             [["# a comment"]]))))
+             [["# a comment"]])))))

-  (deftest casting-test
-    (let [data [["this" "that"]
-                ["1" "y"]]]
-      (testing "should work with mappify"
-        (is (= (->> data
-                    mappify
-                    (cast-with {:this ->int})
-                    first)
-               {:this 1 :that "y"}))))
-    (let [data [["1" "this"]
-                ["2" "that"]]]
-      (testing "should work without mappify"
-        (is (= (->> data
-                    (cast-with {0 ->int})
-                    second)
-               [2 "that"]))))))
+(deftest casting-test
+  (let [data [["this" "that"]
+              ["1" "y"]]]
+    (testing "should work with mappify"
+      (is (= (->> data
+                  mappify
+                  (cast-with {:this ->int})
+                  first)
+             {:this 1 :that "y"}))))
+  (let [data [["1" "this"]
+              ["2" "that"]]]
+    (testing "should work without mappify"
+      (is (= (->> data
+                  (cast-with {0 ->int})
+                  second)
+             [2 "that"])))))


Remove old monolitic tests file.

Remove old monolitic tests file.

--- test/buddy/test_buddy_auth.clj
+++ test/buddy/test_buddy_auth.clj
@@ -1,233 +0,0 @@
-(ns buddy.test_buddy_auth
-  (:require [clojure.test :refer :all]
-            [ring.util.response :refer [response? response]]
-            [buddy.core.codecs :refer :all]
-            [buddy.sign.generic :as s]
-            [buddy.auth :refer [throw-unauthorized]]
-            [buddy.auth.backends.httpbasic :refer [http-basic-backend parse-httpbasic-header]]
-            [buddy.auth.backends.session :refer [session-backend]]
-            [buddy.auth.backends.token :as stoken]
-            [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]))
-
-(defn make-httpbasic-request
-  [username, password]
-  (if (and username password)
-    {:headers {"authorization" (format "Basic %s" (str->base64 (format "%s:%s" username password)))}}
-    {:headers {}}))
-
-(defn httpbasic-auth-fn
-  [request {:keys [username]}]
-  (when (= username "foo")
-    :foo))
-
-(def secret-key "test-secret-key")
-
-(deftest http-basic-parse-test
-  (testing "Parse httpbasic header from request"
-    (let [header  (format "Basic %s" (str->base64 "foo:bar"))
-          request {:headers {"authorization" header}}
-          parsed  (parse-httpbasic-header request)]
-      (is (not (nil? parsed)))
-      (is (= (:password parsed) "bar"))
-      (is (= (:username parsed) "foo")))))
-
-(deftest token-test
-  (let [authfn (fn [request token]
-                 (get {:token1 {:userid 1}
-                       :token2 {:userid 2}} (keyword token)))]
-    (testing "Parse authorization header"
-      (let [signed-data     (s/dumps {:userid 1} secret-key)
-            header-content  (format "Token %s" signed-data)
-            request         {:headers {"authorization" header-content}}
-            parsed          (stoken/parse-authorization-header request)]
-        (is (= parsed signed-data))))
-
-    (testing "Signed token backend authentication"
-      (let [signed-data     (s/dumps {:userid 1} secret-key)
-            header-content  (format "Token %s" signed-data)
-            request         {:headers {"authorization" header-content}}
-            backend         (stoken/signed-token-backend {:privkey secret-key})
-            handler         (-> (fn [req] req)
-                                (wrap-authentication backend))
-            resp            (handler request)]
-        (is (= (:identity resp) {:userid 1}))))
-
-    (testing "Signed token backend wrong authentication"
-      (let [signed-data     (s/dumps {:userid 1} "wrong-key")
-            header-content  (format "Token %s" signed-data)
-            request         {:headers {"authorization" header-content}}
-            backend         (stoken/signed-token-backend {:privkey secret-key})
-            handler         (-> (fn [req] req)
-                                (wrap-authentication backend))
-            resp            (handler request)]
-        (is (nil? (:identity resp)))))
-
-    (testing "Signed token backend with wrong data"
-      (let [header-content  "Token foobar"
-            request         {:headers {"authorization" header-content}}
-            backend         (stoken/signed-token-backend {:privkey secret-key})
-            handler         (-> (fn [req] req)
-                                (wrap-authentication backend))
-            resp            (handler request)]
-        (is (nil? (:identity resp)))))
-
-  (testing "Signed token unathorized request 1"
-    (let [signed-data     (s/dumps {:userid 1} secret-key)
-          header-content  (format "Token %s" signed-data)
-          request         {:headers {"authorization" header-content}}
-          backend         (stoken/signed-token-backend {:privkey secret-key})
-          handler         (-> (fn [req] (throw-unauthorized))
-                              (wrap-authorization backend)
-                              (wrap-authentication backend))
-          resp            (handler request)]
-      (is (= (:status resp) 403))))
-
-  (testing "Signed token unathorized request 2"
-    (let [signed-data     (s/dumps {:userid 1} "wrong-key")
-          header-content  (format "Token %s" signed-data)
-          request         {:headers {"authorization" header-content}}
-          backend         (stoken/signed-token-backend {:privkey secret-key})
-          handler         (-> (fn [req] (throw-unauthorized))
-                              (wrap-authorization backend)
-                              (wrap-authentication backend))
-          resp            (handler request)]
-      (is (= (:status resp) 401))))
-
-  (testing "Signed token unathorized request 3"
-    (let [signed-data     (s/dumps {:userid 1} "wrong-key")
-          header-content  (format "Token %s" signed-data)
-          request         {:headers {"authorization" header-content}}
-          uhandler        (fn [_ _] {:status 3000})
-          backend         (stoken/signed-token-backend {:privkey secret-key
-                                                        :unauthorized-handler uhandler})
-          handler         (-> (fn [req] (throw-unauthorized))
-                              (wrap-authorization backend)
-                              (wrap-authentication backend))
-          resp            (handler request)]
-      (is (= (:status resp) 3000))))
-
-    (testing "Basic token backend authentication 01"
-      (let [request              {:headers {"authorization" "Token token1"}}
-            backend              (stoken/token-backend {:authfn authfn})
-            handler              (-> (fn [request] (:identity request))
-                                     (wrap-authentication backend))
-            response             (handler request)]
-        (is (= response {:userid 1}))))
-
-    (testing "Token backend with unauthorized requests 1"
-      (let [request  {:headers {"authorization" "Token token1"}}
-            backend  (stoken/token-backend {:authfn authfn})
-            handler  (-> (fn [request] (throw-unauthorized))
-                         (wrap-authorization backend)
-                         (wrap-authentication backend))
-            response (handler request)]
-        (is (= (:status response) 403))))
-
-    (testing "Token backend with unauthorized requests 2"
-      (let [request  {:headers {"authorization" "Token token3"}}
-            backend  (stoken/token-backend {:authfn authfn})
-            handler  (-> (fn [request] (throw-unauthorized))
-                         (wrap-authorization backend)
-                         (wrap-authentication backend))
-            response (handler request)]
-        (is (= (:status response) 401))))
-
-    (testing "Token backend with unauthorized requests 3"
-      (let [request  {:headers {"authorization" "Token token3"}}
-            uhandler (fn [_ _] {:status 3000})
-            backend  (stoken/token-backend {:authfn authfn
-                                            :unauthorized-handler uhandler})
-            handler  (-> (fn [request] (throw-unauthorized))
-                         (wrap-authorization backend)
-                         (wrap-authentication backend))
-            response (handler request)]
-        (is (= (:status response) 3000))))
-
-))
-
-(deftest session-auth-test
-  (testing "Simple backend authentication 01"
-    (let [request {:session {:identity {:userid 1}}}
-          backend (session-backend)
-          handler (fn [req] req)
-          handler (wrap-authentication handler backend)
-          resp    (handler request)]
-      (is (= (:identity resp) {:userid 1}))))
-
-  (testing "Simple backend authentication 02"
-    (let [request {:session {}}
-          backend (session-backend)
-          handler (fn [req] )
-          handler (wrap-authentication handler backend)
-          resp    (handler request)]
-      (is (nil? (:identity resp)))))
-
-  (testing "Handle unauthenticated unauthorized requests without specifying unauthorized handler"
-    (let [request {:session {}}
-          backend (session-backend)
-          handler (-> (fn [req] (throw-unauthorized "FooMsg"))
-                      (wrap-authorization backend)
-                      (wrap-authentication backend))
-          resp    (handler request)]
-      (is (= (:status resp) 401))))
-
-  (testing "Handle unauthorized requests specifying unauthorized handler"
-    (let [request {:session {}}
-          uhander (fn [request metadata] {:body "" :status 3000})
-          backend (session-backend {:unauthorized-handler uhander})
-          handler (-> (fn [req] (throw-unauthorized "FooMsg"))
-                      (wrap-authorization backend)
-                      (wrap-authentication backend))
-          resp    (handler request)]
-      (is (= (:status resp) 3000))))
-
-  (testing "Handle authenticated unauthorized requests without specifying unauthorized handler"
-    (let [request {:session {:identity {:userid 1}}}
-          backend (session-backend)
-          handler (-> (fn [req] (throw-unauthorized "FooMsg"))
-                      (wrap-authorization backend)
-                      (wrap-authentication backend))
-          resp    (handler request)]
-      (is (= (:status resp) 403)))))
-
-(deftest authentication-middleware-test-with-httpbasic
-  (testing "Auth middleware with http-basic backend"
-    (let [backend (http-basic-backend {:realm "Foo" :authfn httpbasic-auth-fn})
-          handler (fn [req] req)
-          handler (wrap-authentication handler backend)]
-      (let [req   (make-httpbasic-request "user" "pass")
-            resp  (handler req)]
-        (is (nil? (:identity resp))))
-      (let [req   (make-httpbasic-request "foo" "pass")
-            resp  (handler req)]
-        (is (= (:identity resp) :foo))))))
-
-(deftest authorization-middleware-test-with-httpbasic
-  (testing "Authorization middleware tests 01 with httpbasic backend"
-    (let [backend (http-basic-backend {:realm "Foo" :authfn httpbasic-auth-fn})
-          handler (fn [req] (if (nil? (:identity req))
-                              (throw-unauthorized {:msg "FooMsg"})
-                              req))
-          handler (wrap-authorization handler backend)
-          handler (wrap-authentication handler backend)
-          req     (make-httpbasic-request "user" "pass")
-          resp    (handler req)]
-      (is (= (:status resp) 401))))
-  (testing "Authorization middleware tests 02 with httpbasic backend"
-    (let [backend (http-basic-backend {:realm "Foo" :authfn httpbasic-auth-fn})
-          handler (fn [req] (if (nil? (:identity req))
-                              (throw-unauthorized {:msg "FooMsg"})
-                              req))
-          handler (wrap-authorization handler backend)
-          handler (wrap-authentication handler backend)
-          req     (make-httpbasic-request "foo" "pass")
-          resp    (handler req)]
-      (is (= (:identity resp) :foo))))
-  (testing "Authorization middleware tests 03 with httpbasic backend"
-    (let [backend (http-basic-backend {:realm "Foo" :authfn httpbasic-auth-fn})
-          handler (fn [req] (throw-unauthorized {:msg "FooMsg"}))
-          handler (wrap-authorization handler backend)
-          handler (wrap-authentication handler backend)
-          req     (make-httpbasic-request "foo" "pass")
-          resp    (handler req)]
-      (is (= (:status resp) 403)))))


Add more tests for compact message signing.

--- test/buddy/test_buddy_sign.clj
+++ test/buddy/test_buddy_sign.clj
@@ -25,97 +25,122 @@
   (:import java.util.Arrays))

 (def secret "test")
+(def rsa-privkey (private-key "test/_files/privkey.3des.rsa.pem" "secret"))
+(def rsa-pubkey (public-key "test/_files/pubkey.3des.rsa.pem"))
+(def ec-privkey (private-key "test/_files/privkey.ecdsa.pem" "secret"))
+(def ec-pubkey (public-key "test/_files/pubkey.ecdsa.pem"))

 (deftest buddy-sign-jws
-  (let [plainkey "secret"
-        rsa-privkey (private-key "test/_files/privkey.3des.rsa.pem" "secret")
-        rsa-pubkey  (public-key "test/_files/pubkey.3des.rsa.pem")
-        ec-privkey  (private-key "test/_files/privkey.ecdsa.pem" "secret")
-        ec-pubkey   (public-key "test/_files/pubkey.ecdsa.pem")]
+  (testing "Pass exp as claim or parameter shoult return same result"
+    (let [candidate1 {"iss" "joe" :exp 1300819380}
+          candidate2 {"iss" "joe"}
+          result1    (jws/encode candidate1 secret)
+          result2    (jws/encode candidate2 secret {:exp 1300819380})]
+      (is (= result1 result2))))

-    (testing "Pass exp as claim or parameter shoult return same result"
-      (let [candidate1 {"iss" "joe" :exp 1300819380}
-            candidate2 {"iss" "joe"}
-            result1    (jws/encode candidate1 plainkey)
-            result2    (jws/encode candidate2 plainkey {:exp 1300819380})]
-        (is (= result1 result2))))
+  (testing "Unsing simple jws"
+    (let [candidate {:foo "bar"}
+          result    (-> (jws/encode candidate secret)
+                        (either/from-either)
+                        (jws/decode secret))]
+      (is (either/right? result))
+      (is (= (either/from-either result) candidate))))

-    (testing "Unsing simple jws"
-      (let [candidate {:foo "bar"}
-            result    (-> (jws/encode candidate plainkey)
-                          (either/from-either)
-                          (jws/decode plainkey))]
-        (is (either/right? result))
-        (is (= (either/from-either result) candidate))))
+  (testing "Unsigning jws with exp"
+    (let [candidate {:foo "bar"}
+          now       (jws/to-timestamp (jodat/now))
+          exp       (+ now 2)
+          signed    (-> (jws/encode candidate secret {:exp exp})
+                        (either/from-either))]
+      (let [unsigned (-> (jws/decode signed secret)
+                         (either/from-either))]
+        (is (= unsigned (assoc candidate :exp exp))))

-    (testing "Unsigning jws with exp"
-      (let [candidate {:foo "bar"}
-            now       (jws/to-timestamp (jodat/now))
-            exp       (+ now 2)
-            signed    (-> (jws/encode candidate plainkey {:exp exp})
-                          (either/from-either))]
-        (let [unsigned (-> (jws/decode signed plainkey)
-                           (either/from-either))]
-          (is (= unsigned (assoc candidate :exp exp))))
+      (Thread/sleep 3000)

-        (Thread/sleep 3000)
+      (let [unsigned (jws/decode signed secret)]
+        (is (either/left? unsigned)))))

-        (let [unsigned (jws/decode signed plainkey)]
-          (is (either/left? unsigned)))))
+  (testing "Unsigning jws with nbf"
+    (let [candidate {:foo "bar"}
+          now       (jws/to-timestamp (jodat/now))
+          nbf       (+ now 2)
+          signed    (-> (jws/encode candidate secret {:nbf nbf})
+                        (either/from-either))]
+      (let [unsigned (jws/decode signed secret)]
+        (is (either/right? unsigned))
+        (is (= (either/from-either unsigned) (assoc candidate :nbf nbf))))

-    (testing "Unsigning jws with nbf"
-      (let [candidate {:foo "bar"}
-            now       (jws/to-timestamp (jodat/now))
-            nbf       (+ now 2)
-            signed    (-> (jws/encode candidate plainkey {:nbf nbf})
-                          (either/from-either))]
-        (let [unsigned (jws/decode signed plainkey)]
-          (is (either/right? unsigned))
-          (is (= (either/from-either unsigned) (assoc candidate :nbf nbf))))
+      (Thread/sleep 3000)

-        (Thread/sleep 3000)
+      (let [unsigned (jws/decode signed secret)]
+        (is (either/left? unsigned)))))

-        (let [unsigned (jws/decode signed plainkey)]
-          (is (either/left? unsigned)))))
+  (testing "Using :hs256 hmac with expired token."
+    (let [secret (safebase64->bytes (str "KdnIJv7h5r--N2Na7XfS0EiHUKrZm_"
+                                         "qucUbF6PmE6FOMrelLwzBOGEmI17Uqmaeu"))
+          data (str "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL29yc"
+                    "GhpZC10ZXN0LmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1NGNhZmM0YzJlMGU"
+                    "5YzZiMTQ5ZDMwY2QiLCJhdWQiOiJIdTRxd3FRaU9nVHJCNlliT2NHTXBUQTdpN"
+                    "jFSNVp1SCIsImV4cCI6MTQyMjYyNTA5MCwiaWF0IjoxNDIyNTg5MDkwfQ.3wKN"
+                    "ZzgghjpsPBi5gDwv-RkbzvhG22Npcfyl8SUZriI")
+          result (jws/decode data secret {:alg :hs256})]
+      (is (either/left? result))))

-    (testing "Using :hs256 hmac with expired token."
-      (let [secret (safebase64->bytes (str "KdnIJv7h5r--N2Na7XfS0EiHUKrZm_"
-                                           "qucUbF6PmE6FOMrelLwzBOGEmI17Uqmaeu"))
-            data (str "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL29yc"
-                      "GhpZC10ZXN0LmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1NGNhZmM0YzJlMGU"
-                      "5YzZiMTQ5ZDMwY2QiLCJhdWQiOiJIdTRxd3FRaU9nVHJCNlliT2NHTXBUQTdpN"
-                      "jFSNVp1SCIsImV4cCI6MTQyMjYyNTA5MCwiaWF0IjoxNDIyNTg5MDkwfQ.3wKN"
-                      "ZzgghjpsPBi5gDwv-RkbzvhG22Npcfyl8SUZriI")
-            result (jws/decode data secret {:alg :hs256})]
-        (is (either/left? result))))
+  (testing "Using :rs256 digital signature"
+    (let [candidate {:foo "bar"}
+          result    (-> (jws/encode candidate rsa-privkey {:alg :rs256})
+                        (either/from-either)
+                        (jws/decode rsa-pubkey {:alg :rs256}))]
+      (is (= (either/from-either result) candidate))))

-    (testing "Using :rs256 digital signature"
-      (let [candidate {:foo "bar"}
-            result    (-> (jws/encode candidate rsa-privkey {:alg :rs256})
-                          (either/from-either)
-                          (jws/decode rsa-pubkey {:alg :rs256}))]
-        (is (= (either/from-either result) candidate))))
+  (testing "Using :ps512 digital signature"
+    (let [candidate {:foo "bar"}
+          result    (-> (jws/encode candidate rsa-privkey {:alg :ps512})
+                        (either/from-either)
+                        (jws/decode rsa-pubkey {:alg :ps512}))]
+      (is (= (either/from-either result) candidate))))

-    (testing "Using :ps512 digital signature"
-      (let [candidate {:foo "bar"}
-            result    (-> (jws/encode candidate rsa-privkey {:alg :ps512})
-                          (either/from-either)
-                          (jws/decode rsa-pubkey {:alg :ps512}))]
-        (is (= (either/from-either result) candidate))))
-
-    (testing "Using :ec512 digital signature"
-      (let [candidate {:foo "bar"}
-            result    (-> (jws/encode candidate ec-privkey {:alg :es512})
-                          (either/from-either)
-                          (jws/decode ec-pubkey {:alg :es512}))]
-        (is (= (either/from-either result) candidate))))
-))
+  (testing "Using :ec512 digital signature"
+    (let [candidate {:foo "bar"}
+          result    (-> (jws/encode candidate ec-privkey {:alg :es512})
+                        (either/from-either)
+                        (jws/decode ec-pubkey {:alg :es512}))]
+      (is (= (either/from-either result) candidate))))
+)

 (deftest buddy-sign-compact
-  (testing "Signing with compat implementation."
+  (testing "Signing with compat implementation using :hs256."
     (let [data {:foo1 "bar1"}
           signed (compact/encode data secret)]
       (is (= (either/right data)
              (compact/decode @signed secret)))))
+
+  (testing "Using :poly1305-aes mac algorithm"
+    (let [data {:foo1 "bar1"}
+          signed (compact/encode data secret {:alg :poly1305-aes})]
+      (is (= (either/right data)
+             (compact/decode @signed secret {:alg :poly1305-aes})))))
+
+  (testing "Using :rs256 digital signature"
+    (let [candidate {:foo "bar"}
+          result    (-> (compact/encode candidate rsa-privkey {:alg :rs256})
+                        (either/from-either)
+                        (compact/decode rsa-pubkey {:alg :rs256}))]
+      (is (= (either/from-either result) candidate))))
+
+    (testing "Using :ps512 digital signature"
+      (let [candidate {:foo "bar"}
+            result    (-> (compact/encode candidate rsa-privkey {:alg :ps512})
+                          (either/from-either)
+                          (compact/decode rsa-pubkey {:alg :ps512}))]
+        (is (= (either/from-either result) candidate))))
+
+  (testing "Using :ec512 digital signature"
+    (let [candidate {:foo "bar"}
+          result    (-> (compact/encode candidate ec-privkey {:alg :es512})
+                        (either/from-either)
+                        (compact/decode ec-pubkey {:alg :es512}))]
+      (is (= (either/from-either result) candidate))))
 )


Fix ns decl

Fix ns decl

--- test/caesium/crypto/hash_test.clj
+++ test/caesium/crypto/hash_test.clj
@@ -1,9 +1,9 @@
 (ns caesium.crypto.hash-test
   (:require [caesium.crypto.hash :as h]
+            [caesium.test-utils :refer [const-test]]
             [caesium.util :refer [array-eq]]
             [caesium.vectors :as v]
-            [caesium.test-utils :refer [const-test]]
-            [clojure.test :refer [are deftest is]]))
+            [clojure.test :refer [are deftest]]))

 (const-test
  h/sha256-bytes 32


eh, test a bit longer for generative data

--- test/cheshire/test/generative.clj
+++ test/cheshire/test/generative.clj
@@ -49,7 +49,7 @@
     (when-not verbose
       (reset! report-fn identity))
     (println "Seeds:" seeds)
-    (binding [*msec* 15000
+    (binding [*msec* 25000
               *seeds* seeds
               *verbose* false]
       (doall (map deref (test-namespaces 'cheshire.test.generative))))))


Add first test for fake transactor creation process.

--- test/continuo/postgresql_spec.clj
+++ test/continuo/postgresql_spec.clj
@@ -1,11 +1,54 @@
 (ns continuo.postgresql-spec
   (:require [clojure.test :as t]
-            [continuo.postgresql.schema :as schema]))
+            [suricatta.core :as sc]
+            [continuo.core :as co]
+            [continuo.impl :as impl]
+            [continuo.executor :as exec]
+            [continuo.postgresql.connection :as conn]
+            [continuo.postgresql.schema :as schema])
+  (:import java.net.URI))

-(t/deftest schema-internal-tests
-  (let [schema [[:db/add :user/username {:type :continuo/string}]
-                [:db/add :user/fullname {:type :continuo/string}]
-                [:db/drop :user/name]]
-        cschema (schema/compile-schema schema)]
-    (cschema (fn [sql]
-               (println "Executing:" sql)))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Fixtures & Initialization
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def +ctx+)
+(def dbspec {:subprotocol "postgresql"
+             :subname "//127.0.0.1/test"})
+
+(defn transaction-fixture
+  [continuation]
+  (with-open [ctx (sc/context dbspec)]
+    (sc/atomic ctx
+      (alter-var-root #'+ctx+ (constantly ctx))
+      (continuation)
+      (sc/set-rollback! ctx))))
+
+(deftype Transactor [schema]
+  conn/ITrasactor
+  (-get-connection [_] +ctx+)
+  (-get-schema [_] schema))
+
+(defmethod impl/connect :pgtest
+  [_ _]
+  (exec/submit (fn [] (Transactor. (atom nil)))))
+
+(t/use-fixtures :each transaction-fixture)
+
+(def ^:static uri "pgtest://localhost/test")
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Tests
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(t/deftest facked-connect-tests
+  (let [tx @(impl/connect (URI. uri) {})]
+    (t/is (instance? Transactor tx))))
+
+;; (t/deftest schema-internal-tests
+;;   (let [schema [[:db/add :user/username {:type :continuo/string}]
+;;                 [:db/add :user/fullname {:type :continuo/string}]
+;;                 [:db/drop :user/name]]
+;;         cschema (schema/compile-schema schema)]
+;;     (cschema (fn [sql]
+;;                (println "Executing:" sql)))))


wont be needing that

wont be needing that

--- clj-unit/compile.clj
+++ clj-unit/compile.clj
@@ -1,3 +0,0 @@
-(binding [*compile-path*      "classes"
-          *warn-on-reflection* true]
-  (compile 'clj-unit.core))


Returning index specific refresh calls

Returning index specific refresh calls

--- test/kixi/integration/base.clj
+++ test/kixi/integration/base.clj
@@ -43,7 +43,10 @@
   []
   (let [conn (esr/connect (str "http://" es-host ":" es-port)
                           {:connection-manager (clj-http.conn-mgr/make-reusable-conn-manager {:timeout 10})})]
-    (esi/refresh conn)))
+    (esi/refresh conn
+                 kixi.datastore.metadatastore.elasticsearch/index-name)
+    (esi/refresh conn
+                 kixi.datastore.schemastore.elasticsearch/index-name)))

 (defmacro is-submap
   [expected actual & [msg]]
@@ -365,9 +368,9 @@
     (if (= :kixi.datastore.schema/created
            (:kixi.comms.event/key  event))
       (do
+        (refresh-indexes)
         (wait-for-url uid (schema-url
-                             (get-in event [:kixi.comms.event/payload ::ss/id])))
-        (refresh-indexes))
+                             (get-in event [:kixi.comms.event/payload ::ss/id]))))
       event)))

 (defn metadata->user-id


Couple of Redis calls leaked through

Couple of Redis calls leaked through

--- test/exploud/deployments_test.clj
+++ test/exploud/deployments_test.clj
@@ -157,6 +157,7 @@
                                    :undo-message "message"
                                    :undo-silent true
                                    :undo-user "user"}) => ..es-result..
+       (redis/resume "application" "environment" "region") => ..resume-result..
        (redis/enqueue {:action :exploud.messages.data/start-deployment
                        :parameters {:application "application"
                                     :environment "environment"
@@ -180,6 +181,7 @@
                                    :undo-message "message"
                                    :undo-silent true
                                    :undo-user "user"}) => ..es-result..
+       (redis/resume "application" "environment" "region") => ..resume-result..
        (redis/enqueue {:action :exploud.messages.data/start-deployment
                        :parameters {:id "id"
                                     :status "running"


influxdb test fixed

influxdb test fixed

--- test/riemann/influxdb_test.clj
+++ test/riemann/influxdb_test.clj
@@ -58,7 +58,7 @@
 (deftest point-conversion
   (is (nil? (influxdb/event->point-9 #{} {:service "foo test", :time 1}))
       "Event with no metric is converted to nil")
-  (is (= {"name" "test service"
+  (is (= {"measurement" "test service"
           "time" "2015-04-07T00:32:45.000Z"
           "tags" {"host" "host-01"}
           "fields" {"value" 42.08}}
@@ -69,7 +69,7 @@
             :time 1428366765
             :metric 42.08}))
       "Minimal event is converted to point fields")
-  (is (= {"name" "service_api_req_latency"
+  (is (= {"measurement" "service_api_req_latency"
           "time" "2015-04-06T21:15:41.000Z"
           "tags" {"host" "www-dev-app-01.sfo1.example.com"
                   "sys" "www"


removing wrap internal errir

removing wrap internal errir

--- resources/leiningen/new/closp/clj/middleware.clj
+++ resources/leiningen/new/closp/clj/middleware.clj
@@ -2,7 +2,6 @@
   (:require [clojure.tools.logging :as log]
             [prone.middleware :as prone]
             [taoensso.tempura :refer [tr] :as tempura]
-            [noir-exception.core :refer [wrap-internal-error]]
             [buddy.auth.middleware :refer [wrap-authentication wrap-authorization]]
             [buddy.auth.accessrules :refer [wrap-access-rules]]
             [ring.middleware.anti-forgery :refer [wrap-anti-forgery]]
@@ -21,17 +20,13 @@
   (fn [req]
     (let [accept-language (get-in req [:headers "accept-language"])
           short-languages (or (tempura/parse-http-accept-header accept-language) ["en"])]
-      (sess/put! :locale (first short-languages))
       (handler (assoc req :localize (partial tr
                                              {:default-locale :en
                                               :dict           loc/local-dict}
                                              short-languages))))))

 (defn add-req-properties [handler config]
-  (fn [req]
-    (sess/put! :registration-allowed? (:registration-allowed? config))
-    (sess/put! :captcha-enabled? (:captcha-enabled? config))
-    (handler req)))
+  (fn [req] (handler (assoc req :config config))))

 (def development-middleware
   [#(wrap-miniprofiler % {:store in-memory-store-instance})
@@ -43,7 +38,6 @@
    add-locale
    #(wrap-access-rules % {:rules auth/rules})
    #(wrap-authorization % auth/auth-backend)
-   #(wrap-internal-error % :log (fn [e] (log/error e)))
    #(wrap-transit-response % {:encoding :json :opts {}})
    wrap-anti-forgery
    wrap-trimmings])


fix formatting when logging unhandled events

This has been bugging me for weeks...

--- components/sente/src/gorillalabs/tesla/component/router.clj
+++ components/sente/src/gorillalabs/tesla/component/router.clj
@@ -16,7 +16,7 @@
                (go (try
                      (if-let [event-fn (get @(:events router) id)]
                        (event-fn event-msg)
-                       (do (log/info "Unhandled event: %s" id)
+                       (do (log/infof "Unhandled event: %s" id)
                            (when ?reply-fn
                              (?reply-fn {:umatched-event-as-echoed-from-from-server event}))))
                      (catch Exception e (log/error  "Caught exception: " (.getMessage e))))
@@ -30,7 +30,7 @@
   (swap! (:events router-component) dissoc id))

 (defn- start []
-  (log/info "-> Starting sente router")
+  (log/info "-> Starting sente router.")
   (let [event-msg-channel (chan)]
     (event-msg-handler event-msg-channel)
     {:event-msg-channel event-msg-channel :events (atom {}) :router (sente/start-server-chsk-router! (:ch-recv socket/socket) #(go (>! event-msg-channel %)))}))


fix typo

fix typo

--- moebius/src/moebius/core.clj
+++ moebius/src/moebius/core.clj
@@ -162,7 +162,7 @@

 (defmacro when-event-name-is
   "if the eventName of the given event is equal to the give name
-  then evaluate the body. Oterwhise the event is returned unchanged.
+  then evaluate the body. Otherwhise the event is returned unchanged.

    example:

@@ -187,8 +187,8 @@

 (defmacro when-event-match
-  "if the eventName of the given event is equal to the give name
-  then evaluate the body. Oterwhise the event is returned unchanged.
+  "If the event matches one of the patterns the related expression is evaluated and returned.
+   If none matches the event is left unchanged.

    example:


app-state is just derefing the reconciler

--- src/test/compassus/tests.cljc
+++ src/test/compassus/tests.cljc
@@ -44,15 +44,10 @@
 (deftest test-create-app
   (is (instance? compassus.core.CompassusApplication *app*))
   (is (om/reconciler? (c/get-reconciler *app*)))
-  (is (= (-> (c/get-reconciler *app*)
-           om/app-state
-           deref
+  (is (= (-> @(c/get-reconciler *app*)
            (dissoc ::c/route))
         init-state))
-  (is (contains? (-> (c/get-reconciler *app*)
-                   om/app-state
-                   deref)
-        ::c/route))
+  (is (contains? @(c/get-reconciler *app*) ::c/route))
   (is (some? (c/root-class *app*)))
   (is (fn? (c/root-class *app*)))
   (is (some? #?(:clj  (-> (c/root-class *app*) meta :component-name)
@@ -179,7 +174,7 @@
                                               :parser (om/parser {:read posts-read})}})
         r (c/get-reconciler app)
         p (-> r :config :parser)]
-    (is (not= posts-init-state (dissoc @(om/app-state r) ::c/route)))
+    (is (not= posts-init-state (dissoc @r ::c/route)))
     (is (= (-> (p {:state (-> r :config :state)} (om/get-query (c/root-class app)))
                (get ::c/route-data))
            posts-init-state))))
@@ -246,12 +241,12 @@
              (om/get-query (c/root-class app)) [:remote])
            {:remote [{:index (om/get-query Home)}]}))
     (c/mount! app nil)
-    (is (= (dissoc @(om/app-state (c/get-reconciler app)) ::c/route) init-state))
+    (is (= (dissoc @(c/get-reconciler app) ::c/route) init-state))
     (is (= (om/gather-sends (#'om/to-env r)
              '[(fire/missiles! {:how-many 42})] [:remote])
            {:remote '[(fire/missiles! {:how-many 42})]}))
     (om/transact! r '[(fire/missiles! {:how-many 3})])
-    (is (= (-> @(om/app-state r) (get 'fire/missiles!) :result)
+    (is (= (-> @r (get 'fire/missiles!) :result)
            {:missiles/fired? 3}))
     (c/set-route! app :about)
     (is (= (om/gather-sends (#'om/to-env r)
@@ -278,7 +273,7 @@
                           (cb (remote-parser {} remote)))}})
         r (c/get-reconciler app)]
     (c/mount! app nil)
-    (is (contains? @(om/app-state (c/get-reconciler app)) :foo))))
+    (is (contains? @(c/get-reconciler app) :foo))))

 (def idents-state
   {:item/by-id {0 {:id 0 :name "some item"}}})


Change name of storytime page.

Change name of storytime page.

--- src/tryclojure/views/home.clj
+++ src/tryclojure/views/home.clj
@@ -22,8 +22,8 @@
       (javascript-tag
        (str "mode = '" mode "';"))]]]))

-(defpage "/story" []
-  (repl-html "story" "Story time with Isla"))
+(defpage "/storytime" []
+  (repl-html "story" "Storytime"))

 (defpage "/code" []
   (repl-html "isla" "Try Isla"))


added explanation to mutate_prefs

added explanation to mutate_prefs


Fixes #229 - no timeout for expression evaluation or obtaining response

--- ccw.core/src/ccw/repl/view_helpers.clj
+++ ccw.core/src/ccw/repl/view_helpers.clj
@@ -76,11 +76,11 @@

 (defn eval-expression
   [repl-view log-component {:keys [send]} requests-atom expr]
-  (let [response-fn (send expr :ns (.getCurrentNamespace repl-view))
+  (let [response-fn (send expr :ns (.getCurrentNamespace repl-view) :timeout Long/MAX_VALUE)
         key [(System/currentTimeMillis) expr]]
     (swap! requests-atom assoc key response-fn)
     (future (try
-              (doseq [{:keys [out err value ns status] :as resp} (repl/response-seq response-fn)]
+              (doseq [{:keys [out err value ns status] :as resp} (repl/response-seq response-fn Long/MAX_VALUE)]
                 (ui-sync
                   (when ns
                     ; TODO: need to make sure that a response from an earlier request doesn't
@@ -92,7 +92,7 @@
                       (log log-component v k)
                       (CCWPlugin/log (str "Cannot handle REPL response: " k (pr-str resp)))))
                   (case status
-                    ("timeout" "interrupted") (log log-component (eval-failure-msg status out) :err)
+                    ("timeout" "interrupted") (log log-component (eval-failure-msg status expr) :err)
                     nil)))
               (catch Throwable t
                 (CCWPlugin/logError (eval-failure-msg nil expr) t)


Check capacity in bind inputs before putting segments on channel

--- resources/leiningen/new/onyx_app/utils.clj
+++ resources/leiningen/new/onyx_app/utils.clj
@@ -77,7 +77,12 @@

 (defn bind-inputs! [lifecycles mapping]
   (doseq [[task segments] mapping]
-    (let [in-ch (get-input-channel (channel-id-for lifecycles task))]
+    (let [in-ch (get-input-channel (channel-id-for lifecycles task))
+          n-segments (count segments)]
+      (when (< input-channel-capacity n-segments)
+        (throw (ex-info "Input channel capacity is smaller than bound inputs. Capacity can be adjusted in utils.clj"
+                        {:channel-size input-channel-capacity
+                         :n-segments n-segments})))
       (doseq [segment segments]
         (>!! in-ch segment))
       (>!! in-ch :done))))


Add French support to the desktop version

--- desktop/src/nightweb_desktop/utils.clj
+++ desktop/src/nightweb_desktop/utils.clj
@@ -29,6 +29,7 @@
 ; language

 (def lang-files {"en" "values/strings.xml"
+                 "fr" "values-fr/strings.xml"
                  "ja" "values-ja/strings.xml"})
 (def lang-strings (-> (get lang-files (.getLanguage (Locale/getDefault)))
                       (or (get lang-files "en"))


Fixes #167 - Auto-Indent Fails With Files Using CR-LF

--- ccw.core/src/ccw/editors/antlrbased/PareditAutoEditStrategy.clj
+++ ccw.core/src/ccw/editors/antlrbased/PareditAutoEditStrategy.clj
@@ -29,6 +29,7 @@
    "\"" [:paredit-doublequote true]
    "\t" [:paredit-indent-line true]
    "\n" [:paredit-newline true]
+   "\r\n" [:paredit-newline true]
    })

 (def *strict-commands*


Fix another lurking laziness bug

Fix another lurking laziness bug

--- src/edu/berkeley/ai/angelic/hybrid/solutions.clj
+++ src/edu/berkeley/ai/angelic/hybrid/solutions.clj
@@ -33,7 +33,7 @@
 			     (map->valuation ::hflv/HybridFixedLPValuation {(envs/get-initial-state env) 0})
 			     act-seq)
 	[cont-result num-var-map rew] (util/first-maximal-element #(nth % 2)
-				        (map #(cls/solve-lp-state %)
+				        (util/map-when #(cls/solve-lp-state %)
                                              (util/safe-get final-val :continuous-lp-states)))]
     (map #(hs/hybrid-strips-action->action (:schema  %)
 	    (into (util/safe-get % :var-map)


Fix lein-hyde dependencies

Fix lein-hyde dependencies

--- lein-hyde/project.clj
+++ lein-hyde/project.clj
@@ -3,6 +3,7 @@
   :url "https://github.com/paleltops/hyde-pallet"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[com.palletops/hyde-pallet "0.1.0-SNAPSHOT"]]
+  :dependencies [[com.palletops/hyde-pallet "0.1.0-SNAPSHOT"]
+                 [com.palletops/lein-docudata "0.1.1-SNAPSHOT"]]
   :plugins [[lein-modules "0.3.2"]]
   :eval-in-leiningen true)


Update perf test

Update perf test

--- test/clj/libx/perf_tuple.cljc
+++ test/clj/libx/perf_tuple.cljc
@@ -61,15 +61,6 @@
   =>
   (insert-unconditional! [?e :todo/done :tag]))

-(cr/defrule remove-older-unique-identity-facts
-  {:super true :salience 100}
-  [:unique-identity (= ?a1 (:a this)) (= ?t1 (:t this))]
-  [?fact2 <- :unique-identity (= ?a1 (:a this)) (= ?t2 (:t this))]
-  [:test (> ?t1 ?t2)]
-  =>
-  (trace (str "SCHEMA MAINT - :unique-identity" ?t1 " is greater than " ?t2))
-  (retract! ?fact2))
-
 (def-tuple-rule acc-all-visible
   {:group :report}
   [?count <- (acc/count) :from [:todo/title]]
@@ -88,6 +79,15 @@
   (doseq [action ?actions]
     (cr/retract! action)))

+(cr/defrule remove-older-one-to-one-facts
+  {:super true :salience 100}
+  ;[?fact1 <- :one-to-one (= ?e (:e this)) (= ?a1 (:a this)) (= ?t1 (:t this))]
+  [?fact2 <- :one-to-one (= ?e (:e this)) (= ?a1 (:a this)) (= ?t2 (:t this))]
+  ;[:test (and (not= ?fact1 ?fact2) #_(> (:t ?fact1) (:t ?fact2)))]
+  =>
+  (trace (str "SCHEMA MAINT - :one-to-one retracting") ?fact2)
+  (retract! ?fact2))
+
 (def groups [:action :calc :report :cleanup])
 (def activation-group-fn (util/make-activation-group-fn :calc))
 (def activation-group-sort-fn (util/make-activation-group-sort-fn groups :calc))
@@ -100,19 +100,17 @@
   :activation-group-fn activation-group-fn
   :activation-group-sort-fn activation-group-sort-fn)

-;(def tuple-session
-;  (cr/mk-session 'libx.perf-tuple
-;   :fact-type-fn :a
-;   :ancestors-fn ancestors-fn
-;   :activation-group-fn activation-group-fn
-;   :activation-group-sort-fn activation-group-sort-fn)
-
 (defn n-facts-session [n]
   (-> tuple-session
+    ;(l/replace-listener)
     (insert (repeatedly n #(vector (guid) :todo/title "foobar")))))

 (def session (atom (n-facts-session 10#_0000)))
-;(inspect/explain-activations @session)
+
+;(inspect/inspect @session)
+;(ns-unmap *ns* 'remove-older-one-to-one-facts)
+;; 246ms without, 5000ms with
+
 (defn perf-loop [iters]
   (time
     (dotimes [n iters]
@@ -122,10 +120,10 @@
             ;(l/replace-listener)
             (util/insert-action [(guid) :add-todo-action-2 {:todo/title "ho"}])
             (util/insert-action [(guid) :add-todo-action {:title "hey"}])
-            (insert [[(guid) :done-count 5]
-                     [(guid) :done-count 6]])
+            (insert [[1 :done-count 5]
+                     [1 :done-count 6]])
             (cr/fire-rules)))))))
-@state/rules
+
 (perf-loop 1#_00)

 (l/vec-ops @session)


Add tests for queries with max # of results

--- test/desdemona/query_test.clj
+++ test/desdemona/query_test.clj
@@ -1,7 +1,7 @@
 (ns desdemona.query-test
   (:require
    [desdemona.query :as q]
-   [clojure.test :refer [deftest is are]]))
+   [clojure.test :refer [deftest is are testing]]))

 (def dsl->logic
   @#'desdemona.query/dsl->logic)
@@ -19,7 +19,13 @@
     [[{:ip "10.0.0.1"}]]

     '(= (:ip x) "BOGUS")
-    []))
+    [])
+  (testing "explicit maximum number of results"
+    (are [n-results]
+        (= [[{:ip "10.0.0.1"}]]
+           (q/run-dsl-query n-results '(= (:ip x) "10.0.0.1") events))
+      1
+      10)))

 (deftest logic-query-tests
   (are [query results] (= results (q/run-logic-query query events))
@@ -27,4 +33,12 @@
     []

     '(l/featurec x {:ip "10.0.0.1"})
-    [[{:ip "10.0.0.1"}]]))
+    [[{:ip "10.0.0.1"}]])
+  (testing "explicit maximum number of results"
+    (are [n-results]
+        (= [[{:ip "10.0.0.1"}]]
+           (q/run-logic-query n-results
+                              '(l/featurec x {:ip "10.0.0.1"})
+                              events))
+      1
+      10)))