Rename log2 alias in cookie to log

Rename log2 alias in cookie to log

Since it no longer uses clojure.tools.logging.

--- src/clojure/frereth_cp/client/cookie.clj
+++ src/clojure/frereth_cp/client/cookie.clj
@@ -7,8 +7,7 @@
             [frereth-cp.shared.bit-twiddling :as b-t]
             [frereth-cp.shared.constants :as K]
             [frereth-cp.shared.crypto :as crypto]
-            ;; FIXME: Refactor this to plain log
-            [frereth-cp.shared.logging :as log2]
+            [frereth-cp.shared.logging :as log]
             [frereth-cp.shared.specs :as specs]
             [frereth-cp.shared.serialization :as serial]
             [frereth-cp.util :as utils]
@@ -32,7 +31,7 @@
            ::shared/work-area
            ::state/server-security
            ::state/shared-secrets]
-    log-state ::log2/state
+    log-state ::log/state
     :as this}
    {:keys [::K/header
            ::K/client-extension
@@ -40,48 +39,48 @@
     ^bytes client-nonce-suffix ::K/client-nonce-suffix
     ^bytes cookie ::K/cookie
     :as rcvd}]
-  (let [log-state (log2/info log-state
-                             ::decrypt-actual-cookie
-                             "Getting ready to try to extract cookie"
-                             {::raw-cookie cookie
-                              ::human-readable (shared/bytes->string cookie)})
+  (let [log-state (log/info log-state
+                            ::decrypt-actual-cookie
+                            "Getting ready to try to extract cookie"
+                            {::raw-cookie cookie
+                             ::human-readable (shared/bytes->string cookie)})
         {^bytes text ::shared/text
          ^bytes working-nonce ::shared/working-nonce} work-area]
     (assert working-nonce (str "Missing nonce buffer amongst\n"
                                (keys work-area)
                                "\nin\n"
                                (keys this)))
-    (let [log-state (log2/info log-state
-                               ::decrypt-actual-cookie
-                               "Copying nonce prefix"
-                               {::src K/cookie-nonce-prefix
-                                ::dst working-nonce})]
+    (let [log-state (log/info log-state
+                              ::decrypt-actual-cookie
+                              "Copying nonce prefix"
+                              {::src K/cookie-nonce-prefix
+                               ::dst working-nonce})]
       (b-t/byte-copy! working-nonce K/cookie-nonce-prefix)
       (b-t/byte-copy! working-nonce
                       K/server-nonce-prefix-length
                       K/server-nonce-suffix-length
                       client-nonce-suffix)
-      (let [log-state (log2/info log-state
-                                 ::decrypt-actual-cookie
-                                 "Copying encrypted cookie"
-                                 {::target text
-                                  ::this this
-                                  ::my-keys (keys this)})]
+      (let [log-state (log/info log-state
+                                ::decrypt-actual-cookie
+                                "Copying encrypted cookie"
+                                {::target text
+                                 ::this this
+                                 ::my-keys (keys this)})]
         (b-t/byte-copy! text 0 K/cookie-frame-length cookie)
         (let [shared (::state/client-short<->server-long shared-secrets)]
           (when-not shared
             (throw (ex-info "Missing client-short<->server-long secret"
                             {::state/shared-secrets shared-secrets})))
-          (let [log-state (log2/info log-state
-                                     ::decrypt-actual-cookie
-                                     "Trying to decrypt"
-                                     {::shared/text  (b-t/->string text)
-                                      ::shared/working-nonce (b-t/->string working-nonce)
-                                      ::client-short<->server-long (b-t/->string shared)})]
+          (let [log-state (log/info log-state
+                                    ::decrypt-actual-cookie
+                                    "Trying to decrypt"
+                                    {::shared/text  (b-t/->string text)
+                                     ::shared/working-nonce (b-t/->string working-nonce)
+                                     ::client-short<->server-long (b-t/->string shared)})]
             ;; TODO: If/when an exception is thrown here, it would be nice
             ;; to notify callers immediately
             (try
-              (let [{log-state ::log2/state
+              (let [{log-state ::log/state
                      decrypted ::crypto/unboxed} (crypto/open-after log-state text 0 144 working-nonce shared)
                     {server-short-pk ::K/s'
                      server-cookie ::K/black-box
@@ -91,20 +90,20 @@
                                            ::server-cookie server-cookie)]
                 (assoc this
                        ::state/server-security server-security
-                       ::log2/state log-state))
+                       ::log/state log-state))
               (catch ExceptionInfo ex
                 (assoc this
-                       ::log2/state (log2/exception log-state
-                                                    ex
-                                                    ::decrypt-actual-cookie
-                                                    "Decryption failed"
-                                                    (.getData ex)))))))))))
+                       ::log/state (log/exception log-state
+                                                  ex
+                                                  ::decrypt-actual-cookie
+                                                  "Decryption failed"
+                                                  (.getData ex)))))))))))

 (defn decrypt-cookie-packet
   [{:keys [::shared/extension
            ::shared/packet
            ::state/server-extension]
-    log-state ::log2/state
+    log-state ::log/state
     :as this}]
   (when-not (= (count packet) K/cookie-packet-length)
     (let [err {::expected-length K/cookie-packet-length
@@ -113,20 +112,20 @@
                ;; Because the stack trace hides
                ::where 'shared.curve.client/decrypt-cookie-packet}]
       (throw (ex-info "Incoming cookie packet illegal" err))))
-  (let [log-state (log2/debug log-state
-                              ::decrypt-cookie-packet
-                              "Incoming packet that looks like it might be a cookie"
-                              {::raw-packet packet
-                               ::human-readable (shared/bytes->string packet)})
+  (let [log-state (log/debug log-state
+                             ::decrypt-cookie-packet
+                             "Incoming packet that looks like it might be a cookie"
+                             {::raw-packet packet
+                              ::human-readable (shared/bytes->string packet)})
         {:keys [::K/header
                 ::K/client-extension
                 ::K/server-extension]
          :as rcvd} (serial/decompose-array K/cookie-frame packet)
-        log-state (log2/info log-state
-                             ::decrypt-cookie-packet
-                             "Verifying that decrypted packet looks like a Cookie"
-                             {::raw-header header
-                              ::human-readable (shared/bytes->string header)})]
+        log-state (log/info log-state
+                            ::decrypt-cookie-packet
+                            "Verifying that decrypted packet looks like a Cookie"
+                            {::raw-header header
+                             ::human-readable (shared/bytes->string header)})]
     ;; Q: How accurate/useful is this approach?
     ;; (i.e. mostly comparing byte array hashes)
     ;; A: Not at all.
@@ -140,7 +139,7 @@
                (b-t/bytes= extension client-extension)
                (b-t/bytes= server-extension server-extension))
       (decrypt-actual-cookie (assoc this
-                                    ::log2/state log-state)
+                                    ::log/state log-state)
                              rcvd))))

 (s/fdef received-response
@@ -149,8 +148,8 @@
                      :cookie ::specs/network-packet)
         :ret any?)
 (defn received-response
-  [{log-state ::log2/state
-    :keys [::log2/logger]
+  [{log-state ::log/state
+    :keys [::log/logger]
     :as this}
    notifier
    {:keys [:host :message :port]
@@ -162,10 +161,10 @@
   ;; If they don't match, we need to discard this cookie
   ;; and go back to waiting (don't forget to reduce the
   ;; timeout based on elapsed time)
-  (let [log-state (log2/info log-state
-                             ::received-response
-                             "Possibly got a response from server"
-                             cookie)]
+  (let [log-state (log/info log-state
+                            ::received-response
+                            "Possibly got a response from server"
+                            cookie)]
     (if-not (or (= cookie ::drained)
                 (= cookie ::hello-response-timed-out))
       (if (= K/cookie-packet-length (count message))
@@ -184,16 +183,16 @@
                                                                          ::state/server-extension
                                                                          ::state/server-security
                                                                          ::state/shared-secrets])
-                                                           ::log2/state log-state
+                                                           ::log/state log-state
                                                            ::shared/packet message))]
             (let [this (into this decrypted)
                   {:keys [::shared/my-keys]} this
                   server-short (get-in this
                                        [::state/server-security
                                         ::specs/public-short])
-                  log-state (log2/debug log-state
-                                        ::cookie->vouch
-                                        "Managed to decrypt the cookie")]
+                  log-state (log/debug log-state
+                                       ::cookie->vouch
+                                       "Managed to decrypt the cookie")]
               (assert server-short (str "Missing ::specs/public-short among\n"
                                         (keys (::state/server-security this))
                                         "\namong bigger-picture\n"
@@ -205,55 +204,55 @@
                                    (crypto/box-prepare
                                     server-short
                                     (.getSecretKey my-short-pair)))
-                    log-state (log2/debug log-state
-                                          ::cookie->vouch
-                                          "Prepared shared short-term secret")]
+                    log-state (log/debug log-state
+                                         ::cookie->vouch
+                                         "Prepared shared short-term secret")]
                 (dfrd/success! notifier (assoc this
-                                               ::log2/state log-state
+                                               ::log/state log-state
                                                ::specs/network-packet cookie))))
-            (let [log-state (log2/warn log-state
-                                       ::received-response
-                                       "Unable to decrypt server cookie"
-                                       {::problem cookie})]
-              (dfrd/success! notifier (assoc this ::log2/state log-state))))
+            (let [log-state (log/warn log-state
+                                      ::received-response
+                                      "Unable to decrypt server cookie"
+                                      {::problem cookie})]
+              (dfrd/success! notifier (assoc this ::log/state log-state))))
           ;; TODO: Look into recovering from these
           (catch ExceptionInfo ex
-            (let [log-state (log2/exception log-state
-                                            ex
-                                            ::received-response
-                                            "High-level failure")
-                  log-state (log2/flush-logs! logger log-state)]
-              (dfrd/error! notifier (assoc this ::log2/state log-state))))
+            (let [log-state (log/exception log-state
+                                           ex
+                                           ::received-response
+                                           "High-level failure")
+                  log-state (log/flush-logs! logger log-state)]
+              (dfrd/error! notifier (assoc this ::log/state log-state))))
           (catch RuntimeException ex
-            (let [log-state (log2/exception log-state
-                                            ex
-                                            ::received-response
-                                            "Unexpected failure")
-                  log-state (log2/flush-logs! logger log-state)]
-              (dfrd/error! notifier (assoc this ::log2/state log-state))))
+            (let [log-state (log/exception log-state
+                                           ex
+                                           ::received-response
+                                           "Unexpected failure")
+                  log-state (log/flush-logs! logger log-state)]
+              (dfrd/error! notifier (assoc this ::log/state log-state))))
           (catch Exception ex
-            (let [log-state (log2/exception log-state
-                                            ex
-                                            ::received-response
-                                            "Low-level failure")
-                  log-state (log2/flush-logs! logger log-state)]
-              (dfrd/error! notifier (assoc this ::log2/state log-state))))
+            (let [log-state (log/exception log-state
+                                           ex
+                                           ::received-response
+                                           "Low-level failure")
+                  log-state (log/flush-logs! logger log-state)]
+              (dfrd/error! notifier (assoc this ::log/state log-state))))
           (catch Throwable ex
-            (let [log-state (log2/exception log-state
-                                            ex
-                                            ::received-response
-                                            "Serious Problem")
-                  log-state (log2/flush-logs! logger log-state)]
-              (dfrd/error! notifier (assoc this ::log2/state log-state)))))
-        (let [log-state (log2/warn log-state
-                                   ::received-response
-                                   "Invalid response. Just discard and retry"
-                                   {::problem cookie})]
-          (dfrd/success! notifier (assoc this ::log2/state log-state))))
-      (let [log-state (log2/warn log-state
-                                 ::received-response
-                                 "Server didn't respond to HELLO. Move on to next.")]
-        (dfrd/success! notifier (assoc this ::log2/state log-state))))))
+            (let [log-state (log/exception log-state
+                                           ex
+                                           ::received-response
+                                           "Serious Problem")
+                  log-state (log/flush-logs! logger log-state)]
+              (dfrd/error! notifier (assoc this ::log/state log-state)))))
+        (let [log-state (log/warn log-state
+                                  ::received-response
+                                  "Invalid response. Just discard and retry"
+                                  {::problem cookie})]
+          (dfrd/success! notifier (assoc this ::log/state log-state))))
+      (let [log-state (log/warn log-state
+                                ::received-response
+                                "Server didn't respond to HELLO. Move on to next.")]
+        (dfrd/success! notifier (assoc this ::log/state log-state))))))

 (defn hello-response-failed!
   [this failure]
@@ -279,11 +278,11 @@
     (do
       (send wrapper
             update
-            ::log2/state
-            #(log2/info %
-                        ::wait-for-cookie!
-                        "Sent to server"
-                        sent))
+            ::log/state
+            #(log/info %
+                       ::wait-for-cookie!
+                       "Sent to server"
+                       sent))
       (let [chan<-server (::state/chan<-server @wrapper)
             d (strm/try-take! chan<-server
                                 ::drained


Fixed bug in uniform-deletion (prev acted as if rate was inverted).

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -306,7 +306,7 @@
 given by uniform-deletion-rate."
   [ind {:keys [uniform-deletion-rate maintain-ancestors]}]
   (let [new-genome (filter identity
-                           (map #(if (< (lrand) uniform-deletion-rate) % nil)
+                           (map #(if (< (lrand) uniform-deletion-rate) nil %)
                                 (:genome ind)))]
     (make-individual :genome new-genome
                      :history (:history ind)


Fix typo

Fix typo

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -1103,7 +1103,7 @@

 (defn checks-autoconstructing-diversifying?
   [ind argmap]
-  (assoc in :diversifying
+  (assoc ind :diversifying
     (some (fn [instruction-map]
             (and (= (:instruction instruction-map) 'genome_autoconstructing)
                  (not (:silent instruction-map))))


Pass files to compile properly. Fixes #16.

--- src/leiningen/protobuf.clj
+++ src/leiningen/protobuf.clj
@@ -151,7 +151,7 @@
   "Compile protocol buffer files located in proto dir."
   ([project]
      (compile project (proto-files (io/file (or (:proto-path project) "proto")))))
-  ([project files]
+  ([project & files]
      (install project)
      (when (= "protobuf" (:name project))
        (fetch project)


(SERVER018) Fixed typo

(SERVER018) Fixed typo

--- test/puppetlabs/services/request_handler/request_handler_core_test.clj
+++ test/puppetlabs/services/request_handler/request_handler_core_test.clj
@@ -121,7 +121,7 @@
       (is (nil? (get req :client-cert)))
       (is (nil? (get req :client-cert-cn)))))

-  (testing "Setting the auth header to somethign other than 'SUCCESS' fails"
+  (testing "Setting the auth header to something other than 'SUCCESS' fails"
     (let [req (core/as-jruby-request
                 (puppet-server-config true)
                 {:request-method :GET


cider-nrepl auto injects and bump refactor-nrepl to 2.2

--- dot/lein/profiles.clj
+++ dot/lein/profiles.clj
@@ -2,8 +2,7 @@
  {:plugins [[lein-vanity "0.2.0" :exclusions [org.clojure/clojure]]
             [lein-ancient "0.6.5"]
             [jonase/eastwood "0.2.0"]
-            [cider/cider-nrepl "0.11.0-SNAPSHOT"]
-            [refactor-nrepl "2.0.0-SNAPSHOT"]]
+            [refactor-nrepl "2.2.0-SNAPSHOT"]]
   :dependencies [[slamhound "1.5.5"]
                  [org.clojure/tools.nrepl "0.2.12"]]
   :aliases {"slamhound" ["run" "-m" "slam.hound"]}}}


adding move-back route

adding move-back route

--- cartagena-engine/src/cartagena/server.clj
+++ cartagena-engine/src/cartagena/server.clj
@@ -19,6 +19,10 @@
              (let [{:keys [player icon from-space board discard-pile]} (:body req)]
                (response/response (engine/play-card player icon from-space board discard-pile))))

+           (POST "/move-back" req
+             (let [{:keys [player from-space board draw-pile discard-pile]} (:body req)]
+               (response/response (engine/move-back player from-space board draw-pile discard-pile))))
+
            (POST "/new-game" req
              (if-let [players (get (:body req) :players)]
                (response/response (engine/new-game! players))


group conditional-related functions together

--- src/babel/italiano/morphology/verbs.cljc
+++ src/babel/italiano/morphology/verbs.cljc
@@ -47,6 +47,54 @@
                              patterns-conditional))
         infinitive (get-in word [:italiano])]
     (first (do-replace-on infinitive unifying-patterns))))
+
+
+(defn regular-conditional-with-future-stem? [word]
+  ;; regular inflection of conditional with :future-stem
+  (and (= (get-in word [:infl]) :conditional)
+       (string? (get-in word '(:future-stem) :none))))
+
+(defn regular-conditional-with-future-stem [word]
+  (let [stem (get-in word '(:future-stem))
+        person (get-in word '(:agr :person))
+        number (get-in word '(:agr :number))
+        drop-e (get-in word '(:italiano :drop-e) false)]
+    (cond
+      (and (= person :1st) (= number :sing))
+      (str stem "ei")
+
+      (and (= person :2nd) (= number :sing))
+      (str stem "esti")
+
+      (and (= person :3rd) (= number :sing))
+      (str stem "ebbe")
+
+      (and (= person :1st) (= number :plur))
+      (str stem "emmo")
+
+      (and (= person :2nd) (= number :plur))
+      (str stem "este")
+
+      (and (= person :3rd) (= number :plur))
+      (str stem "ebbero"))))
+
+(defn regular-conditional [word]
+  (let [unifying-patterns
+        (mapcat #(when (not (= :fail (unify word
+                                            {:agr (:agr %)})))
+                   (:g %))
+                patterns-conditional)
+        infinitive (get-in word [:italiano])]
+    (let [conjugations (do-replace-on infinitive unifying-patterns)]
+      (if (empty? conjugations)
+        (throw (Exception. (str "no conjugation found for infinitive: " infinitive))))
+      (if (not (empty? (rest conjugations)))
+        (throw (Exception. (str "more than one conjugation found for infinitive:'" infinitive "': "
+                                (string/join "," (vec (set conjugations)))
+                                "; word: " (dag_unify.core/strip-refs word)
+                                "; unifying-patterns: " (string/join "," (map dag_unify.core/strip-refs
+                                                                              unifying-patterns))))))
+      (first conjugations))))

 ;; </conditional>

@@ -577,58 +625,6 @@
       (and (= person :3rd) (= number :plur))
       (str stem "anno"))))

-(defn regular-conditional-with-future-stem? [word]
-  ;; regular inflection of conditional with :future-stem
-  (and (= (get-in word [:infl]) :conditional)
-       (string? (get-in word '(:future-stem) :none))))
-
-(defn regular-conditional-with-future-stem [word]
-  (let [stem (get-in word '(:future-stem))
-        person (get-in word '(:agr :person))
-        number (get-in word '(:agr :number))
-        drop-e (get-in word '(:italiano :drop-e) false)]
-    (cond
-      (and (= person :1st) (= number :sing))
-      (str stem "ei")
-
-      (and (= person :2nd) (= number :sing))
-      (str stem "esti")
-
-      (and (= person :3rd) (= number :sing))
-      (str stem "ebbe")
-
-      (and (= person :1st) (= number :plur))
-      (str stem "emmo")
-
-      (and (= person :2nd) (= number :plur))
-      (str stem "este")
-
-      (and (= person :3rd) (= number :plur))
-      (str stem "ebbero"))))
-
-(defn regular-conditional? [word]
-  ;; regular inflection of conditional without :future-stem
-  (and (= (get-in word '(:infl)) :conditional)
-       (get-in word '(:italiano))))
-
-(defn regular-conditional [word]
-  (let [unifying-patterns
-        (mapcat #(when (not (= :fail (unify word
-                                            {:agr (:agr %)})))
-                   (:g %))
-                patterns-conditional)
-        infinitive (get-in word [:italiano])]
-    (let [conjugations (do-replace-on infinitive unifying-patterns)]
-      (if (empty? conjugations)
-        (throw (Exception. (str "no conjugation found for infinitive: " infinitive))))
-      (if (not (empty? (rest conjugations)))
-        (throw (Exception. (str "more than one conjugation found for infinitive:'" infinitive "': "
-                                (string/join "," (vec (set conjugations)))
-                                "; word: " (dag_unify.core/strip-refs word)
-                                "; unifying-patterns: " (string/join "," (map dag_unify.core/strip-refs
-                                                                              unifying-patterns))))))
-      (first conjugations))))
-
 (defn irregular-imperfect-1sing? [word]
   (and
    (= (get-in word '(:infl)) :imperfect)


updated source now in source reader

updated source now in source reader

--- src/clj/rksm/cloxp_cljs/ns/internals.clj
+++ src/clj/rksm/cloxp_cljs/ns/internals.clj
@@ -196,7 +196,7 @@
         ns-sym (symbol (namespace sym))
         file (or file (fm/find-file-for-ns-on-cp ns-sym))
         old-file-src (slurp file)
-        new-file-src (sf/updated-source sym info new-source old-src old-file-src)]
+        new-file-src (src-rdr/updated-source sym info new-source old-src old-file-src)]
     (spit file new-file-src)))

 (defn eval-and-update-meta!
@@ -225,7 +225,7 @@
     ; 1. update file and analyzed data
     (if write-to-file
       (when file
-        (let [new-file-src (sf/updated-source sym info new-source old-src old-file-src)]
+        (let [new-file-src (src-rdr/updated-source sym info new-source old-src old-file-src)]
           (spit file new-file-src)
           (analyze-cljs-ns! ns-name)
           (if *compile?*


fix toolbar main action

fix toolbar main action

--- src/cljs/swarmpit/component/toolbar.cljs
+++ src/cljs/swarmpit/component/toolbar.cljs
@@ -56,7 +56,7 @@
          :aria-label "split button"}
         (comp/button
           {:startIcon (:icon main-action)
-           :onClick   #(:onClick main-action)}
+           :onClick   (:onClick main-action)}
           (:name main-action))
         (comp/button
           {:color         "primary"


Add more example from section 5.1.5

Add more example from section 5.1.5

--- src/clojure_walkthrough/cjia/ch05_xx.clj
+++ src/clojure_walkthrough/cjia/ch05_xx.clj
@@ -30,6 +30,7 @@

 ;; Static Methods
 (Long/parseLong "12321") ;; 12321
+

 ;; calling with (Classname/staticMethod args*)

@@ -93,3 +94,37 @@
       (.set Calendar/SECOND 0)
       (.set Calendar/MILLISECOND 0))
     (.getTime calendar-obj)))
+
+;; 5.1.5 some useful Clojure macros when working with Java
+;; using `memfn` or 'member-as-function'
+;; Suppose we have the following
+(map (fn [x] (.getBytes x)) ["amit" "rob" "kyle"])
+
+;; Can be simplified to
+(map #(.getBytes %) ["amit" "rob" "kyle"])
+
+;; Using memfn
+(memfn GetBytes) ;; #function[clojure-walkthrough.cjia.ch05-xx/eval20313/fn--20314]
+
+(memfn ^String getBytes) ;; #function[clojure-walkthrough.cjia.ch05-xx/eval20323/fn--20324]
+
+;; Using it in our example above
+(map (memfn getBytes) ["amit" "rob" "kyle"]) ;; (#object["[B" 0x303317a5 "[B@303317a5"] #object["[B" 0x6a556a5b "[B@6a556a5b"] #object["[B" 0xdb9b2e7 "[B@db9b2e7"])N
+
+;; Using memfn on String object
+(.subSequence "Clojure" 2 5) ;; "oju"
+
+;; The equivalent form with optional type hints is
+((memfn ^String subSequence ^Long start ^Long end) "Clojure" 2 5) ;; "oju"
+
+;; Java bean - Note the result is map which is much easier to deal with in some instance
+(bean (Calendar/getInstance)) ;; {:weeksInWeekYear 53, :timeZone #object[sun.util.calendar.ZoneInfo 0x35e030c2 "sun.util.calendar.ZoneInfo[id=\"Australia/Melbourne\",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Melbourne,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]]"], :weekDateSupported true, :weekYear 2016, :lenient true, :time #inst "2016-04-25T05:52:43.490-00:00", :timeInMillis 1461563563490, :class java.util.GregorianCalendar, :firstDayOfWeek 1, :gregorianChange #inst "1582-10-15T00:00:00.000-00:00", :minimalDaysInFirstWeek 1}
+
+;; Array
+(def tokens (.split "clojure.in.action" "\\."))
+
+(alength tokens) ;; 3
+
+(aget tokens 2) ;; "action"
+
+(aset tokens 2 "actionable") ;; "actionable"


GAWB-1694: Keywordizing stuff

GAWB-1694: Keywordizing stuff

--- src/cljs/main/broadfcui/common.cljs
+++ src/cljs/main/broadfcui/common.cljs
@@ -178,7 +178,7 @@

 (def set-type->membership-attribute
   {"participant_set" "participants"
-   "sample_set" :samples
+   "sample_set" "samples"
    "pair_set" "pairs"})

 ; The list of all access levels in the system, inclusive of roles that aren't directly assignable
@@ -200,7 +200,7 @@
     (cond (= entity-type root-entity-type) 1
           ;; example: entity is 'sample_set', RET is 'sample', presumably using expression 'this.samples'
           (= entity-type (singular-type->set-type root-entity-type))
-          (count (get-in entity [:attributes (set-type->membership-attribute entity-type) :items]))
+          (count (get-in entity [:attributes (keyword (set-type->membership-attribute entity-type)) :items]))
           ;; something nonsensical has been selected, submission will probably fail anyway:
           :else 1)))


Style fix.

Style fix.

--- src/com/lemondronor/turboshrimp.clj
+++ src/com/lemondronor/turboshrimp.clj
@@ -156,4 +156,3 @@

 (defn get-nav-data [drone]
   (:nav-data drone))
-


Implement seamless abortion of attribute exploration

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/fca/exploration/repl.clj
+++ src/conexp/fca/exploration/repl.clj
@@ -35,12 +35,14 @@
     (filter #(.startsWith (str %) str-query)
             (remove #{:default} (keys (methods run-repl-command))))))

+(def ^:private abortion-sentinal (Exception. "You should never see this"))
+
 (defn- eval-command
   "Runs the given REPL command query with state, in the case the query uniquely determines
   a command.  If not, an error message is printed and state is returned."
   [query state]
   (if (= query 'abort)
-    (throw (Exception. "Abnormal abortion from attribute exploration"))
+    (throw abortion-sentinal)
     (let [suitable-methods (suitable-repl-commands query)]
       (cond
        (second suitable-methods)
@@ -86,12 +88,17 @@
                              (print-str (:implication initial-state))
                              " hold? "))
     (println "Then please provide a counterexample")
-    (loop [counterexamples []]
-      (let [counterexample  (counterexample-from-expert initial-state result-fns),
-            counterexamples (conj counterexamples counterexample)]
-        (if (yes-or-no? "Do you want to give another counterexample? ")
-          (recur counterexamples)
-          counterexamples)))))
+    (try
+      (loop [counterexamples []]
+        (let [counterexample  (counterexample-from-expert initial-state result-fns),
+              counterexamples (conj counterexamples counterexample)]
+          (if (yes-or-no? "Do you want to give another counterexample? ")
+            (recur counterexamples)
+            counterexamples)))
+      (catch Exception e
+        (if (identical? e abortion-sentinal)
+          :abort
+          (throw))))))

 (defn counterexamples-via-repl
   "Starts a repl for counterexamples, which must be specified completely."


Add and update ClojureDocs for byte_array_conversion.clj.

--- src/dsbdp/byte_array_conversion.clj
+++ src/dsbdp/byte_array_conversion.clj
@@ -51,24 +51,27 @@
   (ByteArrayHelper/getInt32BigEndian ba idx))

 (defn timestamp
-  "Get the (pcap) timestamp value of the four bytes starting at index idx in the byte-array ba."
+  "Get the (pcap) timestamp long value starting at index idx in the byte-array ba."
   [ba idx]
   (+ (* (ByteArrayHelper/getInt32 ba idx) 1000000000) (* (ByteArrayHelper/getInt32 ba (+ idx 4)) 1000)))

 (defn timestamp-be
-  "Get the (pcap) big endian timestamp value of the four bytes starting at index idx in the byte-array ba."
+  "Get the (pcap) big endian timestamp long value starting at index idx in the byte-array ba."
   [ba idx]
   (+ (* (ByteArrayHelper/getInt32BigEndian ba idx) 1000000000) (* (ByteArrayHelper/getInt32BigEndian ba (+ idx 4)) 1000)))

 (defn eth-mac-addr-str
+  "Starting at index idx of the byte array ba, convert the following bytes into the Ethernet MAC address String representation."
   [ba idx]
   (ByteArrayHelper/getEthMacAddrString ba idx))

 (defn ipv4-addr-str
+  "Starting at index idx of the byte array ba, convert the following bytes into the IPv4 address String representation."
   [ba idx]
   (ByteArrayHelper/getIpv4AddrString ba idx))

 (defn timestamp-to-str
+  "Convert a timestamp from its Long value to a formatted String."
   [ts]
   (->
     (SimpleDateFormat. "yyyy-MM-DD_HH:mm:ss")
@@ -77,14 +80,18 @@
         (long (/ ts 1000000))))))

 (defn timestamp-str
+  "Get the (pcap) timestamp String represenation starting at index idx in the byte-array ba."
   [ba idx]
   (timestamp-to-str (timestamp ba idx)))

 (defn timestamp-str-be
+  "Get the (pcap) big endian timestamp String representation starting at index idx in the byte-array ba."
   [ba idx]
   (timestamp-to-str (timestamp-be ba idx)))

 (defn ba-to-str
+  "Convert a byte array ba into a String representation, interpreting the ba content as ASCII values.
+   Starts at index idx and converts the number of len bytes."
   [ba idx len]
   (ByteArrayHelper/byteArrayToString ba idx len))


[#384] [Server] Fix typo in `run-server` doc-string (@dsdolzhenko)

--- src/org/httpkit/server.clj
+++ src/org/httpkit/server.clj
@@ -23,7 +23,7 @@
     :max-ws             ; Max websocket message size
     :max-line           ; Max http inital line length
     :proxy-protocol     ; Proxy protocol e/o #{:disable :enable :optional}
-    :worker-name-prefix ; Woker thread name prefix
+    :worker-name-prefix ; Worker thread name prefix
     :worker-pool        ; ExecutorService to use for request-handling (:thread,
                           :worker-name-prefix, :queue-size are ignored if set)
     :error-logger       ; Arity-2 fn (args: string text, exception) to log errors


Do setup within test

Do setup within test

--- spec/cljs/iframe_app/core_test.cljs
+++ spec/cljs/iframe_app/core_test.cljs
@@ -28,8 +28,7 @@
 (def p println)

-(def dummy-ticket-fields
-  (first (gen/sample ticket-fields-gen 1)))
+

 (defn get-master-field-element [field]
   (sel1 (str "a.master-field[data-id='" (:id field) "']")))
@@ -57,13 +56,6 @@

-; what does it do to state? what should app-state be after a given action?
-; for each action, there should be a function that takes app-state and
-; the action (incl arg) and returns the new app-state
-
-; e.g. select-master-field will change selections to reset the others and
-;
-
 (defn behave [[behaviour-name arg]]
   (when-let [action (:element-getter (behaviour->action behaviour-name))]
     (action arg)))
@@ -85,103 +77,60 @@
   (reductions (fn [state {:keys [transform-fn value]}]
                 (transform-fn state value))
               {:master-field nil
-               :field-value nil
+               :field-value  nil
                :slave-fields #{}}
               (map (fn [[behaviour-name value :as behaviour]]
                      {:transform-fn (:transform (behaviour->action behaviour-name))
                       :value        value})
                    behaviours)))

+
+(defn dummy-behaviour [ticket-fields]
+  (let [master-field (rand-nth ticket-fields)
+        field-value (rand-nth (:possible-values master-field))
+        slave-field (rand-nth (fields-without-field ticket-fields
+                                                    master-field))]
+    [[:select-master-field master-field],
+     [:select-field-value field-value],
+     [:select-slave-field slave-field]]))
+
+(defn setup-app [ticket-fields]
+  (.appendChild (.-body js/document)
+                (let [element (.createElement js/document "div")
+                      _ (set! (.-id element) "app")]
+                  element))
+  (om/root app
+           app-state
+           {:target (. js/document (getElementById "app"))
+            :shared {:pick-channel  (chan)
+                     :ticket-fields ticket-fields}}))
+
 (deftest ^:async declarative
   ; TODO: replace these dummy fields with generators
-  (let [master-field (rand-nth dummy-ticket-fields)
-        field-value (rand-nth (:possible-values master-field))
-        slave-field (rand-nth (fields-without-field dummy-ticket-fields
-                                                    master-field))
-        behaviours [[:select-master-field master-field],
-                    [:select-field-value field-value],
-                    [:select-slave-field slave-field]]
-        states (get-states-for-behaviors behaviours)
-        behaviours-with-state-afterwards (map vector behaviours (rest states))]
+  (let [ticket-fields (first (gen/sample ticket-fields-gen))
+        behaviour (dummy-behaviour ticket-fields)
+        states (get-states-for-behaviors behaviour)
+        behaviours-with-state-afterwards (map vector behaviour (rest states))]

+    (setup-app ticket-fields)
     (go
       (doseq [[behaviour after-state] behaviours-with-state-afterwards]
         (behave behaviour)
         (wait-a-bit)

+
         (is (selection-state-matches? after-state))
         (is (state-matches-dom? after-state)))
+      (dommy/set-html! (.-body js/document) "")
       (done))))
+

 (set! (.-onload js/window)
       (fn []
-        (.appendChild (.-body js/document)
-                      (let [element (.createElement js/document "div")
-                            _ (set! (.-id element) "app")]
-                        element))
-        ; instantiate app component with dummy data
-        ; click on some of the things
-        ; test some stuff =)
-        (om/root app
-                 app-state
-                 {:target (. js/document (getElementById "app"))
-                  :shared {:pick-channel  (chan)
-                           :ticket-fields dummy-ticket-fields}})
         (t/run-all-tests)
         (js/setTimeout
           (fn []
             (.callPhantom js/window "exit"))
           3000)))
-
-;
-;(deftest ^:async can-make-condition
-;  (let [element->value-as-number #(-> %
-;                                      (dommy/attr :value)
-;                                      string->int)
-;        master-field-el (first (sel "div.field-list a.field"))
-;        master-field-id (element->value-as-number master-field-el)]
-;    (go
-;      (click master-field-el)
-;      (println "just clicked master field")
-;      (wait-a-bit)
-;
-;      (is (= "active" (dommy/class (dommy/parent master-field-el))))
-;
-;      (let [value-element (first (sel :a.value))
-;            value-element-value (dommy/attr value-element :value)
-;            _ (do (click value-element)
-;                  (println "just clicked value element")
-;                  (wait-a-bit)
-;                  (is (= "active" (dommy/class (dommy/parent value-element)))))
-;            slave-field-elements (take 2 (sel :.selectedField))
-;
-;            _ (do (is (not (empty? slave-field-elements)))
-;                  (doseq [slave-field slave-field-elements]
-;                    (click slave-field)
-;                    (println "just clicked a slave field")
-;                    (wait-a-bit))
-;                  (wait-a-bit)
-;                  (doseq [slave-field slave-field-elements]
-;                    (is (.contains (dommy/class slave-field) "assigned"))))
-;
-;            _ (println (:conditions @app-state))
-;
-;            ; just to make sure it doesn't add new conditions
-;            second-value-element (second (sel :a.value))
-;            _ (do
-;                (click second-value-element)
-;                (wait-a-bit))
-;
-;
-;            slave-field-element-ids (->> slave-field-elements
-;                                         (map element->value-as-number)
-;                                         set)
-;
-;            condition (first (:conditions @app-state))]
-;        (is (and (= master-field-id (:id (:master-field condition)))
-;                 (= value-element-value (:value (:field-value condition)))
-;                 (= slave-field-element-ids (set (map :id (:slave-fields condition)))))))
-;      (done))))
-;


specs.types: Move type hints to the top of the namespace

--- src/main/workflo/macros/specs/types.cljc
+++ src/main/workflo/macros/specs/types.cljc
@@ -51,6 +51,19 @@
 (s/def ::bytes bytes?)
 (s/def ::enum keyword?)

+;;;; Type options
+
+(s/def ::unique-value any?)
+(s/def ::unique-identity any?)
+(s/def ::indexed any?)
+(s/def ::fulltext any?)
+(s/def ::component any?)
+(s/def ::no-history any?)
+
+;;;; Types whose values are not to be persisted
+
+(s/def ::non-persistent any?)
+
 ;;;; Entity IDs

 (s/def ::id any?)
@@ -95,16 +108,3 @@
   [spec]
   (merge {:entity (val-after (s/describe spec) 'entity-ref)}
          (entity-ref-opts spec)))
-
-;;;; Type options
-
-(s/def ::unique-value any?)
-(s/def ::unique-identity any?)
-(s/def ::indexed any?)
-(s/def ::fulltext any?)
-(s/def ::component any?)
-(s/def ::no-history any?)
-
-;;;; Types whose values are not to be persisted
-
-(s/def ::non-persistent any?)


Add stereo-player doc string.

Add stereo-player doc string.

--- src/overtone/sc/sample.clj
+++ src/overtone/sc/sample.clj
@@ -23,12 +23,13 @@
                                  FREE))))))

     (defsynth stereo-player
+      "Plays a dual channel audio buffer."
       [buf 0 rate 1.0 start-pos 0.0 loop? 0 vol 1]
       (let [rate (* rate (buf-rate-scale:kr buf))]
-       (out 0
-           (* vol (play-buf 2 buf rate
-                            1 start-pos loop?
-                            FREE)))))))
+        (out 0
+             (* vol (play-buf 2 buf rate
+                              1 start-pos loop?
+                              FREE)))))))

 (defonce loaded-samples* (ref {}))


Bugfix: locate-defs-in-module needs into {}

--- src/oxcart/passes/defs.clj
+++ src/oxcart/passes/defs.clj
@@ -26,6 +26,7 @@
   (->> (for [form (:forms module)
              :when (pattern/def? form)]
          [(pattern/def->symbol form) form])
+       (into {})
        (assoc module :symbols)))


Made fallback-line-number private.

Made fallback-line-number private.

--- src/midje/parsing/util/file_position.clj
+++ src/midje/parsing/util/file_position.clj
@@ -12,8 +12,7 @@
 ;; For annotating forms with information retrieved at runtime.
 ;; For reporting syntax errors

-;; TODO: Make private.
-(def fallback-line-number (atom (Integer. 0)))
+(def ^:private fallback-line-number (atom (Integer. 0)))

 (defn set-fallback-line-number-from [form]
   (reset! fallback-line-number (or (:line (meta form)) (Integer. 0))))


when system does not exists we get back a nil value

--- src/proxmox/generators.clj
+++ src/proxmox/generators.clj
@@ -13,12 +13,12 @@

 (defn ct-exists [id node]
   (try+
-    (prox-get (<< "/nodes/~{node}/openvz/~{id}/status/current")) true
+    (prox-get (<< "/nodes/~{node}/openvz/~{id}/status/current"))
     (catch [:status 500] e false)))

 (defn qm-exists [id node]
   (try+
-    (prox-get (<< "/nodes/~{node}/qemu/~{id}/status/current")) true
+    (prox-get (<< "/nodes/~{node}/qemu/~{id}/status/current"))
     (catch [:status 500] e false)))

 (defn try-gen


as-is now, lists-comparison fail https://gist.github.com/4691902

--- src/runtime/testengine.clj
+++ src/runtime/testengine.clj
@@ -2,24 +2,38 @@
   (:use clojure.test)
   )

-(defmacro isthrown?
-  [cls & restt]
-  (list
-    `is
-    (let [tocls (eval cls)]
-      `(
-         ~'thrown? ;thanks Anderkent for unquote-quote here
-         ~tocls
-         ~@restt
+(def ^:private a RuntimeException)
+(defn ^:private b [] (throw (RuntimeException. "1")))
+
+(with-test
+  (defmacro isthrown?
+    [cls & restt]
+    (let [tocls (eval cls)]
+      `(is
+         (
+           ~'thrown? ;thanks Anderkent for unquote-quote here
+           ~tocls
+           ~@restt
+           )
          )
       )
     )
+  (is (thrown? java.lang.RuntimeException (b)))
+  (isthrown? a (b))
+  (is (=
+        (macroexpand-1
+          '(isthrown? a (throw (RuntimeException. "1")))
+          )
+        '(clojure.test/is (thrown? java.lang.RuntimeException (throw (RuntimeException. "1"))))
+        ))
+
   )

-(def a RuntimeException)

-(macroexpand-1
-  '(isthrown? a (throw (RuntimeException. "1")))
-)
+;(macroexpand-1
+;  '(isthrown? a (throw (RuntimeException. "1")))
+;)
+;=
+;(clojure.test/is (thrown? java.lang.RuntimeException (throw (RuntimeException. "1"))))

-;(isthrown? a (throw (RuntimeException. "1")))+


(PDB-5022) start-puppetdb: remove extraneous trs statement

--- src/puppetlabs/puppetdb/cli/services.clj
+++ src/puppetlabs/puppetdb/cli/services.clj
@@ -894,7 +894,6 @@
                        :clean-lock (ReentrantLock.))]

     (when (> (count write-dbs-config) 1)
-      (let [msg (trs "multiple write database support is experimental")])
       (binding [*out* *err*]
         (println
          (trs "WARNING: multiple write database support is experimental")))


Improved type inference

Improved type inference

--- src/rdf_path_examples/type_inference.clj
+++ src/rdf_path_examples/type_inference.clj
@@ -26,43 +26,36 @@

 (defn infer-datatype
   "Infers data type of `literal`."
-  [^String literal]
-  (if (absolute-uri? literal)
-    ::xsd/anyURI
-    (condp re-matches literal
-      #"^\d{4}-\d{2}-\d{2}$" ::xsd/date
-      #"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?([+\-]\d{2}:\d{2}|Z)?$" ::xsd/dateTime
-      duration-regex ::xsd/duration
-      ::xsd/string)))
+  [literal]
+  (cond (instance? Boolean literal) ::xsd/boolean
+        (number? literal) ::xsd/decimal
+        (absolute-uri? literal) ::xsd/anyURI
+        :else (condp re-matches literal
+                #"^\d{4}-\d{2}-\d{2}$" ::xsd/date
+                #"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?([+\-]\d{2}:\d{2}|Z)?$" ::xsd/dateTime
+                duration-regex ::xsd/duration
+                ::xsd/string)))

 (defprotocol Resource
   "An RDF resource"
   (infer-type [resource] "resource type"))

 (extend-protocol Resource
-  Boolean
-  (infer-type [_] ::xsd/boolean)
-
-  Number
-  (infer-type [_] ::xsd/decimal)
-
   PersistentArrayMap
-  (infer-type [{value "@value"
+  (infer-type [{id "@id"
+                value "@value"
                 resource-type "@type"}]
-    (cond (nil? value)
+    (cond id
           :referent
           (and resource-type (xml-schema-data-type? resource-type))
           (data-type->xml-schema resource-type)
-          :else (infer-type value)))
+          :else (infer-datatype value)))

   PersistentVector
   ; We expect the vector's ranges to be homogeneous.
   ; Their data type is inferred from their first member.
   (infer-type [[sample-resource & _]]
-    (infer-type sample-resource))
-
-  String
-  (infer-type [value] (infer-datatype value)))
+    (infer-type sample-resource)))

 (defn lowest-common-ancestor
   "Compute lowest common ancestor in the type hierarchy of `a` and `b`."


Reformatting

Reformatting

--- src-cljs/kixi/hecuba/web/chart.cljs
+++ src-cljs/kixi/hecuba/web/chart.cljs
@@ -71,67 +71,67 @@
     om/IRenderState
     (render-state [_ {:keys [clicked]}]
       (dom/div nil
-                 (dom/table #js {:id "form-table" :cellSpacing "10"}
-                            (let [cols {:left "Left axis plots" :right "Right axis plots"}]
-                              (dom/tr nil
-                                      (for [col cols]
-                                        (dom/td nil
-                                                (dom/h4 nil (val col))
-                                                (dom/form nil
-                                                          (for [device cursor]
-                                                            (let [id      (str (:hecuba/name device))
-                                                                  name    (str (:name device))
-                                                                  axis    (first col)
-                                                                  ]
-                                                              (dom/div nil
-                                                                       (dom/input #js
-                                                                                {:type "checkbox"
-                                                                                :onChange
-                                                                                (fn [e]
-                                                                                (let [checked (= (.. e -target -checked) true)]
-                                                                                (put! clicked
-                                                                                {:id id
-                                                                                :axis axis
-                                                                                :checked checked})
-                                                                                ))})
-                                                                       (dom/label nil name)
-                                                                       (dom/br #js {}))))))))))))))
+           (dom/table #js {:id "form-table" :cellSpacing "10"}
+                (let [cols {:left "Left axis plots" :right "Right axis plots"}]
+                  (dom/tr nil
+                       (for [col cols]
+                         (dom/td nil
+                              (dom/h4 nil (val col))
+                              (dom/form nil
+                                   (for [device cursor]
+                                     (let [id      (str (:hecuba/name device))
+                                           name    (str (:name device))
+                                           axis    (first col)
+                                           ]
+                                       (dom/div nil
+                                            (dom/input #js
+                                                 {:type "checkbox"
+                                                  :onChange
+                                                  (fn [e]
+                                                    (let [checked (= (.. e -target -checked) true)]
+                                                      (put! clicked
+                                                            {:id id
+                                                             :axis axis
+                                                             :checked checked})
+                                                      ))})
+                                            (dom/label nil name)
+                                            (dom/br #js {}))))))))))))))

 ;;;;;;;;;;;;; Component 2: Chart ;;;;;;;;;;;;;;;;

 (defn chart-item
   [cursor owner]
-   (reify
-     om/IWillMount
-     (will-mount [_]
-       (let [clicked-items (om/get-state owner [:clicked])]
-          (go (while true
-                (let [sel (<! clicked-items)
-                      checked         (str (get sel :checked))
-                      axis            (get sel :axis)
-                      id              (str (get sel :id))]
-                  (.log js/console "Consumed axis: " (str axis) ". Id " (str id) ". Checked: " (str checked))
-                  (om/update! cursor update-in [:selected axis] (if (truthy? checked) conj disj) id))))))
-     om/IRender
-     (render [_]
-       (dom/div #js {:id "chart" :width 500 :height 550}))
-      om/IDidUpdate
-      (did-update [this prev-props prev-state root-node]
-        (let [n (.getElementById js/document "chart")]
-          (while (.hasChildNodes n)
-            (.removeChild n (.-lastChild n))))
-        (let [Chart        (.-chart dimple)
-             svg          (.newSvg dimple "#chart" 500 500)
-             measurements (apply concat (vals (select-keys mock-data (merge (:left (:selected cursor)) (:right (:selected cursor))))))
-             dimple-chart (Chart. svg (clj->js measurements))
-             x            (.addCategoryAxis dimple-chart "x" "month")
-             y1           (.addMeasureAxis dimple-chart "y" "reading")
-             y2           (.addMeasureAxis dimple-chart "y" "reading")]
-         (.setBounds dimple-chart 60 30 350 350)
-         (.addSeries dimple-chart "device_id" js/dimple.plot.line (clj->js [x y1]))
-         (.addSeries dimple-chart "device_id" js/dimple.plot.line (clj->js [x y2]))
-         (.addLegend dimple-chart 60 10 300 20 "right")
-         (.draw dimple-chart)))))
+  (reify
+    om/IWillMount
+    (will-mount [_]
+      (let [clicked-items (om/get-state owner [:clicked])]
+        (go (while true
+              (let [sel (<! clicked-items)
+                    checked         (str (get sel :checked))
+                    axis            (get sel :axis)
+                    id              (str (get sel :id))]
+                (.log js/console "Consumed axis: " (str axis) ". Id " (str id) ". Checked: " (str checked))
+                (om/update! cursor update-in [:selected axis] (if (truthy? checked) conj disj) id))))))
+    om/IRender
+    (render [_]
+      (dom/div #js {:id "chart" :width 500 :height 550}))
+    om/IDidUpdate
+    (did-update [this prev-props prev-state root-node]
+      (let [n (.getElementById js/document "chart")]
+        (while (.hasChildNodes n)
+          (.removeChild n (.-lastChild n))))
+      (let [Chart        (.-chart dimple)
+            svg          (.newSvg dimple "#chart" 500 500)
+            measurements (apply concat (vals (select-keys mock-data (merge (:left (:selected cursor)) (:right (:selected cursor))))))
+            dimple-chart (Chart. svg (clj->js measurements))
+            x            (.addCategoryAxis dimple-chart "x" "month")
+            y1           (.addMeasureAxis dimple-chart "y" "reading")
+            y2           (.addMeasureAxis dimple-chart "y" "reading")]
+        (.setBounds dimple-chart 60 30 350 350)
+        (.addSeries dimple-chart "device_id" js/dimple.plot.line (clj->js [x y1]))
+        (.addSeries dimple-chart "device_id" js/dimple.plot.line (clj->js [x y2]))
+        (.addLegend dimple-chart 60 10 300 20 "right")
+        (.draw dimple-chart)))))

 ;;;;;;;;;;; Bootstrap ;;;;;;;;;;;;

@@ -144,21 +144,14 @@
       om/IRenderState
       (render-state [_ {:keys [chans]}]
         (dom/div nil
-                 (dom/h3 #js {:key "head"} (str "Metering data - " (get-in cursor [:property])))
-                 (dom/p nil "Note: When you select something to plot on a given axis, you will only be able to plot other items of the same unit on that axis.")
-                 ;; Builds chart component
-                 (om/build chart-item cursor {:key :hecuba/name :init-state chans})
-                 ;; Builds table containing form components for left and right axis
-                 (dom/div #js {:id "device-form"}
-                          (om/build device-form (get-in cursor model-path)
-                                     {:key :hecuba/name :init-state chans})))))))
+             (dom/h3 #js {:key "head"} (str "Metering data - " (get-in cursor [:property])))
+             (dom/p nil "Note: When you select something to plot on a given axis, you will only be able to plot other items of the same unit on that axis.")
+             ;; Builds chart component
+             (om/build chart-item cursor {:key :hecuba/name :init-state chans})
+             ;; Builds table containing form components for left and right axis
+             (dom/div #js {:id "device-form"}
+                  (om/build device-form (get-in cursor model-path)
+                      {:key :hecuba/name :init-state chans})))))))

 (om/root chart-state (create-form-and-chart [:devices]) (.getElementById js/document "app"))
-
-
-
-
-
-
-


tweak server logging

tweak server logging

--- src/polismath/components/server.clj
+++ src/polismath/components/server.clj
@@ -28,6 +28,7 @@
   "This wraps a handler such that requested for /healthcheck"
   [handler]
   (fn [{:as request :keys [uri]}]
+    (log/debug "wrap-handler called for request" uri)
     (if (= uri "/healthcheck")
       (healthcheck-handler request)
       (handler request))))
@@ -36,7 +37,7 @@
   [config opts app jetty-server]
   component/Lifecycle
   (start [component]
-    (log/info ">> Starting server component with config:" config)
+    (log/info ">> Starting server component with config:" (:server config))
     (let [wrapped-handler (wrap-handler (:handler app))
           jetty-server (jetty/run-jetty wrapped-handler
                                         (merge {:join? false :port 8080}


restore the last view before entering background only on android in prod configuration

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/ui/screens/views.cljs
+++ src/status_im/ui/screens/views.cljs
@@ -321,6 +321,7 @@
                               (navigation/set-navigator-ref r)
                               (when (and
                                      platform/android?
+                                     (not js/goog.DEBUG)
                                      (not (contains? #{:intro :login} @view-id)))
                                 (navigation/navigate-to @view-id)))
             ;; see https://reactnavigation.org/docs/en/state-persistence.html#development-mode


Delete spray.clj

Delete spray.clj

--- src/swagger_gen/examples/spray/spray.clj
+++ src/swagger_gen/examples/spray/spray.clj
@@ -1,65 +0,0 @@
-(ns swagger-gen.examples.spray.spray
-  (:require [swagger-gen.generator :refer :all]
-            [swagger-gen.util :refer [camelize normalize-def]]))
-
-;; Rendering logic for Scala projects using Spray json
-;;
-;; *******************************************************************
-
-(defn resolve-array-type
-  [items]
-  (let [type (first items)]
-    (format "Seq[%s]" (normalize-def type))))
-
-(defn format-type [type items]
-  (condp = type
-    "string"    "String"
-    "array"     (resolve-array-type items)
-    "integer"   "Int"
-    "integer32" "Int"
-    type))
-
-(defn render-arg [arg]
-  (let [[name type items] ((juxt :name :type :items) arg)]
-    (format "%s: %s"
-            (camelize name)
-            (format-type type items))))
-
-(defn render-case-class
-  "Take a swagger model definition and turns it into a Scala case class or case object
-   depending on arity"
-  [definition]
-  (let [[name args] ((juxt :name :args) definition)]
-    (if (zero? (count args))
-    (format "case object %s" name)
-             (let [arguments (->> (map render-arg args) (interpose ", ")
-                                  (apply str))]
-               (format "case class %s(%s)" name  arguments)))))
-
-(defn to-spray-route [path]
-  "")
-
-;; Rendering
-;; *******************************************************************
-
-(def spec "resources/swagger/petstore.yaml")
-(def cardstorage "/home/vagrant/workspace/cardstorage/cardstorage-sync-acceptor/cardstorage-sync-acceptor-spec/src/main/resources/cardstorage-v2.yaml")
-
-(def model-template "resources/templates/spray/models.mustache")
-(def routes-template "resources/templates/spray/routes.mustache")
-
-(defn models []
-  (render-swagger cardstorage model-template
-    (fn [spec]
-      (assoc spec :definitions
-             (map #(assoc % :class  (render-case-class %)
-                            :arglen (count (:args %)))
-                  (:definitions spec))))))
-
-(defn routes []
-  (render-swagger cardstorage routes-template
-                  (fn [spec]
-                    (assoc spec :paths
-                           (map identity (:paths spec))))))
-
-


Add default-params to the bidi-based screen router

--- src/main/workflo/macros/screen/bidi.cljs
+++ src/main/workflo/macros/screen/bidi.cljs
@@ -55,12 +55,15 @@

 (defn router
   [{:keys [default-screen
+           default-params
            mount-screen]
-    :or   {default-screen 'home}
+    :or   {default-screen 'home
+           default-params {}}
     :as   env}]
   (br/start-router! (routes)
                     {:on-navigate #(on-navigate env %)
-                     :default-location {:handler default-screen}}))
+                     :default-location {:handler default-screen
+                                        :route-params default-params}}))

 (defn goto!
   [router screen params]


extended-equality considers any Throwable false.

--- src/midje/checkers/extended_equality.clj
+++ src/midje/checkers/extended_equality.clj
@@ -31,7 +31,7 @@

           :else
           (= actual expected))
-    (catch Exception ex false)))
+    (catch Throwable ex false)))

 (defn extended-list-= [actual-args checkers]
   "Element-by-element comparison, using extended-= for the right-hand-side values."


fixed failed test

fixed failed test

--- test/org/domaindrivenarchitecture/pallet/crate/backup/backup__lib_test.clj
+++ test/org/domaindrivenarchitecture/pallet/crate/backup/backup__lib_test.clj
@@ -31,8 +31,8 @@
              "cd /home/dataBackupSource/store"
              "# test wether pwd points to expected place"
             "if [ \"$PWD\" == \"/home/dataBackupSource/store\" ]; then"
-            "  (ls -t portal_prod_file_*|head -n 1;ls portal_prod_file_*)|sort|uniq -u|xargs rm"
-            "  (ls -t portal_prod_mysql_*|head -n 1;ls portal_prod_mysql_*)|sort|uniq -u|xargs rm"
+            "  (ls -t portal_prod_file_*|head -n 1;ls portal_prod_file_*)|sort|uniq -u|xargs rm -r"
+            "  (ls -t portal_prod_mysql_*|head -n 1;ls portal_prod_mysql_*)|sort|uniq -u|xargs rm -r"
             "fi"
             ""]
            (sut/source-transport-script-lines


[search] fix clearing search field

[search] fix clearing search field

--- src/braid/search/ui/search_bar.cljs
+++ src/braid/search/ui/search_bar.cljs
@@ -18,7 +18,8 @@
                 (dispatch [:braid.search/update-query! (.. e -target -value)]))}]
      (if search-query
        [:a.action.clear
-        {:href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
+        {:on-click (fn [] (reset! search-query ""))
+         :href (routes/group-page-path {:group-id @(subscribe [:open-group-id])
                                         :page-id "inbox"})
          :style {:color (color/->color @(subscribe [:open-group-id]))}}]
        [:div.action.search])]))


Only delete BK data if flag is set

Only delete BK data if flag is set

--- src/onyx/state/bookkeeper.clj
+++ src/onyx/state/bookkeeper.clj
@@ -55,8 +55,9 @@
   (component/stop [{:keys [server] :as component}]
     (info "Stopping BookKeeper server")
     (.shutdown ^BookieServer server)
-    (cleanup-dir (:journal-dir component))
-    (cleanup-dir (:ledger-dir component))
+    (when (:onyx.bookkeeper/delete-server-data? env-config)
+      (cleanup-dir (:journal-dir component))
+      (cleanup-dir (:ledger-dir component)))
     (assoc component :server nil :port nil :journal-dir nil :ledger-dir nil)))

 (defn started? [bookie]
@@ -76,7 +77,7 @@
                               (reset! bookie (component/start (->Bookie env-config port log)))
                               (catch Throwable t
                                 (error t "Error starting BookKeeper server:"))))
-                          (Thread/sleep 100)))]
+                          (Thread/sleep 1000)))]
       (info "Starting BookKeeper Monitor service")
       (assoc component :bookie bookie :monitor-fut monitor-fut)))
   (component/stop [component]


rename samples to assets

rename samples to assets

--- src/overtone/config/store.clj
+++ src/overtone/config/store.clj
@@ -29,12 +29,12 @@
   @config*)

 (def OVERTONE-DIRS
-  (let [root    (str (System/getProperty "user.home") "/.overtone")
-        log     (str root "/log")
-        samples (str root "/samples")]
+  (let [root   (str (System/getProperty "user.home") "/.overtone")
+        log    (str root "/log")
+        assets (str root "/assets")]
       {:root root
        :log log
-       :samples samples}))
+       :assets assets}))

 (def OVERTONE-CONFIG-FILE (str (:root OVERTONE-DIRS) "/config.clj"))
 (def OVERTONE-LOG-FILE (str (:log OVERTONE-DIRS) "/log.log"))


Add a non-matching test

Add a non-matching test


allow more flexibility in healthcheck return values

--- dropwizard-clojure-core/src/main/clojure/dropwizard_clojure/healthcheck.clj
+++ dropwizard-clojure-core/src/main/clojure/dropwizard_clojure/healthcheck.clj
@@ -2,24 +2,24 @@
   (:import [com.codahale.metrics.health HealthCheck]
            [com.codahale.metrics.health HealthCheck$Result]))

-(defn- to-result [clojure-result]
+(def ^{:private true} default-unhealthy-message
+  "unhealthy")
+
+(defn- marshall-clj-result [x]
   (cond
-    (true? clojure-result)
-    (HealthCheck$Result/healthy)
+    (or (seq? x) (vector? x) (list? x)) (take 2 x)
+    :else (if x [true] [false])))

-    (or (nil? clojure-result) (false? clojure-result))
-    (HealthCheck$Result/unhealthy "unhealthy")
+(defn- to-result [[healthy? arg]]
+  (if healthy?
+    (HealthCheck$Result/healthy arg)
+    (HealthCheck$Result/unhealthy (if (nil? arg)
+                                    default-unhealthy-message
+                                    arg))))

-    (vector? clojure-result)
-    (let [[healthy? message-or-throwable] clojure-result]
-      (if healthy?
-        (HealthCheck$Result/healthy message-or-throwable)
-        (HealthCheck$Result/unhealthy message-or-throwable)))
-
-    :else
-    (HealthCheck$Result/unhealthy
-     (format "invalid healthcheck return value `%s'" clojure-result))))
+(def ^{:private true} result
+  (comp to-result marshall-clj-result))

 (defn healthcheck [healthcheck-fn]
   (proxy [HealthCheck] []
-    (check [] (to-result (healthcheck-fn)))))
+    (check [] (result (healthcheck-fn)))))


Simple changes - Better reporting (for unit testing unit testing) - Factored out System/exit call (for with-redefs mock-out)

--- jvm-runner/src/clojure/codewars/clojure/test.clj
+++ jvm-runner/src/clojure/codewars/clojure/test.clj
@@ -14,7 +14,7 @@

 (defn- print-context []
   (when (seq *testing-contexts*)
-      (->> (testing-contexts-str) (str "<IT::>") println)))
+    (->> (testing-contexts-str) (str "<IT::>") println)))

 (defn- print-with-message [status {:keys [:message]}]
   (if (string? message)
@@ -30,28 +30,33 @@
 (defn- print-expectations [{:keys [:expected :actual]}]
   (println "expected:" (pr-str expected) "- actual:" (expr-str actual)))

+(defn- fail []
+  (flush)
+  (System/exit 1))
+
 (defmulti codewars-report :type)

 (defmethod codewars-report :pass [_]
   (with-test-out
+    (inc-report-counter :pass)
     (print-context)
     (println "<PASSED::>Test Passed")))

 (defmethod codewars-report :fail [m]
   (with-test-out
+    (inc-report-counter :fail)
     (print-context)
     (print-with-message "<FAILED::>" m)
     (print-expectations m))
-  (flush)
-  (System/exit 1))
+  (fail))

 (defmethod codewars-report :error [m]
   (with-test-out
+    (inc-report-counter :error)
     (print-context)
     (print-with-message "<ERROR::>" m)
     (print-expectations m))
-  (flush)
-  (System/exit 1))
+  (fail))

 (defmethod codewars-report :begin-test-ns [_])
 (defmethod codewars-report :end-test-ns [_])


Fix bug

Fix bug

--- src/checkin_halake/models/users.clj
+++ src/checkin_halake/models/users.clj
@@ -11,7 +11,8 @@

 (defn- fix-user [doc]
   (-> (dissoc doc :password)
-      (update-in [:status] (fnil keyword :dropin))))
+      (some-> identity
+              (update-in [:status] (fnil keyword :dropin)))))

 (def initial-tickets
   (zipmap (keys ticket/ticket-types)


clean routes

clean routes

--- src/clj/salava/metabadge/routes.clj
+++ src/clj/salava/metabadge/routes.clj
@@ -17,17 +17,11 @@
                   :summary "get all metabadges"
                   :auth-rules access/signed
                   :current-user current-user
-                  (ok (mb/all-metabadges ctx current-user))
-                  )
+                  (ok (mb/all-metabadges ctx current-user)))
+
              (GET "/info" [assertion_url]
                   :summary "get metabadge info via assertion url"
                   :current-user current-user
-                  (mb/all-metabadges ctx current-user)
-                  #_(prn (map #(-> %
-                                 :test
-                                 :metabadge
-                                 :badge
-                                 )(mb/all-metabadges ctx current-user)))
                   (ok (mb/check-metabadge ctx assertion_url)))

              (GET "/badge/info" [assertion_url]


De-n00bed multimethod dispatcher for find-by-path

--- src/clojure/alfresco/filefolder.clj
+++ src/clojure/alfresco/filefolder.clj
@@ -31,7 +31,7 @@
   [node]
   (.exists (file-folder-service) node))

-(defn exist?
+(defn all-exist?
   "Do all of the given nodes exist?"
   [nodes]
   (every? true? (map #(exists? %) nodes)))
@@ -54,22 +54,18 @@
 (defn copy!
   "Copies a node from one place to another. Returns the nodeRef of the newly created node."
   [source-node target-parent new-name]
-  { :pre (exist? [source-node target-parent]) }
+  { :pre (all-exist? [source-node target-parent]) }
   (.getNodeRef (.copy (file-folder-service) source-node target-parent new-name)))
-
-; N00B WARNING: Don't yet know how to express this inline as an anonymous fn...
-(defn- first-sequential?
-  [& args]
-  (sequential? (first args)))

 (defmulti find-by-path
   "Finds a node at the given path location, optionally providing a start-node (defaults to Company Home).
   Returns nil if the path does not identify a node."
-  first-sequential?)
+  #(sequential? (first %&)))

 (defmethod find-by-path true
   ([path-elems] (find-by-path path-elems (n/company-home)))
   ([path-elems start-node]
+    { :pre (exists? start-node) }
     (let [file-info (.resolveNamePath (file-folder-service) start-node path-elems false)]
       (if (nil? file-info)
         nil


optimizing

optimizing

--- src/tailrecursion/boot.clj
+++ src/tailrecursion/boot.clj
@@ -24,15 +24,13 @@
   {"maven" "http://repo1.maven.org/maven2/"
    "clojars" "http://clojars.org/repo"})

-(defn install
-  [{:keys [coordinates repositories]}]
+(defn install [{:keys [coordinates repositories]}]
   (let [deps (pom/add-dependencies
               :coordinates (mapv exclude-clojure coordinates)
               :repositories (merge *default-repositories* repositories))]
     (swap! env update-in [:dependencies] merge deps)))

-(defn add
-  [dirs]
+(defn add [dirs]
   (let [meth (doto (.getDeclaredMethod URLClassLoader "addURL" (into-array Class [URL]))
                (.setAccessible true))]
     (.invoke meth (ClassLoader/getSystemClassLoader)


Some light reformatting.

Some light reformatting.

--- src/blutwurst/tuple_formatter.clj
+++ src/blutwurst/tuple_formatter.clj
@@ -64,6 +64,7 @@

 (defn format-rows [spec tables]
  (mapv (partial (case (:format spec)
-         :csv csv-formatter
-         :sql sql-formatter) spec)
+                  :csv csv-formatter
+                  :sql sql-formatter)
+                spec)
        tables))


Do not constrain notes width

Do not constrain notes width

--- src/clj/chili_dog_night/views.clj
+++ src/clj/chili_dog_night/views.clj
@@ -101,7 +101,7 @@
    (when-not (nil? (:notes data))
      [:div
       (p "This is what they discussed during, and between films:")
-      (p (:notes data))])])
+      (into [:p.f4.f3-ns.lh-copy] (:notes data))])])

 (defn login []
   (common "Login"


implement NONE removal for ALL and MAP-VALS on PersistentArrayMap

--- src/clj/com/rpl/specter/navs.cljc
+++ src/clj/com/rpl/specter/navs.cljc
@@ -100,19 +100,29 @@
      (all-transform [structure next-fn]
        (let [k-it (.keyIterator structure)
              v-it (.valIterator structure)
-             array (i/fast-object-array (* 2 (.count structure)))]
-         ;;TODO: how to handle NONE here...?
-         ;;needs to size the array appropriately...
-         ;;need to use the same strategy for MAP-VALS
-         (loop [i 0]
+             none-cell (i/mutable-cell 0)
+             len (.count structure)
+             array (i/fast-object-array (* 2 len))]
+         (loop [i 0
+                j 0]
            (if (.hasNext k-it)
              (let [k (.next k-it)
                    v (.next v-it)
-                   [newk newv] (next-fn [k v])]
-               (aset array i newk)
-               (aset array (inc i) newv)
-               (recur (+ i 2)))))
-         (clojure.lang.PersistentArrayMap/createAsIfByAssoc array))))
+                   newkv (next-fn [k v])]
+               (if (identical? newkv i/NONE)
+                (do
+                  (i/update-cell! none-cell inc)
+                  (recur (+ i 2) j))
+                (do
+                  (aset array j (nth newkv 0))
+                  (aset array (inc j) (nth newkv 1))
+                  (recur (+ i 2) (+ j 2)))))))
+         (let [none-count (i/get-cell none-cell)
+               array (if (not= 0 none-count)
+                        (java.util.Arrays/copyOf array (* 2 (- len none-count)))
+                        array
+                        )]
+          (clojure.lang.PersistentArrayMap/createAsIfByAssoc array)))))

   #?(:cljs cljs.core/PersistentArrayMap)
@@ -208,17 +218,29 @@
      (map-vals-transform [structure next-fn]
        (let [k-it (.keyIterator structure)
              v-it (.valIterator structure)
-             array (i/fast-object-array (* 2 (.count structure)))]
-        ;;TODO: Need to handle NONE here just like it's handled in all-transform
-         (loop [i 0]
+             none-cell (i/mutable-cell 0)
+             len (.count structure)
+             array (i/fast-object-array (* 2 len))]
+         (loop [i 0
+                j 0]
            (if (.hasNext k-it)
              (let [k (.next k-it)
                    v (.next v-it)
                    newv (next-fn v)]
-               (aset array i k)
-               (aset array (inc i) newv)
-               (recur (+ i 2)))))
-         (clojure.lang.PersistentArrayMap. array))))
+               (if (identical? newv i/NONE)
+                (do
+                  (i/update-cell! none-cell inc)
+                  (recur (+ i 2) j))
+                (do
+                  (aset array j k)
+                  (aset array (inc j) newv)
+                  (recur (+ i 2) (+ j 2)))))))
+         (let [none-count (i/get-cell none-cell)
+               array (if (not= 0 none-count)
+                        (java.util.Arrays/copyOf array (* 2 (- len none-count)))
+                        array
+                        )]
+          (clojure.lang.PersistentArrayMap. array)))))

   #?(:cljs cljs.core/PersistentArrayMap)


add some convenience functions for ease of REPLing

--- src/clj/weasel/repl/websocket.clj
+++ src/clj/weasel/repl/websocket.clj
@@ -1,6 +1,7 @@
 (ns weasel.repl.websocket
   (:refer-clojure :exclude [loaded-libs])
   (:require [cljs.repl]
+            [cljs.repl.browser]
             [cljs.compiler :as cmp]
             [cljs.env :as env]
             [weasel.repl.server :as server]))
@@ -53,11 +54,19 @@
                opts)]
     opts))

-(comment
-  (cemerick.piggieback/cljs-repl
-    :repl-env (weasel.repl.websocket/repl-env :port 9001)
-    :verbose true)
-  )
+(defn- start-brepl
+  ([] (start-brepl 9000))
+  ([port]
+     (cemerick.piggieback/cljs-repl
+       :repl-env (cljs.repl.browser/repl-env :port port)
+       )))
+
+(defn- start-wrepl
+  ([] (start-wrepl 9001))
+  ([port]
+     (cemerick.piggieback/cljs-repl
+       :repl-env (repl-env :port port)
+       :verbose true)))

 (comment
   (let [user-env '{:ns nil :locals {}}


apply authorization rules in web/commodities

--- src/clj_money/web/commodities.clj
+++ src/clj_money/web/commodities.clj
@@ -6,6 +6,11 @@
             [clojure.tools.logging :as log]
             [clj-money.util :refer [format-number]]
             [clj-money.web.shared :refer :all]
+            [clj-money.authorization :refer [apply-scope
+                                             authorize
+                                             tag-resource]]
+            [clj-money.models.auth-helpers :refer [user-owns-entity?
+                                                   user-entity-ids]]
             [clj-money.validation :as validation]
             [clj-money.models.commodities :as commodities]
             [clj-money.models.prices :as prices]))
@@ -48,7 +53,8 @@
 (defn index
   [{params :params}]
   (let [entity (:entity params)
-        commodities (commodities/select-by-entity-id (env :db) (:id entity))]
+        criteria (apply-scope {:entity-id (:id entity)} :commodity)
+        commodities (commodities/search (env :db) criteria)]
     (with-layout "Commodities" {:entity entity}
       [:div.row
        [:div.col-md-6
@@ -95,7 +101,9 @@

 (defn new-commodity
   ([{{entity-id :entity-id} :params :as req}]
-   (new-commodity req {:entity-id entity-id}))
+   (new-commodity req (-> {:entity-id entity-id}
+                          (tag-resource :commodity)
+                          (authorize :new))))
   ([{{entity :entity} :params} commodity]
    (with-layout "New commodity" {:entity entity}
      [:div.row
@@ -107,19 +115,22 @@
   [{params :params}]
   (let [commodity (commodities/create
                     (env :db)
-                    (select-keys params [:entity-id :name :symbol :exchange :type]))]
+                    (-> params
+                        (select-keys [:entity-id
+                                      :name
+                                      :symbol
+                                      :exchange
+                                      :type])
+                        (tag-resource :commodity)
+                        (authorize :create)))]
     (if (validation/has-error? commodity)
       (new-commodity {} commodity)
       (redirect (format "/entities/%s/commodities" (:entity-id commodity))))))

-(defn show
-  [req]
-  "show")
-
 (defn edit
   ([{params :params :as req}]
    (let [id (:id params)
-         commodity (commodities/find-by-id (env :db) id)]
+         commodity (authorize (commodities/find-by-id (env :db) id) :edit)]
      (edit req commodity)))
   ([_ commodity]
    (with-layout "Edit commodity" {:entity-id (:entity-id commodity)}
@@ -130,16 +141,20 @@

 (defn update
   [{params :params}]
-  (let [result (commodities/update (env :db)
-                                   (select-keys
-                                     params
-                                     [:id :name :symbol :exchange :type]))]
+  (let [commodity (-> (commodities/find-by-id (env :db) (:id params))
+                      (authorize :update)
+                      (merge (select-keys params [:id
+                                                  :name
+                                                  :symbol
+                                                  :exchange
+                                                  :type])))
+        result (commodities/update (env :db) commodity)]
     (if (validation/has-error? result)
       (edit {} result)
       (redirect (format "/entities/%s/commodities" (:entity-id result))))))

 (defn delete
   [{params :params}]
-  (let [commodity (commodities/find-by-id (env :db) (:id params))]
+  (let [commodity (authorize (commodities/find-by-id (env :db) (:id params)) :delete)]
     (commodities/delete (env :db) (:id commodity))
     (redirect (format "/entities/%s/commodities" (:entity-id commodity)))))


badge format initial

badge format initial

--- src/cljs/salava/page/ui/edit.cljs
+++ src/cljs/salava/page/ui/edit.cljs
@@ -328,11 +328,11 @@
        (cond
          (and (:toggle-move-mode @state) (not (= index (:toggled @state))))         [:a {:href "#" :on-click #(do

-                                                                                (f/move-positions blocks (:toggled @state) index)
-                                                                                (swap! state assoc :toggle-move-mode false :toggled nil)
-                                                                                )} [:div.placeholder.html-block-content.html-block-content-hover
-
-                                                                                (t :page/Clicktodrop)]]
+                                                                                (f/move-positions blocks (:toggled @state) index)
+                                                                                (swap! state assoc :toggle-move-mode false :toggled nil)
+                                                                                )} [:div.placeholder.html-block-content.html-block-content-hover
+
+                                                                                (t :page/Clicktodrop)]]
          :else            [:button {:class    "btn btn-success"
                                     :on-click #(do
                                                  (.preventDefault %)
@@ -352,27 +352,37 @@
      [field-after blocks state index]
      [:div.field.thumbnail {:class (when block-toggled? " block-to-move")}
       #_[:div.field-move
-       [:div.move-arrows
-        (if-not first?
-          [:div.move-up {:on-click #(f/move-field :up blocks index)}
-           [:i {:class "fa fa-chevron-up"}]])
-        (if-not last?
-          [:div.move-down {:on-click #(f/move-field :down blocks index)}
-           [:i {:class "fa fa-chevron-down"}]])]]
+         [:div.move-arrows
+          (if-not first?
+            [:div.move-up {:on-click #(f/move-field :up blocks index)}
+             [:i {:class "fa fa-chevron-up"}]])
+          (if-not last?
+            [:div.move-down {:on-click #(f/move-field :down blocks index)}
+             [:i {:class "fa fa-chevron-down"}]])]]
       [:div.field-content
        [:div.form-group
         [:div.col-xs-8
          [:span.block-title (some-> (filter #(= type (:value %)) block-type-map) first :value capitalize) ]
+         (when (= type "badge")
+           [:div.form-group
+             [:select {:class "form-control"
+                       :aria-label "select blocktype"
+                       :value (get-in @block-atom [:badge :format])
+                       :on-change #(update-block-value block-atom :format (.-target.value %))}
+              [:option {:value "short"} (t :page/Short)]
+              [:option {:value "long"} (t :page/Long)]]]
+
+           )
          #_[block-type block-atom]]
         [:div.move {:on-click #(do
-                                                  (.preventDefault %)
-                                                  (cond
-                                                    (and first? last?) (swap! state assoc :toggle-move-mode false :toggled nil)
-                                                    (:toggle-move-mode @state) (swap! state assoc :toggle-move-mode false :toggled nil)
-                                                    :else (swap! state assoc :toggle-move-mode true :toggled index))
-                                                  #_(if (:toggle-move-mode @state)
-                                                      (swap! state assoc :toggle-move-mode false :toggled nil)
-                                                      (swap! state assoc :toggle-move-mode true :toggled index)))}
+                                 (.preventDefault %)
+                                 (cond
+                                   (and first? last?) (swap! state assoc :toggle-move-mode false :toggled nil)
+                                   (:toggle-move-mode @state) (swap! state assoc :toggle-move-mode false :toggled nil)
+                                   :else (swap! state assoc :toggle-move-mode true :toggled index))
+                                 #_(if (:toggle-move-mode @state)
+                                     (swap! state assoc :toggle-move-mode false :toggled nil)
+                                     (swap! state assoc :toggle-move-mode true :toggled index)))}
          [:span.move-block {:class (when block-toggled? " block-to-move")}  [:i.fa.fa-arrows]]]
         [:div {:class "close"
                :on-click #(f/remove-field blocks index)}
@@ -390,24 +400,24 @@

 (defn page-blocks [blocks badges tags files state]
   (let [block-count (count @blocks)
-         position (if (pos? block-count) (dec block-count) nil)]
-  [:div {:id "field-editor"}
-   (into [:div {:id "page-blocks"}]
-         (for [index (range (count @blocks))]
-           (block (cursor blocks [index]) index blocks badges tags files state)))
-   [field-after blocks state position]
-   ;(when (seq @blocks)[field-after blocks state (dec (count @blocks))] [field-after blocks state 0])
-   #_[:div.add-field-after
-      (if (and (:toggle-move-mode @state) #_(not (= (dec index) (:toggled @state))))
-        [:div.placeholder.html-block-content.html-block-content-hover
-         "Click to drop block"
-         ]
-        [:button {:class    "btn btn-success"
-                  :on-click #(do
-                               (.preventDefault %)
-                               (open-modal [:page :blocktype] {:block-atom blocks :index nil} {:size :md})
-                               #_(m/modal! [open-block-modal blocks nil] {:size :md}))}
-         (t :page/Addblock)])]]))
+        position (if (pos? block-count) (dec block-count) nil)]
+    [:div {:id "field-editor"}
+     (into [:div {:id "page-blocks"}]
+           (for [index (range (count @blocks))]
+             (block (cursor blocks [index]) index blocks badges tags files state)))
+     [field-after blocks state position]
+     ;(when (seq @blocks)[field-after blocks state (dec (count @blocks))] [field-after blocks state 0])
+     #_[:div.add-field-after
+        (if (and (:toggle-move-mode @state) #_(not (= (dec index) (:toggled @state))))
+          [:div.placeholder.html-block-content.html-block-content-hover
+           "Click to drop block"
+           ]
+          [:button {:class    "btn btn-success"
+                    :on-click #(do
+                                 (.preventDefault %)
+                                 (open-modal [:page :blocktype] {:block-atom blocks :index nil} {:size :md})
+                                 #_(m/modal! [open-block-modal blocks nil] {:size :md}))}
+           (t :page/Addblock)])]]))

 #_(defn page-description [description]
     [:div.form-group


Fix tests.

Fix tests.

--- test/catacumba/handlers_postal_tests.clj
+++ test/catacumba/handlers_postal_tests.clj
@@ -39,7 +39,7 @@
 (defn- response->frame
   [response]
   (let [data (response->data response)]
-    (pc/decode data :application/transit+json)))
+    (pc/-decode data :application/transit+json)))

 (defn- send-raw-frame
   [uri method frame content-type]
@@ -61,7 +61,7 @@
   ([uri frame]
    (send-frame uri frame :put))
   ([uri frame method]
-   (let [data (pc/encode frame :application/transit+json)]
+   (let [data (pc/-encode frame :application/transit+json)]
      @(md/chain
        (send-raw-frame uri method data "application/transit+json")
        response->frame))))
@@ -149,10 +149,10 @@
               (a/close! out)))]
     (with-server {:handler (pc/router handler)}
       (let [frame {:type :subscribe :data nil}
-            frame (pc/encode frame :application/transit+json)
+            frame (pc/-encode frame :application/transit+json)
             conn @(http/websocket-client (str "ws://localhost:5050/?d="
                                               (codecs/bytes->safebase64 frame)))
             result @(ms/take! conn)
-            frame (pc/decode (codecs/str->bytes result)
+            frame (pc/-decode (codecs/str->bytes result)
                              :application/transit+json)]
         (is (= frame {:data [1], :type :response}))))))


Add tests for map-into-list

Add tests for map-into-list

--- test/cljs/comic_reader/ui/base_test.cljs
+++ test/cljs/comic_reader/ui/base_test.cljs
@@ -1,5 +1,6 @@
 (ns comic-reader.ui.base-test
-  (:require [devcards.core :refer-macros [defcard-rg]]
+  (:require [cljs.test :refer-macros [is testing]]
+            [devcards.core :refer-macros [deftest defcard-rg]]
             [comic-reader.ui.base :as sut]))

 (defcard-rg loading
@@ -13,3 +14,17 @@

 (defcard-rg large-button
   [sut/large-button "Button"])
+
+(deftest test-map-into-list
+  (is (= [:ul [:li 1] [:li 2]]
+         (sut/map-into-list [:ul] identity [1 2])))
+
+  (is (= [:ol.everything
+          [:li [:a {:href "a"} "A"]]
+          [:li [:a {:href "b"} "B"]]]
+         (sut/map-into-list [:ol.everything]
+                            (fn [el]
+                              [:a {:href (:url el)}
+                               (:content el)])
+                            [{:url "a" :content "A"}
+                             {:url "b" :content "B"}]))))