Sanity check Roman Numerals

Sanity check Roman Numerals

--- src/clojush/problems/software/benchmarks_v2/roman_numerals.clj
+++ src/clojush/problems/software/benchmarks_v2/roman_numerals.clj
@@ -12,58 +12,63 @@

 (def roman-numeral-values
   (let [roman-numeral-map {\i 1
-                      \v 5
-                      \x 10
-                      \l, 50
-                      \c 100
-                      \d 500
-                      \m 1000}
+                           \v 5
+                           \x 10
+                           \l 50
+                           \c 100
+                           \d 500
+                           \m 1000}
         visible-chars (map char (range 0 127))]
     (vec (for [c visible-chars]
            (get roman-numeral-map (first (string/lower-case c)) 0)))))

 ; Atom generators
 (def roman-numerals-atom-generators
-  (concat (list
-            roman-numeral-values
-            1
-            5
-            10
-            50
-            100
-            500
-            1000
-            ;;; end constants
-            ;;; end ERCs
-            (tag-instruction-erc [:string :char :integer :boolean :vector_integer :exec] 1000)
-            (tagged-instruction-erc 1000)
-            ;;; end tag ERCs
-            'in1
-            ;;; end input instructions
-            )
-          (registered-for-stacks [:string :char :integer :boolean :vector_integer :exec])))
+  (make-proportional-atom-generators
+   (concat
+    (registered-for-stacks [:string :char :integer :boolean :vector_integer :exec])
+    (list (tag-instruction-erc [:string :char :integer :boolean :vector_integer :exec] 1000) ; tags
+          (tagged-instruction-erc 1000)))
+   (list 'in1) ; inputs
+   (list roman-numeral-values
+         0
+         1
+         4
+         5
+         9
+         10
+         40
+         50
+         90
+         100
+         400
+         500
+         900
+         1000) ; constants
+   {:proportion-inputs 0.15
+    :proportion-constants 0.05}))

 ;; Define test cases
 (defn roman-numerals-input
  "Makes a Roman Numeral input given a decimal number."
  [num]
  (apply str
-           (loop [roman "" number num]
-             (cond
-               (> number (mod number 1000)) (recur (str roman "M") (- number 1000))
-               (> number (mod number 900)) (recur (str roman "CM") (- number 900))
-               (> number (mod number 500)) (recur (str roman "D") (- number 500))
-               (> number (mod number 400)) (recur (str roman "CD") (- number 400))
-               (> number (mod number 100)) (recur (str roman "C") (- number 100))
-               (> number (mod number 90)) (recur (str roman "XC") (- number 90))
-               (> number (mod number 50)) (recur (str roman "L") (- number 50))
-               (> number (mod number 40)) (recur (str roman "XL") (- number 40))
-               (> number (mod number 10)) (recur (str roman "X") (- number 10))
-               (> number (mod number 9)) (recur (str roman "IX") (- number 9))
-               (> number (mod number 5)) (recur (str roman "V") (- number 5))
-               (> number (mod number 4)) (recur (str roman "IV") (- number 4))
-               (> number (mod number 1)) (recur (str roman "I") (- number 1))
-               :else roman))))
+        (loop [roman "" number num]
+          (cond
+            (> number (mod number 1000)) (recur (str roman "M") (- number 1000))
+            (> number (mod number 900)) (recur (str roman "CM") (- number 900))
+            (> number (mod number 500)) (recur (str roman "D") (- number 500))
+            (> number (mod number 400)) (recur (str roman "CD") (- number 400))
+            (> number (mod number 100)) (recur (str roman "C") (- number 100))
+            (> number (mod number 90)) (recur (str roman "XC") (- number 90))
+            (> number (mod number 50)) (recur (str roman "L") (- number 50))
+            (> number (mod number 40)) (recur (str roman "XL") (- number 40))
+            (> number (mod number 10)) (recur (str roman "X") (- number 10))
+            (> number (mod number 9)) (recur (str roman "IX") (- number 9))
+            (> number (mod number 5)) (recur (str roman "V") (- number 5))
+            (> number (mod number 4)) (recur (str roman "IV") (- number 4))
+            (> number (mod number 1)) (recur (str roman "I") (- number 1))
+            :else roman))))

 ;; A list of data domains for the problem. Each domain is a vector containing
 ;; a "set" of inputs and two integers representing how many cases from the set
@@ -71,22 +76,69 @@
 ;; inputs is either a list or a function that, when called, will create a
 ;; random element of the set.
 (def roman-numerals-data-domains
-  [[(list ""
-          "I"
-          "V"
-          "X"
-          "L"
-          "C"
-          "D"
-          "M"
-          "IV"
-          "VI"
-          "IX"
-          "XI"
-          "MMMCMXCIX") 13 0] ; Special edge cases
-    [(fn [] (roman-numerals-input (inc (lrand-int 3999)))) 187 2000]
-   ;[(fn [] (map roman-numerals-input (remove #(contains? #{1 5 10 50 100 500 1000 4 6 9 11 3999} %) (range 1 4000)))) 0 3987] ; The rest of the possible numbers 1-3999
-   ])
+  (let [edge-cases (list ""
+                         "I"
+                         "II"
+                         "III"
+                         "IV"
+                         "V"
+                         "VI"
+                         "VII"
+                         "VIII"
+                         "IX"
+                         "X"
+                         "XI"
+                         "XII"
+                         "XVIII"
+                         "XIX"
+                         "XX"
+                         "XXI"
+                         "XXX"
+                         "XL"
+                         "XLI"
+                         "XLVIII"
+                         "XLIX"
+                         "L"
+                         "LI"
+                         "LIII"
+                         "LIV"
+                         "LXXXVIII"
+                         "LXXXIX"
+                         "XC"
+                         "XCI"
+                         "XCII"
+                         "XCVIII"
+                         "XCIX"
+                         "C"
+                         "CI"
+                         "CIV"
+                         "CXLIX"
+                         "CXCIV"
+                         "CXCIX"
+                         "CC"
+                         "CCC"
+                         "CCCLIX"
+                         "CCCXCVIII"
+                         "CCCXCIX"
+                         "CD"
+                         "CDLXXIII"
+                         "CDXC"
+                         "CDXCIX"
+                         "D"
+                         "DXI"
+                         "DCCCLXXXVIII"
+                         "DCCCXCIX"
+                         "CM"
+                         "CMI"
+                         "CMXCIX"
+                         "M"
+                         "MM"
+                         "MMM"
+                         "MMMCM"
+                         "MMMCMXCIX")]
+    [[edge-cases (count edge-cases) 0] ; Special edge cases
+     [(fn [] (roman-numerals-input (inc (lrand-int 3999)))) 187 2000]
+     ]))

 ;;Can make Roman Numeral test data like this:
 ;(test-and-train-data-from-domains roman-numerals-data-domains)
@@ -96,7 +148,6 @@
   "Takes a sequence of inputs and gives IO test cases of the form
    [input output]."
   [inputs]
-  (println inputs)
   (map (fn [in]
           (vector in
               (loop [roman in number 0]


Adding correct cache header

Adding correct cache header

--- apoya-app/src/clj/apoya/app.clj
+++ apoya-app/src/clj/apoya/app.clj
@@ -56,7 +56,8 @@
                    (.getInput))]
       (if (or (nil? etag) (not= etag if-none-match))
         (response/content-type {:body body
-                                :headers {"etag" etag}
+                                :headers {"etag" etag
+                                          "cache-control" (str "max-age=" max-age)}
                                 :status 200}
                                mime-type)
         {:status 304 :body "" :headers {"etag" etag


Remove some debug code

Remove some debug code

--- src/deadman/core.clj
+++ src/deadman/core.clj
@@ -63,11 +63,7 @@
     (when timer {:body (:data timer)}
               (route/not-found {:message "Not found"}))))

-(defn reflect [request]
-  (str request))
-
 (defroutes main-routes
-  (POST "/timers/:id" request (reflect request))
   (PUT "/timers/:id" request (handle-timer-request request))
   (GET "/timers/:id" request (get-timer request))
   (GET "/timers" request (fn [r] @timers))


Add Propper Unprocessable Entity Error Message to Find Workbook

--- src/lens/handler.clj
+++ src/lens/handler.clj
@@ -179,7 +179,10 @@
     (fnk [workbook] (render-workbook path-for workbook))

     :handle-not-found
-    (error-body path-for "Workbook not found.")))
+    (error-body path-for "Workbook not found.")
+
+    :handle-unprocessable-entity
+    (error-body path-for "Missing query param 'id'.")))

 ;; ---- Handlers --------------------------------------------------------------


Added default value for output directory arg of site builder.

--- src/profanity_power_index/core.clj
+++ src/profanity_power_index/core.clj
@@ -44,7 +44,8 @@
    :long-opt "--output-directory"
    :required "DIRECTORY_NAME"
    :desc "The name of the output directory for the site."
-   :id :output-directory]])
+   :id :output-directory
+   :default "site"]])

 (defn -main
   [& args]
@@ -60,5 +61,4 @@
                   (extract env options))
       "generate" (let [options (parse-opts (rest args) generate-spec)]
                     (generate options))
-      (println (str command "is not a command.")))
-))
+      (println (str command "is not a command.")))))


Remove clutter

Remove clutter

--- dev/src/yada/dev/external.clj
+++ dev/src/yada/dev/external.clj
@@ -27,8 +27,6 @@

       ]]))

-#_(io/resource "META-INF/resources/webjars/material-design-lite/1.0.2/material.css")
-
 (defn new-external-content [& {:as opts}]
   (-> (->> opts
            (merge {})


Added new fn mapify-current-movies which returns movies in a map, e.g. ({:name Mov-Name} {:name Another-Mov})

--- src/cine/core.clj
+++ src/cine/core.clj
@@ -25,6 +25,7 @@

 (defn mapify-current-movies
   "Returns current movies in a map e.g. {:name 'MI5'}"
+  []
   (map #(assoc {} :name %1) (get-current-movies)))

 (defn get-upcoming-movies


[#2309] Make sure to only have feature flag on Keycloak authentication

--- backend/src/akvo/lumen/auth.clj
+++ backend/src/akvo/lumen/auth.clj
@@ -33,7 +33,7 @@
   be configured via the KEYCLOAK_URL env var."
   [keycloak-public-client auth0-public-client authorizer]
   (let [keycloak-verifier (RSASSAVerifier. (:rsa-key keycloak-public-client))
-        auth0-verifier (RSASSAVerifier.  (:rsa-key auth0-public-client))]
+        auth0-verifier (RSASSAVerifier. (:rsa-key auth0-public-client))]
     (fn [handler]
       (fn [{:keys [tenant] :as req}]
         (if-let [token (jwt/jwt-token req)]
@@ -74,16 +74,32 @@
 ;;; Authorization helpers
 ;;;

-;; Currently Keycloak API authz is not available when authenticating with Auth0
-;; but only for users with app_metadata set to true in path -> lumen -> features
-;; -> apiAuthz and akvo.org email.
-(defn api-authz? [{:strs [email email_verified] :as jwt-claims}]
-  (let [flag-path ["https://akvo.org/app_metadata" "lumen" "features"
-                   "apiAuthz"]
-        flag (get-in jwt-claims flag-path)]
-    (and (and (some? flag) flag)
-         (and (some? email_verified) email_verified)
-         (and (some? email) (string/ends-with? email "@akvo.org")))))
+(defmulti api-authz?
+  (fn [{:strs [iss] :as jwt-claims}]
+    (cond
+      (string/ends-with? iss "eu.auth0.com/") :auth0
+      (or (= iss "https://kc.akvotest.org/auth/realms/akvo")
+          (= iss "https://login.akvo.org/auth/realms/akvo")) :keycloak)))
+
+#_(defmethod api-authz? :auth0
+    [{:strs [email email_verified] :as jwt-claims}]
+    (let [flag-path ["https://akvo.org/app_metadata" "lumen" "features"
+                     "apiAuthz"]
+          flag (get-in jwt-claims flag-path)]
+      (and (and (some? flag) flag)
+           (and (some? email_verified) email_verified)
+           (and (some? email) (string/ends-with? email "@akvo.org")))))
+
+;; If authenticated with auth0 API authz is required
+(defmethod api-authz? :auth0
+  [{:strs [email email_verified] :as jwt-claims}]
+  true)
+
+(defmethod api-authz? :keycloak
+  [{:strs [email family_name]}]
+  (and
+   (and (some? family_name) (string/ends-with? family_name "$auth"))
+   (and (some? email) (string/ends-with? email "@akvo.org"))))

 (defn- application-json-type
   "code taken from ring.middleware.json/wrap-json-response"
@@ -176,9 +192,30 @@
       application-json-type))

 (def internal-server-error
-  (-> (response/response "Internal server errror")
+  (-> (response/response "Internal server error")
       (response/status 500)
       application-json-type))
+
+(defn handle-api-authorization
+  [authorizer handler {:keys [jwt-claims tenant] :as request}]
+  (try
+    (let [email (get jwt-claims "email")
+          allowed-paths (delay (p/allowed-paths authorizer email))]
+      (cond
+        (nil? jwt-claims) not-authorized
+        (admin-path? request) (if (api-tenant-admin? tenant @allowed-paths)
+                                (handler request)
+                                not-authorized)
+        (api-path? request) (if (api-tenant-member? tenant @allowed-paths)
+                              (handler request)
+                              not-authorized)
+        :else not-authorized))
+    (catch Exception e
+      (let [wrap-info (fn [e v] (log/info (.getMessage e)) v)]
+        (case (-> e ex-data :response-code)
+          503 (wrap-info e service-unavailable)
+          401 not-authorized
+          (wrap-info e internal-server-error))))))

 (defmethod ig/init-key :akvo.lumen.auth/wrap-api-authorization
   [_ {:keys [authorizer]}]
@@ -205,5 +242,6 @@
                 (wrap-info e internal-server-error)))))
         (handler request)))))

+
 (defmethod ig/pre-init-spec :akvo.lumen.auth/wrap-api-authorization [_]
   (s/keys :req-un [::p/authorizer]))


Fixed bug in Clojure 1.5.0 caused by workaround for CLJ-870

--- ring-core/src/ring/util/codec.clj
+++ ring-core/src/ring/util/codec.clj
@@ -9,6 +9,14 @@

 (defn- double-escape [^String x]
   (.replace (.replace x "\\" "\\\\") "$" "\\$"))
+
+(def ^:private string-replace-bug?
+  (= "x" (str/replace "x" #"." (fn [x] "$0"))))
+
+(defmacro fix-string-replace-bug [x]
+  (if string-replace-bug?
+    `(double-escape ~x)
+    x))

 (defn percent-encode
   "Percent-encode every character in the given string using either the specified
@@ -33,7 +41,7 @@
                (fn [chars]
                  (-> ^bytes (parse-bytes chars)
                      (String. (or encoding "UTF-8"))
-                     (double-escape)))))
+                     (fix-string-replace-bug)))))

 (defn url-encode
   "Returns the url-encoded version of the given string, using either a specified


(PE-3177) Use build-type in foss config

(PE-3177) Use build-type in foss config

Because there are separate configs for PE and foss, they need a way to
tell ezbake which set of templates should be used. This commit adds
build-type to the jvm-puppet config to indicate it is a foss build.

--- configs/jvm-puppet/jvm-puppet.clj
+++ configs/jvm-puppet/jvm-puppet.clj
@@ -10,7 +10,8 @@
                  ["snapshots" "http://nexus.delivery.puppetlabs.net/content/repositories/snapshots/"]]
   :main puppetlabs.trapperkeeper.main

-  :ezbake {:pe {}
-           :foss {:user "puppet"
-                  :group "puppet"}}
-  )+  :ezbake { :user "puppet"
+            :group "puppet"
+            :build-type "foss"
+            }
+  )


combineTile.clj: some refactoring

combineTile.clj: some refactoring

--- clojure/org/gavrog/clojure/combineTiles.clj
+++ clojure/org/gavrog/clojure/combineTiles.clj
@@ -8,14 +8,12 @@
   (let [idcs (indices ds)]
     (frequencies (for [D (orbit-reps ds idcs)] (canonical (orbit ds idcs D))))))

-(defn- orbit-partition [maps]
-  (reduce (fn [p [D E]] (punion p D E)) pempty (apply concat maps)))
-
-(defn- reps-by-automorphism-group [ds]
-  (map first (orbit-partition (automorphisms ds))))
+(defn- partition-by-automorphism-group [ds]
+  (into pempty (apply concat (automorphisms ds))))

 (defn- inequivalent-forms [ds]
-  (map (partial renumbered-from ds) (reps-by-automorphism-group ds)))
+  (for [orb (partition-by-automorphism-group ds)]
+    (renumbered-from ds (first orb))))

 (defn combine-tiles [ds]
   (make-backtracker


solutions, some refactoring.

solutions, some refactoring.

--- src/exp/sahdd.clj
+++ src/exp/sahdd.clj
@@ -89,7 +89,7 @@
 (defn make-descendents [state action prim-constructor ref-constructor]
   (if (env/primitive? action)
       (when-let [[ss sr] (and (env/applicable? action state) (env/successor action state))]
-        [(prim-constructor ss sr)])
+        [(prim-constructor (vary-meta ss assoc :opt [action]) sr)])
     (map ref-constructor (hierarchy/immediate-refinements action state))))

 (defn generalize-outcome-pair [[outcome-state reward] gen-state reward-to-gen-state]
@@ -272,15 +272,19 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Drivers  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn sahucs-simple [henv]
+(defn hierarchical-search [henv search-maker]
   (binding [*problem-cache* (HashMap.)]
     (let [e    (hierarchy/env henv)
           init (env/initial-logging-state e)
           tla  (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)])
-          top  (make-incremental-dijkstra-search (make-initial-sp-nodes init tla))
-          result (next-partial-solution top Double/NEGATIVE_INFINITY)]
-      (assert (< (count (:result-pairs result 1))))
-      (second (first (:result-pairs result))))))
+          top  (search-maker init tla)]
+      (when-let [[s r] (first (:result-pairs (next-partial-solution top Double/NEGATIVE_INFINITY)))]
+        [(map env/action-name (:opt (meta s))) r ]))))
+
+(defn sahucs-simple [henv]
+  (hierarchical-search henv (fn [s a] (make-incremental-dijkstra-search (make-initial-sp-nodes s a)))))
+
+

 (defn blablabla [henv]
@@ -301,6 +305,9 @@
       (assert (< (count (:result-pairs result 1))))
       (second (first (:result-pairs result))))))

+;; TODO: compare performance to other algorithms.
+
+
 ;; For SAHA, nothing is open.
 ;  Or strcture is same.
  ; Goal is: ?


Fix minor typos

Fix minor typos

Closes #90.

--- src-cljs/rmfu_ui/about.cljs
+++ src-cljs/rmfu_ui/about.cljs
@@ -6,9 +6,9 @@
     [:div.row
      [:div.col-lg-12
       [:h1.text-center "About Feed"]
-      [:p "Feed is collaboration between Rocky Mountain Farmers Union and Code for Denver to help provide a place for active engagement within RMFU's communities"]
+      [:p "Feed is a collaboration between Rocky Mountain Farmers Union and Code for Denver to help provide a place for active engagement within RMFU's communities."]
       [:h2 "Rocky Mountain Farmers Union"]
-      [:p "Rocky Mountain Farmers Union is an advocate for family farmers and ranchers, local communities, and consumers. We are a progressive grassroots organization whose members determine our priorities. Founded in 1907, Rocky Mountain Farmers Union represent farm and ranch families in Colorado, New Mexico and Wyoming. Working together with similar state chapters across America, we are the heart and soul of the National Farmers Union."]
+      [:p "Rocky Mountain Farmers Union is an advocate for family farmers and ranchers, local communities, and consumers. We are a progressive grassroots organization whose members determine our priorities. Founded in 1907, Rocky Mountain Farmers Union represents farm and ranch families in Colorado, New Mexico and Wyoming. Working together with similar state chapters across America, we are the heart and soul of the National Farmers Union."]
       [:h2 "Code for Denver"]
       [:p "We believe technology and innovation are powerful tools we can all use to make our community an even more spectacular place to live.


Fix !that (#56)

Fix !that (#56)

--- src/yetibot/core/commands/that.clj
+++ src/yetibot/core/commands/that.clj
@@ -5,9 +5,11 @@
     [yetibot.core.hooks :refer [cmd-hook]]))

 (defn get-that [chat-source cmd?]
-  ;; the cmd used to call this will be in history, so get the last two then get
-  ;; the first for it
-  (let [result (last (h/last-chat-for-room chat-source cmd? 2))]
+  (info (pr-str chat-source))
+  ;; the cmd used to call this will be in history, so if cmd? is true, get the
+  ;; last two then get the last of those
+  (let [items (if cmd? 2 1)
+        result (last (h/last-chat-for-room chat-source cmd? items))]
     {:result/value (:body result)
      :result/data result}))


Call force-update-all on file saved

Call force-update-all on file saved

--- env/dev/cljs/cglossa/dev.cljs
+++ env/dev/cljs/cglossa/dev.cljs
@@ -1,5 +1,6 @@
 (ns cglossa.dev
   (:require [cglossa.core :as core]
+            [reagent.core :refer [force-update-all]]
             [figwheel.client :as figwheel :include-macros true]
             [cljs.core.async :refer [put!]]
             [weasel.repl :as weasel]))
@@ -8,7 +9,7 @@

 (figwheel/watch-and-reload
   :websocket-url "ws://localhost:3449/figwheel-ws"
-  :jsload-callback (fn [] (core/main)))
+  :jsload-callback (fn [] (force-update-all)))

 (weasel/connect "ws://localhost:9001" :verbose true)


Optionally accept a URL root in the Clojure client

--- src/shale/client.clj
+++ src/shale/client.clj
@@ -9,131 +9,164 @@
         [clojure.set :only [rename-keys]]
         shale.utils))

+(def default-url-root "http://localhost:5000")
+
 (def ^:private sessions-url
-  (clojure.string/join "/" ["http://localhost:5000" "sessions"]))
+  (memoize
+    (fn [url-root]
+      (clojure.string/join "/" [url-root "sessions"]))))

 (def ^:private nodes-url
-  (clojure.string/join "/" ["http://localhost:5000" "nodes"]))
+  (memoize
+    (fn [url-root]
+      (clojure.string/join "/" [url-root "nodes"]) )))

-(defn ^:private session-url [id]
-  (clojure.string/join "/" [sessions-url id]))
+(defn ^:private session-url [url-root id]
+  (clojure.string/join "/" [(sessions-url url-root)id]))

-(defn ^:private session-by-webdriver-url [webdriver-id]
-  (clojure.string/join "/" [sessions-url "webdriver" webdriver-id]))
+(defn ^:private session-by-webdriver-url [url-root webdriver-id]
+  (clojure.string/join "/" [(sessions-url url-root) "webdriver" webdriver-id]))

-(defn ^:private map->session-url [m-or-id]
+(defn ^:private map->session-url [url-root m-or-id]
   (if (map? m-or-id)
     (if (contains? m-or-id :webdriver-id)
-      (session-by-webdriver-url (:webdriver-id m-or-id))
-      (session-url (or (:session-id m-or-id) (:id m-or-id))))
-    (session-url m-or-id)))
+      (session-by-webdriver-url url-root (:webdriver-id m-or-id))
+      (session-url url-root (or (:session-id m-or-id) (:id m-or-id))))
+    (session-url url-root m-or-id)))

-(defn sessions []
-  (let [response (try+ (client/get sessions-url)
-                       (catch [:status 400] {:keys [body]} (error body) (throw+)))]
-    (json/parse-string (response :body))))
+(defn sessions
+  ([] (sessions default-url-root))
+  ([url-root]
+   (let [response (try+
+                    (client/get (sessions-url url-root))
+                    (catch [:status 400] {:keys [body]} (error body) (throw+)))]
+     (json/parse-string (response :body)))))

-(defn nodes []
-  (let [response (try+ (client/get nodes-url)
-                       (catch [:status 400] {:keys [body]} (error body) (throw+)))]
-    (json/parse-string (response :body))))
+(defn nodes
+  ([] (nodes default-url-root))
+  ([url-root]
+   (let [response (try+ (client/get (nodes-url url-root))
+                        (catch [:status 400] {:keys [body]} (error body) (throw+)))]
+     (json/parse-string (response :body)))))

-(defn session [id]
-  (let [url (map->session-url id)
-        response (client/get url)]
-    (json/parse-string (response :body))))
+(defn session
+  ([id] (session default-url-root id))
+  ([url-root id]
+   (let [url (map->session-url url-root id)
+         response (client/get url)]
+     (json/parse-string (response :body)))))

-(defn get-or-create-session! [{:keys [browser-name
-                                      node
-                                      reserved
-                                      tags
-                                      reserve-after-create
-                                      force-create]
-                              :or {browser-name "phantomjs"
-                                   node nil
-                                   reserved nil
-                                   reserve-after-create nil
-                                   force-create nil
-                                   tags []}
-                              :as requirements}]
-  (let [body (rename-keys (select-keys requirements
-                                       [:browser-name :reserved :node :tags])
-                          {:browser-name :browser_name})
-        params (rename-keys (select-keys requirements
-                                         [:reserve-after-create :force-create])
-                            {:reserve-after-create :reserve_after_create
-                             :force-create :force_create})
-        response (try+
-                   (client/post sessions-url
-                     {:body (json/generate-string body)
-                      :content-type :json
-                      :accept :json
-                      :query-params params})
-                   (catch [:status 400] {:keys [body]} (error body) (throw+)))]
-    (json/parse-string (response :body))))
+(defn get-or-create-session!
+  ([requirements] (get-or-create-session! default-url-root requirements))
+  ([url-root {:keys [browser-name
+                     node
+                     reserved
+                     tags
+                     reserve-after-create
+                     force-create]
+              :or {browser-name "phantomjs"
+                   node nil
+                   reserved nil
+                   reserve-after-create nil
+                   force-create nil
+                   tags []}
+              :as requirements}]
+   (let [body (rename-keys (select-keys requirements
+                                        [:browser-name :reserved :node :tags])
+                           {:browser-name :browser_name})
+         params (rename-keys (select-keys requirements
+                                          [:reserve-after-create :force-create])
+                             {:reserve-after-create :reserve_after_create
+                              :force-create :force_create})
+         response (try+
+                    (client/post (sessions-url url-root)
+                                 {:body (json/generate-string body)
+                                  :content-type :json
+                                  :accept :json
+                                  :query-params params})
+                    (catch [:status 400] {:keys [body]} (error body) (throw+)))]
+     (json/parse-string (response :body)))))

-(defn modify-session! [id {:keys [reserved tags]
-                           :or {reserved nil
-                                tags nil}}]
-  (let [url (map->session-url id)
-        body (merge (if (not (nil? reserved)) {:reserved reserved})
-                    (if tags {:tags tags})
-                    {})
-        response (try+
-                   (client/put url
-                               {:body (json/generate-string body)
-                                :content-type :json
-                                :accept :json})
-                   (catch [:status 400] {:keys [body]}
-                     (error body)
-                     (throw+)))]
-    (json/parse-string (response :body))))
+(defn modify-session!
+  ([id options] (modify-session! default-url-root id options))
+  ([url-root id {:keys [reserved tags]
+                 :or {reserved nil
+                      tags nil}}]
+   (let [url (map->session-url url-root id)
+         body (merge (if (not (nil? reserved)) {:reserved reserved})
+                     (if tags {:tags tags})
+                     {})
+         response (try+
+                    (client/put url
+                                {:body (json/generate-string body)
+                                 :content-type :json
+                                 :accept :json})
+                    (catch [:status 400] {:keys [body]}
+                      (error body)
+                      (throw+)))]
+     (json/parse-string (response :body)))))

-(defn reserve-session! [id]
-  (modify-session! id {:reserved true}))
+(defn reserve-session!
+  ([id] (reserve-session! default-url-root id))
+  ([url-root id]
+   (modify-session! url-root id {:reserved true})))

-(defn release-session! [id]
-  (modify-session! id {:reserved false}))
+(defn release-session!
+  ([id] (release-session! default-url-root id))
+  ([url-root id]
+   (modify-session! url-root id {:reserved false})))

-(defn destroy-session! [id]
-  (let [url (map->session-url id)]
-    (client/delete url))
-  nil)
+(defn destroy-session!
+  ([id] (destroy-session! default-url-root id))
+  ([url-root id]
+   (let [url (map->session-url url-root id)]
+     (client/delete url))
+   nil))

-(defn destroy-sessions! []
-  (client/delete sessions-url)
-  nil)
+(defn destroy-sessions!
+  ([] (destroy-sessions! default-url-root))
+  ([url-root]
+   (client/delete (sessions-url url-root))
+   nil))

-(defn refresh-sessions! []
-  (let [response (try+
-                   (client/post
-                     (clojure.string/join "/" [sessions-url "refresh"]) {})
-                   (catch [:status 400] {:keys [body]} (error body) (throw+)))]
-    (json/parse-string (response :body))))
+(defn refresh-sessions!
+  ([] (refresh-sessions! default-url-root))
+  ([url-root]
+   (let [response (try+
+                    (client/post
+                      (clojure.string/join "/"
+                                           [(sessions-url url-root) "refresh"])
+                      {})
+                    (catch [:status 400] {:keys [body]} (error body) (throw+)))]
+     (json/parse-string (response :body)))))

-(defn get-or-create-webdriver! [{:keys [browser-name
-                                        node
-                                        reserved
-                                        tags
-                                        reserve-after-create
-                                        force-create]
-                                 :or {browser-name "phantomjs"
-                                      node nil
-                                      reserved nil
-                                      reserve-after-create nil
-                                      force-create nil
-                                      tags []}
-                                 :as requirements}]
-  (let [session (get-or-create-session! requirements)]
-    (webdriver/resume-webdriver
-      (get session "webdriver_id")
-      (get-in session ["node" "url"])
-      {"platform" "ANY"
-       "browserName" (get session "browser_name")})))
+(defn get-or-create-webdriver!
+  ([requirements] (get-or-create-webdriver! default-url-root requirements))
+  ([url-root {:keys [browser-name
+                     node
+                     reserved
+                     tags
+                     reserve-after-create
+                     force-create]
+              :or {browser-name "phantomjs"
+                   node nil
+                   reserved nil
+                   reserve-after-create nil
+                   force-create nil
+                   tags []}
+              :as requirements}]
+   (let [session (get-or-create-session! url-root requirements)]
+     (webdriver/resume-webdriver
+       (get session "webdriver_id")
+       (get-in session ["node" "url"])
+       {"platform" "ANY"
+        "browserName" (get session "browser_name")}))))

-(defn release-webdriver! [driver]
-  (if-let [session-id (session-id driver)]
-    (release-session! {:webdriver-id session-id})))
+(defn release-webdriver!
+  ([driver] (release-webdriver! default-url-root driver))
+  ([url-root driver]
+   (if-let [session-id (session-id driver)]
+     (release-session! url-root {:webdriver-id session-id}))))

 (defmacro with-webdriver*
     "Given tags and a browser name to get or create a new webdriver session,


add doc strings to functions

add doc strings to functions

--- src/t3tr0s/core.cljs
+++ src/t3tr0s/core.cljs
@@ -63,16 +63,18 @@
   [board]
   (join "\n" (map row-str board)))

-(defn print-board []
+(defn print-board
+  "Prints the board to screen."
+  []
   (println (board-str (:board @state))))

-(defn write-to-board [ x y value ]
-  (swap! state assoc-in [:board y x] value)
-  )
+(defn write-to-board
+  "Writes a given value to the x,y position on the board."
+  [ x y value ]
+  (swap! state assoc-in [:board y x] value))

 (defn init []
   (connect-repl)
-  (print-board)
-  )
+  (print-board))

-(document-ready init)+(document-ready init)


Use reduce instead of apply.

Use reduce instead of apply.

--- project/analyze-data/src/analyze_data/naive_bayes/train.clj
+++ project/analyze-data/src/analyze_data/naive_bayes/train.clj
@@ -31,7 +31,7 @@
     (count label-indices)
     (for [[label indices] label-indices]
       (let [samples (m/select X indices :all)]
-        (apply m/add samples)))))
+        (reduce m/add samples)))))

 (defn- calc-phi
   "X: design matrix


Schedule to the next context the message side effect.

--- src/uxbox/data/messages.cljs
+++ src/uxbox/data/messages.cljs
@@ -88,15 +88,15 @@

 (defn error!
   [& args]
-  (rs/emit! (apply show-error args)))
+  (p/schedule 0 #(rs/emit! (apply show-error args))))

 (defn info!
   [& args]
-  (rs/emit! (apply show-info args)))
+  (p/schedule 0 #(rs/emit! (apply show-info args))))

 (defn dialog!
   [& args]
-  (rs/emit! (apply show-dialog args)))
+  (p/schedule 0 #(rs/emit! (apply show-dialog args))))

 (defn close!
   []


Speed up validator (is array)

Speed up validator (is array)

--- src/whisper2cyanite/core.clj
+++ src/whisper2cyanite/core.clj
@@ -91,7 +91,6 @@
   [mstore pstore options tenant]
   (let [min-ttl (:min-ttl options default-min-ttl)
         validators [[#(not= %2 nil) "Point not found"]
-                    [#(sequential? %2) "Value is not an array"]
                     [#(= (count %2) 1) "Array size is not equal to 1"]
                     [#(= %1 (first %2)) "Values are not equal"]]]
     (reify


Fix validator

Fix validator

--- src/whisper2cyanite/core.clj
+++ src/whisper2cyanite/core.clj
@@ -161,7 +161,9 @@
         data (if (fetch-data? processor)
                (whisper/fetch-archive-seq-ra ra-file file archive from to) nil)
         series (if data (whisper/remove-nulls (:series data)) nil)]
-    (process-metrics processor rollup period retention points path file series)))
+    (when (not-empty series)
+      (process-metrics processor rollup period retention points path
+                       file series))))

 (defn- process-file
   "Process a file."


Fixed odd order patterns on wishes

Fixed odd order patterns on wishes

--- src/wishlistd/models/sql.clj
+++ src/wishlistd/models/sql.clj
@@ -49,7 +49,9 @@
   "Selects one wishlist row and all corresponding wish rows for a given code."
   (first
     (select wishlist (wishlist-fields)
-      (with wish (wish-fields))
+      (with wish
+        (wish-fields)
+        (order :id :asc))
       (where {:code code}))))

 (defn update-wishlist [{:keys [code] :as wl}]


Add example comment

Add example comment

--- src/aerobio/htseq/wgseq.clj
+++ src/aerobio/htseq/wgseq.clj
@@ -160,7 +160,21 @@
   (run-wgseq-comparison
    eid recipient "ComparisonSheet.csv" get-toolinfo template))

+
+
+
 (comment
+
+  (let [dirs (->> (get-comparison-files
+                   :wgseq
+                   "171202_NS500751_0065_AHYYG3BGX3"
+                   "T4-D39nonclone-ComparisonSheet.csv")
+                  (mapv last))
+        old (fs/join (get-exp-info "171202_NS500751_0065_AHYYG3BGX3" :out)
+                     "Old")]
+    (fs/move dirs old))
+
+

   (fs/dodir "/data1/NextSeq/TVOLab/KarenWGS012816/Fastq/Raw/"
             #(fs/re-directory-files % "Day4N2*.fastq.gz")


nullpo

nullpo

--- src/antlion_clojure/bot.clj
+++ src/antlion_clojure/bot.clj
@@ -490,7 +490,7 @@
   [{:keys [slack dynamodb res] :as opt}]
   (let [{:keys [user channel text]} res
         txt (some-> text (split #"\s+" 2) second)
-        matched-responses (filter #(matched-response? text %) (dynamodb/get-all-responses dynamodb))]
+        matched-responses (some->> (dynamodb/get-all-responses dynamodb) (filter #(matched-response? text %)))]
     (cond
       (and (slack/message-for-me? opt)
                (not (slack/message-from-me? opt)))


update example

update example

--- example/src/example/core.cljs
+++ example/src/example/core.cljs
@@ -15,9 +15,7 @@
    :text-align "center"
    :font "normal 18px sans-serif"})

-
 (def color (r/atom "#856dcf"))
-

 ;;; Rum
 (rumss/defstyled RumH1 :h1
@@ -27,7 +25,8 @@
    :margin-bottom :v-margin})

 (rum/defc RumTitle < rum/reactive []
-  [:div {:class (wrapper "8px")}
+  [:div {:class (wrapper "8px")
+         :css {:border-bottom (str "1px solid " @color)}}
    (RumH1 {:v-margin "8px"
            :color (rum/react color)}
           "Clojure Style Sheets for Rum")])


use config instead of env in handler

use config instead of env in handler

--- src/chat/server/handler.clj
+++ src/chat/server/handler.clj
@@ -18,9 +18,11 @@
             [braid.server.route.api :refer [api-private-routes
                                             api-public-routes]]
             [environ.core :refer [env]]
+            [braid.server.conf :refer [config]]
             ; requiring so mount sees state
             [chat.server.email-digest :refer [email-jobs]]))

+; NOT using config here, b/c it won't have started when this runs
 (if (= (env :environment) "prod")
   (do
     (require 'taoensso.carmine.ring)
@@ -38,7 +40,7 @@

 (defn assoc-cookie-conf [defaults]
   (-> defaults
-      (assoc-in [:session :cookie-attrs :secure] (= (env :environment) "prod"))
+      (assoc-in [:session :cookie-attrs :secure] (= (config :environment) "prod"))
       (assoc-in [:session :cookie-attrs :max-age] (* 60 60 24 7))
       (assoc-in [:session :store] session-store)))


Add event loop processing; add basic outline of a login process.

--- src/clj/om_sente/server.clj
+++ src/clj/om_sente/server.clj
@@ -22,28 +22,63 @@
   (println "user.dir" (System/getProperty "user.dir"))
   (str (System/getProperty "user.dir") path))

+(defn unique-id
+  "Return a really unique ID (for an unsecured session ID)."
+  []
+  (rand-int 10000))
+
+(defn index
+  "Handle index page request. Injects session uid if needed."
+  [req]
+  {:status 200
+   :session (if (get-in req [:session :uid])
+              (:session req)
+              (assoc (:session req) :uid (unique-id)))
+   :body (slurp "index.html")})
+
 (defroutes server
   (-> (routes
-       (GET  "/"   req {:status 200
-                        :session (assoc (:session req) :uid "test")
-                        :body (slurp "index.html")})
+       (GET  "/"   req (#'index req))
        (GET  "/qw" req (#'ring-ajax-get-ws req))
        (POST "/qw" req (#'ring-ajax-post   req))
        (r/files "/" {:root (root "")})
        (r/not-found "
Page not found. I has a sad!
"))
       h/site))

+(defmulti handle-event (fn [event ring-req] (first event)))
+
+(defmethod handle-event :test/echo
+  [[_ msg] req]
+  (chsk-send! (get-in req [:session :uid]) [:test/reply (str "<" msg ">")]))
+
+(defmethod handle-event :default
+  [_ req]
+  nil)
+
+;; :session/status -> :session/state :open / :secure
+;; :session/auth username password -> :auth/fail or :auth/success
+;; (updates session uid etc)
+
+(defmethod handle-event :session/status
+  [_ req]
+  (chsk-send! (get-in req [:session :uid])
+              [:session/state (if (get-in req [:session :token])
+                                :secure
+                                :open)]))
+
+(defmethod handle-event :session/auth
+  [[_ username password] req]
+  (chsk-send! (get-in req [:session :uid])
+              [(if (and (= "admin" username)
+                        (= "secret" password))
+                 :auth/succcess
+                 :auth/fail)]))
+
 (defn handle-data
   "Main event processor."
   [{:keys [client-uuid ring-req event] :as data}]
-  ;; right now we just echo back anything we receive
-  (println "handle-data" data)
-  (let [[ev-id & payload] event]
-    (case ev-id
-      :test/echo (do
-                   (chsk-send! "test" [:test/reply (first payload)])
-                   (println "sent reply"))
-      nil)))
+  (println data)
+  (handle-event event ring-req))

 (defn -main [& args]
   (println "starting -main")
@@ -56,3 +91,4 @@
     (kit/run-server #'server {:port port})))

 (println "server loaded")
+;; (-main)


Added a few ways to implement color (some commented out)

--- src/cljs/zetawar/views.cljs
+++ src/cljs/zetawar/views.cljs
@@ -308,6 +308,11 @@

 (defn faction-settings [{:as views-ctx :keys [conn dispatch translate]}]
   (with-let [faction (subs/faction-to-configure conn)
+             ;color (when @faction
+              ;       (-> @faction
+              ;           :faction/color
+              ;           name
+              ;           string/capitalize))
              selected-player-type (r/atom nil)
              hide-settings (fn [ev]
                              (when ev (.preventDefault ev))
@@ -324,7 +329,12 @@
                                  :on-hide hide-settings}
      [:> js/ReactBootstrap.Modal.Header {:close-button true}
       [:> js/ReactBootstrap.Modal.Title
-       (translate :configure-faction-title)]]
+       (str "Configure Faction: " ;color)]]
+            (when @faction
+              (-> @faction
+                  :faction/color
+                  name
+                  string/capitalize)))]]
      [:> js/ReactBootstrap.Modal.Body
       [:form
        [:div.form-group


Test-starts-with-2 and test-ends-with-2

Test-starts-with-2 and test-ends-with-2

--- test/hurvinek/utils_test.clj
+++ test/hurvinek/utils_test.clj
@@ -211,6 +211,15 @@
             true  (startsWith "Hello world!" "Hello")
             true  (startsWith "Hello world!" "H")
             true  (startsWith "Hello world!" ""))))
+
+(deftest test-starts-with-2
+    "Check the function hurvinek.utils/starts-with."
+    (testing "the function hurvinek.utils/starts-with."
+        (are [x y] (= x y)
+            false (startsWith "" "hello")
+            false (startsWith "" "Hello")
+            false (startsWith "" "H")
+            true  (startsWith "" ""))))

 (deftest test-starts-with-NPE
     "Check the function hurvinek.utils/starts-with."
@@ -228,6 +237,15 @@
             true  (endsWith "Hello world!" "!")
             true  (endsWith "Hello world!" ""))))

+(deftest test-ends-with-2
+    "Check the function hurvinek.utils/ends-with."
+    (testing "the function hurvinek.utils/ends-with."
+        (are [x y] (= x y)
+            false (endsWith "" "hello")
+            false (endsWith "" "Hello")
+            false (endsWith "" "H")
+            true  (endsWith "" ""))))
+
 (deftest test-ends-with-NPE
     "Check the function hurvinek.utils/ends-with."
     (testing "the function hurvinek.utils/ends-with."


Conflated reports.scheduler/get-executing-jobs and filter-executing-jobs into get-executing-jobs-by-key for semantic clarity.

--- reports/src/reports/scheduler.clj
+++ reports/src/reports/scheduler.clj
@@ -20,18 +20,14 @@
                           :baseURL baseURL} path}))
     (scheduler/delete-job (jobs/key reportId))))

-(defn- get-executing-jobs []
-  "Returns a list of executing jobs in the form of ^org.quartz.JobExecutionContext"
-  (.getCurrentlyExecutingJobs ^Scheduler @scheduler/*scheduler*))
-
-(defn- filter-executing-jobs [key]
-  "Filter the list of executing jobs by key (usually returns just 1 job)"
+(defn- get-executing-jobs-by-key [key]
+  "Get a list of executing jobs by key (usually returns just 1 job)"
   (filter #(= (.. ^JobExecutionContext % (getJobDetail) (getKey)) (jobs/key key))
-          (get-executing-jobs)))
+          (.getCurrentlyExecutingJobs ^Scheduler @scheduler/*scheduler*)))

 (defn- job-executing? [key]
   "Returns true if there is a running job for that particular key"
-  (if (empty? (filter-executing-jobs key)) false true))
+  (if (empty? (get-executing-jobs-by-key key)) false true))

 (defn- report-id [m]
   "Generates a unique identifier based on the map"


added restore order via keep-order

added restore order via keep-order

--- src/conexp/contrib/gui/editors/context_editor/util.clj
+++ src/conexp/contrib/gui/editors/context_editor/util.clj
@@ -472,6 +472,24 @@
          comp-inc (map (fn [x] [(obj-map (first x)) (att-map (second x))]) inc)]
     (make-context comp-obj comp-att comp-inc)))

+(defn- restore-order
+  "Takes obj-rows as a parameter and a corresponding list of object names
+   that shall take their respective position if available."
+  [old-obj-rows old-objs new-obj-rows obj-nbrs]
+  (let [new-obj-keys (set (filter string? (keys new-obj-rows)))]
+    (loop [ obj-rows new-obj-rows
+            old-objs (filter (fn [x] (contains? new-obj-keys x)) old-objs) ]
+      (if (empty? old-objs) obj-rows
+        (let [ obj (first old-objs)
+               target (old-obj-rows obj) ]
+          (if (contains? obj-nbrs target)
+            (let [ obj2 (obj-rows target)
+                   source (obj-rows obj)
+                   switched-rows (conj obj-rows {obj target target obj
+                                   obj2 source source obj2}) ]
+              (recur switched-rows (rest old-objs)))
+            (recur obj-rows (rest old-objs))))))))
+
 (defn make-editable-context
   "Takes an optional context as input and returns an appropriate
   editable-context structure that is bound to a compatible version of the
@@ -495,13 +513,25 @@
                           (zipmap (range 1 (+ 1 (count obj-sort))) obj-sort)))
                    (ref (make-one-to-many self))) ]
       (deliver self e-ctx)
-      e-ctx)))
+      e-ctx))
   ([context-in keep-order]
-    (let [ e-ctx (make-editable-contect context-in)
-           old-objs (filter string? (:obj-rows keep-order))
-           old-atts (filter string? (:attr-cols keep-order))
-           obj-nbrs (set (filter (comp not string?) (deref (:obj-rows e-ctx))))
-           att-nbrs (set (filter (comp not string?) (deref (:att-nbrs e-ctx))))]
+    (let [ e-ctx (make-editable-context context-in)
+           old-obj-rows (:obj-rows keep-order)
+           old-objs (filter string? (keys old-obj-rows))
+           old-attr-cols (:attr-cols keep-order)
+           old-atts (filter string? (keys old-attr-cols))
+           other-obj-rows (keys (deref (:obj-rows e-ctx)))
+           obj-nbrs (set (filter (comp not string?)
+                           other-obj-rows))
+           other-attr-cols (keys (deref (:att-nbrs e-ctx)))
+           att-nbrs (set (filter (comp not string?)
+                           other-attr-cols))
+           new-obj-rows (restore-order old-obj-rows old-objs
+                          other-obj-rows obj-nbrs)
+           new-attr-cols (restore-order old-attr-cols old-atts
+                           other-attr-cols att-nbrs) ]
+      (dosync (ref-set (:obj-rows e-ctx) new-obj-rows)
+        (ref-set (:attr-cols e-ctx) new-attr-cols))
       e-ctx)))


systems-toolbox v0.1.13-SNAPSHOT

systems-toolbox v0.1.13-SNAPSHOT

--- Clojure-Websockets/MainApp/project.clj
+++ Clojure-Websockets/MainApp/project.clj
@@ -7,7 +7,7 @@
                  [clojurewerkz/elastisch "2.2.0-beta2"]
                  [org.clojure/tools.logging "0.3.1"]
                  [com.matthiasnehlsen/inspect "0.1.12"]
-                 [matthiasn/systems-toolbox "0.1.12-SNAPSHOT"]
+                 [matthiasn/systems-toolbox "0.1.13-SNAPSHOT"]
                  [org.clojure/tools.namespace "0.2.10"]
                  [ch.qos.logback/logback-classic "1.1.2"]
                  [com.taoensso/sente "1.4.1"]


Add note on `default`

Add note on `default`

--- src/active/clojure/lens.cljc
+++ src/active/clojure/lens.cljc
@@ -166,7 +166,10 @@
   (if (= dflt v) nil v))

 (defn default
-  "Returns a lens that shows nil as the given default value, but does not change any other value."
+  "Returns a lens that shows nil as the given default value, but does
+  not change any other value. Note that this lens changed the type of
+  the underlying data from `Maybe a` to `a` and thus you must not
+  shove `nil` into it."
   [dflt]
   (xmap default-yank default-shove dflt))


more options for select

more options for select

--- src/er_cassandra/record.clj
+++ src/er_cassandra/record.clj
@@ -8,16 +8,29 @@
    [clj-uuid :as uuid]
    [er-cassandra.key :refer [make-sequential extract-key-equality-clause]]))

+;; low-level record-based cassandra statement generation and execution
+;;
+;; keys can be extracted from records, provided explicitly or mixed.
+;;
+;; execution is async and returns a manifold Deferred
+
 (defn select-statement
   "returns a Hayt select statement"

   ([table key record-or-key-value]
    (select-statement table key record-or-key-value {}))

-  ([table key record-or-key-value opts]
+  ([table
+    key
+    record-or-key-value
+    {:keys [columns only-if order-by limit]:as opts}]
    (let [key-clause (extract-key-equality-clause key record-or-key-value opts)]
      (h/select table
-               (h/where key-clause)))))
+               (h/where key-clause)
+               (when columns (apply h/columns columns))
+               (when only-if (h/only-if only-if))
+               (when order-by (h/order-by order-by))
+               (when limit (h/limit limit))))))

 (defn select
   "select records"
@@ -33,8 +46,10 @@

 (defn select-one
   "select a single record"
+
   ([session table key record-or-key-value]
    (select-one session table key record-or-key-value {}))
+
   ([session table key record-or-key-value opts]
    (d/chain (select session table key record-or-key-value opts)
             first)))


woooo render looking cleaner and hotter, shortcuts simpliar :+1:

--- src/bitsplit_cli/display.clj
+++ src/bitsplit_cli/display.clj
@@ -1,48 +1,34 @@
 (ns bitsplit-cli.display)

-(defn enumerate [things]
-    (map-indexed vector things))
-
-(defn address-info [[from addresses]]
-    {:address from
-     :to (apply merge
-            (for [[i info] (enumerate addresses)]
-                {(str i) info}))})
-
-(defn percent->string [big-dec]
+(defn show-percent [big-dec]
     (-> big-dec
         (* 100)
         (str "% ")))

-(defn- info->string [[index [address percent]]]
-    (str "    "
-         "(" index ") "
-         address " " (percent->string percent)
-         \newline))
-
-(defn- render-pair->string [[index info]]
-    (apply str "(" index ") "
-        (:address info)
-        \newline
-        (map info->string
-            (:to info))))
-
-(defn renderable->string [renderable]
-    (->> renderable
-        (map render-pair->string)
-        (apply str)))
-
-(defn splits->renderable [splits]
-    (apply merge
-        (for [[i addresses] (enumerate splits)]
-            {(str i) (address-info addresses)})))
-
 (def unique-index
     (let [index (atom 0)]
-    (memoize (fn [item] (swap! index inc)))))
+    (memoize (fn [_] (swap! index inc)))))

-(defn render [last-rendered splits]
-    (->> splits
-        splits->renderable
-        (reset! last-rendered)
-        renderable->string))+
+(defn- show-address [shortcuts address]
+    (let [i (unique-index address)]
+        (swap! shortcuts assoc (str i) address)
+        (str \( i \) " " address)))
+
+(defn- show-addresses [shortcuts [address percent]]
+    (str "    "
+        (show-address shortcuts address)
+        " "  (show-percent percent)
+        \newline))
+
+; todo given the existence of unique id, can do this in a very simple way
+(defn- show-splits [shortcuts [address children]]
+    (apply str
+        (show-address shortcuts address)
+        \newline
+        (map (partial show-addresses shortcuts) children)))
+
+
+(defn render [shortcuts splits]
+    (apply str
+        (map (partial show-splits shortcuts) splits)))


key accessor settings

key accessor settings

--- src/bluebell/utils/party.clj
+++ src/bluebell/utils/party.clj
@@ -27,10 +27,10 @@
      (fn
        ([] {:desc (str "(key-accessor " k ")")})
        ([obj]
-        (utils/implies req-on-get (contains? obj k))
+        (assert (utils/implies req-on-get (contains? obj k)))
         (get obj k))
        ([obj x]
-        (utils/implies req-on-assoc (contains? obj k))
+        (assert (utils/implies req-on-assoc (contains? obj k)))
         (assoc obj k x))))))

 (defn index-accessor


Removed java-primitives serialization.

Removed java-primitives serialization.

--- src/carbonite/JavaBridge.clj
+++ src/carbonite/JavaBridge.clj
@@ -11,4 +11,6 @@
   (default-registry))

 (defn -enhanceRegistry [registry]
-  (default-registry registry))
+  (doto registry
+    (register-serializers clojure-primitives)
+    (register-serializers (clojure-collections registry))))


default source for pedestal component's input set to environment config file

--- src/clj/hellhound/system.clj
+++ src/clj/hellhound/system.clj
@@ -46,5 +46,6 @@
   `(-> hellhound.core/default-system-structure
        ;; TODO: Pass the options from config file
        (hellhound.component.websocket/make-websocket-component {})
-       (hellhound.component.pedestal/make-pedestal-component {})
+       (hellhound.component.pedestal/make-pedestal-component
+         (hellhound.core/get-config :pedestal :service-map))
        ~@body))


shadow color

shadow color

--- src/clj/just_married/css.clj
+++ src/clj/just_married/css.clj
@@ -10,6 +10,7 @@
   {:amaranth "#E52B50"
    :white "#FFFFFF"
    :navy "#0e0e4c"
+   :light-grey "#DDDDDD"
    ;; :light-background "#dcdcdc"
    :light-background "#f9eef0"
    :dark-red "#8B0000"
@@ -156,7 +157,7 @@
    [:#map {:width map-width
            :height map-width
            :padding "15px"
-           :box-shadow "10px 10px 20px #999"
+           :box-shadow (format "10px 10px 20px %s" (:light-grey COLOR-PALLETTE))
            :border-radius "10px"}]

    [:.navbar__container (:desktop navbar-grid-config)


refactor layout function

refactor layout function

move head content to a separate function
add support for side-bar

--- src/clj_money/web/shared.clj
+++ src/clj_money/web/shared.clj
@@ -153,46 +153,55 @@
            [:div {:class (str "alert alert-" (name css-class))} message]))
        alerts))

+(defn- head
+  [page-title options]
+  [:head
+   [:meta  {:charset "utf-8"}]
+   [:meta  {:http-equiv "X-UA-Compatible" :content "IE=edge"}]
+   [:meta  {:name "viewport" :content "width=device-width, initial-scale=1"}]
+   "<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->"
+
+   [:meta  {:name "description" :content "Double-entry account system"}]
+   [:meta  {:name "author" :content "Doug Knight"}]
+   [:link  {:rel "icon" :href "../../favicon.ico"}]
+   [:title (str "clj-money - " (if-let [site-title (:site-title options)]
+                                 site-title
+                                 page-title))]
+
+   "<!-- jQuery -->"
+   [:script {:src "/js/jquery-3.1.0.min.js"}]
+   [:script {:src "/js/jquery-ui.min.js"}]
+   [:script {:src "/js/jquery-startup.js"}]
+   [:script {:src "/js/bootstrap.min.js"}]
+
+   "<!-- Bootstrap core CSS -->"
+   [:link {:rel "stylesheet" :href "/css/bootstrap.min.css"}]
+   [:link {:rel "stylesheet" :href "/css/bootstrap-theme.min.css"}]
+   [:link {:rel "stylesheet" :href "/css/jquery-ui.min.css"}]
+   [:link {:rel "stylesheet" :href "/css/jquery-ui.structure.min.css"}]
+   [:link {:rel "stylesheet" :href "/css/jquery-ui.theme.min.css"}]
+   [:link {:rel "stylesheet" :href "/css/clj-money.css"}]
+   ])
+
 (defn layout
   "Renders content inside a standard page template"
   [page-title options & content]
   (html5
     [:html {:lang "en"}
-     [:head
-      [:meta  {:charset "utf-8"}]
-      [:meta  {:http-equiv "X-UA-Compatible" :content "IE=edge"}]
-      [:meta  {:name "viewport" :content "width=device-width, initial-scale=1"}]
-      "<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->"
-
-      [:meta  {:name "description" :content "Double-entry account system"}]
-      [:meta  {:name "author" :content "Doug Knight"}]
-      [:link  {:rel "icon" :href "../../favicon.ico"}]
-      [:title (str "clj-money - " (if-let [site-title (:site-title options)]
-                                    site-title
-                                    page-title))]
-
-      "<!-- jQuery -->"
-      [:script {:src "/js/jquery-3.1.0.min.js"}]
-      [:script {:src "/js/jquery-ui.min.js"}]
-      [:script {:src "/js/jquery-startup.js"}]
-      [:script {:src "/js/bootstrap.min.js"}]
-
-      "<!-- Bootstrap core CSS -->"
-      [:link {:rel "stylesheet" :href "/css/bootstrap.min.css"}]
-      [:link {:rel "stylesheet" :href "/css/bootstrap-theme.min.css"}]
-      [:link {:rel "stylesheet" :href "/css/jquery-ui.min.css"}]
-      [:link {:rel "stylesheet" :href "/css/jquery-ui.structure.min.css"}]
-      [:link {:rel "stylesheet" :href "/css/jquery-ui.theme.min.css"}]
-      [:link {:rel "stylesheet" :href "/css/clj-money.css"}]
-      ]
+     (head page-title options)
      [:body
       (primary-nav (:entity options))
       [:div.container {:style "margin-top: 2em;"}
        (html
-         [:h1#page-title page-title]
-         (if-let [alerts (:alerts options)]
-           (render-alerts alerts))
-         content)]]]))
+         (let [side-bar (:side-bar options)]
+           [:div.row
+            [:div {:class (format "col-md-%s" (if side-bar 8 12))}
+             [:h1#page-title page-title]
+             (if-let [alerts (:alerts options)]
+               (render-alerts alerts))
+             content]
+            (if side-bar
+              [:div.col-md-4 side-bar])]))]]]))

 (defn- input-element
   [name value options]


Minor changes.

Minor changes.

--- src/cljc/flocking/rules.cljc
+++ src/cljc/flocking/rules.cljc
@@ -36,12 +36,6 @@
 (defn cohere [[pos _] {:keys [strength] } average-pos]
   (weighted-vec pos strength average-pos))

-;(defn align [[_ vel] {:keys [strength] } average-vel]
-;  (vec/scale (vec/sub average-vel vel) strength))
-
-;(defn cohere [[pos _] {:keys [strength] } average-pos]
-;  (vec/scale (vec/sub average-pos pos) strength))
-
 (defn gen-wander []
   { :direction (* 2 Math/PI (Math/random))
    :rate (Math/random)


remove redundant json parsing

remove redundant json parsing

--- src/cljs/clj_money/data.cljs
+++ src/cljs/clj_money/data.cljs
@@ -23,10 +23,7 @@
   (go (let [response (<! (http/get (path :entities) {:headers {"Content-Type" "application/json"
                                                                "Accept" "application/json"}}))]
         (if (= 200 (:status response))
-          (let [reader (transit/reader :json {:keywordize-keys true})]
-            (-> (transit/read reader (:body response))
-                keywordize-keys
-                callback))
+          (callback (:body response))
           (.log js/console "Unable to get the entities from the service" (:body response))))))

 (defn delete-entity


Extracted more configuration options

Extracted more configuration options

--- src/cljs/db_quiz/config.cljs
+++ src/cljs/db_quiz/config.cljs
@@ -9,10 +9,8 @@
              :missed "#333333"
              :player-1 "#fc4349"
              :player-2 "#2c3e50"}
-   :data {:sparql {:endpoint "http://cs.dbpedia.org/sparql"
-                   :classes {:default ["http://dbpedia.org/ontology/Person"
-                                       "http://dbpedia.org/ontology/Place"
-                                       "http://dbpedia.org/ontology/Work"]}}}
+   :data {:sparql {; Maximum number of results per query
+                   :page-size 5000}}
    :guess-similarity-threshold 0.94
    :layout {; Width of hexagon's border (in pixels)
             :border-width 1
@@ -26,5 +24,9 @@
             :space 8}
    :letters ["A" "B" "C" "Č" "D" "E" "F" "G" "H" "Ch" "I" "J" "K" "L"
              "M" "N" "O" "P" "R" "Ř" "S" "Š" "T" "U" "V" "W" "Z" "Ž"]
+   ; Maximum number of characters in a question
+   :max-question-length 500
    ; Available time for making a guess (in seconds)
-   :time-to-guess 30})
+   :time-to-guess 60
+   ; Time to display the correct answer (in seconds)
+   :verdict-display-time 5})


bug fix

bug fix

--- src/cljs/netrunner/auth.cljs
+++ src/cljs/netrunner/auth.cljs
@@ -119,10 +119,10 @@
 (defn auth-forms [cursor owner]
   (om/component
    (sab/html
-    (when-not (:user @app-state)
-      [:div
+    [:div
+     (when-not (:user @app-state)
        (om/build register-form cursor)
-       (om/build login-form cursor)]))))
+       (om/build login-form cursor))])))

 (om/root auth-menu app-state {:target (. js/document (getElementById "right-menu"))})
 (om/root auth-forms app-state {:target (. js/document (getElementById "auth-forms"))})


Tentative de résolution de problème de dépréciation MapBox

Qui casse toutes l'app

--- src/cljs/trottoirs/core.cljs
+++ src/cljs/trottoirs/core.cljs
@@ -28,7 +28,7 @@
                                                                       :stroke "red"}}))
                                           map))]
     (do
-      (identity (.addTo (.tileLayer js/L (str "http://{s}.tiles.mapbox.com/v4/laem.lihjhd1m/{z}/{x}/{y}.png?access_token=" token)
+      (identity (.addTo (.tileLayer js/L (str "https://api.mapbox.com/styles/v1/mapbox/light-v10/tiles/{z}/{x}/{y}?access_token=" token)
                         (clj->js {:attribution "Thks, mapbox"
                                   :maxZoom 19}))
             map))


Function to diff configurations.

Function to diff configurations.

--- src/clojure/parkour/conf.clj
+++ src/clojure/parkour/conf.clj
@@ -127,3 +127,14 @@
 (defmethod conf-coerce Map [val]
   (let [kv-str (fn [[k v]] (str (conf-coerce k) "=" (conf-coerce v)))]
     (str/join "," (map kv-str val))))
+
+(defn diff
+  "Map of updates from `conf` to `conf'`."
+  [conf conf']
+  (let [conf (configuration conf), conf' (configuration conf')]
+    (reduce (fn [diff key]
+              (let [val (get conf key), val' (get conf' key)]
+                (if (= val val')
+                  diff
+                  (assoc diff key val'))))
+            {} (set (mapcat keys [conf conf'])))))


Add helper for integral status codes.

Add helper for integral status codes.

--- src/clojure/parkour/tool.clj
+++ src/clojure/parkour/tool.clj
@@ -1,8 +1,25 @@
 (ns parkour.tool
-  (:require [parkour.conf :as conf]
-            [parkour.util :refer [coerce]])
+  (:require [clojure.tools.logging :as log]
+            [parkour.conf :as conf]
+            [parkour.util :refer [coerce returning]])
   (:import [org.apache.hadoop.conf Configuration Configurable]
            [org.apache.hadoop.util Tool ToolRunner]))
+
+(defn integral*
+  "Function form of the `integral` macro."
+  [f]
+  (try
+    (let [rv (f)]
+      (if (integer? rv) rv 0))
+    (catch Exception e
+      (returning -1
+        (log/error e "Uncaught exception:" (str e))))))
+
+(defmacro integral
+  "Evaluate `body` forms.  If the result of evaluation is an integral value,
+return it.  If the result is non-integral, return 0.  If evaluation throws an
+exception, return -1."
+  [& body] `(integral* (fn ^:once [] ~@body)))

 (deftype ParkourTool [^:unsynchronized-mutable ^Configuration conf, f]
   Configurable
@@ -11,9 +28,9 @@

   Tool
   (run [_ args]
-    (let [rv (conf/with-default conf
-               (apply f conf (seq args)))]
-      (cond (integer? rv) rv, rv 0, :else -1))))
+    (integral
+     (conf/with-default conf
+       (apply f conf (seq args))))))

 (defn tool
   "Hadoop `Tool` for function `f`, which should take a Hadoop


parse comments

parse comments

--- src/atom_finder/util/cdt_util.clj
+++ src/atom_finder/util/cdt_util.clj
@@ -9,11 +9,10 @@
         includePaths (make-array String 0)
         info (new ScannerInfo definedSymbols includePaths)
         log (new DefaultLogService)
-        ;savedIncludes (atom_finder.FileCodeReaderFactory/getInstance)
+        ;savedIncludes (atom_finder.FileCodeReaderFactory/getInstance) ; Compiling include files bloats the AST of each parsed file, and paradoxically reduces the proportion of correctly typed nodes, because of the AST size inflation.
         emptyIncludes (IncludeFileContentProvider/getEmptyFilesProvider)
         opts 8]

-    ;; TODO GCCLanguage would probably parse some files (like K&R declarations) better
     (.getASTTranslationUnit (GPPLanguage/getDefault) file-content
                             info emptyIncludes org.eclipse.cdt.internal.core.index.EmptyCIndex/INSTANCE opts log)))

@@ -27,7 +26,7 @@
         emptyIncludes (IncludeFileContentProvider/getEmptyFilesProvider)
         opts 8]

-    ;; TODO GCCLanguage would probably parse some files (like K&R declarations) better
+    ;; GCCLanguage parses some files (like K&R declarations) better
     (.getASTTranslationUnit (GCCLanguage/getDefault)
                             (FileContent/create "Anonymous CCCC file"
                                                 (.toCharArray source)) info emptyIncludes


look up things directly in the lexicon in (analyze)

--- src/babel/english/morphology.cljc
+++ src/babel/english/morphology.cljc
@@ -753,14 +753,18 @@
                             looked-up))))
                  (keys replace-pairs)))]

-    (concat
-     analyzed
+    ;; rethink how we retrieve lexical entries here: should we
+    ;; do additional analysis via analyzed-via-identity, or just look up directly
+    ;; with (get lexicon surface-form)? also, (set) is expensive due to need
+    ;; to check for duplicates.
+    (set
+     (concat
+      (or analyzed analyzed-via-identity)

      ;; also lookup the surface form itself, which
      ;; might be either the canonical form of a word, or an irregular conjugation of a word.
-     (if (not (empty? analyzed-via-identity))
-       analyzed-via-identity
-       (get lexicon surface-form)))))
+     (get lexicon surface-form)
+     ))))

 (def pronoun-semantic-gender-agreement
   (let [gender (atom :top)]


add title property to documents, remove name property

--- src/brainbot/nozzle/esconnect.clj
+++ src/brainbot/nozzle/esconnect.clj
@@ -19,31 +19,28 @@
 (def mapping-types
   {"doc" {:_all {:enabled false},
           :properties
-          {:name {:index "not_analyzed", :type "string", :store "yes"},
-           :parent {:index "not_analyzed", :type "string", :store "yes"},
-           :tags
-           {:index "not_analyzed",
-            :type "string",
-            :index_options "docs",
-            :store true,
-            :omit_norms true},
+          {:parent {:index "not_analyzed", :type "string", :store "yes"},
+           :tags {:index "not_analyzed",
+                  :type "string",
+                  :index_options "docs",
+                  :store true,
+                  :omit_norms true},
            :lastmodified {:type "date", :store "yes"},
            :content {:type "string", :store "yes"},
-           :deny_token_document
-           {:index "not_analyzed",
-            :type "string",
-            :store true,
-            :null_value "UNAUTHENTICATED"},
-           :allow_token_document
-           {:index "not_analyzed",
-            :type "string",
-            :store true,
-            :null_value "NOBODY"}},
+           :title   {:type "string", :store "yes"},
+
+           :deny_token_document {:index "not_analyzed",
+                                 :type "string",
+                                 :store true,
+                                 :null_value "UNAUTHENTICATED"},
+           :allow_token_document {:index "not_analyzed",
+                                  :type "string",
+                                  :store true,
+                                  :null_value "NOBODY"}},
           :_source {:enabled false}},
    "dir" {:_all {:enabled false},
           :properties
           {:lastmodified {:type "date", :store "yes"},
-           :name {:index "not_analyzed", :type "string", :store "yes"},
            :parent {:index "not_analyzed", :type "string", :store "yes"}},
           :_source {:enabled false}}})

@@ -178,6 +175,8 @@
   [fs es-index {:keys [directory entry] :as body} {publish :publish}]
   (let [parent-id (make-id "" directory)
         id (make-id "" directory (:relpath entry))
+        title (or (get-in body [:extract :tika-content :dc:title])
+                  (:relpath entry))
         simple-perms (simplify-permissions-for-es (:permissions entry))]

@@ -185,6 +184,7 @@
              id
              {:parent parent-id
               :content (get-in body [:extract :tika-content :text])
+              :title title
               :tags (get-tags-from-path directory)
               :allow_token_document (simple-perms true)
               :deny_token_document (simple-perms false)


always preserve persistentarraymap for ALL and MAP-VALS, also improve performance of those cases by almost 2x

--- src/clj/com/rpl/specter/navs.cljc
+++ src/clj/com/rpl/specter/navs.cljc
@@ -107,15 +107,18 @@
   #?(:clj
   (all-transform [structure next-fn]
     (let [k-it (.keyIterator structure)
-          v-it (.valIterator structure)]
-      (loop [ret {}]
+          v-it (.valIterator structure)
+          array (i/fast-object-array (* 2 (.count structure)))]
+      (loop [i 0]
         (if (.hasNext k-it)
           (let [k (.next k-it)
                 v (.next v-it)
                 [newk newv] (next-fn [k v])]
-            (recur (assoc ret newk newv)))
-          ret
-          )))))
+            (aset array i newk)
+            (aset array (inc i) newv)
+            (recur (+ i 2)))))
+      (clojure.lang.PersistentArrayMap. array)
+      )))

   #?(:cljs cljs.core/PersistentArrayMap)
   #?(:cljs
@@ -197,14 +200,18 @@
   #?(:clj
   (map-vals-transform [structure next-fn]
     (let [k-it (.keyIterator structure)
-          v-it (.valIterator structure)]
-      (loop [ret {}]
+          v-it (.valIterator structure)
+          array (i/fast-object-array (* 2 (.count structure)))]
+      (loop [i 0]
         (if (.hasNext k-it)
           (let [k (.next k-it)
-                v (.next v-it)]
-            (recur (assoc ret k (next-fn v))))
-          ret
-          )))))
+                v (.next v-it)
+                newv (next-fn v)]
+            (aset array i k)
+            (aset array (inc i) newv)
+            (recur (+ i 2)))))
+      (clojure.lang.PersistentArrayMap. array)
+      )))

   #?(:cljs cljs.core/PersistentArrayMap)
   #?(:cljs


add entities/entity?

add entities/entity?

--- src/clj_money/models/entities.clj
+++ src/clj_money/models/entities.clj
@@ -122,3 +122,7 @@
   [storage-spec id]
   (with-storage [s storage-spec]
     (delete-entity s id)))
+
+(defn entity?
+  [model]
+  (= :entity (authorization/get-resource-tag model)))


Fix card quantities being rendered

Fix card quantities being rendered

--- src/cljs/decktouch/card-list.cljs
+++ src/cljs/decktouch/card-list.cljs
@@ -26,9 +26,8 @@

 (defn card-in-list-component [card]
   (let [card-id (str (clojure.string/replace (get card "imageName") #"\W" "_"))]
-    (reagent/create-class {:render #(card-in-list card card-id)
-                           :component-did-mount #(card-in-list-did-mount card-id)
-                           })))
+    (with-meta #(card-in-list % card-id)
+               {:component-did-mount #(card-in-list-did-mount card-id)})))

 (defn is-card-of-type? [card type]
   (contains? (set (get card "types")) type))


fix page share link

fix page share link

--- src/cljs/salava/page/ui/view.cljs
+++ src/cljs/salava/page/ui/view.cljs
@@ -137,7 +137,7 @@
             (if (= @visibility-atom "public")
               (t :page/Public)
               (t :core/Publishandshare))]])
-        [:div {:class (str "share-wrapper " @visibility-atom) } [s/share-buttons (str (session/get :site-url) (path-for "/page/view/") (:id page)) (:name page) (= "public" (:visibility page)) false show-link-or-embed-atom]]]
+        [:div {:class (str "share-wrapper " @visibility-atom) } [s/share-buttons (str (session/get :site-url) (path-for "/profile/page/view/") (:id page)) (:name page) (= "public" (:visibility page)) false show-link-or-embed-atom]]]
        (admintool (:id page) "page"))
      [ph/view-page page]
      (if (:owner? page) "" (reporttool1 (:id page)  (:name page) "page"))]))


Catch parinfer errors caused by invalid numbers

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -278,11 +278,17 @@
   (set-font-size! text-area @font-size))

 (defn paren-mode [text x line]
-  (let [res (Parinfer/parenMode text (int x) (int line) nil false)]
+  (let [res (try
+              (Parinfer/parenMode text (int x) (int line) nil false)
+              (catch Exception _
+                (Parinfer/parenMode text (int 0) (int 0) nil false)))]
     {:x (.-cursorX res) :text (.-text res)}))

 (defn indent-mode [text x line]
-  (let [^ParinferResult res (Parinfer/indentMode text (int x) (int line) nil false)]
+  (let [res (try
+              (Parinfer/indentMode text (int x) (int line) nil false)
+              (catch Exception _
+                (Parinfer/indentMode text (int 0) (int 0) nil false)))]
     {:x (.-cursorX res) :text (.-text res)}))

 (defn get-cursor-position


Encode url query params only

Encode url query params only

--- src/hatti/views/photos.cljs
+++ src/hatti/views/photos.cljs
@@ -2,7 +2,7 @@
   (:require [chimera.js-interop :refer [format]]
             [cljsjs.photoswipe]
             [cljsjs.photoswipe-ui-default]
-            [clojure.string :refer [replace]]
+            [clojure.string :refer [replace split join]]
             [om.core :as om :include-macros true]
             [sablono.core :refer-macros [html]]
             [hatti.constants :as constants]
@@ -34,10 +34,17 @@
   "If not a fully qualified URL, remove the API namespace prefix from a URI
    string and convert to a fully qualified URL."
   [url]
-  (js/encodeURIComponent
-   (if (= (subs url 0 4) "http")
-     url
-     (remote/make-url (replace url #"/api/v1" "")))))
+  (let [string-vec (split url #"\?")
+        index 1
+        encoded-question-mark "%3F"
+        encoded-url
+        (join encoded-question-mark
+              (assoc string-vec
+                     index
+                     (js/encodeURIComponent (nth string-vec index))))]
+    (if (= (subs encoded-url 0 4) "http")
+      encoded-url
+      (remote/make-url (replace encoded-url #"/api/v1/" "")))))

 (defn- build-caption
   [item]


Add a problem. The description is rather verbose - it could probably use some work before we deploy this.

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -670,6 +670,19 @@
                     "(=  0 (reduce __ []))"
                     "(=  6 (reduce __ 1 [2 3]))"]})

+      (insert! :problems
+           {:_id 65
+            :title "Black box testing"
+            :times-solved 0
+            :description "Clojure has many sequence types, which act in subtly different ways. The core functions typically convert them into a uniform \"sequence\" type and work with them that way, but it can be important to understand the behavioral and performance differences so that you know which kind is appropriate for your application.
Write a function which takes a collection and returns one of :map, :set, :list, or :vector - describing the type of collection it was given.
You won't be allowed to inspect their class or use the built-in predicates like list? - the point is to poke at them and understand their behavior."
+            :tags ["medium" "seqs" "testing"]
+            :tests ["(= :map (__ {:a 1, :b 2}))"
+                    "(= :list (__ (range (rand-int 20))))"
+                    "(= :vector (__ [1 2 3 4 5 6]))"
+                    "(= :set (__ #{10 (rand-int 5)}))"]
+            :restricted (map str '[class type Class vector? sequential?
+                                   list? seq? map? set? getClass])})
+
       ))

-(load-problems)+(load-problems)


Added a test case to "Black Box Testing"

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -676,10 +676,11 @@
             :times-solved 0
             :description "Clojure has many collection types, which act in subtly different ways. The core functions typically convert them into a uniform \"sequence\" type and work with them that way, but it can be important to understand the behavioral and performance differences so that you know which kind is appropriate for your application.

Write a function which takes a collection and returns one of :map, :set, :list, or :vector - describing the type of collection it was given.
You won't be allowed to inspect their class or use the built-in predicates like list? - the point is to poke at them and understand their behavior."
             :tags ["medium" "seqs" "testing"]
-            :tests ["(= :map (__ {:a 1, :b 2}))"
-                    "(= :list (__ (range (rand-int 20))))"
-                    "(= :vector (__ [1 2 3 4 5 6]))"
-                    "(= :set (__ #{10 (rand-int 5)}))"]
+            :tests ["(= :map (__ {:a 1, :b 2}))",
+                    "(= :list (__ (range (rand-int 20))))",
+                    "(= :vector (__ [1 2 3 4 5 6]))",
+                    "(= :set (__ #{10 (rand-int 5)}))",
+                    "(= [:map :set :vector :list] (map __ [{} #{} [] ()]))"]
             :restricted (map str '[class type Class vector? sequential?
                                    list? seq? map? set? getClass])})


CMR-285: Fixed bug with page_size validation.

--- src/cmr/search/services/parameter_validation.clj
+++ src/cmr/search/services/parameter_validation.clj
@@ -26,7 +26,8 @@

              :else
              []))
-      (catch Exception e ["page_size must be a number between 1 and 2000"]))))
+      (catch Exception e ["page_size must be a number between 1 and 2000"]))
+    []))

 (defn unrecognized-params-validation
   "Validates that no invalid parameters were supplied"


remove old oarlock helmsman workaround

remove old oarlock helmsman workaround

--- src/galleon/applications.clj
+++ src/galleon/applications.clj
@@ -34,9 +34,7 @@
     :helmsman-context "navigator"
     :helmsman-definition navigator/helmsman-def}
    {:app-name "Oarlock"
-    :schema o-schema/schema
-    :helmsman-context "oarlock"
-    :helmsman-definition (fn [_] [])}
+    :schema o-schema/schema}
    {:app-name "Gangway"
     :start-fn! gangway.util/start-queues!
     :schema gangway.schema/gangway-schema


oldGen parsing and Computation added

oldGen parsing and Computation added

--- src/gc_parser/matcher_g1.clj
+++ src/gc_parser/matcher_g1.clj
@@ -109,17 +109,15 @@

 (defn oldOccup [yob yoa sb sa hob hoa]
-  (println (str "oldOccup:" yob yoa sb sa hob hoa ))
-  (let [oob  ( - ((toMB hob) (+ ((toMB yob) (toMB sb)))))
-        ooa  ( - ((toMB hoa) (+ ((toMB yoa) (toMB sa)))))]
-    (str oob ooa))
+  ;(println (str "oldOccup run:" yob ))
+  (let []
+    (join SEP [(- hob (+ yob sb)) ( - hoa (+ yoa sa)) ]))
+    ; (join SEP [oob ooa]))
 )

 (defn oldsize [ysb ysa sb sa hsb hsa]
-      (let [osb  ( - (hsb (+ (ysb sb))))
-            osa  ( - (hsa (+ (ysa sa))))]
-        (str osb osa))
-      (join SEP [osb osa])
+      (join SEP [( - hsb (+ ysb sb)) ( - hsa (+ ysa sa))
+                                  ])
 )

@@ -140,31 +138,25 @@
 ; PauseTime = G1 Evac does not report pause time separately, only in Times
 (defn process-g1-evac [entry]
   (let [[a ts yob ysb yoa ysa sb sa hob hsb hoa hsa ut kt rt & e] entry
-        ;oldGenOcc (oldOccup yob yoa sb sa hob hoa)
-        ;oldGenSize (oldsize ysb ysa sb sa hsb hsa)
+        oldGenOcc (oldOccup yob yoa sb sa hob hoa)
+        oldGenSize (oldsize ysb ysa sb sa hsb hsa)
         ]
-    ;(println (str "Hello process-g1-evac:" entry))
-    ;(println (str "   " ))
-    (join SEP [ts "g1evac" rt yob ysb yoa sb sa hob hsb hoa ut kt rt])))
-
-
+    (join SEP [ts "g1evac" rt yob ysb yoa sb sa hob hsb hoa oldGenOcc oldGenSize ut kt rt])))

 (defn process-g1-young [entry]
   (let [[a ts pt yob ysb yoa ysa sb sa hob hsb hoa hsa ut kt rt & e] entry
-        ;heaps (doall (map toMB [yob ysb yoa sb sa hob hsb hoa c]))
-       ; hh heaps
+        oldGenOcc (oldOccup yob yoa sb sa hob hoa)
+        oldGenSize (oldsize ysb ysa sb sa hsb hsa)
         ]
-    ;(println (str "g1-young:" entry))
-   ; (println (str "g1-young:"  heaps))
-    ;(println (str "   " ))
-    (join SEP [ts "g1young" pt yob  ysb yoa sb sa hob hsb hoa hsa ut kt rt])))
-    ;(join SEP [ts "g1young" pt (toMB yob) (toMB ysb)(toMB yoa) (toMB sb) (toMB sa) (toMB hob) (toMB hsb) (toMB hoa) ut kt rt])))
-    ;(join SEP [ts "g1young" pt (toMB yob) ysb (toMB yoa) (toMB sb) (toMB sa) (toMB hob) (toMB hsb) (toMB hoa) ut kt rt])))
-
-
+
+    (join SEP [ts "g1young" pt yob  ysb yoa sb sa hob hsb hoa hsa oldGenOcc oldGenSize ut kt rt])))
+
 (defn process-g1-mixed [entry]
-  (let [[a ts pt yob ysb yoa ysa sb sa hob hsb hoa hsa ut kt rt & e] entry]
-    (join SEP [ts "g1mixed" pt yob ysb yoa sb sa hob hsb hoa ut kt rt])))
+  (let [[a ts pt yob ysb yoa ysa sb sa hob hsb hoa hsa ut kt rt & e] entry
+        oldGenOcc (oldOccup yob yoa sb sa hob hoa)
+        oldGenSize (oldsize ysb ysa sb sa hsb hsa)
+        ]
+    (join SEP [ts "g1mixed" pt yob ysb yoa sb sa hob hsb hoa oldGenOcc oldGenSize ut kt rt])))

 (defn process-g1-conc-reg-start[entry]
     (let [[a ts ys ye ym hs he hm pt ut kt rt & e] entry]
@@ -207,5 +199,4 @@
   (let [[a ts hob hoa hsa pt & e] entry]
     ;(println (str "Hello process-g1-cleanup:" entry))
     ;(println (str "   " ))
-    (join SEP [ts "g1cleanup" pt " " " " " " " " " " " " " " hob hoa hsa])))
-
+    (join SEP [ts "g1cleanup" pt " " " " " " " " " " " " " " hob hoa hsa])))


Remove duplicate comment

Remove duplicate comment

--- src/graphql_clj/executor.clj
+++ src/graphql_clj/executor.clj
@@ -15,7 +15,7 @@
     (and variable-name (not (contains? variables variable-name))) (gerror/throw-error (format "Variable(%s) is missing from input variables." variable-name))
     :else (gerror/throw-error (format "Argument value is missing for argument (%s) (%s)." argument-name value))))

-(defn build-arguments [selection variables] ;; TODO: handle case when arguments are defined in field, but no argument provided.
+(defn build-arguments [selection variables]
   (->> selection :arguments (map (partial update-argument variables)) (into {})))

 (defn get-selection-name


Pacify kibit

Pacify kibit

--- src/grimoire/api/fs/read.clj
+++ src/grimoire/api/fs/read.clj
@@ -18,10 +18,10 @@
 (defmethod api/-list-groups ::fs/Config [config]
   (let [handle (io/file (:docs config))]
     (if (.isDirectory handle)
-      (-> (for [d     (.listFiles handle)
-                :when (.isDirectory d)]
-            (t/->Group (.getName d)))
-          succeed)
+      (succeed
+       (for [d     (.listFiles handle)
+             :when (.isDirectory d)]
+         (t/->Group (.getName d))))
       (fail "Could not find store directory"))))

 (defmethod api/-list-artifacts ::fs/Config [config thing]
@@ -30,12 +30,14 @@
         _      (assert thing)
         handle (impl/thing->handle config :else thing)]
     (if (.isDirectory handle)
-      (-> (for [d     (.listFiles handle)
-                :when (.isDirectory d)]
-            (t/->Artifact thing (.getName d)))
-          succeed)
-      (fail (str "No such group "
-                 (t/thing->path thing))))))
+      (succeed
+       (for [d     (.listFiles handle)
+             :when (.isDirectory d)]
+         (t/->Artifact thing (.getName d))))
+      (->> thing
+           t/thing->path
+           (str "No such group ")
+           fail))))

 (defmethod api/-list-versions ::fs/Config [config thing]
   (let [thing    (t/ensure-thing thing)
@@ -59,10 +61,10 @@
         _       (assert version)
         handle  (impl/thing->handle config :else version)]
     (if (.isDirectory handle)
-      (-> (for [d     (sort-by #(.getName %) (.listFiles handle))
-                :when (.isDirectory d)]
-            (t/->Platform version (.getName d)))
-          succeed)
+      (succeed
+       (for [d     (sort-by #(.getName %) (.listFiles handle))
+             :when (.isDirectory d)]
+         (t/->Platform version (.getName d))))
       (fail (str "No such version "
                  (t/thing->path thing))))))

@@ -73,10 +75,10 @@
         _        (assert platform)
         handle   (impl/thing->handle config :else platform)]
     (if (.isDirectory handle)
-      (-> (for [d     (.listFiles handle)
-                :when (.isDirectory d)]
-            (t/->Ns platform (.getName d)))
-          succeed)
+      (succeed
+       (for [d     (.listFiles handle)
+             :when (.isDirectory d)]
+         (t/->Ns platform (.getName d))))
       (fail (str "No such platform "
                  (t/thing->path thing))))))

@@ -87,10 +89,10 @@
         _         (assert namespace)
         handle    (impl/thing->handle config :else namespace)]
     (if (.isDirectory handle)
-      (-> (for [d     (.listFiles handle)
-                :when (.isDirectory d)]
-            (t/->Def namespace (.getName d)))
-          succeed)
+      (succeed
+       (for [d     (.listFiles handle)
+             :when (.isDirectory d)]
+         (t/->Def namespace (.getName d))))
       (fail (str "No such namespace "
                  (t/thing->path thing))))))

@@ -99,13 +101,13 @@
   (if-not (t/versioned? thing)
     (let [versions (api/thing->prior-versions config thing)]
       (if (succeed? versions)
-        (-> (for [thing (result versions)
-                  :let  [v (t/thing->name (t/thing->version thing))
-                         h (impl/thing->notes-handle config thing)]
-                  :when (.exists h)
-                  :when (.isFile h)]
-              (t/->Note thing, (.getPath h)))
-            succeed)
+        (succeed
+         (for [thing (result versions)
+               :let  [v (t/thing->name (t/thing->version thing))
+                      h (impl/thing->notes-handle config thing)]
+               :when (.exists h)
+               :when (.isFile h)]
+           (t/->Note thing, (.getPath h))))

         ;; versions is a Fail, pass it down
         versions))
@@ -119,13 +121,13 @@
   {:pre [(t/thing? thing)]}
   (let [versions (api/thing->prior-versions config thing)]
     (if (succeed? versions)
-      (-> (for [prior-thing (result versions)
-                :let        [v (t/thing->name (t/thing->version prior-thing))
-                             h (impl/thing->handle config :examples prior-thing)]
-                ex          (.listFiles h)
-                :when       (.isFile ex)]
-            (t/->Example thing, (.getPath ex)))
-          succeed)
+      (succeed
+       (for [prior-thing (result versions)
+             :let        [v (t/thing->name (t/thing->version prior-thing))
+                          h (impl/thing->handle config :examples prior-thing)]
+             ex          (.listFiles h)
+             :when       (.isFile ex)]
+         (t/->Example thing, (.getPath ex))))

       ;; versions is a Fail, pass it down
       versions)))
@@ -134,6 +136,7 @@
 ;;--------------------

 (defmethod api/-read-note ::fs/Config [config thing]
+  {:pre [(t/note? thing)]}
   (let [handle (impl/thing->notes-handle config (t/thing->parent thing))]
     (if (.exists handle) ;; guard against missing files
       (-> handle slurp succeed)
@@ -169,17 +172,17 @@
         current-version (t/thing->version thing)
         versions        (api/thing->prior-versions config thing)]
     (if (succeed? versions)
-      (-> (for [thing (result versions)
-                :let  [v (t/thing->name (t/thing->version thing))
-                       h (impl/thing->related-handle config thing)]
-                :when (.exists h)
-                :when (.isFile h)
-                line  (line-seq (io/reader h))
-                :let  [sym (read-string line)]]
-            (-> current-version
-                (t/->Ns  (namespace sym))
-                (t/->Def (name sym))))
-          succeed)
+      (succeed
+       (for [thing (result versions)
+             :let  [v (t/thing->name (t/thing->version thing))
+                    h (impl/thing->related-handle config thing)]
+             :when (.exists h)
+             :when (.isFile h)
+             line  (line-seq (io/reader h))
+             :let  [sym (read-string line)]]
+         (-> current-version
+             (t/->Ns  (namespace sym))
+             (t/->Def (name sym)))))

       ;; versions is a Fail, pass it down
       versions)))


Improve tests

Improve tests

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -15,31 +15,31 @@
                  )))
   (is (= "SELECT first,second FROM \"table-name\";"
          (select "table-name"
-                 (columns ["first" "second"]))))
+                 (columns "first" "second"))))

   (is (=  "SELECT * FROM foo WHERE foo='bar' AND moo>3 AND meh>4 AND baz IN (5,6,7);"
           (select :foo
-                  (where [[= :foo "bar"]
-                          [> :moo 3]
+                  (where [[:= :foo "bar"]
+                          [:> :moo 3]
                           [:> :meh 4]
                           [:in :baz [5 6 7]]
                           ]))))

   (is (=  "SELECT * FROM foo WHERE foo='bar' ORDER BY foo ASC;"
           (select :foo
-                  (order-by [(asc :foo)])
+                  (order-by (asc :foo))
                   (where [[= :foo "bar"]]))))

   (is (=  "SELECT * FROM foo WHERE foo='bar' ORDER BY foo ASC LIMIT 10;"
           (select :foo
-                  (order-by [(asc :foo)])
+                  (order-by (asc :foo))
                   (limit 10)
                   (where [[= :foo "bar"]]))))

   (is (=  "SELECT * FROM foo WHERE foo='bar' ORDER BY foo ASC LIMIT 10 ALLOW FILTERING;"
           (select :foo
                   (where [[= :foo "bar"]])
-                  (order-by [(asc :foo)])
+                  (order-by (asc :foo))
                   (limit 10)
                   (allow-filtering)
                   )))
@@ -65,66 +65,72 @@
                           (-> "longName"
                               ttl
                               (as "ttla")))
-                 (limit (? "limit"))))))
+                 (limit (? "limit")))))
+
+  (is (= "SELECT a,b,\"C\" FROM foo WHERE a IN ('127.0.0.1','127.0.0.3') AND \"C\"='foo' ORDER BY a ASC,b DESC LIMIT 42;";
+         (select :foo
+                 (columns "a"
+                          "b"
+                          (quote* "C"))
+                 (where [[:in :a ["127.0.0.1", "127.0.0.3"]]
+                         [:= (quote* "C") "foo"]])
+                 (order-by (asc :a)
+                           (desc :b))
+                 (limit (int 42)))))

-  ;; "SELECT a,b,\"C\" FROM foo WHERE a IN ('127.0.0.1','127.0.0.3') AND \"C\"='foo' ORDER BY a ASC,b DESC LIMIT 42;";
-  ;; select("a", "b", quote("C")).from("foo")
-  ;; .where(in("a", InetAddress.getByName("127.0.0.1"), InetAddress.getByName("127.0.0.3")))
-  ;; .and(eq(quote("C"), "foo"))
-  ;; .orderBy(asc("a"), desc("b"))
-  ;; .limit(42);
+  )

-  ;; "SELECT writetime(a),ttl(a) FROM foo ALLOW FILTERING;";
-  ;; select().writeTime("a").ttl("a").from("foo").allowFiltering();
+;; "SELECT writetime(a),ttl(a) FROM foo ALLOW FILTERING;";
+;; select().writeTime("a").ttl("a").from("foo").allowFiltering();

-  ;; "SELECT DISTINCT longName AS a,ttl(longName) AS ttla FROM foo WHERE k IN () LIMIT :limit;";
-  ;; select().distinct().column("longName").as("a").ttl("longName").as("ttla").from("foo").where(in("k")).limit(bindMarker("limit"));
+;; "SELECT DISTINCT longName AS a,ttl(longName) AS ttla FROM foo WHERE k IN () LIMIT :limit;";
+;; select().distinct().column("longName").as("a").ttl("longName").as("ttla").from("foo").where(in("k")).limit(bindMarker("limit"));

-  ;; "SELECT * FROM foo WHERE bar=:barmark AND baz=:bazmark LIMIT :limit;";
-  ;; select().all().from("foo").where().and(eq("bar", bindMarker("barmark"))).and(eq("baz", bindMarker("bazmark"))).limit(bindMarker("limit"));
+;; "SELECT * FROM foo WHERE bar=:barmark AND baz=:bazmark LIMIT :limit;";
+;; select().all().from("foo").where().and(eq("bar", bindMarker("barmark"))).and(eq("baz", bindMarker("bazmark"))).limit(bindMarker("limit"));

-  ;; "SELECT a FROM foo WHERE k IN ();";
-  ;; select("a").from("foo").where(in("k"));
+;; "SELECT a FROM foo WHERE k IN ();";
+;; select("a").from("foo").where(in("k"));

-  ;; "SELECT a FROM foo WHERE k IN ?;";
-  ;; select("a").from("foo").where(in("k", bindMarker()));
+;; "SELECT a FROM foo WHERE k IN ?;";
+;; select("a").from("foo").where(in("k", bindMarker()));

-  ;; "SELECT count(*) FROM foo;";
-  ;; select().countAll().from("foo");
+;; "SELECT count(*) FROM foo;";
+;; select().countAll().from("foo");

-  ;; "SELECT intToBlob(b) FROM foo;";
-  ;; select().fcall("intToBlob", column("b")).from("foo");
+;; "SELECT intToBlob(b) FROM foo;";
+;; select().fcall("intToBlob", column("b")).from("foo");

-  ;; "SELECT * FROM foo WHERE k>42 LIMIT 42;";
-  ;; select().all().from("foo").where(gt("k", 42)).limit(42);
+;; "SELECT * FROM foo WHERE k>42 LIMIT 42;";
+;; select().all().from("foo").where(gt("k", 42)).limit(42);

-  ;; "SELECT * FROM foo WHERE token(k)>token(42);";
-  ;; select().all().from("foo").where(gt(token("k"), fcall("token", 42)));
+;; "SELECT * FROM foo WHERE token(k)>token(42);";
+;; select().all().from("foo").where(gt(token("k"), fcall("token", 42)));

-  ;; "SELECT * FROM foo2 WHERE token(a,b)>token(42,101);";
-  ;; select().all().from("foo2").where(gt(token("a", "b"), fcall("token", 42, 101)));
+;; "SELECT * FROM foo2 WHERE token(a,b)>token(42,101);";
+;; select().all().from("foo2").where(gt(token("a", "b"), fcall("token", 42, 101)));

-  ;; "SELECT * FROM words WHERE w='):,ydL ;O,D';";
-  ;; select().all().from("words").where(eq("w", "):,ydL ;O,D"));
+;; "SELECT * FROM words WHERE w='):,ydL ;O,D';";
+;; select().all().from("words").where(eq("w", "):,ydL ;O,D"));

-  ;; "SELECT * FROM words WHERE w='WA(!:gS)r(UfW';";
-  ;; select().all().from("words").where(eq("w", "WA(!:gS)r(UfW"));
+;; "SELECT * FROM words WHERE w='WA(!:gS)r(UfW';";
+;; select().all().from("words").where(eq("w", "WA(!:gS)r(UfW"));

-  ;; Date date = new Date();
-  ;; date.setTime(1234325);
-  ;; "SELECT * FROM foo where d=1234325";
-  ;; select().all().from("foo").where(eq("d", date));
+;; Date date = new Date();
+;; date.setTime(1234325);
+;; "SELECT * FROM foo where d=1234325";
+;; select().all().from("foo").where(eq("d", date));

-  ;; "SELECT * FROM foo where b=0xCAFEBABE";
-  ;; select().all().from("foo").where(eq("b", Bytes.fromHexString("0xCAFEBABE")));
+;; "SELECT * FROM foo where b=0xCAFEBABE";
+;; select().all().from("foo").where(eq("b", Bytes.fromHexString("0xCAFEBABE")));

-  ;; select().countAll().from("foo").orderBy(asc("a"), desc("b")).orderBy(asc("a"), desc("b"));
-  ;; select().column("a").all().from("foo");
-  ;; select().column("a").countAll().from("foo");
-  ;; select().all().from("foo").limit(-42);
-  ;; select().all().from("foo").limit(42).limit(42);
+;; select().countAll().from("foo").orderBy(asc("a"), desc("b")).orderBy(asc("a"), desc("b"));
+;; select().column("a").all().from("foo");
+;; select().column("a").countAll().from("foo");
+;; select().all().from("foo").limit(-42);
+;; select().all().from("foo").limit(42).limit(42);


Use grid-id instead of id in UI.

Use grid-id instead of id in UI.

--- sonic-jam/src/sonic_jam/core.cljs
+++ sonic-jam/src/sonic_jam/core.cljs
@@ -219,14 +219,14 @@
                                                     (om/transact! cursor (fn [c] (assoc c "type" (:type state))))
                                                     (let [grid-id (new-id)
                                                           grid {"name" ""
-                                                                "id" grid-id
+                                                                "grid-id" grid-id
                                                                 "bpc" 1
                                                                 "tracks" []}]
                                                       (om/transact! cursor (fn [c] (assoc c
                                                                                "type" (:type state)
                                                                                "synth-params" {}
                                                                                "sample-params" {}
-                                                                                "id" grid-id)))
+                                                                                "grid-id" grid-id)))
                                                       (om/transact! (om/observe owner (grids))
                                                                     (fn [c] (assoc c (get grid "id") grid)))
                                                       (go (>! set-state-ch grid-id))))
@@ -293,7 +293,7 @@
                                     (dom/td nil (get %1 "fx"))
                                     (dom/td nil (om/build param-editor
                                                           {:cursor %1
-                                                          :id id
+                                                           :id id
                                                            :set-state-ch set-state-ch})))
                            cursor
                            (range))
@@ -488,7 +488,7 @@
                                                 :set-state-ch (:set-state-ch state)}))
                 (dom/td nil
                         (when (= "grid" (get cursor "type"))
-                          (let [id (get cursor "id")
+                          (let [id (get cursor "grid-id")
                                 sub-state {:set-state-ch (:set-state-ch state)
                                            :get-state-ch (:get-state-ch state)}]
                             (om/build grid-view id {:state sub-state})))))))))