Update the specs for conforming queries to the latest query language

--- src/main/workflo/macros/specs/conforming_query.cljc
+++ src/main/workflo/macros/specs/conforming_query.cljc
@@ -5,108 +5,126 @@
             [workflo.macros.query.util :as util]
             [workflo.macros.specs.query]))

-;;;; Simple properties
-
-(s/def ::simple-property
-  (s/tuple #{:simple}
-           :workflo.macros.specs.query/property-name))
-
-;;;; Links
+(s/def ::simple
+  (s/tuple #{:simple} :workflo.macros.specs.query/property-name))

 (s/def ::link
-  (s/tuple #{:link}
-           :workflo.macros.specs.query/link))
+  (s/tuple #{:link} :workflo.macros.specs.query/link))

-;;;; Joins
+(s/def ::join-source
+  (s/or :simple ::simple
+        :link ::link))

-(s/def ::model-join
-  (s/tuple #{:model-join}
-           :workflo.macros.specs.query/model-join))
+(s/def ::join-properties-value
+  (s/with-gen
+    (s/map-of ::join-source ::query :count 1)
+    #(gen/map (s/gen ::join-source)
+              (gen/vector
+               (s/gen #{[:property [:simple 'a]]
+                        [:property [:simple 'b]]
+                        [:prefixed-properties
+                         {:base 'a
+                          :children [[:property [:simple 'b]]
+                                     [:property [:simple 'c]]]}]
+                        [:property [:link '[a _]]]})
+               1 10)
+              {:num-elements 1})))

-(s/def ::limited-recursion
-  (s/tuple #{:limited}
-           :workflo.macros.specs.query/limited-recursion))
+(s/def ::join-properties
+  (s/tuple #{:properties} ::join-properties-value))

-(s/def ::unlimited-recursion
-  (s/tuple #{:unlimited}
-           :workflo.macros.specs.query/unlimited-recursion))
+(s/def ::unlimited-join-recursion
+  (s/tuple #{:unlimited} #{'... ''...}))

-(s/def ::recursion
-  (s/or :limited ::limited-recursion
-        :unlimited ::unlimited-recursion))
+(s/def ::limited-join-recursion
+  (s/tuple #{:limited} (s/and int? pos?)))

-(s/def ::recursive-join-value
-  (s/map-of :workflo.macros.specs.query/join-property
-            ::recursion
+(s/def ::join-recursion-value
+  (s/map-of ::join-source
+            (s/or :unlimited ::unlimited-join-recursion
+                  :limited ::limited-join-recursion)
             :count 1))

-(s/def ::recursive-join
-  (s/tuple #{:recursive-join} ::recursive-join-value))
+(s/def ::join-recursion
+  (s/tuple #{:recursive} ::join-recursion-value))

-(s/def ::properties-join-value
-  (s/with-gen
-    (s/map-of :workflo.macros.specs.query/join-property
-              ::query
-              :count 1)
-    #(gen/map (s/gen :workflo.macros.specs.query/join-property)
-              (s/gen #{[[:regular-query [:property [:simple 'foo]]]]})
-              {:num-elements 1})))
+(s/def ::join-model-value
+  (s/map-of ::join-source
+            (s/tuple #{:model} :workflo.macros.specs.query/model-name)
+            :count 1))

-(s/def ::properties-join
-  (s/tuple #{:properties-join}
-           ::properties-join-value))
+(s/def ::join-model
+  (s/tuple #{:model} ::join-model-value))

 (s/def ::join
-  (s/tuple #{:join}
-           (s/or :model-join ::model-join
-                 :recursive-join ::recursive-join
-                 :properties-join ::properties-join)))
-
-;;;; Individual properties
+  (s/tuple #{:join} (s/or :properties ::join-properties
+                          :recursion ::join-recursion
+                          :model ::join-model)))

 (s/def ::property-value
-  (s/or :simple ::simple-property
-        :link   ::link
-        :join   ::join))
+  (s/or :simple ::simple
+        :link ::link
+        :join ::join))

 (s/def ::property
   (s/tuple #{:property} ::property-value))

-;;;; Nested properties
+(s/def :aliased-property-value/property
+  ::property-value)

-(s/def ::base
+(s/def :aliased-property-value/alias
   :workflo.macros.specs.query/property-name)

-(s/def ::children
-  (s/coll-of ::property-value :kind vector?
-             :min-count 1 :gen-max 10))
+(s/def :aliased-property-value/as
+  #{:as})

-(s/def ::nested-properties-value
-  (s/keys :req-un [::base ::children]))
+(s/def ::aliased-property-value
+  (s/keys :req-un [:aliased-property-value/property
+                   :aliased-property-value/alias]
+          :opt-un [:aliased-property-value/as]))

-(s/def ::nested-properties
-  (s/tuple #{:nested-properties} ::nested-properties-value))
+(s/def ::aliased-property
+  (s/tuple #{:aliased-property} ::aliased-property-value))

-;;;; Queries
+(s/def :prefixed-properties-value/base
+  :workflo.macros.specs.query/property-name)

-(s/def ::regular-query-value
+(s/def :prefixed-properties-value/children
+  (s/with-gen
+    ::query
+    #(gen/vector
+      (s/gen (s/or :property ::property
+                   :aliased-property ::aliased-property
+                   :parameterization ::parameterization))
+      1 10)))
+
+(s/def ::prefixed-properties-value
+  (s/keys :req-un [:prefixed-properties-value/base
+                   :prefixed-properties-value/children]))
+
+(s/def ::prefixed-properties
+  (s/tuple #{:prefixed-properties} ::prefixed-properties-value))
+
+(s/def :parameterization-value/query
   (s/or :property ::property
-        :nested-properties ::nested-properties))
+        :aliased-property ::aliased-property))

-(s/def ::regular-query
-  (s/tuple #{:regular-query} ::regular-query-value))
-
-(s/def ::parameters
+(s/def :parameterization-value/parameters
   :workflo.macros.specs.query/parameters)

-(s/def ::parameterized-query-value
-  (s/keys :req-un [::regular-query-value ::parameters]))
+(s/def ::parameterizatio-value
+  (s/keys :req-un [:parameterization-value/query
+                   :parameterization-value/parameters]))

-(s/def ::parameterized-query
-  (s/tuple #{:parameterized-query} ::parameterized-query-value))
+(s/def ::parameterization
+  (s/tuple #{:parameterization} ::parameterizatio-value))
+
+(s/def ::query-value
+  (s/or :property ::property
+        :aliased-property ::aliased-property
+        :prefixed-properties ::prefixed-properties
+        :parameterization ::parameterization))

 (s/def ::query
-  (s/coll-of (s/or :regular-query ::regular-query
-                   :parameterized-query ::parameterized-query)
-             :kind vector? :min-count 1
-             :gen-max 10))
+  (s/coll-of ::query-value :kind vector?
+             :min-count 1 :gen-max 10))


Fix insert tests to accomodate for changed formatting

--- test/clojure/clojurewerkz/cassaforte/query_test.clj
+++ test/clojure/clojurewerkz/cassaforte/query_test.clj
@@ -164,7 +164,7 @@
                           (unix-timestamp-of :created_at)
                           (limit 5))))

-  (is (renders-to "INSERT INTO events(created_at,message) VALUES (now(),'Message 1');"
+  (is (renders-to "INSERT INTO events (created_at,message) VALUES (now(),'Message 1');"
                   (insert :events
                           {:created_at (now)
                            :message    "Message 1"})))
@@ -219,19 +219,19 @@
                        (limit 42)))))

 (deftest test-insert-query
-  (is (renders-to "INSERT INTO foo(asd) VALUES ('bsd');"
+  (is (renders-to "INSERT INTO foo (asd) VALUES ('bsd');"
                   (insert :foo
                           {"asd" "bsd"})))
-  (is (renders-to "INSERT INTO foo(asd) VALUES ('bsd');"
+  (is (renders-to "INSERT INTO foo (asd) VALUES ('bsd');"
                   (insert :foo
                           {"asd" "bsd"})))

-  (is (renders-to "INSERT INTO foo(asd) VALUES ('bsd');"
+  (is (renders-to "INSERT INTO foo (asd) VALUES ('bsd');"
                   (insert :foo
                           {"asd" "bsd"})))

-  (is (renders-to "INSERT INTO foo(a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;"
+  (is (renders-to "INSERT INTO foo (a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;"
                   (insert :foo
                           (array-map "a"          123
                                      "b"          (java.net.InetAddress/getByName "127.0.0.1")
@@ -240,7 +240,7 @@
                           (using (array-map :timestamp 42
                                             :ttl       24)))))

-  (is (renders-to "INSERT INTO foo(a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;"
+  (is (renders-to "INSERT INTO foo (a,b,\"C\",d) VALUES (123,'127.0.0.1','foo''bar',{'x':3,'y':2}) USING TIMESTAMP 42 AND TTL 24;"
                   (insert :foo
                           (array-map "a"          123
                                      "b"          (java.net.InetAddress/getByName "127.0.0.1")
@@ -249,35 +249,35 @@
                           (using (array-map :timestamp 42
                                             :ttl       24)))))

-  (is (renders-to "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4) USING TIMESTAMP 42 AND TTL 24;"
+  (is (renders-to "INSERT INTO foo (a,b) VALUES ({2,3,4},3.4) USING TIMESTAMP 42 AND TTL 24;"
                   (insert :foo
                           (array-map "a" (sorted-set 2 3 4)
                                      "b" 3.4)
                           (using (array-map :timestamp 42
                                             :ttl       24)))))

-  (is (renders-to "INSERT INTO foo(a,b) VALUES ({2,3,4},3.4) USING TTL ? AND TIMESTAMP ?;"
+  (is (renders-to "INSERT INTO foo (a,b) VALUES ({2,3,4},3.4) USING TTL ? AND TIMESTAMP ?;"
                   (insert :foo
                           (array-map :a (sorted-set 2 3 4)
                                      :b 3.4)
                           (using (array-map :ttl       ?
                                             :timestamp ?)))))

-  (is (renders-to "INSERT INTO foo(c,a,b) VALUES (123,{2,3,4},3.4) USING TIMESTAMP 42;"
+  (is (renders-to "INSERT INTO foo (c,a,b) VALUES (123,{2,3,4},3.4) USING TIMESTAMP 42;"
                   (insert :foo
                           (array-map :c 123
                                      :a (sorted-set 2 3 4)
                                      :b 3.4)
                           (using {:timestamp 42}))))

-  (is (renders-to "INSERT INTO foo(k,x) VALUES (0,1) IF NOT EXISTS;";
+  (is (renders-to "INSERT INTO foo (k,x) VALUES (0,1) IF NOT EXISTS;";
                   (insert :foo
                           (array-map :k 0
                                      :x 1)
                           (if-not-exists))))

-  (is (renders-to "INSERT INTO foo(k,x) VALUES (0,(1));";
+  (is (renders-to "INSERT INTO foo (k,x) VALUES (0,(1));";
                   (insert :foo
                           (array-map :k 0
                                      :x (tuple-of [:int] [(int 1)]))))))
@@ -415,9 +415,9 @@
                   (truncate :a :b))))

 (deftest test-batch
-  (is (renders-to (str "BEGIN BATCH INSERT INTO foo(asd) VALUES ('bsd');"
-                       "INSERT INTO foo(asd) VALUES ('bsd');"
-                       "INSERT INTO foo(asd) VALUES ('bsd');"
+  (is (renders-to (str "BEGIN BATCH INSERT INTO foo (asd) VALUES ('bsd');"
+                       "INSERT INTO foo (asd) VALUES ('bsd');"
+                       "INSERT INTO foo (asd) VALUES ('bsd');"
                        "APPLY BATCH;")
                   (batch
                    (queries


Fix the key to the `=` table.

Fix the key to the `=` table.

--- test/clojure_the_language/clojure_numerics_test.clj
+++ test/clojure_the_language/clojure_numerics_test.clj
@@ -157,9 +157,9 @@
 ;;;
 ;;;   Key to the table entries:
 ;;;
-;;;         =   (= x y) is true
-;;;         .   (= x y) is false
-;;;             where x is the row value and x is the column value
+;;;         =   means   (= x y) is true
+;;;         .   means   (= x y) is false
+;;;             where x is the row value and y is the column value
 ;;;
 ;;;             ----------------------------------
 ;;;        =    |   2  2N   |  2M 2.0M  |  2.0   |


Add loading spinners

Add loading spinners

--- src-cljs/frontend/components/pages/projects.cljs
+++ src-cljs/frontend/components/pages/projects.cljs
@@ -1,5 +1,6 @@
 (ns frontend.components.pages.projects
   (:require [frontend.api :as api]
+            [frontend.components.common :as common]
             [frontend.components.pieces.org-picker :as org-picker]
             [frontend.routes :as routes]
             [frontend.utils.vcs-url :as vcs-url]
@@ -64,18 +65,31 @@
          [:div {:data-component `page}
           [:.sidebar
            [:.card
-            (om/build org-picker/picker
-                      {:orgs (:organizations user)
-                       :selected-org (first (filter #(= selected-org-ident (organization-ident %)) (:organizations user)))
-                       :on-org-click #(om/set-state! owner :selected-org-ident (organization-ident %))})]]
+            (if (:organizations user)
+              (om/build org-picker/picker
+                        {:orgs (:organizations user)
+                         :selected-org (first (filter #(= selected-org-ident (organization-ident %)) (:organizations user)))
+                         :on-org-click #(om/set-state! owner :selected-org-ident (organization-ident %))})
+              [:div.loading-spinner common/spinner])]]
           [:.main
-           (when selected-org
+           ;; TODO: Pulling these out of the ident is a bit of a hack. Instead,
+           ;; we should pull them out of the selected-org itself. We can do that
+           ;; once the selected-org and the orgs in org list are backed by the
+           ;; same normalized data.
+           ;;
+           ;; Once they are, we'll have a value for selected-org here, but it
+           ;; will only have the keys the org list uses (which includes the
+           ;; vcs-type and the name). The list of projects will still be missing
+           ;; until it's loaded by an additional API call.
+           (when-let [[_ [vcs-type name]] selected-org-ident]
              [:.card
               [:.header
                [:.title
-                (:name selected-org)
-                (case (:vcs_type selected-org)
+                name
+                (case vcs-type
                   "github" [:i.octicon.octicon-mark-github]
                   "bitbucket" [:i.fa.fa-bitbucket]
                   nil)]]
-              (om/build table (:projects selected-org))])]])))))
+              (if (:projects selected-org)
+                (om/build table (:projects selected-org))
+                [:div.loading-spinner common/spinner])])]])))))


Add watch

Add watch

--- src/aurora/language.cljs
+++ src/aurora/language.cljs
@@ -98,9 +98,7 @@
                 (.clear-facts kn name)
                 (when (true? (.update-facts kn name))
                   (set!! changed? true)))))
-          changed?))
-  (quiesce [this name->transient?]
-           (while (true? (.tick this name->transient?)))))
+          changed?)))

 (defn knowledge []
   (Knowledge. {}))
@@ -137,10 +135,13 @@
                  (.run (aget rule->flow rule) kn rule->dirty? kind->name->rules)
                  (recur 0))
                (recur (+ i 1)))))))
-  (tick [this kn]
+  (tick [this kn watch]
+        (.run this kn)
+        (when watch
+          (watch kn))
         (.tick kn name->transient?))
-  (quiesce [this kn]
-           (.quiesce kn name->transient?)))
+  (quiesce [this kn watch]
+           (while (true? (.tick this kn watch)))))

 ;; COMPILER

@@ -346,15 +347,14 @@

 (enable-console-print!)

-(.run flows kn)
-
 (.get-or-create-index kn "know" "connected" #js ["x" "y"])

 (.get-or-create-index kn "remember" "str-edge" #js ["name"])

 (.get-or-create-index kn "forget" "str-edge" #js ["name"])

-(.quiesce flows kn)
+(prn :running)
+(.quiesce flows kn (fn [kn] (prn :ticked kn)))

 (.get-or-create-index kn "know" "edge" #js ["x" "y"])


Style changes to api.cljs. These are mostly cosmetic.

--- src/chessground/api.cljs
+++ src/chessground/api.cljs
@@ -9,17 +9,18 @@
   (clj->js
     (letfn [(push-in [ch val] (push! (get channels ch) val))]
       {"toggleOrientation" (fn [] (push-in :toggle-orientation true))
-       "setOrientation" (fn [orientation] (push-in :set-orientation orientation))
-       "setFen" (fn [fen] (push-in :set-fen fen))
-       "startPos" (fn [] (push-in :set-fen "start"))
-       "setDests" (fn [dests] (push-in :set-dests (js->clj dests)))
-       "setColor" (fn [color] (push-in :set-color color))
-       "setPieces" (fn [pieces] (push-in :set-pieces
-                                         (into {} (for [[k v] (js->clj pieces)]
-                                                    [k (common/keywordize-keys v)]))))
-       "move" (fn [orig dest] (push-in :api-move [orig dest]))
-       "showMoved" (fn [orig dest] (push-in :show-moved [orig dest]))
-       "clear" (fn [] (push-in :clear true))
-       "getOrientation" (fn [] (:orientation @state-atom))
-       "getColor" (fn [] (:color (:movable @state-atom)))
-       "getPosition" (fn [] (clj->js (chess/get-pieces (:chess @state-atom))))})))
+       "setOrientation"    (fn [orientation] (push-in :set-orientation orientation))
+       "setFen"            (fn [fen] (push-in :set-fen fen))
+       "startPos"          (fn [] (push-in :set-fen "start"))
+       "setDests"          (fn [dests] (push-in :set-dests (js->clj dests)))
+       "setColor"          (fn [color] (push-in :set-color color))
+       "setPieces"         (fn [pieces]
+                             (push-in :set-pieces
+                               (into {} (for [[k v] (js->clj pieces)]
+                                          [k (common/keywordize-keys v)]))))
+       "move"              (fn [orig dest] (push-in :api-move [orig dest]))
+       "showMoved"         (fn [orig dest] (push-in :show-moved [orig dest]))
+       "clear"             (fn [] (push-in :clear true))
+       "getOrientation"    (fn [] (:orientation @state-atom))
+       "getColor"          (fn [] (:color (:movable @state-atom)))
+       "getPosition"       (fn [] (clj->js (chess/get-pieces (:chess @state-atom))))})))


fix dissoc-in reference

fix dissoc-in reference

--- src/clj/fleetdb/core.clj
+++ src/clj/fleetdb/core.clj
@@ -604,7 +604,7 @@
 (defmethod query* "drop-index" [db [_ coll ispec]]
   (if-not (get-in db [coll :imap ispec])
     [db 0]
-    [(core/dissoc-in db [coll :imap ispec]) 1]))
+    [(dissoc-in db [coll :imap ispec]) 1]))

 (defmethod query* "list-indexes" [db [_ coll]]
   (or (keys (get-in db [coll :imap])) (list)))


Sort next job ascending

Sort next job ascending

--- src/clj/inky/compile.clj
+++ src/clj/inky/compile.clj
@@ -59,7 +59,7 @@
               :compile-jobs
               {:succeeded nil :started nil}
               {:$set {:started (util/now)}}
-              :sort {:created -1}
+              :sort {:created 1}
               :return-new? true)]
     job))


[style] better use of spacing

[style] better use of spacing

--- src/clj_dstream/core.clj
+++ src/clj_dstream/core.clj
@@ -181,19 +181,13 @@
 (defn are-neighbors [position-indices-1 position-indices-2]
   (if (= position-indices-1 position-indices-2)
     true
-    (let [zipped-truthiness (map (fn [[e1 e2]] (= e1 e2)) (map vector position-indices-1 position-indices-2))]
-      (and
-        (= 1 (count (remove true? zipped-truthiness)))
-        (let [index-of-false (.indexOf
-                               (->> (map vector position-indices-1 position-indices-2)
-                                    (map (fn [[a b]] (= a b))))
-                               false)]
-          (and
-            (not (= -1 index-of-false))
-            (= 1
-               (Math/abs
-                 (- (get position-indices-1 index-of-false)
-                    (get position-indices-2 index-of-false))))))))))
+    (let [zipped-truthiness (->> (map vector position-indices-1 position-indices-2)
+                                 (map (fn [[a b]] (= a b))))]
+      (and (= 1 (count (remove true? zipped-truthiness)))
+           (let [index-of-false (.indexOf zipped-truthiness false)]
+             (and (not (= -1 index-of-false))
+                  (= 1 (Math/abs (- (get position-indices-1 index-of-false)
+                                    (get position-indices-2 index-of-false))))))))))

 (s/fdef are-neighbors
         :args (s/cat :u (s/cat :indices-1 ::position-index :indices-2 ::position-index))


Use nil to represent empty squares in board data structure, allows nicer conditionals. Also adds ids to squares

--- src/cljs/chess/core.cljs
+++ src/cljs/chess/core.cljs
@@ -1,19 +1,24 @@
 (ns chess.core
   (:require [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
-            [clojure.string :refer [upper-case]]))
+            [clojure.string :refer [upper-case]]
+            [clojure.set :refer [map-invert]]))
+
+(def empty-sq nil)
+
+(def empty-rank (vec (replicate 8 empty-sq)))

 (def initial-board
   [[:r :n :b :q :k :b :n :r]
    [:p :p :p :p :p :p :p :p]
-   [:. :. :. :. :. :. :. :.]
-   [:. :. :. :. :. :. :. :.]
-   [:. :. :. :. :. :. :. :.]
-   [:. :. :. :. :. :. :. :.]
+   empty-rank
+   empty-rank
+   empty-rank
+   empty-rank
    [:P :P :P :P :P :P :P :P]
    [:R :N :B :Q :K :B :N :R]])

-(def empty-sq :.)
+

 (def pieces {:r "rook" :R "rook"
              :n "knight" :N "knight"
@@ -22,13 +27,14 @@
              :k "king" :K "king"
              :p "pawn" :P "pawn"})

-(def file->i
-  "Convert a letter file to an integer index (eg \"a\" -> 0)"
-  (let [m (into {}
-                (map-indexed
-                 (fn [i c] [c i])
-                 (seq "abcdefgh")))]
-    (fn [f] (get m (char f)))))
+(let [f-to-i (into {}
+              (map-indexed
+               (fn [i c] [c i])
+               (seq "abcdefgh")))
+      i-to-f (map-invert f-to-i)]
+  (do
+    (defn file->i [f] (get f-to-i (char f)))
+    (defn i->file [i] (get i-to-f i))))

 (defn parse-int
   [i]
@@ -41,13 +47,10 @@
   (let [[f r] (vec p)]
     [(- 8 (parse-int r)) (file->i f)]))

-(declare valid-piece?)
-
 (defn in
   "Get the contents of a square on the board. Nil if empty"
   [board sq]
-  (let [p (get-in board (to-board-ks sq))]
-    (if (valid-piece? p) p)))
+  (get-in board (to-board-ks sq)))

 (defn put
   "Puts a piece at a square in the board"
@@ -88,10 +91,10 @@
         om/IRender
         (render [_]
           (apply dom/div #js {:className "board"}
-                   (map
-                    (fn [r] (apply dom/div #js {:className "row"}
-                                   (map (fn [s] (dom/div #js {:className "square"}
-                                                         (if (valid-piece? s)
+                   (map-indexed
+                    (fn [i r] (apply dom/div #js {:className "row" :id (- 8 i)}
+                                   (map-indexed (fn [j s] (dom/div #js {:className "square" :id (str (i->file j) (- 8 i))}
+                                                         (if s
                                                            (dom/div #js {:className (str "piece " (colour s) " " (pieces s))} nil)))) r)))
                     (:board app))))))
     app-state


Refactoring

Refactoring

--- src/cljs/darts/core.cljs
+++ src/cljs/darts/core.cljs
@@ -17,19 +17,15 @@
 (defn redirect-to [path]
   (set! js/window.location.href path))

-(defonce players (atom nil))
-
-(defn parse-json [json]
-  (walk/keywordize-keys (t/read (t/reader :json) @players)))
+(def players (atom nil))

 (defn load-players []
-  (GET "/list-players" {:handler (fn [res]
-                                   (reset! players res))}))
-
-(defn list-players []
-  (load-players)
-  [:ul
-   (map (fn [player] ^{:key player} [:li (:name player)]) (parse-json @players))])
+  (GET "/list-players"
+       {:handler (fn [res]
+                   (->> res
+                        (t/read (t/reader :json))
+                        (walk/keywordize-keys)
+                        (reset! players)))}))

 (def player1 (atom ""))
 (def player2 (atom ""))
@@ -51,9 +47,6 @@
                             :rounds [23 68 7 13]}
                          :starting-score 310}))

-(defn remaining-points [{:keys [rounds]} starting-score]
-  (- starting-score (reduce + 0 rounds)))
-
 (def message (atom ""))

 (def game example-game)
@@ -66,7 +59,8 @@
        (<= score points)))

 (defn points [player]
-  (remaining-points (get @game player) (:starting-score @game)))
+  (- (:starting-score @game)
+     (reduce + 0 (:rounds (get @game player)))) )

 (defn record-score [player new-score]
   (swap! game #(update-in %1 [%2 :rounds] conj (js/parseInt %3))
@@ -108,9 +102,9 @@
   [:div
    @message
    [:div
-    [:span "Player 1: " (remaining-points (get @game 0) (:starting-score @game))]
+    [:span "Player 1: " (points 0)]
     [:br]
-    [:span "Player 2: " (remaining-points (get @game 1) (:starting-score @game))]]
+    [:span "Player 2: " (points 1)]]
    [:div
     [:br ]
     (str "Player " (+ 1 @current-player) " turn")
@@ -152,7 +146,7 @@
         (concat [^{:key "1-nil"}[:option ""]]
                 (map (fn [{:keys [name]}]
                        ^{:key name}[:option name])
-                     (parse-json @players))))]]
+                     @players)))]]
      [:li (str "Player 2: ")
       [:select {:id "player2"
                 :value @player2
@@ -162,7 +156,7 @@
                 (map (fn [{:keys [name]}]
                        (when (not= @player1 name)
                          ^{:key name}[:option name]))
-                     (parse-json @players))))]]]
+                     @players)))]]]
     [select-game-pane]]
    (when (both-players-selected?)
      [:div


Prevent Warnings From Double Click Dissoc keys from Parent

--- src/cljs/lens/terms.cljs
+++ src/cljs/lens/terms.cljs
@@ -58,7 +58,7 @@
                                           (when (:active term) "active")))
           :href "#"
           :on-click (h (put! activate (:id @term)))
-          :on-double-click #(when (:childs @term) (put! open @term))}
+          :on-double-click (h (when (:childs @term) (put! open @term)))}
       (om/build comp/count-badge term)
       (primary-label term)
       (cond
@@ -234,7 +234,9 @@
   (first (filter :active (-> terms :list :terms))))

 (defn clean-term [term]
-  (dissoc term :childs :search-childs :active :embedded :forms :links))
+  (let [ks [:childs :search-childs :active :embedded :forms :links]]
+    (-> (apply dissoc term ks)
+        (update-in [:parent] #(apply dissoc % ks)))))

 (defcomponent terms
   "The terms component consists of a return stack, a search field and a terms


remove unused samples

remove unused samples

--- src/codemash/samples.clj
+++ src/codemash/samples.clj
@@ -1,32 +0,0 @@
-(ns codemash.samples
-  "Samples lurk here:
-   https://github.com/stars-my-destination/samples"
-  (:use overtone.live))
-
-(def p5-sample-root "~/Workspace/music/samples/P5mlr/")
-;;Samples by devism http://monome.org/community/discussion/736/x&page=1#Item_22
-(defonce chords-s  (load-sample (str p5-sample-root "CHORDs.wav")))
-(defonce voice-1-s (load-sample (str p5-sample-root "VOICE.wav")))
-(defonce voice-2-s (load-sample (str p5-sample-root "VOICE2.wav")))
-(defonce strings-s (load-sample (str p5-sample-root "STRINGS.wav")))
-(defonce drums-s   (load-sample (str p5-sample-root "DRUMS.wav")))
-(defonce dub-s     (load-sample (str p5-sample-root  "DUB.wav")))
-(defonce string-s  (load-sample (str p5-sample-root "STRINGS.wav")))
-(defonce bass-1-s  (load-sample (str p5-sample-root "BASS1.WAV")))
-(defonce bass-2-s  (load-sample (str p5-sample-root "BASS2.WAV")))
-(defonce bass-3-s  (load-sample (str p5-sample-root "BASS3.WAV")))
-(defonce hard-1-s  (load-sample (str p5-sample-root "HARD1.WAV")))
-(defonce hard-2-s  (load-sample (str p5-sample-root "HARD2.WAV")))
-(defonce hard-3-s  (load-sample (str p5-sample-root "HARDDUB.WAV")))
-(defonce gtr-1-s   (load-sample (str p5-sample-root "GTR1.WAV")))
-(defonce gtr-2-s   (load-sample (str p5-sample-root "GTR2.WAV")))
-(defonce gtr-3-s   (load-sample (str p5-sample-root "GTR3.WAV")))
-(defonce gtr-str-s (load-sample (str p5-sample-root "GTrSTr.wav")))
-
-
-(defonce d-kick-s         (load-sample "~/Workspace/music/samples/sliced-p5/kick.aif"))
-(defonce d-shake-s        (load-sample "~/Workspace/music/samples/sliced-p5/shaker.aif"))
-(defonce d-tom-s          (load-sample "~/Workspace/music/samples/sliced-p5/tom.aif"))
-(defonce d-shake-2-s      (load-sample "~/Workspace/music/samples/sliced-p5/double-shake.aif"))
-(defonce d-shake-1-s      (load-sample "~/Workspace/music/samples/sliced-p5/single-shake.aif"))
-(defonce d-shake-2-deep-s (load-sample "~/Workspace/music/samples/sliced-p5/double-shake-deep.aif"))


Implement checkboxes for query terms

Implement checkboxes for query terms

--- src/cljs/cglossa/search_inputs/cwb/extended.cljs
+++ src/cljs/cglossa/search_inputs/cwb/extended.cljs
@@ -100,8 +100,8 @@
                        form*  (if (empty? form)
                                 ".*"
                                 (cond-> form
-                                        start? (str form ".+")
-                                        end? (str ".+" form)))
+                                        start? (str ".+")
+                                        end? (#(str ".+" %))))
                        main   (str "(" attr "=\"" form* "\" %c)")
                        feats  (for [[name value] features]
                                 (str name "=\"" value "\""))
@@ -176,26 +176,26 @@
           [:label.checkbox-inline
            [:input {:type    "checkbox"
                     :checked (:lemma? term-val)
-                    ;:on-change #(on-lemma?-changed)
+                    :on-change #(swap! wrapped-term assoc :lemma? (.-target.checked %))
                     }] "Lemma"]
           [:label.checkbox-inline
            [:input {:type    "checkbox"
                     :title   "Start of word"
                     :checked (:start? term-val)
-                    ;:on-change #(on-start?-changed)
+                    :on-change #(swap! wrapped-term assoc :start? (.-target.checked %))
                     }] "Start"]
           [:label.checkbox-inline
            [:input {:type    "checkbox"
                     :title   "End of word"
                     :checked (:end? term-val)
-                    ;:on-change #(on-end?-changed)
+                    :on-change #(swap! wrapped-term assoc :end? (.-target.checked %))
                     }] "End"]]
          (when has-phonetic?
            [:div
             [:label.checkbox-inline
              [:input {:type    "checkbox"
                       :checked (:phonetic? term-val)
-                      ;:on-change #(on-phonetic?-changed)
+                      :on-change #(swap! wrapped-term assoc :phonetic? (.-target.checked %))
                       }] "Phonetic form"]])]]
        [:div.table-row
         (when first?


fixes exception in "lein test": Exception in thread "main" java.lang.RuntimeException: No such namespace: DCAwareRoundRobinPolicy, compiling:(clojurewerkz/cassaforte/policies.clj:38:7)

--- src/clojure/clojurewerkz/cassaforte/policies.clj
+++ src/clojure/clojurewerkz/cassaforte/policies.clj
@@ -16,7 +16,7 @@
   "Consistency levels, retry policies, reconnection policies, etc"
   (:import [com.datastax.driver.core ConsistencyLevel]
            [com.datastax.driver.core.policies
-            LoadBalancingPolicy DCAwareRoundRobinPolicy$Builder RoundRobinPolicy TokenAwarePolicy
+            LoadBalancingPolicy DCAwareRoundRobinPolicy DCAwareRoundRobinPolicy$Builder RoundRobinPolicy TokenAwarePolicy
             LoggingRetryPolicy DefaultRetryPolicy DowngradingConsistencyRetryPolicy FallthroughRetryPolicy
             RetryPolicy ConstantReconnectionPolicy ExponentialReconnectionPolicy]))


Remove try+catch in render-scene

Remove try+catch in render-scene

--- src-cljs/pong/core.cljs
+++ src-cljs/pong/core.cljs
@@ -156,11 +156,8 @@
   "Loop over the entities calling each ones draw fn."
   [ctx world-state]
   (doseq [ent (:entities world-state)]
-    (let [{:keys [value draw]} ent]
-      (try
-        (draw ctx value)
-        (catch js/Error e
-          (println e))))))
+    (when-let [{:keys [value draw]} ent]
+      (draw ctx value))))

 (defn ^:export init
   "The main entry point for the game. The big-bang process is launched from here."


Updated crypto libraries in core

Updated crypto libraries in core

--- ring-core/project.clj
+++ ring-core/project.clj
@@ -9,8 +9,8 @@
                  [commons-io "2.4"]
                  [commons-fileupload "1.3"]
                  [clj-time "0.6.0"]
-                 [crypto-random "1.1.0"]
-                 [crypto-equality "0.1.0"]]
+                 [crypto-random "1.2.0"]
+                 [crypto-equality "1.0.0"]]
   :profiles
   {:provided {:dependencies [[javax.servlet/servlet-api "2.5"]]}
    :dev {:dependencies [[javax.servlet/servlet-api "2.5"]]}


middleware should wrap the routes. re-indent api.

--- src/ebot_api/handler.clj
+++ src/ebot_api/handler.clj
@@ -71,35 +71,33 @@

 (defapi app
-        (middlewares [(wrap-cors :access-control-allow-origin #".*"
-                                 :access-control-allow-methods [:get]
-                                 :access-control-allow-headers ["Origin" "X-Requested-With"
-                                                                "Content-Type" "Accept"])])
-        (swagger-ui)
-        (swagger-docs
-          {:info {:title       "Ebot-api"
-                  :description "eBot api"}
-           :tags [{:name "api", :description "EBOT rest api"}]})
-        (context* "/api" []
-                  :tags ["api"]
-                  (GET* "/matches" []
-                        :summary "Get all matches"
-                        (ok (get-all-matchs)))
-                  (GET* "/match/:id" []
-                        :summary "Get match with id"
-                        :path-params [id :- Long]
-                        (ok (get-matchs id)))
-                  (GET* "/rounds/:matchid" []
-                        :summary "Get rounds with match id"
-                        :path-params [matchid :- Long]
-                        (ok (get-rounds matchid)))
-                  (GET* "/round/:id" []
-                        :summary "Get round with id"
-                        :path-params [id :- Long]
-                        (ok (get-round id)))
-                  (GET* "/team/:id" []
-                        :summary "Get team with id"
-                        :path-params [id :- Long]
-                        (ok (get-team id)))
-
-                  ))
+  (middlewares [(wrap-cors :access-control-allow-origin #".*"
+                           :access-control-allow-methods [:get]
+                           :access-control-allow-headers ["Origin" "X-Requested-With"
+                                                          "Content-Type" "Accept"])]
+    (swagger-ui)
+    (swagger-docs
+      {:info {:title       "Ebot-api"
+              :description "eBot api"}
+       :tags [{:name "api", :description "EBOT rest api"}]})
+    (context* "/api" []
+      :tags ["api"]
+      (GET* "/matches" []
+        :summary "Get all matches"
+        (ok (get-all-matchs)))
+      (GET* "/match/:id" []
+        :summary "Get match with id"
+        :path-params [id :- Long]
+        (ok (get-matchs id)))
+      (GET* "/rounds/:matchid" []
+        :summary "Get rounds with match id"
+        :path-params [matchid :- Long]
+        (ok (get-rounds matchid)))
+      (GET* "/round/:id" []
+        :summary "Get round with id"
+        :path-params [id :- Long]
+        (ok (get-round id)))
+      (GET* "/team/:id" []
+        :summary "Get team with id"
+        :path-params [id :- Long]
+        (ok (get-team id))))))


Unified "on-event" arguments.

Unified "on-event" arguments.

--- src/fm/simrunner/app.clj
+++ src/fm/simrunner/app.clj
@@ -24,8 +24,8 @@
 (defmethod on-event :action-performed [app _ & [widget :as args]]
   (act/dispatch (-> widget meta :action) app args))

-(defmethod on-event :input-changed [app _ & args]
-  (inp/dispatch (-> args first meta :id) app args))
+(defmethod on-event :input-changed [app _ & [widget :as args]]
+  (inp/dispatch (-> widget meta :id) app args))

 (defn- app [config]
   {:config config


Added jetty restart on OOM, will only work when blocking (ie from -main, not when run inline).

--- src/foreclojure/core.clj
+++ src/foreclojure/core.clj
@@ -3,6 +3,7 @@
             [compojure.handler          :as   handler]
             [foreclojure.config         :as   config]
             [sandbar.stateful-session   :as   session])
+  (:import  [java.lang                  OutOfMemoryError])
   (:use     [compojure.core             :only [defroutes routes GET]]
             [foreclojure.static         :only [static-routes welcome-page]]
             [foreclojure.api            :only [api-routes]]
@@ -97,10 +98,15 @@

 (let [default-jetty-port 8080]
   (defn run []
-    (prepare-mongo)
-    (register-heartbeat)
-    (run-jetty (var app) {:join? *block-server*
-                          :port (get config :jetty-port default-jetty-port)})))
+    (try
+      (do
+        (prepare-mongo)
+        (register-heartbeat)
+        (run-jetty (var app) {:join? *block-server*
+                              :port  (get config :jetty-port default-jetty-port)}))
+      (catch OutOfMemoryError e
+        ;;TODO: log this?
+        (run)))))

 (defn -main [& args]
   (binding [*block-server* true]


add iwatchable skel

add iwatchable skel

--- src/hodgepodge/core.cljs
+++ src/hodgepodge/core.cljs
@@ -39,6 +39,17 @@
        (if-let [i (.getItem s (serialize key))]
          (deserialize i)
          not-found)))
+
+  IWatchable
+  (-notify-watches [this oldval newval]
+    ; TODO
+    )
+  (-add-watch [this key f]
+    ; TODO
+    )
+  (-remove-watch [this key]
+    ; TODO
+    )
 )

  (comment


Fix query test so records are inserted inside test transactions.

--- clj_record/test/query_test.clj
+++ clj_record/test/query_test.clj
@@ -8,58 +8,59 @@
         clj-record.test.test-helper))

-(def manufacturers [(manufacturer/create (valid-manufacturer-with {:name "Sozooke Motors" :grade 90}))
-		    (manufacturer/create (valid-manufacturer-with {:name "Foyoto Auto" :grade 78}))
-		    (manufacturer/create (valid-manufacturer-with {:name "GMB Motors" :grade 89}))
-		    (manufacturer/create (valid-manufacturer-with {:name "Ghysler Inc" :grade 60}))
-		    (manufacturer/create (valid-manufacturer-with {:name "Merledas Automotive" :grade 39}))])
+(defn manufacturers []
+  [ (manufacturer/create (valid-manufacturer-with {:name "Sozooke Motors" :grade 90}))
+    (manufacturer/create (valid-manufacturer-with {:name "Foyoto Auto" :grade 78}))
+    (manufacturer/create (valid-manufacturer-with {:name "GMB Motors" :grade 89}))
+    (manufacturer/create (valid-manufacturer-with {:name "Ghysler Inc" :grade 60}))
+    (manufacturer/create (valid-manufacturer-with {:name "Merledas Automotive" :grade 39}))])

 (defdbtest find-records-using-equal
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke} (set (manufacturer/find-records {:grade (query/equal 90)}))))))

 (defdbtest find-records-using-not-equal
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke foyoto ghysler merledas} (set (manufacturer/find-records {:name (query/not-equal "GMB Motors")}))))))

 (defdbtest find-records-using-greater-than
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke gmb} (set (manufacturer/find-records {:grade (query/greater-than 80)}))))))

 (defdbtest find-records-using-greater-than-or-equal
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke foyoto gmb ghysler} (set (manufacturer/find-records {:grade (query/greater-than-or-equal 60)}))))))

 (defdbtest find-records-using-less-than
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{foyoto ghysler merledas} (set (manufacturer/find-records {:grade (query/less-than 80)}))))))

 (defdbtest find-records-using-less-than-or-equal
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{ghysler merledas} (set (manufacturer/find-records {:grade (query/less-than-or-equal 60)}))))))

 (defdbtest find-records-using-like
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{gmb ghysler} (set (manufacturer/find-records {:name (query/like "G%")}))))))

 (defdbtest find-records-using-not-like
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{foyoto ghysler merledas} (set (manufacturer/find-records {:name (query/not-like "%Motors")}))))))

 (defdbtest find-records-using-between
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{foyoto ghysler} (set (manufacturer/find-records {:grade (query/between 40 80)}))))))

 (defdbtest find-records-using-not-between
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke gmb merledas} (set (manufacturer/find-records {:grade (query/not-between 40 80)}))))))

 (defdbtest find-records-using-in
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{gmb merledas} (set (manufacturer/find-records {:name (query/in "GMB Motors" "Merledas Automotive")}))))))

 (defdbtest find-records-using-not-in
-  (let [[sozooke foyoto gmb ghysler merledas] manufacturers]
+  (let [[sozooke foyoto gmb ghysler merledas] (manufacturers)]
     (is (= #{sozooke foyoto ghysler} (set (manufacturer/find-records {:name (query/not-in "GMB Motors" "Merledas Automotive")}))))))

 (deftest attempt-to-supply-nil-value


Make the message match the ctx key

Make the message match the ctx key

--- src/vip/data_processor/validation/transforms.clj
+++ src/vip/data_processor/validation/transforms.clj
@@ -9,7 +9,7 @@

 (defn read-edn-sqs-message [ctx]
   (let [message (edn/read-string (get-in ctx [:input :body]))]
-    (assoc ctx :input message :skip-validations? (get message :skip-validations false))))
+    (assoc ctx :input message :skip-validations? (get message :skip-validations? false))))

 (defn assert-filename [ctx]
   (if-let [filename (get-in ctx [:input :filename])]


Switch diff algirithm from Myers to Histogram. Speed up diff calculation by 3x times

--- src-clj/acha/git_parser.clj
+++ src-clj/acha/git_parser.clj
@@ -87,7 +87,7 @@
 (def empty-array (byte-array 0))

 (def raw-comparator RawTextComparator/DEFAULT)
-(def diff-algorithm MyersDiff/INSTANCE)
+(def diff-algorithm (DiffAlgorithm/getAlgorithm DiffAlgorithm$SupportedAlgorithm/HISTOGRAM))

 (defn- parse-edit-list [^EditList el ^RawText a ^RawText b]
   (->> el


Added dataset mean test.

Added dataset mean test.

--- test/clojure/uncomplicate/bayadera/core_test.clj
+++ test/clojure/uncomplicate/bayadera/core_test.clj
@@ -157,7 +157,10 @@
        (/ (sum (col (:pdf (histogram data-set)) 4)) (mrows (:pdf (histogram data-set)))) => (roughly 1.0))
       (facts
        "Test variance"
-       (sum (axpy! -1 (variance (p/data data-set)) (p/variance data-set))) => (roughly 0 0.003)))))
+       (sum (axpy! -1 (variance (p/data data-set)) (p/variance data-set))) => (roughly 0 0.003))
+      (facts
+       "Test mean"
+       (sum (axpy! -1 (mean (p/data data-set)) (p/mean data-set))) => (roughly 0 0.003)))))

 (defn test-all [factory binomial-lik-model]
   (test-uniform factory)


Day 12, first half working

Day 12, first half working

--- src/adventofcode1/twelf.clj
+++ src/adventofcode1/twelf.clj
@@ -12,6 +12,7 @@
    [clojure.core.match :refer [match]]
    [clojure.math.combinatorics :as combo]
    [clojure.string :as str]
+   [com.rpl.specter :as sp]

    spyscope.core
    mw.utils
@@ -23,8 +24,15 @@

 ;; Initially, only "a" to "d"
 (s/def ::regs (s/map-of string? integer?))
+(s/def ::ip   integer?)

-(s/def ::computer (s/keys :req-un [::regs]))
+(s/def ::computer (s/keys :req-un [::ip ::regs]))
+
+;; since :y doesn't always exists, I might have to remove it
+(s/def ::cmd  (s/keys :reg-un [::cmd ::x ::y]))
+(s/def ::cmds (s/coll-of ::cmd))
+
+

 (s/fdef init-computer
         :args (s/cat)
@@ -32,7 +40,8 @@

 (defn init-computer
   []
-  {:regs {"a" 0 "b" 0 "c" 0 "d" 0}})
+  {:ip 0
+   :regs {"a" 0 "b" 0 "c" 0 "d" 0}})

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; helpers
@@ -47,7 +56,7 @@
 (defn parse-cpy-value
   [cmd]
   (if-let [[_ x y] (re-find (re-matcher #"^cpy (-?\d+) ([a-z]+)$" cmd))]
-    {:cmd :cpy-value :x x :y y}))
+    {:cmd :cpy-value :x (parse-int x) :y y}))

 (defn parse-cpy-reg
   [cmd]
@@ -68,13 +77,13 @@
 (defn parse-jnz-value
   [cmd]
   (if-let [[_ x y] (re-find (re-matcher #"^jnz (-?\d+) (-?\d+)$" cmd))]
-    {:cmd :jnx-value :x x :y y}))
+    {:cmd :jnz-value :x (parse-int x) :y (parse-int y)}))

 ;; do we know the 2nd arg is always a number? Yes, at least in my sample
 (defn parse-jnz-x-reg
   [cmd]
   (if-let [[_ x y] (re-find (re-matcher #"^jnz ([a-z]+) (-?\d+)$" cmd))]
-    {:cmd :jnx-x-reg :x x :y y}))
+    {:cmd :jnz-x-reg :x x :y (parse-int y)}))

 (defn parse-cmd
@@ -89,18 +98,48 @@
         ret)))

 ;; testdata defined further down
+(declare sample-data)
 (declare puzzle-input-a)

 (defn parse-cmds
   ([](parse-cmds (str/split-lines puzzle-input-a)))
   ([cmds]
-   (map parse-cmd cmds)))
+   (vec (map parse-cmd cmds))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; execution

+(s/fdef exec
+        :args (s/cat :cmd ::cmd :ip ::ip :regs ::regs)
+        :ret  (s/tuple ::ip ::regs))

+(defn exec
+  [cmd ip regs]
+  (match (:cmd cmd)
+    :cpy-value [(inc ip) (assoc regs (:y cmd) (:x cmd))]
+    :cpy-reg   [(inc ip) (assoc regs (:y cmd) (get regs (:x cmd)))]
+    :inc       [(inc ip) (assoc regs (:x cmd) (inc (get regs (:x cmd))))]
+    :dec       [(inc ip) (assoc regs (:x cmd) (dec (get regs (:x cmd))))]
+    :jnz-value (if-not (zero? (:x cmd))
+                 [(+ ip (:y cmd)) regs]
+                 [(inc ip) regs])
+    :jnz-x-reg (if-not (zero? (get regs (:x cmd)))
+                 [(+ ip (:y cmd)) regs]
+                 [(inc ip) regs])))
+
+
+
+(defn main
+  ;;([](main (parse-cmds (str/split-lines sample-data)) (init-computer)))
+  ([](main (parse-cmds (str/split-lines puzzle-input-a)) (init-computer)))
+  ([cmds comp]
+   (let [{:keys [ip regs]} comp]
+     ;; we are finished if there is no more cmds to run
+     (if (or (neg? ip)(>= ip (count cmds)))
+         comp
+         (let [[ip2 regs2] (exec (nth cmds ip) ip regs)]
+           (recur cmds {:ip ip2 :regs regs2}))))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -138,3 +177,6 @@
 jnz d -2
 dec c
 jnz c -5")
+
+
+;; (clojure.spec.test/instrument)


first draft release

first draft release

--- moebius/project.clj
+++ moebius/project.clj
@@ -1,4 +1,4 @@
-(defproject samsara/moebius "0.1.0-SNAPSHOT"
+(defproject samsara/moebius "0.1.0"
   :description "A system to process and enrich and correlate events in realtime"

   :url "https://samsara.github.com/"


add in find

add in find

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/aurora/editor/fake.cljs
+++ src/aurora/editor/fake.cljs
@@ -95,6 +95,9 @@

 (defmethod draw-clause :when [clause world path]
   [:span [:span.keyword "when "] (rule-ui clause world path)])
+
+(defmethod draw-clause :find [clause world path]
+  [:span [:span.keyword "find "] (rule-ui clause world path)])

 (defmulti compile-clause (fn [clause world]
                            (:type clause)))


oops, fix last commit

oops, fix last commit

--- src/main/shadow/build/npm.clj
+++ src/main/shadow/build/npm.clj
@@ -656,10 +656,11 @@
                     (.toPath package-dir)

                     rel-name
-                    (str "./" (-> (.toPath file)
-                                  (.relativize package-path)
-                                  (str)
-                                  (rc/normalize-name)))]
+                    (->> (.toPath file)
+                         (.relativize package-path)
+                         (str)
+                         (rc/normalize-name)
+                         (str "./"))]

                 ;; FIXME: I'm almost certain that browser allows overriding without extension
                 ;; "./lib/some-file":"./lib/some-other-file"


max-total-depth: 10 -> 15

max-total-depth: 10 -> 15

--- src/babel/english/demo.cljc
+++ src/babel/english/demo.cljc
@@ -11,7 +11,7 @@

 ;; during generation, will not decend deeper than this when creating a tree:
 ;; should also be possible to override per-language.
-(def ^:const max-total-depth 10)
+(def ^:const max-total-depth 15)

 (defn demo [ & [n spec]]
   (let [demo-specs


+(def present-grammar)

+(def present-grammar)

--- src/babel/italiano/lab.cljc
+++ src/babel/italiano/lab.cljc
@@ -295,6 +295,11 @@
 (def basic-grammar
   #{"sentence-nonphrasal-head"})

+(def present-grammar
+  #{"sentence-phrasal-head"
+    "vp-pronoun-phrasal"
+    "vp-pronoun-nonphrasal"})
+
 (def chiamarsi-grammar
   #{"s-aux"
     "sentence-phrasal-head"
@@ -388,8 +393,13 @@
     :aspect :perfect}
    present-perfect-grammar

-   {:tense :future}
-   future-grammar})
+   {:synsem {:sem {:tense :future}}}
+   future-grammar
+
+   {:synsem {:sem {:tense :present
+                   :aspect :simple}}}
+   present-grammar})
+

 (defn rule-matcher-reducer [input-spec]
   (reduce
@@ -417,7 +427,10 @@
                                :subcat []}}
                      {:synsem {:cat :verb
                                :sem {:tense :future}
-                               :subcat []}}]]
+                               :subcat []}}
+                     {:synsem {:cat :verb
+                               :sem {:tense :present
+                                     :aspect :simple}}}]]
     (repeatedly
      #(do (println "")
           (println


remove `fetch-` from tag-statistics-for-user

--- src/braid/server/db/tag.clj
+++ src/braid/server/db/tag.clj
@@ -45,7 +45,7 @@
        (map first)
        set))

-(defn fetch-tag-statistics-for-user
+(defn tag-statistics-for-user
   [conn user-id]
   (->> (d/q '[:find
               ?tag-id
@@ -68,7 +68,7 @@
 (defn fetch-tags-for-user
   "Get all tags visible to the given user"
   [conn user-id]
-  (let [tag-stats (fetch-tag-statistics-for-user conn user-id)]
+  (let [tag-stats (tag-statistics-for-user conn user-id)]
     (->> (d/q '[:find
                 (pull ?t [:tag/id
                           :tag/name


Use new buflen protocol

Use new buflen protocol

--- src/caesium/crypto/sign.clj
+++ src/caesium/crypto/sign.clj
@@ -1,6 +1,7 @@
 (ns caesium.crypto.sign
   (:refer-clojure :exclude [bytes])
-  (:require [caesium.binding :refer [defconsts sodium]]))
+  (:require [caesium.binding :refer [defconsts sodium]]
+            [caesium.byte-bufs :refer [buflen]]))

 (defconsts [bytes seedbytes publickeybytes secretkeybytes primitive])

@@ -27,23 +28,21 @@
   "Puts a signed version of the given message using given secret key into the
   given out buffer."
   [out sk m]
-  (let [mlen (alength ^bytes m)]
-    (.crypto_sign sodium out nil m mlen sk)
-    out))
+  (.crypto_sign sodium out nil m (buflen m) sk)
+  out)

 (defn signed
   "Produces a signed version of the given message m using given secret key."
   [sk m]
-  (let [sm (byte-array (+ bytes (alength ^bytes m)))]
+  (let [sm (byte-array (+ bytes (buflen m)))]
     (signed-to-buf! sm sk m)))

 (defn sign-to-buf!
   "Puts a signature of the given message using given secret key into the given
   out buffer."
   [out sk m]
-  (let [mlen (alength ^bytes m)]
-    (.crypto_sign_detached sodium out nil m mlen sk)
-    out))
+  (.crypto_sign_detached sodium out nil m (buflen m) sk)
+  out)

 (defn sign
   "Produces a detached signature for a message m using given secret key."
@@ -58,14 +57,14 @@
   message. When given a valid signature, returns nil. When given an
   invalid signed message or signature, raises RuntimeException."
   ([pk sm]
-   (let [smlen (alength ^bytes sm)
+   (let [smlen (buflen sm)
          m (byte-array (- smlen bytes))
          res (.crypto_sign_open sodium m nil sm smlen pk)]
      (if (zero? res)
        m
        (throw (RuntimeException. "Signature validation failed")))))
   ([pk msg sig]
-   (let [mlen (alength ^bytes msg)
+   (let [mlen (buflen msg)
          res (.crypto_sign_verify_detached sodium sig msg mlen pk)]
      (when-not (zero? res)
        (throw (RuntimeException. "Signature validation failed"))))))


Simplifies generate-and-parse while focusing on ISO format.

--- umm-spec-lib/test/cmr/umm_spec/test/generate_and_parse.clj
+++ umm-spec-lib/test/cmr/umm_spec/test/generate_and_parse.clj
@@ -8,7 +8,6 @@
             [cmr.common.util :refer [update-in-each]]
             [cmr.common.test.test-check-ext :as ext :refer [defspec]]
             [cmr.umm-spec.test.expected-conversion :as expected-conversion]
-            [cmr.umm-spec.test.umm-record-sanitizer :as urs]
             [cmr.umm-spec.core :as core]
             [cmr.umm-spec.simple-xpath :refer [select context]]
             [cmr.umm-spec.xml-to-umm-mappings.iso19115-2 :as iso-xml-to-umm]
@@ -17,81 +16,32 @@
             [cmr.common.util :refer [are2]]
             [cmr.umm-spec.test.umm-generators :as umm-gen]))

+(def tested-formats
+  "Seq of formats to use in round-trip conversion and XML validation tests."
+  ;; We will re-enable the other formats after ISO support is complete.
+  ;; :dif :dif10 :iso-smap :echo10
+  [:iso19115])
+
 (defn xml-round-trip
   "Returns record after being converted to XML and back to UMM through
   the given to-xml and to-umm mappings."
   [record format]
   (let [metadata-xml (core/generate-metadata :collection format record)]
-    ;; validate xml
-    ;; Since our UMM JSON schema is not complete in defining things like enumeration values for
-    ;; controlled vocabulary fields, the generator generated fields would not create validate field
-    ;; values for those fields (e.g. Dataset_Language field). Until we change the schema to be
-    ;; explicit on those enumeration values and other things, we can't turn validation on xml on.
-    ;; See CMR-1990
-    ; (is (empty? (core/validate-xml :collection format metadata-xml)))
+    ;; XML validation pending
+    ;; (is (empty? (core/validate-xml :collection format metadata-xml)))
     (core/parse-metadata :collection format metadata-xml)))

-;; TODO: This is added temporarily to make sure we don't break the xml schema validations that
-;; are currently working. We will remove this function and the test when all metadata formats
-;; can turn on the xml validation.
-(defn new-xml-round-trip
-  "Returns record after being converted to XML and back to UMM through
-  the given to-xml and to-umm mappings."
-  [record format]
-  (let [metadata-xml (core/generate-metadata :collection format record)]
-    ;; validate xml
-    ;; Since our UMM JSON schema is not complete in defining things like enumeration values for
-    ;; controlled vocabulary fields, the generator generated fields would not create validate field
-    ;; values for those fields (e.g. Dataset_Language field). Until we change the schema to be
-    ;; explicit on those enumeration values and other things, we can't turn validation on xml on.
-    ;; See CMR-1990
-    (is (empty? (core/validate-xml :collection format metadata-xml)))
-    (core/parse-metadata :collection format metadata-xml)))
+(deftest roundtrip-example-record
+  (doseq [metadata-format tested-formats]
+    (testing (str metadata-format)
+      (is (= (expected-conversion/convert expected-conversion/example-record metadata-format)
+             (xml-round-trip expected-conversion/example-record metadata-format))))))

-(deftest roundtrip-gen-parse
-  (are2 [metadata-format]
-        (= (expected-conversion/convert expected-conversion/example-record metadata-format)
-           (xml-round-trip expected-conversion/example-record metadata-format))
-
-        "echo10"
-        :echo10
-
-        "dif9"
-        :dif
-
-        "dif10"
-        :dif10
-
-        "iso-smap"
-        :iso-smap
-
-        "ISO19115-2"
-        :iso19115))
-
-(deftest generate-valid-xml
-  (testing "valid XML is generated for each format"
-    (are [fmt]
-         (empty?
-           (core/validate-xml :collection fmt
-                              (core/generate-metadata :collection fmt expected-conversion/example-record)))
-         :echo10
-         :dif
-         :dif10
-         :iso-smap
-         :iso19115)))
-
-(defspec roundtrip-generator-gen-parse 1000
-  (for-all [umm-record umm-gen/umm-c-generator
-            metadata-format (gen/elements [:echo10 :dif :dif10 :iso-smap :iso19115])]
+(defspec roundtrip-generated-records 1000
+  (for-all [umm-record (gen/no-shrink umm-gen/umm-c-generator)
+            metadata-format (gen/elements tested-formats)]
     (is (= (expected-conversion/convert umm-record metadata-format)
            (xml-round-trip umm-record metadata-format)))))
-
-(defspec new-roundtrip-generator-gen-parse 100
-  (for-all [umm-record umm-gen/umm-c-generator
-            metadata-format (gen/elements [:echo10 :dif :dif10 :iso-smap])]
-    (let [umm-record (urs/sanitized-umm-record umm-record)]
-      (is (= (expected-conversion/convert umm-record metadata-format)
-             (new-xml-round-trip umm-record metadata-format))))))

 (defn- parse-iso19115-projects-keywords
   "Returns the parsed projects keywords for the given ISO19115-2 xml"
@@ -119,7 +69,7 @@
   ;; random XML gen
   (def metadata-format :iso19115)

-  (def sample-record (first (gen/sample (gen/such-that (comp :HorizontalSpatialDomain :SpatialExtent) umm-gen/umm-c-generator) 1)))
+  (def sample-record (first (gen/sample (gen/such-that :DataDates umm-gen/umm-c-generator) 1)))

   ;; generated xml
   (core/generate-metadata :collection metadata-format sample-record)
@@ -134,5 +84,4 @@
   ;; for generated test failures
   (is (= (expected-conversion/convert user/failing-value metadata-format)
          (xml-round-trip user/failing-value metadata-format)))
-
   )


CMR-2112 Add unit tests for format ISBN function

--- umm-spec-lib/test/cmr/umm_spec/test/umm_spec_test_util.clj
+++ umm-spec-lib/test/cmr/umm_spec/test/umm_spec_test_util.clj
@@ -1,7 +1,10 @@
 (ns cmr.umm-spec.test.umm-spec-test-util
   "Tests for cmr.umm-spec.util functions"
-  (:require [clojure.test :refer :all]
-            [cmr.umm-spec.util :as util]))
+  (:require
+   [clojure.test :refer :all]
+   [cmr.common.util :refer [are3]]
+   [cmr.umm-spec.util :as util]))
+

 (deftest test-parse-data-size
   (are [s expected] (= expected
@@ -14,7 +17,7 @@
     "79 MB compressed; 214 MB uncompressed" [{:Size 79.0 :Unit "MB"} {:Size 214.0 :Unit "MB"}]
     "Total Volume: 40 Mbytes for XBT data; 10 Mbytes for TSG data" [{:Size 40.0 :Unit "MB"} {:Size 10.0 :Unit "MB"}]
     "1010 files; Total size: 2351.98 MB" [{:Size 2351.98 :Unit "MB"}]
-
+
     "Single layer, raster format, 13.2 megabytes; vector format, 1.2 megabytes"
     [{:Size 13.2 :Unit "MB"} {:Size 1.2 :Unit "MB"}]

@@ -27,3 +30,19 @@
          "92.4 MB, 0.4 GB"))
   (is (= [{:Size 92.4 :Unit "MB"} {:Size 0.4 :Unit "GB"}]
          (util/parse-data-sizes (util/data-size-str [{:Size 92.4 :Unit "MB"} {:Size 0.4 :Unit "GB"}])))))
+
+(deftest format-isbn
+  (are3 [original-isbn formatted-isbn]
+    (is (= formatted-isbn (util/format-isbn original-isbn)))
+
+    "Remove dashes"
+    "123-456-789-1" "1234567891"
+
+    "No changes"
+    "1234567891" "1234567891"
+
+    "Remove ISBN"
+    "ISBN-12345678" "12345678"
+
+    "Remove ISSN"
+    "ISSN-12345678" "12345678"))


load gce provider

load gce provider

--- src/celestial/workflows.clj
+++ src/celestial/workflows.clj
@@ -17,6 +17,7 @@
     [slingshot.slingshot :only  [throw+ try+]]
     [celestial.model :only (vconstruct pconstruct rconstruct)])
   (:require ; loading defmethods
+    gce.provider
     proxmox.provider
     freenas.provider
     aws.provider


Removing error handling test code

Removing error handling test code

--- src/clj/zetawar/router.cljs
+++ src/clj/zetawar/router.cljs
@@ -42,7 +42,6 @@
         ;; TODO: validate event
         ;; TODO: validate handler return value
         (handle-event* router-ctx msg)
-        (throw (js/Error. "testing"))
         (catch :default ex
           (js/Raven.captureException ex)
           (log/errorf ex "Error handling event: %s" (pr-str msg))))


Implement a default expiration time if an invalid one is specified.

--- src/clj_codetip/handler.clj
+++ src/clj_codetip/handler.clj
@@ -19,7 +19,8 @@
           (condp = expiry
             "hour" (t/hours 1)
             "day"  (t/days 1)
-            "week" (t/weeks 1))))
+            "week" (t/weeks 1)
+            (t/hours 1))))

 (defn- paste-title


Remove logging statements

Remove logging statements

--- src/cljs/dato/lib/core.cljs
+++ src/cljs/dato/lib/core.cljs
@@ -57,14 +57,11 @@
         ws                 (ws/build dato-host dato-path {:on-open    (fn [event] (js/console.log ":on-open :" event))
                                                           :on-close   (fn [event] (js/console.log ":on-close :" event))
                                                           :on-message (fn [event]
-                                                                        (js/console.log "Bla: " event)
                                                                         (let [fr (js/FileReader. (.-data event))]
                                                                           (aset fr "onloadend" (fn [e]
                                                                                (let [data (transit/read transit-reader (.. e -target -result))]
-                                                                                (js/console.log "Bla 2: " data " pending: " pending-rpc)
                                                                                (if-let [cb-id (:server/rpc-id data)]
                                                                                (let [cb-or-ch (get @pending-rpc cb-id)]
-                                                                                (js/console.log "pending-rpc: " @pending-rpc)
                                                                                (swap! pending-rpc dissoc cb-id)
                                                                                ;; Should we just pass the whole payload through, or just the data/resultts?
                                                                                (cond
@@ -75,7 +72,6 @@
                                                                           (.readAsText fr (.-data event))))
                                                           :on-error   (fn [event] (js/console.log ":on-error :" event))})
         dato-send!         (fn [event data]
-                             (js/console.log "dato-send! " (pr-str event) (pr-str data))
                              (.send ws (transit/write transit-writer [event data])))
         controls-ch        (async/chan)
         comms              {:controls controls-ch
@@ -161,7 +157,6 @@
                               ([intent tx meta]
                                (transact! intent tx meta nil))
                               ([intent tx meta cb]
-                               (js/console.log "cast!")
                                (cast! {:event :db/updated
                                        :data  {:intent intent
                                                ;; TODO: Decide on where the cb goes, and stick to it.
@@ -227,12 +222,12 @@
                                              ;; Check if we're reloading
                                              ;; with a pre-existing db
                                              (when-not bootstrapped?
-                                               (js/console.log (pr-str schema))
-                                               (js/console.log (pr-str (vals schema)))
+                                               ;;(js/console.log (pr-str schema))
+                                               ;;(js/console.log (pr-str (vals schema)))
                                                ;;(js/console.log "conn: " (pr-str conn))
                                                (remove-watch app-db :global-listener)
                                                (reset! app-db @conn)
-                                               (js/console.log "me")
+                                               ;;(js/console.log "me")
                                                (doto app-db
                                                  (db/setup-listener! :global-listener))
                                                (d/listen! app-db :server-tx-report
@@ -241,12 +236,9 @@
                                                               (js/console.log "Listened TX: " tx-report)
                                                               (when (or (get-in tx-report [:tx-meta :tx/broadcast?])
                                                                         (get-in tx-report [:tx-meta :tx/persist?]))
-                                                                (js/console.log "Prep that shit!")
                                                                 (let [prepped (db/prep-broadcastable-tx-report tx-report)]
                                                                   (when @network-enabled?
-                                                                    (js/console.log "Send that tx-shit!")
                                                                     (dato-send! :ss/tx-requested prepped)))))))
-                                               (js/console.log "too: " (pr-str (type app-db)))
                                                (let [local-session-id (d/tempid :db.part/user)]
                                                  (d/transact! app-db (vals schema))
                                                  (d/transact! app-db [{:db/id                 (d/tempid :db.part/user)
@@ -254,10 +246,8 @@
                                                                       ;; TODO: This can likely be moved out to a user-land handler
                                                                       (assoc (:session data) :db/id local-session-id)
                                                                       {:local/current-session {:db/id local-session-id}}]))
-                                               (js/console.log "app-db: " app-db)
                                                (reset! cast-bootstrapped? true))
                                              conn)]
-                                    (js/console.log "Something")
                                     (put! dato-ch [:dato/bootstrap-succeeded session-id])
                                     (loop []
                                       (let [msg (<! ws-ch)]
@@ -267,7 +257,6 @@

 ;; TODO: Probably convert to cljs Record to reify this stuff + avoid the apply shortcut
 (defn bootstrap! [dato & args]
-  (js/console.log "bootstrap!")
   (apply (get-in dato [:api :bootstrap!]) args))

 (defn db [dato]


Removed code used for repl testing

Removed code used for repl testing

--- src/clobin/models/paste.clj
+++ src/clobin/models/paste.clj
@@ -28,6 +28,4 @@
 (defn get!
   "Get a stored paste."
   [{:keys [pid]}]
-  (carmine (r/get pid)))
-
-(get! {:pid "0"})
+  (carmine (r/get pid)))


trying to make the two put methods more consistent for the routes in repo.clj

--- src/clojars/routes/repo.clj
+++ src/clojars/routes/repo.clj
@@ -35,41 +35,58 @@
 (defn user-artifacts [username]
   (mapcat group-artifacts (:groups (@ev/users username))))

-;; web handlers
-
 (defn save-to-file [sent-file input]
   (-> sent-file
       .getParentFile
       .mkdirs)
   (io/copy input sent-file))

-(defn try-save-to-file [sent-file input]
+(defn- try-save-to-file [sent-file input]
   (try
     (save-to-file sent-file input)
     (catch java.io.IOException e
       (.delete sent-file)
       (throw e))))

-(defn pom? [filename]
+(defn- pom? [filename]
   (.endsWith filename ".pom"))

-(defn get-pom-info [contents info]
+(defn- get-pom-info [contents info]
   (-> contents
       StringReader.
       maven/pom-to-map
       (merge info)))

+(defn- body-and-add-pom [body filename info account]
+  (if (pom? filename)
+    (let [contents (slurp body)]
+      (db/add-jar account (get-pom-info contents info))
+      contents)
+    body))
+
+(defmacro with-error-handling [& body]
+  `(try
+     ~@body
+     ;; should we only do 201 if the file didn't already exist?
+     {:status 201 :headers {} :body nil}
+     (catch Exception e#
+       (pst e#)
+       {:status 403 :headers {} :body (.getMessage e#)})))
+
+;; web handlers
 (defroutes routes
   (PUT ["/:group/:artifact/:file"
-        :group #".+" :artifact #"[^/]+" :file #"maven-metadata\.xml[^/]*"]
+        :group #"[^\.]+" :artifact #"[^/]+" :file #"maven-metadata\.xml[^/]*"]
        {body :body {:keys [group artifact file]} :params}
-       (with-account
-         (require-authorization
-          (string/replace group "/" ".")
-          (save-to-file (io/file (config :repo) group artifact file)
-                        body)
-          ;; should we only do 201 if the file didn't already exist?
-          {:status 201 :headers {} :body nil})))
+       (let [groupname (string/replace group "/" ".")]
+         (with-account
+           (require-authorization
+            groupname
+            (with-error-handling
+              (let [file (io/file (config :repo) group artifact file)]
+
+                (try-save-to-file file body))
+              )))))
   (PUT ["/:group/:artifact/:version/:filename"
         :group #"[^\.]+" :artifact #"[^/]+" :version #"[^/]+"
         :filename #"[^/]+(\.pom|\.jar|\.sha1|\.md5|\.asc)$"]
@@ -78,30 +95,19 @@
          (with-account
            (require-authorization
             groupname
-            (try
-              (let [info {:group groupname
+            (with-error-handling
+              (let [file (io/file (config :repo) group artifact version filename)
+                    info {:group groupname
                           :name  artifact
-                          :version version}
-                    file (io/file (config :repo) group
-                                  artifact version filename)]
+                          :version version}]
                 (ev/validate-deploy groupname artifact version filename)
                 (db/check-and-add-group account groupname)
-                (let [contents (if (pom? filename)
-                                 (let [contents (slurp body)]
-                                   (db/add-jar account (get-pom-info contents info))
-                                   contents)
-                                 body
-                                 )]
-                  (try-save-to-file file contents))
+
+                (try-save-to-file file (body-and-add-pom body filename info account))
+
                 ;; Be consistent with scp only recording pom or jar
                 (when (some #(.endsWith filename %) [".pom" ".jar"])
-                  (ev/record-deploy {:group-id groupname
-                                     :artifact-id artifact
-                                     :version version} account file)))
-              {:status 201 :headers {} :body nil}
-              (catch Exception e
-                (pst e)
-                {:status 403 :headers {} :body (.getMessage e)}))))))
+                  (ev/record-deploy info account file))))))))
   (PUT "*" _ {:status 400 :headers {}})
   (not-found "Page not found"))


public-profiles

public-profiles

--- src/clojure/nossal/data.clj
+++ src/clojure/nossal/data.clj
@@ -9,20 +9,24 @@
                                    :alternateName "Rodrigo Nossal"
                                    :url "http://noss.al"}))

+(def public-profiles #{"http://facebook.com/nossal"
+                       "http://instagram.com/nossal"
+                       "http://twitter.com/nossal"
+                       "http://github.com/nossal"
+                       "http://soundcloud.com/nossal"
+                       "http://linkedin.com/in/nossal"
+                       "http://flickr.com/photos/nossal"
+                       "http://last.fm/user/nossal"
+                       "http://slideshare.net/nossal"
+                       "http://about.me/nossal"
+                       "http://medium.com/@nossal"
+                       "http://ello.co/nossal"})
+
 (def data-person (json/write-str {"@context" "http://schema.org"
                                   "@type" "Person"
                                   :name "Rodrigo Nossal"
                                   :url "http://noss.al"
-                                  :sameAs #{"http://facebook.com/nossal"
-                                            "http://instagram.com/nossal"
-                                            "http://twitter.com/nossal"
-                                            "http://github.com/nossal"
-                                            "http://soundcloud.com/nossal"
-                                            "http://linkedin.com/in/nossal"
-                                            "http://flickr.com/photos/nossal"
-                                            "http://last.fm/user/nossal"
-                                            "http://slideshare.net/nossal"
-                                            "http://about.me/nossal"}}))
+                                  :sameAs public-profiles}))

 (def data-analytics (json/write-str {:vars {:account (env :google-analytics)}
                                      :triggers {:trackPageview {:on "visible" :request "pageview"}}}))


Tweak hardocded resilience

Tweak hardocded resilience

--- src/clojush/meta_errors.clj
+++ src/clojush/meta_errors.clj
@@ -168,7 +168,7 @@
         0
         (if (> (/ (count (distinct hist))
                   (count hist))
-               3/5)
+               2/5)
           0
           1)))))


Align with https://github.com/akvo/akvo-caddisfly/issues/230

https://github.com/akvo/akvo-caddisfly/commit/5c8171c4b4a3af1967a36bc22cf06470ed4d877e#diff-f83c183214e694d06e5c6be80c43ad31

--- backend/src/akvo/lumen/component/caddisfly.clj
+++ backend/src/akvo/lumen/component/caddisfly.clj
@@ -7,13 +7,14 @@
             [integrant.core :as ig]
             [clojure.tools.logging :as log]))

-(def v2-count 109)
+(def v2-count 110)

 (def missed-v1-uuids-in-v2
   ["f0f3c1dd-89af-49f1-83e7-bcc31c3006cf"
    "a2413119-38eb-4959-92ee-cc169fdbb0fc"
    "c3535e72-ff77-4225-9f4a-41d3288780c6"
-   "d488672f-9a4c-4aa4-82eb-8a95c40d0296"])
+   "d488672f-9a4c-4aa4-82eb-8a95c40d0296"
+   "90cd957c-b40a-4c88-8881-4fb1cc6c12c6"])

 (defn version-schema-backwards-adapt
   "Even when we think we can safely ignore them. As they were obsolete before Lumen was released.


Fix board creation flow.

Fix board creation flow.

--- src/oc/storage/api/boards.clj
+++ src/oc/storage/api/boards.clj
@@ -453,7 +453,7 @@
                                 (api-common/blank-response)
                                 (api-common/location-response
                                   (board-url/url org-slug board-slug)
-                                  (board-rep/render-board org-slug new-board ctx nil)
+                                  (board-rep/render-board (:existing-org ctx) new-board ctx nil)
                                   mt/board-media-type))))
   :handle-unprocessable-entity (fn [ctx]
     (api-common/unprocessable-entity-response (:reason ctx))))


Do not try to retrieve seens if the user requesting the board is not logged in.

--- src/oc/storage/api/boards.clj
+++ src/oc/storage/api/boards.clj
@@ -367,7 +367,7 @@
                              board (or (:updated-board ctx) (:existing-board ctx))
                              drafts-board? (:drafts-board? ctx)
                              user-id (-> ctx :user :user-id)
-                             container-seen (seen/retrieve-by-user-container config/dynamodb-opts user-id (:uuid board))
+                             container-seen (when user-id (seen/retrieve-by-user-container config/dynamodb-opts user-id (:uuid board)))
                              params (when-not drafts-board?
                                       (-> ctx-params
                                        (dissoc :org-slug)


Fix broken 'no method' case

Fix broken 'no method' case

--- src/pinpointer/formatter.cljc
+++ src/pinpointer/formatter.cljc
@@ -199,7 +199,9 @@
   (render-regex frame printer x))

 (defmethod render `s/multi-spec [frame _ printer x]
-  (render-next printer x))
+  (if (= (:reason frame) "no method")
+    (highlight (visit/visit (:base-printer printer) x))
+    (render-next printer x)))

 (defmethod render `s/nonconforming [frame _ printer x]
   (render-next printer x))


remove redundant (defn)

remove redundant (defn)

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -253,15 +253,3 @@
                     (string/join "," (map :rule result))
                     " for: " (spec-info spec))))
     result))
-
-(defn find-comp-paths [bolt & [path]]
-  (if (not (= false (get-in bolt [:phrasal])))
-    (let [path (if (nil? path)
-                 (rest (find-end-of-bolt bolt))
-                 path)]
-      (if (not (empty? path))
-        (concat
-         [(vec (concat path [:comp]))]
-         (find-comp-paths bolt (rest path)))
-        [[:comp]]))))
-


rename variables and modify comments

rename variables and modify comments

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -54,29 +54,21 @@
     (->>
      (lightning-bolts model spec depth max-depth)

-     ;; For each bolt, create a map of complement positions
-     ;; within the bolt to possible complements for that position
+     ;; For each bolt, create a map. This map is from paths in a bolt
+     ;; to possible complements at that path for that bolt.
      (map (fn [bolt]
             {:bolt bolt
              :comps (comp-paths-to-complements bolt model depth max-depth)}))

-     ;; For each such map:complement-position -> complements, find all
-     ;; possible combinations of complements, taking one complement
-     ;; per position.
-     ;; The result is a trellis for each bolt, and a path through this
-     ;; trellis is a generated expression, with one complement for
-     ;; each complement position.
      (mapcat (fn [{bolt :bolt comps :comps}]
-               (let [keys (keys comps)
-                     vals (vals comps)]
+               (let [paths (keys comps)
+                     comps-at-paths (vals comps)]
                  ;; TODO: further flatten this into the overall ->> pipeline
                  (map (fn [each-path-through-trellis]
                         {:bolt bolt
-                         :comps (zipmap keys each-path-through-trellis)})
-                      (apply combo/cartesian-product vals)))))
-
-     ;; for each such path through a trellis, unify the bolt with all
-     ;; of its complements to create a final expression tree.
+                         :comps (zipmap paths each-path-through-trellis)})
+                      (apply combo/cartesian-product comps-at-paths)))))
+
      (map (fn [{bolt :bolt comps :comps}]
             ;; TODO: further flatten this into the overall ->> pipeline
             (reduce (fn [a b]


s/debug/trace/

s/debug/trace/

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -80,7 +80,7 @@
                            (lightning-bolt grammar lexicon each-spec depth index morph total-depth))
                          spec))
     (do
-      (log/debug (str "lightning-bolt(depth=" depth ", total-depth=" total-depth "): sem:" (strip-refs (get-in spec [:synsem :sem]))))
+      (log/trace (str "lightning-bolt(depth=" depth ", total-depth=" total-depth "): sem:" (strip-refs (get-in spec [:synsem :sem]))))
       (let [morph (if morph morph (fn [input] (get-in input [:rule] :default-morph-no-rule)))
             depth (if depth depth 0)
             parents (filter #(not (fail? %)) (map (fn [rule] (unifyc spec rule)) grammar))]
@@ -103,6 +103,7 @@
             (lazy-cat phrasal lexical)))))))

 (defn add-complement [bolt path spec grammar lexicon cache morph depth total-depth]
+  (log/info (str "add-complement: " (show-bolt bolt path morph)))
   (let [input-spec spec
         from-bolt bolt ;; so we can show what (add-complement) did to the input bolt, for logging.
         spec (unifyc spec (get-in bolt path))
@@ -127,13 +128,13 @@
     (filter (fn [complement]
               (if (fail? complement)
                 (do
-                  (log/debug (str "add-complement(depth=" depth ",total-depth=" total-depth
+                  (log/trace (str "add-complement(depth=" depth ",total-depth=" total-depth
                                   ",path=" path ",bolt=(" (show-bolt bolt path morph) ") FAILED:"
                                   "'" (morph complement) "'"))

                   false)
                 (do
-                  (log/debug (str "add-complement(depth=" depth ",total-depth=" total-depth
+                  (log/trace (str "add-complement(depth=" depth ",total-depth=" total-depth
                                   ",path=" path ",bolt=(" (show-bolt bolt path morph) ")=>"
                                   "'" (morph complement) "'"))
                   true)))
@@ -141,7 +142,7 @@
                    (unify (copy bolt)
                           (path-to-map path
                                        (copy complement))))
-                 (let [debug (log/debug (str "add-complement(depth=" depth ",total-depth=" total-depth
+                 (let [debug (log/trace (str "add-complement(depth=" depth ",total-depth=" total-depth
                                              ",path=" path ",bolt=(" (show-bolt bolt path morph)
                                              "): calling generate-all(" (strip-refs spec) ");"
                                              "input-spec: " input-spec))


~(defn morph-ps) : fix stack overflow

~(defn morph-ps) : fix stack overflow

--- src/babel/italiano.cljc
+++ src/babel/italiano.cljc
@@ -32,7 +32,7 @@
 (defn morph-ps
   ([expr]
    (let [model @@(get babel.directory/models :it)]
-     (morph-ps expr)))
+     (morph-ps expr model)))

   ([expr model & {:keys [from-language show-notes]
                   :or {from-language nil


(transitivize) should leave lexeme alone if :transitivize=false

--- src/babel/lexiconfn.clj
+++ src/babel/lexiconfn.clj
@@ -866,6 +866,8 @@
                        (not (= :unspec (get-in val [:synsem :sem :obj])))
                        (not (= '() (get-in val [:synsem :subcat :2])))

+                       (not (= false (get-in val [:transitivize])))
+
                        (not (= :adjective (get-in val [:synsem :subcat :2 :cat])))
                        (not (= :intensifier (get-in val [:synsem :subcat :2 :cat])))

@@ -873,7 +875,8 @@
                   (unify val
                          transitive)

-                  (= (get-in val [:synsem :cat]) :verb)
+                  (and (= (get-in val [:synsem :cat]) :verb)
+                       (not (= false (get-in val [:transitivize]))))
                   (unify val
                          verb-subjective)
                   true


more api

more api

--- src/bitcoinrpc/core.clj
+++ src/bitcoinrpc/core.clj
@@ -49,11 +49,6 @@
   `(let [x# ~body]
      (println "dbg:" '~body "=" x#)
      x#))
-#_(defmacro def-rpc-opt [name n & args]
-   `(defn ~name ~(get-description name)
-      ([~@args] (btc-rpc ~(str name) ~@args))
-      ([~@(take n args)] (btc-rpc ~(str name) ~@(take n args)))
-      ))

 (defmacro def-rpc-opt [name n & args]
   `(defn ~name ~(get-description name)
@@ -146,13 +141,13 @@
 (def-rpc setnetworkactive b)

 ;== Rawtransactions ==
-;createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,"data":"hex",...} ( locktime )
+(def-rpc-opt createrawtransaction 2 txids addresses locktime)
 (def-rpc decoderawtransaction hexstring)
 (def-rpc decodescript hexstring)
 (def-rpc-opt fundrawtransaction 1 hexstring options)
 (def-rpc-opt getrawtransaction 1 txid verbose)
 (def-rpc-opt sendrawtransaction 1 hexstring allowhighfees)
-;signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
+(def-rpc-opt signrawtransaction 1 hexstring txids privatekeys sighashtype)

 ;== Util ==
 (def-rpc createmultisig nrequired the-keys)
@@ -189,11 +184,11 @@
 (def-rpc-opt gettransaction 1 txid include_watchonly)
 (def-rpc getunconfirmedbalance)
 (def-rpc getwalletinfo)
-;importaddress "address" ( "label" rescan p2sh )
+(def-rpc-opt importaddress 1 address label rescan p2sh)
 (def-rpc importmulti requests options)
-;importprivkey "bitcoinprivkey" ( "label" ) ( rescan )
+(def-rpc-opt importprivkey 1 bitcoinprivkey label rescan)
 (def-rpc importprunedfunds)
-;importpubkey "pubkey" ( "label" rescan )
+(def-rpc-opt importpubkey 1 pubkey label rescan)
 (def-rpc importwallet filename)
 (def-rpc-opt keypoolrefill 0 newsize)
 (def-rpc-opt listaccounts 0 minconf include_watchonly)
@@ -204,7 +199,7 @@
 (def-rpc-opt listsinceblock 0 blockhash target_confirmations include_watchonly)
 (def-rpc-opt listtransactions 0 account count skip include_watchonly)
 (def-rpc-opt listunspent 0 minconf maxconf  addresses include_unsafe)
-;lockunspent unlock ([{"txid":"txid","vout":n},...])
+(def-rpc-opt lockunspent 0 unlock todo)
 (def-rpc-opt move 3 fromaccount toaccount amount minconf comment)
 (def-rpc removeprunedfunds txid)
 (def-rpc-opt sendfrom 3 fromaccount toaddress amount  minconf comment comment_to)


Update views.clj

Update views.clj

--- src/briefcase/views.clj
+++ src/briefcase/views.clj
@@ -51,7 +51,7 @@
     [:div.categories (published data)]))

 (def ^:private six-months-ago
-  (minus (from-date (java.util.Date.) (months 6))))
+  (minus (from-date (java.util.Date.)) (months 6)))

 (defn- old-entry-warning
   "Generates a warning for entries that are more than 6 months or so old"


require

require

--- src/celestial/tasks.clj
+++ src/celestial/tasks.clj
@@ -5,6 +5,7 @@
     [celestial.common :only (slurp-edn)]
     [taoensso.timbre :only (debug info trace)]
     [celestial.model :only (vconstruct pconstruct)])
+  (:require proxmox.provider aws.provider); loading defmethods
   (:import
     [celestial.puppet_standalone Standalone]
     [proxmox.provider Container]))


quickbenck over rest-routes

quickbenck over rest-routes

--- perf-test/clj/reitit/opensensors_routing_test.clj
+++ perf-test/clj/reitit/opensensors_routing_test.clj
@@ -73,19 +73,11 @@
         total 10000
         dropped (int (* total 0.45))]
     (mapv
-      #(let [times (->> (range total)
-                        (mapv
-                          (fn [_]
-                            (let [now (System/nanoTime)
-                                  result (f %)
-                                  total (- (System/nanoTime) now)]
-                              (assert result)
-                              total)))
-                        (sort)
-                        (drop dropped)
-                        (drop-last dropped))
-             avg (int (/ (reduce + times) (count times)))]
-         [% avg]) urls)))
+      (fn [path]
+        (let [time (int (* (first (:sample-mean (cc/quick-benchmark (dotimes [_ 1000] (f path)) {}))) 1e6))]
+          (println path "=>" time "ns")
+          [path time]))
+      urls)))

 (defn bench [routes no-paths?]
   (let [routes (mapv (fn [[path name]]


Fix reflection errors. Close #354.

Fix reflection errors. Close #354.

--- src/cljc/quil/core.cljc
+++ src/cljc/quil/core.cljc
@@ -1597,9 +1597,9 @@
   drawn to the screen. Used in combination with [[ambient]], [[specular]], and
   [[shininess]] in setting the material properties of shapes.

-  If passed one arg it is assumed to be an `int` (i.e. a color),
+  If passed one arg it is assumed to be an `float` (gray),
   multiple args are converted to `floats`."
-     ([gray] (.emissive (current-graphics) gray))
+     ([gray] (.emissive (current-graphics) (float gray)))
      ([r g b] (.emissive (current-graphics) (float r) (float g) (float b)))))

 (defn
@@ -1773,10 +1773,10 @@
   * `:dilate`    - increases the light areas. Doesn't work with level."
   ([mode]
    (.filter (current-graphics)
-            (u/resolve-constant-key mode filter-modes)))
+            (int (u/resolve-constant-key mode filter-modes))))

   ([mode level]
-   (let [mode (u/resolve-constant-key mode filter-modes)]
+   (let [mode (int (u/resolve-constant-key mode filter-modes))]
      (.filter (current-graphics) mode (float level)))))

 #?(:clj
@@ -2441,7 +2441,7 @@
   "Returns true if object is loaded."
   [object]
   (condp = (type object)
-    #?@(:clj  (PImage (pos? (.-width object))
+    #?@(:clj  (PImage (pos? (.-width ^PImage object))
                ; shader is loaded synchronously
                       PShader true)
         :cljs (js/p5.Shader (and (aget object "_vertSrc") (aget object "_fragSrc"))
@@ -2522,7 +2522,7 @@
         ; instead we convert extract alphas into array and use array version of mask()
         ; see https://processing.org/reference/PImage_mask_.html
       (let [pxls (pixels mask)
-            alphas (amap ^ints pxls idx ret (int (alpha (aget ^ints pxls idx))))]
+            ^ints alphas (amap ^ints pxls idx ret (int (alpha (aget ^ints pxls idx))))]
         (.mask img alphas))
       :cljs (.mask img mask))))

@@ -3771,7 +3771,7 @@
   help. (Bug 1094)"
   ([x y c] (set-pixel (current-graphics) x y c))
   ([^PImage img x y c]
-   (.set img (int x) (int y) c)))
+   (.set img (int x) (int y) (int c))))

 (defn
   ^{:requires-bindings true
@@ -4805,10 +4805,10 @@
        (finally
          (quil.core/pop-matrix)))))

-(defn begin-draw [graphics]
+(defn begin-draw [^PGraphics graphics]
   #?(:clj (.beginDraw graphics)))

-(defn end-draw [graphics]
+(defn end-draw [^PGraphics graphics]
   #?(:clj (.endDraw graphics)))

 (defmacro


remove deprecated HashMap deftype

remove deprecated HashMap deftype

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -3845,117 +3845,6 @@

 (set! cljs.core.ObjMap/fromObject (fn [ks obj] (ObjMap. nil ks obj 0 nil)))

-;;; HashMap
-;;; DEPRECATED
-;;; in favor of PersistentHashMap
-
-; The keys field is an array of all keys of this map, in no particular
-; order. Each key is hashed and the result used as a property name of
-; hashobj. Each values in hashobj is actually a bucket in order to handle hash
-; collisions. A bucket is an array of alternating keys (not their hashes) and
-; vals.
-(deftype HashMap [meta count hashobj ^:mutable __hash]
-  Object
-  (toString [this]
-    (pr-str this))
-
-  IWithMeta
-  (-with-meta [coll meta] (HashMap. meta count hashobj __hash))
-
-  IMeta
-  (-meta [coll] meta)
-
-  ICollection
-  (-conj [coll entry]
-    (if (vector? entry)
-      (-assoc coll (-nth entry 0) (-nth entry 1))
-      (reduce -conj
-              coll
-              entry)))
-
-  IEmptyableCollection
-  (-empty [coll] (with-meta cljs.core.HashMap/EMPTY meta))
-
-  IEquiv
-  (-equiv [coll other] (equiv-map coll other))
-
-  IHash
-  (-hash [coll] (caching-hash coll hash-imap __hash))
-
-  ISeqable
-  (-seq [coll]
-    (when (pos? count)
-      (let [hashes (.sort (js-keys hashobj))]
-        (mapcat #(map vec (partition 2 (aget hashobj %)))
-                hashes))))
-
-  ICounted
-  (-count [coll] count)
-
-  ILookup
-  (-lookup [coll k] (-lookup coll k nil))
-  (-lookup [coll k not-found]
-    (let [bucket (aget hashobj (hash k))
-          i (when bucket (scan-array 2 k bucket))]
-      (if i
-        (aget bucket (inc i))
-        not-found)))
-
-  IAssociative
-  (-assoc [coll k v]
-    (let [h (hash k)
-          bucket (aget hashobj h)]
-      (if bucket
-        (let [new-bucket (aclone bucket)
-              new-hashobj (goog.object/clone hashobj)]
-          (aset new-hashobj h new-bucket)
-          (if-let [i (scan-array 2 k new-bucket)]
-            (do                         ; found key, replace
-              (aset new-bucket (inc i) v)
-              (HashMap. meta count new-hashobj nil))
-            (do                         ; did not find key, append
-              (.push new-bucket k v)
-              (HashMap. meta (inc count) new-hashobj nil))))
-        (let [new-hashobj (goog.object/clone hashobj)] ; did not find bucket
-          (aset new-hashobj h (array k v))
-          (HashMap. meta (inc count) new-hashobj nil)))))
-  (-contains-key? [coll k]
-    (let [bucket (aget hashobj (hash k))
-          i (when bucket (scan-array 2 k bucket))]
-      (if i
-        true
-        false)))
-
-  IMap
-  (-dissoc [coll k]
-    (let [h (hash k)
-          bucket (aget hashobj h)
-          i (when bucket (scan-array 2 k bucket))]
-      (if (not i)
-        coll ; key not found, return coll unchanged
-        (let [new-hashobj (goog.object/clone hashobj)]
-          (if (> 3 (alength bucket))
-            (js-delete new-hashobj h)
-            (let [new-bucket (aclone bucket)]
-              (.splice new-bucket i 2)
-              (aset new-hashobj h new-bucket)))
-          (HashMap. meta (dec count) new-hashobj nil)))))
-
-  IFn
-  (-invoke [coll k]
-    (-lookup coll k))
-  (-invoke [coll k not-found]
-    (-lookup coll k not-found)))
-
-(set! cljs.core.HashMap/EMPTY (HashMap. nil 0 (js-obj) 0))
-
-(set! cljs.core.HashMap/fromArrays (fn [ks vs]
-  (let [len (alength ks)]
-    (loop [i 0, out cljs.core.HashMap/EMPTY]
-      (if (< i len)
-        (recur (inc i) (assoc out (aget ks i) (aget vs i)))
-        out)))))
-
 ;;; PersistentArrayMap

 (defn- array-map-index-of-nil? [arr m k]
@@ -6668,11 +6557,6 @@
     (let [pr-pair (fn [keyval] (pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
       (pr-sequential-writer writer pr-pair "{" ", " "}" opts coll)))

-  HashMap
-  (-pr-writer [coll writer opts]
-    (let [pr-pair (fn [keyval] (pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
-      (pr-sequential-writer writer pr-pair "{" ", " "}" opts coll)))
-
   PersistentArrayMap
   (-pr-writer [coll writer opts]
     (let [pr-pair (fn [keyval] (pr-sequential-writer writer pr-writer "" " " "" opts keyval))]


* src/cljs/cljs/core.cljs: communicate old value to watchers

--- src/cljs/cljs/core.cljs
+++ src/cljs/cljs/core.cljs
@@ -2780,8 +2780,9 @@
   [a new-value]
   (when-let [validate (.validator a)]
     (assert (validate new-value) "Validator rejected reference state"))
-  (set! (.state a) new-value)
-  (-notify-watches a (.state a) new-value)
+  (let [old-value (.state a)]
+    (set! (.state a) new-value)
+    (-notify-watches a old-value new-value))
   new-value)

 (defn swap!


fix quote regression in `cljs.repl/doc` pointed out by Mike Fikes

--- src/cljs/cljs/repl.cljs
+++ src/cljs/cljs/repl.cljs
@@ -15,7 +15,7 @@
   (cond
     (:forms m) (doseq [f (:forms m)]
                  (println "  " f))
-    (:arglists m) (prn (:arglists m)))
+    (:arglists m) (prn (second (:arglists m))))
   (if (:special-form m)
     (do
       (println "Special Form")


Code chef triangle clean up

Code chef triangle clean up

--- src/codechef/helper.clj
+++ src/codechef/helper.clj
@@ -17,21 +17,6 @@
       (println (count ts))
       (doseq [[a b c] (sort ts)]
         (println a b c)))))
-
-
-#(let [[a b c] %
-       s (/ (+ a b c) 2)
-       p (Math/sqrt (* s (- s a) (- s b) (- s c)))
-       r (/ p s)]
-  (<= r 3))
-
-(defn bla-bla-truc []
-  (take 20 (map #(let [[a b c] %
-                       s (double (/ (+ a b c) 2))
-                       p (Math/sqrt (* s (- s a) (- s b) (- s c)))
-                       r (/ p s)]
-                  {:inradius r :permiter s :area p :sides %})
-                (iterate #(update-in % [2] inc) [1 1 1]))))

 (def rev-vec (comp vec reverse))

@@ -59,30 +44,6 @@
             rev-vec)
         (assoc iv (dec size) lc)))))

-'(let [gr (Integer/parseInt (read-line))
-       res (binding [*unchecked-math* false]
-             (for [^int a (range 1 101) ^int b (range 1 (inc a)) ^int c (range 1 (inc b))
-                   :let [sp (/ (+ a b c) 2)
-                         area (Math/sqrt (* sp (- sp a) (- sp b) (- sp c)))
-                         r (/ area sp)]
-                   :when (and (> (+ a b) c) (> (+ a c) b) (> (+ b c) a) (== r gr))]
-               (vec (sort [a b c]))))]
-   (-> res
-       vec
-       sort))
-
-'(binding [*unchecked-math* true]
-   (let [gr (Integer/parseInt (read-line))
-         res (for [^int a (range 1 1001) ^int b (range 1 (inc a)) ^int c (range 1 (inc b))
-                   :let [sp (/ (+ a b c) 2.0)
-                         area (Math/sqrt (* sp (- sp a) (- sp b) (- sp c)))
-                         r (/ area sp)]
-                   :when (and (> (+ a b) c) (> (+ a c) b) (> (+ b c) a) (== r gr))]
-               (vec (sort [a b c])))]
-     (println (count res))
-     (doseq [[a b c] res]
-       (println a b c))))
-
 (defn odometer-generator [size lower upper]
   (fn [x]
     (if (= upper (last x))
@@ -93,4 +54,4 @@
                               (< % pos) %2
                               (> % pos) lower))
                           x)))
-      (assoc x (dec size) (inc (last x))))))+      (assoc x (dec size) (inc (last x))))))


Fix indentation problems in Clojure

Fix indentation problems in Clojure

--- src/computer_build/vhdl.clj
+++ src/computer_build/vhdl.clj
@@ -8,7 +8,11 @@
   (if (empty? line) '()
     (if (string? line)
       (cons line (indent-lines lines))
-      (concat (indented-lines (indent-lines line)) (indent-lines lines)))))
+      (concat
+          (if (:noindent (meta line))
+              (indent-lines line)
+              (indented-lines (indent-lines line)))
+          (indent-lines lines)))))

 (defn spaces [& strings] (str-join " " strings))

@@ -35,7 +39,7 @@
     (str "architecture arch_" name " of " name " is")
     (map to-vhdl defs)
     "begin"
-    (map to-vhdl architecture)
+    (with-meta (map to-vhdl architecture) {:noindent true})
     (str "end arch_" name ";"))))))

 ; does not generate lines like block-level methods do
@@ -46,7 +50,7 @@
   (list
     (str "process(" (str-join "," (map keyword-to-str ports)) ")")
     "begin"
-    (map to-vhdl definition)
+    (with-meta (map to-vhdl definition) {:noindent true})
     "end process;"))

 (defmethod to-vhdl :case [[type target & cases]]
@@ -70,7 +74,7 @@
 (defmethod to-vhdl :if [[type condition & body]]
   (list
     (spaces "if" (to-vhdl condition) "then")
-    (map to-vhdl body)
+    (with-meta (map to-vhdl body) {:noindent true})
     "end if;"))

 (defmethod to-vhdl :and [[type condA condB]]