fix kafka plugin to use 1 peer max

fix kafka plugin to use 1 peer max

--- src/leiningen/new/onyx_app/src/onyx_app/jobs/sample_submit_job.clj
+++ src/leiningen/new/onyx_app/src/onyx_app/jobs/sample_submit_job.clj
@@ -26,20 +26,21 @@
                   :task-scheduler :onyx.task-scheduler/balanced}]
     (cond-> base-job
       (= :dev mode) (add-core-async-output :write-lines {:onyx/batch-size batch-size})
-      (= :dev mode) (add-seq-file-input :read-lines {:onyx/batch-size batch-size
+      (= :dev mode) (add-seq-file-input :read-lines {:onyx/batch-size batch-size
                                                      :filename "resources/sample_input.edn"})
       (= :prod mode) (add-kafka-input :read-lines {:onyx/batch-size batch-size
+                                                   :onyx/max-peers 1
                                                    :kafka/topic "meetup"
-                                                   :kafka/group-id "onyx-consumer"
-                                                   :kafka/zookeeper "zk:2181"
+                                                   :kafka/group-id "onyx-consumer"
+                                                   :kafka/zookeeper "zk:2181"
                                                    :kafka/deserializer-fn :{{app-name}}.tasks.kafka/deserialize-message-json
                                                    :kafka/offset-reset :smallest})
       (= :prod mode) (add-sql-insert-output :write-lines {:onyx/batch-size batch-size
-                                                          :sql/classname "com.mysql.jdbc.Driver"
-                                                          :sql/subprotocol "mysql"
-                                                          :sql/subname "//db:3306/meetup"
-                                                          :sql/user "onyx"
-                                                          :sql/password "onyx"
+                                                          :sql/classname "com.mysql.jdbc.Driver"
+                                                          :sql/subprotocol "mysql"
+                                                          :sql/subname "//db:3306/meetup"
+                                                          :sql/user "onyx"
+                                                          :sql/password "onyx"
                                                           :sql/table :recentMeetups})
       {{#metrics?}}true (add-metrics :write-lines {:metrics/buffer-capacity 10000
                                                    :metrics/workflow-name "meetup-workflow"


blog/auth check toggle

blog/auth check toggle

--- webapp/src/webapp/core.clj
+++ webapp/src/webapp/core.clj
@@ -40,7 +40,7 @@
 	(GET "/" request (do (log request "homepage" "page-view" (:remote-addr request) {}) site-map))
 	(GET "/ff" request (do (log request "fantasy-football" "page-view" (:remote-addr request) {}) ff))
 	(GET "/microblog" request (do (log request "microblog" "page-view" (:remote-addr request) {}) (microblog)))
-	(GET "/microblog/post" request (friend/authenticated (if false (do (log request "microblog_post" "page-view" (:remote-addr request) {}) (mb_post))(str "Try again!\n" request))))
+	(GET "/microblog/post" request (friend/authenticated (if true (do (log request "microblog_post" "page-view" (:remote-addr request) {}) (mb_post))(str "Try again!\n" request))))
     (POST "/microblog_post" request (let [message (:message (:params request))] (do (log request "microblog_post" "publish" (:remote-addr request) {:message message}) (mb_post_post message))))
     (GET "/site_stats" request (do (log request "site_stats" "page-view" (:remote-addr request) {}) (stats-output)))
 	(compojure.route/not-found "Link not found."))


working on string conversion from word array

--- src/hangman/core.clj
+++ src/hangman/core.clj
@@ -20,7 +20,7 @@
        (str/split-lines )
        (map str/trim ) ))

-(def ^:const all-letters-set (set (map char (range (int \a) (inc(int \z)) ))) )
+(def ^:const all-letters (set (map char (range (int \a) (inc(int \z)) ))) )

 (def tst-words [
   "is" "at" "by" "up"
@@ -43,44 +43,41 @@
     (map vec word-seq) ))

 (defn num-rows
-  "Given a 2D array (vector of vectors), return the number of rows (1st dimension)."
+  "Given a 2D array (seq of seqs), return the number of rows (1st dimension)."
   [word-array]
   (count word-array) )

 (defn num-cols
-  "Given a 2D array (vector of vectors), return the number of columns (2nd dimension)."
+  "Given a 2D array (seq of seqs), return the number of columns (2nd dimension)."
   [word-array]
-  (count (word-array 0)) )
+  (count (first word-array)) )

 (defn get-array-col
-  "Given a 2D array (vector of vectors), return a vector of elements
+  "Given a 2D array (seq of seqs), return a vector of elements
   from the specified column."
-  [word-array col-idx]
-  { :pre  [ (vector? word-array) (integer? col-idx) ]
-    :post [ (vector? %) ] }
-  (reduce #(conj %1 (%2 col-idx))
-          [] word-array ) )
+  [word-seq col-idx]
+  { :pre  [ (vector? word-seq) (integer? col-idx) ]
+    :post [] }
+  (reduce #(conj %1 (nth %2 col-idx))
+          [] word-seq ) )

 (defn get-array-row
   "Given a 2D array (vector of vectors), return a vector of elements
   from the specified row."
   [word-array row-idx]
   { :pre  [ (integer? row-idx) ]
-    :post [ (vector? %) ] }
-  (word-array row-idx) )
+    :post [] }
+  (nth word-array row-idx) )

 (defn to-freqs-by-col
-  "For each column of a 2D array, computes an element frequency map. Returns as
-  a vector indexed by column."
+  "For each column of a 2D array (seq of seqs), computes an element frequency map. Returns
+  as a vector indexed by column."
   [word-array]
-  { :pre  [ (vector? word-array)
-            (< 0 (num-rows word-array) )
+  { :pre  [ (< 0 (num-rows word-array) )
             (< 0 (num-cols word-array) ) ]
-    :post [ (vector? %) ] }
-  (vec
-    (for [idx (range 0 (num-cols word-array)) ]
-      (let [curr-col (get-array-col word-array idx)]
-        (frequencies curr-col)) )))
+    :post [] }
+  (vec (for [idx (range 0 (num-cols word-array)) ]
+         (frequencies (get-array-col word-array idx)) )))

 (defn filter-with-idx
   "Returns values from data-seq where corresponding pred-seq elements are truthy.
@@ -169,10 +166,9 @@
   "Generate the next guess letter by calculating the bits of information for each possible
   guess letter. "
   [keep-words used-chars]
-  (let [
-        avail-chars   (set/difference all-letters-set used-chars)
+  (let [avail-chars   (set/difference all-letters used-chars)
         char-bits     (zipmap avail-chars (map #(calc-info-bits keep-words %) avail-chars) )
-        best-char     (apply max-key char-bits avail-chars ) ]
+        best-char     (apply max-key char-bits avail-chars) ]
     best-char ) )

 (defn make-guess-freq
@@ -280,7 +276,8 @@
     curr-words          (words-map curr-len)
       _ (assert (= curr-words     ["abcd" "xbcd" "xxcd" "xxxd"]  ))
     word-array          (to-word-array  curr-words)
-      _ (assert (= word-array [[\a \b \c \d] [\x \b \c \d] [\x \x \c \d] [\x \x \x \d]] ))
+      _ (assert (= word-array
+                   [[\a \b \c \d] [\x \b \c \d] [\x \x \c \d] [\x \x \x \d]] ))

     col-char-freqs      (to-freqs-by-col word-array)
       _ (assert (= col-char-freqs [{\a 1, \x 3} {\b 2, \x 2} {\c 3, \x 1} {\d 4}] ))


CMR-688: Uncommented reset line in ingest_util.

--- system-int-test/src/cmr/system_int_test/utils/ingest_util.clj
+++ system-int-test/src/cmr/system_int_test/utils/ingest_util.clj
@@ -173,4 +173,4 @@
          (create-provider provider-guid provider-id grant-all?))
        (f)
        (finally
-         #_(reset))))))
+         (reset))))))


Map Position

Map Position

--- src/tester/core.cljs
+++ src/tester/core.cljs
@@ -18,7 +18,7 @@
 (s/def ::x ::within-board-size)
 (s/def ::y ::within-board-size)
 (s/def ::direction directions)
-(s/def ::position (s/tuple ::within-board-size ::within-board-size))
+(s/def ::position (s/keys :req [::x ::y]))
 (s/def ::value (s/with-gen pos-int? (fn [] (s/gen (s/and pos-int? #(< 0 % 10))))))
 (s/def ::tile (s/keys :req [::position ::value]))

@@ -26,11 +26,14 @@
                      (s/coll-of ::tile :max-count (* board-size board-size))
                      #(apply distinct? (map ::position %))))

+(def default-board-gen (gen/such-that #(< 0 (count %) board-size) (s/gen ::game-board)))
+
 (s/def ::app-db (s/keys :req [::game-board]))

 (defn initial-state
   []
-  (gen/generate (s/gen ::app-db)))
+  {::game-board (gen/generate default-board-gen)})
+

 (defonce app-db (reagent/atom (initial-state)))

@@ -41,8 +44,8 @@
 (defn tile-comparator
   [direction]
   (fn [tile1 tile2]
-    (let [[x1 y1] (::position tile1)
-          [x2 y2] (::position tile2)]
+    (let [{x1 ::x y1 ::y} (::position tile1)
+          {x2 ::x y2 ::y} (::position tile2)]
       (case direction
         ::up (compare y1 y2)
         ::down (compare y2 y1)
@@ -63,11 +66,19 @@
         :args (s/cat :direction ::direction :board ::game-board)
         :ret ::tiles-to-move)

+(defn- vertical?
+  [direction]
+  #{::up ::down})
+
+(defn- horizontal?
+  [direction]
+  #{::left ::right})
+
 (defn group-by-direction
   [direction board]
-    (cond
-     (#{::up ::down} direction) (group-by (fn [t] (some-> t ::position first)) board)
-     (#{::right ::left} direction) (group-by (fn [t] (some-> t ::position second)) board)))
+  (cond
+    (vertical? direction) (group-by  #(-> % ::position ::x) board)
+    (horizontal? direction) (group-by #(-> % ::position ::y) board)))

 (s/fdef join-first
         :args (s/cat :tiles (s/and (s/coll-of ::tile) #(< 0 (count %))))
@@ -84,12 +95,23 @@
 (s/fdef move-direction
         :args (s/cat :board ::game-board :direction ::direction))

+(defn shift-in-direction
+  [direction row]
+  (case
+      ::up (map-indexed (fn [idx itm] (update itm ::position #())))
+      ::down
+      ::left
+      ::right
+      ))
+
 (defn move-direction
   [board direction]
   (->> (group-by-direction direction board)
        (vals)
        (map (partial sort-tiles-by-priority direction))
-       (mapcat join-first)))
+       (mapcat join-first)
+       #_(mapcat (partial shift-in-direction direction))
+       ))

 (defn update-state
   [state [event-type & params]]
@@ -119,7 +141,8 @@

 (defn position->coordinates
   [position]
-  (into [] (map #(* tile-width %)) position))
+  (-> (update position ::x #(* tile-width %))
+      (update ::y #(* tile-width %))))

 (defn game-board
   []
@@ -139,7 +162,7 @@
                :align-items "center"}}
       (for [tile game-board
             :let [{:keys [::position ::value]} tile
-                  [x y] (position->coordinates position)]]
+                  {x ::x y ::y} (position->coordinates position)]]
         ^{:key (hash position)}
         [:div {:style {:position "absolute"
                        :background-color "orange"


Fixed bug in explicit regress-state

Fixed bug in explicit regress-state

--- src/edu/berkeley/ai/angelic/descriptions_and_valuations.clj
+++ src/edu/berkeley/ai/angelic/descriptions_and_valuations.clj
@@ -393,7 +393,7 @@
 				 :let [[next step-reward] (envs/next-state-and-reward stat action)]
 				 :when (= next state)]
 			     [stat step-reward pre-reward]))]
-    (util/first-maximal-element #(+ (second %) (nth % 3)) candidates)))
+    (util/first-maximal-element #(+ (second %) (nth % 2)) candidates)))

 (defmethod progress-valuation [::Valuation ::ExplicitDescription]  [val desc]
   (make-explicit-valuation


Add scalarmult tests

Add scalarmult tests

--- test/caesium/crypto/scalarmult_test.clj
+++ test/caesium/crypto/scalarmult_test.clj
@@ -1,12 +1,31 @@
 (ns caesium.crypto.scalarmult-test
   (:require [caesium.crypto.scalarmult :as s]
-            [clojure.test :refer [deftest is are]]
+            [clojure.test :refer [deftest is are testing]]
             [caesium.util :as u]))

 (deftest consts-tests
   (is (= 32 s/bytes))
   (is (= 32 s/scalarbytes))
   (is (= "curve25519" s/primitive)))
+
+(def basepoint
+  (byte-array (into [9] (repeat (dec s/bytes) 0))))
+
+(def scalar-1
+  "The number 1, as a curve25519 scalar."
+  (s/int->scalar 1))
+
+(deftest scalarmult-tests
+  (testing "-to-buf! and regular API work identically"
+    (let [out (byte-array s/bytes)
+          r (s/scalarmult scalar-1)]
+      (s/scalarmult-to-buf! scalar-1 out)
+      (is (u/array-eq r out))))
+  (testing "base point mult uses the base point"
+    (is (u/array-eq
+         (s/scalarmult scalar-1)
+         (s/scalarmult scalar-1 basepoint)))))
+
 (deftest int->scalar-test
   (are [n expected] (u/array-eq expected (s/int->scalar n))
     0 (byte-array 32)


Ready for lein-template release

Ready for lein-template release

--- lein-template/project.clj
+++ lein-template/project.clj
@@ -1,7 +1,7 @@
 ;; Copyright © 2014 JUXT LTD.

 ;; We call this project modular to make the invocation: lein new modular appname
-(defproject modular/lein-template "0.6.8"
+(defproject modular/lein-template "0.6.9"
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}


Remove the unnecessary apply.

Remove the unnecessary apply.

--- src-cljs/githubcomments/core.cljs
+++ src-cljs/githubcomments/core.cljs
@@ -28,7 +28,6 @@
             repo [(dataset/get element "repositoryOwner")
                   (dataset/get element "repositoryName")]
             response (async/<! (repo-comments repo))]
-        (apply display-comments
-               [(rendered-comments repo (:body response)) element]))))
+        (display-comments (rendered-comments repo (:body response)) element))))

 (init)


Getting system-test's world to start

Getting system-test's world to start

Well, getting it closer

--- test/com/frereth/server/system_test.clj
+++ test/com/frereth/server/system_test.clj
@@ -16,18 +16,11 @@
        (-> world :control-socket :socket)))

 (deftest start-stop []
-  ;; Seems more than a little wrong to be using an atom here. Oh well.
-  (let [world (atom nil)
-        inited (sys/init nil)
-        ;; Avoid both reserved and ephemeral ports
-        ;; At least on most systems.
-        auth-port (+ (rand-int 48109) 1025)
-        action-port (+ (rand-int 48109) 1025)
-        overridden (-> inited
-                       (update-in [:auth-socket :url :port] (constantly auth-port))
-                       (update-in [:action-socket :url :port] (constantly action-port)))]
-    (comment (println "Overridden World:\n" (util/pretty overridden)))
-    (reset! world overridden)
+  (let [initial-options {:event-loop {:url {:cljeromq.common/port (+ (rand-int 48109) 1025)}}}
+        ;; Seems more than a little wrong to be using an atom here. Oh well.
+        ;; Q: Why did I make that particular decision?
+        world (atom initial-options)]
+    (swap! world sys/init)
     (is (not (active? @world)) "World created in active state")

     ;; N.B. if this throws an exception, all bets are off.
@@ -50,15 +43,13 @@
           ;; In all fairness, it should. I just really didn't want to
           ;; deal with that tonight.
           (swap! world component/stop)
-          (is (not (active? world)) "World stopped")))
+          (is (not (active? @world)) "World stopped")))
       (catch ExceptionInfo ex
         (let [data (.getData ex)
-              msg (str "Failed to start system:\n"
+              cause (.getCause ex)
+              msg (str "system-test/start-stop Failed to start system:\n"
                        ex
-                       "\nDetails:\n"
-                       (util/pretty data)
-                       "\nThere's a good chance this is related to either port "
-                       auth-port " or " action-port
-                       "\nHopefully this doesn't cause serious problems, but it probably will")]
+                       "\nCause:\n"
+                       (util/pretty cause))]
           (println msg))
         (is false "TODO: Just use bind-random-port instead")))))


Less verbose logs (no logs)

Less verbose logs (no logs)

--- storm-core/src/clj/org/apache/storm/pacemaker/pacemaker.clj
+++ storm-core/src/clj/org/apache/storm/pacemaker/pacemaker.clj
@@ -30,7 +30,7 @@

 ;; Stats Functions

-(def sleep-seconds 5)
+(def sleep-seconds 60)

 (defn- check-and-set-loop [stats key new & {:keys [compare new-fn]
@@ -71,12 +71,12 @@
             largest (.getAndSet (:largest-heartbeat-size stats) 0)
             average (.getAndSet (:average-heartbeat-size stats) 0)
             total-keys (.size heartbeats)]
-        (log-message "\nReceived " send-count " heartbeats totaling " received-size " bytes,\n"
-                     "Sent " get-count " heartbeats totaling " sent-size " bytes,\n"
-                     "The largest heartbeat was " largest " bytes,\n"
-                     "The average heartbeat was " average " bytes,\n"
-                     "Pacemaker contained " total-keys " total keys\n"
-                     "in the last " sleep-seconds " second(s)")
+        (log-debug "\nReceived " send-count " heartbeats totaling " received-size " bytes,\n"
+                   "Sent " get-count " heartbeats totaling " sent-size " bytes,\n"
+                   "The largest heartbeat was " largest " bytes,\n"
+                   "The average heartbeat was " average " bytes,\n"
+                   "Pacemaker contained " total-keys " total keys\n"
+                   "in the last " sleep-seconds " second(s)")
         (dosync (ref-set last-five-s
                          {:send-pulse-count send-count
                           :total-received-size received-size


get fixpoint working

get fixpoint working

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

--- src/aurora/compiler/datalog.cljs
+++ src/aurora/compiler/datalog.cljs
@@ -196,7 +196,7 @@
     (let [new-kn (rule kn)]
       (if (= new-kn kn)
         new-kn
-        (recur kn)))))
+        (recur new-kn)))))

 ;; tests


links to check lists from overview

links to check lists from overview

--- src/checkmate/views/overview.clj
+++ src/checkmate/views/overview.clj
@@ -1,5 +1,6 @@
 (ns checkmate.views.overview
-  (:require [clojure.string :as string]))
+  (:require [clojure.string :as string]
+            [hiccup.element :as elm]))

 (defn render-group [group]
   (let [ordered (sort-by first group)]
@@ -8,7 +9,7 @@
        [:div
         [:h4 (string/upper-case letter)]
         (for [i items]
-          [:div (:name i)])])]))
+          [:div (elm/link-to (str "/show/" (:_id i)) (:name i))])])]))

 (defn render [lists]
   (let [grouped (group-by (comp first :name) lists)]


Cover new syntax features with tests

Cover new syntax features with tests

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -27,6 +27,14 @@
        "SELECT asd FROM \"table-name\";"
        (select "table-name"
                (column "asd"))))
+
+  (is (renders-to
+       "SELECT * FROM foo;"
+       (select (all) (from :foo))))
+
+  (is (renders-to
+       "SELECT * FROM foo.bar;"
+       (select (all) (from :foo :bar))))

   (is (renders-to
        "SELECT first,second FROM \"table-name\";"


State reset

State reset

--- src/clj_gamification/handler.clj
+++ src/clj_gamification/handler.clj
@@ -5,6 +5,7 @@
             [hiccup.page :refer [html5]]
             [ring.util.response :refer [redirect]]
             [ring.middleware.session :refer [wrap-session]]
+            [ring.middleware.session.memory :refer [memory-store]]
             [clojure.pprint]))

 (def state (atom :not-started))
@@ -12,6 +13,7 @@
 (def teams (atom {}))
 (def votes (atom {}))
 (def voter-ips (atom #{}))
+(def session-atom (atom {}))

 (defn toint [numstr] (Integer/parseInt numstr))

@@ -116,6 +118,17 @@
                            "Thank you for your vote!"
                            (page-vote)))))

+(defn reset-state []
+  "Reset GM, teams, votes etc. to be able to start from scratch. CAVEATS: Stuff saved in people's session won't be reset."
+  ;; => Consider using a random string as part of the session key
+  (reset! state :not-started)
+  (reset! team-counter 1)
+  (reset! teams {})
+  (reset! votes {})
+  (reset! voter-ips #{})
+  (clojure.pprint/pprint @session-atom)
+  (reset! session-atom {}))
+
 (defroutes app-routes
   "/ - depending on the current stage, show either game master's page, team-registration page, or voting page
    /team - new team registration, idea publication
@@ -155,11 +168,19 @@
            #_(POST "/start-brainstorming" [] (str (compare-and-set! state :oldstate :newstate))) ;; CURRENTLY NOT NEEDED
            (POST "/start-voting" [] (str (compare-and-set! state :brainstorming :voting)))
            (POST "/show-voting-results" [] (str (compare-and-set! state :voting :voting-finished))))
+  (GET "/reset" [sure]
+       (if sure
+         (do
+           (reset-state)
+           "Done resetting the state!")
+         (page "Reset"
+               [:p "Do you really want to reset the state, teams, votes? "
+                [:a {:href "/reset?sure=yes"} "Sure, reset it all!"]])))
   (route/resources "/")
   (route/not-found "Not Found"))

 (def app
   (-> (handler/site app-routes)
-      wrap-session))
+      (wrap-session {:store (memory-store session-atom)})))

-;; TIME USED: 3.5 + 1h
+;; TIME USED: (time-in-hrs + 3.5 1.5 1)


fix busy state in UI

fix busy state in UI

--- src/cljs/iwaswhere_web/core.cljs
+++ src/cljs/iwaswhere_web/core.cljs
@@ -16,7 +16,7 @@
 (def sente-cfg {:relay-types #{:entry/update :entry/find :entry/trash
                                :import/geo :import/photos :import/phone
                                :import/spotify :import/flight
-                               ;:cmd/keep-alive
+                               :cmd/keep-alive
                                :stats/pomo-day-get
                                :stats/get :stats/get2 :import/movie :blink/busy
                                :state/stats-tags-get :import/weight
@@ -57,8 +57,7 @@
      [:cmd/route {:from :client/scheduler-cmp
                   :to   #{:client/store-cmp
                           :client/ws-cmp}}]])
-  ;(ka/init-keepalive! switchboard)
-  )
+  (ka/init-keepalive! switchboard))

 (init!)


Functions for asking about castling rights.

--- src/clojure/clj_chess/board.cljc
+++ src/clojure/clj_chess/board.cljc
@@ -98,6 +98,28 @@
   "The piece on a given square."
   [board square]
   (.pieceOn board square))
+
+(defn can-castle-kingside?
+  "Tests whether the given side still has the right to castle kingside."
+  [board side]
+  (.canCastleKingside board (if (= side :white) 0 1)))
+
+(defn can-castle-queenside?
+  "Tests whether the given side still has the right to castle kingside."
+  [board side]
+  (.canCastleQueenside board (if (= side :white) 0 1)))
+
+(defn castle-rights
+  "Castle rights, a subset of #{:white-oo :white-ooo :black-oo :black-ooo}"
+  [board]
+  (into #{}
+        (concat
+          (for [[c k] (map vector (range) [:white-oo :black-oo])
+                :when (can-castle-kingside? board c)]
+            k)
+          (for [[c k] (map vector (range) [:white-ooo :black-ooo])
+                :when (can-castle-queenside? board c)]
+            k))))

 (defn last-move
   "The last move played to reach this board position, or nil if we are at


Remove unneeded and side-effecting user.clj

--- lein-light-nrepl/src/user.clj
+++ lein-light-nrepl/src/user.clj
@@ -1,2 +0,0 @@
-(ns user
-  (:require [clojure.repl :refer :all]))


provide a standard (defn generate) variant which takes no arguments

--- src/babel/espanol.cljc
+++ src/babel/espanol.cljc
@@ -56,22 +56,30 @@
   ((:lookup (medium)) lexeme))

 (defn generate
-  [spec & {:keys [max-total-depth model truncate-children]
-           :or {max-total-depth generate/max-total-depth
-                model nil
-                truncate-children false}}]
-  (log/debug (str "generating with spec: " (strip-refs spec) " with max-total-depth: " max-total-depth))
-  (if (nil? model)
-    (let [error-message
-          (str "you must supply a model to do generation.")]
-      (log/error error-message)
-      (throw (Exception. error-message))))
-  (let [result (generate/generate spec model
-                                  :max-total-depth max-total-depth
-                                  :truncate-children truncate-children)]
-    (if result
-      (conj {:surface (fo result)}
-            result))))
+  ([]
+   (let [max-total-depth generate/max-total-depth
+         truncate-children true
+         model (medium)]
+     (generate {:modified false}
+               :max-total-depth max-total-depth
+               :truncate-children true
+               :model model)))
+  ([spec & {:keys [max-total-depth model truncate-children]
+            :or {max-total-depth generate/max-total-depth
+                 model nil
+                 truncate-children false}}]
+   (log/debug (str "generating with spec: " (strip-refs spec) " with max-total-depth: " max-total-depth))
+   (if (nil? model)
+     (let [error-message
+           (str "you must supply a model to do generation.")]
+       (log/error error-message)
+       (throw (Exception. error-message))))
+   (let [result (generate/generate spec model
+                                   :max-total-depth max-total-depth
+                                   :truncate-children truncate-children)]
+     (if result
+       (conj {:surface (fo result)}
+             result)))))

 (defn preprocess [input]
   "arbitrary regexp replacements to convert Spanish orthography into a parsable whitespace-delimited expression"


Make MIDI input node a bit larger

Make MIDI input node a bit larger

--- src/alder/node-type.cljs
+++ src/alder/node-type.cljs
@@ -243,7 +243,7 @@
              nil
              false
              "MIDI Note"
-             [110 40]
+             [110 80]
              #(js/MIDINoteNode. %)
              {:constructor "new MIDINoteNode(context)"
               :dependencies {"MIDINoteNode" ["audio/midi_note_node"


Log request time (synchronous calls mean it's quite slow at the moment) ~ 14 seconds with lots of builds and release environments

--- src/build_mon/core.clj
+++ src/build_mon/core.clj
@@ -4,16 +4,17 @@
             [ring.middleware.params :as params]
             [bidi.bidi :as bidi]
             [cheshire.core :as json]
+            [clj-time.core :as t]
             [build-mon.vso-api :as api]
             [build-mon.vso-release-api :as release-api]
             [build-mon.html :as html])
   (:gen-class))

 (def logger {:log-exception (fn [message exception]
-                              (prn "=========   ERROR   ==========")
-                              (prn message)
-                              (prn exception)
-                              (prn "=============================="))})
+                              (println "=========   ERROR   ==========")
+                              (println message)
+                              (println exception)
+                              (println "=============================="))})

 (def states-ordered-worst-first [:failed :in-progress-after-failed :in-progress :succeeded])

@@ -25,11 +26,11 @@
 (defn in-progress? [build] (nil? (:result build)))

 (defn- get-release-state [release-env previous-release-env]
-    (cond (release-succeeded? release-env) :succeeded
-          (and (release-in-progress? release-env) (release-succeeded? previous-release-env)) :in-progress
-          (and (release-in-progress? release-env) (not (release-succeeded? previous-release-env))) :in-progress-after-failed
-          (release-not-started? release-env) :not-started
-          :default :failed))
+  (cond (release-succeeded? release-env) :succeeded
+        (and (release-in-progress? release-env) (release-succeeded? previous-release-env)) :in-progress
+        (and (release-in-progress? release-env) (not (release-succeeded? previous-release-env))) :in-progress-after-failed
+        (release-not-started? release-env) :not-started
+        :default :failed))

 (defn get-state [build previous-build]
   (cond (succeeded? build) :succeeded
@@ -44,18 +45,18 @@
   (let [environments (-> release :environments)
         previous-environments (-> previous-release :environments)]
     (map (fn [env]
-      (let [prev-env-release (filter (fn [prev-env]
-                                (= (:name env) (:name prev-env)))
-                                previous-environments)
-        release-state (get-release-state env prev-env-release)]
-        {:env-name (:name env) :state release-state}))
-     environments)))
+           (let [prev-env-release (filter (fn [prev-env]
+                                            (= (:name env) (:name prev-env)))
+                                          previous-environments)
+                 release-state (get-release-state env prev-env-release)]
+             {:env-name (:name env) :state release-state}))
+         environments)))

 (defn- generate-release-info [release previous-release]
-   {:release-definition-name (-> :releaseDefinition release :name)
-    :release-definition-id (:id release)
-    :release-number (:name release)
-    :release-environments (generate-release-environments release previous-release)})
+  {:release-definition-name (-> :releaseDefinition release :name)
+   :release-definition-id (:id release)
+   :release-number (:name release)
+   :release-environments (generate-release-environments release previous-release)})

 (defn generate-build-info [build previous-build commit-message]
   (let [state (get-state build previous-build)]
@@ -104,13 +105,16 @@
         build-definition-ids (map :id build-definitions)]
     (universal-monitor-for-definition-ids vso-api vso-release-api request build-definition-ids release-definition-ids)))

-(def routes ["/" {"" :universal-monitor}])
+(def routes ["/" :universal-monitor])

 (defn wrap-routes [handlers]
   (fn [request]
-    (when-let [route-method (bidi/match-route routes (:uri request))]
-      (when-let [handler (-> route-method :handler handlers)]
-        (handler (merge request (select-keys route-method [:route-params])))))))
+    (let [request-start-time (t/now)]
+      (when-let [route (bidi/match-route routes (:uri request))]
+        (when-let [handler (-> route :handler handlers)]
+          (let [response (handler (merge request (select-keys route [:route-params])))]
+            (println "Response time:" (t/in-seconds (t/interval request-start-time (t/now))) "seconds")
+            response))))))

 (defn handlers [vso-api vso-release-api]
   {:universal-monitor (partial universal-monitor vso-api vso-release-api)})
@@ -118,22 +122,18 @@
 (defn -main [& [vso-account vso-project vso-personal-access-token port]]
   (let [port (Integer. (or port 3000))]
     (if (and vso-account vso-project vso-personal-access-token port)
-      (let [
-            vso-api (api/vso-api-fns logger
-                                    (api/vso-api-get-fn vso-personal-access-token)
+      (let [vso-api (api/vso-api-fns logger
+                                     (api/vso-api-get-fn vso-personal-access-token)
                                      vso-account
                                      vso-project)
             vso-release-api (release-api/vso-release-api-fns
-                                    logger
-                                    (release-api/vso-release-api-get-fn vso-personal-access-token)
-                                    vso-account
-                                    vso-project)
+                              logger
+                              (release-api/vso-release-api-get-fn vso-personal-access-token)
+                              vso-account
+                              vso-project)
             wrapped-handler (-> (handlers vso-api vso-release-api)
-                                    wrap-routes
-                                    (resource/wrap-resource "public")
-                                    (params/wrap-params))]
-        (println "==============================================================")
-        (println "Starting up... please enjoy your project monitor #repsforrufus")
-        (println "==============================================================")
+                                wrap-routes
+                                (resource/wrap-resource "public")
+                                (params/wrap-params))]
         (ring-jetty/run-jetty wrapped-handler {:port port}))
-      (prn "App didn't start due to missing parameters."))))
+      (println "App didn't start due to missing parameters."))))


Split prog-curr out of prog-history.

Split prog-curr out of prog-history.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -18,23 +18,23 @@
                           ;   :net-connect-ch => ch
                           ;   :res-ch => ch }

-(def prog-history
-  (atom {:prog-peers {:servers {}  ; { server-addr => ports }.
-                      :clients {}} ; { client-addr => client-info }.
-         :prog-events []})) ; Each event is [ts label args].
+(def prog-curr (atom {:servers {}    ; { server-addr => ports }.
+                      :clients {}})) ; { client-addr => client-info }.
+
+(def prog-history (atom [])) ; Each event is [ts label @prog-curr].

 (def run-world       (atom nil))
 (def run-world-hover (atom nil))

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

-(defn render-world [app owner]
+(defn render-world [prog-curr owner]
   (apply dom/ul nil
          (map (fn [[k v]] (dom/li nil (str k ":" (count v))))
-              (:prog-peers app))))
-
-(defn on-event-focus [ts label args]
-  (reset! run-world-hover args)
+              prog-curr)))
+
+(defn on-event-focus [ts label prog-curr]
+  (reset! run-world-hover prog-curr)
   (.add gdom/classes (gdom/getElement "world-container") "hover"))

 (defn on-event-blur []
@@ -43,17 +43,17 @@

 (defn render-events [app owner]
   (apply dom/ul nil
-         (map (fn [[ts label args]]
-                (dom/li #js {:onMouseEnter #(on-event-focus ts label args)
+         (map (fn [[ts label prog-curr]]
+                (dom/li #js {:onMouseEnter #(on-event-focus ts label prog-curr)
                              :onMouseLeave #(on-event-blur)}
-                        (str ts (apply str label) args)))
-              (:prog-events app))))
+                        (str ts (apply str label) prog-curr)))
+              app)))

 (defn render-clients [app owner]
   (apply dom/select #js {:id "client"}
          (map (fn [client-addr]
                 (dom/option #js {:value client-addr} (str client-addr)))
-              (keys (:clients (:prog-peers app))))))
+              (keys (:clients app)))))

 (defn init-roots []
   (om/root render-world run-world
@@ -66,7 +66,7 @@
            {:target (. js/document (getElementById "world-map-hover"))})
   (om/root render-events prog-history
            {:target (. js/document (getElementById "events"))})
-  (om/root render-clients prog-history
+  (om/root render-clients prog-curr
            {:target (. js/document (getElementById "controls-clients"))}))

 ; ------------------------------------------------
@@ -135,8 +135,7 @@
           (act-loop cmd-dispatch-loop world [num-dispatches 0]
                     (when-let [msg (atake cmd-dispatch-loop req-ch)]
                       (when-let [client-req-ch
-                                 (get-in @prog-history
-                                         [:prog-peers :clients (:client msg) :req-ch])]
+                                 (get-in @prog-curr [:clients (:client msg) :req-ch])]
                         (aput cmd-dispatch-loop client-req-ch msg))
                       (recur (inc num-dispatches))))
           (println :prog-res prog-res)
@@ -168,11 +167,8 @@
 ; --------------------------------------------

 (defn prog-event [label f]
-  (swap! prog-history #(let [ph (f %)]
-                         (update-in ph [:prog-events]
-                                    conj [(count (:prog-events ph))
-                                          label
-                                          {:prog-peers (:prog-peers ph)}]))))
+  (let [pc (swap! prog-curr f)]
+    (swap! prog-history #(conj % [(count %) label pc]))))

 (defn kv-server [server-addr & ports]
   (let [world (:world @prog-base)
@@ -185,7 +181,7 @@
              (when-let [[accept-ch close-accept-ch] (atake server-init listen-result-ch)]
                (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch)
                (prog-event [:kv-server server-addr port]
-                           #(update-in % [:prog-peers :servers server-addr]
+                           #(update-in % [:servers server-addr]
                                        conj port)))))
          (reset! done true))
     (wait-done done)))
@@ -198,7 +194,7 @@
                                                   server-addr server-port
                                                   client-addr (:res-ch @prog-base))]
            (prog-event [:kv-client client-addr server-addr server-port]
-                       #(assoc-in % [:prog-peers :clients client-addr]
+                       #(assoc-in % [:clients client-addr]
                                   {:client-addr client-addr
                                    :server-addr server-addr
                                    :server-port server-port


Added cur-realm-collset/coll to lane-state.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -46,7 +46,11 @@
                       :collsets {}}}})

 (def initial-lane-state
-  {:cur-realm "_lobby" :cur-user-realm "_lobby" :cur-user "_anon"})
+  {:cur-realm "_lobby"
+   :cur-realm-collset "default"
+   :cur-realm-collset-coll "default"
+   :cur-user-realm "_lobby"
+   :cur-user "_anon"})

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

@@ -60,6 +64,7 @@
         [server-state (assoc (dissoc m :pswd) :status :ok)]
         [server-state (assoc (dissoc m :pswd) :status :invalid)])
       [server-state (assoc (dissoc m :pswd) :status :invalid)])
+
     "realms-list"
     (if-let [{:keys [cur-user-realm cur-user]} m]
       (let [realm-keys (if (and (= cur-user-realm "_system")
@@ -75,6 +80,7 @@
                                 (assoc m :status :ok))))
         [server-state nil])
       [server-state (assoc m :status :not-authenticated)])
+
     nil))

 ; --------------------------------------------
@@ -84,16 +90,19 @@
     :update-user-realm
     [(assoc lane-state
        :cur-realm (:realm m)
+       :cur-realm-collset (:realm-collset m)
+       :cur-realm-collset-coll (:realm-collset-coll m)
        :cur-user-realm (:user-realm m)
        :cur-user (:user m))
      (assoc m :status :ok)]
+
     "lane-state"
     [lane-state (assoc m :status :ok :value lane-state)]
+
     "realms-list"
-    (do (msg-put actx :server-state-ch
-                 (assoc m :cur-user-realm (:cur-user-realm lane-state)
-                        :cur-user (:cur-user lane-state)))
+    (do (msg-put actx :server-state-ch (merge m lane-state))
         [lane-state nil])
+
     nil))

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


Clarify a confusing log message. (#1193)

--- scheduler/src/cook/kubernetes/controller.clj
+++ scheduler/src/cook/kubernetes/controller.clj
@@ -62,8 +62,8 @@
       (= "Error" (.getReason terminated)) :reason-command-executor-failed
       (= "OOMKilled" (.getReason terminated)) :reason-container-limitation-memory
       :default (do
-                 (log/warn "Unable to determine kubernetes state for pod" {:pod-status pod-status
-                                                                           :container-status status})
+                 (log/warn "Unable to determine kubernetes failure reason for pod" {:pod-status pod-status
+                                                                                :container-status status})
                  :unknown))))

 (defn write-status-to-datomic


support numbers as children

support numbers as children

--- src/cellophane/dom.clj
+++ src/cellophane/dom.clj
@@ -296,10 +296,11 @@
                                    (assoc (p/-render c) :react-key
                                      (some-> (p/-props c) :cellophaneclj$reactKey))

-                                   (string? c)
-                                   (if (> child-node-count 1)
-                                     (span nil c)
-                                     (text-node c))
+                                   (or (string? c) (number? c))
+                                   (let [c (cond-> c (number? c) str)]
+                                     (if (> child-node-count 1)
+                                       (span nil c)
+                                       (text-node c)))
                                    (nil? c) nil
                                    :else (do
                                            (println "invalid child element:" c (class c))


Subject: [PATCH] Updated the server module

--- src/arachnida/server.clj
+++ src/arachnida/server.clj
@@ -7,6 +7,41 @@

 (require '[hiccup.page :as page])
 (require '[hiccup.form :as form])
+
+(require '[arachnida.db-interface :as db-interface])
+(require '[arachnida.calendar     :as calendar])
+
+(defn read-stat-per-weeks
+    [first-day last-day]
+    (let [stat (first
+        (db-interface/read-stat-per-weeks-from-db first-day last-day))]
+        {:deletions     (or (:deletions stat) 0)
+         :insertions    (or (:insertions stat) 0)
+         :commits-count (or (:commits_count stat) 0)
+         :files-changed (or (:files_changed stat) 0)}))
+
+(defn read-stat-per-weeks-for-author
+    [first-day last-day author]
+    (if (and author (pos? (count author)))
+        (let [stat (first
+            (db-interface/read-stat-per-weeks-for-author-from-db first-day last-day author))]
+            {:deletions     (or (:deletions stat) 0)
+             :insertions    (or (:insertions stat) 0)
+             :commits-count (or (:commits_count stat) 0)
+             :files-changed (or (:files_changed stat) 0)})
+            {:deletions     0
+             :insertions    0
+             :commits-count 0
+             :files-changed 0}))
+
+(defn read-stat-for-week
+    [week author]
+    (if (and week author)
+        (let [calendar  (calendar/get-calendar-for-week 2015 (Integer. week))
+              first-day (calendar/get-first-day-of-week-formatted calendar)
+              last-day  (calendar/get-last-day-of-week-formatted calendar)]
+              {:statistic-for-week (db-interface/read-statistic-for-week-from-db first-day last-day author)
+               :commits-for-week   (db-interface/read-commits-for-week first-day last-day author)})))

 (defn file-operation
     [operation]
@@ -87,16 +122,16 @@
                          [:td (:deletions s)]
                     ])]
             [:h1 "Commits for selected week"]
-                [:table
+                [:table {:border 1}
                 (for [s (:commits-for-week stat-for-week)]

                     [:tr (if (= (str (:id s)) commit-id) {:style "background-color:yellow"})
-                         [:td (:project s)]
+                         [:td (:product s)]
                          [:td (:repo s)]
                          [:td (:branch s)]
+                         [:td (:date s)]
                          [:td [:a {:href (str "?author=" selected-author "&week=" selected-week "&commit-id=" (:id s))} (:sha s)]]
                          [:td (:message s)]
-                         [:td (:date s)]
                     ]
                 )]
             [:h1 "Changes made in selected commit"]
@@ -115,30 +150,39 @@
           (-> (http-response/response html-output)
               (http-response/content-type "text/html; charset=utf-8"))))

+(defn get-weeks-stat
+    [last-week author]
+    (for [week (range 1 (inc last-week))]
+    (let [calendar  (calendar/get-calendar-for-week 2015 week)
+          first-day (calendar/get-first-day-of-week-formatted calendar)
+          last-day  (calendar/get-last-day-of-week-formatted calendar)
+          stat-for-all (read-stat-per-weeks first-day last-day)
+          stat-for-author (read-stat-per-weeks-for-author first-day last-day author)]
+          {:week      week
+           :first-day first-day
+           :last-day  last-day
+           :stat-for-all stat-for-all
+           :stat-for-author stat-for-author})))
+
 (defn handler
     [request]
     (let [params          (:params  request)
           cookies         (:cookies request)
           selected-author (get params "author")
-          selected-week   (get params "week")
+          selected-week   (or (get params "week") "1")
           commit-id       (get params "commit-id")
-;         authors         (read-authors)
-;         last-week       (get-week (get-calendar))
-;         weeks-stat      (get-weeks-stat last-week selected-author)
-;         stat-for-week   (read-stat-for-week selected-week selected-author)
-;         commit-info     (read-commit-info commit-id)
-          authors nil
-          weeks-stat nil
-          last-week nil
-          stat-for-week nil
-          commit-info nil
+          authors         (db-interface/read-authors)
+          last-week       (calendar/get-week (calendar/get-calendar))
+          weeks-stat      (get-weeks-stat last-week selected-author)
+          stat-for-week   (read-stat-for-week selected-week selected-author)
+          commit-info     (db-interface/read-commit-info commit-id)
           ]
- ;         (println "Author:" selected-author)
- ;         (println "Authors:" authors)
- ;         (println "Weeks: " weeks-stat)
- ;         (println "Stat4week " stat-for-week)
+          (println "Author:" selected-author)
+          (println "Authors:" authors)
+          (println "Weeks: " weeks-stat)
+          (println "Stat4week " stat-for-week)
           (println "Commit ID: " commit-id)
- ;         (println "Commit info " commit-info)
+          (println "Commit info " commit-info)
         (let [response (generate-response authors selected-author weeks-stat selected-week stat-for-week commit-id commit-info)]
               (println "Outgoing cookies: " (get response :cookies))
               response)))


Data preparation for author and week page

--- src/arachnida/server.clj
+++ src/arachnida/server.clj
@@ -300,7 +300,6 @@
           statistic   (db-interface/read-statistic-for-author author-name)
           last-week       (calendar/get-week (calendar/get-calendar))
           weeks-stat      (get-weeks-stat last-week author-name)
-          stat-for-week   (read-stat-for-week last-week author-name)
           week-graph-data [{:values (get-data weeks-stat :stat-for-author :commits-count) :label "Commits"}
                            {:values (get-data weeks-stat :stat-for-author :files-changed) :label "Files changed"}
                            {:values (get-data weeks-stat :stat-for-author :deletions) :label "Deletions"}
@@ -314,6 +313,17 @@
         (-> (html-renderer/render-author-page author-name statistic weeks-stat last-week week-graph-data cummulative-graph-data)
             continue-processing)))

+(defn perform-author-week-page
+    [request]
+    (let [params          (:params request)
+          author-name     (get params "name")
+          selected-week   (get params "week")
+          weeks-stat      (get-weeks-stat (Integer/parseInt selected-week) author-name)
+          stat-for-week   (read-stat-for-week selected-week author-name)
+          ]
+        (-> (html-renderer/render-author-week-page author-name selected-week stat-for-week)
+            continue-processing)))
+
 (defn perform-product-page
     [request]
     (let [params (:params request)
@@ -358,6 +368,7 @@
         (condp = uri
             "/"                                 (perform-index-page request)
             "/author"                           (perform-author-page request)
+            "/author-week"                      (perform-author-week-page request)
             "/product"                          (perform-product-page request)
             "/favicon.ico"                      (return-icon uri)
             "/bootstrap.min.css"                (return-css uri)


make name/type encoder non-configurable in SQL parser

--- src/asphalt/internal.clj
+++ src/asphalt/internal.clj
@@ -98,7 +98,10 @@
                    :timestamp  sql-timestamp})

-(def supported-sql-types (set (keys sql-type-map)))
+(def supported-sql-types (str "either of " (->> (keys sql-type-map)
+                                             (remove nil?)
+                                             (map name)
+                                             (str/join ", "))))

 (defrecord SQLTemplate
@@ -125,29 +128,21 @@
   ^SQLTemplate [sql param-pairs result-column-types]
   (when-not (string? sql)
     (unexpected "SQL string" sql))
-  (when-not (and (vector? param-pairs)
-              (every? vector? param-pairs)
-              (every? #(<= 1 (count %) 2) param-pairs))
-    (unexpected "param-pairs vector with 1 or 2 element vectors of param name and optional type" param-pairs))
-  (when-not (vector? result-column-types)
-    (unexpected "result-column-types vector" result-column-types))
-  (let [param-types (map second param-pairs)]
-    (when-not (every? #(contains? supported-sql-types %) param-types)
-      (unexpected (str "every param type to be one of " supported-sql-types) param-pairs)))
-  (when-not (every? #(contains? supported-sql-types %) result-column-types)
-    (unexpected (str "every result column type to be one of " supported-sql-types) result-column-types))
-  (->SQLTemplate sql
-    ;; param names and types
-    (->> param-pairs
-      (map (fn [[k t]] [k (get sql-type-map t)]))
-      object-array)
-    ;; result types
-    (->> result-column-types
-      (map sql-type-map)
-      int-array)))
+  (->SQLTemplate sql (object-array param-pairs) (int-array result-column-types)))

 ;; ----- SQL parsing helpers -----
+
+
+(def encode-name keyword)
+
+
+(defn encode-type
+  [^String token ^String sql]
+  (let [k (keyword token)]
+    (when-not (contains? sql-type-map k)
+      (unexpected (str supported-sql-types " in SQL string: " sql) token))
+    (get sql-type-map k)))

 (defn valid-type-char?
@@ -224,7 +219,7 @@
       #_sql-string     11 (.setString    prepared-statement param-index ^String param-value)
       #_sql-time       12 (.setTime      prepared-statement param-index ^java.sql.Time param-value)
       #_sql-timestamp  13 (.setTimestamp prepared-statement param-index ^java.sql.Timestamp param-value)
-      (unexpected (str "either of " (pr-str supported-sql-types)) param-type))))
+      (unexpected supported-sql-types param-type))))

 (defn set-params!
@@ -292,7 +287,7 @@
       #_sql-string     11 (.getString    result-set column-index)
       #_sql-time       12 (.getTime      result-set column-index)
       #_sql-timestamp  13 (.getTimestamp result-set column-index)
-      (unexpected (str "either of " (pr-str supported-sql-types)) column-type))))
+      (unexpected supported-sql-types column-type))))

 (defn read-result-row


Print all leaf nodes

Print all leaf nodes

--- src/atom_finder/core.clj
+++ src/atom_finder/core.clj
@@ -83,9 +83,50 @@
                      (-> node .getRawSignature (.replaceAll "\n" " \\ "))
                      (-> node .getRawSignature (.subSequence 0 5))))))]

-     (pre-tree f node)))
+    (pre-tree f node)))
+
+(defn depth [node]
+  (inc
+   (apply max 0
+          (map depth
+               (.getChildren node)))))
+
+(defn leaf? [node] (empty? (.getChildren node)))
+
+(defn leaves [node]
+  (if (leaf? node)
+    node
+    (flatten (map leaves (.getChildren node)))))
+
+(defn node-str [node]
+  (let [stx (.getSyntax node)]
+        (if (nil? stx)
+          "nil"
+          (.getImage stx))))
+
+(map node-str (leaves root))
+
+;; http://stackoverflow.com/questions/23178750/iteratively-apply-function-to-its-result-without-generating-a-seq
+(defn fn-pow
+  [f x n]
+    (nth (iterate f x) n))
+
+(defn ancestor
+  "Get the nth grandparent of the node"
+  [n node]
+  (fn-pow #(.getParent %) node n))
+
+(defn filter-size
+  "Return every sub-tree of size n"
+  [n node]
+
+  (distinct (map #(ancestor n %) (leaves node))))
+
+(filter-size 3 root)
+

 (def filename "/Users/dgopstein/nyu/confusion/atoms/simplifications/2000-natori/nonconfusing.c")
+(def root (translation-unit filename))

 (defn -main
   [& args]
@@ -94,6 +135,6 @@

   (visit-ast filename)
   (ast-visitor-proxy)
-  (print-tree (translation-unit filename))
-  (pre-tree #(-> % .getClass .getSimpleName) (translation-unit filename))
+  (print-tree root)
+  (pre-tree #(-> % .getClass .getSimpleName) root)
   )


Include search engine in corpus hashmap

Include search engine in corpus hashmap

--- src/clj/cglossa/db.clj
+++ src/clj/cglossa/db.clj
@@ -99,7 +99,7 @@

 (defn get-corpus [code]
   (let [ress (sql-query (str "SELECT @rid as corpus_rid, name as corpus_name, "
-                             "logo, has_phonetic, has_headword_search, "
+                             "logo, search_engine, has_phonetic, has_headword_search, "
                              "$cats.@rid as cat_rids, $cats.code as cat_codes, "
                              "$cats.name as cat_names "
                              "FROM Corpus "
@@ -112,6 +112,7 @@
     {:corpus              {:rid                 (:corpus_rid res)
                            :name                (:corpus_name res)
                            :logo                (:logo res)
+                           :search-engine       (:search_engine res :cwb)
                            :has-phonetic        (:has_phonetic res)
                            :has-headword-search (:has_headword_search res)}
      :metadata-categories (-> (map (fn [rid name] {:rid rid :name name})


Snitch fix

Snitch fix

--- src/clj/game/cards.clj
+++ src/clj/game/cards.clj
@@ -1810,7 +1810,7 @@
    {:abilities [{:once :per-run :req (req current-ice) :msg (msg "expose " (:title current-ice))
                  :effect (effect (expose current-ice)
                                  (resolve-ability {:optional {:prompt "Jack out?" :msg "jack out"
-                                                              :effect (effect (jack-out))}}
+                                                              :effect (effect (jack-out nil))}}
                                                   card nil))}]}

    "Space Camp"


Enable ssl config in irc

Enable ssl config in irc

--- src/yetibot/core/adapters/irc.clj
+++ src/yetibot/core/adapters/irc.clj
@@ -161,6 +161,7 @@
     conn
     (irc/connect
       (:host (config)) (read-string (or (:port (config)) "6667")) (:username (config))
+      :ssl? (:ssl? (config))
       :callbacks callbacks)))

 (defn join-channels []


Fix typo in refactored validate-dmx-value.

--- src/afterglow/effects/util.clj
+++ src/afterglow/effects/util.clj
@@ -101,4 +101,4 @@
   ([value]
    (validate-dmx-value "value"))
   ([value name]
-   (validate-value 0 255 name)))
+   (validate-value value 0 255 name)))


(maint) Attempting to connect to closed broker causes exception

Attempting to connect to a broker that's rejecting connections because
it's not connected to a controller now returns a 404. 404 during
websocket handshake results in an IllegalStateException, which gets
propagated via an ExecutionException. Expect an exception when trying to
connect.

--- test/integration/puppetlabs/pcp/broker/controllers_test.clj
+++ test/integration/puppetlabs/pcp/broker/controllers_test.clj
@@ -305,7 +305,7 @@
           (let [{:keys [broker]} (get-context app :BrokerService)
                 database (:database broker)]
             (testing "client connections disallowed when no controller is connected"
-              (is (nil? (client/connect :certname agent-cert))))
+              (is (thrown? Exception (client/connect :certname agent-cert))))
             (testing "broker state is error on start (no controllers connected)"
               (is (= :error (:state (core/status broker :info)))))
             (testing "controller disconnection"


missing key error

missing key error

--- src/celestial/common.clj
+++ src/celestial/common.clj
@@ -12,6 +12,7 @@
 (ns celestial.common
   (:import java.util.Date)
   (:use
+    [slingshot.slingshot :only  [throw+ try+]]
     [celestial.config :only (config)]
     [clojure.core.strint :only (<<)]
     ))
@@ -21,7 +22,12 @@

 (import-logging)

-(defn get* [& keys] (get-in config keys))
+(defn get*
+  "Reading a keys path from configuration"
+  [& keys]
+  (if-let [v (get-in config keys)]
+    v
+    (throw+ {:type ::missing-conf :message (<< "No matching configuration keys ~{keys} found")})))

 (defn slurp-edn [file] (read-string (slurp file)))


clojure: laid out skeleton for new morphism function

--- clojure/org/gavrog/clojure/pgraph_morphisms.clj
+++ clojure/org/gavrog/clojure/pgraph_morphisms.clj
@@ -1,5 +1,5 @@
 (ns org.gavrog.clojure.pgraph-morphisms
-  (:use (org.gavrog.clojure.common [util :only [bfs]]))
+  (:use (org.gavrog.clojure.common [util :only [empty-queue]]))
   (:import (org.gavrog.joss.pgraphs.basic
              PeriodicGraph$CoverNode Morphism Morphism$NoSuchMorphismException)
            (org.gavrog.joss.pgraphs.io Net)
@@ -101,12 +101,27 @@
   (when (.isUnimodularIntegerMatrix M)
     (let [sigs (node-signatures net)
           d (.minus (first (first (sigs w))) (first (first (sigs v))))
-          op (.times (Operator. (extend-matrix M)) (Operator. d))]
-      (if (= (map-sig op (sigs v)) (sigs w))
-        (println "@@" v w op " okay! @@"))
-      (try
-        (Morphism. v w op)
-        (catch Morphism$NoSuchMorphismException ex nil)))))
+          op (.times (Operator. (extend-matrix M)) (Operator. d))
+          check-sigs (fn [v w] (= (map-sig op (sigs v)) (sigs w)))]
+      (loop [src2img {}
+             q (into empty-queue [v w])]
+        (cond
+          (empty? q)
+          src2img
+
+          (= w (src2img v))
+          (recur src2img (pop q))
+
+          (not (and (check-sigs v w) (nil? (src2img v))))
+          nil
+
+          :else
+          (let [src2img (assoc src2img v w)]))))))
+
+(comment "previous version using Java:"
+  (try
+    (Morphism. v w op)
+    (catch Morphism$NoSuchMorphismException ex nil)))

 (defn symmetries [net]
   (let [bases (iterator-seq (.iterator (.characteristicBases net)))


Change button logic to jump to argument

Change button logic to jump to argument

--- src/discuss/references/main.cljs
+++ src/discuss/references/main.cljs
@@ -126,9 +126,9 @@
             author (:author data)]
         (bs/callout-info
           (dom/div #js {:className "pull-right"}
-                   (bs/button-default-sm #(save-statement-change-view data) (vlib/fa-icon "fa-check") " Auswählen"))
+                   (bs/button-default-sm #(com/jump-to-argument (:slug issue) (:uid argument)) (vlib/fa-icon "fa-check") " Auswählen"))
           (dom/a #js {:href    "javascript:void(0)"
-                      :onClick #(save-statement-change-view data)}
+                      :onClick #(com/jump-to-argument (:slug issue) (:uid argument))}
                  (dom/strong nil (:text argument)))         ; TODO this should not be only the first one
           (dom/div nil "Issue: " (:title issue))
           (dom/div nil "Autor: " (:nickname author)))))))


Added category title.

Added category title.

--- src/dragon/blog/content/data.clj
+++ src/dragon/blog/content/data.clj
@@ -53,6 +53,9 @@
   ([opts]
     (merge
       {:page-data {
+         ;; XXX the following line breaks sites that don't have a /blog prefix
+         ;;     and expect the  Selmer page data to
+         ;;     be "/"
          :base-path "/blog"
          :site-title (:site-title opts)
          :site-description (:site-description opts)
@@ -108,6 +111,7 @@
     (-> opts
         (base-data-fn)
         (assoc-in [:page-data :active] (name (:category-key opts)))
+        (assoc :category-title (:title opts))
         (dissoc :title :subtitle)
         (assoc :posts-data (or (:posts-data opts) posts)
                :posts-stats (posts-stats posts)


tweak docstring

tweak docstring

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -1119,8 +1119,9 @@
              ret))))))

 (defn watch
-  "Given a source which can be compiled, watch it for changes invoking build
-   then it does."
+  "Given a source directory, produce runnable JavaScript. Watch the source
+   directory for changes rebuliding when necessary. Takes the same arguments as
+   cljs.closure/build."
   ([source opts]
     (watch source opts
       (if-not (nil? env/*compiler*)


debug-log the build doc we tried to save in es

--- src/clj/runbld/store.clj
+++ src/clj/runbld/store.clj
@@ -1,17 +1,17 @@
 (ns runbld.store
   (:refer-clojure :exclude [get])
-  (:require [runbld.schema :refer :all]
-            [schema.core :as s])
-  (:require [clojure.core.async :as async
-             :refer [go go-loop chan >! <! alts! close!]]
+  (:require [clojure.core.async :as async]
             [clojure.string :as str]
+            [elasticsearch.connection :as conn]
+            [elasticsearch.connection.http :as http]
             [elasticsearch.document :as doc]
             [elasticsearch.indices :as indices]
-            [elasticsearch.connection :as conn]
-            [elasticsearch.connection.http :as http]
+            [runbld.io :as io]
+            [runbld.schema :refer :all]
             [runbld.util.date :as date]
-            [runbld.io :as io]
+            [runbld.util.debug :as debug]
             [runbld.vcs :refer [VcsRepo]]
+            [schema.core :as s]
             [slingshot.slingshot :refer [try+ throw+]])
   (:import (elasticsearch.connection Connection)))

@@ -120,6 +120,7 @@
         t (name DocType)
         id (:id d)
         es-addr {:index idx :type t :id id}]
+    (debug/log "Saving doc in ES:" d)
     (doc/update conn idx t id {:body {:doc d
                                       :doc_as_upsert true}
                                :query-params {:refresh true}})
@@ -231,10 +232,10 @@
   ([opts :- OptsElasticsearch]
    (let [BUFSIZE (-> opts :bulk-size)
          TIMEOUT_MS (-> opts :bulk-timeout-ms)
-         ch (chan BUFSIZE)
-         proc (go-loop [buf []]
+         ch (async/chan BUFSIZE)
+         proc (async/go-loop [buf []]
                 (let [timed-out (async/timeout TIMEOUT_MS)
-                      [x select] (alts! [ch timed-out])
+                      [x select] (async/alts! [ch timed-out])
                       newbuf
                       (cond
                         ;; got nil from the message chan, index buf,


move function closer to related functions

--- src/clj_money/import.clj
+++ src/clj_money/import.clj
@@ -140,6 +140,20 @@
     (trading/buy (:storage context) purchase))
   context)

+(defmethod ^:private import-transaction :transfer
+  [{:keys [storage accounts] :as context}
+   {:keys [from-account-id to-account-id] :as transaction}]
+  (let [from-commodity-account (accounts/find-by-id storage (accounts from-account-id))
+        from-account (accounts/find-by-id storage (:parent-id from-commodity-account))
+        to-commodity-account (accounts/find-by-id storage (accounts to-account-id))]
+    (trading/transfer (:storage context)
+                      (assoc transaction
+                             :transfer-date (:transaction-date transaction)
+                             :commodity-id (:commodity-id from-commodity-account)
+                             :from-account-id (:id from-account)
+                             :to-account-id (:parent-id to-commodity-account))))
+  context)
+
 ; This is maybe too specific to GnuCash. It would be better if the
 ; gnucash namespace did these lookups
 (defn- ensure-split-ids
@@ -152,20 +166,6 @@
                                (accounts commodity-account-id))]
       (assoc transaction :commodity-id (:commodity-id commodity-account)
                          :account-id (:parent-id commodity-account)))))
-
-(defmethod ^:private import-transaction :transfer
-  [{:keys [storage accounts] :as context}
-   {:keys [from-account-id to-account-id] :as transaction}]
-  (let [from-commodity-account (accounts/find-by-id storage (accounts from-account-id))
-        from-account (accounts/find-by-id storage (:parent-id from-commodity-account))
-        to-commodity-account (accounts/find-by-id storage (accounts to-account-id))]
-    (trading/transfer (:storage context)
-                      (assoc transaction
-                             :transfer-date (:transaction-date transaction)
-                             :commodity-id (:commodity-id from-commodity-account)
-                             :from-account-id (:id from-account)
-                             :to-account-id (:parent-id to-commodity-account))))
-  context)

 (defmethod ^:private import-transaction :split
   [context transaction]


Add support for putting :metadata.

Add support for putting :metadata.

--- src/clj_ravendb/rest.clj
+++ src/clj_ravendb/rest.clj
@@ -63,8 +63,8 @@
   ([client id document options]
    (bulk-operations! client [{:method "PUT"
                               :id id
-                              :document document
-                              :metadata {}}] options)))
+                              :document (dissoc document :metadata)
+                              :metadata (get document :metadata {})}] options)))

 (defn- query-index
   ([client query]
@@ -161,7 +161,7 @@
   (let [fragments (list url "Databases" database)
         address (clojure.string/join "/" fragments)
         oauth-header (ttl
-                       #(if enable-oauth?
+                       #(if enable-oauth?
                           (:body (get-req (req/oauth-token {:address oauth-url :api-key api-key :ssl-insecure? ssl-insecure?}))))
                        :ttl/threshold (* oauth-expiry-seconds 1000))
         load-replications (fn []


Switch flocking on and off with mouse click.

--- src/cljs/boids/core.cljs
+++ src/cljs/boids/core.cljs
@@ -7,14 +7,6 @@
 (ns boids.core
   (:require [quil.core :as q :include-macros true]
             [quil.middleware :as m :include-macros true]))
-
-(defn foo [greeting]
-  (if greeting
-    (str greeting "ClojureScript!")
-    (str "Hello, ClojureScript!")))
-
-
-(.write js/document (foo "Welcome to "))

 (defprotocol PVec
   (add [a b])
@@ -54,21 +46,22 @@
     {:boids     boids
      :obstacles [
                  {:position (multiply (Vector. (q/width) (q/height)) 0.5)
-                  :radius 50}]})
+                  :radius 50}]
+     :flock? true})

   )

-(defn update-boid [b bs os]
+(defn update-boid [b flock? bs os]
   ;(.profile js/console "update")
   (let [requested []
         nearby-boids (filter (partial not= b) (filter #(< (dist (:position b) (:position %)) 100) bs))

         ;; Avoid walls

-        requested (conj requested (multiply (Vector. -1 0) (/ 100 (q/sq (- (q/width) (:x (:position b)))))))
-        requested (conj requested (multiply (Vector. 1 0) (/ 100 (q/sq (:x (:position b))))))
-        requested (conj requested (multiply (Vector. 0 1) (/ 100 (q/sq (:y (:position b))))))
-        requested (conj requested (multiply (Vector. 0 -1) (/ 100 (q/sq (- (q/height) (:y (:position b)))))))
+        requested (conj requested (multiply (Vector. -1 0) (/ 500 (q/sq (- (q/width) (:x (:position b)))))))
+        requested (conj requested (multiply (Vector. 1 0) (/ 500 (q/sq (:x (:position b))))))
+        requested (conj requested (multiply (Vector. 0 1) (/ 500 (q/sq (:y (:position b))))))
+        requested (conj requested (multiply (Vector. 0 -1) (/ 500 (q/sq (- (q/height) (:y (:position b)))))))

         ;; Avoid obstacles

@@ -86,14 +79,14 @@

         ;; Match velocity with nearby boids

-        requested (if (> (count nearby-boids) 0)
+        requested (if (and flock? (> (count nearby-boids) 0))
                     (conj requested (multiply (subtract (multiply (reduce add (map :velocity nearby-boids)) (/ 1 (count nearby-boids))) (:velocity b))
                                               0.1))
                     requested)
         ;; Attract to Center of Mass of nearby boids

-        requested (if (> (count nearby-boids) 0)
+        requested (if (and flock? (> (count nearby-boids) 0))
                     (let [com (multiply (reduce add (map :position nearby-boids)) (/ 1 (count nearby-boids)))]
                       (conj requested (normalise (subtract com (:position b)))))
                     requested)
@@ -121,7 +114,7 @@

 (defn update-boids [state]
   (assoc state :boids (map (fn [b]
-                             (update-boid b (:boids state) (:obstacles state))) (:boids state) )))
+                             (update-boid b (:flock? state) (:boids state) (:obstacles state))) (:boids state) )))

 (defn draw [state]
   (q/background 200)
@@ -150,6 +143,9 @@
   (assoc state :obstacles [{:position (Vector. (:x e) (:y e))
                             :radius 50}]))

+(defn mouse-clicked [state e]
+  (assoc state :flock? (not (:flock? state))))
+
 (defn boids-sketch []
   (q/sketch
     :host "boids-sketch"
@@ -157,7 +153,8 @@
     :update #'update-boids
     :middleware [m/fun-mode]
     :draw #'draw
-    :size [1000 800]
-    :mouse-moved mouse-moved))
+    :size [(- (aget js/window "innerWidth") 40) (- (aget js/window "innerHeight") 100)]
+    :mouse-moved mouse-moved
+    :mouse-clicked mouse-clicked))

 (boids-sketch)


Pull square into it's own component

Pull square into it's own component

--- src/cljs/chess/core.cljs
+++ src/cljs/chess/core.cljs
@@ -2,6 +2,8 @@
   (:require [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
             [chess.board :as board]))
+
+

 (defonce app-state (atom {:board board/start-position}))

@@ -16,6 +18,15 @@
     (render [_]
       (dom/div #js {:className (piece-class-name p)} nil))))

+(defn square [s owner {:keys [rank file on-click]}]
+  (reify
+    om/IRender
+    (render [_]
+      (dom/div
+       #js {:className "square" :id (board/from-board-ks file rank)}
+       (if s
+         (om/build piece s))))))
+
 (defn main []
   (om/root
     (fn [app owner]
@@ -24,10 +35,9 @@
         (render [_]
           (apply dom/div #js {:className "board"}
                    (map-indexed
-                    (fn [i r] (apply dom/div #js {:className "row"}
-                                   (map-indexed (fn [j s] (dom/div #js {:className "square" :id (board/from-board-ks j i)}
-                                                         (if s
-                                                           (om/build piece s)))) r)))
+                    (fn [rank r] (apply dom/div #js {:className "row"}
+                                   (map-indexed (fn [file s] (om/build square s {:opts {:rank rank :file file}})) r)))
                     (:board app))))))
     app-state
     {:target (. js/document (getElementById "app"))}))
+


Past matches page

Past matches page

--- src/cljs/darts/core.cljs
+++ src/cljs/darts/core.cljs
@@ -250,14 +250,10 @@
   [:div [:h2 "Dartflow"]
    [:ul
     [:li [:a {:href "#/new-game"} "New match"]]
-    [:li [:a {:href "#/standings"} "Standings"]]]])
+    [:li [:a {:href "#/standings"} "Standings"]]
+    [:li [:a {:href "#/matches"} "Past Matches"]]]])

 (def matches (atom nil))
-
-(defn standings-component []
-  [:div
-   (println @matches)
-   [:div "Hello"]])

 (defn winning-player [{:keys [starting-score] :as match}]
   (let [score-0 (reduce + 0 (:rounds (:p0 match)))]
@@ -284,15 +280,16 @@
          " 0 - 1 ")
        "(avg. " (clojure.string/join ", " (averages match)) ")"))

-(defn render-matches [ms]
-  (when ms
+(defn render-matches [matches]
+  (when matches
     (into [:ul]
      (map-indexed (fn [i m] ^{:key i}
                     [:li (render-match m)])
-          ms)))
-  )
-
-(defn standings-page []
+          matches))))
+
+(defn standings-page [])
+
+(defn list-matches-page []
   (let [get-stuff #(GET "/list-matches"
                         {:handler (fn [r]
                                     (->> r
@@ -321,6 +318,9 @@

 (secretary/defroute "/standings" []
   (session/put! :current-page #'standings-page))
+
+(secretary/defroute "/matches" []
+  (session/put! :current-page #'list-matches-page))

 (secretary/defroute "/new-player" []
   (session/put! :current-page #'new-player-page))


Groups EDN specs (?)

Groups EDN specs (?)

Unsure

--- src/clojure/yaw/spec.clj
+++ src/clojure/yaw/spec.clj
@@ -142,10 +142,41 @@
 ;; (s/conform :scene/light [:sun {:dir [0 0 -1] :color :blue}])
 ;; => [:sun {:tag :sun, :params {:dir [0 0 -1], :color [:kw :blue]}}]

+;; GROUPS
+(s/def :scene/group (s/cat :tag #{:group}
+                           :id-kw qualified-keyword?
+                           :params (s/keys :req-un [:params/pos]
+                                           :opt-un [:params/rot :params/scale])
+                           :items (s/+ (s/spec :scene/item))))
+
+;; (s/conform :scene/group [:group :test/group {:pos [0 1 0]}
+;;                          [:item :test/item1 {:mesh :mesh/box :pos [0 0 2] :color :red}]
+;;                          [:item :test/item2 {:mesh :mesh/box :pos [0 0 -2] :color :blue}]
+;;                          [:item :test/item3 {:mesh :mesh/cone :pos [0 0 0] :color [0 0.3 0]}]])
+;; => {:tag :group,
+;;  :id-kw :test/group,
+;;  :params {:pos [0 1 0]},
+;;  :items [{:tag :item,
+;;           :id-kw :test/item1,
+;;           :params {:mesh :mesh/box,
+;;                    :pos [0 0 2],
+;;                    :color [:kw :red]}}
+;;          {:tag :item,
+;;           :id-kw :test/item2,
+;;           :params {:mesh :mesh/box,
+;;                    :pos [0 0 -2],
+;;                    :color [:kw :blue]}}
+;;          {:tag :item,
+;;           :id-kw :test/item3,
+;;           :params {:mesh :mesh/cone,
+;;                    :pos [0 0 0],
+;;                    :color [:rgb [0 0.3 0]]}}]}
+
 ;; GENERAL
 (s/def :scene/object (s/or :camera :scene/camera
                            :item :scene/item
-                           :light :scene/light))
+                           :light :scene/light
+                           :group :scene/group))

 ;; (s/conform :scene/object [:camera :test/cam {:pos [0 2 -5] :target [0 0 0]}])
 ;; => [:camera {:tag :camera, :id-kw :test/cam, :params {:pos [0 2 -5], :target [:vec [0 0 0]]}}]


cleanup

cleanup

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/ui/tweets.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/ui/tweets.cljs
@@ -20,7 +20,6 @@

 (defn missing-tweet [tweet]
   (put! c/tweet-missing-chan (:id_str tweet))
-  (print "retrieving tweet" (:id_str tweet))
   [:div.tweet "loading..." (:id_str tweet)])

 (defn tweet-text [tweet user app]


relax constraints of complement of slash-obj: may be a noun phrase rather than just a pronoun

--- src/babel/english/grammar.cljc
+++ src/babel/english/grammar.cljc
@@ -466,8 +466,7 @@
                                 :2 second-arg}}}})
     {:synsem {:aux false}
      :head {:synsem {:aux false}}
-     :comp {:phrasal false
-            :synsem {:pronoun true
+     :comp {:synsem {:subcat '()
                      :case :nom
                      :cat :noun}}}


make some pronouns reflexive that should be

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -1884,6 +1884,7 @@
     :target :it ;; Italian makes gender distinction for agreement with verbs and adjectives..
     :synsem {:cat :noun
              :pronoun true
+             :reflexive false
              :case :top ;; see comment in "it" about :case.
              :agr {:person :2nd
                    :gender :masc
@@ -1898,6 +1899,7 @@
     :synsem {:cat :noun
              :pronoun true
              :case :top ;; see comment in "it" about :case.
+             :reflexive false
              :agr {:person :2nd
                    :gender :fem
                    :number :sing}
@@ -1910,6 +1912,7 @@
     :synsem {:cat :noun
              :pronoun true
              :case :top ;; see comment in "it" about :case.
+             :reflexive false
              :agr {:person :2nd
                    :gender :fem
                    :number :sing}
@@ -1920,22 +1923,26 @@
    "you all (♂)"
    {:synsem {:cat :noun
              :pronoun true
+             :reflexive false
              :case :top ;; see comment in "it" about :case.
              :agr {:person :2nd
                    :gender :masc
                    :number :plur}
              :sem {:human true
+                   :reflexive false
                    :pred :voi}
              :subcat '()}}

    "you all (♀)"
    {:synsem {:cat :noun
              :pronoun true
+             :reflexive false
              :case :top ;; see comment in "it" about :case.
              :agr {:person :2nd
                    :gender :fem
                    :number :plur}
              :sem {:human true
+                   :reflexive false
                    :pred :voi}
              :subcat '()}}
    "your"


+pred2lex; +cat2lex

+pred2lex; +cat2lex

--- src/babel/espanol/grammar.cljc
+++ src/babel/espanol/grammar.cljc
@@ -5,7 +5,9 @@
    [babel.espanol.lexicon :refer [lexicon]]
    [babel.espanol.morphology :as morph
     :refer [analyze fo morph-walk-tree]]
-   [babel.index :refer (build-lex-sch-index create-index spec-to-phrases)]
+   [babel.index :refer (build-lex-sch-index
+                        create-index map-subset-by-cat
+                        map-subset-by-pred spec-to-phrases)]
    [babel.lexiconfn :refer [lexicon-for-generation]]
    [babel.parse :as parse]
    [babel.stringutils :refer [show-as-tree]]
@@ -452,6 +454,22 @@
                    (map #(keyword (get-in % [:rule]))
                         grammar)
                    grammar)
+
+     :pred2lex ;; map:<pred => subset of lexicon with that pred>
+     (map-subset-by-pred
+      (filter #(not (nil? %))
+              (vec (set (mapcat (fn [entry]
+                                  (get-in entry [:synsem :sem :pred]))
+                                (vals lexicon)))))
+      (flatten (vals lexicon)))
+
+     :cat2lex ;; map:<cat => subset of lexicon with that cat>
+     (map-subset-by-cat
+      (filter #(not (nil? %))
+              (vec (set (mapcat (fn [entry]
+                                  (get-in entry [:synsem :cat]))
+                                (vals lexicon)))))
+      (flatten (vals lexicon)))

      :grammar grammar
      :lexicon lexicon
@@ -483,6 +501,23 @@
                         (do
                           (merge tree
                                  (morph-walk-tree tree))))
+
+     :pred2lex ;; map:<pred => subset of lexicon with that pred>
+     (map-subset-by-pred
+      (filter #(not (nil? %))
+              (vec (set (mapcat (fn [entry]
+                                  (get-in entry [:synsem :sem :pred]))
+                                (vals lexicon)))))
+      (flatten (vals lexicon)))
+
+     :cat2lex ;; map:<cat => subset of lexicon with that cat>
+     (map-subset-by-cat
+      (filter #(not (nil? %))
+              (vec (set (mapcat (fn [entry]
+                                  (get-in entry [:synsem :cat]))
+                                (vals lexicon)))))
+      (flatten (vals lexicon)))
+
      :grammar grammar
      :lexical-cache (atom (cache/fifo-cache-factory {} :threshold 1024))
      :lexicon lexicon


Include original var name in tokenization

--- src/clj/clojuredocs/search.clj
+++ src/clj/clojuredocs/search.clj
@@ -63,9 +63,12 @@

 (defn tokenize-name [s]
   (when s
-    (->> (str/split s #"-")
-         (interpose " ")
-         (apply str))))
+    (str
+      s
+      " "
+      (->> (str/split s #"-")
+           (interpose " ")
+           (apply str)))))

 (def searchable-vars
   (do


Comment out unimplemented Un-map and Un-alias menu items

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -1121,8 +1121,11 @@
       (config! ns-menu :items [(id :ns-require-btn-action) :separator (id :ns-trace-btn-action) (id :ns-untrace-btn-action)])

       (config! vars-menu :items
-        [(id :var-trace-btn-action) :separator (id :vars-unmap-btn-action)
-         (id :vars-unalias-btn-action) :separator vars-categorized-cb
+               [(id :var-trace-btn-action)
+                ;;:separator
+                ;;(id :vars-unmap-btn-action) (id :vars-unalias-btn-action)
+                :separator
+                vars-categorized-cb
          vars-fqn-listing-cb vars-search-doc-also-cb])

@@ -1186,8 +1189,8 @@
                                     :separator (id :fqn-history-back-action)
                                     :separator
                                     (id :var-trace-btn-action)
-                                    :separator
-                                    (id :vars-unmap-btn-action) (id :vars-unalias-btn-action)
+                                    ;;:separator
+                                    ;;(id :vars-unmap-btn-action) (id :vars-unalias-btn-action)
                                     :separator
                                     (checkbox-menu-item :action (id :vars-categorized-cb-action))
                                     (checkbox-menu-item :action (id :vars-fqn-listing-cb-action))


Make main reloadable

Make main reloadable

--- src/cljs/clojuredocs/main.cljs
+++ src/cljs/clojuredocs/main.cljs
@@ -34,9 +34,6 @@
 (defn clog [& args]
   (.log js/console (pr-str args)))

-#_(def app-state
-    (atom (or (reader/read-string (aget js/window "PAGE_DATA")) {})))
-
 (defn on-el
   [init-state & pairs]
   (let [unmount-fns
@@ -119,11 +116,6 @@
       (fn [exs]
         (vec (remove #(= ex-to-del %) exs))))))

-#_(go-loop []
-    (when-let [ex (<! new-example-ch)]
-      (swap! app-state assoc :create-success? true)
-      (recur)))
-
 ;; Styleguide

 (def push-sels [:.mobile-push-wrapper :.mobile-nav-menu :.mobile-nav-bar])
@@ -143,116 +135,137 @@
                  :name "Getting Started"
                  :desc "Where to go to get started with Clojure. Provides a host of information  con the language, core concepts, tutorials, books, and videos to help you learn Clojure."}]})

-#_(dommy/listen! (sel1 :body) :keydown
-    (fn [e]
-      ;; ctrl-s to focus search input
-      (when (and (.-ctrlKey e) (= 83 (.-keyCode e)))
-        (doseq [$el (sel ".search input.query")]
-          (.focus $el))
-        ;; prevent save dialog
-        (.preventDefault e))))
-
 (.attach js/FastClick js/document.body)

-;; Hack to fix mobile safari ios 8 scrolling issue
-#_(doseq [$el (sel :.mobile-nav-menu)]
-    (let [f (fn [$el]
-              (dommy/set-style! $el
-                :height (str (.-innerHeight js/window) "px")))]
-      (dommy/listen! js/window :resize
-        (fn [_]
-          (f $el)))
-      (f $el)))
+(defn bind-resize []
+  (let [unbinds (doall
+                  (for [$el (sel :.mobile-nav-menu)]
+                    (do
+                      (let [f (fn [$el]
+                                (dommy/set-style! $el
+                                  :height (str (.-innerHeight js/window) "px")))
+                            handler (fn [_]
+                                      (f $el))]
+                        (dommy/listen! js/window :resize handler)
+                        (f $el)
+                        (fn []
+                          (dommy/unlisten! js/window :resize handler))))))]
+    (fn []
+      (doseq [unbind unbinds]
+        (unbind)))))

 (defn init []
-  (on-el
-    {}
-    :.btn.mobile-menu
-    (fn [$el]
-      (let [f (fn [e]
-                (doseq [s push-sels]
-                  (dommy/toggle-class! (sel1 s) :mobile-push))
-                (.stopPropagation e))]
-        (dommy/listen! $el :click f)
-        (fn []
-          (dommy/unlisten! $el :click f))))
-
-    :body
-    (fn [$el]
-      (let [h (fn [_]
-                (doseq [s push-sels]
-                  (dommy/remove-class! (sel1 s) :mobile-push)))]
-        (dommy/listen! $el :click h)
-        (fn []
-          (dommy/unlisten! $el :click h))))
-
-    :.mobile-nav-menu
-    (fn [$el]
-      (let [h (fn [e] (.stopPropagation e))]
-        #_(dommy/listen! $el
-            :click h
-            :touchstart h
-            :touchend h))
-
-      (let [f #(doseq [s push-sels]
-                 (dommy/remove-class! (sel1 s) :mobile-push))]
-        (doseq [$a (sel $el :a)]
-          (dommy/listen! $a :click f))
-        (fn []
-          (doseq [$a (sel $el :a)]
-            (dommy/unlisten! $a :click f)))))
-
-
-    ;; Styleguide
-    :.sg-quick-lookup
-    (fn [$el]
-      #_(om/root
-          search/$quick-lookup
+  (let [shutdown-els
+        (on-el
           {}
-          {:target $el}))
-
-    #_ :.sg-quick-lookup-autocomplete
-    #_(fn [$el]
-        (om/root
-          search/$quick-lookup
-          ex-ac-results
-          {:target $el}))
-
-    #_ :.sg-quick-lookup-null-state
-    #_ (fn [$el]
-         (om/root
-           search/$quick-lookup
-           {:results-empty? true}
-           {:target $el :init-state {:text "foo bar"}}))
-
-    #_ :.sg-quick-lookup-loading
-    #_ (fn [$el]
-         (om/root
-           search/$quick-lookup
-           {:search-loading? true}
-           {:target $el}))
-
-    #_ :.sg-see-alsos-null-state
-    #_ (fn [$el]
-         (om/root
-           see-alsos/$see-alsos
-           {:var {:ns "foo" :name "bar"}}
-           {:target $el}))
-
-    #_ :.sg-see-alsos-populated
-    #_ (fn [$el]
-         (om/root
-           see-alsos/$see-alsos
-           {:var {:ns "foo" :name "bar"}
-            :see-alsos [{:_id "", :user {:login "mmwaikar"}, :created-at #inst "2011-10-14T13:29:04.000-00:00", :name "map-indexed", :ns "clojure.core", :doc "Returns a lazy sequence consisting of the result of applying f to 0\nand the first item of coll, followed by applying f to 1 and the second\nitem in coll, etc, until coll is exhausted. Thus function f should\naccept 2 arguments, index and item."} {:_id "", :user {:login "gstamp"}, :created-at #inst "2012-09-06T11:28:04.000-00:00", :name "pmap", :ns "clojure.core", :doc "Like map, except f is applied in parallel. Semi-lazy in that the\nparallel computation stays ahead of the consumption, but doesn't\nrealize the entire result unless required. Only useful for\ncomputationally intensive functions where the time of f dominates\nthe coordination overhead."} {:_id "", :user {:login "gstamp"}, :created-at #inst "2012-09-06T11:28:33.000-00:00", :name "amap", :ns "clojure.core", :doc "Maps an expression across an array a, using an index named idx, and\nreturn value named ret, initialized to a clone of a, then setting \neach element of ret to the evaluation of expr, returning the new \narray ret."} {:_id "", :user {:login "adereth"}, :created-at #inst "2013-06-21T19:20:53.000-00:00", :name "mapcat", :ns "clojure.core", :doc "Returns the result of applying concat to the result of applying map\nto f and colls.  Thus function f should return a collection."}]}
-           {:target $el}))
-
-    :body.var-page var-page/init
-    :body.styleguide-page styleguide/init
-    :body search/init
-    "[data-sticky-offset]" sticky/init
-    "[data-animate-scroll]" animated-scroll-init))
-
+          :.btn.mobile-menu
+          (fn [$el]
+            (let [f (fn [e]
+                      (doseq [s push-sels]
+                        (dommy/toggle-class! (sel1 s) :mobile-push))
+                      (.stopPropagation e))]
+              (dommy/listen! $el :click f)
+              (fn []
+                (dommy/unlisten! $el :click f))))
+
+          :body
+          (fn [$el]
+            (let [h (fn [_]
+                      (doseq [s push-sels]
+                        (dommy/remove-class! (sel1 s) :mobile-push)))]
+              (dommy/listen! $el :click h)
+              (fn []
+                (dommy/unlisten! $el :click h))))
+
+          :.mobile-nav-menu
+          (fn [$el]
+            (let [h (fn [e] (.stopPropagation e))]
+              #_(dommy/listen! $el
+                  :click h
+                  :touchstart h
+                  :touchend h))
+
+            (let [f #(doseq [s push-sels]
+                       (dommy/remove-class! (sel1 s) :mobile-push))]
+              (doseq [$a (sel $el :a)]
+                (dommy/listen! $a :click f))
+              (fn []
+                (doseq [$a (sel $el :a)]
+                  (dommy/unlisten! $a :click f)))))
+
+
+          ;; Styleguide
+          :.sg-quick-lookup
+          (fn [$el]
+            #_(om/root
+                search/$quick-lookup
+                {}
+                {:target $el}))
+
+          #_ :.sg-quick-lookup-autocomplete
+          #_(fn [$el]
+              (om/root
+                search/$quick-lookup
+                ex-ac-results
+                {:target $el}))
+
+          #_ :.sg-quick-lookup-null-state
+          #_ (fn [$el]
+               (om/root
+                 search/$quick-lookup
+                 {:results-empty? true}
+                 {:target $el :init-state {:text "foo bar"}}))
+
+          #_ :.sg-quick-lookup-loading
+          #_ (fn [$el]
+               (om/root
+                 search/$quick-lookup
+                 {:search-loading? true}
+                 {:target $el}))
+
+          #_ :.sg-see-alsos-null-state
+          #_ (fn [$el]
+               (om/root
+                 see-alsos/$see-alsos
+                 {:var {:ns "foo" :name "bar"}}
+                 {:target $el}))
+
+          #_ :.sg-see-alsos-populated
+          #_ (fn [$el]
+               (om/root
+                 see-alsos/$see-alsos
+                 {:var {:ns "foo" :name "bar"}
+                  :see-alsos [{:_id "", :user {:login "mmwaikar"}, :created-at #inst "2011-10-14T13:29:04.000-00:00", :name "map-indexed", :ns "clojure.core", :doc "Returns a lazy sequence consisting of the result of applying f to 0\nand the first item of coll, followed by applying f to 1 and the second\nitem in coll, etc, until coll is exhausted. Thus function f should\naccept 2 arguments, index and item."} {:_id "", :user {:login "gstamp"}, :created-at #inst "2012-09-06T11:28:04.000-00:00", :name "pmap", :ns "clojure.core", :doc "Like map, except f is applied in parallel. Semi-lazy in that the\nparallel computation stays ahead of the consumption, but doesn't\nrealize the entire result unless required. Only useful for\ncomputationally intensive functions where the time of f dominates\nthe coordination overhead."} {:_id "", :user {:login "gstamp"}, :created-at #inst "2012-09-06T11:28:33.000-00:00", :name "amap", :ns "clojure.core", :doc "Maps an expression across an array a, using an index named idx, and\nreturn value named ret, initialized to a clone of a, then setting \neach element of ret to the evaluation of expr, returning the new \narray ret."} {:_id "", :user {:login "adereth"}, :created-at #inst "2013-06-21T19:20:53.000-00:00", :name "mapcat", :ns "clojure.core", :doc "Returns the result of applying concat to the result of applying map\nto f and colls.  Thus function f should return a collection."}]}
+                 {:target $el}))
+
+          :body.var-page var-page/init
+          :body.styleguide-page styleguide/init
+          :body search/init
+          "[data-sticky-offset]" sticky/init
+          "[data-animate-scroll]" animated-scroll-init)
+
+        shutdown-search-listener
+        (let [body (sel1 :body)
+              f (fn [e]
+                  ;; ctrl-s to focus search input
+                  (when (and (.-ctrlKey e) (= 83 (.-keyCode e)))
+                    (doseq [$el (sel ".search input.query")]
+                      (.focus $el))
+                    ;; prevent save dialog
+                    (.preventDefault e)))]
+          (dommy/listen! (sel1 :body) :keydown f)
+          (fn []
+            (dommy/unlisten! (sel1 :body) :keydown f)))
+
+        ;; Hack to fix mobile safari ios 8 scrolling issue
+        shutdown-resize (bind-resize)]
+    (fn []
+      (shutdown-els)
+      (shutdown-search-listener)
+      (shutdown-resize))))
+
+;; redirection to enable reloading of init code
+(defn reload [] (init))

 ;; project.clj entry
-(defonce reload-hook (page/hook-reload-fn init))
+(defonce reload-hook (page/hook-reload-fn reload))


Fix default get-new-robot-velocity

Fix default get-new-robot-velocity

--- src/cljs/robot_kata/robot.cljs
+++ src/cljs/robot_kata/robot.cljs
@@ -57,9 +57,7 @@
       (if (> (- current-time @last-tick-time))
         (reset! last-tick-time current-time) ) ) ) )

-(defn ^:export get-new-robot-velocity [robot-state sensed-color]
-  (cond (= sensed-color "white") STRAIGHT
-        :else                    ARC_LEFT ) )
+(defn ^:export get-new-robot-velocity [robot-state sensed-color] (.-STRAIGHT commands))

 (defn enable-start-test-buttons []
   (doseq [b (sel [:#test-start-button-div :button])]