Remove all atom variable.

Remove all atom variable.

--- src/cljs/reversi/phaser.cljs
+++ src/cljs/reversi/phaser.cljs
@@ -2,12 +2,14 @@
   (:require [clojure.browser.repl]
             [reversi.core :as rcore]))

-(def *border* (atom rcore/*default-border*))
-(def *phaser-border* (atom [[] [] [] [] [] [] [] []]))
-(def *visible-possible-grids-pos* (atom '()))
-(def ^:dynamic *game* (js/Phaser.Game. 905 605 js/Phaser.AUTO "game_div"))
-(def ^:dynamic *default-player-use-piece* rcore/*black-piece*)
-(def ^:dynamic *default-pc-use-piece* rcore/*white-piece*)
+(def *border*  rcore/*default-border*)
+(def *phaser-border* [[] [] [] [] [] [] [] []])
+(def *visible-possible-grids-pos* '())
+(def ^:dynamic *default-player-piece* rcore/*black-piece*)
+(def ^:dynamic *default-pc-piece* rcore/*white-piece*)
+(def *game* (js/Phaser.Game.
+             905 605
+             js/Phaser.AUTO "game_div"))

 (defn grid-name->rcore-grid [grid-name]
   (let [gn-rp-table
@@ -25,13 +27,23 @@
          rcore/*possible-grid* "possible-grid"}]
     (rp-gn-table rcore-grid)))

+(defn grid-pos->phaser-pos [grid-pos]
+  [(+ (* 75 (first grid-pos)) 5)
+   (+ (* 75 (second grid-pos)) 5)])
+
 (defn another-color-piece [grid-name]
   (rcore-grid->grid-name
    (rcore/another-color-piece
     (grid-name->rcore-grid grid-name))))

-(defn put-piece [piece [x y] border phaser-border]
-  (let [result-border
+(defn put-piece [piece [x y] game]
+  (let [border
+        (.-border game)
+        phaser-border
+        (.-phaserBorder game)
+        visible-possible-grids-pos
+        (.-visiblePossibleGridsPos game)
+        result-border
         (rcore/put-piece piece
                          [x y]
                          border
@@ -46,95 +58,120 @@
                                  false)
                            ))]
     (when-not (empty? result-border)
-      (doseq [pg-pos @*visible-possible-grids-pos*]
+      (doseq [pg-pos visible-possible-grids-pos]
         (set! (.-visible ((rcore/gridth pg-pos phaser-border)
                           "possible-grid")) false))
-      (reset! *visible-possible-grids-pos* '())
-      (reset! *border* result-border)
+      (set! (.-visiblePossibleGridsPos game) '())
+      (set! (.-border game) result-border)
       result-border)))

-(defn pc-ai-put-piece [border phaser-border]
-  (let [pc-possible-grids-pos
+(defn pc-ai-put-piece [game]
+  (let [border
+        (.-border game)
+        phaser-border
+        (.-phaserBorder game)
+        visible-possible-grids-pos
+        (.-visiblePossibleGridsPos game)
+        pc-possible-grids-pos
         (rcore/find-putable-empty-grids
-         *default-pc-use-piece* border)]
+         *default-pc-piece* border)]
     (if-not (empty? pc-possible-grids-pos)
-      (put-piece *default-pc-use-piece*
+      (put-piece *default-pc-piece*
                  (rand-nth pc-possible-grids-pos)
-                 border
-                 phaser-border))))
-
-(defn show-possible-grid-on-pborder [border phaser-border]
-  (let [player-possible-grids-pos
+                 game))))
+
+(defn show-possible-grid-on-pborder [game]
+  (let [border
+        (.-border game)
+        phaser-border
+        (.-phaserBorder game)
+        visible-possible-grids-pos
+        (.-visiblePossibleGridsPos game)
+        player-possible-grids-pos
         (rcore/find-putable-empty-grids
-         *default-player-use-piece* border)]
+         *default-player-piece* border)]
     (if-not (empty? player-possible-grids-pos)
       (do
-        (swap! *visible-possible-grids-pos* concat
-               player-possible-grids-pos)
+        (set! (.-visiblePossibleGridsPos game)
+              (concat visible-possible-grids-pos
+                      player-possible-grids-pos))
         (doseq [pg-pos player-possible-grids-pos]
           (set! (.-visible ((rcore/gridth pg-pos phaser-border)
                             "possible-grid"))
                 true))
         player-possible-grids-pos)
-      (pc-ai-put-piece border phaser-border))))
+      (pc-ai-put-piece game))))

 (defn on-click-possible-grid [pgrid]
-  (put-piece *default-player-use-piece*
-             (.-gridPosition pgrid)
-             @*border*
-             @*phaser-border*)
-  (pc-ai-put-piece @*border* @*phaser-border*)
-  (let [no-put-piece-ai-and-player?
-        (nil? (show-possible-grid-on-pborder @*border* @*phaser-border*))]
-    (when (or (rcore/end-game? @*border*) no-put-piece-ai-and-player?)
-      (let [winner (rcore/who-win? @*border*)]
-        (if (= winner *default-player-use-piece*)
-          (js/alert "you are winner!")
-          (js/alert "you are loser!")))))
-  (let [result-count (rcore/grid-count @*border*)]
-    (set! (.-text (.-pieceCountText *game*))
-          (str "black-piece: " (result-count rcore/*black-piece*)
-               "\nwhite-piece: " (result-count rcore/*white-piece*)
-               ))))
+  (let [game (.-game pgrid)
+        border (.-border game)
+        phaser-border (.-phaserBorder game)
+        default-player-piece (.-defaultPlayerPiece game)
+        default-pc-piece (.-defaultPcPiece game)]
+    (put-piece default-player-piece
+               (.-gridPosition pgrid)
+               game)
+    (pc-ai-put-piece game)
+    (let [no-put-piece-ai-and-player?
+          (nil? (show-possible-grid-on-pborder game))]
+      (when (or (rcore/end-game? border) no-put-piece-ai-and-player?)
+        (let [winner (rcore/who-win? border)]
+          (if (= winner default-player-piece)
+            (js/alert "you are winner!")
+            (js/alert "you are loser!")))))
+    (let [result-count (rcore/grid-count border)]
+      (set! (.-text (.-pieceCountText game))
+            (str "black-piece: " (result-count rcore/*black-piece*)
+                 "\nwhite-piece: " (result-count rcore/*white-piece*))))))

 (defn create-pieces [piece-name game]
   (let [piece-color (grid-name->rcore-grid piece-name)]
     (dotimes [y 8]
       (dotimes [x 8]
-        (let [piece
-              (.sprite (.-add game) (+ 5 (* x 75)) (+ 5 (* y 75)) piece-name)]
+        (let [phaser-border (.-phaserBorder game)
+              phaser-pos
+              (grid-pos->phaser-pos [x y])
+              piece
+              (.sprite (.-add game) (first phaser-pos) (second phaser-pos) piece-name)]
           (set! (.-visible piece) false)
           (set! (.-gridPosition piece) [x y])
           (set! (.-gridColor piece) piece-color)
-          (swap! *phaser-border* assoc-in [y x piece-name] piece))))))
+          (set! (.-phaserBorder game)
+                (assoc-in phaser-border [y x piece-name] piece)))))))

 (defn create-possible-grids [grid-name game]
   (dotimes [y 8]
     (dotimes [x 8]
-      (let [pgrid
+      (let [phaser-border (.-phaserBorder game)
+            pgrid
             (.sprite (.-add game) (+ 5 (* x 75)) (+ 5 (* y 75)) grid-name)]
         (set! (.-inputEnabled pgrid) true)
         (.add (.-onInputDown (.-events pgrid)) on-click-possible-grid game)
         (set! (.-visible pgrid) false)
         (set! (.-gridPosition pgrid) [x y])
-        (set! (.-gridColor pgrid) 3)
+        (set! (.-gridColor pgrid) rcore/*possible-grid*)
         (set! (.-useHandCursor (.-input pgrid)) true)
-        (swap! *phaser-border* assoc-in [y x grid-name] pgrid)))))
-
-(defn init-border []
-  (set! (.-visible ((rcore/gridth [3 3] @*phaser-border*) "black-piece")) true)
-  (set! (.-visible ((rcore/gridth [4 4] @*phaser-border*) "black-piece")) true)
-  (set! (.-visible ((rcore/gridth [4 3] @*phaser-border*) "white-piece")) true)
-  (set! (.-visible ((rcore/gridth [3 4] @*phaser-border*) "white-piece")) true)
-  (set! (.-visible ((rcore/gridth [3 4] @*phaser-border*) "white-piece")) true)
-  (set! (.-visible ((rcore/gridth [4 2] @*phaser-border*) "possible-grid")) true)
-  (set! (.-visible ((rcore/gridth [3 5] @*phaser-border*) "possible-grid")) true)
-  (set! (.-visible ((rcore/gridth [5 3] @*phaser-border*) "possible-grid")) true)
-  (set! (.-visible ((rcore/gridth [2 4] @*phaser-border*) "possible-grid")) true)
-  (swap! *visible-possible-grids-pos* conj [4 2])
-  (swap! *visible-possible-grids-pos* conj [3 5])
-  (swap! *visible-possible-grids-pos* conj [5 3])
-  (swap! *visible-possible-grids-pos* conj [2 4]))
+        (set! (.-phaserBorder game)
+              (assoc-in phaser-border [y x grid-name] pgrid))))))
+
+;; (defn game-loop []
+;;   (js/alert "wiwi"))
+
+(defn init-border [game]
+  (let [phaser-border (.-phaserBorder game)]
+    (set! (.-visible ((rcore/gridth [3 3] phaser-border) "black-piece")) true)
+    (set! (.-visible ((rcore/gridth [4 4] phaser-border) "black-piece")) true)
+    (set! (.-visible ((rcore/gridth [4 3] phaser-border) "white-piece")) true)
+    (set! (.-visible ((rcore/gridth [3 4] phaser-border) "white-piece")) true)
+    (set! (.-visible ((rcore/gridth [3 4] phaser-border) "white-piece")) true)
+    (set! (.-visible ((rcore/gridth [4 2] phaser-border) "possible-grid")) true)
+    (set! (.-visible ((rcore/gridth [3 5] phaser-border) "possible-grid")) true)
+    (set! (.-visible ((rcore/gridth [5 3] phaser-border) "possible-grid")) true)
+    (set! (.-visible ((rcore/gridth [2 4] phaser-border) "possible-grid")) true)
+    (doseq [pos [ [4 2] [3 5] [5 3] [2 4] ]]
+      (let [visible-possible-grids-pos (.-visiblePossibleGridsPos game)]
+        (set! (.-visiblePossibleGridsPos game)
+              (conj visible-possible-grids-pos pos))))))

 (defn create-all-pieces [white-name black-name game]
   (doseq [piece-name [white-name black-name]]
@@ -147,19 +184,41 @@
         style (clj->js { :font "35px Arial" :fill "#000000" :align "left" })]
     (set! (.-pieceCountText game) (.text (.-add game) 615 20 text style))))

-(defn ^export restart [game]
-  (reset! *border* rcore/*default-border*)
-  (reset! *phaser-border* [[] [] [] [] [] [] [] []])
-  (reset! *visible-possible-grids-pos* '())
-  (.start (.-state game) "main"))
-
 (defn create-buttons [game]
   (let [restart-button
         (.sprite (.-add game) 675 515 "restart-button")]
     (set! (.-inputEnabled restart-button) true)
     (set! (.-useHandCursor (.-input restart-button)) true)
     (.add (.-onInputDown (.-events restart-button))
-          (fn [b] (restart game)) game)))
+          (fn [b] (.restartGame game game)) game)
+    (set! (.-restartButton game) restart-button)))
+
+(def ^:dynamic *assets-table*
+                                        ;name    path
+  [["border"         "assets/reversi-border.png"]
+   ["white-piece"    "assets/white-piece.png"]
+   ["black-piece"    "assets/black-piece.png"]
+   ["possible-grid"  "assets/gray-grid.png"]
+   ["restart-button" "assets/restart-button.png"]])
+
+(defn preload [game]
+  (let [loader (.-load game)]
+    (doseq [pair *assets-table*]
+      (let [name (first pair)
+            path (second pair)]
+        (.image loader name path)))))
+
+;; (defn update [game]
+;;   )
+
+;; (defn render [game])
+
+(defn init-reversi []
+  (set! (.-border *game*) *border*)
+  (set! (.-phaserBorder *game*) *phaser-border*)
+  (set! (.-visiblePossibleGridsPos *game*) *visible-possible-grids-pos*)
+  (set! (.-defaultPlayerPiece *game*) *default-player-piece*)
+  (set! (.-defaultPcPiece *game*) *default-pc-piece*))

 (defn create [game]
   (set! (.-backgroundColor (.-stage game)) "#ffffff")
@@ -168,25 +227,16 @@
   (create-all-pieces "white-piece" "black-piece" game)
   (create-text game)
   (create-buttons game)
-  (init-border))
-
-(defn preload [game]
-  (let [loader (.-load game)]
-    (.image loader "border" "assets/reversi-border.png")
-    (.image loader "white-piece" "assets/white-piece.png")
-    (.image loader "black-piece" "assets/black-piece.png")
-    (.image loader "possible-grid" "assets/gray-grid.png")
-    (.image loader "restart-button" "assets/restart-button.png")))
-
-;; (defn update [game]
-;;   )
+  (init-border game))

 (defn ^export start [game]
-  (.add (.-state game) "main"
-        (clj->js {:preload preload
-                  :create create
-                  ;; :update update
-                  }))
-  (.start (.-state game) "main"))
+  (init-reversi)
+    (.add (.-state game) "main"
+          (clj->js {:preload preload
+                    :create create
+                    ;; :update update
+                    }))
+    (.start (.-state game) "main"))
+(set! (.-restartGame *game*) start)

 (start *game*)


renaming

renaming

--- src/cljs/triboard/ai/ai.cljs
+++ src/cljs/triboard/ai/ai.cljs
@@ -12,20 +12,20 @@
 ;; -----------------------------------------

 (defprotocol AIStrategy
-  (summarize-score [this scores] "Extract data from the score to compare")
+  (optimized-score [this scores] "Extract data from the score to compare")
   (maximizing-turn? [this turn] "Indicates whether we are in min or max"))

 (defn- make-ai
   [player]
   (reify AIStrategy
-    (summarize-score [_ scores] (get scores player))
+    (optimized-score [_ scores] (get scores player))
     (maximizing-turn? [_ turn] (= (:player turn) player))
     ))

 (defn- make-cheating-ai
   [player]
   (reify AIStrategy
-    (summarize-score [_ scores] (+ (:red scores) (:green scores)))
+    (optimized-score [_ scores] (+ (:red scores) (:green scores)))
     (maximizing-turn? [_ turn] (not= (:player turn) :blue))
     ))

@@ -50,7 +50,7 @@
   [ai {:keys [scores] :as turn}]
   (min-max-step ai turn
     (fn look-ahead [_ transition]
-      (summarize-score ai (reduce scores/update-scores scores transition))
+      (optimized-score ai (reduce scores/update-scores scores transition))
       )))

 (defn- tree-score


Fix broken "next quest"

Fix broken "next quest"

--- src/braid/quests/events.cljs
+++ src/braid/quests/events.cljs
@@ -37,7 +37,7 @@
       {:websocket-send
        (list [:braid.server.quests/upsert-quest-record
               (helpers/get-quest-record state quest-record-id)])
-       :dispatch [:activate-next-quest]})))
+       :dispatch [:quests/activate-next-quest]})))

 (reg-event-fx
   :quests/increment-quest


Add resolve- fn that will resolve all refs in passed piece of ctx.

* Does not handle circular references.

--- src/isla/interpreter.clj
+++ src/isla/interpreter.clj
@@ -88,6 +88,26 @@

 (defn lookup-ref [ref env]
   (lookup (get (:ctx env) ref) env))
+;; does not handle circular references
+(defmulti resolve- (fn [ast env] (class ast)))
+
+(defmethod resolve- :default [thing env] thing)
+
+;; (defmethod resolve- clojure.lang.PersistentVector [vec- env]
+;;   (if (> (count vec-) 0)
+;;     (let []
+;;       (pprint vec-)
+;;       (utils/thr "Time to fill out lookup for arrays")))
+;;   vec-)
+
+(defmethod resolve- java.util.Map [ast env]
+  (if (contains? ast :ref)
+    (resolve- (get (:ctx env) (:ref ast)) env) ;; resolve and dive down
+    (reduce (fn [hash el] ;; just dive down
+              (merge hash el)) ast
+              (map (fn [e] {(get e 0) (resolve- (get e 1) env)}) ast))))
+
+

 (defn lookup [identifier env]
   (if (contains? identifier :ref)


Thread for each participant

Thread for each participant

--- src/rpi_challenger/core.clj
+++ src/rpi_challenger/core.clj
@@ -7,18 +7,14 @@
             [rpi-challenger.challenges :as c]
             [rpi-challenger.rating :as rating]
             [rpi-challenger.io :as io])
-  (:import [org.slf4j LoggerFactory]))
+  (:import [org.slf4j LoggerFactory]
+           [java.util.concurrent Executors]))

-;(defonce thread-pool (java.util.concurrent.Executors/newCachedThreadPool))
+(defonce thread-pool (Executors/newCachedThreadPool))

 (def ^:dynamic logger (LoggerFactory/getLogger (str (ns-name *ns*))))

 (defonce tournament (ref (t/make-tournament)))
-
-(defn register
-  [name url]
-  (dosync
-    (alter tournament t/register-participant (p/make-participant name url))))

 (defn get-participants
   []
@@ -79,5 +75,18 @@
   (dosync
     (alter tournament t/finish-current-round)))

+(defn make-poller
+  [participant]
+  #(while (not (Thread/interrupted))
+     ;(println "poll" participant) ; TODO
+     (Thread/sleep 1000)))
+
+(defn register
+  [name url]
+  (let [participant (p/make-participant name url)]
+    (dosync
+      (alter tournament t/register-participant participant))
+    (.execute thread-pool (make-poller participant))))
+
 ; TODO: remove this dummy data
 (register "Hello World Dummy", "http://localhost:8080/hello-world")


fix(user plugins): NPE fix when no user plugin folder + better trace on kbd cleanup

--- ccw.core/src/clj/ccw/core/user_plugins.clj
+++ ccw.core/src/clj/ccw/core/user_plugins.clj
@@ -16,7 +16,7 @@
         to-remove (remove #(= load-key
                               (get (m/transient-data %) "ccw/load-key"))
                           cmds)
-        _ (t/format :user-plugins "to-remove: %s" to-remove)
+        _ (t/format :user-plugins "to-remove: %s" (seq to-remove))
         app-cmds (application-type-elements app)]
     (doseq [c (doall to-remove)] ; prevents ConcurrentModificationExceptions in .remove
       (t/format :user-plugins "user-plugins gc, element to remove: %s" c)
@@ -94,13 +94,16 @@
         (.listFiles (io/file d))))

 (defn user-plugins [d]
-  (if (and d (plugin-folder? d))
-    (if-not (f/exists? (io/file d "skip"))
-      [d]
-      [])
-    (mapcat user-plugins
-            (filter f/directory?
-                    (.listFiles (io/file d))))))
+  (cond
+    (not d)
+      []
+    (plugin-folder? d)
+      (if-not (f/exists? (io/file d "skip"))
+        [d]
+        [])
+    :else
+      (mapcat user-plugins
+        (filter f/directory? (.listFiles (io/file d))))))

 (defn load-user-script [f]
   (try
@@ -144,7 +147,7 @@
   skipped-plugin is a plugin with the same id as plugin, which has been loaded first.
   Do not call directly, it does not manage eclipse model cleanup."
   [user-plugins]
-  (loop [user-plugins (next user-plugins), seen-plugins-names #{}, seen-plugins #{}, skipped-plugins []]
+  (loop [user-plugins (seq user-plugins), seen-plugins-names #{}, seen-plugins #{}, skipped-plugins []]
     (if-not user-plugins
       skipped-plugins
       (let [p (first user-plugins)


typo fix

typo fix

--- src/leiningen/new/onyx_app/src/onyx_app/jobs/meetup_job.clj
+++ src/leiningen/new/onyx_app/src/onyx_app/jobs/meetup_job.clj
@@ -15,7 +15,7 @@
   "Build up the base job that will be shared in every environment configuration.
   Here you will build the workflow. Also build catalog entries, flow conditions,
   and lifecycles that apply to your business logic. The idea is to keep this
-  clean of enviornment specific settings."
+  clean of environment specific settings."
   [{:keys [batch-size batch-timeout] :as opts}]
   (-> {:workflow [[:read-lines  :extract-meetup-info]
                   [:extract-meetup-info :prepare-rows]
@@ -27,9 +27,9 @@
                                        :onyx/batch-timeout batch-timeout}))))

 (defn configure-job
-  "Configures the job to use either the :dev or :prod enviornments.
+  "Configures the job to use either the :dev or :prod environments.
   This is where you will typically switch out your input/output plugins
-  or enviornment specific settings like pinned tasks."
+  or environment specific settings like pinned tasks."
   [job mode {:keys [batch-size] :as opts}]
   (cond-> job
     (= :dev mode) (add-task (core-async-task/output-task :write-lines {:onyx/batch-size batch-size}))


use the ch-id passed to open

use the ch-id passed to open

--- src/pc/http/sente.clj
+++ src/pc/http/sente.clj
@@ -1182,7 +1182,7 @@

 (defn convert-to-sente-format [msg]
   (assoc msg
-         :client-id (user-id-fn (:tal/ring-req msg))
+         :client-id (:tal/ch-id msg)
          :ring-req (:tal/ring-req msg)
          :event [(:op msg) (:data msg)]
          :?data (:data msg)))


correct typo in trading route

correct typo in trading route

--- src/clj_money/web/server.clj
+++ src/clj_money/web/server.clj
@@ -95,7 +95,7 @@

   ; Trading
   (route GET "/accounts/:account-id/purchases/new" trading/new-purchase)
-  (route POST "/accounts:account-id/purchases" trading/purchase)
+  (route POST "/accounts/:account-id/purchases" trading/purchase)
   (route GET "/accounts/:account-id/sales/new" trading/new-sale)
   (route POST "/accounts/:account-id/sales" trading/sell)


optimize clojure.string/join

optimize clojure.string/join

--- src/cljs/clojure/string.cljs
+++ src/cljs/clojure/string.cljs
@@ -9,7 +9,7 @@
 (ns clojure.string
   (:refer-clojure :exclude [replace reverse])
   (:require [goog.string :as gstring])
-  (:import goog.string.StringBuffer))
+  (:import [goog.string StringBuffer]))

 (defn- seq-reverse
   [coll]
@@ -48,11 +48,22 @@

 (defn join
   "Returns a string of all elements in coll, as returned by (seq coll),
-   separated by an optional separator."
+  separated by an optional separator."
   ([coll]
-     (apply str coll))
+   (loop [sb (StringBuffer.) coll (seq coll)]
+     (if coll
+       (recur (. sb (append (str (first coll)))) (next coll))
+       (.toString sb))))
   ([separator coll]
-     (apply str (interpose separator coll))))
+   (loop [sb (StringBuffer.) coll (seq coll)]
+     (if coll
+       (do
+         (. sb (append (str (first coll))))
+         (let [coll (next coll)]
+           (when-not (nil? coll)
+             (. sb (append separator)))
+           (recur sb coll)))
+       (.toString sb)))))

 (defn upper-case
   "Converts string to all upper-case."


note to self

note to self

--- src/cljs/fuzz/om_slacky.cljs
+++ src/cljs/fuzz/om_slacky.cljs
@@ -22,3 +22,11 @@
       (when-let [msg (<! slacky-msg-chan)]
         (swap! app-state update-in [:messages] conj msg)
         (recur)))))
+
+
+
+
+
+
+
+;; Figwheel - look at atom, inject into it


code improvement

code improvement

--- src/cljs/netrunner/chat.cljs
+++ src/cljs/netrunner/chat.cljs
@@ -15,7 +15,8 @@
             messages (get-in @app-state [:channels ch])]
         (swap! app-state assoc-in [:channels ch] (conj messages msg)))))

-(defn send-msg [channel owner]
+(defn send-msg [event channel owner]
+  (.preventDefault event)
   (authenticated
    (fn [user]
      (let [input (om/get-node owner "msg-input")
@@ -29,10 +30,9 @@
 (defn msg-input-view [{:keys [channel]} owner]
   (om/component
    (sab/html
-    [:div.msg-box
-     [:input {:type "text" :ref "msg-input" :placeholder "Say something..."
-              :onKeyPress #(when (== (.-keyCode %) 13) (send-msg channel owner))}]
-     [:button {:on-click #(send-msg channel owner)} "Send"]])))
+    [:form.msg-box {:on-submit #(send-msg % channel owner)}
+     [:input {:type "text" :ref "msg-input" :placeholder "Say something..."}]
+     [:button "Send"]])))

 (defn channel-view [{:keys [channel active-channel]} owner]
   (reify


Remove assertions

Remove assertions

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -548,11 +548,6 @@

     (update! screen :renderer (stage))"
   [screen & args]
-  (assert (some? (:update-fn! screen)) "The first argument in update! must be
-the screen map.")
-  (assert (even? (count args)) "You need to give update! your screen followed by
-pairs of values, such as
-(update! screen :renderer (stage) :camera (orthographic)).")
   ((:update-fn! screen) assoc args))

 (defn run!
@@ -562,10 +557,6 @@
     (run! my-other-screen :on-show)
     (run! my-other-screen :on-change-color :color :blue)"
   [screen-object fn-name & options]
-  (assert (some? (:screen screen-object)) "The first argument in run! must be
-a defscreen object.")
-  (assert (keyword? fn-name) "The second argument in run! must be a keyword.")
-  (assert (even? (count options)) "Unexpected argument count in run!.")
   (let [execute-fn! (-> screen-object :screen deref :execute-fn!)
         screen-fn (-> screen-object :options (get fn-name))]
     (apply execute-fn! screen-fn options)


Make (end-notes) more succinct

Make (end-notes) more succinct

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -180,16 +180,10 @@
   (let [off-touch-ids (->> (filter-type "touchend" touches)
                            (map :touch-id)
                            set)
-        off-freqs (->> notes
-                       (filter (fn [n] (contains? off-touch-ids (n :touch-id))))
-                       (map :freq))]
+        note-off? (fn [n] (contains? off-touch-ids (n :touch-id)))]
     (-> instrument
-        (assoc :notes (map (fn [{touch-id :touch-id :as n}]
-                             (if (contains? off-touch-ids touch-id)
-                               (assoc n :off playhead)
-                               n))
-                           notes))
-        (->> (reduce-val->> stop-piano-key off-freqs)))))
+        (assoc :notes (map (fn [n] (if (note-off? n) (assoc n :off playhead) n)) notes))
+        (->> (reduce-val->> stop-piano-key (->> notes (filter note-off?) (map :freq)))))))

 (defn max-scroll-distance
   [touches instrument]


fix phone link

fix phone link

--- src-cljs/frontend/components/common.cljs
+++ src-cljs/frontend/components/common.cljs
@@ -214,5 +214,5 @@
           [:a {:href "https://twitter.com/circleci"} "Twitter"]
           [:a {:href "mailto:sayhi@circleci.com"} "Email"]
           [:a {:href "https://www.hipchat.com/gjwkHcrD5"} "Support Chat"]
-          [:a {:href ""} "Phone"]
+          [:a {:href "https://circleci.com/about#contact"} "Phone"]
           [:a {:href "https://goo.gl/maps/uhkLn"} "San Francisco, CA"]]]))


finished 2.47. can compute the decimal value of floating point number of any bit configuration

--- src/computer_systems/ch2.clj
+++ src/computer_systems/ch2.clj
@@ -12,7 +12,7 @@
   (loop [power 0
          rv    0]
     (if (= power (count bit-vector))
-     rv
+     (int rv)
      (recur
       ;power
       (+ power 1)
@@ -527,12 +527,14 @@
      (enumerate-bits (- n 1)))))

 ;Defaults bit counts for floats in this problem
-(def float-configuration {:s 1 :e 2 :f 2})
+(def float-configuration {:s 1 :e 4 :f 3})

 (defn grab-sign
   "Will grab the sign portion of a float bitstring"
   [bit-string]
-  ())
+  (if (= (first bit-string) 0)
+    1
+    -1))

 (defn grab-exponent
   "Will grab the exponent portion of a float bitstring"
@@ -569,3 +571,58 @@
         (if all-0s-fraction
           :infinity
           :nan)))))
+
+
+(defn bias-exponent [exp cat]
+  (let [bias (- (Math/pow 2 (-  (float-configuration :e) 1)) 1)]
+    (if (= cat :denormalized-values)
+      (- 1 bias)
+      (- exp bias))))
+
+(defn compute-significand [frac cat]
+  (if (= cat :denormalized-values)
+    frac
+    (+ 1 frac)))
+
+(defn compute-v [twoExM cat s]
+  (if (contains? #{:normalized-values :denormalized-values} cat)
+    (* s twoExM)
+    cat))
+
+
+
+(defn compute-float-table-row [bit-string]
+  (let
+      [cat    (get-float-category bit-string)
+       s      (grab-sign bit-string)
+       e      (bits-to-unsigned (grab-exponent bit-string))
+       E      (bias-exponent e cat)
+       twoE   (Math/pow 2 E)
+       f      (to-decimal {:type :binary :val  (str "0." (apply str (grab-fraction bit-string)))})
+       M      (compute-significand f cat)
+       twoExM (* twoE M)
+       V      (compute-v twoExM cat s)]
+   (assoc
+    {}
+    :vec   bit-string
+    :cat   cat
+    :s     s
+    :e     e
+    :E     E
+    :2E    twoE
+    :f     f
+    :M     M
+    :2ExM  twoExM
+    :V     V)))
+
+
+(defn complete-whole-float-table
+  [config]
+  (def float-configuration config)
+  (map
+   #(compute-float-table-row %1)
+   (enumerate-bits (+ (:s config) (:e config) (:f config)))))
+
+;(complete-whole-float-table {:s 1 :e 2 :f 2}) ;solves the problem!
+
+


Placeholder for #6.

Placeholder for #6.

--- src/leiningen/fregec.clj
+++ src/leiningen/fregec.clj
@@ -73,7 +73,10 @@
    :eval-in :subprocess})

 (defn fregec
-  "Compile Frege source files in :frege-source-path to :compile-path
+  "Compile Frege source files in :frege-source-paths to :compile-path
+
+Set :frege-compile-first in project.clj to specify a sequence of files
+that need to be compiled, in order, before the rest of the Frege source.

 Set :fregec-options in project.clj to pass options to the Frege compiler."
   [project]
@@ -84,7 +87,7 @@
                          project)
           srcs  (:frege-source-paths project)
           out   (:compile-path project)
-          files (stale-frege-sources srcs out)
+          files (stale-frege-sources srcs out (or (:frege-compile-first project) []))
           flags (flags-to-bits [:warnings :withcp :runjavac])
           cp    (cp/get-classpath project)
           form  (subprocess-form project


Prefer when to if in this case

Prefer when to if in this case

--- src/reply/hacks/complete.clj
+++ src/reply/hacks/complete.clj
@@ -5,6 +5,5 @@
   (try (let [val (resolve sym)]
     (when (class? val) val))
       (catch RuntimeException e
-        (if (= ClassNotFoundException (type (repl-exception e)))
-          nil
+        (when (not= ClassNotFoundException (class (repl-exception e)))
           (throw e)))))


CMR-3652 adds when for target for single instance identity

--- access-control-app/src/cmr/access_control/data/access_control_index.clj
+++ access-control-app/src/cmr/access_control/data/access_control_index.clj
@@ -325,28 +325,29 @@
         provider-id (acls/acl->provider-id acl)
         target (:target (or (:system-identity acl)
                             (:provider-identity acl)))
-        target-group-id (get-in acl [:single-instance-identity :target-id])]
+        target-group-id (when (= "GROUP_MANAGEMENT" (get-in acl [:single-instance-identity :target]))
+                          (get-in acl [:single-instance-identity :target-id]))]
     (merge
-      (access-value-elastic-doc-map acl)
-      (temporal-elastic-doc-map acl)
-      (entry-title-elastic-doc-map acl)
-      (identifier-applicable-elastic-doc-map acl)
-      (assoc (select-keys concept-map [:concept-id :revision-id])
-             :display-name display-name
-             :display-name.lowercase (str/lower-case display-name)
-             :identity-type (acl->identity-type acl)
-             :permitted-group permitted-groups
-             :permitted-group.lowercase (map str/lower-case permitted-groups)
-             :group-permission (map acl-group-permission->elastic-doc (:group-permissions acl))
-             :target target
-             :target.lowercase (util/safe-lowercase target)
-             :target-group-id target-group-id
-             :target-provider-id provider-id
-             :target-provider-id.lowercase (util/safe-lowercase provider-id)
-             :acl-gzip-b64 (util/string->gzip-base64 (:metadata concept-map))
-             :legacy-guid (:legacy-guid acl)
-             :legacy-guid.lowercase (when-let [legacy-guid (:legacy-guid acl)]
-                                      (str/lower-case legacy-guid))))))
+     (access-value-elastic-doc-map acl)
+     (temporal-elastic-doc-map acl)
+     (entry-title-elastic-doc-map acl)
+     (identifier-applicable-elastic-doc-map acl)
+     (assoc (select-keys concept-map [:concept-id :revision-id])
+            :display-name display-name
+            :display-name.lowercase (str/lower-case display-name)
+            :identity-type (acl->identity-type acl)
+            :permitted-group permitted-groups
+            :permitted-group.lowercase (map str/lower-case permitted-groups)
+            :group-permission (map acl-group-permission->elastic-doc (:group-permissions acl))
+            :target target
+            :target.lowercase (util/safe-lowercase target)
+            :target-group-id target-group-id
+            :target-provider-id provider-id
+            :target-provider-id.lowercase (util/safe-lowercase provider-id)
+            :acl-gzip-b64 (util/string->gzip-base64 (:metadata concept-map))
+            :legacy-guid (:legacy-guid acl)
+            :legacy-guid.lowercase (when-let [legacy-guid (:legacy-guid acl)]
+                                     (str/lower-case legacy-guid))))))

 (defn index-acl
   "Indexes ACL concept map. options is an optional map of options. Only :synchronous? is currently supported."


try out autocomplete on keyword

try out autocomplete on keyword

--- src/wb_es/mappings/core.clj
+++ src/wb_es/mappings/core.clj
@@ -19,7 +19,14 @@
                            :analyzer "keyword_ignore_case"}
                      :autocomplete {:type "string"
                                     :analyzer "autocomplete"
-                                    :search_analyzer "standard"}}
+                                    :search_analyzer "standard"}
+
+                     ;; autocomplete analyzer will handle gene name like unc-22 as phase search,
+                     ;; seeems sufficient for now, no need for autocomplete_keyword analyzer
+                     ;; :autocomplete_keyword {:type "string"
+                     ;;                        :analyzer "autocomplete_keyword"
+                     ;;                        :search_analyzer "keyword_ignore_case"}
+                     }
             }
     :other_names {:type "string"
                   :analyzer "keyword_ignore_case"}
@@ -49,6 +56,9 @@
                :analyzer {"autocomplete" {:type "custom"
                                           :tokenizer "standard"
                                           :filter ["lowercase" "autocomplete_filter"]}
+                          "autocomplete_keyword" {:type "custom"
+                                                  :tokenizer "keyword"
+                                                  :filter ["lowercase" "autocomplete_filter"]}
                           "keyword_ignore_case" {:type "custom"
                                                  :tokenizer "keyword"
                                                  :filter ["lowercase"]}}}}


Fix errors in recursive-descent parser.

Fix errors in recursive-descent parser.

--- src/smallex/parser/smlx.clj
+++ src/smallex/parser/smlx.clj
@@ -45,8 +45,8 @@
   (if (some #(contains? % (:value name-item)) (vals grammar))
     (throw (ex-info "Definition already exists." name-item))
     (let [[rem-seq expr] (end-paren parse-expr item-seq)
-          updated-grammar (assoc grammar (grammar-key definition-type)
-                                 (:value name-item) expr)]
+          updated-grammar (assoc-in grammar [(grammar-key definition-type)
+                                             (:value name-item)] expr)]
       [rem-seq updated-grammar])))

 (defn- parse-expr
@@ -57,7 +57,7 @@
   (cond (contains? #{:string :char-set :symbol} (:type head-item))
         [item-seq head-item]
         (= (:type head-item) :paren-start)
-        (end-paren parse-operation head-item item-seq)))
+        (end-paren parse-operation (first item-seq) (rest item-seq))))

 (defn- parse-operation
   "Parses an operation, which is some known operator along with several
@@ -77,7 +77,7 @@
   [[head :as item-seq] args]
   (should-exist head)
   (if (= (:type head) :paren-end)
-    [(rest item-seq) args]
+    [item-seq args]
     (let [[rem-seq expr] (parse-expr item-seq)]
       (recur rem-seq (conj args expr)))))


CMR-6499: Clean up code for readability

CMR-6499: Clean up code for readability

--- search-app/src/cmr/search/services/parameters/converters/shapefile.clj
+++ search-app/src/cmr/search/services/parameters/converters/shapefile.clj
@@ -138,22 +138,24 @@
   "Validate that the number of points in the features is greater than zero and less than the limit"
   [features]
   (let [point-count (features-point-count features)]
-    (if (= point-count 0)
-      "Shapefile has no points"
-      (when (> point-count (max-shapefile-points))
-        (format "Number of points in shapefile exceeds the limit of %d"
-          (max-shapefile-points))))))
+    (cond
+      (= point-count 0) "Shapefile has no points"
+      (> point-count (max-shapefile-points))
+          (format "Number of points in shapefile exceeds the limit of %d"
+            (max-shapefile-points))
+      :else nil)))

 (defn- validate-feature-count
   "Validates that the number of features is greater than zero and less than the limit"
   [features]
   (let [feature-count (count features)]
-    (if (= feature-count 0)
-      "Shapefile has no features"
-      (when (> feature-count (max-shapefile-features))
+    (cond
+      (= feature-count 0) "Shapefile has no features"
+      (> feature-count (max-shapefile-features))
         (format "Shapefile feature count [%d] exceeds the %d feature limit"
           feature-count
-          (max-shapefile-features))))))
+          (max-shapefile-features))
+      :else nil)))

 (defn validate-features
   "Validate this list of features in terms of shapefile limits"
@@ -183,13 +185,16 @@
   [features mime-type]
   (validate-features features)
   (let [iterator (.iterator features)]
+  ;; Loop overall all the Features in the list, building up a vector of conditions
     (loop [conditions []]
       (if (.hasNext iterator)
         (let [feature (.next iterator)
               [feature-conditions _] (feature->conditions feature (winding-opts mime-type))]
           (if (> (count feature-conditions) 0)
+            ;; if any conditions were created for the feature add them to the current conditions
             (recur (conj conditions (gc/or-conds feature-conditions)))
             (recur conditions)))
+        ;; no more Features in list - return conditions created
         conditions))))

 (defn error-if


cleanup

cleanup

--- src/sormilla/drone_comm.clj
+++ src/sormilla/drone_comm.clj
@@ -246,59 +246,3 @@
       (-> (.getData packet) log parse-navdata))
     (catch java.net.SocketTimeoutException e
       nil)))
-
-;;
-;; Testing:
-;;
-
-(comment
-
-(do
-  (println "prepare....")
-  (Thread/sleep 5000)
-  (println "go!....")
-  (logging/navdata-logging! true)
-  (Thread/sleep 500)
-  (enable-navdata)
-  (ctrl-ack)
-  (trim)
-  (Thread/sleep 500)
-  (println "takeoff")
-  (takeoff)
-  (Thread/sleep 8000)
-  (println "landing")
-  (land)
-  (Thread/sleep 4000)
-  (println "emerg")
-  (emergency)
-  (Thread/sleep 500)
-  (println "bye")
-  (logging/navdata-logging! false))
-
-(require '[clojure.java.io :as io])
-(require '[clojure.string :as s])
-
-(defn line->navdata [line]
-  (let [[timestamp & data] (s/split line #" ")]
-    (when (and timestamp data)
-      [(Long/valueOf timestamp 16)
-       (parse-navdata (byte-array (map (fn [v] (ubyte (Integer/valueOf v 16))) data)))])))
-
-(defn state-changes [states [timestamp {new-state :control-state}]]
-  (if (= new-state (second (first states)))
-    states
-    (cons [timestamp new-state] states)))
-
-(def states (with-open [i (io/reader (io/file "navdata.log"))]
-              (reverse (reduce state-changes [] (map line->navdata (line-seq i))))))
-
-states
-
-[1377247353528 :landed]
-[1377247357171 :trans-gotofix]
-[1377247363344 :hovering]
-[1377247365165 :trans-looping]
-[1377247366075 :landed]
-
-)
-


Use when-not instead of single branch if-not and do

--- src/day8/re_frame/trace.cljs
+++ src/day8/re_frame/trace.cljs
@@ -148,19 +148,18 @@

 (defn add-filter [filter-items filter-input filter-type]
   ;; prevent duplicate filter strings
-  (if-not (some #(= filter-input (:query %)) @filter-items)
-    (do
-      ;; if existing, remove prior filter for :slower-than
-      (when (and (= :slower-than filter-type)
-                 (some #(= filter-type (:filter-type %)) @filter-items))
-        (swap! filter-items (fn [item]
-                              (remove #(= :slower-than (:filter-type %)) item))))
-      ;; add new filter
-      (swap! filter-items conj {:id (random-uuid)
-                                :query (if (= filter-type :contains)
-                                         (str/lower-case filter-input)
-                                         (js/parseFloat filter-input))
-                                :filter-type filter-type}))))
+  (when-not (some #(= filter-input (:query %)) @filter-items)
+    ;; if existing, remove prior filter for :slower-than
+    (when (and (= :slower-than filter-type)
+               (some #(= filter-type (:filter-type %)) @filter-items))
+      (swap! filter-items (fn [item]
+                            (remove #(= :slower-than (:filter-type %)) item))))
+    ;; add new filter
+    (swap! filter-items conj {:id          (random-uuid)
+                              :query       (if (= filter-type :contains)
+                                             (str/lower-case filter-input)
+                                             (js/parseFloat filter-input))
+                              :filter-type filter-type})))

 (defn render-traces [showing-traces filter-items filter-input trace-detail-expansions]
   (doall


Mihir | Making it return an object

Mihir | Making it return an object

--- src/aggregatequeryservice/runqueries.clj
+++ src/aggregatequeryservice/runqueries.clj
@@ -4,7 +4,7 @@
   (:use aggregatequeryservice.utils)
   (:gen-class
   :name aggregatequeryservice.runqueries
-  :methods [#^{:static true} [AQS [String javax.sql.DataSource java.util.HashMap] java.util.List]]))
+  :methods [#^{:static true} [AQS [String javax.sql.DataSource java.util.HashMap] Object]]))

 (defn get-queries
   "Appends query group name to every query object"


Attribution

Attribution

--- examples/simple/assets/cljs/frontend/core.cljs
+++ examples/simple/assets/cljs/frontend/core.cljs
@@ -2,7 +2,7 @@
   (:require [reagent.core :as reagent]
             [re-frame.core :as rf]))

-;; A detailed walk-through of this source code is provied in the docs:
+;; This example is from the re-frame documentation. For more info, see:
 ;; https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md

 ;; -- Domino 1 - Event Dispatch -----------------------------------------------


test that "reified IFn can be used as a job"

--- test/unit/core.clj
+++ test/unit/core.clj
@@ -244,6 +244,23 @@
           #"Assert failed: \(nil\? \(namespace"
           (b/schedule jdbc-conn #'j/job-with-namespaced-queue)))))

+(def ^{::b/queue :test-queue} ifn-job
+  (reify clojure.lang.IFn
+    (applyTo
+      [_ [ctx data]]
+      (insert-aux-data! (:jdbc-conn ctx) data))))
+
+(defdbtest
+  "reified IFn can be used as a job"
+  (with-open [jdbc-conn (.getConnection ds)]
+    (let [expected-aux-data "ifn-job data"]
+      ; act
+      (b/schedule jdbc-conn #'ifn-job expected-aux-data)
+
+      ; assert
+      (is (ack-done? (b/work-once jdbc-conn)))
+      (is-aux-data-committed jdbc-conn expected-aux-data))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; several queues ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (defdbtest
   "schedule and independently process three jobs off different queues"


A bit of refactoring.

A bit of refactoring.


Add subtype polymorphism examples

Add subtype polymorphism examples

--- src/clojure_walkthrough/cjia/ch04_xx.clj
+++ src/clojure_walkthrough/cjia/ch04_xx.clj
@@ -39,3 +39,31 @@

 ;; Now let's give it another go
 (open-ad-hoc-type-namer {}) ;; "map"
+
+;; 4.1.3: subtype polymophism
+
+; first attempt with ad hoc polymorphism
+(defn map-type-namer [thing]
+  (condp = (type thing)
+    clojure.lang.PersistentArrayMap "map"
+    clojure.lang.PersistentHashMap  "map"))
+
+(map-type-namer (hash-map))  ;; "map"
+
+;; Note the duplicate implementation
+(map-type-namer (array-map)) ;; "map"
+
+;; let try with different kind of map
+(map-type-namer (sorted-map)) ;; => throw IllegalArgumentException: No matchng clause:
+
+;; Let's fix that
+(defn subtype-map-type-namer [thing]
+  (cond
+    (instance? clojure.lang.APersistentMap thing) "map" ;; Note: APersistentMap is Java superclass of all maplike things in Clojure
+    :else (throw (IllegalArgumentException.
+                  (str "No implementation found for ") (type thing)))))
+
+;; Now works for anything maplike!
+(subtype-map-type-namer (hash-map))   ;; "map"
+(subtype-map-type-namer (array-map))  ;; "map"
+(subtype-map-type-namer (sorted-map)) ;; "map"


Created atom-generators and worked on defining input instructions.

--- src/clojush/examples/bioavailability.clj
+++ src/clojush/examples/bioavailability.clj
@@ -31,11 +31,13 @@
   (:use [clojush.pushgp.pushgp]
         [clojush.pushstate]
         [clojush.interpreter]
+        [clojush.random]
         [local-file])
   (:require [clojure.string :as string]
             [clojure-csv.core :as csv]))

 (defn read-data []
+  "Reads data from data/bioavailability.txt into a sequence of sequences."
   (let [f (slurp* "src/clojush/examples/data/bioavailability.txt")
         lines (csv/parse-csv f :delimiter \tab)]
     (map #(map (fn [x] (float (read-string x)))
@@ -51,18 +53,48 @@
 ;(def test-cases-shuffled
 ;  (shuffle (read-data)))

-
 (defn define-test-cases
+  "Returns a map with two keys: train and test. Train maps to a
+   subset of 251 random test cases (70%), and test maps to the
+   remaining 108 test cases (30%). These sets are different each
+   time this is called."
   []
   (let [test-cases-shuffled (shuffle (read-data))
         train-num 251]
     {:train (subvec test-cases-shuffled 0 train-num)
      :test (subvec test-cases-shuffled train-num)}))

+;(count (:test (define-test-cases)))

-(count (:test (define-test-cases)))
+
+;(run-push '(4 5 integer_add yyy6) (make-push-state))
+
+
+;(define-registered (symbol (str "x" (+ 4 2))) (fn [state] (push-item 2999 :integer state)))
+
+;(doseq [a (map #(symbol (str "x" %)) (range 241))]
+;  (define-registered a (fn [state] (push-item 2999 :integer state))))
+
+
+;(sort (map str (vec @registered-instructions)))
+
+
+;; I want x0 through x240 to be instructions that, when executed, push
+;; the float from that column onto the float stack.
+
+
+;; This definition of atom-generators makes it so that choosing a terminal
+;; has equivalent probability of choosing one of the operators. This is
+;; the method used in the paper above.
+(def bioavailability-atom-generators
+  (list
+    (fn [] (lrand-nth (list 'integer_div 'integer_mult 'integer_add 'integer_sub)))
+    (fn [] (lrand-nth (for [n (range 241)]
+                        (symbol (str "x" n)))))
+    ))
+
+;; Test random code generation
+;(random-code 100 bioavailability-atom-generators)

-
-


Removed some errant code.

Removed some errant code.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1062,7 +1062,7 @@
                            (some #{errors} [(:errors parent1) (:errors parent2)]))
         make-child-genome (fn [g1 g2]
                             (produce-child-genome-by-autoconstruction g1 g2 argmap))
-        diff #(expressed-difference %1 %2 argmap) ;(assoc i :program (translate-plush-genome-to-push-program i argmap))
+        diff #(expressed-difference %1 %2 argmap)
         genome-error #(do (swap! evaluations-count inc)
                           (:errors (error-function
                                     {:genome %


Allow collection of rates for uniform-deletion-rate.

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -325,8 +325,11 @@
   "Returns the individual with each element of its genome possibly deleted, with probability
 given by uniform-deletion-rate."
   [ind {:keys [uniform-deletion-rate maintain-ancestors]}]
-  (let [new-genome (vec (filter identity
-                                (map #(if (< (lrand) uniform-deletion-rate) nil %)
+  (let [rate (if (number? uniform-deletion-rate)
+               uniform-deletion-rate
+               (lrand-nth uniform-deletion-rate))
+        new-genome (vec (filter identity
+                                (map #(if (< (lrand) rate) nil %)
                                      (:genome ind))))]
     (make-individual :genome new-genome
                      :history (:history ind)


CMR-3551: Addressed the last PR comments.

--- ingest-app/src/cmr/ingest/services/humanizer_alias_cache.clj
+++ ingest-app/src/cmr/ingest/services/humanizer_alias_cache.clj
@@ -51,17 +51,20 @@
    Note: if the shortname of a platform alias already exists in the collection's platforms, this
    alias won't be added to the platform-aliases."
   [platforms plat-sn-key plat-alias-map]
-  (let [platform-shortnames (map plat-sn-key platforms)
+  (let [platform-shortnames-set (set (map plat-sn-key platforms))
         platform-aliases (for [coll-plat platforms
                                :let [coll-plat-sn (get coll-plat plat-sn-key)
-                                     aliases (get plat-alias-map (str/upper-case coll-plat-sn))]
-                               alias (set/difference (set aliases) (set platform-shortnames))]
+                                     aliases-set (set (get plat-alias-map (str/upper-case coll-plat-sn)))]
+                               alias (set/difference aliases-set platform-shortnames-set)]
                            (assoc coll-plat plat-sn-key alias))]
     platform-aliases))

 (defn update-collection-with-aliases
   "Returns the collection with all the platform aliases added.
-   Given plat-alias-map being {\"TERRA\" [\"AM-1\" \"am-1\"]}
+   Given plat-alias-map being {\"TERRA\" [\"AM-1\" \"am-1\"]},
+   which indicates AM-1 and am-1 are aliases of TERRA. That means that granules referring to
+   a collection through AM-1 or am-1 would be permitted if the collection had TERRA.
+   Here is one example:
    Original collection platforms: [{:ShortName \"Terra\" :Otherfields \"other-terra-values\"}
                                    {:ShortName \"AM-1\" :Otherfields \"other-am-1-values\"}]
    updated collection platforms: [{:ShortName \"Terra\" :Otherfields \"other-terra-values\"}


tidy up

tidy up

--- src/quoridor/core.clj
+++ src/quoridor/core.clj
@@ -69,19 +69,12 @@
 (defn- allowed-pawn-move?
   [state move]
   (let [current-position (state (keyword (state :current)))
-        other-position (if (= (state :current) "black") (state :white) (state :black))
-        col (first current-position)
-        row (to-digit (second current-position))
-        up-move (str col (+ row 1))
-        down-move (str col (- row 1))
-        left-move (str (-> col int (- 1) char) row)
-        right-move (str (-> col int (+ 1) char) row)
-        jump-move (jump state)]
-    (and (contains? (set (filter valid-move? [up-move
-                                              down-move
-                                              left-move
-                                              right-move
-                                              jump-move]))
+        other-position (if (= (state :current) "black") (state :white) (state :black))]
+    (and (contains? (set (filter valid-move? [(up current-position)
+                                              (down current-position)
+                                              (left current-position)
+                                              (right current-position)
+                                              (jump state)]))
                     move)
          (not (contains? (set [current-position other-position]) move)))))

@@ -124,6 +117,10 @@
   [state]
   (println (str "Congrats " (winner state) ", you won!")))

+(defn- quit-move?
+  [move]
+  (= move "q"))
+
 (defn -main
   [& args]
   (loop [current (first black-white)
@@ -136,7 +133,7 @@
           (let [move (s/trim (read-line))
                 next-player (first next)]
             (cond
-              (= move "q") (println "Thanks for playing!")
+              (quit-move? move) (println "Thanks for playing!")
               (allowed-wall-move? state move) (recur next-player
                                                      (rest next)
                                                      (-> state


simplify introspection resolver

simplify introspection resolver

--- src/graphql_clj/resolver.clj
+++ src/graphql_clj/resolver.clj
@@ -27,16 +27,19 @@
         mutation-root-name (str (get-in schema [:roots :mutation]))]
     (fn [type-name field-name]
       (get-in {query-root-name {"__schema" (fn [context parent args]
-                                             {:types        (introspection/schema-types schema)
-                                              :queryType    (root-type schema query-root-name)
-                                              :mutationType (root-type schema mutation-root-name)
-                                              :directives   []})
+                                             {})
                                 "__type" (fn [context parent args]
                                            (let [type-name (get args "name")
                                                  type (get-type-in-schema schema type-name)]
                                              (assert type (format "type is nil for type-name: %s." type-name))
                                              (introspection/type-resolver (assoc type :type-name type-name))))}
-               "__Schema" {"directives" (fn [context parent args]
+               "__Schema" {"types" (fn [context parent args]
+                                     (introspection/schema-types schema))
+                           "queryType" (fn [context  parent args]
+                                         (root-type schema query-root-name))
+                           "mutationType" (fn [context parent args]
+                                            (root-type schema mutation-root-name))
+                           "directives" (fn [context parent args]
                                           [])}
                "__Type" {"ofType" (fn [context parent args]
                                     (when-let [inner-type (:inner-type parent)]


Another tweaks of wording.

Another tweaks of wording.

--- src/re_demo/core.cljs
+++ src/re_demo/core.cljs
@@ -155,7 +155,7 @@
    :padding "10px 0px 10px 10px"
    :child   [alert-box
              :alert-type :danger
-             :heading    "Use Chrome Instead?"
+             :heading    "Only Tested On Chrome"
              :body       "re-com should work on all modern browsers, but there might be dragons!"]])

 ;; -- Routes, Local Storage and History ------------------------------------------------------


(maint) Split up code_id tests in general-puppet-int-test

The code-id tests were previously all in the same deftest, which didn't
really offer much benefit, as each testing call had to spin up its own
with-puppetserver-running. This commit breaks that deftest into four
deftests, so that they can more easily be run on their own.

--- test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
+++ test/integration/puppetlabs/general_puppet/general_puppet_int_test.clj
@@ -42,8 +42,8 @@
        (let [catalog (testutils/get-catalog)]
          (is (testutils/catalog-contains? catalog "Notify" "this command echoes a thing\n")))))))

-(deftest ^:integration code-id-request-test
-  (testing "code id is added to the request body for catalog requests"
+(deftest ^:integration code-id-request-test-get-catalog
+  (testing "code id is added to the request body for catalog requests via get"
     ; As we have set code-id-command to echo, the code id will
     ; be the result of running `echo $environment`, which will
     ; be production here.
@@ -54,8 +54,10 @@
           {:code-id-command (script-path "echo")
            :code-content-command (script-path "echo")}}
      (let [catalog (testutils/get-catalog)]
-       (is (= "production" (get catalog "code_id"))))))
-  (testing "code id is added to the request body for catalog requests"
+       (is (= "production" (get catalog "code_id")))))))
+
+(deftest ^:integration code-id-request-test-post-catalog
+  (testing "code id is added to the request body for catalog requests via post"
     ; As we have set code-id-command to echo, the code id will
     ; be the result of running `echo $environment`, which will
     ; be production here.
@@ -66,7 +68,9 @@
           {:code-id-command (script-path "echo")
            :code-content-command (script-path "echo")}}
      (let [catalog (testutils/post-catalog)]
-       (is (= "production" (get catalog "code_id"))))))
+       (is (= "production" (get catalog "code_id")))))))
+
+(deftest ^:integration code-id-request-test-non-zero-exit
     (testing "catalog request fails if code-id-command returns a non-zero exit code"
       ; As we have set code-id-command to warn, the code id will
       ; be the result of running `warn_echo_and_error $environment`, which will
@@ -83,7 +87,9 @@
                                 testutils/catalog-request-options)]
           (is (= 500 (:status catalog-response)))
           (is (re-find #"Non-zero exit code returned while running" (:body catalog-response)))
-          (is (logged? #"Executed an external process which logged to STDERR: production" :warn))))))
+          (is (logged? #"Executed an external process which logged to STDERR: production" :warn)))))))
+
+(deftest ^:integration code-id-request-test-no-environment
   (testing "code id is not added and 400 is returned if environment is not included in request"
     (logging/with-test-logging
      (bootstrap/with-puppetserver-running


Fixed a missing gobj/get

Fixed a missing gobj/get

--- src/future_app/ios/core.cljs
+++ src/future_app/ios/core.cljs
@@ -7,7 +7,7 @@

 (def ReactNative (js/require "react-native"))
 (def app-registry (gobj/get ReactNative "AppRegistry"))
-(def text (r/adapt-react-class (get ReactNative "Text")))
+(def text (r/adapt-react-class (gobj/get ReactNative "Text")))
 (def view (r/adapt-react-class (gobj/get ReactNative "View")))
 (def image (r/adapt-react-class (gobj/get ReactNative "Image")))
 (def touchable-highlight (r/adapt-react-class (gobj/get ReactNative "TouchableHighlight")))


Faster convolution function

Faster convolution function

--- src/neuhon/windowing.clj
+++ src/neuhon/windowing.clj
@@ -53,8 +53,7 @@
 (defn convolute
   "Applies the convolution between an input signal and a window"
   [signal window]
-  (let [convolution (fn [i] (* (nth signal i) (nth window i)))]
-    (map convolution (range (count window)))))
+    (map #(* %1 %2) signal window))

 (comment "A spectral window type for storing the window coefficients,
   as well of the left and right bounds of the window")
@@ -85,7 +84,10 @@
 (defn win-nth
   "Gets the spectral window corresponding to a given bin"
   [matrix n]
-  (Window. (nth (.coefs matrix) n) (nth (.lks matrix) n) (nth (.rks matrix) n)))
+  (Window.
+    (nth (.coefs matrix) n)
+    (nth (.lks matrix) n)
+    (nth (.rks matrix) n)))

 (defn get-Q-from-p
   "Computes the constant Q, based on an arbitrary parameter p"
@@ -95,12 +97,24 @@
 (defn win-left-bound
   "Left bound index of the spectral window that corresponds to fk"
   [Q fk N sampling-rate]
-  (double (Math/round (* (- 1 (/ (double Q) 2)) (/ (double (* fk N)) (double sampling-rate))))))
+  (double
+    (Math/round
+      (*
+        (- 1 (/ (double Q) 2))
+        (/
+          (double (* fk N))
+          (double sampling-rate))))))

 (defn win-right-bound
   "Right bound index of the spectral window that corresponds to fk"
   [Q fk N sampling-rate]
-  (double (Math/round (* (+ 1 (/ (double Q) 2)) (/ (double (* fk N)) (double sampling-rate))))))
+  (double
+    (Math/round
+      (*
+        (+ 1 (/ (double Q) 2))
+        (/
+          (double (* fk N))
+          (double sampling-rate))))))

 (defn cosine-win-element
   "Computes one coefficient of the cosine temporal window"


fix metric name

fix metric name

--- src/riemann/index.clj
+++ src/riemann/index.clj
@@ -98,7 +98,7 @@
       (events [this]
         (let [base {:state "ok" :time (unix-time)}]
           (map (partial merge base)
-               [{:service "riemann index event-count"
+               [{:service "riemann index size"
                  :metric (.size hm)}])))

       clojure.lang.Seqable


first key

first key

--- src/ophion/aggregate.clj
+++ src/ophion/aggregate.clj
@@ -138,7 +138,7 @@
 (defn mark
   [label]
   (let [field (mark-field label)
-        path (first field)]
+        path (first (keys field))]
     [{:$addFields field}
      {:$project
       {(str path "._history") false


remove uneeded :require

remove uneeded :require

--- src/metabase/driver/generic_sql/sync.clj
+++ src/metabase/driver/generic_sql/sync.clj
@@ -2,8 +2,7 @@
   "Generic implementations of `metabase.driver` `(sync-tables [db]) function that should work across any SQL database supported by Korma."
   (:require [clojure.java.jdbc :as jdbc]
             [clojure.math.numeric-tower :as math]
-            (clojure.tools [logging :as log]
-                           [macro :refer [macrolet]])
+            [clojure.tools.logging :as log]
             [korma.core :refer :all]
             [metabase.db :refer :all]
             [metabase.driver.generic-sql.util :refer :all]


Add protocol version to kernel info messages.

Bringing it up to match the protocol version 5.0 spec.

--- src/ipython_clojure/core.clj
+++ src/ipython_clojure/core.clj
@@ -9,6 +9,8 @@
   (:import [org.zeromq ZMQ])
   (:gen-class :main true))

+(def protocol-version "5.0")
+
 (defn prep-config [args]
   (-> args first slurp json/read-str walk/keywordize-keys))

@@ -32,10 +34,11 @@

 (defn kernel-info-header [message]
   (let [header (cheshire/generate-string {:msg_id (uuid)
+                                          :date (now)
                                           :username (get-in message [:header :username])
                                           :session (get-in message [:header :session])
                                           :msg_type "kernel_info_reply"
-                                          :version "5.0"})]
+                                          :version protocol-version})]
     header))

 (defn close-comm-header [message]
@@ -111,6 +114,7 @@

 (defn new-header [msg_type session-id]
   {:date (now)
+   :version protocol-version
    :msg_id (uuid)
    :username "kernel"
    :session session-id


throw entire error message on email post?

--- src/polismath/server.clj
+++ src/polismath/server.clj
@@ -256,13 +256,16 @@
 (defn send-email-notification-via-polis-api!
   [filename {:keys [zinvite email]}]
   (try
+    (comment (client/request))
     (let [response
           (client/post "https://pol.is/api/v3/sendEmailExportReady"
                        {:query-params {:webserver_username (:webserver-username env/env)
                                        :webserver_pass (:webserver-pass env/env)
                                        :email email
                                        :filename filename
-                                       :conversation_id zinvite}})]
+                                       :raise false
+                                       :conversation_id zinvite}
+                        :throw-entire-message? true})]
       (log/info "send email notification response:\n" (with-out-str (clojure.pprint/pprint response))))
     (catch Exception e
       (log/error e "failed to send email:\n"))))


renaming to local

renaming to local

--- test/celestial/test/config.clj
+++ test/celestial/test/config.clj
@@ -47,7 +47,7 @@
 (fact "docker sanity"
    (validate-conf (assoc-in local-prox [:hypervisor :dev :docker :nodes] nil)) =>
        {:hypervisor {:dev {:docker {:nodes '("must be present")}}}}
-   (validate-missing :hypervisor :dev :docker :nodes :local-docker :host) =>
-      {:hypervisor {:dev {:docker {:nodes '(({:local-docker {:host ("must be present")}}))}}}}
+   (validate-missing :hypervisor :dev :docker :nodes :local :host) =>
+      {:hypervisor {:dev {:docker {:nodes '(({:local {:host ("must be present")}}))}}}}
   )


code cleanup

code cleanup

--- src/selmer/parser.clj
+++ src/selmer/parser.clj
@@ -129,6 +129,16 @@
 ;; FunctionNode call-sites or TextNode content. open-tag? fn returns
 ;; true or false based on character lookahead to see if it's {{ or {%

+(defn to-node [tag content buf rdr]
+  (-> content
+    (conj (TextNode. (.toString buf)))
+    (conj (FunctionNode. (parse-tag tag rdr)))))
+
+(defn update-tags [tag tags content args buf]
+  (assoc tags tag
+         {:args args
+          :content (conj content (TextNode. (.toString buf)))}))
+
 (defn tag-content [rdr start-tag & end-tags]
   (let [buf (StringBuilder.)]
     (loop [ch       (read-char rdr)
@@ -141,16 +151,12 @@
         tags
         (open-tag? ch rdr)
         (let [{:keys [tag-name args] :as tag} (read-tag-info rdr)]
-          (if-let [open-tag (and tag-name (some #{tag-name} end-tags))]
-              (let [tags     (assoc tags cur-tag
-                                    {:args args
-                                     :content (conj content (TextNode. (.toString buf)))})
-                    end-tags (next (drop-while #(not= tag-name %) end-tags))]
+          (if-let [open-tag  (and tag-name (some #{tag-name} end-tags))]
+              (let [tags     (update-tags cur-tag tags content args buf)
+                    end-tags (next (drop-while #(not= tag-name %) end-tags))]
                 (.setLength buf 0)
                 (recur (if (empty? end-tags) nil (read-char rdr)) tags [] open-tag end-tags))
-              (let [content (-> content
-                              (conj (TextNode. (.toString buf)))
-                              (conj (FunctionNode. (parse-tag tag rdr))))]
+              (let [content (to-node tag content buf rdr)]
                 (.setLength buf 0)
                 (recur (read-char rdr) tags content cur-tag end-tags))))
         :else


fix repeat length

fix repeat length

--- src/semitone/core.clj
+++ src/semitone/core.clj
@@ -45,6 +45,7 @@
         (= (type length) clojure.lang.Ratio)
         (merge state {:key (if (< length 0) nil (:key state))
                       :length (Math/abs (* 4.0 length ppq))
+                      :repeat-length 0
                       :notes (rest notes)})
         (symbol? length)
         (if-let [m (re-matches #"(-|)((?:[xwhqistjlmno]\.*)+)" (name length))]
@@ -57,9 +58,10 @@
                                                    (- 2.0 (/ 1.0 (reduce * (repeat (count (get % 2)) 2))))
                                                    ppq)
                                                (re-seq #"\G([xwhqistjlmno])(\.*)" (get m 2))))
+                          :repeat-length 0
                           :notes (rest notes)}))
           (if-let [m (re-matches #"([-=])[-=]*" (name length))]
-            (merge state {:length (* (:length state) (count (name length)))
+            (merge state {:repeat-length (* (:length state) (count (name length)))
                           :key (if (= "=" (get m 1)) (:key state) nil)
                           :notes (rest notes)})
             state))
@@ -195,7 +197,8 @@
                       :param :octave
                       :cc-value 0
                       :tempo 120
-                      :length (.getResolution (.getSequence sequencer))}
+                      :length (.getResolution (.getSequence sequencer))
+                      :repeat-length 0}
                      (or state {}))]
     (loop [notes notes state state]
       (if (not (empty? notes))
@@ -244,12 +247,15 @@
                                                        (:channel state)
                                                        (:key state)
                                                        (:release state))
-                                                      (+ (:position state) (:length state) (:displacement state))))))
+                                                      (+ (:position state)
+                                                         (or (:repeat-length state) (:length state))
+                                                         (:displacement state))))))
                           :else nil)
                         state))]
                 (merge state {:position (if (vector? notes)
                                           (:position state)
-                                          (+ (:position state) (:length state)))}))
+                                          (+ (:position state)
+                                             (or (:repeat-length state) (:length state))))}))
               notes (:notes state)]
           (recur notes state))
         state))))


Add docstrings to as-field and as-table functions.

--- src/suricatta/dsl.clj
+++ src/suricatta/dsl.clj
@@ -202,12 +202,14 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn as-table
+  "Coerce querypart to table expression."
   [o & args]
   (defer
     (->> (map unwrap* args)
          (as-table* o))))

 (defn as-field
+  "Coerce querypart to field expression."
   [o & args]
   (defer
     (->> (map unwrap* args)


made aws footprint smaller

made aws footprint smaller

--- src/org/domaindrivenarchitecture/pallet/convention/managed_vm.clj
+++ src/org/domaindrivenarchitecture/pallet/convention/managed_vm.clj
@@ -11,7 +11,7 @@
 (def DdaVmConventionConfig
   "The convention configuration for managed vms crate."
   {:ide-user s/Keyword
-   :platform (s/enum :virtualbox :aws :other)})
+   :platform (s/enum :virtualbox :aws)})

 (defn default-vm-backup-config
   "Managed vm crate default configuration"
@@ -37,8 +37,7 @@
                                           :install-libreoffice :install-open-jdk-8}}
         (= platform :aws) {:tightvnc-server {:user-password "test"}
                            :settings #{:install-xfce-desktop :install-tightvnc-server
-                            :install-libreoffice :install-open-jdk-8 :install-linus-basics}}
-        (= platform :other) {:settings #{:install-libreoffice :install-open-jdk-8}}
+                            :install-open-jdk-8 :install-linus-basics}}
         )
       )
   )


Update the realm reset phrase.

Update the realm reset phrase.

Signed-off-by: Julien Eluard <c768e13f1ba4c3ebed2909a1fc1e4b50bb021a2f@gmail.com>

--- src/status_im/data_store/realm/core.cljs
+++ src/status_im/data_store/realm/core.cljs
@@ -60,7 +60,7 @@
   (open-realm (last schemas) file-name encryption-key))

 (defn reset-realm [file-name schemas encryption-key]
-  (utils/show-popup "Please note" "You must recover or create a new account with this upgrade. Also chatting with accounts in previous releases is incompatible")
+  (utils/show-popup "Important: Wallet Upgrade" "The Status Wallet will be upgraded in this release. The 12 mnemonic words will generate different addresses and whisper identities (public key). Given that we changed the algorithm used to generate keys and addresses, it will be impossible to re-import accounts created with the old algorithm in Status. Please create a new account.")
   (delete-realm file-name)
   (open-realm (last schemas) file-name encryption-key))


Add beats to ubuntu

Add beats to ubuntu

--- src/terraboot/vpc.clj
+++ src/terraboot/vpc.clj
@@ -64,7 +64,7 @@
                                                    {:path        "/etc/openvpn/up.sh"
                                                     :content     (snippet "system-files/up.sh")
                                                     :permissions "744"}]}
-                                  )))
+                                  beats-user-data-ubuntu)))

 ;;(defn vpc-dns-zone [name]
 ;;  (str name environment-dns)


Changed way of getting default json files from resources in jar.

--- src/tyranitar/git.clj
+++ src/tyranitar/git.clj
@@ -233,9 +233,10 @@
 (defn- get-repo-list-from-snc
   []
   (let [response (client/get snc-url {:as :json :throw-exceptions false})
-        qwe (prn response)
         body (:body response)]
     body))
+
+(get-repo-list-from-snc)

 (defn- filter-by-env
   [env list]
@@ -265,9 +266,7 @@

 (defn- copy-file
   [resource-name dest-path]
-  (let [source (as-file (resource resource-name))
-        dest (as-file dest-path)]
-    (copy source dest)))
+  (spit dest-path (resource resource-name)))

 (defn- copy-properties-file
   [name repo-path]


rk4 for systems works.

rk4 for systems works.

--- src/numerics/runge_kutta.clj
+++ src/numerics/runge_kutta.clj
@@ -10,25 +10,67 @@
 (defn dot [u v] (reduce + (map * u v)))

 (defn ks[f ic h { :keys [a c]}]
-  (loop [k [] ai a ci c]
+  (let [fty (apply juxt f)]
+    (loop [k [] ai a ci c]
     (if (= (count c) (count k))
       k
-      (let [deltas [(* h (first ci)) (* h (dot (first ai) k))]
-            fc (map + ic deltas)]
-        (recur (conj k (f fc)) (rest ai) (rest ci))))))
+      (let [[tn & yn] ic
+            t (+ tn (* (first ci) h))
+            y (map + yn (map (fn [k] (* h (reduce + (map #(* % k) (first ai))))) (or (peek k) (repeat 0))))
+            ty (into [t] y)]
+        (recur (conj k (fty ty)) (rest ai) (rest ci)))))))

 ;Note - for adaptive RK, just do two deltas inside of here
 (defn rk-step [f ic h { b :b :as tableau }]
   (let [k (ks f ic h tableau)
-        deltas [h (* h (dot b k))]]
-    (vec (map + ic deltas))))
+        deltas (map dot (repeat b) (apply map vector k))
+        [tn & yn] ic]
+    (into [(+ tn h)] (map + yn (map #(* % h) deltas)))))

 (def ic [0 4 6])
 (defn f [[_ y1 _]] (* -0.5 y1))
 (defn g [[_ y1 y2]] (- 4.0 (* 0.3 y2) (* 0.1 y1)))

-(prn (f ic))
-(prn (g ic))
+(prn (ks [f g] ic 0.5 rk4-tableau))
+(prn (rk-step [f g] ic 0.5 rk4-tableau))

-(prn (f [0.25 3.5 6.45]))
-(prn (g [0.25 3.5 6.45]))+;(def c [0 0.5 0.5 1.0])
+;(def a [[]
+;        [0.5]
+;        [0.0 0.5]
+;        [0.0 0.0 1.0]])
+;(def b [(/ 1.0 6.0) (/ 1.0 3.0) (/ 1.0 3.0) (/ 1.0 6.0)])
+;
+;(def h 0.5)
+;(def ic [0 4 6])
+;(defn f [[_ y1 _]] (* -0.5 y1))
+;(defn g [[_ y1 y2]] (- 4.0 (* 0.3 y2) (* 0.1 y1)))
+;(def fg (juxt f g))
+;
+;(def k0 (let [[tn & yn] ic
+;              t (+ tn (* (c 0) h))
+;              y (map + yn (map (fn [k] (* h (reduce + (map #(* % k) (a 0))))) [0 0]))]
+;          (fg (into [t] y))))
+;
+;(prn k0)
+;
+;(def k1 (let [[tn & yn] ic
+;              t (+ tn (* (c 1) h))
+;              y (map + yn (map (fn [k] (* h (reduce + (map #(* % k) (a 1))))) k0))]
+;          (fg (into [t] y))))
+;
+;(prn k1)
+;
+;(def k2 (let [[tn & yn] ic
+;              t (+ tn (* (c 2) h))
+;              y (map + yn (map (fn [k] (* h (reduce + (map #(* % k) (a 2))))) k1))]
+;          (fg (into [t] y))))
+;
+;(prn k2)
+;
+;(def k3 (let [[tn & yn] ic
+;              t (+ tn (* (c 3) h))
+;              y (map + yn (map (fn [k] (* h (reduce + (map #(* % k) (a 3))))) k2))]
+;          (fg (into [t] y))))
+;
+;(prn k3)


default order is creationdate

default order is creationdate

--- src/ontrail/mongerfilter.clj
+++ src/ontrail/mongerfilter.clj
@@ -1,4 +1,4 @@
-(ns ontrail.mongerfilter
+<(ns ontrail.mongerfilter
   (:use [monger.operators])
   (:require [clj-time.format :as format]
             [ontrail.group :as group]
@@ -98,4 +98,4 @@
 (defn sortby [params]
   (if-let [sort-order (:sb params)]
     (order-by sort-order)
-    {:lastModifiedDate -1}))
+    {:creationDate -1}))


[Fixes: #11290] Increase group size to 20

Increases the maximum size of a group chat to 20.

Signed-off-by: Andrea Maria Piana <39e16ece3c2d27e1889178b15ddb376e524032f8@gmail.com>

--- src/status_im/constants.cljs
+++ src/status_im/constants.cljs
@@ -50,7 +50,7 @@
 (def command-state-transaction-sent 7)

 (def min-password-length 6)
-(def max-group-chat-participants 10)
+(def max-group-chat-participants 20)
 (def default-number-of-messages 20)

 (def mailserver-password "status-offline-inbox")


refactor indented-str-block and add new helper fn fs for formatting strings with sensible defaults.

--- src/overtone/helpers/doc.clj
+++ src/overtone/helpers/doc.clj
@@ -37,28 +37,43 @@
        (gen-padding (str s pad) (dec len) pad)
        s)))

+(defn- indented-str-block*
+  [s ls cur-len max-len indent]
+  (if (empty? ls)
+    s
+    (let [f-len (.length (first ls))]
+      (if (.endsWith (first ls) "\n\n")
+        (if (> (+ cur-len f-len) max-len)
+          (indented-str-block* (str s "\n" (gen-padding indent) (first ls) (gen-padding indent)) (rest ls) 0 max-len indent)
+          (indented-str-block* (str s (first ls) (gen-padding indent)) (rest ls) 0 max-len indent))
+        (if (> (+ cur-len f-len) max-len)
+          (indented-str-block* (str s "\n" (gen-padding indent)) ls 0 max-len indent)
+          (indented-str-block* (str s (first ls) " ") (rest ls) (+ cur-len f-len) max-len indent))))))
+
 (defn indented-str-block
-  "Appends a list ls of strings to string s in a formatted block with a specific
-   width max-len and indentation indent. May be called with a basic text string
-   and max-len and indent in which case text will be split on whitespace.
+  "Appends a list ls of strings to string s in a formatted block with a
+   specific width max-len and indentation indent. May be called with a
+   basic text string and max-len and indent in which case text will be
+   split on whitespace.

   Will clobber all single \n found but will honour two in a row. This allows
   docstrings to contain \n for formatting purposes in source form rather than
   require them to exist on one large line."
-  ([txt max-len indent] (let [id (str (java.util.UUID/randomUUID))
-                              split-text (str/replace txt #"[\n]{2}" id)
-                              split-text (str/replace split-text "\n" " ")
-                              split-text (str/replace split-text id "\n\n ")
-                              split-text (str/split split-text #" +")]
-                          (indented-str-block "" split-text 0 max-len indent)))
-  ([s ls cur-len max-len indent]
-     (if (empty? ls)
-       s
-       (let [f-len (.length (first ls))]
-         (if (.endsWith (first ls) "\n\n")
-           (if (> (+ cur-len f-len) max-len)
-             (indented-str-block (str s "\n" (gen-padding indent) (first ls) (gen-padding indent)) (rest ls) 0 max-len indent)
-             (indented-str-block (str s (first ls) (gen-padding indent)) (rest ls) 0 max-len indent))
-           (if (> (+ cur-len f-len) max-len)
-             (indented-str-block (str s "\n" (gen-padding indent)) ls 0 max-len indent)
-             (indented-str-block (str s (first ls) " ") (rest ls) (+ cur-len f-len) max-len indent)))))))
+  ([txt max-len wrap-indent] (indented-str-block txt max-len wrap-indent 0))
+  ([txt max-len wrap-indent init-indent]
+     (let [id         (str (java.util.UUID/randomUUID))
+           txt        (str/replace txt #"[\n]{2}" id)
+           txt        (str/replace txt "\n" " ")
+           txt        (str/replace txt id "\n\n ")
+           txt        (str/replace txt #"\A +" "")
+           split-text (str/split txt #" +")
+           split-text (cons (str (gen-padding init-indent) (first split-text))
+                            (rest split-text))]
+       (indented-str-block* "" split-text 0 max-len wrap-indent))))
+
+(defn fs
+  "Format string. Synonym for indented-str-block but with a default
+   initial and wrap indentation of two characters. Also ensures that
+   there is whitespace above and below the text."
+  [txt]
+  (indented-str-block (str "\n\n" txt "\n\n") 70 7 2))


Massage and improve pitch related fns during a fun weekend workign with Marius Kempe.

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -34,8 +34,8 @@
   (* freq (java.lang.Math/pow 2 (/ n-cents 1200))))

 ;; MIDI
-(def midi-range (range 128))
-(def middle-C 60)
+(def MIDI-RANGE (range 128))
+(def MIDDLE-C 60)

 ;; Manipulating pitch using midi note numbers

@@ -75,7 +75,11 @@
             (conj result (get phrase (first notes))))
      result)))

-; Making MIDI note numbers nicer to look at...
+(defn octave-note
+  "Convert an octave and note to a midi note."
+  [octave note]
+  (+ (+ (* octave 12) note) 12))
+
 (def NOTE {:C  0  :c  0
            :C# 1  :c# 1  :Db 1  :db 1
            :D  2  :d  2
@@ -98,140 +102,59 @@
 ;;  generator functions would have to choose the scales, chords, notes and rhythm based on
 ;;  a mix of looking up aspects of the mood, and informed randomness.

-; Use a note (:C scale) or (:Eb scale)
-(def SCALE (let [major [2 2 1 2 2 2 1]
-                 minor [2 1 2 2 1 2 2]]
-             {:major major
-              :minor minor
-              :major-pentatonic (only major [1 2 3 5 6])
-              :minor-pentatonic (only minor [1 3 4 5 7])}))
-
-(def DIATONIC-MODES
-  (let [ionian-sequence [2 2 1 2 2 2 1]
-        ionian-len (count ionian-sequence)
-        rotate-ionian (fn [offset] (drop offset (take (+ ionian-len offset) (cycle ionian-sequence))))]
-    {:ionian     (rotate-ionian 0)
-     :major      (rotate-ionian 0)
-     :dorian     (rotate-ionian 1)
-     :phrygian   (rotate-ionian 2)
-     :lydian     (rotate-ionian 3)
-     :mixolydian (rotate-ionian 4)
-     :aeolian    (rotate-ionian 5)
-     :minor      (rotate-ionian 5)
-     :lochrian   (rotate-ionian 6)}))
-
-(defn nth-diatonic
-  "Return the count of semitones for the nth degree from the start of the diatonic scale in the specifiec mode (or ionian/major by default).
-     i.e. the ionian/major scale has an interval sequence of 2 2 1 2 2 2 1
-          therefore the 4th degree is (+ 2 2 1 2) semitones from the start of the scale.
-
-  You may be interested to know that each of the seven degrees of the diatonic scale has its own name:
-
-  1 (do)  tonic
-  2 (re)  supertonic
-  3 (mi)  mediant
-  4 (fa)  subdominant
-  5 (sol) dominant
-  6 (la)  submediant/superdominant
-  7 (ti)  subtonic"
-
-  ([n] (nth-diatonic n :ionian))
-  ([n mode]
-     (reduce + (take n (cycle (mode DIATONIC-MODES))))))
+;; Use a note (:C scale) or (:Eb scale)
+
+;;  You may be interested to know that each of the seven degrees of the diatonic scale has its own name:
+;;
+;; 1 (do)  tonic
+;; 2 (re)  supertonic
+;; 3 (mi)  mediant
+;; 4 (fa)  subdominant
+;; 5 (sol) dominant
+;; 6 (la)  submediant/superdominant
+;; 7 (ti)  subtonic"
+

 ;; Various scale intervals in terms of steps on a piano, or midi note numbers
 ;; All sequences should add up to 12 - the number of semitones in an octave
-(def SCALES
-  {:diatonic          [2 2 1 2 2 2 1]
-   :pentatonic        [2 3 2 2 3]
-   :whole-tone        [2 2 2 2 2 2]
-   :chromatic         [1 1 1 1 1 1 1 1 1 1 1 1]
-   :harmonic-minor    [2 1 2 2 1 3 1]
-   :melodic-minor-asc [2 1 2 2 2 2 1]
-   :hungarian-minor   [2 1 3 1 1 3 1]
-   :octatonic         [2 1 2 1 2 1 2 1]
-   :messiaen1         [2 2 2 2 2 2]
-   :messiaen2         [1 2 1 2 1 2 1 2]
-   :messiaen3         [2 1 1 2 1 1 2 1 1]
-   :messiaen4         [1 1 3 1 1 1 3 1]
-   :messiaen5         [1 4 1 1 4 1]
-   :messiaen6         [2 2 1 1 2 2 1 1]
-   :messiaen7         [1 1 1 2 1 1 1 1 2 1]})
-
-;; * Diatonic function
-;;   - in terms of centeredness around the root, this is the order
-;; of chord degrees: I, V, IV, vi, iii, ii, vii (The first 3 chords
-;; being major, second 3 minor, and last diminished)
-
-(def CHORD
-  (let [major [0 4 7]
-        minor [0 3 7]
-        major7 [0 4 7 11]
-        minor7 [0 2 6 9]
-        aug    [0 4 8]
-        dim    [0 3 6]]
-    {:major  major
-     :M      major
-     :minor  minor
-     :m      minor
-     :major7 major7
-     :M7     major7
-     :minor7 minor7
-     :m7     minor7
-     :augmented aug
-     :a         aug
-     :diminished dim
-     :i          dim}))
-
-(defn octave-note
-  "Convert an octave and note to a midi note."
-  [octave note]
-  (+ (+ (* octave 12) note) 12))
-
-; midicps
-(defn midi->hz
-  "Convert a midi note number to a frequency in hz."
-  [note]
-  (* 440.0 (java.lang.Math/pow 2.0 (/ (- note 69.0) 12.0))))
-
-; cpsmidi
-(defn hz->midi
-  "Convert from a frequency to the nearest midi note number."
-  [freq]
-  (java.lang.Math/round (+ 69
-                 (* 12
-                    (/ (java.lang.Math/log (* freq 0.0022727272727))
-                       (java.lang.Math/log 2))))))
-
-; ampdb
-(defn amp->db
-  "Convert linear amplitude to decibels."
-  [amp]
-  (* 20 (java.lang.Math/log10 amp)))
-
-; dbamp
-(defn db->amp
-  "Convert decibels to linear amplitude."
-  [db]
-  (java.lang.Math/exp (* (/ db 20) (java.lang.Math/log 10))))
-
-; TODO: finish this...
-(defn chord
-  "Returns notes for the specified chord.
-  (chord :c :major)  ; c major
-  (chord :a :minor)  ; a minor
-  (chord :Bb :dim)   ; b flat diminished
-  (chord :g :minor7) ; g minor seventh
-  (chord :E :m7)     ; E minor seventh
-  (chord :D :M7)     ; D major seventh
-  (chord :F :aug)    ; D major seventh
-  "
-  [base cname & [octave]]
-  (let [octave (or octave 4)
-        base (octave-note octave (NOTE base))]
-    (map #(+ % base) (CHORD cname))))
-
-(defn scale [skey & [sname]]
+
+(def SCALE   (let [ionian-sequence [2 2 1 2 2 2 1]
+                   ionian-len (count ionian-sequence)
+                   rotate-ionian (fn [offset] (drop offset (take (+ ionian-len offset) (cycle ionian-sequence))))]
+
+               {:diatonic          ionian-sequence
+                :ionian            (rotate-ionian 0)
+                :dorian            (rotate-ionian 1)
+                :phrygian          (rotate-ionian 2)
+                :lydian            (rotate-ionian 3)
+                :mixolydian        (rotate-ionian 4)
+                :aeolian           (rotate-ionian 5)
+                :lochrian          (rotate-ionian 6)
+
+                ;;comment these out for the time being as
+                ;;they can be confused with major and minor
+                ;;chords:
+                ;;:minor             (rotate-ionian 5)
+                ;;:major             (rotate-ionian 0)
+
+                :pentatonic        [2 3 2 2 3]
+                :major-pentatonic  [2 2 3 2 3]
+                :minor-pentatonic  [3 2 2 3 2]
+                :whole-tone        [2 2 2 2 2 2]
+                :chromatic         [1 1 1 1 1 1 1 1 1 1 1 1]
+                :harmonic-minor    [2 1 2 2 1 3 1]
+                :melodic-minor-asc [2 1 2 2 2 2 1]
+                :hungarian-minor   [2 1 3 1 1 3 1]
+                :octatonic         [2 1 2 1 2 1 2 1]
+                :messiaen1         [2 2 2 2 2 2]
+                :messiaen2         [1 2 1 2 1 2 1 2]
+                :messiaen3         [2 1 1 2 1 1 2 1 1]
+                :messiaen4         [1 1 3 1 1 1 3 1]
+                :messiaen5         [1 4 1 1 4 1]
+                :messiaen6         [2 2 1 1 2 2 1 1]
+                :messiaen7         [1 1 1 2 1 1 1 1 2 1]}))
+
+(defn scale-field [skey & [sname]]
   "Create the note field for a given scale.  Scales are specified with a keyword:
   :g :major,
   :d :minor"
@@ -245,9 +168,97 @@
             (list base)
             (take (* 8 12) (cycle intervals)))))))

-(defn from-scale [lower upper ] nil)
-
-(defn octaves [scale])
+(defn nth-interval
+  "Return the count of semitones for the nth degree from the start of the diatonic scale in the specifiec mode (or ionian/major by default).
+     i.e. the ionian/major scale has an interval sequence of 2 2 1 2 2 2 1
+          therefore the 4th degree is (+ 2 2 1 2) semitones from the start of the scale."
+  ([n] (nth-interval :ionian n))
+  ([scale n]
+     (reduce + (take n (cycle (scale SCALE))))))
+
+(def DEGREE {:i   1
+             :ii  2
+             :iii 3
+             :iv  4
+             :v   5
+             :vi  6
+             :vii 7})
+
+(defn degree->interval
+  "Converts the degree of a scale given as a roman numeral keyword or integer and converts it to the number
+   of intervals (semitones) from the tonic of the specified scale."
+  [scale degree]
+  (if-let [deg (DEGREE degree)]
+    (nth-interval scale (dec deg))
+    (nth-interval scale (dec degree))))
+
+(def CHORD
+  (let [major  [0 4 7]
+        minor  [0 3 7]
+        major7 [0 4 7 11]
+        dom7   [0 4 7 10]
+        minor7 [0 3 7 10]
+        aug    [0 4 8]
+        dim    [0 3 6]
+        dim7   [0 3 6 9]]
+    {:major      major
+     :M          major
+     :minor      minor
+     :m          minor
+     :major7     major7
+     :dom7       dom7
+     :7          dom7
+     :M7         major7
+     :minor7     minor7
+     :m7         minor7
+     :augmented  aug
+     :a          aug
+     :diminished dim
+     :dim        dim
+     :i          dim
+     :diminished7 dim7
+     :dim7       dim7
+     :i7         dim7}))
+
+(defn chord
+  "Returns a set of notes for the specified chord at the specified octave (defaulting to 4).
+  (chord :c :major)  ; c major           -> #{60 64 67}
+  (chord :a :minor 3); a minor           -> #{57 60 64}
+  (chord :Bb :dim)   ; b flat diminished -> #{70 73 76}
+  "
+  ([root chord-name] (chord root chord-name 4))
+  ([root chord-name octave]
+     (let [root (if (keyword? root) (NOTE root) root)
+           chord-name (if (keyword? chord-name) (CHORD chord-name) chord-name)
+           base (octave-note octave root)]
+       (set (map #(+ % base) chord-name)))))
+
+; midicps
+(defn midi->hz
+  "Convert a midi note number to a frequency in hz."
+  [note]
+  (* 440.0 (java.lang.Math/pow 2.0 (/ (- note 69.0) 12.0))))
+
+; cpsmidi
+(defn hz->midi
+  "Convert from a frequency to the nearest midi note number."
+  [freq]
+  (java.lang.Math/round (+ 69
+                 (* 12
+                    (/ (java.lang.Math/log (* freq 0.0022727272727))
+                       (java.lang.Math/log 2))))))
+
+; ampdb
+(defn amp->db
+  "Convert linear amplitude to decibels."
+  [amp]
+  (* 20 (java.lang.Math/log10 amp)))
+
+; dbamp
+(defn db->amp
+  "Convert decibels to linear amplitude."
+  [db]
+  (java.lang.Math/exp (* (/ db 20) (java.lang.Math/log 10))))

 (defn chosen-from [notes]
   (let [num-notes (count notes)]
@@ -264,19 +275,12 @@
   [base-freq interval]
   (* base-freq (math/expt 2 (/ interval 12))))

-(defn diatonic-freq
+(defn interval-freq
   "Returns the frequency of the given interval using the specified mode and tuning (defaulting to ionian and equal-tempered respectively)."
-  ([base-freq n] (diatonic-freq base-freq n :ionian :equal-tempered))
+  ([base-freq n] (interval-freq base-freq n :ionian :equal-tempered))
   ([base-freq n mode tuning]
      (case tuning
-           :equal-tempered (nth-equal-tempered-freq base-freq (nth-diatonic n mode)))))
-
-
-;; TODO:
-;; * weighted random
-;; * arpeggiator(s)
-
-[:c 0.8 :g 0.2 :e 0.7]
+           :equal-tempered (nth-equal-tempered-freq base-freq (nth-interval n mode)))))

 (defn- weighted-bins
   "Creates N bins where N is the smallest power of two greater than the number
@@ -354,3 +358,27 @@
 ;; - drum and bass sounds
 ;;
 ;;* create a library of sequence modifiers and harmonizers
+
+;;; ideas:
+
+;;; represent all notes with midi numbers
+;;; represent sequences of notes (i.e. scales) with vectors/lists
+;;; represent sequences of durations with vectors/lists
+;;; [1 3 5 7]
+;;; represent chords with sets
+;;; #{1 3 5}
+;;
+;;[1 3 5 #{1 4 5} 7]
+;;[1 1 2     6    3]
+
+
+;; chromatic notes -> 0-11
+;; degrees -> i -> vii
+
+;; chord - concrete: (60 64 67)
+;; chord - concrete - chromatic notes: (4 7 12)
+
+
+;; chord - abstract - chromatic notes: (0 4 7)
+;; chord - abstract - chromatic notes: (0 4 7)
+;; chord - abstract - degrees: (i iii v)


no need to parse port value to an int, we expect an int from the json body already.

--- src/metabase/api/meta/db.clj
+++ src/metabase/api/meta/db.clj
@@ -34,13 +34,12 @@
 ;Stub function that will eventually validate a connection string
 (defendpoint POST "/validate" [:as {{:keys [host port]} :body}]
   (require-params host port)
-  (let [response-invalid (fn [m] {:status 400 :body {:valid false :message m}})
-        port (Integer/parseInt port)]
-        (cond
-            (not (u/host-up? host)) (response-invalid "Host not reachable")
-            (not (u/host-port-up? host port)) (response-invalid "Invalid port")
-            (= (rand-int 2) 1)  (response-invalid "Invalid User or Password")
-            :else {:valid true} )))
+  (let [response-invalid (fn [m] {:status 400 :body {:valid false :message m}})]
+    (cond
+      (not (u/host-up? host)) (response-invalid "Host not reachable")
+      (not (u/host-port-up? host port)) (response-invalid "Invalid port")
+      (= (rand-int 2) 1) (response-invalid "Invalid User or Password")
+      :else {:valid true})))

 (defendpoint GET "/:id" [id]
   (->404 (sel :one Database :id id)


Set to fail if ClojureScript warning triggers

--- planck-cljs/script/build.clj
+++ planck-cljs/script/build.clj
@@ -17,7 +17,7 @@
        (when-let [s (cljs.analyzer/error-message warning-type extra)]
          (binding [*out* *err*]
            (println "WARNING:" (cljs.analyzer/message env s)))
-         #_(System/exit 1))))]
+         (System/exit 1))))]
   (api/build (api/inputs "src")
     {:output-dir         "out"
      :output-to          "out/main.js"


Restore broken websocket support

Restore broken websocket support

--- src/zoo_event/web/routes.clj
+++ src/zoo_event/web/routes.clj
@@ -29,6 +29,16 @@
   (fn [req]
     (update-in (handler req) [:headers] assoc "Access-Control-Allow-Origin" "*")))

+(defn wrap-websockets
+  [handler]
+  (fn [req]
+    (handler
+      (if (and (= (get-in req [:headers "upgrade"]) "websocket")
+               (not (or (= (get-in req [:headers "accept"]) app-mime)
+                        (= (get-in req [:headers "accept"]) "application/json"))))
+        (update-in req [:headers] assoc "accept" stream-mime)
+        req))))
+
 (defn handler
   [db kafka]
   (let [handler (cmpj/routes
@@ -38,6 +48,7 @@
                  (cmpj/GET "/:type/:project" [type project :as req]
                            ((ev/handle-project-request kafka db) type project req)))]
     (-> (wrap-to-param handler)
+        wrap-websockets
         wrap-from-param
         wrap-json-response
         wrap-cors


Make color a function

Make color a function

--- src/play_clj/core_basics.clj
+++ src/play_clj/core_basics.clj
@@ -14,16 +14,15 @@
      (.glClearColor (float r) (float g) (float b) (float a))
      (.glClear (bit-or GL20/GL_COLOR_BUFFER_BIT GL20/GL_DEPTH_BUFFER_BIT)))))

-(defmacro color
+(defn color
   "Returns a [Color](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/Color.html).

     (color :white)
     (color 1 1 1 1)"
-  [& args]
-  (if (keyword? (first args))
-    `(Color. ^Color ~(u/gdx-field :graphics :Color
-                                  (u/key->upper (first args))))
-    `(Color. ~@args)))
+  ([k]
+   (Color. (eval (u/gdx-field :graphics :Color (u/key->upper k)))))
+  ([r g b a]
+   (Color. r g b a)))

 (defmacro color!
   "Calls a single method on a `color`."


Minor code cleanup

Minor code cleanup

--- src/re_frame/middleware.cljs
+++ src/re_frame/middleware.cljs
@@ -114,9 +114,9 @@
   ^{:re-frame-factory-name "path"}
   (fn path
     [& args]
-    (let [path   (flatten args)
-          _      (if (empty? path)
-                   (error "re-frame: \"path\" middleware given no params."))]
+    (let [path   (flatten args)]
+      (when (empty? path)
+        (error "re-frame: \"path\" middleware given no params."))
       (fn path-middleware
         [handler]
         (fn path-handler


Implement parsing percentage from string for offset

--- src/cljs/comic_reader/ui/waypoints.cljs
+++ src/cljs/comic_reader/ui/waypoints.cljs
@@ -1,18 +1,28 @@
 (ns comic-reader.ui.waypoints
-  (:require [reagent.core :as reagent])
+  (:require [cljs.reader :as r]
+            [clojure.string :as str]
+            [reagent.core :as reagent])
   (:import (goog.async Throttle)))

 (def ^:private waypoints (atom {}))

-(defn- as-percentage [offset]
-  0)
+(defn- parse-percentage [s]
+  (let [percent-str (str "0." (str/replace s #"%|\." ""))
+        reader-result (r/read-string percent-str)]
+    (if (number? reader-result)
+      reader-result
+      0)))
+
+(defn- as-percentage [node-height offset-percent]
+  (let [percentage (parse-percentage offset-percent)]
+    (* node-height percentage)))

 (defn- get-offset-position [node offset]
   (cond
-    (number? offset)    offset
-    (string? offset)    (as-percentage node offset)
-    (function? offset)  (offset node)
-    :else               0))
+    (number? offset)  offset
+    (string? offset)  (as-percentage (.innerHeight node) offset)
+    (fn? offset)      (offset node)
+    :else             0))

 (defn- get-node-position-at-offset [node offset]
   (let [offset-position (get-offset-position node offset)


make badge grid responsive

make badge grid responsive

--- src/cljs/salava/core/ui/badge_grid.cljs
+++ src/cljs/salava/core/ui/badge_grid.cljs
@@ -63,7 +63,7 @@
                                              [:div.lefticon [:i {:class "fa fa-history"}] (t :badge/Expired)]
                                              [:a.righticon {:class "righticon expired" :on-click (fn [] (m/modal! [delete-badge-modal id state init-data]
                                                                                {:size :lg})) :title (t :badge/Delete)} [:i {:class "fa fa-trash"}]]])
-                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})}
+                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id} {:hide (fn [] (init-data state))})}
                                   (if image_file
                                    [:div.media-left
                                     [:img.badge-img {:src (str "/" image_file)
@@ -75,7 +75,7 @@
                                    [:p issuer_content_name]]]
                                  ]]
                                 [:div {:class (str "media-content " (if expired? "media-expired") (if revoked " media-revoked"))}
-                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id})}
+                                 [:a {:href "#" :on-click #(mo/open-modal [:badge :info] {:badge-id id} {:hide (fn [] (init-data state))})}
                                   [:div.icons
                                    [:div.visibility-icon
                                     (case visibility


Only AOT compile the actual cassandra config code. (Requiring logging includes containium systems and config.)

--- systems/cassandra-node/src/containium/systems/cassandra/config.clj
+++ systems/cassandra-node/src/containium/systems/cassandra/config.clj
@@ -4,15 +4,13 @@

 (ns containium.systems.cassandra.config
   (:refer-clojure :exclude [munge])
-  (:require [containium.systems.logging :refer (refer-logging)]
-            [clojure.java.io :as io])
+  (:require [clojure.java.io :as io])
   (:import [org.apache.cassandra.config Config Config$CommitLogSync Config$DiskFailurePolicy
             SeedProviderDef]
            [java.util LinkedHashMap]
            [java.net URL])
   (:gen-class :extends org.apache.cassandra.config.YamlConfigurationLoader
               :exposes-methods {loadConfig superLoadConfig}))
-(refer-logging)

 (defonce system-config (promise))
@@ -66,7 +64,7 @@
           "Logger not realized; config loaded before containium was able to set it.")
   (assert (realized? system-config)
           "Configuration not realized; config loaded before containium was able to set it.")
-  (info @logger "Constructing Cassandra config from:" (pr-str @system-config))
+  (println "[INFO] Constructing Cassandra config from:" (pr-str @system-config))
   (let [config (if-let [url (:config-file @system-config)]
                  (.superLoadConfig this ^URL (io/resource url))
                  (Config.))]