update the actual thing

update the actual thing

--- src/clj/shadow/cljs/passes.clj
+++ src/clj/shadow/cljs/passes.clj
@@ -27,7 +27,7 @@
     ast))

-(defn load-macros [env {:keys [op name] :as ast}]
+(defn load-macros [_ {:keys [op name] :as ast}]
   (if (or (not= :ns op)
           (not (-> name meta :load-macros)))
     ast
@@ -41,12 +41,12 @@
                                          (conj m var-name)
                                          m))
                                      #{}))]
-          ;; this is sort of ugly, but the compiler env does not store the result of a pass, only the parse
+
           (swap! env/*compiler* assoc-in [::ana/namespaces name :macros] macros)
           (assoc ast :macros macros)
           ))))

-(defn infer-macro-require [env {:keys [op requires name] :as ast}]
+(defn infer-macro-require [_ {:keys [op requires name] :as ast}]
   (if (or (not= :ns op)
           (empty? requires))
     ast
@@ -55,7 +55,7 @@
                 (if (nil? macros)
                   ast
                   (let [update-fn (fn [current]
-                                    (update-in ast [:require-macros] assoc used-name used-ns))]
+                                    (update-in current [:require-macros] assoc used-name used-ns))]

                     (swap! env/*compiler* update-in [::ana/namespaces name] update-fn)
                     (update-fn ast))
@@ -64,7 +64,7 @@
             requires)))

-(defn infer-macro-use [env {:keys [op uses name] :as ast}]
+(defn infer-macro-use [_ {:keys [op uses name] :as ast}]
   (if (or (not= :ns op)
           (empty? uses))
     ast
@@ -72,7 +72,7 @@
               (let [macros (get-in @env/*compiler* [::ana/namespaces used-ns :macros])]
                 (if (contains? macros used-name)
                   (let [update-fn (fn [current]
-                                    (update-in ast [:use-macros] merge {used-name used-ns}))]
+                                    (update-in current [:use-macros] merge {used-name used-ns}))]

                     (swap! env/*compiler* update-in [::ana/namespaces name] update-fn)
                     (update-fn ast))


Remove old implementation

Remove old implementation

--- src/clj_gatling/simulation.clj
+++ src/clj_gatling/simulation.clj
@@ -3,30 +3,6 @@
             [clj-time.core :as time]
             [clj-time.local :as local-time]
             [clojure.core.async :as async :refer [go go-loop put! <!! alts! <! >!]]))
-
-(defn- collect-result [cs]
-  (let [[result c] (async/alts!! cs)]
-    @result))
-
-(defmacro with-channels [binding & body]
-  `(let [~(first binding) (repeatedly ~(second binding) async/chan)
-         ~'result (do ~@body)]
-    (dorun ~'result) ;Lazy results must be evaluated before channels are closed
-    (doseq [~'c ~(first binding)] (async/close! ~'c))
-    ~'result))
-
-(defn- run-parallel-and-collect-results [function times]
-  (with-channels [cs times]
-    (let [ps (map vector (iterate inc 0) cs)]
-      (doseq [[i c] ps]
-        (go (>! c (function i))))
-      (repeatedly times (partial collect-result cs)))))
-
-(defn- collect-result-and-run-next [cs run]
-  (let [[result c] (async/alts!! cs)
-        ret @result]
-    (go (>! c (run)))
-    ret))

 (defprotocol RunnerProtocol
   (continue-run? [runner current-time i])
@@ -42,22 +18,6 @@
   (continue-run? [_ _ i] (< i requests))
   (runner-info [_] (str "requests " requests)))

-(defn- run-scenarios-in-parallel [scenario-runners parallel-count runner]
-    (let [cs (repeatedly parallel-count async/chan)
-          scenario-start (local-time/local-now)
-          ps (map vector (iterate inc 0) cs)
-          results (async/chan)]
-      (doseq [[i c] ps]
-        (go (>! c ((nth scenario-runners i)))))
-      (let [count-c (go-loop [i 0]
-                      (let [[result c] (async/alts! cs)]
-                        (async/put! c ((nth scenario-runners (+ i parallel-count))))
-                        (async/put! results result)
-                      (if (continue-run? runner scenario-start i)
-                        (recur (inc i))
-                        i)))]
-        (repeatedly (async/<!! count-c) (fn []  @(async/<!! results))))))
-
 (defn- now [] (System/currentTimeMillis))

 (defn- async-http-request [url user-id callback]
@@ -72,46 +32,8 @@
 (defn- request-result [id request-name success start]
   {:id id :name request-name :result success :start start :end (now)})

-(defn- callback->chan [step-fn id]
-  (let [c (async/chan)]
-    (step-fn id (fn [success] (async/put! c success)))
-    c))
-
-(defn- run-scenario-async [scenario step-timeout id]
-  (fn [] (let [scenario-start (now)
-        end-result (promise)
-        run-requests-fn (fn run-requests [requests result]
-          (if (empty? requests)
-            (deliver end-result {:id id :name (:name scenario) :start scenario-start :end (now) :requests result})
-            (let [request (first requests)
-                  start (now)]
-              (go
-                (let [response (callback->chan (request-fn request) id)
-                      timeout  (async/timeout step-timeout)
-                      [s channel] (async/alts! [response timeout])
-                      success (if (= channel timeout)
-                                false
-                                s)]
-                  (run-requests (rest requests) (conj result (request-result id (:name request) success start))))))))]
-    (run-requests-fn (:requests scenario) [])
-    end-result)))
-
-(defn- run-nth-scenario-with-multiple-users [scenarios users step-timeout requests duration i]
-  (let [
-        scenario-start (local-time/local-now)
-        result (promise)
-        scenario (nth scenarios i)
-        runner (if (nil? duration)
-                 (FixedRequestNumberRunner. requests)
-                 (DurationRunner. duration))
-        scenario-runs (map (partial run-scenario-async scenario step-timeout) (range))]
-     (println (str "Running scenario " (:name scenario) " with " users " users and " (runner-info runner) "."))
-     (deliver result (run-scenarios-in-parallel scenario-runs users runner))
-    result))
-
 (defn async-function-with-timeout [request timeout user-id result-channel]
-  (let [now      #(System/currentTimeMillis)
-        start    (now)
+  (let [start    (now)
         response (async/chan)
         function (memoize (request-fn request))]
     (go


added "categorized listing" menu option to choose between simple alphabetic and categorized listing of vars/fun/macros

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -178,7 +178,7 @@
 (defn ns-unloaded [] @all-ns-unloaded-atom)
 (swap! all-ns-unloaded-atom (fn [& a] (all-ns-unloaded)))
 (swap! all-ns-loaded-atom (fn [& a] (all-ns-loaded)))
-(def group-vars-by-object-type (atom true))
+(def group-vars-by-object-type-atom (atom false))
 (def ns-lb-refresh-atom (atom true))
 (def vars-lb-refresh-atom (atom true))

@@ -470,7 +470,8 @@
         [(b/selection (id :vars-cbx))
          (b/selection (id :ns-lb))
          (id :vars-filter-tf)
-         vars-lb-refresh-atom])
+         vars-lb-refresh-atom
+         group-vars-by-object-type-atom])
       (b/transform (fn [o]
         (let [n-s (selection (id :ns-lb))
               n (and n-s (find-ns (symbol n-s)))
@@ -486,13 +487,13 @@
             {:already-filtered false :string-seq []}))))
       (b/transform regx-tf-filter (id :vars-filter-tf))
       (b/transform (fn [symbol-str-seq]
-        (if @group-vars-by-object-type
+        (if @group-vars-by-object-type-atom
           (let [n-s (selection (id :ns-lb))
                 n (and n-s (find-ns (symbol n-s)))
                 v (selection (id :vars-cbx))
                 fqns? (#{"all-publics" "search-all-docs"} v)]
             (group-by-object-type symbol-str-seq fqns? n-s))
-          symbol-str-seq)))
+          (sort symbol-str-seq))))
       (b/filter (fn [l]  ;; only refresh if the list really has changed
         (if (= l (seesaw.meta/get-meta root :last-vars-lb))
           false
@@ -738,6 +739,8 @@
           clojuredocs-access-btn-group (button-group)
           clojuredocs-online-rb (radio-menu-item :text "ClojureDocs Online" :id :clojuredocs-online-rb :group clojuredocs-access-btn-group)
           clojuredocs-offline-rb (radio-menu-item :text "ClojureDocs Offline/Local" :id :clojuredocs-offline-rb :group clojuredocs-access-btn-group)
+
+          vars-categorized-cb (checkbox-menu-item :text "Categorized Listing" :id :vars-categorized-cb)

           auto-refresh-browser-cb (checkbox-menu-item :text "Auto-Refresh" :id :auto-refresh-browser)
           auto-refresh-browser-timer (timer auto-refresh-browser-handler  :initial-value {:root root}
@@ -757,12 +760,19 @@

       (config! ns-menu :items ["Load" "Trace"])

-      (config! vars-menu :items ["Trace" "Unmap"])
+      (config! vars-menu :items ["Trace" "Unmap" :separator vars-categorized-cb])

-      (config! auto-refresh-browser-cb :listen [:action
-        (fn [e] (if (config auto-refresh-browser-cb :selected?) (.start auto-refresh-browser-timer) (.stop auto-refresh-browser-timer)))] :selected? false)
+      (config! auto-refresh-browser-cb
+        :listen [:action (fn [e] (if (config auto-refresh-browser-cb :selected?)
+                                   (.start auto-refresh-browser-timer)
+                                   (.stop auto-refresh-browser-timer)))]
+        :selected? false)

+      (config! vars-categorized-cb
+         :listen [:action (fn [e] (swap! group-vars-by-object-type-atom (fn [_] (config vars-categorized-cb :selected?))))]
+        :selected? false)
+
       (config! color-coding-cb :selected? true)

       (config! font-Monospaced-rb :listen [:action (fn [e] (set-font-handler! root "Monospaced"))] :selected? true)


Fix issue #45: Preserve same font name when changing font size

--- src/clj_ns_browser/browser.clj
+++ src/clj_ns_browser/browser.clj
@@ -90,13 +90,15 @@
 (defn font-size+
   "Increase the font-size of the widget w by 1."
   [w]
-  (config! w :font {:size (+ 1 (.getSize (config w :font)))}))
+  (let [f (config w :font)]
+    (config! w :font {:name (.getName f) :size (inc (.getSize f))})))

 (defn font-size-
   "Decrease the font-size of the widget w by 1."
   [w]
-  (config! w :font {:size (- (.getSize (config w :font)) 1)}))
+  (let [f (config w :font)]
+    (config! w :font {:name (.getName f) :size (dec (.getSize f))})))

 ;; constants and global maps shared by all seesaw widgets


rename angular module to traveler

rename angular module to traveler

--- src/cljs/traveler/ng/core.cljs
+++ src/cljs/traveler/ng/core.cljs
@@ -3,16 +3,16 @@
   (:use-macros [purnam.core :only [!]]
                [gyr.core :only [def.module def.controller def.directive]]))

-(def.module users-module [])
+(def.module traveler [])

-(def.directive users-module.ngEnter []
+(def.directive traveler.ngEnter []
   (fn [scope element attrs]
     (element.bind "keydown keypress" (fn [event]
                                        (if (== event.which 13)
                                          (scope.$apply (fn []
                                                          (scope.$eval attrs.ngEnter))))))))

-(def.controller users-module.users-ctrl [$scope $filter]
+(def.controller traveler.users-ctrl [$scope $filter]
   ;;modify these values to change the defaults
   (! $scope.gap 5)
   (! $scope.usersPerPage 10)


Remove some modes, add a code for lantern

--- config.clj
+++ config.clj
@@ -29,8 +29,11 @@
       (handler/control-code :konami
         :code [:up :up :down :down :left :right :left :right :B :A :start]
         :mode :strobe)
+      (handler/control-code :konami
+        :code [:L :R :L :R :L :R :start]
+        :mode :lantern)
       (handler/buffer-keys 20)
-      (handler/log-events (comp #{:button/press} :type))
+      #_(handler/log-events (comp #{:button/press} :type))
       handler/system-reset)

   :web-options
@@ -72,8 +75,6 @@

   :playlist
   [:flicker
-   :strip-eq
-   :pulse
    :dart
    :rainbow
    :ant])


repl refresh ability.

repl refresh ability.

--- clojure/meetup/meetup.clj
+++ clojure/meetup/meetup.clj
@@ -1,6 +1,9 @@
 (ns meetup
   (:require [clj-time.core :as t]
-            [clj-time.predicates :as tpr]))
+            [clj-time.predicates :as tpr]
+            [clojure.tools.namespace.repl :as repl :only [refresh]]))
+
+(repl/refresh)

 (defn- simple-format [d]
   (when d
@@ -44,4 +47,3 @@
 (def friteenth    (partial schedule-in-date-range 5 teens))
 (def saturteenth  (partial schedule-in-date-range 6 teens))
 (def sunteenth    (partial schedule-in-date-range 7 teens))
-X


docstring

docstring

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -285,7 +285,7 @@
   (vector query values))

 (defn execute
-  "Executes built query
+  "Executes a pre-built query

    Options
      * prepared - wether the query should or should not be executed as prepared, always passed


bug in cogroup-by fixed !!

bug in cogroup-by fixed !!

--- src/datasplash/core.clj
+++ src/datasplash/core.clj
@@ -16,7 +16,7 @@
             Partition Partition$PartitionFn
             SerializableFunction WithKeys GroupByKey RemoveDuplicates Count
             Flatten Combine$CombineFn Combine View View$AsSingleton Sample]
-           [com.google.cloud.dataflow.sdk.transforms.join KeyedPCollectionTuple CoGroupByKey CoGbkResult$CoGbkResultCoder UnionCoder]
+           [com.google.cloud.dataflow.sdk.transforms.join KeyedPCollectionTuple CoGroupByKey CoGbkResult$CoGbkResultCoder UnionCoder CoGbkResult]
            [com.google.cloud.dataflow.sdk.values KV PCollection TupleTag PBegin PCollectionList]
            [com.google.cloud.dataflow.sdk.util.common Reiterable]
            [com.google.cloud.dataflow.sdk.util GcsUtil]
@@ -246,6 +246,7 @@
   [^DoFn$ProcessContext c]
   (.output c (.element c)))

+
 (defn make-nippy-coder
   {:doc "Returns an instance of a CustomCoder using nippy for serialization"
    :added "0.1.0"}
@@ -336,12 +337,13 @@
 (defn map-op
   [transform {:keys [isomorph? kv?] :as base-options}]
   (fn make-map-op
-    ([f {:keys [key-coder value-coder] :as options} ^PCollection pcoll]
+    ([f {:keys [key-coder value-coder coder] :as options} ^PCollection pcoll]
      (let [default-coder (cond
                            isomorph? (.getCoder pcoll)
-                           kv? (KvCoder/of
-                                (or key-coder (make-nippy-coder))
-                                (or value-coder (make-nippy-coder)))
+                           kv? (or coder
+                                   (KvCoder/of
+                                    (or key-coder (make-nippy-coder))
+                                    (or value-coder (make-nippy-coder))))
                            :else (make-nippy-coder))
            opts (merge (assoc base-options :coder default-coder) options)
            pardo (ParDo/of (dofn (transform f) opts))]
@@ -908,29 +910,24 @@
      (ptransform
       :cogroup
       [^KeyedPCollectionTuple pcolltuple]
-      (let [key-coder (.getKeyCoder pcolltuple)
-            cogbk-res-schema (.getCoGbkResultSchema pcolltuple)
-            _ (println "SCHEMA" cogbk-res-schema)
-            vals-coder (->> (.getKeyedCollections pcolltuple)
-                            (map (fn [tagpcoll] (-> tagpcoll
-                                                    (.getCollection)
-                                                    (.getCoder)
-                                                    (.getValueCoder)))))
-            _ (println "VALS CODER" vals-coder)
-            cogbk-res-coder (CoGbkResult$CoGbkResultCoder/of cogbk-res-schema vals-coder)
-            ordered-tags (->> pcolltuple
+      (let [ordered-tags (->> pcolltuple
                               (.getKeyedCollections)
                               (map #(.getTupleTag %))
                               (sort-by #(.getId %)))
             rel (apply-transform pcolltuple (CoGroupByKey/create) base-schema opts)
+            cogbk-coder (-> rel
+                            (.getCoder)
+                            (.getValueCoder))
             final-rel (map-kv (fn [^KV elt]
                                 (let [k (.getKey elt)
                                       raw-values (.getValue elt)
-                                      values (mapv (fn [tag] (.getAll raw-values tag)) ordered-tags)]
+
+                                      values (mapv (fn [tag] (let [raw-val (.getAll raw-values tag)
+                                                                   m-val (into (list) (iterator-seq (.iterator raw-val)))]
+                                                               m-val)) ordered-tags)]
                                   [k values]))
                               (assoc opts
-                                     :without-coercion-to-clj true
-                                     :coder (make-kv-coder key-coder cogbk-res-coder))
+                                     :without-coercion-to-clj true)
                               rel)]
         final-rel)))))


CMR-3680 removes println

CMR-3680 removes println

--- system-int-test/test/cmr/system_int_test/ingest/granule_ingest_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/granule_ingest_test.clj
@@ -390,7 +390,6 @@
                               :headers
                               (get "Content-Type"))
         granule-search-response (search/find-refs :granule {:concept-id gran-concept-id})]
-    (println ingest-collection-response)
     (testing "Collection ingested and indexed successfully as version 1.2 UMM JSON"
       (is (= 201 (:status ingest-collection-response)))
       (is (= "application/vnd.nasa.cmr.umm+json;version=1.2; charset=utf-8"


Extend om-next parser

Extend om-next parser

--- src/discuss/parser.cljs
+++ src/discuss/parser.cljs
@@ -1,12 +1,29 @@
 (ns discuss.parser
   (:require [om.next :as om]))

-(def init-data {:search/results []})
+(def init-data {:search/results []
+                :layout/title "discuss"
+                :issue/title "Town has to cut spending"
+                :issue/info "Our town needs to cut spending. Please discuss ideas how this should be done."
+                :discussion/items [{:htmls ["the city should reduce the number of street festivals"],
+                                    :texts ["the city should reduce the number of street festivals"],
+                                    :url "town-has-to-cut-spending/attitude/36"}
+                                   {:htmls ["we should shut down University Park"],
+                                    :texts ["we should shut down University Park"],
+                                    :url "town-has-to-cut-spending/attitude/37"}
+                                   {:htmls ["we should close public swimming pools"],
+                                    :texts ["we should close public swimming pools"],
+                                    :url "town-has-to-cut-spending/attitude/38"}]
+                :discussion/bubbles []})

 ;; -----------------------------------------------------------------------------
 ;; Parsing

-(defmulti read (fn [env key params] key))
+(defn get-data [state key]
+  (let [st @state]
+    (into [] (map #(get-in st %)) (get st key))))
+
+(defmulti read om/dispatch)
 (defmethod read :default
   [{:keys [state] :as env} key params]
   (let [st @state]
@@ -14,10 +31,23 @@
       {:value value}
       {:value :not-found})))

+#_(defmethod read :item/by-url
+  [{:keys [state]} _ {:keys [url]}]
+  (let [st @state
+        item (for [item (get st :discussion/items) :when (= url (:url item))] item)]
+    item))
+;; (read {:state (om/app-state scarf.core/reconciler)} :color/by-id {:id 1})
+
+
 (defmulti mutate om/dispatch)
 (defmethod mutate 'search/results [{:keys [state]} _ {:keys [results]}]
   {:action (fn [] (swap! state assoc :search/results results))})

+(defmethod mutate 'discussion/items [{:keys [state]} _ {:keys [items]}]
+  {:action (fn [] (swap! state assoc :discussion/items items))})
+
+(defmethod mutate 'discussion/bubbles [{:keys [state]} _ {:keys [bubbles]}]
+  {:action (fn [] (swap! state assoc :discussion/bubbles bubbles))})

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

@@ -25,4 +55,3 @@
   (om/reconciler
    {:state  init-data
     :parser (om/parser {:read read :mutate mutate})}))
-


adapt node server for clj, cljs & edn

adapt node server for clj, cljs & edn

--- pp-node-server/src/main.cljs
+++ pp-node-server/src/main.cljs
@@ -12,7 +12,7 @@
 (def app (express))

 (def config
-  (util/json-parse (node/require "../config/config.json")))
+  (util/json-parse (node/require "../../../config/config.json")))

 (def typefns {"js"   web/format-js
               "json" web/format-js
@@ -37,15 +37,14 @@
               input    (:input body)
               settings (or (:settings body) {})]
           (try
-            (let [result ((get typefns tipe) input settings)]
+            (let [result ((get typefns tipe) input settings tipe)]
               (-> res
                   (.status 200)
-                  (.json ((get typefns tipe) input settings))))
+                  (.json (str result))))
             (catch :default e
               ;; TODO: figure out how to parse these errors!
               (do
-                (print e)
-                (.send (.status res 500) e)))))))
+                (.send (.status res 400) e)))))))

     ;; not found
     (.use (fn [req res] (.send (.status res 404) "Not Found"))))


Comment out some debug code

Comment out some debug code

--- src/dolly/namespace.clj
+++ src/dolly/namespace.clj
@@ -104,11 +104,9 @@
 (def first-time (atom true))

 (defn should-show-namespace? [ns-sym show-opts]
-  (when @first-time
-    (println (format "jafinger-dbg: show-opts='%s'" show-opts))
-    (reset! first-time false))
-  ;; TBD
-  true
+;;  (when @first-time
+;;    (println (format "jafinger-dbg: show-opts='%s'" show-opts))
+;;    (reset! first-time false))
   (loop [opts show-opts]
     (when-first [opt opts]
       (cond
@@ -202,6 +200,8 @@
                     (println "\nFiles in /filemap but not in /files:")
                     (pp/pprint only-in-filemap))
                   (when-not (empty? only-in-files)
-                    (println "\nFiles in /files but not in /filemap, probably because they have no top-level ns form that tools.namespace can find:")
-                    (pp/pprint only-in-files)))}))
+                    (println
+"\nFiles in /files but not in /filemap, probably because they have
+no top-level ns form that tools.namespace can find:")
+                    (pp/pprint (map str only-in-files))))}))
            tracker))))))


attempt to fix delay when new sound plays

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -91,7 +91,8 @@
   (swap! app-state assoc :current-sound
     (.createSound js/soundManager #js {:id   (:current-sound-id @app-state)
                                        :type "audio/mpeg"
-                                       :url  sound-data}))
+                                       :url  sound-data
+                                       :autoLoad true}))

   (.play (:current-sound @app-state)
          #js {:onfinish on-finish


[safeguard] Return intermediate stash when reaching either max-iter or max-stash-size + log warning

--- src/duckling/engine.clj
+++ src/duckling/engine.clj
@@ -4,6 +4,7 @@
   1. rules are transformed into objets via rules macro
   2. rules are (recursively) matched based on theirs pattern vectors.
   3. tokens containing final info are produced using their production rules"
+  (:use [clojure.tools.logging])
   (:require [clojure.set :as sets]
             [duckling.time.prod]
             [duckling.time.api :as time]
@@ -192,12 +193,18 @@
          prev-stash-size 0
          ; safeguard: number of max iterations (loops DO occur :))
          remaining-iter 10]
-    (let [stash-size (count stash)]
-      (if (and (< stash-size 500) (> stash-size prev-stash-size))
-        (if (> remaining-iter 0)
-          (recur (pass-once stash rules sentence) (count stash) (dec remaining-iter))
-          (throw (Exception. (str "@pass-all reached maximum iterations for sentence '" sentence "'"))))
-        stash))))
+    (let [stash-size (count stash)
+          max-iter-reached? (< remaining-iter 0)
+          max-stash-reached? (> stash-size 600)
+          finished? (<= stash-size prev-stash-size)]
+      (if (or max-iter-reached? max-stash-reached? finished?)
+        (do
+          (when max-iter-reached?
+            (warnf (format "@pass-all reached maximum iterations for sentence '%s'" sentence)))
+          (when max-stash-reached?
+            (warnf (format "@pass-all reached maximum stash size for sentence '%s'" sentence)))
+          stash)
+        (recur (pass-once stash rules sentence) (count stash) (dec remaining-iter))))))

 (defn maxlen-judge
   "Choose the winning token in the stash."


cleaning up server control

cleaning up server control

--- resources/public/scripts/control.cljs
+++ resources/public/scripts/control.cljs
@@ -5,30 +5,12 @@
             [cljs-http.client :as http]
   ))

-;;; helpers
+;;; server operations

 (defn- get-sign-url [type]
   (case type
     :sign-in "/user/session"
     :sign-up "/user"))
-
-
-(defn- reply [ch ]
-
-  )
-
-(defn- srv-op []
-
-  )
-
-; (defn mutate-and-put! [op ch state k v]
-;   (op state k v)
-;   (put! ch {k v})
-;   )
-
-;;; server operations
-
-; TODO: fix signatures

 (defn- sign [type user pass rsp-ch]
   (go
@@ -50,42 +32,33 @@
 ;     (DELETE url {:handler #(println "yay")})))
   )

-
-
 (defn get-private-notes [user-id rsp-ch]
   (go
-    (let [srv-ch (http/get "/note" {})
-          {:keys [status body]} (<! srv-ch)]
+    (let [{:keys [status body]} (<! (http/get "/note" {}))]
       (case status
         200 (put! rsp-ch {:ok? true :notes (reverse body)})
-        401 (put! rsp-ch {:ok? false})
-        (println "hmz") ; TODO: define return value {:ok? true/false :}
+        (put! rsp-ch {:ok? false :error body})
   ))))

-
-
-; (defn get-public-notes
-;   []
-;   ; TODO: implement backend
-;   )
-
-
+(defn get-public-notes [rsp-ch]
+  ; TODO: needs backend implementation
+  (println "TODO: not implemented")
+  )

 (defn create-note [user-id text visibility rsp-ch]
   (go
-    ; TODO: change "query-params" - I want form-params
-    (let [srv-rsp (<! (http/post "/note" {:query-params {:text text :visibility visibility}}))]
-      (case (:status srv-rsp)
-        200 (put! rsp-ch {:ok? true :note (:body srv-rsp)})
-        (println "uh oh, note not created!" srv-rsp) ; (put! rsp-ch (:body srv-rsp)) ; TODO: parse this..
+    (let [{:keys [status body]} (<! (http/post "/note" {:query-params {:text text :visibility visibility}}))] ; TODO: change "query-params" - I want form-params
+      (case status
+        200 (put! rsp-ch {:ok? true :note body})
+        (put! rsp-ch {:ok? false :error body})
   ))))

 (defn- delete-note [note-id rsp-ch]
   (go
-    (let [srv-rsp (<! (http/delete (str "/note/" note-id)))]
-      (case (:status srv-rsp)
+    (let [{:keys [status body]} (<! (http/delete (str "/note/" note-id)))]
+      (case status
         200 (put! rsp-ch {:ok? true})
-        (println "ooops, couldn't delete note" note-id)
+        (put! rsp-ch {:ok? false :error body})
   ))))

 (defn- get-update-note-params [{:keys [note-id text visibility] :as note}]
@@ -98,12 +71,10 @@

 (defn- update-note [{:keys [note-id] :as note} rsp-ch]
   (go
-    (let [srv-ch (http/put (str "/note/" note-id) {:query-params (get-update-note-params note)})
-          {:keys [status body]} (<! srv-ch)]
+    (let [{:keys [status body]} (<! (http/put (str "/note/" note-id) {:query-params (get-update-note-params note)}))]
       (case status
         200 (put! rsp-ch {:ok? true})
-        401 (put! rsp-ch {:ok? false})
-        (println "hmz") ; TODO: define return value {:ok? true/false :}
+        (put! rsp-ch {:ok? false :error body})
   ))))

 (defn- get-note [note-id rsp-ch]
@@ -111,27 +82,25 @@
     (let [{:keys [status body] :as srv-rsp} (<! (http/get (str "/note/" note-id)))]
       (case status
         200 (put! rsp-ch {:ok? true :note body})
-        (println "ooops, couldn't get note" note-id)
+        (put! rsp-ch {:ok? false :error body})
   ))))

 ;;; server control

 (defn init [ch]
   (go (while true
-    (let [data (<! ch)
-          {:keys [tag rsp-ch]} data]
+    (let [{:keys [tag rsp-ch] :as data} (<! ch)]
       (case tag
         ; TODO: xxx
         :sign-up (println "sign-up" data)
         :sign-in (println "sign-in" data)
         :sign-out (println "sign-out" data)
         :create-note (create-note (:user-id data) (:text data) (:visibility data) rsp-ch)
-        :edit-note (println "editing note" data)
         :delete-note (delete-note (:note-id data) rsp-ch)
         :update-note (update-note (:note data) rsp-ch)
         :get-note (get-note (:note-id data) rsp-ch)
         :get-private-notes (get-private-notes (:user-id data) rsp-ch)
-        :get-public-notes (println "retrieving public notes" data)
+        :get-public-notes (get-public-notes rsp-ch)
         (do
           (println "oops" data)
           (put! rsp-ch data))


Reorganize icons in sidebar and add labels

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -485,70 +485,90 @@
         (html
           [:nav.aside-left-nav

-           [:a.aside-item.logo {:title "Home"
+            [:a.aside-item.logo {:title "Home"
                                 :data-placement "right"
                                 :data-trigger "hover"
                                 :href "/"}
             [:div.logomark
              (common/ico :logo)]]

-           [:a.aside-item.avatar {:data-placement "right"
-                                  :data-trigger "hover"
-                                  :title "Settings"
-                                  :href "/account"}
-            [:img.account-avatar {:src avatar-url}]]
-
-           [:a.aside-item {:title "Documentation"
-                           :data-placement "right"
-                           :data-trigger "hover"
-                           :href "/docs"}
-            (nav-icon "fa-copy" "Docs")]
-
-           [:a.aside-item (merge (common/contact-support-a-info owner)
+            [:a.aside-item {:data-placement "right"
+                            :data-trigger "hover"
+                            :title "Builds"
+                            :href "/"}
+             (nav-icon "fa-list" "Builds")
+             [:div.nav-label "Builds"]]
+
+            [:a.aside-item {:data-placement "right"
+                            :data-trigger "hover"
+                            :title "Insights"
+                            :href "/build-insights"}
+             (nav-icon "fa-bar-chart" "Insights")
+             [:div.nav-label "Insights"]]
+
+            [:a.aside-item {:href "/add-projects",
+                            :data-placement "right"
+                            :data-trigger "hover"
+                            :title "Add projects"}
+             (nav-icon "fa-plus-circle" "AddProject")
+             [:div.nav-label "Projects"]]
+
+            [:a.aside-item {:href "/invite-teammates",
+                            :data-placement "right"
+                            :data-trigger "hover"
+                            :title "Invite your teammates"}
+              (nav-icon "fa-user-plus" "Team")
+              [:div.nav-label "Team"]]
+
+            [:a.aside-item {:data-placement "right"
+                                   :data-trigger "hover"
+                                   :title "Account Settings"
+                                   :href "/account"}
+              (nav-icon "fa-cog" "Builds")
+              [:div.nav-label "Account Settings"]]
+
+            [:hr]
+
+            [:a.aside-item {:title "Documentation"
+                            :data-placement "right"
+                            :data-trigger "hover"
+                            :href "/docs"}
+              (nav-icon "fa-copy" "Docs")
+              [:div.nav-label "Docs"]]
+
+            [:a.aside-item (merge (common/contact-support-a-info owner)
                                  {:title "Support"
                                   :data-placement "right"
                                   :data-trigger "hover"
                                   :data-bind "tooltip: {title: 'Support', placement: 'right', trigger: 'hover'}"})
-            (nav-icon "fa-comments" "Support")]
-
-           [:a.aside-item {:href "/add-projects",
-                           :data-placement "right"
-                           :data-trigger "hover"
-                           :title "Add Projects"}
-            (nav-icon "fa-plus-circle" "AddProject")]
-
-           [:a.aside-item {:href "/invite-teammates",
-                           :data-placement "right"
-                           :data-trigger "hover"
-                           :title "Invite your teammates"}
-            (nav-icon "fa-user" "Team")]
-
-           [:a.aside-item {:data-placement "right"
-                           :data-trigger "hover"
-                           :title "Changelog"
-                           :href "/changelog"
-                           :class (when (changelog-updated-since? (:last_viewed_changelog user))
+              (nav-icon "fa-comments" "Support")
+              [:div.nav-label "Support"]]
+
+            [:a.aside-item {:data-placement "right"
+                            :data-trigger "hover"
+                            :title "Changelog"
+                            :href "/changelog"
+                            :class (when (changelog-updated-since? (:last_viewed_changelog user))
                                     "unread")}
-            (nav-icon "fa-bell" "Notifications")]
-
-	   [:a.aside-item {:data-placement "right"
-                           :data-trigger "hover"
-                           :title "Insights"
-                           :href "/build-insights"}
-            (nav-icon "fa-bar-chart" "Insights")]
-
-           (when (:admin user)
-             [:a.aside-item {:data-placement "right"
-                             :data-trigger "hover"
-                             :title "Admin"
-                             :href "/admin"}
-              (nav-icon "fa-cogs" "Admin")])
-
-           [:a.aside-item.push-to-bottom {:data-placement "right"
-                                          :data-trigger "hover"
-                                          :title "Logout"
-                                          :href "/logout"}
-            (nav-icon "fa-power-off" "Power")]])))))
+              (nav-icon "fa-bell" "Changelog")
+              [:div.nav-label "Changelog"]]
+
+            [:hr]
+
+            (when (:admin user)
+              [:a.aside-item {:data-placement "right"
+                              :data-trigger "hover"
+                              :title "Admin"
+                              :href "/admin"}
+                (nav-icon "fa-cogs" "Admin")
+                [:div.nav-label "Admin"]])
+
+            [:a.aside-item.push-to-bottom {:data-placement "right"
+                                           :data-trigger "hover"
+                                           :title "Logout"
+                                           :href "/logout"}
+              (nav-icon "fa-power-off" "Power")
+              [:div.nav-label "Logout"]]])))))

 (defn aside [app owner]
   (reify


test component

test component

--- src-cljs/frontend/components/build.cljs
+++ src-cljs/frontend/components/build.cljs
@@ -87,8 +87,14 @@
                         :build-running? build-running?
                         :current-container-id current-container-id}
                        {:react-key (:index container)}))
-           (when (om/get-shared owner [:ab-tests :parallelism_button])
+           (when (om/get-shared owner [:ab-tests :parallelism_button_design])
              [:a.container-selector.parallelism-tab
+              {:role "button"
+               :href (build-model/path-for-parallelism build)
+               :title "adjust parallelism"}
+              [:span "+"]])
+           (when-not (om/get-shared owner [:ab-tests :parallelism_button_design])
+                [:a.container-selector.parallelism-tab-b
               {:role "button"
                :href (build-model/path-for-parallelism build)
                :title "adjust parallelism"}


Conservatories

Conservatories

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -372,7 +372,7 @@
                (text-control profile_data state owner :profile_air_in_winter "Air In Winter")
                (text-control profile_data state owner :profile_lightning "Lightning")
                (text-control profile_data state owner :profile_noise "Noise")
-               (text-control profile_data state owner :profile_comfort "Comfort")
+               (text-control profile_data state owner :profile_comfort "Comfort")
                (text-control profile_data state owner :profile_design "Design")
                (text-control profile_data state owner :profile_needs "Needs")
                (text-control profile_data state owner :profile_health "Health (perceived)")
@@ -400,6 +400,28 @@
                (text-control profile_data state owner :sap_version_year "SAP Version Year")
                (text-control profile_data state owner :sap_regulations_date "SAP Regulations Date")
                (text-control profile_data state owner :sap_software "Name of SAP Software")])]))]))))
+
+(defn conservatories-row [profiles owner]
+  (reify
+    om/IRenderState
+    (render-state [_ state]
+      (html
+       [:div.col-md-12
+        (for [profile profiles]
+          [:div {:class (profile-column-width)}
+           (bs/panel
+            "Conservatories"
+            (if-let [conservatories (seq (:conservatories profile))]
+              [:div {:class (profile-column-width)}
+               (for [c conservatories]
+                 (bs/panel
+                  "Conservtory"
+                  [(text-control c state owner :conservatory_type "Conservatory Type")
+                   (text-control c state owner :area "Area")
+                   (text-control c state owner :double_glazed "Double Glazed")
+                   (text-control c state owner :glazed_perimeter "Glazed Perimeter")
+                   (text-control c state owner :height "Height")]))]
+              [:p "No conservatories."]))])]))))

 (defn profile-rows [profiles owner]
   (reify
@@ -428,9 +450,9 @@
          (om/build bus-survey-information-row profiles)
          (om/build project-details-row profiles)
          ;; (om/build documents profiles)
-
+
          ;; dwelling details
-         ;; (om/build conservatories profiles)
+         (om/build conservatories-row profiles)
          ;; (om/build extensions profiles)
          ;; (om/build heating-systems profiles)
          ;; (om/build hot-water-systems profiles)
@@ -444,7 +466,7 @@
          ;; (om/build low-energy-lights profiles)
          ;; (om/build ventilation-systems profiles)
          ;; (om/build airflow-measurements profiles)
-
+
          ;; renewable energy systems
          ;; (om/build photovoltaic-panels profiles)
          ;; (om/build solar-thermal-panels profiles)
@@ -454,7 +476,7 @@
          ;; (om/build biomass-boilers profiles)
          ;; (om/build mCHP-systems profiles)
          ]])))
-
+
   )

 (defn profiles-div [data owner]
@@ -474,7 +496,7 @@

 (comment
-
+
   (text-control profile_data state owner :annual_heating_load "Annual Heating Load")
   (text-control profile_data state owner :completeness "Completeness")
   (text-control profile_data state owner :conservation_issues "Conservation Issues")


y-axes 0 unless some numbers are negative

--- src-cljs/kixi/hecuba/widgets/chart.cljs
+++ src-cljs/kixi/hecuba/widgets/chart.cljs
@@ -88,7 +88,7 @@
 (defn y-scale-min-value [left-series right-series]
   (let [series1-min (let [m (apply min (map :value left-series))] (if (= 0 m) 1 m))
         series2-min (let [m (apply min (map :value right-series))] (if (= 0 m) 1 m))]
-    (or (min series1-min series2-min) 0)))
+    (min series1-min series2-min 0)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Draw chart


Fix docstring typos

Fix docstring typos

Minor

--- src/buddy/auth/middleware.clj
+++ src/buddy/auth/middleware.clj
@@ -29,7 +29,7 @@
   provided request).

   NOTE: this function is for internal use, it is public
-  because it is helpfull in enviroments different to ring."
+  because it is helpful in environments different to ring."
   [request backends]
   (loop [[backend & backends] backends]
     (when backend
@@ -44,7 +44,7 @@
   given each of them gets a chance to authenticate the request.

   NOTE: this function is for internal use, it is public
-  because it is helpfull in enviroments different to ring."
+  because it is helpful in environments different to ring."
   [request & backends]
   (if-let [authdata (authenticate-request request backends)]
     (assoc request :identity authdata)


added weak url

added weak url

--- src/crawler/rich_extractor.clj
+++ src/crawler/rich_extractor.clj
@@ -186,9 +186,8 @@
                 xpaths)]
     (apply + upds)))

-(defn pick-paginator
+(defn pick-paginator-updated
   "Picks one XPath for pagination
-
    Args:
     {xpath: sample-bodies,...}
    Returns:
@@ -208,22 +207,45 @@
             [xpath (/ (apply + s) (count s))]))
         pagination-candidates))))))

+(defn pick-paginator-weakest
+  "A pagination that uses the least number of
+   avg. tokens and the least number of total chars
+   is picked for this purpose"
+  [pagination-candidates]
+  (first
+   (first
+    (sort-by
+     second
+     (map
+      (fn [[a-candidate tokens]]
+        [a-candidate
+         (if (empty? tokens)
+           0
+           (/ (apply + (map count tokens))
+              (count tokens)))])
+      pagination-candidates)))))
+
 (defn weak-pagination-detector
   ([page-src url]
      (weak-pagination-detector page-src url (set [])))

   ([page-src url blacklist]
      (let [in-host-xpaths-hrefs (state-action page-src url blacklist)
+
            xpaths-hrefs         (into
                                  {} (map
                                      (fn [[xpath nodes]]
                                        [xpath (map #(-> % :href) nodes)])
                                      in-host-xpaths-hrefs))
+
            xpaths-tokenized     (tokenize-actions in-host-xpaths-hrefs)
+
            xpaths-scored        (sort-by second
                                          (score-actions xpaths-tokenized))
+
            mean-richness        (/ (apply + (map second xpaths-scored))
                                    (count xpaths-scored))
+
            xpaths-considered    (map
                                  (fn [[xpath _]]
                                    [xpath (xpaths-hrefs xpath)])
@@ -231,26 +253,47 @@
                                   (fn [[xpath score]]
                                     (< score mean-richness))
                                   xpaths-scored))
+
            xpaths-samples       (map
                                  (fn [[xpath links]]
                                    [xpath (sample/sample-some-links links blacklist)])
                                  xpaths-considered)
+
            xpaths-samples-map   (into {} xpaths-samples)
+
            pagination-cands     (map
                                  first
                                  (filter
                                   #(pagination? page-src %)
                                   xpaths-samples))
-           pagination-ds        (map
+
+           pagination-xhref-ds  (map
                                  (fn [an-xpath]
-                                   [an-xpath (map (fn [a-sample]
-                                                    (into
-                                                     {} (map
-                                                         (fn [[xpath nodes]]
-                                                           [xpath (map #(-> % :href) nodes)])
-                                                         (dom/xpaths-hrefs-tokens
-                                                          (dom/html->xml-doc a-sample)
-                                                          url))))
-                                                  (xpaths-samples-map an-xpath))])
-                                 pagination-cands)]
-       (pick-paginator xpaths-hrefs pagination-ds blacklist))))
+                                   [an-xpath
+                                    (map (fn [a-sample]
+                                           (into
+                                            {} (map
+                                                (fn [[xpath nodes]]
+                                                  [xpath (map #(-> % :href) nodes)])
+                                                (dom/xpaths-hrefs-tokens
+                                                 (dom/html->xml-doc a-sample)
+                                                 url))))
+                                         (xpaths-samples-map an-xpath))])
+                                 pagination-cands)
+
+           pagination-token-ds  (map
+                                 (fn [an-xpath]
+                                   [an-xpath (let [xp-toks (xpaths-tokenized an-xpath)]
+                                               (sort-by
+                                                count
+                                                (reduce
+                                                 clojure.set/union
+                                                 (map
+                                                  (fn [a-tok-map]
+                                                    (:text-tokens a-tok-map))
+                                                  xp-toks))))])
+                                 pagination-cands)
+
+           picked-xpath         (pick-paginator-weakest pagination-token-ds)]
+
+       [picked-xpath (xpaths-hrefs picked-xpath)])))


Fix test again �

Fix test again �

--- src/main/clojure/pdok/featured/json_reader.clj
+++ src/main/clojure/pdok/featured/json_reader.clj
@@ -94,7 +94,7 @@
        (-> element first (clojure.string/starts-with? "~#"))))

 (defn- get-valid-srid [geometry]
-  (if-let [^String srid (get geometry "srid")]
+  (if-let [srid (get geometry "srid")]
     (Integer. srid)))

 (defn create-geometry-attribute [geometry]


'Probably will break things but' TOTALLY broke things

--- src/degasolv/resolver_spec.clj
+++ src/degasolv/resolver_spec.clj
@@ -6,13 +6,13 @@
                     :greater-equal
                     :greater-than})

-(def str-id-pattern "[^!=<>]*")
+(def str-id-pattern "[^>=<!;,|]+")
 (def id-regex (re-pattern (str "^" str-id-pattern "$")))

 (s/def ::id (s/and
               string?
-              #(re-matches #"^[^!=<>]+$")
-              #(re-matches #"^\p{Print}+$")))
+              #(re-matches id-regex %)
+              #(re-matches #"^\p{Print}+$" %)))

 (def str-version-pattern "(\\p{Alnum}|\\p{Punct})*")

@@ -79,7 +79,6 @@

 (def str-equals-pattern "==")
 (def str-relation-pattern "(>=|==|!=|<=|<|>)")
-(def str-id-pattern "[^>=<!;,|]+")
 (def str-version-predicate-pattern
   (str str-relation-pattern
        str-version-pattern))


Fix NPE

Fix NPE

--- src/dfgm/services/game/cmd.clj
+++ src/dfgm/services/game/cmd.clj
@@ -27,7 +27,7 @@

 (defmethod handle-cmd :register [gm cmd]
   (let [ch  (:ch cmd)
-        ret (new-or-join-game gm {:ch ch :duration (:duration cmd)})]
+        ret (new-or-join-game gm cmd)]
     (send-cmd! ch (assoc ret :type :registered))
     (start-game-if-possible gm (:game-id ret))))


Use the correct content type for served files.

--- src/clj/cljs/repl/browser.clj
+++ src/clj/cljs/repl/browser.clj
@@ -60,31 +60,44 @@
     404 "HTTP/1.1 404 Not Found"
     "HTTP/1.1 500 Error"))

+(def content-types {".js" "text/javascript"
+                    ".html" "text/html"})
+
+(defn content-type [file-name]
+  (let [idx (.lastIndexOf file-name ".")
+        ext (.substring file-name idx)]
+    (get content-types ext "text/html")))
+
 (defn send-and-close
   "Use the passed connection to send a form to the browser. Send a
   proper HTTP response."
-  [conn status form]
-  (let [utf-8-form (.getBytes form "UTF-8")
-        content-length (count utf-8-form)
-        headers (map #(.getBytes (str % "\r\n"))
-                     [(status-line status)
-                      "Server: ClojureScript REPL"
-                      "Content-Type: text/html; charset=utf_8"
-                      (str "Content-Length: " content-length)
-                      ""])]
-    (with-open [os (.getOutputStream conn)]
-      (do (doseq [header headers]
-            (.write os header 0 (count header)))
-          (.write os utf-8-form 0 content-length)
-          (.flush os)
-          (.close conn)))))
+  ([conn status form]
+     (send-and-close conn status form "text/html"))
+  ([conn status form content-type]
+     (let [utf-8-form (.getBytes form "UTF-8")
+           content-length (count utf-8-form)
+           headers (map #(.getBytes (str % "\r\n"))
+                        [(status-line status)
+                         "Server: ClojureScript REPL"
+                         (str "Content-Type: "
+                              content-type
+                              "; charset=utf-8")
+                         (str "Content-Length: " content-length)
+                         ""])]
+       (with-open [os (.getOutputStream conn)]
+         (do (doseq [header headers]
+               (.write os header 0 (count header)))
+             (.write os utf-8-form 0 content-length)
+             (.flush os)
+             (.close conn))))))

 (defn send-404 [conn path]
   (send-and-close conn 404
                   (str ""
                        "
Page not found
"
                        "No page " path " found on this server."
-                       "")))
+                       "")
+                  "text/html"))

 (defn send-for-eval
   "Given a form and a return value function, send the form to the
@@ -92,7 +105,7 @@
   when the return value is received."
   [form return-value-fn]
   (do (set-return-value-fn return-value-fn)
-      (send-and-close @(connection) 200 form)))
+      (send-and-close @(connection) 200 form "text/javascript")))

 (defn return-value
   "Called by the server when a return value is received."
@@ -170,7 +183,8 @@
       </script>

-      ")))
+      ")
+    "text/html"))

 (defn handle-get [opts conn request]
   (let [path (:path request)]
@@ -178,7 +192,7 @@
       (send-repl-client-page opts conn request)
       (let [file (io/file (str (:root opts) path))]
         (if (.exists file)
-          (send-and-close conn 200 (slurp file))
+          (send-and-close conn 200 (slurp file) (content-type (.getName file)))
           (send-404 conn (:path request)))))))

 (defn- handle-connection


Nashorn environment doesn't supply console, setup printing correctly

--- src/clj/cljs/repl/nashorn.clj
+++ src/clj/cljs/repl/nashorn.clj
@@ -155,7 +155,8 @@
       (repl/evaluate-form this env repl-filename
         '(do
            (.require js/goog "cljs.core")
-           (cljs.core/enable-console-print!)))
+           (set! *print-newline* false)
+           (set! *print-fn* js/print)))
       ;; monkey-patch goog.isProvided_ to suppress useless errors
       (repl/evaluate-form this env repl-filename
         '(set! js/goog.isProvided_ (fn [ns] false)))


Fill out the sites API call

Fill out the sites API call

--- src/clj/comic_reader/core.clj
+++ src/clj/comic_reader/core.clj
@@ -1,6 +1,7 @@
 (ns comic-reader.core
   (:gen-class)
-  (:require [ring.util.response :as response]
+  (:require [comic-reader.scrape :as scrape]
+            [ring.util.response :as response]
             [ring.middleware.params :refer [wrap-params]]
             [compojure.core  :as c]
             [compojure.route :as route]))
@@ -13,7 +14,10 @@
 (c/defroutes routes
   (c/GET "/" [] "Hello World!")
   (c/context "/api/v1" []
-    (c/GET "/comics" []
+    (c/GET "/sites" []
+      (edn-response (vec (map #(select-keys % [:name :url])
+                              scrape/sites))))
+    (c/GET "/comics/:site" [site]
       "All the comics.")
     (c/GET "/comic/:name" [name]
       (str "Hello comic" name)))


removed todo notes from walk.

removed todo notes from walk.

--- src/clj/forma/matrix/walk.clj
+++ src/clj/forma/matrix/walk.clj
@@ -2,11 +2,6 @@
   (:use cascalog.api
         [forma.matrix.utils :only (insert-into-val
                                    insert-at)]))
-
-;; TODO: -- documentation on why we do this. Nearest neighbor analysis
-;; links.
-
-;; TODO: update walk-matrix to return useful shit.

 (defn walk-matrix
   "Walks along the rows and columns of a matrix at the given window
@@ -44,11 +39,12 @@
   "apply a function `fn` to each element in a matrix `mat` over a moving
   window, defined by the number of neighbors."
   [f num-neighbors mat]
-  {:pre [(> (count mat) (+ 1 (* 2 num-neighbors)))]}
+  {:pre [(> (count mat)
+            (inc (* 2 num-neighbors)))]}
   (let [window  (+ 1 (* 2 num-neighbors))
         new-mat (buffer-matrix num-neighbors nil mat)]
     (map (comp
           (partial apply f)
-          (partial filter #(not= nil %))
+          (partial filter (complement nil?))
           flatten)
          (walk-matrix new-mat window))))


Removed Resource encoding on server side

Replaced with xhr requests

--- src/clj/my_project/server.clj
+++ src/clj/my_project/server.clj
@@ -16,18 +16,8 @@
 (deftemplate page (io/resource "index.html") []
   [:body] (if is-dev? inject-devmode-html identity))

-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(def type-to-mtype
-  {:png "image/png"})
-
-
-(def default-mime-type "application/octet-stream")
-
-(defn mime-type-from-ext [kword]
-  (get type-to-mtype kword default-mime-type))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
 (defn read-file [file-name]
   (let [f (file file-name)
         length (.length f)
@@ -37,38 +27,11 @@
     buffer
     ))

-
-(defn get-enc-64-as-str [file]
-  (->>
-    file
-    (read-file)
-    (base64/encode-bytes)
-    (map char)
-    (apply str)))
-
-(defn get-file-as-mime-type [rez-name mime-type]
-  (->>
-    (io/resource rez-name)
-    (get-enc-64-as-str)
-    (str "data:" mime-type ";base64,")))
-
-(defn get-png-enc [name]
-  (get-file-as-mime-type (str  "public/data/" name ".png"), "image/png"))
-
-
-(defn get-rez [rez-name rez-type]
-  (let [file-name (str "public/data/" rez-name "." rez-type)
-        mime-type (mime-type-from-ext (keyword rez-type)) ]
-    (get-file-as-mime-type file-name mime-type)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defroutes routes
   (resources "/")
   (resources "/react" {:root "react"})

-  (GET ["/rez/:rez-type/:rez-name" :rez-name #".*" :rez-type #".*"]
-       [rez-name rez-type]
-       (get-rez rez-name rez-type))

   (GET "/" req (page)))


add test for Toshiyuki Sakai

add test for Toshiyuki Sakai

--- src/clj/test/cards-assets.clj
+++ src/clj/test/cards-assets.clj
@@ -519,6 +519,31 @@
       (is (nil? (:ts-active (refresh tsp1))) "Team Sponsorship 1 ability disabled")
       (is (nil? (:ts-active (refresh tsp2))) "Team Sponsorship 2 ability disabled"))))

+(deftest toshiyuki-sakai
+  "Toshiyuki Sakai - Swap with an asset/agenda from HQ; Runner can choose to access new card or not"
+  (do-game
+    (new-game (default-corp [(qty "Toshiyuki Sakai" 1) (qty "Project Junebug" 1) (qty "Hedge Fund" 1)])
+              (default-runner [(qty "Sure Gamble" 3) (qty "Easy Mark" 2)]))
+    (play-from-hand state :corp "Toshiyuki Sakai" "New remote")
+    (let [toshi (get-content state :remote1 0)]
+      (core/advance state :corp {:card (refresh toshi)})
+      (core/advance state :corp {:card (refresh toshi)})
+      (take-credits state :corp)
+      (is (= 2 (:advance-counter (refresh toshi))) "Toshiyuki has 2 advancements")
+      (run-empty-server state "Server 1")
+      (is (= :waiting (-> @state :runner :prompt first :prompt-type))
+          "Runner has prompt to wait for Toshiyuki")
+      (prompt-choice :corp "Yes") ; choose to do a swap
+      (prompt-select :corp (find-card "Hedge Fund" (:hand (get-corp))))
+      (is (= (refresh toshi) (get-content state :remote1 0)) "Toshiyuki still in remote; can't target an operation in hand")
+      (prompt-select :corp (find-card "Project Junebug" (:hand (get-corp))))
+      (let [june (get-content state :remote1 0)]
+        (is (= "Project Junebug" (:title (refresh june))) "Project Junebug swapped into Server 1")
+        (is (= 2 (:advance-counter (refresh june))) "Project Junebug has 2 advancements")
+        (prompt-choice :runner "Yes") ; choose to access new card
+        (prompt-choice :corp "Yes") ; pay 1c to fire Junebug
+        (is (= 4 (count (:discard (get-runner)))) "Runner took 4 net damage")))))
+
 (deftest turtlebacks
   "Turtlebacks - Gain 1 credit for every new server created"
   (do-game


tests for Drive By, Inject, Retrieval Run, Singularity

--- src/clj/test/cards-events.clj
+++ src/clj/test/cards-events.clj
@@ -124,6 +124,36 @@
       (is (= 2 (count (:discard (get-corp)))) "2 cards in Archives")
       (is (empty? (:prompt (get-runner))) "Run concluded"))))

+(deftest drive-by
+  "Drive By - Expose card in remote server and trash if asset or upgrade"
+  (do-game
+    (new-game (default-corp [(qty "Eve Campaign" 2) (qty "Product Placement" 1) (qty "Project Atlas" 1)])
+              (default-runner [(qty "Drive By" 2)]))
+    (core/gain state :corp :click 1)
+    (play-from-hand state :corp "Eve Campaign" "New remote")
+    (play-from-hand state :corp "Eve Campaign" "New remote")
+    (play-from-hand state :corp "Project Atlas" "New remote")
+    (play-from-hand state :corp "Product Placement" "HQ")
+    (take-credits state :corp)
+    (let [eve1 (get-in @state [:corp :servers :remote1 :content 0])
+          eve2 (get-in @state [:corp :servers :remote2 :content 0])
+          atl (get-in @state [:corp :servers :remote3 :content 0])
+          pp (get-in @state [:corp :servers :hq :content 0])]
+      (core/rez state :corp eve1)
+      (play-from-hand state :runner "Drive By")
+      (prompt-select :runner pp)
+      (is (= 1 (count (get-in @state [:corp :servers :hq :content]))) "Upgrades in root of central servers can't be targeted")
+      (prompt-select :runner (refresh eve1))
+      (is (= 1 (count (get-in @state [:corp :servers :remote1 :content]))) "Rezzed cards can't be targeted")
+      (prompt-select :runner eve2)
+      (is (= 2 (:click (get-runner))) "Spent 2 clicks")
+      (is (and (= 1 (count (:discard (get-corp)))) (= 5 (:credit (get-runner)))) "Eve trashed at no cost")
+      (is (nil? (get-in @state [:corp :servers :remote2 :content])) "Server 2 no longer exists")
+      (play-from-hand state :runner "Drive By")
+      (prompt-select :runner atl)
+      (is (= 0 (:click (get-runner))))
+      (is (= 1 (count (get-in @state [:corp :servers :remote3 :content]))) "Project Atlas not trashed from Server 3"))))
+
 (deftest freelance-coding-contract
   "Freelance Coding Contract - Gain 2 credits per program trashed from Grip"
   (do-game
@@ -138,6 +168,22 @@
     (is (= 3 (count (filter #(= (:type %) "Program") (:discard (get-runner))))) "3 programs in Heap")
     (is (= 11 (:credit (get-runner))) "Gained 6 credits from 3 trashed programs")))

+(deftest inject
+  "Inject - Draw 4 cards from Stack and gain 1 credit per trashed program"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Inject" 1) (qty "Imp" 2) (qty "Sure Gamble" 2)]))
+    (take-credits state :corp)
+    (core/move state :runner (find-card "Imp" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Imp" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
+    (is (= 4 (count (:deck (get-runner)))))
+    (play-from-hand state :runner "Inject")
+    (is (= 2 (count (:hand (get-runner)))) "2 non-programs kept in Grip")
+    (is (= 2 (count (filter #(= (:type %) "Program") (:discard (get-runner))))) "2 programs in Heap")
+    (is (= 6 (:credit (get-runner))) "Paid 1 credit to play Inject, gained 2 credits from trashed programs")))
+
 (deftest notoriety
   "Notoriety - Run all 3 central servers successfully and play to gain 1 agenda point"
   (do-game
@@ -157,6 +203,44 @@
     (play-from-hand state :runner "Notoriety")
     (is (= 1 (count (:scored (get-runner)))) "Notoriety moved to score area")
     (is (= 1 (:agenda-point (get-runner))) "Notoriety scored for 1 agenda point")))
+
+(deftest retrieval-run
+  "Retrieval Run - Run Archives successfully and install a program from Heap for free"
+  (do-game
+    (new-game (default-corp)
+              (default-runner [(qty "Retrieval Run" 1) (qty "Morning Star" 1)]))
+    (take-credits state :corp)
+    (core/move state :runner (find-card "Morning Star" (:hand (get-runner))) :discard)
+    (play-from-hand state :runner "Retrieval Run")
+    (is (= [:archives] (get-in @state [:run :server])) "Run initiated on Archives")
+    (core/no-action state :corp nil)
+    (core/successful-run state :runner nil)
+    (prompt-choice :runner "Run ability")
+    (let [ms (first (:discard (get-runner)))]
+      (prompt-choice :runner ms)
+      (is (= "Morning Star" (:title (first (get-in @state [:runner :rig :program])))))
+      (is (= 2 (:credit (get-runner))) "Morning Star installed at no cost")
+      (is (= 2 (:memory (get-runner)))))))
+
+(deftest singularity
+  "Singularity - Run a remote; if successful, trash all contents at no cost"
+  (do-game
+    (new-game (default-corp [(qty "Caprice Nisei" 1) (qty "Breaker Bay Grid" 1) (qty "Eve Campaign" 1)])
+              (default-runner [(qty "Singularity" 1)]))
+    (play-from-hand state :corp "Breaker Bay Grid" "New remote")
+    (play-from-hand state :corp "Caprice Nisei" "Server 1")
+    (play-from-hand state :corp "Eve Campaign" "Server 1")
+    (take-credits state :corp)
+    (play-from-hand state :runner "Singularity")
+    (prompt-choice :runner "Server 1")
+    (is (= 2 (:click (get-runner))))
+    (is (= 1 (:credit (get-runner))))
+    (core/no-action state :corp nil)
+    (core/successful-run state :runner nil)
+    (prompt-choice :runner "Run ability")
+    (is (= 3 (count (:discard (get-corp)))) "All 3 cards trashed from Server 1")
+    (is (= 1 (:credit (get-runner))) "No credits paid for trashing")
+    (is (nil? (get-in @state [:corp :servers :remote1 :content])) "Server 1 no longer exists")))

 (deftest stimhack
   "Stimhack - Gain 9 temporary credits and take 1 brain damage after the run"


Make numpad 5 also harvest current cell

Make numpad 5 also harvest current cell

--- src/cljc/robinson/update.cljc
+++ src/cljc/robinson/update.cljc
@@ -132,7 +132,7 @@
                                                                  ;(log/info "cell place-id" (str (rv/xy->place-id state x y)))
                                                                  ;(log/debug "blocking?" x y cell blocking?)
                                                                  blocking?)))
-        #_#__ (log/info "visible-cells" visible-cells)
+        _ (log/info "visible-cells" visible-cells)
         dwtl             (/ (reduce (fn [acc [x y]] (+ acc (- (dec new-time)
                                                               (get (rw/get-cell state x y) :discovered (- new-time 10000)))))
                                  0 visible-cells)
@@ -2517,6 +2517,7 @@
                            \o          [identity               :open            false]
                            \c          [identity               :close           false]
                            \.          [do-rest                :normal          true]
+                           :numpad5    [do-rest                :normal          true]
                            :left       [move-left              :normal          true]
                            :down       [move-down              :normal          true]
                            :up         [move-up                :normal          true]
@@ -2631,6 +2632,7 @@
                            :down       [harvest-down           :normal          true]
                            :up         [harvest-up             :normal          true]
                            :right      [harvest-right          :normal          true]
+                           :numpad5    [harvest-center         :normal          true]
                            \>          [harvest-center         :normal          true]
                            :escape     [identity               :normal          false]}
                :wield     {:escape     [identity               :normal          false]


Adding a font for text fields

Adding a font for text fields

--- src/cljs/hatti/ona/forms.cljs
+++ src/cljs/hatti/ona/forms.cljs
@@ -107,9 +107,10 @@
   "Get the icon relevant to the given field (depending on its type)."
   [:i {:class
        (cond
+         (text? field)        "fa fa-font"
          (time-based? field)  "fa fa-clock-o"
          (numeric? field)     "fa fa-bar-chart"
-         (calculate? field)  "fa fa-bar-chart"
+         (calculate? field)   "fa fa-bar-chart"
          (categorical? field) "fa fa-bar-chart fa-flip-h-rotate-90"
          :else                "")}])


Use-cache and delete-workdirs INI options should be handled as booleans

--- src/emender_service/config.clj
+++ src/emender_service/config.clj
@@ -38,7 +38,9 @@
     (-> configuration
         (update-in [:jenkins :port] parse-int)
         (update-in [:result-cache :pretty-print] parse-boolean)
-        (update-in [:config :verbose] parse-boolean)))
+        (update-in [:result-cache :use-cache] parse-boolean)
+        (update-in [:config :verbose] parse-boolean)
+        (update-in [:config :delete-workdirs] parse-boolean)))

 (defn load-configuration
     "Load configuration from the provided INI file."
@@ -75,3 +77,7 @@
     [request]
     (-> request :configuration :result-cache :pretty-print))

+(defn delete-workdirs?
+    [request]
+    (-> request :configuration :config :delete-workdirs))
+


upgrade to newest goboard.js and use a test function for make-move

--- src/greybear/server.clj
+++ src/greybear/server.clj
@@ -24,7 +24,7 @@
      [:body
       [:div#players "Players: " (game :white) " vs. " (game :black)]
       [:canvas#goBoard]
-      (javascript-tag (format "goboard.draw(\"goBoard\", %s, 1, 18, 17);"
+      (javascript-tag (format "goboard.draw(\"goBoard\", %s, 1, function(x, y) {console.log(x, y)}, 18, 17);"
                               (stones-to-js (game :stones))))])))

 (defroutes main-routes


Switch cambered cl equation to use cl=Pi*(2A0 + A1)

Add function A-0 and A-1, modified cambered-coefficiant-of-lift

--- src/hydrofoil/model.clj
+++ src/hydrofoil/model.clj
@@ -205,14 +205,27 @@
         camber-position (individual :corrected-position-camber)]
     (* 2 (Math/PI) attack-angle)))

+(defn A-0
+  [individual run-constants]
+  (let [attack-angle (run-constants :angle-of-attack-radians)
+        theta-switch-constant (theta-switch individual)]
+    (- attack-angle
+       (* (/ 1 (Math/PI))
+          (+ (integral-production individual gradient-forward-polar-function 0 theta-switch-constant (/ theta-switch-constant 90) 90)
+             (integral-production individual gradient-aft-polar-function theta-switch-constant (Math/PI) (/ (- ((Math/PI) theta-switch-constant)) 90) 90))))))
+
+(defn A-1
+  [individual run-constants]
+  (let [theta-switch-constant (theta-switch individual)]
+    (* (/ 2 (Math/PI))
+       (+ (integral-production individual gradient-forward-polar-function 0 theta-switch-constant (/ theta-switch-constant 90) 90)
+          (integral-production individual gradient-aft-polar-function theta-switch-constant (Math/PI) (/ (- (Math/PI) theta-switch-constant) 90) 90)))))
+
+
 (defn cambered-coefficient-of-lift
   [individual run-constants]
-  (let [attack-angle (run-constants :angle-of-attac-radians)
-        theta-switch-constant (theta-switch individual)]
-    (- (* 2 (Math/PI))
-       (* 2 (+ (integral-production individual gradient-forward-polar-function 0 theta-switch-constant (/ theta-switch-constant 90) 90)
-               (integral-production individual gradient-aft-polar-function theta-switch-constant (Math/PI) (/ theta-switch-constant 90) 90))))))
-
+  (+ (* 2 (Math/PI) (A-0 individual run-constants))
+     (* (Math/PI) (A-1 individual run-constants))))

 (defn coefficient-of-lift
   [individual run-constants]


Cleanup debug

Cleanup debug

--- src/clojure/clojurewerkz/cassaforte/debug.clj
+++ src/clojure/clojurewerkz/cassaforte/debug.clj
@@ -16,13 +16,6 @@
   "Debug utilities"
   (:require [clojure.stacktrace :refer :all]))

-(defmacro output-debug
-  "Prints debugging statements out."
-  [q]
-  `(do
-     (println "Built query: " ~q)
-     ~q))
-
 (defmacro catch-exceptions
   "Catches driver exceptions and outputs stacktrace."
   [& forms]


Cosmetics

Cosmetics

--- src/clojure/clojurewerkz/cassaforte/uuids.clj
+++ src/clojure/clojurewerkz/cassaforte/uuids.clj
@@ -1,7 +1,7 @@
 (ns clojurewerkz.cassaforte.uuids
   "Provides utility functions for UUID generation."
   (:import [com.datastax.driver.core.utils UUIDs]
-           [java.util UUID]))
+           java.util.UUID))

 (defn random
   "Creates a new random (version 4) UUID."


Cheaper assert/retract in old runtime

Cheaper assert/retract in old runtime

--- src/aurora/language/representation.cljs
+++ src/aurora/language/representation.cljs
@@ -53,10 +53,10 @@
         retracted (:retracted kn)
         name->schema (:name->schema kn)]
     (doseq [fact asserted]
-      (when (or (contains? now fact) (not (contains? retracted fact)))
+      (when (not (contains? retracted fact))
         (conj!! next fact)))
     (doseq [fact retracted]
-      (when (or (not (contains? now fact)) (not (contains? asserted fact)))
+      (when (not (contains? asserted fact))
         (disj!! next fact)))
     (->Knowledge #{} #{} #{} (persistent! next) name->schema)))


Press E to free the owls!!

Press E to free the owls!!

--- src/kindness/core.cljs
+++ src/kindness/core.cljs
@@ -20,6 +20,7 @@
    65 :left ;; A
    83 :down ;; S
    68 :right ;; D
+   69 :activate ;; E
    })
 (def move-speed 20)

@@ -30,7 +31,6 @@
 (def image-assets
   {:owl "owl.png"
    :cage "cage.png"})
-

 (defn default-components
   [entity idx]
@@ -58,6 +58,7 @@
        :bounds [:boundable {:bounds v}]
        :controls [:controllable {:controls v}]
        :weapons [:weaponised v]
+       :trigger [:triggerable v]
        nil))))

 (defn make-entity
@@ -78,7 +79,9 @@
 (defn new-owl
   [position]
    [:owl {:position position :bounds [48 48]
-          :weapons {:laser {:every 10000}}}])
+          :weapons {:laser {:every 10000}}
+          :trigger {:action :release
+                    :proximity 50}}])

 (def new-game-entities
   [[:background {:color "#33CC00"}]
@@ -146,31 +149,19 @@
   ;;
   )

-
-(defn position->corrds
-  [[px py] width height shape-height shape-width]
-  [(int (- (* width (/ px 100)) (/ shape-width 2)))
-   (int (- (* height (/ py 100)) (/ shape-height 2)))])
-
-(defn absolute-bounds
-  [[w h] width height]
-  [(int (* width (/ w 100)))
-   (int (* height (/ h 100)))])
-
 (defmulti draw (fn [e] (:shape (utils/find-component :renderable e))))
 (defmethod draw :circle [e]
   (let [renderable (utils/find-component :renderable e)
         color (:color renderable)
         positionable (utils/find-component :positionable e)
-        position (:position positionable)
+        [x y] (:position positionable)
         boundable (utils/find-component :boundable e)
         [w _] (:bounds boundable)
         canvas (:canvas @game-state)
         width (.-width canvas)
         height (.-height canvas)
         radius (int (* height (/ (/ w 2) 100)))
-        surface (:surface @game-state)
-        [x y] (position->corrds position width height (* 2 radius) (* 2 radius))]
+        surface (:surface @game-state)]
     (set! (.-fillStyle surface) color)
     (.beginPath surface)
     (.arc surface x y radius 0 (* 2 Math/PI) true)
@@ -183,13 +174,7 @@
         [x y] (:position positionable)
         boundable (utils/find-component :boundable e)
         [width height] (:bounds boundable)
-        ;; canvas (:canvas @game-state)
-        ;; width (.-width canvas)
-        ;; height (.-height canvas)
-        ;; [shape-width shape-height] (absolute-bounds bounds width height)
-        surface (:surface @game-state)
-        ;; [x y] (position->corrds position width height shape-height shape-width)
-        ]
+        surface (:surface @game-state)]
     ;;(println "name:" (:name e) "x,y:" [x y] "width, height:" [width height] "color:" color)
     (set! (.-fillStyle surface) color)
     (.fillRect surface x y width height)
@@ -230,12 +215,25 @@
   (doseq [entity (renderable-entities)]
     (draw entity)))

-
 (defn tap-print
   [text val]
   ;; (when val
   ;;   (println text))
   val)
+
+(defn object-center
+  [entity]
+  (let [[x y w h] (utils/position-and-bounds entity)]
+    [(int (+ x (/ w 2)))
+     (int (+ y ( / h 2)))]))
+
+(defn entity-proximity?
+  [e1 e2 minimum]
+  (let [[[x1 y1] [x2 y2]] (map object-center [e1 e2])
+        proximity (Math/sqrt (+ (Math/pow (- x1 x2) 2)
+                   (Math/pow (- y1 y2) 2)))]
+    ;; (println "obect centers:" (map object-center [e1 e2]) "proximity:" proximity "min:" minimum)
+    (<= proximity minimum)))

 (defn collide?
   [a b]
@@ -319,20 +317,6 @@
     (println "Entity with name" (:name entity)
              "has position:" (:position (utils/find-component :positionable entity)))))

-(defn entity-dimentions
-  [e]
-  (let [boundable (utils/find-component :boundable e)
-        positionable (utils/find-component :positionable e)
-        [px py] (:position positionable)
-        bounds (:bounds boundable)
-        canvas (:canvas @game-state)
-        width (.-width canvas)
-        height (.-height canvas)
-        [w h] (absolute-bounds bounds width height)
-        [x y] [(int (* width (/ px 100)))
-               (int (* height (/ py 100)))]]
-    [x y w h]))
-
 (defn get-entities
   []
   (println (:entities @game-state)))
@@ -342,6 +326,18 @@
   (doseq [entity (sort-by z-order
                           (:entities @game-state))]
     (println entity)))
+
+(defn trigger-entity!
+  [entity]
+  (replace-entity (assoc-in entity [:components :movable :velocity] 0.5)))
+
+(defn try-activate!
+  []
+  (doseq [player (find-entities-by-component :controllable)]
+    (doseq [entity (find-entities-by-component :triggerable)]
+      (let [proximity (:proximity (utils/find-component :triggerable entity))]
+        (when (entity-proximity? player entity proximity)
+          (trigger-entity! entity))))))

 (defn keyboard-handler
   [event]
@@ -352,6 +348,7 @@
         :right (move-entity! :player move-speed 0)
         :up (move-entity! :player 0 (- move-speed))
         :down (move-entity! :player 0 move-speed)
+        :activate (try-activate!)
         nil))))

 (defn outside-bounds?


ui: hide chats list item overflow

ui: hide chats list item overflow

--- src/status_im/ui/screens/chats_list/styles.cljs
+++ src/status_im/ui/screens/chats_list/styles.cljs
@@ -16,7 +16,8 @@
   {:flex-direction   :row
    :background-color component.styles/color-white
    :android          {:height 76}
-   :ios              {:height 74}})
+   :ios              {:height 74}
+   :overflow         "hidden"})

 (defstyle chat-icon-container
   {:padding-top    18


Add auto-capitalize words to keyboard

Add auto-capitalize words to keyboard

Signed-off-by: andrey <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/wallet/send/views.cljs
+++ src/status_im/ui/screens/wallet/send/views.cljs
@@ -105,6 +105,7 @@
                                 :color (if amount-error colors/red colors/black)
                                 :flex-shrink 1}
           :keyboard-type       :decimal-pad
+          :auto-capitalize     :words
           :accessibility-label :amount-input
           :default-value       amount-text
           :editable            (not request?)
@@ -164,6 +165,7 @@
                                 :color (when amount-error colors/red)
                                 :flex-shrink 1}
           :keyboard-type       :decimal-pad
+          :auto-capitalize     :words
           :accessibility-label :amount-input
           :default-value       amount-text
           :auto-focus          true


Putting it all together

Putting it all together

--- src/structural_typing/mechanics/m_canonical.clj
+++ src/structural_typing/mechanics/m_canonical.clj
@@ -40,9 +40,6 @@
                        (vector prefix-path (hash-map prefix-path (last %))))
                     path-ending-in-map?))

-
-
-
 (def dc:flatten-maps
   (letfn [(do-one [kvs parent-path]
             (reduce (fn [so-far [path v]]
@@ -92,9 +89,11 @@
        dc:required-paths->maps         ; everything is now a flatmap w/ potentially forking keys

        dc:flatten-maps
-       dc:unfork-map-paths
-       (apply merge-with into)
-       ))
+
+       ppp/flatmaps->ppps
+       ppp/fix-forked-paths
+       ppp/fix-required-paths-with-collection-selectors
+       ppp/dc2:ppps->type-description))


Formatting

Formatting

--- src/braid/core/server/routes/client.clj
+++ src/braid/core/server/routes/client.clj
@@ -99,7 +99,7 @@
   (GET "/gateway/create-group" []
     (get-html "gateway" {:gateway_action "create-group"}))

-  (GET  "/gateway/request-password-reset" _
+  (GET "/gateway/request-password-reset" _
     (get-html "gateway" {:gateway_action "request-password-reset"}))

   (GET "/:slug" [slug :as req]


sketch out create-all-webhooks

sketch out create-all-webhooks

--- src/gh_waiting_room/github.clj
+++ src/gh_waiting_room/github.clj
@@ -1,7 +1,8 @@
 (ns gh-waiting-room.github
   (:require [tentacles.issues :refer [my-issues create-comment]]
             [tentacles.repos :refer [create-hook hooks repos]]
-            [gh-waiting-room.config :refer [gh-auth issue-url-regex gh-hide-labels app-domain]]))
+            [gh-waiting-room.config :refer [gh-auth issue-url-regex gh-hide-labels
+                                            app-domain gh-user]]))

 ;;; util fns
 ; TODO: can this come from url-for?
@@ -85,6 +86,15 @@
          (filter filter-fn)
          (map :name))))

+(defn create-all-webhooks
+  "Creates webhooks for all repositories that don't have one in $APP_DOMAIN"
+  []
+  (let [repos (map #(array-map :name % :hooks (list-hooks (gh-user) %)) (list-repos))
+        has-webhook (fn [repo] (some #(= (full-url-for "/webhook") (:url %)) (:hooks repo)))
+        new-repos (remove has-webhook repos)]
+    (doseq [repo new-repos]
+      (create-webhook (gh-user) (:name repo)))))
+
 (defn create-issue-comment [db issue-id issue-num]
   (let [issue (or
                (some #(and (= (:id %) issue-id) %) (viewable-issues db))


Safeguard prepare-join when peer has already joined or is in acceptance

--- src/onyx/log/commands/prepare_join_cluster.clj
+++ src/onyx/log/commands/prepare_join_cluster.clj
@@ -23,30 +23,42 @@
                                                      peer-site
                                                      (:peer-sites replica))))))

+(defn still-joining? [replica joiner]
+  (or (get (map-invert (:prepared replica)) joiner)
+      (get (map-invert (:accepted replica)) joiner)))
+
+(defn already-joined? [replica joiner]
+  (some #{joiner} (:peers replica)))
+
 (s/defmethod extensions/apply-log-entry :prepare-join-cluster :- Replica
   [{:keys [args message-id]} :- LogEntry replica]
   (let [peers (:peers replica)
+        joiner (:joiner args)
         n (count peers)]
     (if (> n 0)
-      (let [joining-peer (:joiner args)
-            all-joined-peers (set (into (keys (:pairs replica)) peers))
+      (let [all-joined-peers (set (into (keys (:pairs replica)) peers))
             all-prepared-deps (set (keys (:prepared replica)))
             prep-watches (set (map (fn [dep] (get (map-invert (:pairs replica)) dep)) all-prepared-deps))
             accepting-deps (set (keys (:accepted replica)))
-            candidates (difference all-joined-peers all-prepared-deps accepting-deps prep-watches #{joining-peer})
+            candidates (difference all-joined-peers all-prepared-deps accepting-deps prep-watches #{joiner})
             sorted-candidates (sort (remove nil? candidates))]
-        (if (seq sorted-candidates)
-          (let [index (mod message-id (count sorted-candidates))
-                watcher (nth sorted-candidates index)]
-            (-> replica
-                (update-in [:prepared] merge {watcher joining-peer})
-                (add-site-acker args)
-                (reconfigure-cluster-workload)))
-          replica))
+        (cond (already-joined? replica joiner)
+              replica
+              (still-joining? replica joiner)
+              replica
+              (seq sorted-candidates)
+              (let [index (mod message-id (count sorted-candidates))
+                    watcher (nth sorted-candidates index)]
+                (-> replica
+                    (update-in [:prepared] merge {watcher joiner})
+                    (add-site-acker args)
+                    (reconfigure-cluster-workload)))
+              :else
+              replica))
       (-> replica
-          (update-in [:peers] conj (:joiner args))
+          (update-in [:peers] conj joiner)
           (update-in [:peers] vec)
-          (assoc-in [:peer-state (:joiner args)] :idle)
+          (assoc-in [:peer-state joiner] :idle)
           (add-site-acker args)
           (reconfigure-cluster-workload)))))

@@ -65,13 +77,17 @@

 (s/defmethod extensions/reactions :prepare-join-cluster :- Reactions
   [entry :- LogEntry old new diff peer-args]
-  (cond (and (= (:id peer-args) (:joiner (:args entry)))
-             (nil? diff))
-        [{:fn :abort-join-cluster
-          :args {:id (:id peer-args)}}]
-        (= (:id peer-args) (:observer diff))
-        [{:fn :notify-join-cluster
-          :args {:observer (:subject diff)}}]))
+  (let [joiner (:joiner (:args entry))]
+    (cond (already-joined? old joiner)
+          []
+          (still-joining? old joiner)
+          []
+          (and (= (:id peer-args) joiner) (nil? diff))
+          [{:fn :abort-join-cluster
+            :args {:id (:id peer-args)}}]
+          (= (:id peer-args) (:observer diff))
+          [{:fn :notify-join-cluster
+            :args {:observer (:subject diff)}}])))

 (s/defmethod extensions/fire-side-effects! :prepare-join-cluster :- State
   [{:keys [args message-id]} :- LogEntry old new diff {:keys [monitoring] :as state}]


Respond to bad requests with 400 - Bad Request

--- src/pz_discover/controllers/services.clj
+++ src/pz_discover/controllers/services.clj
@@ -3,14 +3,18 @@
             [pz-discover.views.services :as sv]))

 (defn lookup-svc-type [zookeeper type]
-  (if-let [data (sm/by-type zookeeper type)]
-    (sv/shape-response 200 :body data)
-    (sv/shape-response 404)))
+  (if type
+    (if-let [data (sm/by-type zookeeper type)]
+      (sv/shape-response 200 :body data)
+      (sv/shape-response 404))
+    (sv/shape-response 400 :body {:reason "Resource type required."})))

 (defn lookup-svc [zookeeper name]
-  (if-let [data (sm/by-name zookeeper name)]
-    (sv/shape-response 200 :body data)
-    (sv/shape-response 404)))
+  (if name
+    (if-let [data (sm/by-name zookeeper name)]
+      (sv/shape-response 200 :body data)
+      (sv/shape-response 404))
+    (sv/shape-response 400 :body {:reason "Resource name required."})))

 (defn lookup-all [zookeeper]
   (if-let [data (sm/all-names zookeeper)]
@@ -20,18 +24,24 @@
 (defn register-svc [zookeeper request]
   (let [name (-> request :params :name)
         data (-> request :params :data)]
-    (if-let [result (sm/register-by-name zookeeper name data)]
-      (sv/shape-response 201 :body result)
-      (sv/shape-response 303 :headers {"Location" (format "/api/v1/resources/%s" name)}))))
+    (if (and name data)
+      (if-let [result (sm/register-by-name zookeeper name data)]
+        (sv/shape-response 201 :body result)
+        (sv/shape-response 303 :headers {"Location" (format "/api/v1/resources/%s" name)}))
+      (sv/shape-response 400 :body {:reason "Resource name and data required."}))))

 (defn update-svc [zookeeper request]
   (let [name (-> request :params :name)
         data (-> request :params :data)]
-    (if-let [result (sm/update-by-name zookeeper name data)]
-      (sv/shape-response 200 :body result)
-      (sv/shape-response 404))))
+    (if (and name data)
+      (if-let [result (sm/update-by-name zookeeper name data)]
+        (sv/shape-response 200 :body result)
+        (sv/shape-response 404))
+      (sv/shape-response 400 :body {:reason "Resource name and data required."}))))

 (defn delete-svc [zookeeper name]
-  (if-let [result (sm/delete-by-name zookeeper name)]
-    (sv/shape-response 200)
-    (sv/shape-response 404)))
+  (if name
+    (if-let [result (sm/delete-by-name zookeeper name)]
+      (sv/shape-response 200)
+      (sv/shape-response 404))
+    (sv/shape-response 400 :body {:reason "Resource name required."})))


Fix concatting warnings from several cljs.edns

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -122,7 +122,7 @@
                             (send-visual! @pod {:exception (merge {:message (.getMessage e)}
                                                                   (ex-data e))}))
                           (throw e)))]
-          (let [warnings (apply merge (map :adzerk.boot-cljs/warnings (relevant-cljs-edn fileset ids)))]
+          (let [warnings (mapcat :adzerk.boot-cljs/warnings (relevant-cljs-edn fileset ids))]
             (send-visual! @pod {:warnings warnings})
             ; Only send changed files when there are no warnings
             ; As prev is updated only when changes are sent, changes are queued untill they can be sent


Add documentation, clarify logic.

Add documentation, clarify logic.

--- src/afterglow/channels.clj
+++ src/afterglow/channels.clj
@@ -18,11 +18,16 @@
   [offset]
   {:offset offset})

-(defn- assign-channel [universe start-address raw-channel]
+(defn- assign-channel
+  "Given a universe and DMX address at which a fixture is being
+  patched, and a raw channel description from the fixture definition,
+  calculate and assign the channel's actual DMX address and universe
+  that it will have in a show."
+  [universe start-address raw-channel]
   (cond-> raw-channel
-    true (assoc :address (+ (:offset raw-channel) (dec start-address))
-                :index (+ (dec (:offset raw-channel)) (dec start-address))
-                :universe universe)
+    (:offset raw-channel) (assoc :address (+ (:offset raw-channel) (dec start-address))
+                                 :index (+ (dec (:offset raw-channel)) (dec start-address))
+                                 :universe universe)
     (:fine-offset raw-channel) (assoc :fine-address (+ (:fine-offset raw-channel) (dec start-address))
                                       :fine-index (+ (dec (:fine-offset raw-channel)) (dec start-address)))))


Fix infinite loop when core/-main called with no args.

--- src/leiningen/core.clj
+++ src/leiningen/core.clj
@@ -94,4 +94,4 @@
          (apply (resolve-task task) args))
        ;; In case tests or some other task started any:
        (shutdown-agents)))
-  ([] (apply -main *command-line-args*)))
+  ([] (apply -main (or *command-line-args* ["help"]))))


Make deps generic. Add draft symlink implementation.

--- src/leiningen/deps.clj
+++ src/leiningen/deps.clj
@@ -6,6 +6,34 @@
   (:import [org.apache.maven.model Dependency Exclusion]
            [org.apache.maven.artifact.ant DependenciesTask RemoteRepository]
            [org.apache.tools.ant.util FlatFileNameMapper]))
+
+;; Add symlinking to Lancet's toolbox.
+(lancet/define-ant-task symlink symlink)
+
+;; Set this to one of :symlink or :copy to decide how dependencies are added to
+;; the library path."
+(def *copy-behavior* :copy)
+
+(defmulti copy-dependencies (fn [k destination flatten? fileset] k))
+
+(defmethod copy-dependencies :copy [k destination flatten? fileset]
+  (lancet/copy {:todir destination :flatten (if flatten? "on" "off")}
+               fileset))
+
+(defmethod copy-dependencies :symlink [k destination flatten? fileset]
+  (let [files (.getIncludedFiles (.getDirectoryScanner fileset lancet/ant-project))
+        dir (.getDir fileset)]
+
+    ;; In principle, this should work... but it doesn't.
+    ;; Instead we link each file in turn.
+    #_
+    (symlink {:action "record" :linkfilename destination}
+             fileset))
+
+    (doseq [f files]
+      (symlink {:link destination
+                :resource (.getCanonicalPath (java.io.File. dir f))})))
+

 ;; TODO: unify with pom.clj

@@ -60,7 +88,8 @@
            (.addDependency deps-task (make-dependency dep))))
        (.execute deps-task)
        (.mkdirs (file (:library-path project)))
-       (lancet/copy {:todir (:library-path project) :flatten "on"}
-                    (.getReference lancet/ant-project
-                                   (.getFilesetId deps-task)))))
+       (copy-dependencies *copy-behavior*
+                          (:library-path project) true
+                          (.getReference lancet/ant-project
+                                         (.getFilesetId deps-task)))))
   ([project] (deps project false)))


fixed bug in distillery.processing/words

--- src/distillery/processing.clj
+++ src/distillery/processing.clj
@@ -57,7 +57,7 @@
   [results & {:keys [predicate best-phrases]}]
   (let [predicate    (or predicate (fn [x] true))
         phrase-src   (if best-phrases
-                       (partial map best-alternate)
+                       (partial map best-alternate-phrase)
                        (partial mapcat :alternates))]
     (->> results
          (phrase-src)


(PDB-3051) benchmark-test: fix clobber, runinterval

Fix numhosts-is-required copy-paste clobbering, and adjust runinterval
test to correctly check the state that it was intended to.

--- test/puppetlabs/puppetdb/cli/benchmark_test.clj
+++ test/puppetlabs/puppetdb/cli/benchmark_test.clj
@@ -25,53 +25,70 @@
             :payload-string payload-string
             :payload (clojure.walk/keywordize-keys payload-string)})))

-(defn run-benchmark [config & cli-args]
+(defn call-with-benchmark-status
+  [config cli-args f]
   (let [submitted-records (atom [])]
-    (with-redefs [client/submit-catalog (mock-submit-record-fn submitted-records :catalog)
-                  client/submit-report (mock-submit-record-fn submitted-records :report)
-                  client/submit-facts (mock-submit-record-fn submitted-records :factset)
+    (with-redefs [client/submit-catalog (mock-submit-record-fn submitted-records
+                                                               :catalog)
+                  client/submit-report (mock-submit-record-fn submitted-records
+                                                              :report)
+                  client/submit-facts (mock-submit-record-fn submitted-records
+                                                             :factset)
                   config/load-config (fn [_] config)
-                  ;; this normally calls System/exit on a cli error; we'd rather have the exception.
+                  ;; This normally calls System/exit on a cli error;
+                  ;; we'd rather have the exception.
                   utils/try+-process-cli! (fn [body] (body))]
-      (let [result (apply benchmark/benchmark-main cli-args)]
-        (when (benchmark/chan? result)
-          (<!! (timeout 1000))
-          (close! result)))
-      @submitted-records)))
+      (f submitted-records (apply benchmark/benchmark-main cli-args)))))
+
+(defn benchmark-nummsgs
+  [config & cli-args]
+  ;; Assumes cli-args does not indicate a --runinterval) run
+  (call-with-benchmark-status config cli-args
+                              (fn [submitted _] @submitted)))

 (deftest config-is-required
   (is (thrown+-with-msg?
        [:kind ::ks/cli-error]
        #"Missing required argument '--config'"
-       (run-benchmark {}))))
+       (benchmark-nummsgs {}))))

-(deftest config-is-required
+(deftest numhosts-is-required
   (is (thrown+-with-msg?
        [:kind ::ks/cli-error]
        #"Missing required argument '--numhosts'"
-       (run-benchmark {}
-                      "--config" "anything.ini"))))
+       (benchmark-nummsgs {}
+                          "--config" "anything.ini"))))

 (deftest nummsgs-or-runinterval-is-required
   (is (thrown+-with-msg?
        [:kind ::utils/cli-error]
        #"Either -N/--nummsgs or -i/--runinterval is required."
-       (run-benchmark {}
-                      "--config" "anything.ini"
-                      "--numhosts" "42"))))
+       (benchmark-nummsgs {}
+                          "--config" "anything.ini"
+                          "--numhosts" "42"))))

 (deftest runs-with-runinterval
-  (let [submitted (run-benchmark {}
-                                 "--config" "anything.ini"
-                                 "--numhosts" "42"
-                                 "--runinterval" "1")]
-    (is (>= (count submitted)) (* 3 42))))
+  (call-with-benchmark-status
+   {}
+   ["--config" "anything.ini" "--numhosts" "42" "--runinterval" "1"]
+   (fn [submitted chan]
+     (let [enough-records (* 3 42)
+           finished (promise)
+           watch-key (Object.)
+           watcher (fn [k ref old new]
+                     (when (>= (count new) enough-records)
+                       (deliver finished true)))]
+       (add-watch submitted watch-key watcher)
+       (when-not (>= (count @submitted) enough-records) ;; avoids add-watch race
+         (deref finished tu/default-timeout-ms nil))
+       (is (>= (count @submitted) enough-records))
+       (close! chan)))))

 (deftest multiple-messages-and-hosts
-  (let [submitted (run-benchmark {}
-                                 "--config" "anything.ini"
-                                 "--numhosts" "2"
-                                 "--nummsgs" "3")]
+  (let [submitted (benchmark-nummsgs {}
+                                     "--config" "anything.ini"
+                                     "--numhosts" "2"
+                                     "--nummsgs" "3")]
     (is (= 18 (count submitted)))))

 (deftest archive-flag-works
@@ -86,18 +103,18 @@
        (#'cli-export/-main "--outfile" export-out-file
                            "--host" (:host svc-utils/*base-url*)
                            "--port" (str (:port svc-utils/*base-url*)))))
-    (let [submitted (run-benchmark {}
-                                   "--config" "anything.ini"
-                                   "--numhosts" "2"
-                                   "--nummsgs" "3"
-                                   "--archive" export-out-file)]
+    (let [submitted (benchmark-nummsgs {}
+                                       "--config" "anything.ini"
+                                       "--numhosts" "2"
+                                       "--nummsgs" "3"
+                                       "--archive" export-out-file)]
       (is (= 18 (count submitted))))))

 (deftest consecutive-reports-are-distinct
-  (let [submitted (run-benchmark {}
-                                 "--config" "anything.ini"
-                                 "--numhosts" "1"
-                                 "--nummsgs" "10")
+  (let [submitted (benchmark-nummsgs {}
+                                     "--config" "anything.ini"
+                                     "--numhosts" "1"
+                                     "--nummsgs" "10")
         reports (->> submitted
                      (filter #(= :report (:entity %)))
                      (map :payload))]
@@ -106,11 +123,11 @@
     (is (= 10 (->> reports (map :end_time) distinct count)))))

 (deftest randomize-catalogs-and-factsets
-  (let [submitted (run-benchmark {}
-                                 "--config" "anything.ini"
-                                 "--numhosts" "1"
-                                 "--nummsgs" "10"
-                                 "--rand-perc" "100")
+  (let [submitted (benchmark-nummsgs {}
+                                     "--config" "anything.ini"
+                                     "--numhosts" "1"
+                                     "--nummsgs" "10"
+                                     "--rand-perc" "100")
         catalog-hashes (->> submitted
                             (filter #(= :catalog (:entity %)))
                             (map :payload)


create a cassandra test session

create a cassandra test session

--- src/er_cassandra/model/alia/model_session.clj
+++ src/er_cassandra/model/alia/model_session.clj
@@ -3,7 +3,7 @@
    [plumbing.core :refer :all]
    [er-cassandra.session :as s]
    [er-cassandra.session.alia :as a]
-   [er-cassandra.model.model-session :as model-session
+   [er-cassandra.model.model-session :as ms
     :refer [ModelSession ModelSpySession]]
    [er-cassandra.model.alia.select :refer [select*]]
    [er-cassandra.model.alia.select-buffered :refer [select-buffered*]]
@@ -129,3 +129,25 @@
   [contact-points keyspace {port nil} {truncate-on-close nil} :as args]
   (let [alia-session (a/create-spy-session args)]
     (create-spy-session* alia-session)))
+
+;; a test-session is just a spy-session which will initialise it's keyspace
+;; if necesary and will truncate any used tables when closed
+(defnk create-test-session
+  [{contact-points nil} {port nil} {datacenter nil} keyspace :as args]
+  (let [s (create-spy-session
+           (merge
+            args
+            {:contact-points (or contact-points ["localhost"])
+             :port (or port 9042)
+             :datacenter datacenter
+             :init-statements
+             [(str "CREATE KEYSPACE IF NOT EXISTS "
+                   "  \"${keyspace}\" "
+                   "WITH replication = "
+                   "  {'class': 'SimpleStrategy', "
+                   "   'replication_factor': '1'} "
+                   " AND durable_writes = true;")]
+
+             :truncate-on-close true}))]
+
+    [s (fn [] (ms/-close s))]))