Added one asteroid

Added one asteroid

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -16,11 +16,13 @@
 (def height 100)
 (def point-size 8)
 (def ship-size 1.5)
+(def turn-speed 4)
 (def shot-size (/ ship-size 10))
 (def shot-speed 1.5)
-(def shot-millis 250)
+(def shot-millis 200)
+(def asteroid-max-speed 1)
+(def asteroid-max-rotation-speed 5)
 (def turn-millis 20)
-(def turn-speed 4)
 (def actions {
               (int \A) {:rotation (- turn-speed)}
               (int \D) {:rotation turn-speed}
@@ -148,6 +150,29 @@
          shot-pos (vec+vec position (num*vec size dir-vec))
          shot-speed (vec+vec speed (num*vec shot-speed dir-vec))]
      (create-shot shot-pos direction shot-speed))))
+
+(defn create-asteroid
+  ([size pos]
+   (let [direction (rand (* 2 (Math/PI)))
+         speed (num*vec (rand asteroid-max-speed) (rotate-vec direction [0 1]))
+         rotation-speed (rand asteroid-max-rotation-speed)]
+     {:type           :asteroid
+
+      :size           size
+      :shape          [[-1.0 -1.0] [1.0 -1.0] [1.0 1.0] [-1.0 1.0]]
+      :color          (Color. 250 240 20)
+
+      :position       pos
+      :speed          speed
+      :acceleration   0
+
+      :direction      direction
+      :rotation-speed rotation-speed
+      }))
+  ([size]
+   (let [x (rand width)
+         y (rand height)]
+     (create-asteroid size [x y]))))

 (defn out-of-bounds? [{[x y] :position size :size}]
   (or
@@ -194,6 +219,14 @@
   (let [position (vec+vec speed position)]
     (assoc shot :position position)))

+(defmethod move :asteroid [{:keys [direction rotation-speed position speed] :as asteroid}]
+  (let [direction (+ direction (* rotation-speed turn-millis 0.001))
+        [x y] (vec+vec speed position)
+        position [(mod x width) (mod y height)]]
+    (assoc asteroid :direction direction
+                    :position position
+                    )))
+
 ; Accelerating shots - not used right now
 #_(defmethod move :shot [{:keys [position speed direction acceleration] :as shot}]
   (let [speed (vec+vec speed (rotate-vec direction [0 (* acceleration turn-millis 0.001)]))
@@ -213,10 +246,11 @@
 ; ----------------------------------------------------------
 ; mutable model
 ; ----------------------------------------------------------
-(defn update-positions! [ship]
+(defn update-positions! [ship asteroid]
   (dosync
     (alter ship shoot)
-    (alter ship move))
+    (alter ship move)
+    (alter asteroid move))
   nil)

 (defn do-action!
@@ -229,8 +263,10 @@
    (do-action! ship action 1))
   )

-(defn reset-game! [ship]
-  (dosync (ref-set ship (create-ship)))
+(defn reset-game! [ship asteroid]
+  (dosync
+    (ref-set ship (create-ship))
+    (ref-set asteroid (create-asteroid 2)))
   nil)

 ; ----------------------------------------------------------
@@ -238,11 +274,19 @@
 ; ----------------------------------------------------------

 (defn draw-polygon [graphics polygon color]
-  (doto graphics
-    (.setColor color)
-    (.fillPolygon (let [jpolygon (new Polygon)]
-                    (doseq [[x y] polygon] (. jpolygon (addPoint x y)))
-                    jpolygon)))
+  (let [jpolygon (new Polygon)]
+    (doseq [[x y] polygon] (. jpolygon (addPoint x y)))
+    (doto graphics
+      (.setColor color)
+      (.drawPolygon jpolygon)))
+  nil)
+
+(defn fill-polygon [graphics polygon color]
+  (let [jpolygon (new Polygon)]
+    (doseq [[x y] polygon] (. jpolygon (addPoint x y)))
+    (doto graphics
+      (.setColor color)
+      (.fillPolygon jpolygon)))
   nil)

 (defmulti paint (fn [_ object] (:type object)))
@@ -253,11 +297,16 @@
   (let [transformation (get-transformation-matrix ship point-size)
         polygon (polygon-to-screen shape transformation)
         cockpit-polygon (polygon-to-screen cockpit-shape transformation)]
-    (draw-polygon g polygon color)
-    (draw-polygon g cockpit-polygon cockpit-color)))
-
-(defmethod paint :shot [g {:keys [shape color] :as shot}]
-  (let [transformation (get-transformation-matrix shot point-size)
+    (fill-polygon g polygon color)
+    (fill-polygon g cockpit-polygon cockpit-color)))
+
+(defmethod paint :shot [g {:keys [shape color] :as object}]
+  (let [transformation (get-transformation-matrix object point-size)
+        polygon (polygon-to-screen shape transformation)]
+    (fill-polygon g polygon color)))
+
+(defmethod paint :asteroid [g {:keys [shape color] :as object}]
+  (let [transformation (get-transformation-matrix object point-size)
         polygon (polygon-to-screen shape transformation)]
     (draw-polygon g polygon color)))

@@ -265,18 +314,19 @@
 ; game
 ; ----------------------------------------------------------

-(defn game-panel [frame ship]
+(defn game-panel [frame ship asteroid]
   (proxy [JPanel ActionListener KeyListener] []
     (paintComponent [g]                                     ; <label id="code.game-panel.paintComponent"/>
       (proxy-super paintComponent g)
-      (paint g @ship))
+      (paint g @ship)
+      (paint g @asteroid))
     (actionPerformed [e]                                    ; <label id="code.game-panel.actionPerformed"/>
-      (update-positions! ship)
+      (update-positions! ship asteroid)
       (when (lose? @ship)
-        (reset-game! ship)
+        (reset-game! ship asteroid)
         (JOptionPane/showMessageDialog frame "You lose!"))
       (when (win? @ship)
-        (reset-game! ship)
+        (reset-game! ship asteroid)
         (JOptionPane/showMessageDialog frame "You win!"))
       (.repaint this))
     (keyPressed [e]
@@ -290,8 +340,9 @@

 (defn game []
   (let [ship (ref (create-ship))
+        asteroid (ref (create-asteroid 2))
         frame (JFrame. "Asteroids")
-        panel (game-panel frame ship)
+        panel (game-panel frame ship asteroid)
         timer (Timer. turn-millis panel)]
     (doto panel                                             ; <label id="code.game.panel"/>
       (.setFocusable true)


reduce volume of internal metro example to stop clipping

--- examples/internal_metro.clj
+++ examples/internal_metro.clj
@@ -9,8 +9,9 @@
            root-trig (impulse:kr 100)
            t1        (pulse-divider:kr root-trig 20)
            t2        (pulse-divider:kr root-trig 10)]
-  (+ (* (decay t1 0.1) src1)
-     (* (decay t2 0.1) src2))))
+       (* 0.2
+          (+ (* (decay t1 0.1) src1)
+             (* (decay t2 0.1) src2)))))

 ;; Here's how you can separate the impulses out across synths and connect them


Rewrote rendering around on prog-events.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -19,52 +19,35 @@
                           ;   :res-ch => ch }

 (def prog-history
-  (atom {:snapshots {0 {}
-                     10 {:a 1 :b 2 :c 3 :d 4}
-                     20 {:a 11 :b 22 :c 33 :d 44}}
-         :prog-peers {:servers {}  ; { server-addr => ports }
-                      :clients {}} ; { client-addr => client-info }
-         :prog-events []}))
-
-(def run-world       (atom {:a 10}))
+  (atom {:prog-peers {:servers {}  ; { server-addr => ports }.
+                      :clients {}} ; { client-addr => client-info }.
+         :prog-events []})) ; Each event is [ts label args].
+
+(def run-world       (atom nil))
 (def run-world-hover (atom nil))

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

 (defn render-world [app owner]
   (apply dom/ul nil
-         (map (fn [[k v]] (dom/li nil (str k ":" v))) app)))
-
-(defn on-event-focus [snapshot-ts event-ts]
-  (when-let [ss (get-in @prog-history [:snapshots snapshot-ts])]
-    (reset! run-world-hover ss)
-    (.add gdom/classes (gdom/getElement "world-container") "hover")))
-
-(defn on-event-blur [snapshot-ts event-ts]
+         (map (fn [[k v]] (dom/li nil (str k ":" v)))
+              (:prog-peers app))))
+
+(defn on-event-focus [ts label args]
+  (reset! run-world-hover args)
+  (.add gdom/classes (gdom/getElement "world-container") "hover"))
+
+(defn on-event-blur []
   (reset! run-world-hover nil)
   (.remove gdom/classes (gdom/getElement "world-container") "hover"))

 (defn render-events [app owner]
   (apply dom/ul nil
-         (second
-          (reduce
-           (fn [[last-snapshot-ts res] [ts kind args]]
-             (if (= kind :snapshot)
-               [ts (conj res
-
-                         (dom/li #js {:className "snapshot"
-                                      :onMouseEnter #(on-event-focus ts nil)
-                                      :onMouseLeave #(on-event-blur ts nil)}
-                                 (str ts)))]
-               [(or last-snapshot-ts ts)
-                (conj res
-                      (dom/li #js {:onMouseEnter
-                                   #(on-event-focus last-snapshot-ts ts)
-                                   :onMouseLeave
-                                   #(on-event-blur last-snapshot-ts ts)}
-                              (str ts (pr-str args))))]))
-           [nil []]
-           (:prog-events app)))))
+         (map (fn [[ts label args]]
+                (dom/li #js {:onMouseEnter #(on-event-focus ts label args)
+                             :onMouseLeave #(on-event-blur)}
+                        (str ts label args)))
+              (:prog-events app))))

 (defn render-clients [app owner]
   (apply dom/select #js {:id "client"}
@@ -184,12 +167,12 @@

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

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

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


create .nrepl-port if it doesn't exist

create .nrepl-port if it doesn't exist

--- src/main/shadow/cljs/devtools/server.clj
+++ src/main/shadow/cljs/devtools/server.clj
@@ -91,11 +91,14 @@
        (log/warn t# "shutdown failed" ~(pr-str body))
        (discard-println ~(str "shutdown failed: " (pr-str body))))))

-(defn shutdown-system [{:keys [http port-files-ref socket-repl cli-repl nrepl] :as app}]
+(defn shutdown-system [{:keys [shutdown-hook http port-files-ref socket-repl cli-repl nrepl] :as app}]
   (discard-println "shutting down ...")
+  (. (Runtime/getRuntime) (removeShutdownHook shutdown-hook))
+
   (do-shutdown
     (doseq [port-file (vals @port-files-ref)]
       (.delete port-file)))
+
   (when socket-repl
     (do-shutdown (socket-repl/stop socket-repl)))

@@ -147,6 +150,8 @@
         (or srv (recur (inc port)))
         ))))

+(declare stop!)
+
 (defn start-system
   [app-ref app-config {:keys [cache-root] :as config}]
   (when @app-ref
@@ -207,10 +212,14 @@
         port-files-ref
         (atom nil)

+        shutdown-hook
+        (Thread. stop!)
+
         app
         (-> {::started (System/currentTimeMillis)
              :server-pid pid
              :config config
+             :shutdown-hook shutdown-hook
              :ssl-context ssl-context
              :http {:port (or https-port http-port)
                     :http-port http-port
@@ -246,6 +255,14 @@
               socket-repl
               (assoc :socket-repl (:port socket-repl)))
             )))
+
+    (let [nrepl-port-file (io/file ".nrepl-port")]
+      (when-not (.exists nrepl-port-file)
+        (spit nrepl-port-file (str (:port nrepl)))
+        (swap! port-files-ref assoc :nrepl-port nrepl-port-file)
+        (.deleteOnExit nrepl-port-file)))
+
+    (. (Runtime/getRuntime) (addShutdownHook shutdown-hook))

     (spit pid-file pid)


require all table-defs from describe-* driver functions to include a :schema attribute (which can still be nil).

--- src/metabase/sync_database/interface.clj
+++ src/metabase/sync_database/interface.clj
@@ -13,8 +13,8 @@

 (def DescribeDatabase
   "Schema for the expected output of `describe-database`."
-  {:tables #{{:name                         schema/Str
-              (schema/optional-key :schema) (schema/maybe schema/Str)}}})
+  {:tables #{{:name   schema/Str
+              :schema (schema/maybe schema/Str)}}})

 (def DescribeTableField
   "Schema for a given Field as provided in `describe-table` or `analyze-table`."
@@ -28,13 +28,13 @@

 (def DescribeTable
   "Schema for the expected output of `describe-table`."
-  {:name                         schema/Str
-   (schema/optional-key :schema) (schema/maybe schema/Str)
-   :fields                       #{DescribeTableField}})
+  {:name   schema/Str
+   :schema (schema/maybe schema/Str)
+   :fields #{DescribeTableField}})

 (def DescribeTableFKs
   "Schema for the expected output of `describe-table-fks`."
   #{{:fk-column-name   schema/Str
-     :dest-table       {:name                         schema/Str
-                        (schema/optional-key :schema) (schema/maybe schema/Str)}
+     :dest-table       {:name   schema/Str
+                        :schema (schema/maybe schema/Str)}
      :dest-column-name schema/Str}})


adjust launch fn to handle empty content

--- src/app/cljs/one/sample/view/editor.cljs
+++ src/app/cljs/one/sample/view/editor.cljs
@@ -26,10 +26,9 @@
         new       ($ "button#new")
         undo      ($ "button#undo")
         redo      ($ "button#redo")
-        set-html! (fn [content] (. field (setHtml false content true)))]
+        set-html! (fn [content] (. field (setHtml false (or content "") true)))]
     (do
-      (list-documents @docs)
-      (if content (set-html! content))
+      (set-html! content)
       (. field (makeEditable))
       (. element (focus)))
     (event/listen field


remove unused support for :passato-stem

remove unused support for :passato-stem

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -681,15 +681,6 @@
   (log/warn (str "not enough agreement specified to conjugate: " (get-in word '(:passato)) " (irreg past)]"))
   (get-in word '(:passato)))

-(defn passato-stem? [word]
-  (and (= :past (get-in word '(:infl)))
-       (get-in word '(:passato-stem))))
-
-(defn passato-stem [word]
-  ;; conjugate irregular passato: option 1) using :passato-stem
-  (let [irregular-passato (get-in word '(:passato-stem))]
-    (str irregular-passato (suffix-of word))))
-
 (defn irregular-passato? [word]
   ;; conjugate irregular passato: option 2) using :passato
   (and (= :past (get-in word '(:infl)))
@@ -866,9 +857,6 @@
     (irregular-passato? word)
     (irregular-passato word)

-    (passato-stem? word)
-    (passato-stem word)
-
     (irregular-passato? word)
     (irregular-passato word)


Keywordize response

Keywordize response

--- src/discuss/communication.cljs
+++ src/discuss/communication.cljs
@@ -26,7 +26,7 @@
 (defn error-handler
   "Generic error handler for ajax requests."
   [{:keys [status status-text]}]
-  (.log js/console (str "something bad happened: " status " " status-text))
+  (.log js/console (str "I feel a disturbance in the Force... " status " " status-text))
   (lib/error-msg! (str status " " status-text))
   (lib/loading? false))

@@ -60,8 +60,10 @@
 (defn references-handler
   "Called when received a response on the reference-query."
   [response]
-  (let [refs  (:references response)
-        error (:error response)]
+  (let [res   (keywordize-keys response)
+        refs  (:references res)
+        csrf  (:csrf res)
+        error (:error res)]
     (if (pos? (count error))
       (lib/error-msg! error)
       (do
@@ -101,7 +103,7 @@
   ([url body]
    (post-json url body success-handler {"Content-Type" "application/json"})))

-(defn post-origin-get-references
+(defn request-references
   "When this app is loaded, request all available references from the external discussion system."
   []
   (let [url "api/get/references"                            ; TODO hardcoded url = bad


fixing typo

fixing typo

--- src/cljc/ow/starbuck/message_router.cljc
+++ src/cljc/ow/starbuck/message_router.cljc
@@ -1,5 +1,5 @@
 (ns ow.starbuck.message-router
-  ?#(:cljs (:require-macros [cljs.core.async.macros :refer [go-loop]]))
+  #?(:cljs (:require-macros [cljs.core.async.macros :refer [go-loop]]))
   (:require [taoensso.timbre :refer [trace debug info warn error fatal]]
             #?(:clj  [clojure.core.async.impl.protocols :as ap]
                :cljs [cljs.core.async.impl.protocols :as ap])


don't throw exceptions in message-router

--- src/cljc/ow/starbuck/message_router.cljc
+++ src/cljc/ow/starbuck/message_router.cljc
@@ -1,10 +1,5 @@
 (ns ow.starbuck.message-router
-  #_(:refer-clojure :rename {compile compile-clj})
-  #_#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]]))
-  (:require #_[com.stuartsierra.component :as c]
-            #_#?(:clj  [clojure.core.async :refer [put! >! <! go go-loop pub sub chan close! timeout alts! promise-chan]]
-               :cljs [cljs.core.async :refer [put! >! <! pub sub chan close! timeout alts! promise-chan]])
-            [taoensso.timbre :refer [trace debug info warn error fatal]]
+  (:require [taoensso.timbre :refer [trace debug info warn error fatal]]
             ;;;[clara.rules :as cr]

             ;;;[clojure.walk :refer [macroexpand-all]]
@@ -48,7 +43,7 @@

 (defn- goto-next [transition msgs]
   (if-let [next (or (and (map? transition) (:next transition))
-                    (and (keyword? transition) transition))]
+                    transition)]
     (let [nexts (if (sequential? next)
                   next
                   [next])
@@ -62,7 +57,7 @@
                 msgs)
            (apply concat)
            (remove #(nil? (:comp %)))))
-    (throw (ex-info "next component undefined in transition" {:transition transition}))))
+    (warn "next component undefined in transition" {:transition transition})))

 (defn- handle-events [eventhandlers msg]
   (let [{:keys [msg evmsgs]}
@@ -75,7 +70,7 @@
                               (update :evmsgs #(conj % evmsg)))
                           (update s :evmsgs #(conj % evmsg))))
                       s)
-                    (throw (ex-info "next component undefined in eventhandler" {:eventhandler eventhandler}))))
+                    (warn "next component undefined in eventhandler" {:eventhandler eventhandler})))
                 {:msg msg
                  :evmsgs []}
                 eventhandlers)]
@@ -90,7 +85,7 @@
 (defn advance [msg ruleset]
   "Takes a message, runs it against ruleset and returns a sequence of routed messages."
   (debug "routing starting with" (select-keys msg #{:route :comp :starbuck/route-count}))
-  (if (< (or (:starbuck/route-count msg) 0) 10)
+  (if (< (or (:starbuck/route-count msg) 0) 100)
     (let [route (get-in ruleset [:routes (:route msg)])
           trans (get-in route [:transitions (:comp msg)])
           evenths (merge (get ruleset :event-handlers)


select fixes

select fixes

--- src/cljs/re_form/inputs/select_impl.cljs
+++ src/cljs/re_form/inputs/select_impl.cljs
@@ -124,7 +124,9 @@
                             (swap! state assoc :selected first-opt
                                    :suggestions-container
                                    (cmn/f-child (:root-node @state) "options")))))
-        reset-input (fn [e] (on-change nil))]
+        reset-input (fn [e]
+                      (on-change nil)
+                      (set! (.-value (:input-node @state)) ""))]

     (r/create-class
      {
@@ -150,7 +152,9 @@
           {:class (when-not (empty? errors) :error)}
           [:div.flex
            {:on-click (fn [_] (do
-                                (when search-fn (js/setTimeout #(.focus (:input-node @state)) 10))
+                                (when search-fn
+                                  (js/setTimeout #(.focus (:input-node @state)) 10)
+                                  (search-fn (.-value (:input-node @state))))
                                 (swap! state assoc :active true
                                        :selected nil)))}
            [:span.triangle "▾"]


logging

logging

--- src/clojure/zensols/nlparse/stanford.clj
+++ src/clojure/zensols/nlparse/stanford.clj
@@ -112,6 +112,8 @@
 (defn- create-tok-re-annotator [tok-re-resources]
   (let [{:keys [tok-re-annotator]} *parse-context*
         tok-re-path (resource-path :tok-re-resource)
+        _ (log/infof "creating tok annotator from <%s> (%s)" tok-re-path
+                     (type tok-re-path))
         tok-re-files (map #(io/file tok-re-path %) tok-re-resources)]
     (swap! tok-re-annotator
            (fn [ann]


Pass last-read-at with the posts if the user is authed.

--- src/oc/storage/representations/entry.clj
+++ src/oc/storage/representations/entry.clj
@@ -25,7 +25,7 @@
                            :team-id :author :publisher :published-at
                            :video-id :video-processed :video-image :video-duration
                            :created-at :updated-at :revision-id :follow-ups
-                           :new-at :new-comments-count :bookmarked])
+                           :new-at :new-comments-count :bookmarked :last-read-at])

 ;; ----- Utility functions -----

@@ -200,6 +200,7 @@
                            :board-access board-access
                            :board-name (:name board)
                            :bookmarked (boolean bookmarked?)
+                           :last-read-at (:read-at entry-read)
                            :new-comments-count (when enrich-entry?
                                                  (if entry-read
                                                    (new-comments-count entry-with-comments user-id entry-read)


Updated API call 'switch' in the server module

--- src/emender_jenkins/server.clj
+++ src/emender_jenkins/server.clj
@@ -54,10 +54,21 @@
     (if (= uri "/api")
         (rest-api/info-handler request (get-hostname))
         (condp = [method (get-api-command uri (config/get-api-prefix request))]
-            [:get  ""]         (rest-api/info-handler request (get-hostname))
-            [:get  "system"    (rest-api/system-banners request)]
-            ;[:post "
-                                     (rest-api/unknown-call-handler uri method))))
+            [:get  ""]                 (rest-api/info-handler request (get-hostname))
+            [:get  "system"]           (rest-api/system-banners       request)
+            [:post "create_job"]       (rest-api/create-job           request)
+            [:post "delete_job"]       (rest-api/delete-job           request)
+            [:post "start_job"]        (rest-api/start-job            request)
+            [:post "enable_job"]       (rest-api/enable-job           request)
+            [:post "disable_job"]      (rest-api/disable-job          request)
+            [:get  "get_job"]          (rest-api/get-job              request)
+            [:post "update_job"]       (rest-api/update-job           request)
+            [:get  "get_jobs"]         (rest-api/get-jobs             request)
+            [:post "get_job_results"]  (rest-api/get-job-results      request)
+            [:post "job_started"]      (rest-api/job-started-handler  request)
+            [:post "job_finished"]     (rest-api/job-finished-handler request)
+            [:post "job_results"]      (rest-api/job-results          request)
+                                       (rest-api/unknown-call-handler uri method))))

 (defn non-api-call-handler
     [request uri]


Minor

Minor

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -187,8 +187,8 @@
                                          :onClick   #(com/dispatch-add-action statement (lib/get-selection))
                                          :disabled  (> 10 (count statement))}
                                     (remaining-characters statement))
+                        (dom/hr nil)
                         (dom/p #js {:className "text-muted text-center"}
-                               (dom/hr nil)
                                "Das Markieren von Textpassagen über mehrere Absätze hinweg und das doppelte markieren schon markierter Textstellen wurde noch nicht implementiert."))))))

 (defn- build-with-buttons


CMR-1387: Fix merge conflict with master

--- search-app/src/cmr/search/services/parameters/parameter_validation.clj
+++ search-app/src/cmr/search/services/parameters/parameter_validation.clj
@@ -250,12 +250,7 @@
   "Validates that no invalid parameters were supplied"
   [concept-type params]
   ;; this test does not apply to page_size, page_num, etc.
-<<<<<<< HEAD
-  (let [params (dissoc params :page-size :page-num :sort-key :result-format :pretty
-                       :echo-compatible)
-=======
   (let [params (dissoc params :page-size :page-num :sort-key :result-format :echo-compatible)
->>>>>>> master
         params (if (= :collection concept-type)
                  ;; Parameters only supported on collections
                  (dissoc params :include-granule-counts :include-has-granules :include-facets


Change add-input to check for nil inputs.

--- src/org/playasophy/wonderdome/system.clj
+++ src/org/playasophy/wonderdome/system.clj
@@ -43,11 +43,17 @@

 (defn add-input
   "Associates a new input source component into a system map. The input
-  function should take an output channel as the first argument."
+  function should take an output channel as the first argument. If the function
+  does not return an input, the channel will be closed."
   [system k input-fn channel & args]
-  (-> system
-      (update-in [:mixer :inputs] conj channel)
-      (assoc k (apply input-fn channel args))))
+  {:pre [(some? channel)]}
+  (if-let [input (apply input-fn channel args)]
+    (-> system
+        (update-in [:mixer :inputs] conj channel)
+        (assoc k input))
+    (do
+      (async/close! channel)
+      system)))

 (defn initialize


Add load-once logic to 'Sha protocol & 'ByteSha type.

Without this load-once logic, recompiling the namespace will break any
future equals comparisons.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -1027,23 +1027,24 @@
          (for [s tree-shas]
            {s (git-tree gitdir s)}))))

-(defprotocol Sha
-  (get-byte-array [_])
-  (get-hex-string [_]))
-
-;; TODO: sub-sha match
-;; (= (str->sha "abcde") (str->sha "abcd"))
-(deftype BytesSha [^bytes bytes]
-  Sha
-  (get-byte-array [_] bytes)
-  (get-hex-string [_] (.toString (java.math.BigInteger. bytes) 16))
-
-  Object
-  (toString [this] (get-hex-string this))
-  (hashCode [_]
-    (bit-or (aget bytes 1) (bit-shift-left (aget bytes 0) 8)))
-  (equals [this o]
-    (and (instance? BytesSha o) (Arrays/equals bytes ^bytes (get-byte-array o)))))
+(when-not (resolve 'Sha)
+  (defprotocol Sha
+    (get-byte-array [_])
+    (get-hex-string [_]))
+
+  ;; TODO: sub-sha match
+  ;; (= (str->sha "abcde") (str->sha "abcd"))
+  (deftype BytesSha [^bytes bytes]
+    Sha
+    (get-byte-array [_] bytes)
+    (get-hex-string [_] (.toString (java.math.BigInteger. bytes) 16))
+
+    Object
+    (toString [this] (get-hex-string this))
+    (hashCode [_]
+      (bit-or (aget bytes 1) (bit-shift-left (aget bytes 0) 8)))
+    (equals [this o]
+      (and (instance? Sha o) (Arrays/equals bytes ^bytes (get-byte-array o))))))

 (defn str->sha [^String s]
   (assert (<= 4 (count s)))


rename var xor -> xor-dataset (#205)

rename var xor -> xor-dataset (#205)

--- examples/xor-mlp/src/xor_mlp/core.clj
+++ examples/xor-mlp/src/xor_mlp/core.clj
@@ -24,6 +24,6 @@
                                :epoch-count 3000
                                :simple-loss-print? true)]
     (println "\nXOR results before training:")
-    (clojure.pprint/pprint (execute/run nn xor))
+    (clojure.pprint/pprint (execute/run nn xor-dataset))
     (println "\nXOR results after training:")
-    (clojure.pprint/pprint (execute/run trained xor))))
+    (clojure.pprint/pprint (execute/run trained xor-dataset))))


fine tuning

fine tuning

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -234,7 +234,7 @@
       (show/add-midi-control-to-var-mapping
         "Automap MIDI" 10 26 :lightness-max-back :min 0 :max 100)
       (show/add-midi-control-to-var-mapping
-        "Automap MIDI" 10 27 :lightness-max-front :min 0 :max 30)
+        "Automap MIDI" 10 27 :lightness-max-front :min 0 :max 50)
       (show/add-midi-control-to-var-mapping
         "Automap MIDI" 10 27 :lightness-max-front-percent :min 0 :max 1)
       (show/add-midi-control-to-var-mapping
@@ -248,7 +248,7 @@
       (afterglow.show/set-variable! :sparkle-chance 0.1)
       (afterglow.show/set-variable! :sparkle-fade 100)
       (afterglow.show/set-variable! :lightness-min-general 0)
-      (afterglow.show/set-variable! :lightness-max-front 30)
+      (afterglow.show/set-variable! :lightness-max-front 50)
       (afterglow.show/set-variable! :lightness-max-back 50)
       (afterglow.show/set-variable! :lightness-max-general 50)
       (afterglow.show/set-variable! :lightness-max-general-percent 1)


Add version

Add version

--- src/obb_rules/game.clj
+++ src/obb_rules/game.clj
@@ -1,6 +1,8 @@
 (ns obb-rules.game
   (:require [obb-rules.stash :as stash]
             [obb-rules.board :as board]))
+
+(def version (System/getProperty "obb-rules-api.version"))

 (defn state?
   "Checks if the game is in a given state"


Trivial comments

Trivial comments

Signed-off-by: Gregory Haskins <640d9fe47775e6723f0355b7315e38f7d98d3539@gmail.com>


Documentation for some of the core functions.

--- src/om_forms/core.cljs
+++ src/om_forms/core.cljs
@@ -176,15 +176,27 @@
                                   :value    (get-in cursor korks)})]
     (input* :input input-attrs label cursor korks opts)))

-(defn html5-input
-  [type & args]
-  (let [[attrs [label placeholder cursor korks & opts]] (resolve-args type {} args)]
-    (apply html5-input* attrs label placeholder cursor korks (name type) opts)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Public

 (defn panel
+
+  "A panel. See http://getbootstrap.com/components/#panels
+
+  Arguments:
+
+  [attrs] title [:close <lambda>] element1 ... element2
+
+    attrs - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+    title - panel title; a string or Hiccup/Sablono style template
+    :close - (optional) lambda to call when panel is closed; when the option is set, the panel shows a close icon (FontAwesome by default)
+    contents - (optional) the contained elements
+
+  Examples:
+
+  (panel \"A simple panel\" [:div \"Contents go here\"])
+  (panel {:class \"my-special-panel\"} \"My special panel\" :close #(js/alert \"closed\") [:div \"Contents go here\"])"
+
   [& args]
   (let [[attrs [title & rest-args]] (resolve-args :panel {:class "panel panel-default"} args)
         [{:keys [close]} [& contents]] (parse-options rest-args)]
@@ -199,6 +211,21 @@
       (seq contents)]]))

 (defn form
+
+  "A form. See http://getbootstrap.com/css/#forms
+
+  Arguments:
+
+  [attrs] element1 ... element2
+
+  attrs - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  contents - (optional) the contained elements
+
+  Examples:
+
+  (form [:div \"Contents go here\"])
+  (form {:style {:background-color \"red\"}} [:div \"Contents go here\"])"
+
   [& args]
   (let [[attrs & elems] (resolve-args :form
                                       {:on-submit #(.preventDefault %)
@@ -207,27 +234,86 @@
     [:form attrs elems]))

 (defn group-title
+
+  "A title for a logical group of controls.
+
+   Arguments:
+
+  [attrs] title [:tag <tag-name>]
+
+  attrs - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  title - the title; a string or Hiccup/Sablono style template
+  tag   - (optional) name of the tag to use, e.g. :h4"
+
   [& args]
   (let [[attrs [title & {:keys [tag]}]] (resolve-args :group-title {:class "group-title"} args)]
     [(or tag (get-in *options* [:group-title :tag]))
      attrs
      title]))

+(defn html5-input
+
+  "TODO"
+
+  [type & args]
+  (let [[attrs [label placeholder cursor korks & opts]] (resolve-args type {} args)]
+    (apply html5-input* attrs label placeholder cursor korks (name type) opts)))
+
+
+
 (defn text
+
+  "Text input. See http://getbootstrap.com/css/#inputs
+
+   Arguments:
+
+   See `html5-input`
+
+   For compatilibity and available attributes see http://www.w3schools.com/html/html_form_input_types.asp"
+
   [& args]
   (apply html5-input :text args))

 (defn password
+
+  "Password input. See http://getbootstrap.com/css/#inputs
+
+   Arguments:
+
+   See `html5-input`
+
+   For compatilibity and available attributes see http://www.w3schools.com/html/html_form_input_types.asp"
+
   [& args]
   (apply html5-input :password args))

 (defn form-buttons
+
+  "Auto-aligning form buttons.
+
+   Arguments:
+
+   button-1 ... button-n"
+
   [& buttons]
   [:div.form-group.form-buttons
    (apply unlabeled-control false buttons)])

 (defn button
+
+  "Button. See http://getbootstrap.com/css/#buttons
+
+  Arguments:
+
+  [attrs] label on-click [:in-progress <bool> :disabled <bool]
+
+  attrs        - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  label        - button label; a string or Hiccup/Sablono style template
+  on-click     - lambda to handle clicks
+  :in-progress - true to show an indicator that a background action is in progress and disable the button
+  :disabled    - true to disable the button"
+
   [& args]
   (let [[attrs [label on-click & {:keys [in-progress disabled]}]] (resolve-args :button
                                                                                {:type  "button"
@@ -244,21 +330,59 @@
              (spinner)))]))

 (defn button-primary
+
+  "Primary button. See http://getbootstrap.com/css/#buttons
+
+  Arguments:
+
+  See `button`."
+
   [& args]
   (let [[attrs [& rest-args]] (resolve-args :button-primary {:class "btn-primary"} args)]
     (apply button attrs rest-args)))

 (defn button-default
+
+  "Default button. See http://getbootstrap.com/css/#buttons
+
+  Arguments:
+
+  See `button`."
+
+
   [& args]
   (let [[attrs [& rest-args]] (resolve-args :button-default {:class "btn-default"} args)]
     (apply button attrs rest-args)))

 (defn button-group
+
+  "Button group.
+
+  Arguments:
+
+  [attrs] button-1 ... button-n
+
+  attrs        - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)"
+
   [& args]
   (let [[attrs [& buttons]] (resolve-args :button-group {:class "button-group"} args)]
     [:div attrs (seq buttons)]))

 (defn checkbox
+
+  "Checkbox. See http://getbootstrap.com/css/#checkboxes-and-radios
+
+  Arguments:
+
+  [attrs] label cursor korks value [:valid? <bool> :validation-error-fn <lambda> :inline <bool>]
+
+  attrs                 - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  label                 - the label; a string or Hiccup/Sablono style template
+  cursor, korks         - data to bind to
+  :inline               - (optional) if true renders the control inline
+  :valid?               - (optional) if false shows a validation error; internal
+  :validation-error-fn  - (optional) lambda <korks> -> <error message>; internal"
+
   [& args]
   (let [[attrs [label cursor korks & {:keys [valid? validation-error-fn inline]}]] (resolve-args :checkbox {} args)
         dom-id (gen-dom-id cursor korks)
@@ -281,6 +405,20 @@
           (error-label validation-error))))))

 (defn radio                                                 ;; TODO: Extract common method for `radio` and `checkbox`.
+
+  "Radio button. See http://getbootstrap.com/css/#checkboxes-and-radios
+
+  Arguments:
+
+  [attrs] label cursor korks value [:valid? <bool> :validation-error-fn <lambda> :inline <bool>]
+
+  attrs                 - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  label                 - the label; a string or Hiccup/Sablono style template
+  cursor, korks         - data to bind to
+  :inline               - (optional) if true renders the control inline
+  :valid?               - (optional) if false shows a validation error; internal
+  :validation-error-fn  - (optional) lambda <korks> -> <error message>; internal"
+
   [& args]
   (let [[attrs [label cursor korks value & {:keys [valid? validation-error-fn inline]}]] (resolve-args :radio {} args)
         dom-id (gen-dom-id cursor korks)
@@ -306,6 +444,25 @@

 (defn textarea
+
+  "Textarea element. See http://getbootstrap.com/css/#textarea
+
+  Arguments:
+
+  [attrs] label placeholder cursor korks [opts]
+
+  attrs                 - (optional) attributes handed over to React (see https://github.com/r0man/sablono#html-attributes)
+  label                 - the label; a string or Hiccup/Sablono style template
+  placeholder           - placeholder text shown if there is no value
+  cursor, korks         - data to bind to
+  opts                  - see `html5-input`
+
+
+  Example:
+
+  (f/textarea \"Textarea\" \"A placeholder\" data [:some-text])
+  (f/textarea {:rows 8} \"Textarea\" \"A placeholder\" data [:some-text] :inline true)"
+
   [& args]
   (js/console.log (prn-str args))
   (let [[attrs [label placeholder cursor korks & opts]] (resolve-args :textarea {:class "form-control"} args)


Experimental parameters table.  More work will be needed.

--- src/re_demo/utils.cljs
+++ src/re_demo/utils.cljs
@@ -37,7 +37,7 @@

 ;; -- Args Table --------------------------------------------------------------

-(defn arg-row
+#_(defn arg-row
   "I show one argument in an args table."
   [name-ems arg]                       ;; TODO: make name-ems overriddable
   (let [required   (:required arg)
@@ -63,13 +63,13 @@
                             (when-not (:last-arg? arg) [line])]]]]))

-(defn- add-flag-to-last
+#_(defn- add-flag-to-last
   "I add a :last? key to the last item in vector (of maps) 'v'"
   [v]
   (assoc-in v [(dec (count v)) :last-arg?]  true))

-(defn args-table
+#_(defn args-table
   "I display a component arguements in an easy to read format"
   [args]
   (let [;; max-chars  (->> args
@@ -89,3 +89,50 @@
                     [gap :size "10px"]]
                    (map (partial arg-row max-ems)  args))])))

+
+(defn arg-row
+  "I show one argument in an args table."
+  [name-width arg odd-row?]
+  (let [required   (:required arg)
+        default    (:default arg)
+        arg-type   (:type arg)
+        needed-vec (if (not required)
+                     (if (nil? default)
+                       [[label :label "optional" :class "small-caps"]]
+                       [[label :label "default:" :class "small-caps"] [label :label (str default)]])
+                     [[label :label "required" :class "small-caps"]])]
+    [h-box
+     :style    { :background (if odd-row?  "#F8F8F8" "#FCFCFC" )}
+     :children [[:span {:style {:width name-width
+                               :font-size "15px"
+                               :padding-left "15px"
+                               :align-self :center
+                               }}
+                 (str (:name arg))]
+                [line :size "1px" :color "white"]
+                [v-box
+                 :style {:padding "7px 15px 2px 15px"}
+                 :gap  "4px"
+                 :width "310px"
+                 :children [[h-box
+                             :gap   "4px"
+                             :children (concat [[label :label arg-type]
+                                                [gap :size "10px"]]
+                                               needed-vec)]
+                            [:span  (:description arg)]
+                            ]]]]))
+
+
+(defn args-table
+  "I display a component arguements in an easy to read format"
+  [args]
+  (let [name-width  "130px"]
+    (fn
+      []
+      [v-box
+       :children (concat
+                   [[label
+                     :class "small-caps"
+                     :label "named parameters:"]
+                    [gap :size "10px"]]
+                   (map (partial arg-row name-width)  args (cycle [true false])))])))


Cleanup new deref watching a bit

Cleanup new deref watching a bit

--- src/reagent/ratom.cljs
+++ src/reagent/ratom.cljs
@@ -31,29 +31,32 @@
                  (recur (inc i))
                  false))))))

+(defn- ^boolean in-arr [a x]
+  (not (or (nil? a)
+           (== -1 (.indexOf a x)))))
+
 (defn- in-context [obj f]
   (binding [*ratom-context* obj]
     (f)))

 (defn- deref-capture [f r]
-  (let [watch (.-watching r)]
-    (set! (.-captured r) nil)
-    (when (dev?)
-      (set! (.-ratomGeneration r)
-            (set! generation (inc generation))))
-    (let [res (in-context r f)
-          capt (.-captured r)]
-      (set! (.-dirty? r) false)
-      (when-not (arr-eq capt watch)
-        (._update-watching r capt))
-      res)))
+  (set! (.-captured r) nil)
+  (when (dev?)
+    (set! (.-ratomGeneration r)
+          (set! generation (inc generation))))
+  (let [res (in-context r f)
+        c (.-captured r)]
+    (set! (.-dirty? r) false)
+    (when-not (arr-eq c (.-watching r))
+      (._update-watching r c))
+    res))

 (defn- notify-deref-watcher! [derefable]
   (when-some [r *ratom-context*]
     (let [c (.-captured r)]
       (if (nil? c)
         (set! (.-captured r) (array derefable))
-        (when (== -1 (.indexOf c derefable))
+        (when-not (in-arr c derefable)
           (.push c derefable))))))

 (defn- check-watches [old new]
@@ -62,15 +65,14 @@
   new)

 (defn- add-w [this key f]
-  (set! (.-watchesArr this) nil)
   (let [w (.-watches this)]
-    (set! (.-watches this) (check-watches w (assoc w key f)))))
+    (set! (.-watches this) (check-watches w (assoc w key f)))
+    (set! (.-watchesArr this) nil)))

 (defn- remove-w [this key]
-  (set! (.-watchesArr this) nil)
-  (let [w (.-watches this)
-        r -running]
-    (set! (.-watches this) (check-watches w (dissoc w key)))))
+  (let [w (.-watches this)]
+    (set! (.-watches this) (check-watches w (dissoc w key)))
+    (set! (.-watchesArr this) nil)))

 (defn- notify-w [this old new]
   (let [w (.-watchesArr this)
@@ -79,9 +81,7 @@
             w)]
     (when (nil? w)
       ;; Copy watches to an array for speed
-      (reduce-kv (fn [_ k f]
-                   (.push a k)
-                   (.push a f))
+      (reduce-kv #(.push a %2 %3)
                  nil (.-watches this)))
     (let [len (alength a)]
       (loop [i 0]
@@ -89,8 +89,7 @@
           (let [k (aget a i)
                 f (aget a (inc i))]
             (f k this old new))
-          (recur (+ 2 i))))))
-  nil)
+          (recur (+ 2 i)))))))

 (defn- pr-atom [a writer opts s]
   (-write writer (str "#<" s " "))
@@ -397,12 +396,10 @@
           wg watching]
       (set! watching der)
       (doseq [w der]
-        (when (or (nil? wg)
-                  (== -1 (.indexOf wg w)))
+        (when-not (in-arr wg w)
           (-add-watch w this handle-reaction-change)))
       (doseq [w wg]
-        (when (or (nil? der)
-                  (== -1 (.indexOf der w)))
+        (when-not (in-arr der w)
           (-remove-watch w this))))
     nil)


fix js function names

fix js function names

--- src/replikativ/js.cljs
+++ src/replikativ/js.cljs
@@ -88,10 +88,10 @@
          (reduce (fn [m [k v]] (assoc m k v)) {}))))

-(defn ^:export streamORMapIdentity [stage user crdt-id stream-eval-fns target]
+(defn ^:export streamORMapIntoIdentity [stage user crdt-id stream-eval-fns target]
   (ormap-realize/stream-into-identity! stage [user crdt-id] (eval-fns->js stream-eval-fns) target))

-(defn ^:export streamLWWRIdentity [stage user crdt-id target]
+(defn ^:export streamLWWRIntoIdentity [stage user crdt-id target]
   (lwwr-realize/stream-into-atom! stage [user crdt-id] target))

 (defn ^:export createUUID [s]


working play/pause/next/prev buttons

working play/pause/next/prev buttons

track offset is still horribly broken, will have to confront that before
implementing seek or showing remaining time

--- src-cljs/core.cljs
+++ src-cljs/core.cljs
@@ -36,7 +36,6 @@
               :playing true
               :track-offset 0
               :track-offset-when 0
-              :source nil
               }
      }))

@@ -48,6 +47,24 @@

 (defn tab-on-view []
   (om/ref-cursor (:tab-on-view (om/root-cursor app-state))))
+
+(defn player-state []
+  (om/ref-cursor (:player (om/root-cursor app-state))))
+
+(defn player-pause []
+  (om/transact! (player-state) #(update-in % [:playing] not)))
+
+(defn player-next []
+  ;; how do we make this fail if there are no more tracks?
+  (om/transact! (player-state) #(update-in % [:track-number] inc)))
+
+(defn player-prev []
+  (let [dec0 #(max (dec %) 0)]
+    (om/transact! (player-state) #(update-in % [:track-number] dec0))))
+
+
+(defn player-el []
+  (aget (.getElementsByTagName js/document "audio") 0))

 (defn enqueue-track [track]
   (om/transact! (player-queue) #(conj % track)))
@@ -229,16 +246,19 @@
       (let [el (om/get-node owner)]
         ;; last arg "true" is cos audio events don't bubble
         ;; http://stackoverflow.com/questions/11291651/why-dont-audio-and-video-events-bubble
-        (.addEventListener el "ended" #(dequeue-track 0) true)))
+        (.addEventListener el "ended" player-next true)))
     om/IRender
     (render [this]
       (let [queue (om/observe owner (player-queue))
-            on-view (om/observe owner (tab-on-view))
-            bits (best-media-url (first queue))]
-        (dom/audio #js {:controls "controls"
-                        :autoPlay "true"
-                        :ref "player"
-                        :src bits})))))
+            on-view (om/observe owner (tab-on-view))]
+        (dom/span #js {}
+                  (dom/button #js { :onClick player-pause }
+                              ">")
+                  (dom/button #js { :onClick player-next }
+                              ">>|")
+                  (dom/button #js { :onClick player-prev }
+                              "|<<")
+                  (dom/audio #js {:ref "player"}))))))

 (defn update-term [[command new-terms] previous]
@@ -313,13 +333,37 @@
                            (om/build player-view app))
                ))))

+(defn music-in-queue? [tracknum offset]
+  (let [queue (player-queue)
+        track (nth queue tracknum nil)]
+    (if track
+      (let [len (get track "length" 0)]
+        (if (>= len offset)
+          [track offset]
+          (music-in-queue? (inc track) (- offset len))))
+      nil)))
+
 (defn sync-transport [_ ref o n]
   (let [desired (:player n)
-        actual (aget (.getElementsByTagName js/document "audio") 0)]
-    (if-not (= (.-src actual) (:source desired))
-      (set! (.-src actual) (:source desired)))
-    (if (= (.-paused actual) (:playing desired))
-      (set! (.-paused actual) (not (:playing desired))))))
+        actual (player-el)
+        [urls offset] (music-in-queue?
+                       (:track-number desired) (:track-offset desired))]
+
+    ;; find out what track we should be playing
+    (let [bits (best-media-url urls)]
+      (if-not (= (.-src actual) bits)
+        (set! (.-src actual) bits)))
+
+    (when (and (.-paused actual) (:playing desired) urls)
+      ;; it might have paused because it reached the end of track, or
+      ;; because the user previously paused it.  If we have music available,
+      ;; now, resume
+      ; (set! (.-currentTime actual) offset)
+      (.play actual))
+
+    (if-not (:playing desired)
+      (.pause actual))))
+

 (defn init []
   (add-watch app-state :transport sync-transport)


Remove unused ns

Remove unused ns

--- src/ansel/auth.clj
+++ src/ansel/auth.clj
@@ -1 +0,0 @@
-(ns ansel.auth)


Fix macro; experiment with calling dependencies task

--- src/app/gradle.clj
+++ src/app/gradle.clj
@@ -3,6 +3,7 @@
           (org.gradle.tooling.model GradleProject)
           (org.gradle.tooling.model.eclipse EclipseProject)
           (org.gradle.tooling.model.idea IdeaProject)
+          (java.io ByteArrayOutputStream)
           (java.net URI))
   (:require [clojure.java.io :refer [file]]))

@@ -23,26 +24,39 @@
       (.useGradleUserHomeDir conn (file home)))
     (.connect conn)))

-(defn gradle-project
-  "Load an EclipseProject instance from Gradle"
-  [& args]
-  (with-gradle args
-    (.getModel proj-conn EclipseProject)))
-
 (defmacro with-gradle
   "Open a gradle project connection, binding to proj-conn
   by default (you can add `:as name` to your args to customize),
   execute the statements, and close the connection when done"
   [gradle-args & body]
-  (let [args-map (apply assoc {} (drop 1 gradle-args))
-        var-name (get args-map :as 'proj-conn)
-        pass-args (if (contains? args-map :as)
-                    (drop-last 2 gradle-args)
-                    gradle-args)]
-    `(let [~var-name (apply gradle-connection ~(vec pass-args))]
+  (let [args-map (if (seq? gradle-args)
+                   (apply assoc {} (drop 1 gradle-args))
+                   {})
+        var-name (get args-map :as 'proj-conn)]
+    `(let [~var-name (apply gradle-connection ~gradle-args)]
        (try
          (do ~body)
          (finally (.close ~var-name))))))
+
+(defn gradle-project
+  "Load an EclipseProject instance from Gradle"
+  [& args]
+  (with-gradle args
+    (.getModel proj-conn EclipseProject)))
+
+(defn gradle-list-dependencies
+  "Wacky way of listing dependencies"
+  [& args]
+  (let [out (ByteArrayOutputStream.)]
+    (with-gradle args
+      (.. proj-conn
+          (newBuild)
+          (forTasks (into-array ["dependencies"]))
+          (setStandardOutput out)
+          (run)
+          ))
+    (.toString out)))
+

 (defn get-dependencies
   "List dependency files for an EclipseProject"


formatting

formatting

--- src/chat/server/extensions/asana.clj
+++ src/chat/server/extensions/asana.clj
@@ -6,10 +6,12 @@
             [taoensso.timbre :as timbre]
             [environ.core :refer [env]]
             [chat.server.db :as db]
-            [chat.server.cache :refer [cache-set! cache-get cache-del! random-nonce]]
+            [chat.server.cache :refer [cache-set! cache-get cache-del!
+                                       random-nonce]]
             [chat.server.extensions :refer [redirect-uri webhook-uri
-                                            handle-thread-change handle-webhook handle-oauth-token
-                                            extension-config str->b64 b64->str edn-response]]
+                                            handle-thread-change handle-webhook
+                                            handle-oauth-token extension-config
+                                            str->b64 b64->str edn-response]]
             [chat.server.crypto :refer [hmac-verify]]))

 (def client-id (env :asana-client-id))
@@ -58,7 +60,8 @@
                                      "redirect_uri" redirect-uri
                                      "code" code}})]
           (if (= 200 (:status resp))
-            (let [{:strs [access_token refresh_token]} (json/read-str (:body resp))]
+            (let [{:strs [access_token refresh_token]} (-> resp :body
+                                                           json/read-str)]
               (db/with-conn
                 (db/save-extension-token! ext-id {:access-token access_token
                                                   :refresh-token refresh_token})))
@@ -76,9 +79,10 @@
       (if (= 200 (:status resp))
         (let [{:strs [access_token refresh_token]} (json/read-str (:body resp))]
           (db/with-conn
-            (db/save-extension-token! (ext :id) {:access-token access_token
-                                                 :refresh-token (or refresh_token
-                                                                    refresh-tok)})))
+            (db/save-extension-token! (ext :id)
+                                      {:access-token access_token
+                                       :refresh-token (or refresh_token
+                                                          refresh-tok)})))
         (do (timbre/warnf "Bad response when exchanging token %s" (:body resp))
             nil)))))


[TEMP COMMIT]

[TEMP COMMIT]

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -674,6 +674,54 @@
              (assoc ttLessonInfo :day day, :rowNum rowNum)))
          lessonInfoSeq)))

+(defn- find-replacement-lessons-within-time
+  "Given a lessonInfo map of a lesson which has been removed, find other lessons
+   on the same day but in a row below the removed lesson, which could be shifted
+   upwards and take the timeslots freed up by the removed lesson."
+  [removedLessonInfo]
+  (let [day       (:day removedLessonInfo)
+        row       (:rowNum removedLessonInfo)
+        startTime (:startTime lesson)
+        endTime   (:endTime lesson)]
+    ; TODO: Find the longest consecutive free time range
+    ))
+
+(defn- shift-lessons-upwards-to-replace-empty-slots
+  "For each removed lesson, see if there are any lessons in rows below it that
+   can be shifted upwards to occupy the empty slots resulting from its removal."
+  [removedLessonInfoSeq]
+  (let [sort-lesson-info-seq (fn [lessonInfoSeq]
+                               (sort #(let [dayA (:day %1)
+                                            dayB (:day %2)]
+                                        (if (= dayA dayB)
+                                          (< (:rowNum %1) (:rowNum %2))
+                                          (< dayA dayB)))
+                                     lessonInfoSeq))]
+
+    (loop [currentLessonInfoSeq (sort-lesson-info-seq removedLessonInfoSeq)
+           nextLessonInfoVec    []]
+      (cond (and (empty? currentLessonInfoSeq) (empty? nextLessonInfoVec))
+            nil
+
+            (empty? currentLessonInfoSeq)
+            (recur (sort-lesson-info-seq nextLessonInfoVec) [])
+
+            ; find timeslot to shift up to replace gap
+            :else
+            (let [replacementLessons (find-replacement-lessons-within-time
+                                       (first currentLessonInfoSeq))]
+              ; TODO: Shift the lessons...
+              ;
+              (recur (rest currentLessonInfoSeq)
+                     ; append newly shifted lessons to nextLessonInfoVec
+                     (loop [newlyShiftedLessons    replacementLessons
+                            nextLessonInfoVecPrime nextLessonInfoVec]
+                       (if (empty? newlyShiftedLessons)
+                           nextLessonInfoVecPrime
+                           (recur (rest newlyShiftedLessons)
+                                  (conj nextLessonInfoVecPrime
+                                        (first newlyShiftedLessons)))))))))))
+
 (defn remove-module
   "Removes a module from the timetable.

@@ -692,6 +740,7 @@
                 rowNum       (:rowNum ttLessonInfoAug)
                 ttLessonInfo (dissoc ttLessonInfoAug :day :rowNum)]
           (timetable-remove-lesson day rowNum ttLessonInfo)))
+        (shift-lessons-upwards-to-replace-empty-slots seqOfRemovedLessons)
         ; Remove from `ModulesSelected`
         (set! ModulesSelected (dissoc ModulesSelected moduleCode))
         ; Remove from `ModulesSelectedOrder`


small fix

small fix

--- src/cljs/salava/profile/ui/edit.cljs
+++ src/cljs/salava/profile/ui/edit.cljs
@@ -2,7 +2,7 @@
   (:require [reagent.core :refer [atom cursor create-class]]
             [reagent.session :as session]
             [salava.core.ui.ajax-utils :as ajax]
-            [salava.core.ui.helper :refer [path-for plugin-fun navigate-to]]
+            [salava.core.ui.helper :refer [path-for plugin-fun navigate-to js-navigate-to]]
             [salava.core.i18n :refer [t]]
             [reagent-modals.modals :as m]
             [salava.core.ui.field :as f]
@@ -107,7 +107,7 @@
                                                                                (swap! state assoc :spinner true :active-button "btn-2")
                                                                                (save-profile state (fn [] (do
                                                                                (swap! state assoc :spinner false)
-                                                                                (navigate-to (str "/profile/"(:user-id @state))))) true))}
+                                                                                (js-navigate-to (str "/profile/"(:user-id @state))))) true))}

                                           (when (and (:spinner @state) (= "btn-2" (:active-button @state))) [:i.fa.fa-spinner.fa-spin.fa-lg {:style {:padding "0 3px"}}]) (t :profile/Saveandclose) #_(t :page/View)]
                                          (when next?  [:div.pull-right {:id "step-button"}


Addressed a windows specific issue. Fixes #1

--- src/leiningen/new/electron.clj
+++ src/leiningen/new/electron.clj
@@ -2,14 +2,13 @@
   (:require [leiningen.new.templates :refer [renderer name-to-path ->files sanitize-ns]]
             [leiningen.core.main :as main]
             [clojure.java.io :as io]
-            [clojure.string :as str])
-  (:import java.io.File))
+            [clojure.string :as str]))

 (def render (renderer "electron"))

 ;; From: https://github.com/http-kit/lein-template/blob/master/src/leiningen/new/http_kit.clj
 (defn binary [file]
-  (io/input-stream (io/resource (str/join File/separator ["leiningen" "new" "electron" file]))))
+  (io/input-stream (io/resource (str/join "/" ["leiningen" "new" "electron" file]))))

 (defn electron
   [name]


Back to 0.8.11

Back to 0.8.11

--- src/leiningen/new/onyx_app.clj
+++ src/leiningen/new/onyx_app.clj
@@ -49,8 +49,8 @@
   (let [path (name-to-path name)
 	data {:name name
 	      ;; The formatting here matters
-	      :onyx-version "0.9.0"
-              :onyx-version-post "-alpha5"
+	      :onyx-version "0.8.11"
+              :onyx-version-post ""
 	      :onyx-sql-minor "0"
 	      :onyx-kafka-minor "0"
 	      :onyx-metrics-minor "0"


Fix typo.

Fix typo.

--- src/kixi/hecuba/api/measurements.clj
+++ src/kixi/hecuba/api/measurements.clj
@@ -1,4 +1,4 @@
-(ns kixi.hecuba.api.mesurements
+(ns kixi.hecuba.api.measurements
   (:require
    [bidi.bidi :as bidi]
    [clojure.string :as string]


Added concept-probability measure.

Added concept-probability measure.

Two functions for that are now implemented. The first one,
`concept-probability' computes the exact fraction, however,
is rather slow. The second one utilizes double precision floating
point arithmetic and omits certain factors that are not representable
in this precision anyway. But, in cases where contexts have thounsands
of attributes this function may not able to compute a correct result.

--- src/main/clojure/conexp/fca/misc.clj
+++ src/main/clojure/conexp/fca/misc.clj
@@ -12,7 +12,9 @@
             [conexp.fca
              [contexts :refer :all]
              [exploration :refer :all]
-             [implications :refer :all]]))
+             [implications :refer :all]]
+            [conexp.math
+             [util :refer [binomial-coefficient]]]))

 ;;; Compatible Subcontexts

@@ -235,3 +237,51 @@
                                    0)))))]
     (/ (counter #{} extent)
        (expt 2 (count extent)))))
+
+
+
+(defn concept-probability
+  "Compute the probability of a `concept' in `context' 𝕂 in the following manor.
+  Let pₘ be the relative frequence of attribute m in context. Then the
+  probability of a subset B ⊆ M in 𝕂 is the product of all pₘ for m ∈ B.
+  Then, the probability of a concep is defined by pr(A,B):=pr(B=B'')
+  which is: $\\sum_{k=0}^n {n\\choose k} p_B^k(1-p_B)^{n-k}\\prod_{m\\in
+  M\\setminus B}(1-p_m^k).$"
+  [context concept]
+  (let [n (count (objects context))
+        M (attributes context)
+        B (second concept) ; intent of concept
+        P_M_B (pmap #(/ (count (attribute-derivation context #{%})) n ) (difference M B))
+        p_B (reduce * (pmap #(/ (count (attribute-derivation context #{%})) n) B))
+        k_barrier (/ (Math/log 1E-16) (Math/log (apply max P_M_B)))]
+    (reduce + (pmap (fn [k]
+                       (* (binomial-coefficient n k)
+                          (expt p_B k)
+                          (expt (- 1 p_B) (- n k))
+                          (reduce * (map #(- 1 (expt % k)) P_M_B)))) (range 1 (inc n))))))
+
+(defn faster-concept-probability
+  "In case some of the powers are evaluated in double precision
+  arithmetic we might get loose of some of the last factors. When
+  $p_m^k$ is smallen than the Wilinson Epsilon we might gain no effect
+  by subtracting it form 1. Therefore we compute some `kbarrier' value
+  for the greatest $p_m$. For k bigger than that we omit the last
+  factor.  Be aware, if you have *many* attributes in the context this
+  might lead to errors."
+  [context concept]
+  (let [n (count (objects context))
+        M (attributes context)
+        B (second concept) ; intent of concept
+        P_M_B (pmap #(/ (count (attribute-derivation context #{%})) n ) (difference M B))
+        p_B (reduce * (pmap #(/ (count (attribute-derivation context #{%})) n) B))
+        k_barrier (int (/ (Math/log 1E-16) (Math/log (apply max P_M_B))))]
+    (+
+     (reduce + (pmap (fn [k]
+                       (* (binomial-coefficient n k)
+                          (expt p_B k)
+                          (expt (- 1 p_B) (- n k))
+                          (reduce * (map #(- 1 (Math/pow % k)) P_M_B)))) (range 1 k_barrier)))
+     (reduce + (pmap (fn [k]
+                       (* (binomial-coefficient n k)
+                          (expt p_B k)
+                          (expt (- 1 p_B) (- n k)))) (range (inc k_barrier) (inc n)))))))


Summarize test durations in minutes (#1241)

Top 10 slowest test with human readable timing. https://github.com/threatgrid/ctia/runs/5854822226?check_suite_focus=true#step:9:284

```clojure
Test var summary (slowest to fastest):
[[ctia.http.routes.graphql-test/test-graphql-route
  {:elapsed-ns 2.38164474867E11, :ISO-8601 "PT3M58.164474867S"}]
 [ctia.entity.incident-test/test-incident-severity-int-search
  {:elapsed-ns 1.24112328665E11, :ISO-8601 "PT2M4.112328665S"}]
 [ctia.entity.weakness-test/test-weakness-routes-access-control
  {:elapsed-ns 1.22775289708E11, :ISO-8601 "PT2M2.775289708S"}]
 [ctia.entity.campaign-test/test-campaign-routes-access-control
  {:elapsed-ns 1.16010526277E11, :ISO-8601 "PT1M56.010526277S"}]
 [ctia.entity.incident-test/test-incident-routes-access-control
  {:elapsed-ns 1.1082183857E11, :ISO-8601 "PT1M50.82183857S"}]
 [ctia.entity.casebook-test/test-casebook-routes-access-control
  {:elapsed-ns 1.01860613086E11, :ISO-8601 "PT1M41.860613086S"}]
 [ctia.http.routes.pagination-test/test-pagination-lists
  {:elapsed-ns 1.01767739728E11, :ISO-8601 "PT1M41.767739728S"}]
 [ctia.entity.actor-test/test-actor-routes-access-control
  {:elapsed-ns 9.9887591013E10, :ISO-8601 "PT1M39.887591013S"}]
 [ctia.task.migration.migrate-es-stores-test/test-migrate-store-indexes
  {:elapsed-ns 9.8318897082E10, :ISO-8601 "PT1M38.318897082S"}]
 [ctia.entity.relationship-test/test-relationship-routes-access-control
  {:elapsed-ns 9.7785129821E10, :ISO-8601 "PT1M37.785129821S"}]
```

[§](#qa) QA
============================

No QA is needed.

[§](#release-notes) Release Notes
=============================================================

```
intern: Summarize test durations in minutes
```

[§](#squashed-commits) Squashed Commits
======================================================================

--- scripts/summarize-tests.clj
+++ scripts/summarize-tests.clj
@@ -1,7 +1,8 @@
 #! /usr/bin/env bb

 (require '[clojure.pprint :as pp])
-(import '[java.io File])
+(import '[java.io File]
+        '[java.time Duration])

 (defn summarize []
   (let [timing-for-prefix (fn [file-prefix]
@@ -15,24 +16,25 @@
         ns-timing (timing-for-prefix "ns-timing")
         sorted-ns-timing (sort-by (comp :elapsed-ns val) > ns-timing)
         var-timing (timing-for-prefix "var-timing")
-        sorted-var-timing (sort-by (comp :elapsed-ns val) > var-timing)]
+        sorted-var-timing (sort-by (comp :elapsed-ns val) > var-timing)
+        humanize-ns (fn [ns]
+                      (str (Duration/ofNanos ns)))
+        humanize (fn [ts]
+                   (mapv (fn [[k {:keys [elapsed-ns] :as t}]]
+                           (assert (number? elapsed-ns) (pr-str t))
+                           [k (assoc t :ISO-8601 (humanize-ns elapsed-ns))])
+                         ts))]
     (when-some [expected (let [f (File. "dev-resources/ctia_test_timings.edn")]
                            (when (.exists f)
                              (-> f
                                  slurp
                                  read-string)))]
-      (println (str "Expected test duration: "
-                    (/ (apply + (map :elapsed-ns (vals expected)))
-                       1e9)
-                    " seconds")))
-    (println (str "Actual test duration: "
-                  (/ (apply + (map :elapsed-ns (vals ns-timing)))
-                     1e9)
-                  " seconds"))
+      (println (str "Expected test duration: " (humanize-ns (apply + (map :elapsed-ns (vals expected)))))))
+    (println (str "Actual test duration: " (humanize-ns (apply + (map :elapsed-ns (vals ns-timing))))))
     (println "\nTest namespace summary (slowest to fastest):")
-    (pp/pprint sorted-ns-timing)
+    (pp/pprint (humanize sorted-ns-timing))
     (println "\nTest var summary (slowest to fastest):")
-    (pp/pprint sorted-var-timing)
+    (pp/pprint (humanize sorted-var-timing))
     (-> (File. "target/test-results") .mkdirs)
     (spit "target/test-results/all-test-var-timings.edn" var-timing)
     (spit "target/test-results/all-test-timings.edn" ns-timing)))


Add separator

Add separator

--- src/org/spootnik/om_fleet/views.cljs
+++ src/org/spootnik/om_fleet/views.cljs
@@ -127,7 +127,7 @@
           (string? script) (cond
                              (= script "ping") script
                              :else "shell")
-          (script "service") (str "service" (script "action"))
+          (script "service") (str "service " (script "action"))
           (script "sleep") "sleep"
           (script "shell") "shell"
           :else "unknown")) " "


require verbose

require verbose

--- src/hackerrank/clojure_libs.clj
+++ src/hackerrank/clojure_libs.clj
@@ -39,3 +39,6 @@
 ;; (require '(clojure [string :as string] test))
 ;; (string/join [1 2 3])

+;; verbose
+(require '[clojure.string :as string] :verbose)
+(require '[clojure.test :as test] :verbose)


extra try/catch blocks for Sync DB

extra try/catch blocks for Sync DB

--- src/metabase/driver/generic_sql/sync.clj
+++ src/metabase/driver/generic_sql/sync.clj
@@ -91,38 +91,44 @@
   "Create new Fields for any that don't exist; mark ones that no longer exist as `inactive`."
   {:arglists '([korma-table table])}
   [korma-table {table-id :id, table-name :name, db :db}]
-  (let [fields (jdbc-columns db table-name)
-        field-names (set (map :column_name fields))
-        field-name->id (sel :many :field->id [Field :name] :table_id table-id :name [in field-names])]
-    ;; Mark any existing `Field` objects not returned by jdbc-columns as inactive
-    (dorun (map (fn [[field-name field-id]]
-                  (when-not (contains? field-names field-name)
-                    (upd Field field-id :active false)))
-                field-name->id))
-    ;; Create `Field` objects for any new Fields returned by jdbc-columns
-    (dorun (map (fn [{field-name :column_name type-name :type_name}]
-                  (when-not (field-name->id field-name)
-                    (ins Field
-                      :table_id table-id
-                      :name field-name
-                      :base_type (or (*column->base-type* (keyword type-name))
-                                     (throw (Exception. (str "Column '" field-name "' has an unknown type: '" type-name
-                                                             "'. Please add the type mapping to corresponding driver (e.g. metabase.driver.postgres.sync).")))))))
-                fields))))
+  (try
+    (let [fields (jdbc-columns db table-name)
+          field-names (set (map :column_name fields))
+          field-name->id (sel :many :field->id [Field :name] :table_id table-id :name [in field-names])]
+      ;; Mark any existing `Field` objects not returned by jdbc-columns as inactive
+      (dorun (map (fn [[field-name field-id]]
+                    (when-not (contains? field-names field-name)
+                      (upd Field field-id :active false)))
+                  field-name->id))
+      ;; Create `Field` objects for any new Fields returned by jdbc-columns
+      (dorun (map (fn [{field-name :column_name type-name :type_name}]
+                    (when-not (field-name->id field-name)
+                      (ins Field
+                        :table_id table-id
+                        :name field-name
+                        :base_type (or (*column->base-type* (keyword type-name))
+                                       (throw (Exception. (str "Column '" field-name "' has an unknown type: '" type-name
+                                                               "'. Please add the type mapping to corresponding driver (e.g. metabase.driver.postgres.sync).")))))))
+                  fields)))
+    (catch Throwable e
+      (log/error "Caught exception in sync-fields-create:" e))))

 (defn- sync-fields-metadata
   "Sync the metadata of all active fields for TABLE (in parallel)."
   {:arglists '([korma-table table])}
   [korma-table {table-id :id table-name :name}]
-  (->> (sel :many Field :table_id table-id :active true)
-       (pmap (fn [field]
-               (try
-                 (check-for-low-cardinality korma-table field)
-                 (check-for-large-average-length korma-table field)
-                 (check-for-urls korma-table field)
-                 (catch Throwable e
-                   (log/warn (format "Caught exception when syncing field '%s.%s':" table-name (:name field)) e)))))
-       dorun))
+  (try
+    (->> (sel :many Field :table_id table-id :active true)
+         (pmap (fn [field]
+                 (try
+                   (check-for-low-cardinality korma-table field)
+                   (check-for-large-average-length korma-table field)
+                   (check-for-urls korma-table field)
+                   (catch Throwable e
+                     (log/warn (format "Caught exception when syncing field '%s.%s':" table-name (:name field)) e)))))
+         dorun)
+    (catch Throwable e
+      (log/error "Caught exception in sync-fields-metadata:" e))))

 ;; ## Metadata -- Fetch Tables/Columns/PKs/FKs from DB


Fixes #162

Fixes #162

--- src/kixi/hecuba/api/devices.clj
+++ src/kixi/hecuba/api/devices.clj
@@ -58,8 +58,8 @@
   (fn [ctx]
     (let [{:keys [request-method session params]} (:request ctx)
           {:keys [projects programmes roles]}     (sec/current-authentication session)
-          entity_id (:entity_id params)
-          project_id (when entity_id
+          entity_id (:entity_id params)
+          project_id (when entity_id
                        (:project_id (search/get-by-id entity_id (:search-session store))))
           programme_id (when project_id (:programme_id (projects/get-by-id (:hecuba-session store) project_id)))]
       (if (and project_id programme_id)
@@ -109,7 +109,8 @@
       (update-in [:type] #(str % "_" type-ext))
       (assoc :period "PULSE" :synthetic true)))

-(defmulti calculated-sensor (fn [sensor] (.toUpperCase (:unit sensor))))
+(defmulti calculated-sensor (fn [sensor] (when-let [unit (:unit sensor)]
+                                           (.toUpperCase unit))))

 (defmethod calculated-sensor "KWH" [sensor]
   (-> sensor


Problem: client can just say 'hello'.

Problem: client can just say 'hello'.

--- main/clojure/src/hydra.clj
+++ main/clojure/src/hydra.clj
@@ -1,14 +1,38 @@
 (ns hydra
   (:require [zeromq.zmq :as zmq])
-  (:import [org.zproto HydraMsg]))
+  (:import [org.zproto HydraMsg]
+           [org.zeromq ZMsg]
+           [java.io StringWriter PrintWriter PrintStream OutputStreamWriter]))

-(defn simple-hello
-  "send a hello message to endpoint and receive the reply."
-  [endpoint]
+(defprotocol HydraClient
+  (hello    [this])
+  (get-tags [this])
+  (get-tag [this tag])
+  (get-post [this post-id])
+  (goodbye [this]))
+
+(defrecord Client [socket]
+  HydraClient
+  (hello [this]
+    (HydraMsg/sendHello socket)
+    (HydraMsg/recv socket))
+  (get-tags [this]
+    (HydraMsg/sendGet_Tags socket)
+    (HydraMsg/recv socket))
+  (get-tag [this tag]
+    (HydraMsg/sendGet_Tag socket tag)
+    (HydraMsg/recv socket))
+  (get-post [this post-id]
+    (HydraMsg/sendGet_Post socket post-id)
+    (HydraMsg/recv socket))
+  (goodbye [this]
+    (HydraMsg/sendGoodbye socket)
+    (HydraMsg/recv socket)))
+
+(defn mk-client [endpoint]
   (let [context (zmq/context)
-        output (doto (zmq/socket context :dealer)
-                 (zmq/connect endpoint)
-                 (zmq/set-receive-timeout 1000))]
-    (HydraMsg/sendHello output)
-    (HydraMsg/recv output)))
+        socket (doto (zmq/socket context :dealer)
+                 (zmq/set-receive-timeout 1000)
+                 (zmq/connect endpoint))]
+    (->Client socket)))


thank kibit

thank kibit

--- src/oc/storage/util/search.clj
+++ src/oc/storage/util/search.clj
@@ -48,7 +48,7 @@
   (let [now (db-common/current-timestamp)]
     (doseq [org (org-res/list-orgs conn [:team-id])]
       (let [boards (board-res/list-boards-by-org conn (:uuid org))
-            allowed-boards (vec (map #(:uuid %) boards))
+            allowed-boards (vec (map :uuid boards))
             entries (entry-res/list-entries-by-org conn (:uuid org) :desc now :before allowed-boards)]
         (doseq [entry entries]
           (let [board (first (filter #(= (:uuid %) (:board-uuid entry)) boards))]


enable to delete todo items

enable to delete todo items

--- src/om_next_todolist/core.cljs
+++ src/om_next_todolist/core.cljs
@@ -58,6 +58,19 @@
      (fn []
        (swap! state update-in [:todos index :completed] not))}))

+(defn- remove-todo
+  [todos id]
+  (-> (remove #(= id (:id %)) todos) vec))
+
+(defmethod mutate 'todos/delete
+  [env key params]
+  (let [state (:state env)
+        id (:id params)
+        todos (remove-todo (:todos @state) id)]
+    {:action
+     (fn []
+       (swap! state assoc :todos todos))}))
+

 ;; -----------------------------------------------------------------------------
 ;; Components
@@ -75,7 +88,10 @@
                         :className "toggle"
                         :checked (and completed "checked")
                         :onChange #(om/transact! this `[(todo/toggle {:id ~id})])})
-        (dom/span #js {:className class} title)))))
+        (dom/span #js {:className class} title)
+        (dom/span #js {:className "delete"
+                       :onClick #(om/transact! this `[(todos/delete {:id ~id}) :todos])}
+                  "[x]")))))

 (def todo-item (om/factory TodoItem))


Remove outdated comment

Remove outdated comment

--- src/onyx/peer/virtual_peer.clj
+++ src/onyx/peer/virtual_peer.clj
@@ -43,8 +43,6 @@
               entry (first (alts!! [kill-ch inbox-ch] :priority true))]
           (if entry
             (let [new-replica (extensions/apply-log-entry entry replica)
-                  ;;; Or could have materialized view here so things are ready for next replica application
-                  ;;; Or maybe two, materialized replica (with map-invert here)
                   diff (extensions/replica-diff entry replica new-replica)
                   reactions (extensions/reactions entry replica new-replica diff state)
                   new-peer-view (extensions/peer-replica-view entry replica new-replica peer-view diff id)


Indentation

Indentation

--- src/cats/core.cljc
+++ src/cats/core.cljc
@@ -326,23 +326,23 @@
     sorted-deps))

 (defn alet*
-    [batches env body]
-    (let [fb (first batches)
+  [batches env body]
+  (let [fb (first batches)
         rb (rest batches)
         fs (first fb)
         fa (get env fs)]
-      (reduce (fn [acc syms]
-                (let [fs (first syms)
-                      fa (get env fs)
-                      faps (map #(get env %) (rest syms))]
-                  (if (= (count syms) 1)
-                    `(join (fmap (fn [~fs] ~acc) ~fa))
-                    `(fapply (fmap (fn [~(first syms)]
-                                     (fn [~@(rest syms)] ~acc))
-                                    ~fa)
-                            ~@faps))))
-            `(do ~body)
-            (reverse batches))))
+    (reduce (fn [acc syms]
+              (let [fs (first syms)
+                    fa (get env fs)
+                    faps (map #(get env %) (rest syms))]
+                (if (= (count syms) 1)
+                  `(join (fmap (fn [~fs] ~acc) ~fa))
+                  `(fapply (fmap (fn [~(first syms)]
+                                   (fn [~@(rest syms)] ~acc))
+                                  ~fa)
+                          ~@faps))))
+          `(do ~body)
+          (reverse batches))))

 #?(:clj
    (defmacro alet


allow mul-add to auto-determine the correct rate

--- src/overtone/sc/cgens/line.clj
+++ src/overtone/sc/cgens/line.clj
@@ -12,8 +12,8 @@
   ""
   (:ar (let [scale (/ (- dsthi dstlo) (- srchi srclo))
              offset (- dstlo (* scale srclo))]
-         (mul-add:ar in scale offset)))
+         (mul-add in scale offset)))

   (:kr (let [scale (/ (- dsthi dstlo) (- srchi srclo))
              offset (- dstlo (* scale srclo))]
-         (mul-add:kr in scale offset))))
+         (mul-add in scale offset))))


chan_size -> chan-size, batch_size -> batch-size

--- src/whisper2cyanite/metric_store.clj
+++ src/whisper2cyanite/metric_store.clj
@@ -45,9 +45,9 @@

 (defn- get-channel
   "Get store channel."
-  [session statement chan_size batch_size data-stored?]
-  (let [ch (async/chan chan_size)
-        ch-p (utils/partition-or-time batch_size ch batch_size 5)]
+  [session statement chan-size batch-size data-stored?]
+  (let [ch (async/chan chan-size)
+        ch-p (utils/partition-or-time batch-size ch batch-size 5)]
     (utils/go-while (not @data-stored?)
                     (let [values (async/<! ch-p)]
                       (if values
@@ -76,14 +76,14 @@
         session (-> (alia/cluster c-options)
                     (alia/connect keyspace))
         insert! (get-cassandra-insert session)
-        chan_size (:cassandra-channel-size options default-cassandra-channel-size)
-        batch_size (:cassandra-batch-size options default-cassandra-batch-size)
+        chan-size (:cassandra-channel-size options default-cassandra-channel-size)
+        batch-size (:cassandra-batch-size options default-cassandra-batch-size)
         data-stored? (atom false)
-        channel (get-channel session insert! chan_size batch_size data-stored?)]
+        channel (get-channel session insert! chan-size batch-size data-stored?)]
     (log/info (str "The metric store has been created. "
                    "Keyspace: " keyspace ", "
-                   "channel size: " chan_size ", "
-                   "batch size: " batch_size))
+                   "channel size: " chan-size ", "
+                   "batch size: " batch-size))
     (reify
       MetricStore
       (insert [this tenant rollup period path time value ttl]


Tiny refactor

Tiny refactor

--- src/braid/core/client/gateway/forms/join_group/events.cljs
+++ src/braid/core/client/gateway/forms/join_group/events.cljs
@@ -16,9 +16,7 @@
 (reg-event-fx
   ::handle-group-info
   (fn [{state :db} [_ group-info]]
-    {:db (assoc-in state [:join-group :group] (if group-info
-                                                       group-info
-                                                       {}))}))
+    {:db (assoc-in state [:join-group :group] (or group-info {}))}))

 (reg-event-fx
   ::handle-error


Let servlets have static content, too

Let servlets have static content, too

--- web/src/immutant/web.clj
+++ web/src/immutant/web.clj
@@ -77,7 +77,7 @@
   ([context-path server]
      (.unregister server context-path)))

-(defn ^{:valid-options #{:context-path}}
+(defn ^{:valid-options #{:context-path :static-dir}}
   mount-servlet
   "Mount a servlet on a server.
    Returns the server instance."


get test coverage working

get test coverage working

--- src/sicp/L3_A/escher/core/eschermain.clj
+++ src/sicp/L3_A/escher/core/eschermain.clj
@@ -1,7 +1,7 @@
 (ns sicp.L3_A.escher.core.eschermain
   (:gen-class))

-(use 'L3_A.escher.core.launch)
+(use 'sicp.L3_A.escher.core.launch)

 (defn -main [& args]
   (run-escher))


Remove clojure.stacktrace reference in user ns.

--- dev/user.clj
+++ dev/user.clj
@@ -10,7 +10,6 @@
       [tests :as test :refer [random-bytes]])
     [clojure.java.io :as io]
     [clojure.repl :refer :all]
-    [clojure.stacktrace :refer [print-cause-trace]]
     [clojure.string :as str]
     [clojure.tools.namespace.repl :refer [refresh]]
     [multihash.core :as multihash])


style MC page and allow pressing enter on password form

--- src/client/mc.cljs
+++ src/client/mc.cljs
@@ -12,9 +12,10 @@
 ;;------------------------------------------------------------

 (hiccups/defhtml stop-html []
-	[:div#inner-container.login
-		[:div.login-container
-      [:button#submit-stop-game.lg-btn "Stop"]]])
+  [:div#inner-container
+    [:div.login-5983e
+      [:form
+        [:button#submit.red-btn-2c9ab "STOP"]]]])

 (declare init-start-page!)

@@ -23,7 +24,7 @@
   []
   (.html ($ "#main-container") (stop-html))

-  (.click ($ "#submit-stop-game")
+  (.click ($ "#submit")
           #(do (.emit @socket "stop-game")
                (init-start-page!))))

@@ -32,17 +33,17 @@
 ;;------------------------------------------------------------

 (hiccups/defhtml start-html []
-	[:div#inner-container.login
-		[:div.login-container
-			[:button#submit-start-lines.lg-btn "Start - 40 lines"]
-      [:button#submit-start-time.lg-btn "Start - 5 minutes"]]])
+  [:div#inner-container
+    [:div.login-5983e
+      [:form
+        [:button#submit.green-btn-f67eb "START"]]]])

 (defn init-start-page!
   "Initialize the start game page."
   []
   (.html ($ "#main-container") (start-html))

-  (.click ($ "#submit-start-time")
+  (.click ($ "#submit")
           #(do (.emit @socket "start-time")
                (init-stop-page!))))

@@ -51,11 +52,13 @@
 ;;------------------------------------------------------------

 (hiccups/defhtml password-html []
-	[:div#inner-container.login
-		[:div.login-container
-			[:label "MC password:"]
-			[:input#password.login-name {:type "password"}]
-			[:button#submit-pass.lg-btn "OK"]]])
+  [:div#inner-container
+    [:div.login-5983e
+      [:form
+        [:div.input-4a3e3
+          [:label.label-66a3b "MC password:"]
+          [:input#password.input-48f1f {:type "password"}]]
+        [:button#submit.red-btn-2c9ab "OK"]]]])

 (defn on-grant-mc
   "Callback for handling the MC access grant."
@@ -70,9 +73,14 @@
   (.html ($ "#main-container") (password-html))

   ; Request access as MC when user submits password.
-  (.click ($ "#submit-pass")
+  (.click ($ "#submit")
           #(.emit @socket "request-mc"
                   (.val ($ "#password"))))
+
+  ; Allow pressing enter to submit.
+  (.keyup ($ "#password")
+          #(if (= (.-keyCode %) 13)
+             (.click ($ "submit"))))

   ; Render either the stop page or the start page
   ; when access as MC is granted.
@@ -84,6 +92,8 @@

 (defn init
   []
+  (client.core/set-bw-background!)
+
   (init-password-page!)
   )


Annotations: Smaller font.

Annotations: Smaller font.

--- src/main/clojure/conexp/gui/draw/nodes_and_connections.clj
+++ src/main/clojure/conexp/gui/draw/nodes_and_connections.clj
@@ -3,6 +3,7 @@
   (:require [conexp.base :refer :all]
             [conexp.gui.draw.scenes :refer :all])
   (:import java.awt.Color
+           java.awt.Font
            [no.geosoft.cc.graphics GInteraction GObject GPosition GScene GSegment GStyle GText GWindow ZoomInteraction]))

 ;;; nodes and connections
@@ -94,7 +95,8 @@
   "Default style for the valuation part of the concept."
   (doto (GStyle.)
     (.setBackgroundColor Color/WHITE)
-    (.setForegroundColor Color/RED)))
+    (.setForegroundColor Color/RED)
+    (.setFont(Font. "TimesRoman" Font/BOLD 10))))

 (def- default-node-label-style
@@ -147,9 +149,8 @@
                          [l u] (create-two-halfcircles x y (radius this))]
                      (.setGeometryXy lower-segment l)
                      (.setGeometryXy upper-segment u)
-                     (println (double x) (double y))
                      (.setGeometry middle-segment
-                                   (double (+ x (/ (radius this) 1.5)))
+                                   (double (+ x (radius this)))
                                    (double y))
                      (.setStyle lower-segment lower-style)
                      (.setStyle upper-segment upper-style)


Remove old atoms

Remove old atoms

--- src/ansel/db.clj
+++ src/ansel/db.clj
@@ -12,13 +12,7 @@
   (:import org.mindrot.jbcrypt.BCrypt))

 (defqueries "sql/queries.sql")
-(def tnow (comp to-timestamp now))
-
 (def config  (atom nil))
-(def running (atom true))
-
-(def save-interval (minutes 3))
-
 (def default-config {:upload-path nil
                      :thumb-path nil
                      :template-path nil
@@ -51,6 +45,8 @@
    :subprotocol "postgresql"
    :subname (get-in @config [:database :host])
    :user (get-in @config [:database :user])})
+
+(def tnow (comp to-timestamp now))

 (defn hash-bcrypt [password]
   (BCrypt/hashpw password (BCrypt/gensalt)))
@@ -112,15 +108,15 @@

 (defn get-images [& limit]
   (let [images (if (seq limit)
-                  (sql-get-images-limit (get-db-spec) (first limit))
-                  (sql-get-all-images (get-db-spec)))]
+                 (sql-get-images-limit (get-db-spec) (first limit))
+                 (sql-get-all-images (get-db-spec)))]
     (map beef-up-image images)))

 (defn get-image-by-id
   ([id] (get-image-by-id id 0))
   ([id user-id]
    (when-let [images (sql-get-image-by-id (get-db-spec) user-id id)]
-      (beef-up-image (first images)))))
+     (beef-up-image (first images)))))

 (defn add-image-to-db [image user-id]
   (sql-insert-image! (get-db-spec)


test fix :heart_eyes:

test fix :heart_eyes:

--- src/metabase/api/meta/field.clj
+++ src/metabase/api/meta/field.clj
@@ -1,6 +1,6 @@
 (ns metabase.api.meta.field
   (:require [compojure.core :refer [GET PUT POST]]
-            [medley.core :as medley]
+            [medley.core :as m]
             [metabase.api.common :refer :all]
             [metabase.db :refer :all]
             [metabase.db.metadata-queries :as metadata]
@@ -36,14 +36,13 @@
 (defendpoint PUT "/:id"
   "Update `Field` with ID."
   [id :as {{:keys [field_type special_type preview_display description]} :body}]
-  {field_type FieldType
+  {field_type   FieldType
    special_type FieldSpecialType}
   (write-check Field id)
-  (check-500 (upd Field id
-               :field_type      field_type
-               :special_type    special_type
-               :preview_display preview_display
-               :description     description))
+  (check-500 (m/mapply upd Field id (merge {:description  description                                   ; you're allowed to unset description and special_type
+                                            :special_type special_type}                                 ; but field_type and preview_display must be replaced
+                                           (when field_type      {:field_type field_type})              ; with new non-nil values
+                                           (when preview_display {:preview_display preview_display}))))
   (sel :one Field :id id))

 (defendpoint GET "/:id/summary"


[layer munging] correct oddness in max pooling 2d desc map conversion

--- keras/src/think/cortex/keras/core.clj
+++ keras/src/think/cortex/keras/core.clj
@@ -51,12 +51,11 @@

 (defmethod model-item->desc :MaxPooling2D
   [{:keys [config]}]
-  (let [[kernel-x kernel-y] (get config :pool_size)
-        [stride-x stride-y] (get config :strides)]
-    (update-in
-     (first
-      (desc/max-pooling kernel-x kernel-y 0 0 stride-x stride-y))
-     [0] #(assoc % :id (keyword (:name config))))))
+  (let [[kernel-x kernel-y] (:pool_size config)
+        [stride-x stride-y] (:strides config)
+        [layer]             (desc/max-pooling kernel-x kernel-y 0 0 stride-x stride-y)
+        layer-id            (-> config :name keyword)]
+    (assoc layer :id layer-id)))

 (defmethod model-item->desc :Activation


Fixing XPath declare location.

Fixing XPath declare location.

--- umm-spec-lib/src/cmr/umm_spec/simple_xpath.clj
+++ umm-spec-lib/src/cmr/umm_spec/simple_xpath.clj
@@ -74,6 +74,9 @@
   [attrib-name]
   (let [[_ _ namespace-part name-part] (re-find #"((.*):)?(.*)" attrib-name)]
     (keyword namespace-part name-part)))
+
+;; Needed for create the element value selector
+(declare parse-xpath)

 (defn- create-attrib-val-equality-selector
   "Creates a selector that selects elements with an attribute with a given value."
@@ -85,9 +88,6 @@
     {:type :attrib-value-selector
      :selectors (:selectors parsed-xpath)
      :value value}))
-
-;; Needed for create the element value selector
-(declare parse-xpath)

 (defn- create-elem-val-equality-selector
   "Creates a selector that selects elements which have a child element with a given value.


remove unused dependency

remove unused dependency

--- test/clj_money/api/accounts_test.clj
+++ test/clj_money/api/accounts_test.clj
@@ -2,7 +2,6 @@
   (:require [clojure.test :refer [deftest is use-fixtures]]
             [ring.mock.request :as req]
             [cheshire.core :as json]
-            [lambdaisland.uri :refer [map->query-string]]
             [dgknght.app-lib.web :refer [path]]
             [dgknght.app-lib.test :refer [parse-json-body]]
             [clj-money.factories.user-factory]


adding restore and splitting protocols

adding restore and splitting protocols

--- moebius/src/moebius/kv.clj
+++ moebius/src/moebius/kv.clj
@@ -1,5 +1,12 @@
 (ns moebius.kv
-  (:refer-clojure :exclude [set get remove]))
+  (:refer-clojure :exclude [set get remove update]))
+
+;;
+;; TODO: multi set function
+;; TODO: force keys to string?
+;; TODO: Do ve need the version? (think repartitioning)
+;; TOOD: tx-log + compaction: single key or all keys x sourceId?
+;;

 (defprotocol KV
   "A key value store protocol"
@@ -8,37 +15,64 @@
     "Set the given key to the give value. Returns the new KV store")

   (get [kvstore sourceId key]
-    "It returns the current value of the given key. nil if not found.")
+    "It returns the current value of the given key. nil if not found."))

+
+
+(defprotocol Tx-Log
+  "A transaction log protocol"
+
+  (update [kvstore sourceId key value]
+    "Set the given key to the give value. Returns the new KV store")

   (snapshot [kvstore]
     "Return the current value of the kvstore")

   (tx-log [kvstore]
-    "Return the current Transaction log"))
+    "Return the current Transaction log")
+
+  (restore [kvstore tx-log]
+    "restore the state of a KV store from a given txlog"))

 (defrecord InMemoryKVstore [data]

+  ;; implementing KV protocol
   KV
   (set [kvstore sourceId key value]
+    (update kvstore sourceId key value))
+
+
+  (get [kvstore sourceId key]
+    (get-in kvstore [:data :snapshot sourceId key]))
+
+
+  ;; implementing Tx-Log semantics
+  Tx-Log
+  (update [kvstore sourceId key value]
     (InMemoryKVstore.
      (-> (:data kvstore)
+         ;; increment version number
          (update-in [:version] inc)
+         ;; update the given key
          (assoc-in [:snapshot sourceId key] value)
+         ;; add a tx-log record
          ((fn [{:keys [version] :as data}]
             (update-in data [:tx-log] conj [version [sourceId key] value]))))))
+
+  (tx-log [kvstore]
+    (-> kvstore :data :tx-log))
+

   (snapshot [kvstore]
     (-> kvstore :data :snapshot))

-  (tx-log [kvstore]
-    (-> kvstore :data :tx-log))

-  (get [kvstore sourceId key]
-    (get-in kvstore [:data :snapshot sourceId key]))
-)
+  (restore [kvstore tx-log]
+    (reduce (fn [kv [_ [sourceId key] value]]
+         (update kv sourceId key value))
+       kvstore tx-log)))

 (defn make-in-memory-kvstore []
@@ -46,15 +80,22 @@

 (comment
- (def kv (make-in-memory-kvstore))
+  ;; create empty kvstores
+  (def kv1 (make-in-memory-kvstore))
+  (def kv2 (make-in-memory-kvstore))

- (def kv1 (set (set kv "a" :test 1) "a" :test 2))
+  ;; both same
+  (= kv1 kv2)

- (set kv "a" :test3 4)
+  ;; make some changes
+  (def kv1'
+    (-> kv1
+        (set "a" :test 1)
+        (set "a" :test 2)))

- (kv-get kv "a" :test)
-  kv
+  ;; restore state based on tx-log
+  (def kv2' (restore kv2 (tx-log kv1')))

- (snapshot kv)
-
- (tx-log kv))
+  ;; still the same
+  (= kv1' kv2')
+)


add close-websocket fn

add close-websocket fn

--- src/replme/cljs/websocket.cljs
+++ src/replme/cljs/websocket.cljs
@@ -8,6 +8,9 @@
 (defn new-socket
   [url]
   (js/WebSocket. url))
+
+(defn close-socket [socket]
+  (.close socket 1000))

 (defn socket-send
   [socket msg]


Increase http-kit queue size

Increase http-kit queue size

--- src/onyx/messaging/http_kit.clj
+++ src/onyx/messaging/http_kit.clj
@@ -42,10 +42,10 @@
     (taoensso.timbre/info "Starting HTTP Kit WebSockets")

     (let [ch (:inbound-ch (:messenger-buffer component))
-          release-ch (chan (clojure.core.async/dropping-buffer 100000))
+          release-ch (chan (clojure.core.async/dropping-buffer 1000000))
           daemon (:acking-daemon component)
           ip "0.0.0.0"
-          server (server/run-server (partial app daemon ch release-ch) {:ip ip :port 0 :thread 1 :queue-size 100000})]
+          server (server/run-server (partial app daemon ch release-ch) {:ip ip :port 0 :thread 1 :queue-size 1000000})]
       (assoc component :server server :ip ip :port (:local-port (meta server)) :release-ch release-ch)))

   (stop [component]


more lenient assert to support older docker api

--- test/clj/swarmpit/docker/client_test.clj
+++ test/clj/swarmpit/docker/client_test.clj
@@ -40,5 +40,5 @@
                        (filter #(= (:ID service) (:ID %))))))))

   (testing "errors"
-    (is (thrown-with-msg? ExceptionInfo #"Docker engine error: secret not-existing not found"
+    (is (thrown-with-msg? ExceptionInfo #"not-existing"
                           (delete-secret "not-existing")))))


Adding --with-zlib-include/lib to openssl

--- src/fatty/core.clj
+++ src/fatty/core.clj
@@ -42,7 +42,7 @@
                                 ["sudo" "make" "install"]]))

 (def openssl (software :source "openssl-0.9.8o"
-                       :steps [["./config" "--prefix=/opt/opscode/embedded" "-L/opt/opscode/embedded/lib" "-I/opt/opscode/embedded/include" "zlib-dynamic" "shared"]
+                       :steps [["./config" "--prefix=/opt/opscode/embedded" "--with-zlib-lib=/opt/opscode/embedded/lib" "--with-zlib-include=/opt/opscode/embedded/include" "zlib-dynamic" "shared"]
                                ["bash" "-c" "make"]
                                ["sudo" "make" "install"]]))