Variable rename

Variable rename

--- src/dmohs/react/core.cljs
+++ src/dmohs/react/core.cljs
@@ -24,10 +24,10 @@

 (defn- props [instance]
-  (let [defaults (aget instance "props" "cljsDefaultProps")]
+  (let [defaults (aget instance "props" "cljsDefault")]
     (if defaults
-      (merge defaults (.. instance -props -cljsProps))
-      (.. instance -props -cljsProps))))
+      (merge defaults (.. instance -props -cljs))
+      (.. instance -props -cljs))))

 (defn- atom-like-state-swap! [instance & swap-args]
@@ -106,7 +106,7 @@
                 ref (props :ref)
                 key (props :key)
                 props (dissoc props :ref :key)]
-            (set! (.. js-props -cljsProps) props)
+            (set! (.. js-props -cljs) props)
             (when ref (set! (.. js-props -ref) ref))
             (when key (set! (.. js-props -key) key))
             (apply React.createElement type js-props children)))))))
@@ -186,7 +186,7 @@
     ;; TODO: propTypes, mixins, statics
     (when-let [x (:get-default-props fn-map)]
       (set! (. class-def -getDefaultProps)
-            (fn [] (this-as this #js{:cljsDefaultProps (.call x this {:this this})}))))
+            (fn [] (this-as this #js{:cljsDefault (.call x this {:this this})}))))
     (when-let [x (:display-name fn-map)] (set! (. class-def -displayName) x))
     (when-let [x (:component-will-mount fn-map)]
       (set! (. class-def -componentWillMount)
@@ -199,14 +199,14 @@
             (fn [nextProps]
               (this-as
                this
-               (.call x this (assoc (default-arg-map this) :next-props (.-cljsProps nextProps)))))))
+               (.call x this (assoc (default-arg-map this) :next-props (.-cljs nextProps)))))))
     (when-let [x (:should-component-update fn-map)]
       (set! (. class-def -shouldComponentUpdate)
             (fn [nextProps nextState]
               (this-as
                this
                (.call x this (assoc (default-arg-map this)
-                                    :next-props (.-cljsProps nextProps)
+                                    :next-props (.-cljs nextProps)
                                     :next-state (.-cljs nextState)))))))
     (when-let [x (:component-will-update fn-map)]
       (set! (. class-def -componentWillUpdate)
@@ -214,7 +214,7 @@
               (this-as
                this
                (.call x this (assoc (default-arg-map this)
-                                    :next-props (.-cljsProps nextProps)
+                                    :next-props (.-cljs nextProps)
                                     :next-state (.-cljs nextState)))))))
     (when-let [x (:component-did-update fn-map)]
       (set! (. class-def -componentDidUpdate)
@@ -222,7 +222,7 @@
               (this-as
                this
                (.call x this (assoc (default-arg-map this)
-                                    :prev-props (.-cljsProps prevProps)
+                                    :prev-props (.-cljs prevProps)
                                     :prev-state (.-cljs prevState)))))))
     (set! (. class-def -componentWillUnmount) (:component-will-unmount fn-map))
     (let [remaining-methods (apply dissoc fn-map react-component-api-method-keys)]


make disembark work with receipt of 'system

--- src/gangway/disembark.clj
+++ src/gangway/disembark.clj
@@ -1,3 +1,3 @@
 (ns gangway.disembark)

-(defn disembark! [msg])
+(defn disembark! [& _])


Rename exit printlns.

Rename exit printlns.

--- src/cbfg/kvs.cljs
+++ src/cbfg/kvs.cljs
@@ -169,8 +169,8 @@
                 (if-let [op-handler (get (or op-handlers-in op-handlers) (:op m))]
                   (do (op-handler kvs-mgr-in state-ch m)
                       (recur (inc tot-ops)))
-                  (println :kvs-mgr-in-unknown-op-exit m))
-                (println :kvs-mgr-in-ch-exit)))
+                  (println :kvs-mgr-in-exit-unknown-op m))
+                (println :kvs-mgr-in-exit-ch)))

     ; Using kvs-mgr-state to avoid atoms, which prevent time-travel.
     (act-loop kvs-mgr-state actx [state { :next-uuid 0 :kvss {} }]
@@ -179,5 +179,5 @@
                   (when (and done-ch done-res)
                     (aput-close kvs-mgr-state done-ch done-res))
                   (recur (or next-state state)))
-                (println :kvs-mgr-state-ch-exit)))
+                (println :kvs-mgr-state-exit-ch)))
     cmd-ch))


DM + MG #17 - Fix tests

DM + MG #17 - Fix tests

--- integration/objective8/api/writers_invite_integration_tests.clj
+++ integration/objective8/api/writers_invite_integration_tests.clj
@@ -58,15 +58,13 @@
                                    :content-type "application/json"
                                    :body the-invited-writer-as-json)) => (contains {:status 400})))

-
-
 (facts "invitations" :integration
        (against-background
          [(m/valid-credentials? anything anything anything) => true
           (before :contents (do
                               (helpers/db-connection)
                               (helpers/truncate-tables)))
-          (after :facts (helpers/truncate-tables)) ])
+          (after :facts (helpers/truncate-tables)) ]
        (fact "GET /api/v1/invitations?uuid=<UUID> retrieves an active invitation by the uuid if it exists"
            (let
              [created-by-id (:_id (users/store-user! {:twitter-id "some-twitter-id"}))
@@ -74,4 +72,4 @@
               stored-invitation (writers/store-invited-writer! {:invited-by-id created-by-id
                                                                 :objective-id objective-id})
               uuid (:uuid stored-invitation)]
-        (helpers/peridot-response-json-body->map (p/request app (str "/api/v1/invitations?uuid=" uuid))) => (dissoc stored-invitation :entity))))
+        (helpers/peridot-response-json-body->map (p/request app (str "/api/v1/invitations?uuid=" uuid))) => (dissoc stored-invitation :entity)))))


Remove unused code from geom ns.

Remove unused code from geom ns.

--- frontend/src/uxbox/main/geom.cljs
+++ frontend/src/uxbox/main/geom.cljs
@@ -746,100 +746,6 @@
      :x x
      :y y}))

-;; --- Transformation Matrix
-
-(declare transformation-matrix-rect)
-(declare transformation-matrix-text)
-(declare transformation-matrix-circle)
-(declare transformation-matrix-icon)
-(declare transformation-matrix-path)
-(declare transformation-matrix-group)
-
-(defn transformation-matrix
-  ([shape]
-   (transformation-matrix @st/state shape))
-  ([state shape]
-   (case (:type shape)
-     :rect (transformation-matrix-rect state shape)
-     :text (transformation-matrix-text state shape)
-     :circle (transformation-matrix-circle state shape)
-     :icon (transformation-matrix-icon state shape)
-     :image (transformation-matrix-icon state shape)
-     :path (transformation-matrix-path state shape)
-     :group (transformation-matrix-group state shape))))
-
-(defn- transformation-matrix-rect
-  [state {:keys [x1 y1 rotation] :or {rotation 0} :as shape}]
-  (let [{:keys [width height]} (size shape)
-        center-x (+ x1 (/ width 2))
-        center-y (+ y1 (/ height 2))]
-    (-> (gmt/matrix)
-        (gmt/translate center-x center-y)
-        (gmt/rotate rotation)
-        (gmt/translate (- center-x) (- center-y)))))
-
-(defn- transformation-matrix-text
-  [state {:keys [x1 y1 rotation] :or {rotation 0} :as shape}]
-  (let [{:keys [width height]} (size shape)
-        center-x (+ x1 (/ width 2))
-        center-y (+ y1 (/ height 2))]
-    (-> (gmt/matrix)
-        (gmt/translate center-x center-y)
-        (gmt/rotate rotation)
-        (gmt/translate (- center-x) (- center-y)))))
-
-(defn- transformation-matrix-icon
-  [state {:keys [x1 y1 rotation view-box] :or {rotation 0} :as shape}]
-  (let [{:keys [width height]} (size shape)
-        orig-width (nth view-box 2)
-        orig-height (nth view-box 3)
-        scale-x (/ width orig-width)
-        scale-y (/ height orig-height)
-        center-x (- width (/ width 2))
-        center-y (- height (/ height 2))]
-    (-> (gmt/matrix)
-        (gmt/translate x1 y1)
-        (gmt/translate center-x center-y)
-        (gmt/rotate rotation)
-        (gmt/translate (- center-x) (- center-y))
-        (gmt/scale scale-x scale-y))))
-
-(defn- transformation-matrix-path
-  [state {:keys [x1 y1 rotation view-box] :or {rotation 0} :as shape}]
-  (let [{:keys [width height]} (size shape)
-        orig-width (nth view-box 2)
-        orig-height (nth view-box 3)
-        scale-x (/ width orig-width)
-        scale-y (/ height orig-height)
-        center-x (- width (/ width 2))
-        center-y (- height (/ height 2))]
-    (-> (gmt/matrix)
-        (gmt/translate x1 y1)
-        (gmt/translate center-x center-y)
-        (gmt/rotate rotation)
-        (gmt/translate (- center-x) (- center-y))
-        (gmt/scale scale-x scale-y))))
-
-(defn- transformation-matrix-circle
-  [state {:keys [cx cy rx ry rotation] :or {rotation 0} :as shape}]
-  (-> (gmt/matrix)
-      (gmt/translate cx cy)
-      (gmt/rotate rotation)
-      (gmt/translate (- cx) (- cy))))
-
-(defn- transformation-matrix-group
-  [state {:keys [dx dy rotation items] :or {rotation 0} :as shape}]
-  (let [shapes-by-id (get state :shapes)
-        shapes (map #(get shapes-by-id %) items)
-        {:keys [x y width height]} (outer-rect-coll shapes)
-        center-x (+ x (/ width 2))
-        center-y (+ y (/ height 2))]
-    (-> (gmt/matrix)
-        (gmt/translate (or dx 0) (or dy 0))
-        (gmt/translate center-x center-y)
-        (gmt/rotate rotation)
-        (gmt/translate (- center-x) (- center-y)))))
-
 ;; --- Helpers

 (defn apply-rotation


Added exclusions to the class_consolidation_by_shared_label rule

To avoid incorrect consolidations we rule out certain ontologies for
consolidation based on shared label name. See reasoning in rule
comments.

--- resources/rules/pre_identifier_merge/step_b_id_exact_match/shared_label/class_consolidation_by_shared_label.clj
+++ resources/rules/pre_identifier_merge/step_b_id_exact_match/shared_label/class_consolidation_by_shared_label.clj
@@ -8,15 +8,37 @@
                   prefix franzOption_chunkProcessingAllowed: <franz:yes>
                   prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                   prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
-                  select ?id1 ?id2 {
-                    ?c1 oboInOwl:hasOBONamespace ?ns1 .
-                    ?c1 rdf:type owl:Class .
-                    ?c1 rdfs:label ?label .
-                    ?c2 rdfs:label ?label .
-                    ?c2 oboInOwl:hasOBONamespace ?ns2 .
-                    ?c2 rdf:type owl:Class .
-                    FILTER (?c1 != ?c2 && STR(IRI(?c1)) < STR(IRI(?c2)))
-                    ?id1 obo:IAO_0000219 ?c1 .
-                    ?id2 obo:IAO_0000219 ?c2 .
-                  }"
+                  select ?c1 ?c2 ?label {
+                       ?c1 oboInOwl:hasOBONamespace ?ns1 .
+                       ?c1 rdf:type owl:Class .
+                       ?c1 rdfs:label ?label .
+                       ?c2 rdfs:label ?label .
+                       ?c2 oboInOwl:hasOBONamespace ?ns2 .
+                       ?c2 rdf:type owl:Class .
+                       # require that c1 and c2 are different and return in a reproducible order to avoid duplicate pairings
+                       # also exclude several ontologies:
+                       #   PR: so that we don't intentionally collapse genes with proteins
+                       #   NCBITaxon: matches appear to be spurious
+                       #   UBERON: so as not to incorrectly collapse species-specific anatomy
+                       #   PO: also so as not to incorrectly collapse plant anatomy with other things
+                       FILTER (?c1 != ?c2 && STR(IRI(?c1)) < STR(IRI(?c2))
+                                   && !contains(str(?c1), 'obo/PR_')
+                                   && !contains(str(?c2), 'obo/PR_')
+                                   && !contains(str(?c1), 'obo/UBERON_')
+                                   && !contains(str(?c2), 'obo/UBERON_')
+                                   && !contains(str(?c1), 'obo/NCBITaxon_')
+                                   && !contains(str(?c2), 'obo/NCBITaxon_')
+                                   && !contains(str(?c1), 'obo/PO_')
+                                   && !contains(str(?c2), 'obo/PO_')
+                                   # CHEBI:base and SO:base are not the same
+                                   && ?label != 'base'
+                                   && ?label != 'probe'
+                                   && ?label != 'direct'
+                                   )
+                       ?id1 obo:IAO_0000219 ?c1 .
+                       ?id2 obo:IAO_0000219 ?c2 .
+                       # exclude any links between different GGPV identifiers
+                       minus {?id1 rdfs:subClassOf* IAO_EXT_0000083}  # ccp:gene_or_gene_product_or_variant_identifier
+                       minus {?id2 rdfs:subClassOf* IAO_EXT_0000083}  # ccp:gene_or_gene_product_or_variant_identifier
+                       }"
   }


add copy and paste

add copy and paste

--- src/lt/objs/platform.cljs
+++ src/lt/objs/platform.cljs
@@ -12,6 +12,16 @@

 (defn open [path]
   (.Shell.openExternal (js/require "nw.gui") path))
+
+(defn copy
+  "Copies given text to platform's clipboard"
+  [text]
+  (.set (.Clipboard.get (js/require "nw.gui")) text "text"))
+
+(defn paste
+  "Returns text of last copy to platform's clipboard"
+  []
+  (.get (.Clipboard.get (js/require "nw.gui")) "text"))

 (def platform (normalize (.-platform js/process)))


http kudos token image

http kudos token image

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

--- src/status_im/ui/screens/wallet/collectibles/kudos/events.cljs
+++ src/status_im/ui/screens/wallet/collectibles/kudos/events.cljs
@@ -6,7 +6,8 @@
             [re-frame.core :as re-frame]
             [status-im.utils.handlers :as handlers]
             [status-im.constants :as constants]
-            [status-im.utils.ethereum.core :as ethereum]))
+            [status-im.utils.ethereum.core :as ethereum]
+            [clojure.string :as string]))

 (def kudos :KDO)

@@ -23,14 +24,20 @@
                        #(re-frame/dispatch [:token-uri-success
                                             tokenId
                                             (when %2
-                                              ;;TODO extra chars in rinkeby
-                                              (subs %2 (.indexOf %2 "http")))])))))
+                                              (subs %2 (.indexOf %2 "http")))]))))) ;; extra chars in rinkeby

 (handlers/register-handler-fx
  :token-uri-success
  (fn [_ [_ tokenId token-uri]]
-   {:http-get {:url                    token-uri
-               :success-event-creator (fn [o]
-                                        [:load-collectible-success kudos {tokenId (http/parse-payload o)}])
-               :failure-event-creator (fn [o]
-                                        [:load-collectible-failure kudos {tokenId (http/parse-payload o)}])}}))
+   {:http-get {:url
+               token-uri
+               :success-event-creator
+               (fn [o]
+                 [:load-collectible-success kudos {tokenId (update (http/parse-payload o)
+                                                                   :image
+                                                                   string/replace
+                                                                   #"http:"
+                                                                   "https:")}]) ;; http in mainnet
+               :failure-event-creator
+               (fn [o]
+                 [:load-collectible-failure kudos {tokenId (http/parse-payload o)}])}}))


fix 404

fix 404

--- cloc-web/src/cloc_web/query_cloc.clj
+++ cloc-web/src/cloc_web/query_cloc.clj
@@ -83,6 +83,7 @@
   [params]
   (let [doc (get-svg-badge params)]
     (if (= 404 (:status doc))
+      doc
       {:headers {"Content-Type" "image/png"}
-       :body (ring-io/piped-input-stream
+       :body (ring-io/piped-input-stream
                (partial output-to-png-stream doc))})))


test case png_badge

test case png_badge

--- cloc-web/test/cloc_web/core_test.clj
+++ cloc-web/test/cloc_web/core_test.clj
@@ -229,3 +229,28 @@
   (testing "total count"
     (let [svg-doc (xml/parse (:body (client/get (str url "/0of/target/master/svg_badge") {:as :stream})))]
       (is (= "2394" (get-in svg-doc [:content 1 :content 1 :content 0]))))))
+
+(deftest get-png-non-existent-user
+  (is (= 404 (:status (client/get (str url "/0of/target/master/png_badge") {:as :stream
+                                                                            :throw-exceptions false})))))
+
+(deftest get-png
+  (scenario "register repo and insert record"
+    (-> (r/table "users")
+        (r/insert {:id "github/0of/target"
+                   :user "0of"
+                   :filter "*"
+                   :lang "SUM"})
+        (r/run @db-conn))
+
+    (-> (r/table "result")
+        (r/insert {"Clojure" {"code" 1891
+                              "lang" "Clojure"
+                              "total" 2394}
+                   "code" 1891
+                   "id" "0of/target/master"
+                   "total" 2394})
+        (r/run @db-conn)))
+
+  (let [header (:headers (client/get (str url "/0of/target/master/png_badge")))]
+    (is (= (get header "Content-Type") "image/png"))))


using destructuring for conciseness and clarity

--- src/midje/util/report.clj
+++ src/midje/util/report.clj
@@ -32,8 +32,8 @@
        ~test-form
        (fact-checks-out?)))

-(defn midje-position-string [position-pair]
-  (format "(%s:%s)" (first position-pair) (second position-pair)))
+(defn midje-position-string [[filename line-num]]
+  (format "(%s:%s)" filename line-num))

 (defmacro with-identity-renderer [& forms]   ; for testing
   `(binding [*renderer* identity] ~@forms))


Check algorithm validity in blob functions.

--- src/mvxcvi/vault/blob.clj
+++ src/mvxcvi/vault/blob.clj
@@ -17,6 +17,14 @@
   (into #{} (keys digest-functions)))

+(defn- assert-valid-digest
+  [algorithm]
+  (when-not (digest-functions algorithm)
+    (throw (IllegalArgumentException.
+             (str "Unsupported digest algorithm: " algorithm
+                  ", must be one of " (string/join ", " digest-algorithms))))))
+
+

 ;; BLOB REFERENCE

@@ -24,6 +32,7 @@
   [algorithm digest]

   Object
+
   (toString [this]
     (str (name algorithm) ":" digest)))

@@ -36,21 +45,19 @@
 (defn hash-content
   "Calculates the blob reference for the given content."
   [algorithm content]
+  (assert-valid-digest algorithm)
   (let [hashfn (digest-functions algorithm)]
-    (when-not hashfn
-      (throw (IllegalArgumentException.
-               (str "Unsupported digest algorithm: " algorithm
-                    ", must be one of " (string/join ", " digest-algorithms)))))
     (BlobRef. algorithm (-> content hashfn .toLowerCase))))

 (defn parse-address
-  "Parses an address string into a blobref. Accepts either a hash URI or the
+  "Parses an address string into a blobref. Accepts either a hash URN or the
   shorter \"algo:address\" format."
   [address]
   (let [address (if (re-find #"^urn:" address) (subs address 4) address)
         address (if (re-find #"^hash:" address) (subs address 5) address)
         [algorithm digest] (string/split address #":" 2)]
+    (assert-valid-digest algorithm)
     (BlobRef. (keyword algorithm) digest)))

@@ -61,4 +68,5 @@
      x
      (parse-address (str x))))
   ([algorithm digest]
+   (assert-valid-digest algorithm)
    (BlobRef. algorithm digest)))


be more precise about outputting newlines in log

--- ccw.core/src/clj/ccw/repl/view_helpers.clj
+++ ccw.core/src/clj/ccw/repl/view_helpers.clj
@@ -57,8 +57,7 @@
           [log-style line-background-color-name] (get log-styles type [default-log-style nil])
           linecnt (.getLineCount log)]
       (.append log s)
-      (when (and (seq s) (not (Character/isWhitespace (last s))))
-        (.append log "\n"))
+      (when-not (re-find #"(\n|\r)$" s) (.append log "\n"))
       (doto log
         cursor-at-end
         .showSelection
@@ -71,7 +70,7 @@
   [status s]
   (format "Expression %s: %s"
     ({"timeout" "timed out", "interrupted" "was interrupted"} status "failed")
-    (-> s
+    (-?> s
       (.substring 0 (min 30 (count s)))
       (str (when (> (count s) 30) "..."))
       (.replaceAll "\\n|\\r" " "))))


Clean up chart.cljs

Clean up chart.cljs

--- src-cljs/kixi/hecuba/web/chart.cljs
+++ src-cljs/kixi/hecuba/web/chart.cljs
@@ -7,19 +7,27 @@

 (mrhyde/bootstrap)

-(def width 450)
-(def height 350)
+(defn create-svg
+  [div width height]
+  (.newSvg dimple div width height))

-(def svg (-> dimple (.newSvg "#chart" width height)))
+(defn dimple-chart
+  [div width height data]
+  (let [Chart (.-chart dimple)
+        svg   (create-svg div width height)]
+    (Chart. svg (clj->js data))))
+
+(defn init-bar-chart
+  [div width height data x-axis-title y-axis-title]
+ ; (.log js/console "Height: " height)
+  (let [chart (dimple-chart div width height data)]
+    (.addCategoryAxis chart "x" x-axis-title)
+    (.addMeasureAxis chart "y" y-axis-title)
+    (.addSeries chart nil js/dimple.plot.bar)
+    (.draw chart)))

 (def data  [{"Word" "Hello" "Awesomeness" 2000}
             {"Word" "World" "Awesomeness" 3000}])

-(let [Chart        (.-chart dimple)
-      dimple-chart (Chart. svg (clj->js data))]
+(init-bar-chart "#chart" 450 350 data "Word" "Awesomeness")

-  (.log js/console "Chart: " dimple-chart)
-  (.addCategoryAxis dimple-chart "x" "Word")
-  (.addMeasureAxis dimple-chart "y" "Awesomeness")
-  (.addSeries dimple-chart nil js/dimple.plot.bar)
-  (.draw dimple-chart))


update remove account page

update remove account page

--- src/cljs/salava/user/ui/cancel.cljs
+++ src/cljs/salava/user/ui/cancel.cljs
@@ -45,24 +45,24 @@
                                                (if (.. e -target -checked)
                                                  (swap! state assoc :confirm-delete "true")(swap! state assoc :confirm-delete "false")))}]

-                         (t :user/Confirmaccountremoval3)]]]]]]
-    [:div.modal-footer
-     [:button {:type         "button"
-               :class        "btn btn-primary"
-               :style {:margin-bottom "unset"}
-               :data-dismiss "modal"}
-      (t :core/Cancel)]
-     [:button {:type         "button"
-               :class        "btn btn-warning"
-               :style {:margin-bottom "unset"}
-               :disabled (if-not (= "true" (:confirm-delete @state))
-                           "disabled")
-               :on-click   #(do
-                              (if (= "true" (:confirm-delete @state))
-                                (cancel-account state)))
-               :data-dismiss "modal"}
+                         (t :user/Confirmaccountremoval3)]]]]]]]
+   [:div.modal-footer
+    [:button {:type         "button"
+              :class        "btn btn-primary"
+              :style {:margin-bottom "unset"}
+              :data-dismiss "modal"}
+     (t :core/Cancel)]
+    [:button {:type         "button"
+              :class        "btn btn-warning"
+              :style {:margin-bottom "unset"}
+              :disabled (if-not (= "true" (:confirm-delete @state))
+                          "disabled")
+              :on-click   #(do
+                             (if (= "true" (:confirm-delete @state))
+                               (cancel-account state)))
+              :data-dismiss "modal"}

-      (t :user/Cancelaccount)]]]])
+     (t :user/Cancelaccount)]]])

 (defn cancel-form [state]


Last of the update collection REST API tests. Also last of the collection REST API integration tests.

--- test/fcms/integration/rest_api/collection/collection_update.clj
+++ test/fcms/integration/rest_api/collection/collection_update.clj
@@ -384,4 +384,58 @@
         :description "this is a collection"
         :version 1})
       ;; check it didn't create another collection
+      (collection/collection-count) => 1)
+
+    (with-state-changes [(before :facts (collection/create-collection "another-c" {:description "this is another collection"}))]
+
+      ;; different slug specified in body is already used - 422 Unprocessable Entity
+      ;; curl -i --header "Accept: application/vnd.fcms.collection+json;version=1" --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms.collection+json;version=1" -X PUT -d '{"name":"another-c", "description": "this is an updated collection"}' http://localhost:3000/c
+      (fact "with a slug that's already used"
+        (let [response (api-request :put "/c" {
+          :headers {
+            :Content-Type (mime-type :collection)
+            :Accept (mime-type :collection)}
+          :body {
+            :name "c-prime"
+            :slug "another-c"
+            :description "this is an updated collection"}})]
+          (:status response) => 422
+          (response-mime-type response) => (mime-type :text)
+          (body-from-response response) => "Slug already used.")
+        ;; check that the update failed
+        (collection/get-collection c) => (contains {
+          :slug c
+          :name c
+          :description "this is a collection"
+          :version 1})
+        ;; check that it didn't modify the other collection
+        (collection/get-collection "another-c") => (contains {
+          :slug "another-c"
+          :name "another-c"
+          :description "this is another collection"
+          :version 1})
+        ;; check it didn't create another collection
+        (collection/collection-count) => 2))
+
+    ;; different slug specified in body is invalid - 422 Unprocessable Entity
+    ;; curl -i --header "Accept: application/vnd.fcms.collection+json;version=1" --header "Accept-Charset: utf-8" --header "Content-Type: application/vnd.fcms.collection+json;version=1" -X PUT -d '{"slug": "c C", "name":"c-prime", "description": "this is an updated collection"}' http://localhost:3000/c
+    (fact "with a slug that's invalid"
+      (let [response (api-request :put "/c" {
+        :headers {
+          :Content-Type (mime-type :collection)
+          :Accept (mime-type :collection)}
+        :body {
+          :slug "c C"
+          :name "c-prime"
+          :description "this is an updated collection"}})]
+        (:status response) => 422
+        (response-mime-type response) => (mime-type :text)
+        (body-from-response response) => "Invalid slug.")
+      ;; check that the update failed
+      (collection/get-collection c) => (contains {
+        :slug c
+        :name c
+        :description "this is a collection"
+        :version 1})
+      ;; check it didn't create another collection
       (collection/collection-count) => 1)))


Remove vestigial reference to HornetQ

Remove vestigial reference to HornetQ

--- src/onyx_starter/core.clj
+++ src/onyx_starter/core.clj
@@ -147,7 +147,7 @@
    :onyx.messaging/impl :core.async
    :onyx.messaging/bind-addr "localhost"})

-;; Start an in-memory ZooKeeper and HornetQ (depending on vm-hornetq?)
+;; Start an in-memory ZooKeeper
 (def env (onyx.api/start-env env-config))

 ;; Start a peer group to share resources.


expand the :lookup option description in 'make-key' docstring

--- src/keypin/core.clj
+++ src/keypin/core.clj
@@ -167,8 +167,9 @@
 (defn make-key
   "Create a key that can be looked up in a java.util.Map/Properties or clojure.lang.ILookup (map, vector) instance. The
   following optional keys are supported:
-  :lookup  - The function to look the key up,
-             args: the-map, the-key, validator, description, value-parser, default-value?, default-value,
+  :lookup  - The function to look the key up:
+             (fn [the-map the-key validator description value-parser default-value? default-value
+                  (fn not-found-fn [not-found-message])])
              default: ordinary key look up
   :parser  - The value parser function (args: key, value)
   :default - Default value to return if key is not found


only consume locked and inc offset before persisting

--- kafka-clj/src/kafka_clj/consumer.clj
+++ kafka-clj/src/kafka_clj/consumer.clj
@@ -95,6 +95,10 @@
   (persistent-set* group-conn (vec state)))

 (defn get-persister [group-conn conf]
+  "Returns an object that have functions p-close p-send,
+   the offset saved will be incremented before its saved.
+   This means we are saving to next offset to be read.
+   The last offset read will is (dec v)"
   (let [{:keys [offset-commit-freq] :or {offset-commit-freq 5000}} conf
         ch (chan 100)]

@@ -105,7 +109,7 @@
               (if (nil? v)
                  (write-persister-data group-conn state) ;channel is closed
 		            (if (= c ch)
-		              (recur t (assoc state (clojure.string/join "/" [(:topic v) (:partition v)]) (:offset v)))))
+		              (recur t (assoc state (clojure.string/join "/" [(:topic v) (:partition v)]) (inc (:offset v))))))
                ;timeout
               (do
                 (write-persister-data group-conn state)
@@ -257,14 +261,19 @@
 (defn- change-partition-lock [group-conn broker-offsets broker topic partition locked?]
   "broker-offsets = {broker {topic [{:partition :offset :topic}]}}
    change the locked value of a partition
-   returns the modified broker-offsets"
+   returns the modified broker-offsets
+
+   Any records that cannot be locked are removed from the map returned"
   (let [rest-records (get-rest-of-partitions broker topic partition broker-offsets)
            p-record (get-partition broker topic partition broker-offsets)
            saved-offset (get-saved-offset group-conn topic partition)]
       (info "change-partition-lock " broker-offsets " with p-record " p-record " locked? " locked? " saved-offset " saved-offset)
-      (if p-record (merge-with merge  {broker {topic (conj rest-records (assoc p-record :locked locked?
-                                                                                :offset (if saved-offset saved-offset
-                                                                                (:offset p-record) ) ))}})
+      (if p-record (merge-with merge  {broker {topic
+                                               (if locked?
+		                                               (conj rest-records (assoc p-record :locked locked?
+		                                                                              :offset (if saved-offset saved-offset
+		                                                                              (:offset p-record) ) ))
+                                                   rest-records)}})
         broker-offsets)))

@@ -283,19 +292,22 @@
 									                                               broker topic partition
 									                                               (reentrant-lock group-conn (str topic "/" partition)))
 																				                (rest partitions)))
-									                               broker-offsets1))]
-        (info "add " add)
-        (info "broker-offsets1 " broker-offsets1)
-
-        (loop [broker-offsets2 broker-offsets1 partitions remove]
-          (if-let [record (first partitions)]
-            (let [{:keys [broker partition]} record]
-	            (recur
-	                 (do
-	                   (release group-conn (str topic "/" partition))
-	                   (change-partition-lock broker-offsets2 broker topic partition false))
-	                 (rest partitions)))
-	            broker-offsets2))))
+									                               broker-offsets1))
+         broker-offsets2
+							        (loop [broker-offsets2 broker-offsets1 partitions remove]
+							          (if-let [record (first partitions)]
+							            (let [{:keys [broker partition]} record]
+								            (recur
+								                 (do
+								                   (release group-conn (str topic "/" partition))
+								                   (change-partition-lock broker-offsets2 broker topic partition false))
+								                 (rest partitions)))
+								            broker-offsets2))]
+
+           ;only allow offsets with locked true, this is done automatically by the change-partition-lock function
+          broker-offsets2
+
+        ))

 (defn consume-producers! [bootstrap-brokers


ignore periodical_number when importing a recorded production

because it is wrong due to the fact that the mvl_only field is missing
and consequently the production_type will be wrong and because of that
also the periodical_number. So simply ignore it when importing with a
request for a recorded production

--- src/mdr2/abacus.clj
+++ src/mdr2/abacus.clj
@@ -88,8 +88,13 @@
     error
     (let [{product_number :product_number :as new-production}
           (-> (read-file f)
-              ;; ignore production_type when importing a recorded production
-              (dissoc :production_type))
+              ;; ignore production_type and periodical_number when
+              ;; importing a recorded production
+              ;; periodical_number is wrong because the XML exported
+              ;; for a recorded production lacks the mvl_only field
+              ;; and hence the production_type and the
+              ;; periodical_number will be wrong
+              (dissoc :production_type :periodical_number))
           production (prod/find-by-productnumber product_number)]
       (cond
         (empty? production)


temp trace: "mounting.. state name"

temp trace: "mounting.. state name"

--- src/mount/core.cljc
+++ src/mount/core.cljc
@@ -144,6 +144,7 @@
                               :status #{:stopped}}
                        stop (assoc :stop `(fn [] ~stop)))]
           `(do
+             (log (str "|| mounting... " ~state-name))
              (~'defonce ~state (DerefableState. ~state-name))
              (mount-it (~'var ~state) ~state-name ~s-meta)
              (~'var ~state))))))


Fixed PagerDuty documentation

Fixed PagerDuty documentation

--- src/riemann/pagerduty.clj
+++ src/riemann/pagerduty.clj
@@ -50,7 +50,7 @@

   The :formatter is an optional argument.

-  (let [pd (pagerduty :service-key \"my-service-key\" :formatter pd-format-event )]
+  (let [pd (pagerduty { :service-key \"my-service-key\" :formatter pd-format-event})]
     (changed-state
       (where (state \"ok\") (:resolve pd))
       (where (state \"critical\") (:trigger pd))))"


Add missing pirate ship descriptions

Add missing pirate ship descriptions

--- src/robinson/describe.clj
+++ src/robinson/describe.clj
@@ -62,7 +62,9 @@
            :deck                   "the deck"
            :tackle                 "tackle"
            :cannon                 "a cannon"
-           :cannon-trunk           "a cannon truck"
+           :cannon-trunk-1         "a cannon truck"
+           :cannon-trunk-2         "a cannon truck"
+           :cannon-breach          "a cannon breach"
            :grate                  "a grate"
            :table                  "a table"
            :chair                  "a chair"
@@ -71,7 +73,9 @@
            :locker                 "a locker"
            :locker2                "a locker"
            :ships-wheel            "the ship's wheel"
+           :ladder                 "a ladder"
            :porthole               "a porthole"
+           :artifact-chest         "a chest"
            :chest                  "a chest"
            ;; ruined temple
            :floor                  "floor"


1st version of graph generator

1st version of graph generator

--- src/arachnida/server.clj
+++ src/arachnida/server.clj
@@ -55,6 +55,19 @@
     [selected-author week-stat data]
     [:td [:a {:href (str "?author=" selected-author "&week=" (:week week-stat))} data]])

+(defn graph-for-authors-data
+    [authors selected-author]
+    (for [author authors]
+         (if (= (:author author) selected-author)
+             (str "{data:[[1," (:commits_count author) "]], label: '" (:author author) "', pie:{explode:20}},\n")
+             (str "{data:[[1," (:commits_count author) "]], label: '" (:author author) "'},\n"))))
+
+(defn graph-for-weeks-stat
+    [weeks-stat who what label]
+    (str "{data:["
+        (apply str (for [week-stat weeks-stat]
+            (str "[" (:week week-stat) "," (get (get week-stat who) what) "],"))) "], label: '" label "'}"))
+
 (defn create-html-page
     [authors selected-author weeks-stat selected-week stat-for-week commit-id commit-info]
     (page/xhtml
@@ -62,6 +75,10 @@
             [:title "Stats"]
             [:meta {:name "Generator" :content "Clojure"}]
             [:meta {:http-equiv "Content-type" :content "text/html; charset=utf-8"}]
+            [:script {:type "text/javascript" :src "http://10.34.3.139/flotr/lib/prototype-1.6.0.2.js"}]
+            [:script {:type "text/javascript" :src "http://10.34.3.139/flotr/lib/canvas2image.js"}]
+            [:script {:type "text/javascript" :src "http://10.34.3.139/flotr/lib/canvastext.js"}]
+            [:script {:type "text/javascript" :src "http://10.34.3.139/flotr/flotr.debug-0.2.0-alpha.js"}]
         ]
         [:body
             [:h1 "Authors"]
@@ -75,6 +92,48 @@
                         [:td (:insertions author)]
                         [:td (:deletions author)]
                     ])
+                ]
+                [:div {:id "authors-graph" :style "width:500px;height:500px"}
+                    [:script {:type "text/javascript"}
+                    "var f = Flotr.draw($('authors-graph'), ["
+                          (graph-for-authors-data authors selected-author)
+                          "], {
+                          HtmlText: false,
+                          grid: {
+                              verticalLines:   true,
+                              horizontalLines: true
+                          },
+                          xaxis: {showLabels: false},
+                          yaxis: {showLabels: false},
+                          pie: {show: true, explode: 5},
+                          legend:{
+                              show: true,
+                              position: 'ne',
+                              backgroundColor: '#D2E8FF',
+                          }});"
+                    ]
+                ]
+                [:div {:id "weeks-stat" :style "width:900px;height:400px"}
+                    [:script {:type "text/javascript"}
+                    "var f = Flotr.draw($('weeks-stat'), ["
+                          (graph-for-weeks-stat weeks-stat :stat-for-all :commits-count "Commits (all)") ","
+                          (graph-for-weeks-stat weeks-stat :stat-for-author :commits-count "Commits (author)") ","
+                          (graph-for-weeks-stat weeks-stat :stat-for-all :files-changed "Files changed (all)") ","
+                          (graph-for-weeks-stat weeks-stat :stat-for-author :files-changed "Files changed (author)")
+                          "], {
+                          HtmlText: false,
+                          grid: {
+                              verticalLines:   true,
+                              horizontalLines: true
+                          },
+                          xaxis: {showLabels: true},
+                          yaxis: {showLabels: true},
+                          legend:{
+                              show: true,
+                              position: 'ne',
+                              backgroundColor: '#D2E8FF',
+                          }});"
+                    ]
                 ]
             [:h1 "Week stat"]
                 [:table {:style "border:2px solid brown"}


Make on-load key optional as per documentation

--- src/braid/core/client/pages.cljs
+++ src/braid/core/client/pages.cljs
@@ -5,8 +5,8 @@

 (def page-dataspec
   {:key keyword?
-   :on-load fn?
    :view fn?
+   (ds/opt :on-load) fn?
    (ds/opt :styles) vector?})

 (defonce pages


wtf??

wtf??

--- src/babel/morphology.clj
+++ src/babel/morphology.clj
@@ -87,8 +87,7 @@
                               (:agr x))
                     :p (:p pair)})
                  (map (fn [p]
-                        {:agr {:synsem {:subcat {:1 {:agr {:number :sing
-                                                           :person :1st}}}}}
+                        {:agr :top
                          :p p})
                       (group-by-two (:p x)))))
           patterns))


only grab up & down when autocompleting

only grab up & down when autocompleting

--- src/chat/client/new-message.cljs
+++ src/chat/client/new-message.cljs
@@ -78,11 +78,11 @@

                                    KeyCodes.ESC (close-autocomplete!)

-                                   KeyCodes.UP (do
+                                   KeyCodes.UP (when autocomplete-open?
                                                  (.preventDefault e)
                                                  (highlight-prev!))

-                                   KeyCodes.DOWN (do
+                                   KeyCodes.DOWN (when autocomplete-open?
                                                    (.preventDefault e)
                                                    (highlight-next!))
                                    (when (KeyCodes.isTextModifyingKeyEvent e)


add Runner toast to Bank Job

add Runner toast to Bank Job

--- src/clj/game/cards-resources.clj
+++ src/clj/game/cards-resources.clj
@@ -52,6 +52,8 @@

    "Bank Job"
    {:data {:counter 8}
+    :events {:no-action {:effect (req (toast state :runner "Click Bank Job to take credits from it instead of accessing" "info"))
+                         :req (req (and (is-remote? (:server run)) (not current-ice)))}}
     :abilities [{:req (req (and (:run @state) (= (:position run) 0)))
                  :label "Take any number of [Credits] on Bank Job"
                  :prompt "How many [Credits]?" :choices :counter :msg (msg "gain " target " [Credits]")


Start voting command working

Start voting command working

--- src/clj_gamification/handler.clj
+++ src/clj_gamification/handler.clj
@@ -7,7 +7,7 @@
             [ring.middleware.session :refer [wrap-session]]
             [clojure.pprint]))

-(def state (atom :voting #_:not-started))
+(def state (atom :not-started))
 (def team-counter (atom 1))
 (def teams (atom {999 "Team 9's idea"}))
 (def votes (atom {998 1, 999 3}))
@@ -52,7 +52,7 @@
   "Vote for a gamification idea"
   (page
    "Vote"
-   [:h1 "The best gamification idea is:"]          ; TODO
+   [:h1 "The best gamification idea is:"]
    [:form {:action "/vote", :method "post"}
     (map
      (fn [[id idea]] [:p
@@ -73,6 +73,14 @@
        (fn [[id votes]] [:li votes " votes for team " id " with " (get @teams id)]) ; TODO show picture, format the list nicely
        results)])))

+(defn- command-js [command] ; TODO include in a script element as a js fun, call it
+  "Create JavaScript to perform a GM command in the background"
+  (str "var xhr = new XMLHttpRequest();
+      xhr.open('POST', '/command/" command "', true);
+      xhr.onload = function(e) {console.log('done with " command "');}
+      xhr.send();
+"))
+
 (defn page-gamemaster []
   "Control page for the GameMaster: 1. task info, 2. show task to others, 3. start brainstorming?, 4. start voting, 5. show number voted, 6. show voting results"
   (page
@@ -80,12 +88,16 @@
    [:h1 "You control the game!"]
    [:p "Your mission, should you decide to accept it: TODO:describe"] ; TODO Hide when read?
    [:h2 "Controls"]
-   (let [bs {:style "display:block;width:100%;margin-bottom:10px"}]
+   (letfn [(button [cmd label]
+             [:button
+              {:style "display:block;width:100%;margin-bottom:10px",
+               :onclick (command-js cmd)}
+              label])]
     [:div
-     [:button bs "1. Show the task on the projector"]
-     [:button bs "2. Start brainstorming"]
-     [:button bs "3. Start voting"]
-     [:button bs "4. Show voting results"]])))
+     (button "show-task" "1. Show the task on the projector")
+     (button "start-brainstorming" "2. Start brainstorming")
+     (button "start-voting" "3. Start voting")
+     (button "show-voting-results" "4. Show voting results")])))

 (defn show-page-for-step [{:keys [remote-addr session] :as req}]
   "Show the right page for the current stage: gamemaster, team registr., voting"
@@ -93,7 +105,7 @@
         gm? (:gamemaster? session)]
    (cond
     (or gm? first-visitor?) {:session {:gamemaster? true},
-                             :body (page-gamemaster)} ; TODO set cookie to remember the gamemaster
+                             :body (page-gamemaster)}
     (= @state :brainstorming) (page-team-registration)
     (= @state :voting) (if (has-voted? req)
                            "Thank you for your vote!"
@@ -138,11 +150,11 @@
   (GET "/vote-results" [] (page-vote-results))
   (GET "/projector" []
        "TODO: Stuff showing on the projector: 1. the task; 2. /teams; 3. /vote-results")
-  (context "/command" [] ; GameMaster posts commands here
-           (POST "show-task" [] "TODO")
-           (POST "start-brainstorming" [] "TODO")
-           (POST "start-voting" [] "TODO")
-           (POST "show-voting-results" [] "TODO"))
+  (context "/command" [] ; GameMaster posts commands here (TODO? check it really is gm)
+           (POST "/show-task" [] "TODO")
+           #_(POST "/start-brainstorming" [] (str (compare-and-set! state :oldstate :newstate))) ;; CURRENTLY NOT NEEDED
+           (POST "/start-voting" [] (str (compare-and-set! state :brainstorming :voting)))
+           (POST "/show-voting-results" [] (str (compare-and-set! state :voting :voting-finished))))
   (route/resources "/")
   (route/not-found "Not Found"))


add local input state

add local input state

--- src/cljs/bulldog/components.cljs
+++ src/cljs/bulldog/components.cljs
@@ -5,18 +5,43 @@
             [om.next :as om :refer-macros [defui]]))

+(defn onChange
+  "Creates input callpack"
+  [value component]
+  (fn [event]
+    (om/set-state!
+     component
+     (assoc
+      (om/get-state component)
+      value
+      (.. event -target -value)))))
+
+
+
 (defui EditorPage
   Object
   (render [this]
-    (html
-     [:div
-      [:input {:placeholder "What's the title?"}]
-      [:input {:placeholder "Give a short introduction"}]
-      [:input {:placeholder "Write your article"}]
-      [:div
-       [:button "Cancel"]
-       [:button "Publish"]]])))
-
+    (let [{:keys [title abstract article] :as local} (om/get-state this)]
+      (html
+       [:div
+        [:input
+         {:placeholder "What's the title?"
+          :type :text
+          :value title
+          :onChange (onChange :title this)}]
+        [:input
+         {:placeholder "Give a short introduction"
+          :type :text
+          :value abstract
+          :onChange (onChange :abstract this)}]
+        [:input
+         {:placeholder "Write your article"
+          :type :text
+          :value article
+          :onChange (onChange :article this)}]
+        [:div
+         [:button {:onClick (fn [e] (-> js/document .-location (set! "#/")))} "Cancel" ]
+         [:button "Publish"]]]))))

 (defui ArticlePage
   om/IQuery


Remove date parsing code

Remove date parsing code

--- src/clojure/nightmod/screens.clj
+++ src/clojure/nightmod/screens.clj
@@ -32,10 +32,6 @@
             edn/read-string
             :title
             (try (catch Exception _)))
-       (-> (.getName f)
-           Long/parseLong
-           u/format-date
-           (try (catch Exception _)))
        (.getName f))
    (.getCanonicalPath f)])


Improve toggling behavior again

Improve toggling behavior again

--- src/clojure/nightmod/screens.clj
+++ src/clojure/nightmod/screens.clj
@@ -95,22 +95,23 @@

 (defn toggle-files!
   []
-  (if (.exists (io/file @ui/tree-selection))
-    (u/toggle-glass!)
-    (s/invoke-now
-      (reset! ui/tree-selection @u/project-dir))))
+  (let [selected? (.exists (io/file @ui/tree-selection))]
+    (when (or selected? (not (.isVisible (u/glass))))
+      (u/toggle-glass!))
+    (when-not selected?
+      (s/invoke-now
+        (reset! ui/tree-selection @u/project-dir)))))

 (defn toggle-docs!
   []
-  (when (or (not (.isVisible (u/glass)))
-            (= @ui/tree-selection u/docs-name))
-    (u/toggle-glass!))
-  (s/invoke-now
-    (if (.isVisible (u/glass))
-      (reset! ui/tree-selection u/docs-name)
-      (reset! ui/tree-selection @u/project-dir))
-    (some-> (s/select @ui/root [:#editor-pane])
-            (s/show-card! u/docs-name))))
+  (let [selected? (= @ui/tree-selection u/docs-name)]
+    (when (or selected? (not (.isVisible (u/glass))))
+      (u/toggle-glass!))
+    (when-not selected?
+      (s/invoke-now
+        (reset! ui/tree-selection u/docs-name)
+        (some-> (s/select @ui/root [:#editor-pane])
+                (s/show-card! u/docs-name))))))

 (defscreen main-screen
   :on-show


Updated transmit library metadata db namespace.

--- src/cmr/transmit/metadata_db.clj
+++ src/cmr/transmit/metadata_db.clj
@@ -6,11 +6,10 @@
             [cheshire.core :as cheshire]
             [clojure.walk :as walk]
             [cmr.system-trace.http :as ch]
-            [cmr.system-trace.core :refer [deftracefn]]
             [cmr.transmit.connection :as conn]
             [cmr.common.log :refer (debug info warn error)]))

-(deftracefn get-concept
+(defn get-concept
   "Retrieve the concept with the given concept and revision-id"
   [context concept-id revision-id]
   (let [conn (config/context->app-connection context :metadata-db)
@@ -25,7 +24,7 @@
         :not-found
         (str "Failed to retrieve concept " concept-id "/" revision-id " from metadata-db: " (:body response))))))

-(deftracefn get-latest-concept
+(defn get-latest-concept
   "Retrieve the latest version of the concept"
   [context concept-id]
   (let [conn (config/context->app-connection context :metadata-db)
@@ -40,7 +39,7 @@
         :not-found
         (str "Failed to retrieve concept " concept-id " from metadata-db: " (:body response))))))

-(deftracefn get-concept-id
+(defn get-concept-id
   "Return a distinct identifier for the given arguments."
   [context concept-type provider-id native-id]
   (let [conn (config/context->app-connection context :metadata-db)
@@ -64,7 +63,7 @@
             err-msg (str "Concept id fetch failed. MetadataDb app response status code: "  status)]
         (errors/internal-error! (str err-msg  " " errors-str))))))

-(deftracefn get-concept-revisions
+(defn get-concept-revisions
   "Search metadata db and return the concepts given by the concept-id, revision-id tuples."
   ([context concept-tuples]
    (get-concept-revisions context concept-tuples false))
@@ -95,7 +94,7 @@
                                     " "
                                     response))))))

-(deftracefn get-latest-concepts
+(defn get-latest-concepts
   "Search metadata db and return the latest-concepts given by the concept-id list"
   ([context concept-ids]
    (get-latest-concepts context concept-ids false))
@@ -126,33 +125,42 @@
                                     " "
                                     response))))))

-(deftracefn get-collection-concept-id
-  "Search metadata db and return the collection-concept-id that matches the search params"
-  [context search-params]
+(defn find-collections
+  "Searches metadata db for concepts matching the given parameters."
+  [context params]
   (let [conn (config/context->app-connection context :metadata-db)
         request-url (str (conn/root-url conn) "/concepts/search/collections")
         response (client/get request-url {:accept :json
-                                          :query-params search-params
+                                          :query-params params
                                           :headers (ch/context->http-headers context)
                                           :throw-exceptions false
                                           :connection-manager (conn/conn-mgr conn)})
-        status (:status response)
-        body (cheshire/decode (:body response))]
-    (case status
-      404
-      (let [err-msg (str "Unable to find collection-concept-id for search params: " search-params)]
-        (errors/throw-service-error :not-found err-msg))
-
-      200
-      (get (first body) "concept-id")
-
-      ;; default
-      (let [errors-str (cheshire/generate-string (flatten (get body "errors")))
-            err-msg (str "Collection concept id fetch failed. MetadataDb app response status code: "  status)]
-        (errors/internal-error! (str err-msg  " " errors-str))))))
-
-
-(deftracefn save-concept
+        {:keys [status body]} response]
+    (case status
+      404 (errors/throw-service-error
+          :not-found (str "Unable to find collections for search params: " (pr-str params))))
+      200 (cheshire/decode body true)
+      ;; default
+      (errors/internal-error!
+        (format "Collection search failed. status: %s body: %s"
+             status body))))
+
+(defn get-providers
+  "Returns the list of provider ids configured in the metadata db"
+  [context]
+  (let [conn (config/context->app-connection context :metadata-db)
+        request-url (str (conn/root-url conn) "/providers")
+        response (client/get request-url {:accept :json
+                                          :headers (ch/context->http-headers context)
+                                          :throw-exceptions false
+                                          :connection-manager (conn/conn-mgr conn)})
+        {:keys [status body]} response]
+    (case status
+      200 (-> body (cheshire/decode true) :providers)
+      ;; default
+      (errors/internal-error! (format "Failed to get providers status: %s body: %s" status body)))))
+
+(defn save-concept
   "Saves a concept in metadata db and index."
   [context concept]
   (let [conn (config/context->app-connection context :metadata-db)
@@ -182,7 +190,7 @@
                                    " "
                                    response)))))

-(deftracefn delete-concept
+(defn delete-concept
   "Delete a concept from metatdata db."
   [context concept-id]
   (let [conn (config/context->app-connection context :metadata-db)


CMR-585: Added support for get-latest-concepts to metadata db.

--- src/cmr/transmit/metadata_db.clj
+++ src/cmr/transmit/metadata_db.clj
@@ -90,6 +90,33 @@
                                    " "
                                    response)))))

+(deftracefn get-latest-concepts
+  "Search metadata db and return the latest-concepts given by the concept-id list"
+  [context concept-ids]
+  (let [conn (config/context->app-connection context :metadata-db)
+        ids-json-str (cheshire/generate-string concept-ids)
+        request-url (str (conn/root-url conn) "/concepts/search/latest-concept-revisions")
+        response (client/post request-url {:body ids-json-str
+                                           :content-type :json
+                                           :accept :json
+                                           :throw-exceptions false
+                                           :headers (ch/context->http-headers context)
+                                           :connection-manager (conn/conn-mgr conn)})
+        status (:status response)]
+    (case status
+      404
+      (let [err-msg "Unable to find all concepts."]
+        (errors/throw-service-error :not-found err-msg))
+
+      200
+      (cheshire/decode (:body response) true)
+
+      ;; default
+      (errors/internal-error! (str "Get latest concept revisions failed. MetadataDb app response status code: "
+                                   status
+                                   " "
+                                   response)))))
+
 (deftracefn get-collection-concept-id
   "Search metadata db and return the collection-concept-id that matches the search params"
   [context search-params]


Added function to retrieve access-value for SMAP ISO granules.

--- src/cmr/umm/iso_smap/granule.clj
+++ src/cmr/umm/iso_smap/granule.clj
@@ -88,6 +88,17 @@
   "Parses ECHO10 XML into a UMM Granule record."
   [xml]
   (xml-elem->Granule (x/parse-str xml)))
+
+(defn xml->access-value
+  "Parse and return the access-value for the given SMAP ISO granule xml.
+  This function is used by cmr-search-app to retrieve the access-value from xml directly"
+  [xml]
+  (let [xml-struct (x/parse-str xml)
+        id-elems (cx/elements-at-path
+                   xml-struct
+                   [:composedOf :DS_DataSet :has :MI_Metadata
+                    :identificationInfo :MD_DataIdentification])]
+    (xml-elem->access-value id-elems)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Generators


CLJS suddenly complaining about no println.

--- src/cbfg/world/base.cljs
+++ src/cbfg/world/base.cljs
@@ -9,6 +9,8 @@
             [goog.dom :as gdom]
             [cbfg.vis :refer [listen-el get-el-value
                               get-el-innerHTML set-el-innerHTML]]))
+
+(enable-console-print!)

 (defn replay-cmd-ch [cmd-inject-ch el-ids ev-to-cmd-fn]
   (merge [cmd-inject-ch


better error message when class name keywords are unbound

--- src/insn/util.clj
+++ src/insn/util.clj
@@ -24,15 +24,15 @@

 (def ^{:doc "The internal class name of the class being generated."
        :dynamic true}
-  *this* ::unbound)
+  *this* nil)

 (def ^{:doc "The internal superclass name of the class being generated."
        :dynamic true}
-  *super* ::unbound)
+  *super* nil)

 (def ^{:doc "The auto-generated labels of the method being emitted."
        :dynamic true}
-  *labels* ::unbound)
+  *labels* nil)

 ;;;

@@ -177,7 +177,7 @@
   [x]
   (if (instance? Label x)
     x
-    (if (= ::unbound *labels*)
+    (if (not *labels*)
       (throw (IllegalStateException.
               "auto-generated labels only available when emitting method bytecode"))
       (or (get @*labels* x)
@@ -273,7 +273,10 @@
   Class
   (class-desc [c] (class-desc (.getName c)))
   Keyword
-  (class-desc [k] @(check-valid "class keyword" class-keyword? k))
+  (class-desc [k]
+    (or @(check-valid "class keyword" class-keyword? k)
+        (throw (IllegalStateException.
+                (str k " class name proxy is only bound during bytecode emission")))))
   String
   (class-desc [s]
     (if (.contains s ".")


Fix incorrect accumulator in heartbeat for push.

--- src/chronograph/data.clj
+++ src/chronograph/data.clj
@@ -659,7 +659,7 @@

 (defn inc-push-bucket [type-name]
   (let [now (truncate-date-for-bucket (t/now))]
-  (k/exec-raw ["INSERT INTO heartbeat_bucket SET push_count = 1, bucket_date = ?, type = ? ON DUPLICATE KEY UPDATE heartbeat_count = heartbeat_count + 1"
+  (k/exec-raw ["INSERT INTO heartbeat_bucket SET push_count = 1, bucket_date = ?, type = ? ON DUPLICATE KEY UPDATE push_count = push_count + 1"
                [(coerce/to-sql-time now) (@type-ids-by-name type-name)]])))

 (defn inc-heartbeat-bucket [type-name]


Escaped quotes

Escaped quotes

--- src/clj/forma/schema.clj
+++ src/clj/forma/schema.clj
@@ -320,10 +320,10 @@
    returns a pixel location.

      (chunkloc->pixloc
-      {:spatial-res "1000", :mod-h 28, :mod-v 9, :index 59, :size 24000}
+      {:spatial-res \"1000\", :mod-h 28, :mod-v 9, :index 59, :size 24000}
       23999)

-    ;=> {:spatial-res "1000", :mod-h 28, :mod-v 9, :sample 1199, :line 1199}"
+    ;=> {:spatial-res \"1000\", :mod-h 28, :mod-v 9, :sample 1199, :line 1199}"
   [{:keys [spatial-res size index mod-h mod-v]} pix-idx]
   (apply pixel-location spatial-res mod-h mod-v
          (r/tile-position spatial-res size index pix-idx)))


set tag to "latest" if none specified on service create/update

--- src/clj/swarmpit/api.clj
+++ src/clj/swarmpit/api.clj
@@ -519,13 +519,20 @@
   [service]
   (assoc-in service [:secrets] (dmo/->service-secrets service (secrets))))

+(defn- standardize-repository-tag
+  [repository-tag]
+  (if (str/blank? repository-tag)
+    "latest"
+    repository-tag))
+
 (defn- standardize-service
   [owner service]
   (let [repository-name (get-in service [:repository :name])
-        repository-tag (get-in service [:repository :tag])]
+        repository-tag (standardize-repository-tag (get-in service [:repository :tag]))]
     (-> service
         (standardize-service-secrets)
         (standardize-service-configs)
+        (assoc-in [:repository :tag] repository-tag)
         (assoc-in [:repository :imageDigest] (repository-digest owner
                                                                 repository-name
                                                                 repository-tag)))))


mapping services to the host network

mapping services to the host network

#444

--- src/clj/swarmpit/api.clj
+++ src/clj/swarmpit/api.clj
@@ -794,9 +794,10 @@

 (defn services-by-network
   [network-name]
-  (services-by #(contains? (->> (get-in % [:Spec :TaskTemplate :Networks])
-                                (map :Target)
-                                (set)) (:id (network network-name)))))
+  (->> (services-by any?)
+       (filter #(get (->> (get % :networks)
+                          (group-by :networkName))
+                     (:networkName (network network-name))))))

 (defn services-by-volume
   [volume-name]


Let should always open a new scope

Let should always open a new scope

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -523,7 +523,9 @@
 (defn emit-let
   [{:keys [bindings expr env]} is-loop]
   (let [context (:context env)]
-    (when (= :expr context) (emits "func () interface{} {"))
+    (if (= :expr context)
+      (emits "func () interface{} {")
+      (emits "{"))
     (binding [*lexical-renames* (into *lexical-renames*
                                       (when (= :statement context)
                                         (map #(vector (System/identityHashCode %)
@@ -536,7 +538,9 @@
       (when is-loop
         (emitln "return nil")
         (emitln "}")))
-    (when (= :expr context) (emits "}()"))))
+    (if (= :expr context)
+      (emits "}()")
+      (emits "}"))))

 (defmethod emit* :let [ast]
   (emit-let ast false))


Kenny's initial position is now also set by the builder

--- src/cljs/kenny/core.cljs
+++ src/cljs/kenny/core.cljs
@@ -54,7 +54,7 @@
   {:dx 0
    :dy 0
    :life 100
-   :position (hero-start-position grid-content)
+   ;;:position (hero-start-position grid-content)
    :game-won false
    :time [60]
    }
@@ -251,6 +251,13 @@
     )
   )

+(defn initial-position [grid-content hero]
+  (if (hero :position)
+    hero
+    (merge hero {:position (hero-start-position grid-content)})
+    )
+  )
+
 (defn hero [app owner]
   (reify
     om/IWillMount
@@ -258,7 +265,9 @@
       (console-log "mounting...")
       (go-loop []
         (<! (timeout 40))
-        (let [original-hero (get-in @app [:hero])
+        (let [
+              grid-content (get-in @app [:grid])
+              original-hero (initial-position grid-content (get-in @app [:hero]))
               bounce (get-in @app [:settings :bounce])
               red-trampete (get-in @app [:settings :red-trampete])
               blue-trampete (get-in @app [:settings :blue-trampete])


Forwarding system protocols is no longer required!

--- src/containium/modules/boxes.clj
+++ src/containium/modules/boxes.clj
@@ -56,13 +56,9 @@
                                  :active-profiles active-profiles
                                  :containium module-config})
               start-fn @(boxure/eval box `(do (require '~(symbol (namespace (:start module-config))))
-                                              ~(:start module-config)))
-              forward-fn @(boxure/eval box '(do (require 'containium.systems)
-                                                containium.systems/forward-systems))]
+                                              ~(:start module-config)))]
           (when (instance? Throwable start-fn) (boxure/clean-and-stop box) (throw start-fn))
-          (when (instance? Throwable forward-fn) (boxure/clean-and-stop box) (throw forward-fn))
           (try
-            (boxure/call-in-box box forward-fn systems)
             (let [start-result (boxure/call-in-box box start-fn systems descriptor)]
               (println "Module" name "started.")
               (assoc box :start-result start-result, :descriptor descriptor))


Add many functions to print to *err* instead of *out*

--- src/such/imperfection.clj
+++ src/such/imperfection.clj
@@ -1,9 +1,10 @@
 (ns such.imperfection
   "Were we perfect, we wouldn't need to test or debug. Since we're not, a
-   few helpers, especially for code written in flow style."
-
+   few helpers organized around printing."
   (:require [clojure.pprint :refer [pprint]]
-            [such.readable :as readable]))
+            [such.readable :as readable]
+            [such.metadata :as meta]
+            [such.ns :as ns]))

 (defmacro val-and-output
   "Execute the body. Instead of just returning the resulting value,
@@ -77,4 +78,31 @@
              (apply format tag args)
              tag))
   value)
-
+
+
+(defn- one-e [[existing-sym prefix suffix]]
+  (let [outsym '*out*
+        errsym '*err*
+        args 'args
+        new-sym (symbol (str "e" existing-sym))
+        docstring (format "Like %s, but prints to `*err*`.
+  Useful for keeping debug output from being captured by [[val-and-output]]."
+                          (str prefix existing-sym suffix))]
+    `(defn ~new-sym ~docstring [& ~args]
+       (binding [~outsym ~errsym]
+         (apply ~existing-sym ~args)))))
+
+(defmacro e
+  {:private true}
+  [& pairs]
+  `(do ~@(map one-e pairs)))
+
+(e [pr "`" "`"]
+   [prn "`" "`"]
+   [print "`" "`"]
+   [println "`" "`"]
+   [pprint "`" "`"]
+   [-pprint- "[[" "]]"]
+   [-prn- "[[" "]]"]
+   [tag- "[[" "]]"]
+   [-tag "[[" "]]"])


Hardcode a word limit on the generations. Wow huge results from this small change!

--- markov-clj/src/markov_clj/markov.clj
+++ markov-clj/src/markov_clj/markov.clj
@@ -58,7 +58,7 @@
   (let [seed (choose-seed database)]
     (loop [{word :word :as prefix-map} {:word :head :prefix seed}
            words [(last seed)]]
-      (if (= :tail word)
+      (if (or (= :tail word) (< 20 (count words)))
         words
         (recur (next-word database prefix-map) (conj words word))))))

@@ -74,4 +74,4 @@
                                   (apply str ,,)))]
     (repeatedly generation-fn)))

-(println (first (generate (parse-corpus (slurp "resources/corpus2.txt")) 2)))
+(println "\n" (first (generate (parse-corpus (slurp "resources/koleman_tweets.txt")) 1)))


Implement make-completion-item for static fields of classes

--- src/de/kotka/vimclojure/util.clj
+++ src/de/kotka/vimclojure/util.clj
@@ -235,8 +235,11 @@
 (defn- type-of-completion
   [thing]
   (cond
-    (instance? clojure.lang.Namespace thing) "n"
+    (instance? clojure.lang.Namespace thing)   "n"
+    (instance? java.lang.reflect.Field thing)  "S"
+    (instance? java.lang.reflect.Method thing) "M"
     (class? thing)        "c"
+    (coll? thing)         (recur (first thing))
     (:macro (meta thing)) "m"
     :else                 (try
                             (let [value (var-get thing)]
@@ -269,13 +272,31 @@
             "info" ""))

 (defmethod make-completion-item "M"
-  [the-name the-method]
-  (let [rtype    (-> the-method .getReturnType .getSimpleName str)
-        arglist  (.getParameterTypes the-method)
-        menu     (str-cat (concat arglist [rtype]) " -> ")
-        info     (str the-name " :: " menu)]
+  [the-name the-methods]
+  (let [nam      (name (read-string the-name))
+        rtypes   (map #(-> % .getReturnType .getSimpleName) the-methods)
+        arglists (map (fn [m]
+                        (let [types (.getParameterTypes m)]
+                          (vec (map #(.getSimpleName %) types))))
+                      the-methods)
+        info     (apply str "  " the-name \newline \newline
+                        (map #(str "  " %1 " " nam
+                                   (str-wrap (str-cat %2 ", ") \( \))
+                                   \; \newline)
+                             rtypes arglists))]
     (hash-map "word" the-name
               "kind" "M"
+              "menu" (print-str arglists)
+              "info" info)))
+
+(defmethod make-completion-item "S"
+  [the-name [the-field]]
+  (let [nam  (name (read-string the-name))
+        menu (-> the-field .getType .getSimpleName)
+        info (str "  " the-name \newline \newline
+                  "  " menu " " the-name \newline)]
+    (hash-map "word" the-name
+              "kind" "S"
               "menu" menu
               "info" info)))


relationship denormalization model

relationship denormalization model

--- src/er_cassandra/model/types.clj
+++ src/er_cassandra/model/types.clj
@@ -5,6 +5,7 @@
    [cats.labs.manifold :refer [deferred-context]]
    [schema.core :as s]
    [clj-time.core :as t]
+   [er-cassandra.util.vector :as v]
    [er-cassandra.key :as k]))

 (s/defschema CallbackFnSchema
@@ -14,7 +15,7 @@
   {(s/optional-key :after-load) [CallbackFnSchema]
    (s/optional-key :before-save) [CallbackFnSchema]})

-;; a private key for a cassandra table
+;; a primary key for a cassandra table
 ;; the first entry may itself be a vector, representing
 ;; a compound partition key
 (s/defschema KeySchema
@@ -31,6 +32,33 @@
 ;; a single column
 (s/defschema SecondaryKeySchema
   s/Keyword)
+
+;; just map parent fidles to child fields for now
+;; :foreign-key and :parent-entity-key will be
+;; included by default
+(s/defschema DenormalizeSchema
+  {s/Keyword s/Keyword})
+
+;; a Relationship allows fields from a parent Entity or
+;; one of its index tables to be
+;; denormalized to records of a child Entity. 1-1 and 1-many
+;; relationships are supported and large child sets are also
+;; supported
+(s/defschema RelationshipSchema
+  {;; target Entity var - will be dynamically deref'd
+   :target s/Symbol
+   ;; the foreign key which must have the corresponding components
+   ;; in the same order as the parent primary key
+   :foreign-key KeySchema
+   ;; the fields to be denormalized
+   :denormalize DenormalizeSchema})
+
+;; basic table schema shared by primary, secondary
+;; unique-key and lookup tables
+(s/defschema TableSchema
+  {:name s/Keyword
+   :key KeySchema
+   (s/optional-key :relationships) [RelationshipSchema]})

 ;; the :key is the primary-key of the table, which may
 ;; have a compound parition key [[pk1 pk2] ck1 ck2]
@@ -39,9 +67,8 @@
 ;; delete with a secondary index from seocondary and lookup tables
 ;; TODO use the :entity-key to delete stale secondary and lookup records
 (s/defschema PrimaryTableSchema
-  {:name s/Keyword
-   :key KeySchema
-   (s/optional-key :entity-key) SecondaryKeySchema})
+  (merge TableSchema
+         {(s/optional-key :entity-key) SecondaryKeySchema}))

 ;; some of the (non-partition) columns in a lookup-table
 ;; key may be collections... these will be expanded to the
@@ -53,22 +80,27 @@
   {(s/optional-key :collections) {s/Keyword
                                   (s/pred #{:list :set :map})}})

+(s/defschema EntityKeySchema
+  {(s/optional-key :has-entity-key?) s/Bool})
+
 ;; unique-key tables are lookup tables with a unique
 ;; constraint on the key, enforced with an LWT
 (s/defschema UniqueKeyTableSchema
-  (merge PrimaryTableSchema
-         CollectionKeysSchema))
+  (merge TableSchema
+         CollectionKeysSchema
+         EntityKeySchema))

 ;; secondary tables contain all columns from the primary
 ;; table, with a different primary key.
 ;; secondary and lookup tables may be materialized views,
 ;; which will be used for query but won't be upserted to
 (s/defschema SecondaryTableSchema
-  (merge PrimaryTableSchema
+  (merge TableSchema
+         EntityKeySchema
          {(s/optional-key :view?) s/Bool}))

 ;; lookup tables contain columns from the uberkey and
-;; a lookup key
+;; a lookup key, plus any additional with-columns
 (s/defschema LookupTableSchema
   (merge SecondaryTableSchema
          CollectionKeysSchema
@@ -82,6 +114,7 @@
    (s/optional-key :callbacks) CallbacksSchema
    (s/optional-key :versioned?) s/Bool})

+
 (s/defrecord Entity
     [primary-table :- PrimaryTableSchema
      unique-key-tables :- [UniqueKeyTableSchema]
@@ -92,7 +125,7 @@

 (defn ^:private force-key-seq
   [table]
-  (assoc table :key (k/make-sequential (:key table))))
+  (assoc table :key (v/coerce (:key table))))

 (defn ^:private force-key-seqs
   [entity-schema table-seq-key]


WIP on map traversal dispatcher -- add :rook :metadata to requests

--- src/io/aviso/rook/dispatcher.clj
+++ src/io/aviso/rook/dispatcher.clj
@@ -266,7 +266,8 @@
                       :arglist          arglist
                       :arg-resolvers    arg-resolvers
                       :schema           schema
-                      :sync?            sync?}
+                      :sync?            sync?
+                      :metadata         metadata}
             handlers (assoc handlers handler-sym handler)]
         (recur routes handlers middleware (next entries)))
       {:routes     (sorted-routes routes)
@@ -385,7 +386,8 @@
                   apply-middleware (ensure-fn apply-middleware)

                   {:keys [middleware-sym route-params non-route-params
-                          verb-fn-sym arglist arg-resolvers schema sync?]}
+                          verb-fn-sym arglist arg-resolvers schema sync?
+                          metadata]}
                   (get handlers handler-sym)

                   route-param-resolver
@@ -399,9 +401,10 @@
                              (mapv ensure-fn
                                (concat route-param-resolver arg-resolvers))]
                          (fn [handler]
-                           (mw (apply rook/wrap-with-arg-resolvers
-                                 handler resolvers))))
+                           (apply rook/wrap-with-arg-resolvers
+                             (mw handler) resolvers)))
                        mw)
+                  #_#_
                   mw (if schema
                        (fn [handler]
                          (wrap-with-schema (mw handler) schema))
@@ -415,6 +418,9 @@
                                     arglist)]
                          (apply ef args)))
                   h  (apply-middleware mw sync? f)
+                  h  (fn wrapped-with-rook-metadata [request]
+                       (h (update-in request [:rook :metadata]
+                            merge (dissoc metadata :arg-resolvers))))

                   pathvec' (mapv #(if (variable? %) ::param-next %) pathvec)


naming

naming

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/stats/timeseries.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/stats/timeseries.cljs
@@ -45,8 +45,8 @@

 (defn ts-data
   "Performs time series analysis by counting tweets in even intervals."
-  [app]
-  (let [tweets-by-id ((util/tweets-by-order :tweets-map :by-id) app 100000)]
+  [state]
+  (let [tweets-by-id ((util/tweets-by-order :tweets-map :by-id) state 100000)]
     (let [oldest (tweet-ts (last tweets-by-id))
           newest (tweet-ts (first tweets-by-id))
           interval (grouping-interval newest oldest)


Type hinting.

Type hinting.

--- src/onyx/messaging/netty_tcp.clj
+++ src/onyx/messaging/netty_tcp.clj
@@ -114,7 +114,7 @@
   [^ChannelGroup channel-group handler]
   (proxy [ChannelInboundHandlerAdapter] []
     (channelActive [ctx]
-      (.add channel-group (.channel ctx)))
+      (.add channel-group (.channel ^ChannelHandlerContext ctx)))
     (channelRead [^ChannelHandlerContext ctx ^Object message]
       (try
         (handler ctx message)
@@ -213,7 +213,7 @@
            (catch Throwable e
              (timbre/fatal e))))))

-(defn established? [channel]
+(defn established? [^Channel channel]
   (and channel (.isActive channel)))

 (defn create-client [client-group host port]
@@ -232,7 +232,7 @@
                                                      ;TimeUnit/MILLISECONDS
                                                      )
         ch (.channel ch-fut)]
-    (if (and (.isSuccess ch-fut)
+    (if (and (.isSuccess ^ChannelFuture ch-fut)
              (established? ch))
       ch
       (do (.close ch)
@@ -328,7 +328,7 @@

 (defn add-failed-check
   "Check if the message failed to send"
-  [f connection buf]
+  [^ChannelFuture f connection buf]
   (.addListener f (reify GenericFutureListener
                     (operationComplete [_ _]
                       (when-not (.isSuccess f)
@@ -371,7 +371,7 @@
       :failed (connect connection)
       ;; may have finished connecting in the time between
       ;; so we should check if it's established now before trying to reconnect
-      :connected (let [channel-val @channel]
+      :connected (let [channel-val ^Channel @channel]
                    (if (established? channel-val)
                      (.writeAndFlush channel-val buf (.voidPromise channel-val))
                      (reset-connection connection)))))


Each update-in is applied to same key

Each update-in is applied to same key

Without benchmarking everything this is pretty close to bikeshedding.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -37,11 +37,13 @@

 (defn tag-each-message [event]
   (if (= (:onyx/type (:onyx.core/task-map event)) :input)
-    (let [event
-          (-> event
-              (update-in [:onyx.core/batch] (partial map add-ack-value))
-              (update-in [:onyx.core/batch] (partial map (partial add-acker-id event)))
-              (update-in [:onyx.core/batch] (partial map (partial add-completion-id event))))]
+    (let [event (update-in event
+                           [:onyx.core/batch]
+                           (fn [batch]
+                             (map (comp (partial add-completion-id event)
+                                        (partial add-acker-id event)
+                                        add-ack-value)
+                                  batch)))]
       (doseq [raw-segment (:onyx.core/batch event)]
         (extensions/internal-ack-message
          (:onyx.core/messenger event)


Implement analyze-var-uses

Implement analyze-var-uses

--- src/oxcart/passes/tree_shake.clj
+++ src/oxcart/passes/tree_shake.clj
@@ -134,3 +134,33 @@
     (-> ast
         (trim-with-emit-set emit-set)
         (clobber-passes))))
+
+
+(defn analyze-var-uses
+  "λ Whole-AST → Options → Whole-AST
+
+  Walks the argument AST, accumulating call site information about
+  vars. Returns an updated Whole-AST which has the `:var-uses' key
+  set, being a map {Var → #{Var}} where each var maps to the set of
+  vars it is used by.
+
+  Options
+  -----------
+    This pass takes no options"
+  [whole-ast options]
+  (let [{:keys [dependency-map] :as whole-ast}
+        (-> whole-ast
+            (require-pass analyze-var-dependencies {}))
+        acc  (atom {})
+        sconj #(conj (or %1 #{}) %2)]
+
+    ;; FIXME
+    ;;   There's probably a way to write this comprehension which is
+    ;;   more efficient, but this works for now.
+    (doseq [[var deps] dependency-map
+            dep  deps]
+      (swap! acc update-in [dep] sconj var))
+
+    (-> whole-ast
+        (assoc :var-uses @acc)
+        (record-pass analyze-var-uses))))


use a mult in the migration

use a mult in the migration

--- src/pc/admin/migrate_storage.clj
+++ src/pc/admin/migrate_storage.clj
@@ -42,7 +42,7 @@
                                   {:port 8067})))

 (defn setup-transaction-queue []
-  (async/tap (async/mult pcd/tx-report-ch) transaction-tap)
+  (async/tap (async/mult pcd/tx-report-mult) transaction-tap)
   (async/go-loop []
     (when-let [transaction (async/<! transaction-tap)]
       (swap! transaction-queue conj transaction)
@@ -135,3 +135,31 @@
 ;; wait for queue to clear
 ;; make the old instance unhealthy
 ;; shut down the old instance
+
+(defmacro with-ns
+  "Evaluates body in another namespace.  ns is either a namespace
+  object or a symbol.  This makes it possible to define functions in
+  namespaces other than the current one."
+  [ns & body]
+  `(do
+     (create-ns ~ns)
+     (binding [*ns* (the-ns ~ns)]
+       (refer 'clojure.core)
+       ~@(map (fn [form] `(eval '~form)) body))))
+
+(defn replace-tx-report-chan []
+  (with-ns 'pc.datomic
+    (async/close! tx-report-ch)
+    (def tx-report-ch (async/chan (async/sliding-buffer 1024)))
+    (def tx-report-mult (async/mult tx-report-ch)))
+  (with-ns 'pc.http.datomic
+    (defn init []
+      (let [conn (pcd/conn)
+            tap (async/chan (async/sliding-buffer 1024))]
+        (async/tap pcd/tx-report-mult tap)
+        (async/go-loop []
+          (when-let [transaction (async/<! tap)]
+            (utils/with-report-exceptions
+              (handle-transaction transaction))
+            (recur)))))
+    (init)))


Encapsulate referenced code in backquotes

--- src/cats/core.cljc
+++ src/cats/core.cljc
@@ -48,7 +48,7 @@
         ~@body)))

 (defn get-current-context
-  "Alias to cats.context/get-current for backward compatibility."
+  "Alias to `cats.context/get-current` for backward compatibility."
   {:deprecated true}
   ([] (ctx/get-current nil))
   ([default] (ctx/get-current default)))
@@ -87,7 +87,7 @@
   ([ctx v] (p/pure ctx v)))

 (defn return
-  "This is a monad version of pure and it works
+  "This is a monad version of `pure` and works
   identically to it."
   ([v] (return (ctx/get-current) v))
   ([ctx v] (p/mreturn ctx v)))
@@ -133,7 +133,7 @@
   (bind mv identity))

 (defn fmap
-  "Apply a function f to the value inside functor's fv
+  "Apply a function `f` to the value inside functor `fv`,
   preserving the context type."
   ([f]
    (fn [fv]
@@ -425,11 +425,11 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (def <$>
-  "A Haskell-style fmap alias."
+  "A Haskell-style `fmap` alias."
   fmap)

 (def <*>
-  "A Haskell-style fapply alias."
+  "A Haskell-style `fapply` alias."
   fapply)

 (defn >>=


Add 'sort' subcommand

Add 'sort' subcommand

--- src/cljam/core.clj
+++ src/cljam/core.clj
@@ -2,7 +2,8 @@
   (:use [clojure.contrib.command-line :only (with-command-line)])
   (:require [cljam.io :as io]
             [cljam.sam :as sam]
-            [cljam.bam :as bam]))
+            [cljam.bam :as bam]
+            [cljam.sorter :as sorter]))

 (defn -view [args]
   (with-command-line args
@@ -31,9 +32,13 @@

 (defn -sort [args]
   (with-command-line args
-    "Usage: sort <in.bam|sam> <out.bam|sam>"
-    [files]
-    nil))
+    "Usage: sort [--order <coordinate|queryname>] <in.bam|sam> <out.bam|sam>"
+    [[order "Specify sorting order of alignments from <coordinate|queryname>" "coordinate"]
+     files]
+    (let [asam (io/slurp (first files))]
+      (condp = order
+        "coordinate" (io/spit (second files) (sorter/sort-by-pos asam))
+        "queryname"  (io/spit (second files) (sorter/sort-by-qname asam))))))

 (defn -index [args]
   (let [[in-bam _] args]


fixed #112

fixed #112

--- src/server/client-interface.cljs
+++ src/server/client-interface.cljs
@@ -444,7 +444,7 @@
                 (rooms/cancel-upload id
                   (fn []
                     (.publish redis-pub-client "cancel-upload" id)
-                    (rooms/get-room-from-user-id (.-id socket)
+                    (rooms/get-room-from-user-id user-id
                       (fn [room]
                         (.emit (.to io room) "upload-cancelled" id))))))))))))


Make walking into room say where you are and describe room.

--- src/isla/story.clj
+++ src/isla/story.clj
@@ -55,8 +55,8 @@
                                  (connected-rooms (:room player) this)))
             (creturn
              (assoc this :player (assoc player :room (get rooms name)))
-             (str "You are in the " name "."))
             (creturn this (str "You cannot go into the " name ".")))))))
+             (t/room-intro room))
   (look [this arguments-str]
     (let [arguments (extract-arguments arguments-str)]
       (if (empty? arguments)


Removed unused function

Removed unused function

--- src/wishlistd/views/wishlist.clj
+++ src/wishlistd/views/wishlist.clj
@@ -20,9 +20,3 @@
 (defpartial wishlist-as-html [wishlist]
   [:h1 (:title wishlist)]
   [:p "LOLOLOLOL"])
-
-(defn create-wishlist-html []
-  (let [wishlist (insert-wishlist {:title "Default"})
-        with-wishes (assoc wishlist :wishes (get-wishes-for-wishlist wishlist))]
-    (wishlist-as-html with-wishes)))
-


Optionally, keyword args

Optionally, keyword args

--- src/yada/core.clj
+++ src/yada/core.clj
@@ -67,7 +67,7 @@
   (debugf "Context is %s" ctx)
   ctx)

-(defn yada
+(defn yada*
   [{:keys
     [service-available?                 ; async-supported
      known-method?
@@ -370,3 +370,9 @@
 ;; Return deferreds, if necessary, if the computation is length to compute (e.g. for exists? checks)

 ;; CORS support: build this in, make allow-origin first-class, which headers should be allowed should be a hook (with default)
+
+
+(defn yada [& args]
+  (if (keyword? (first args))
+    (yada* (into {} args))
+    (yada* (first args))))


Require yada.bidi in yada.yada

Require yada.bidi in yada.yada

This ensures bidi protocol extension of yada.core/handler, which avoids
the need for clients to require yada.bidi. This is the intention behind
requiring yada.yada- to make things simple for users.

It should remain possible for other routing libraries to be integrated
with yada without conflicting with bidi. But users of yada.yada must be
prepared to accept recommended defaults, otherwise they should use
yada.core.

--- src/yada/yada.clj
+++ src/yada/yada.clj
@@ -4,6 +4,7 @@
   (:refer-clojure :exclude [partial])
   (:require
    yada.core
+   yada.bidi
    yada.swagger
    yada.resources.atom-resource
    yada.resources.collection-resource


Speed up specificity-sort

Speed up specificity-sort

--- src/lt/object.cljs
+++ src/lt/object.cljs
@@ -42,8 +42,12 @@
                    behs)]
     listeners))

-(defn specificity-sort [xs dir]
-  (sort-by #(do [(count (string/split (str %) ".")) (str %)]) (if dir < >) xs))
+(defn specificity-sort [xs]
+  (let [arr #js []]
+    (doseq [x xs]
+      (.push arr #js [(count (string/split (name x) ".")) (name x) x]))
+    (.sort arr)
+    (amap arr i _ (aget arr i 2))))

 (defn tags->behaviors [ts]
   (let [duped (apply concat (map @tags (specificity-sort ts)))


Some clean up on the agent based client

Some clean up on the agent based client

--- clojure-agents/src/clojure_agents/core.clj
+++ clojure-agents/src/clojure_agents/core.clj
@@ -22,11 +22,11 @@
     (prn (format "Milliseconds taken: %d" (Math/round (double (/ (- (System/nanoTime) start) 1000000)))))))

 (defn- put-on-builder
-  [builder partial-edges]
+  [builder edges-range]
   (let [partial-map
-        (reduce #(assoc-in %1 [(:i %2) (:j %2)] (:weight %2)) {} partial-edges)]
+        (reduce #(assoc-in %1 [(:i %2) (:j %2)] (:weight %2)) {} edges-range)]
     (assoc builder
-           :edges-assembled (+ (builder :edges-assembled) (count partial-edges))
+           :edges-assembled (+ (builder :edges-assembled) (count edges-range))
            :data (merge-with merge (builder :data) partial-map))))

 (defn- on-builder-updated [key ref old builder]
@@ -34,41 +34,34 @@
     (send graph build-graph builder)))

-(defn- get-edges
+(defn- get-edges-range
   [_ offset limit]
   (json/read-str
     (:body (http-client/get (format "http://localhost:8080/api/graph?offset=%d&limit=%d"
                                     offset limit)))
     :key-fn keyword))

-(defn- assemble-graph
-  [assembled partial-edges]
-  (merge-with merge assembled partial-edges))
-
-(defn- on-edges-received
-  [key ref old edges]
-  (send graph-builder put-on-builder edges))
-
-(defn- get-graph
-  [offsets]
-  (doseq [offset offsets]
-    (let [edges (agent [])]
-      (do
-        (add-watch edges :edges-watcher on-edges-received)
-        (set-error-mode! edges :continue)
-        (set-error-handler!
-          edges
-          (fn [agent _] (send-off agent get-edges offset 1000)))
-        (send-off edges get-edges offset 1000)))))
+(defn- on-edges-range-received
+  [key ref old edges-range]
+  (send graph-builder put-on-builder edges-range))

 (defn- edges-amount-watcher
   [key ref old edges-amount]
-  (def offsets
-    (map #(* 1000 %)
-         (let [batches-amount
-               (+ (quot edges-amount 1000) (Integer/signum (mod edges-amount 1000)))]
-           (range batches-amount))))
-  (get-graph offsets))
+  (let [offsets
+        (map
+          #(* 1000 %)
+          (let [batches-amount
+                (+ (quot edges-amount 1000) (Integer/signum (mod edges-amount 1000)))]
+            (range batches-amount)))]
+    (doseq [offset offsets]
+    (let [edges-range (agent [])]
+      (do
+        (add-watch edges-range :edges-range-watcher on-edges-range-received)
+        (set-error-mode! edges-range :continue)
+        (set-error-handler!
+          edges-range
+          (fn [agent _] (send-off agent get-edges-range offset 1000)))
+        (send-off edges-range get-edges-range offset 1000))))))

 (defn main
   []


API: Allow updating of documents with empty page list

--- src/pepa/model.clj
+++ src/pepa/model.clj
@@ -272,9 +272,11 @@
             (db/update! conn :documents
                         props
                         ["id = ?" id])
-            (when (and (seq pages)
+            (when (and (sequential? pages)
                        (not= (mapv :id (document-pages db id))
                              (vec pages)))
+              (when (empty? pages)
+                (log/warn db "Updating document with empty list of pages:" id))
               (set-pages*! db id (vec pages)))))
         (db/notify! conn :documents/updated {:id id}))
       (throw (ex-info (str "Couldn't find document with id " id)


desktop: Remove input for title from chapter screen

--- apps/desktop/src_front/souptitle_desktop/manager/views/content.cljs
+++ apps/desktop/src_front/souptitle_desktop/manager/views/content.cljs
@@ -45,10 +45,6 @@
                  :display "flex"
                  :flex-direction "column"
                  :padding "10px 20px"}}
-   [inputview {:style {:font-size "18px"
-                       :font-family "Roboto"}
-               :value title
-               :on-blur #(dispatch [:update-chapter-title %])}]
    [srt-link]
    [textview {:style {:flex 1}
               :value src


dummy content

dummy content

--- frontend/components/language_landing.cljs
+++ frontend/components/language_landing.cljs
@@ -40,11 +40,11 @@
                                         :img "/assets/img/outer/stories/john.jpg"
                                         :author "Kevin Rose"
                                         :title "Entrepneur @Google"}
-                                       {:text "text 2"
+                                       {:text "Nullam id dolor id nibh ultricies vehicula ut id elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis."
                                         :img "/assets/img/outer/stories/john.jpg"
                                         :author "Clark Kent"
                                         :title "superman"}
-                                       {:text "text 3"
+                                       {:text "Nullam id dolor id nibh ultricies vehicula ut id elit. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Integer posuere erat a ante venenatis."
                                         :img "/assets/img/outer/stories/john.jpg"
                                         :author "Bruce Wayne"
                                         :title "Batman"}]}})


add declare

add declare

--- clj-tcp/src/clj_tcp/client.clj
+++ clj-tcp/src/clj_tcp/client.clj
@@ -18,6 +18,8 @@
             [io.netty.bootstrap Bootstrap]
             [io.netty.channel.socket.nio NioSocketChannel]))

+(declare get-default-threads)
+
 (defrecord Client [group read-group channel-f write-ch read-ch internal-error-ch error-ch ^AtomicInteger reconnect-count ^AtomicBoolean closed])

@@ -220,12 +222,6 @@
 (defn read-print-in [{:keys [read-ch]}]
   (read-print-ch "read" read-ch))

-
-(defn- create-write-lock-ch [max-concurrent-writes]
-  (let [write-lock-ch (chan (dropping-buffer max-concurrent-writes))]
-    (go
-      (doseq [i (range max-concurrent-writes)]
-        (>! write-lock-ch 1)))))

 (defn write-poison [{:keys [write-ch read-ch internal-error-ch]}]
   (go (>! write-ch [(->Poison) 1] ))


[frontend]: Fix cljfmt

[frontend]: Fix cljfmt

--- frontend/test/warehouse/selenium/test.clj
+++ frontend/test/warehouse/selenium/test.clj
@@ -59,19 +59,19 @@
 ;; https://github.com/mozilla/geckodriver/issues/858
 #_(deftest import-export []
   ; reset env
-  (to base-url)
-  (execute-script "localStorage.clear();")
-
-  (refresh)
+    (to base-url)
+    (execute-script "localStorage.clear();")
+
+    (refresh)

   ; guard: there is zero components
-  (is (empty? (elements "//li[@class='component']")))
-
-  (upload-file (fixture-path "export.json"))
-
-  (wait-until #(not-empty? (elements "//li[@class='component']")))
-  (refresh)
-  (wait-until #(not-empty? (elements "//li[@class='component']"))))
+    (is (empty? (elements "//li[@class='component']")))
+
+    (upload-file (fixture-path "export.json"))
+
+    (wait-until #(not-empty? (elements "//li[@class='component']")))
+    (refresh)
+    (wait-until #(not-empty? (elements "//li[@class='component']"))))

 (defn create-component [component]
   (click "//button[contains(text(), 'Add new')]")


more small stuff

more small stuff

--- src/soot/cards.clj
+++ src/soot/cards.clj
@@ -1100,6 +1100,7 @@
   :class :mage
   :cost 3
   :secret {
+    ; before
     :when-opponent-spell-cast #(if
       (and (:minion (current-target %)) (is-friendly (current-target %)))
       (-> %
@@ -1506,7 +1507,7 @@
   :set :expert
   :class :paladin
   :cost 2
-  :spell (target-all :minion (set-target {:health 1}))
+  :spell (target-all [:minion] (set-target {:health 1}))
 }
 {
   :id 125
@@ -2170,6 +2171,7 @@
   :minion {
     :attack 3
     :health 2
+    ; after
     :when-my-spell-cast (target-all [:minion] (damage-target 1))
   }
 }
@@ -2343,6 +2345,7 @@
   :class :rogue
   :cost 2
   :spell (target [:opponent :minion]
+    ; todo: account for poison
     #(let [damage (:attack (current-target %))]
       ((target-all [:adjacent-to-target] (damage-target damage)) %)))
 }
@@ -4300,7 +4303,7 @@
   :minion {
     :attack 4
     :health 4
-    :battlecry #(let [n (count (filter-all % [:my :minion]))]
+    :battlecry #(let [n (count (filter-all % [:my :minion {:not :self}]))]
       (-> % (buff-self n n)))
   }
 }


Remove unnecessary binding in problem62.clj

--- euler_clojure/src/euler/problem62.clj
+++ euler_clojure/src/euler/problem62.clj
@@ -17,9 +17,8 @@
          cubes {}]
     (let [x (math/expt i 3)
           canonical (str/join (sort (str x)))
-          seen (get cubes canonical [])
-          next (conj seen x)]
-      (if (= 5 (count next))
-        (apply min next)
+          seen (conj (get cubes canonical []) x)]
+      (if (= 5 (count seen))
+        (apply min seen)
         (recur (inc i)
-               (assoc cubes canonical next))))))
+               (assoc cubes canonical seen))))))


Use literal vector in problem62.clj

Use literal vector in problem62.clj

--- euler_clojure/src/euler/problem62.clj
+++ euler_clojure/src/euler/problem62.clj
@@ -17,7 +17,7 @@
          cubes {}]
     (let [x (math/expt i 3)
           canonical (str/join (sort (str x)))
-          seen (get cubes canonical (vector))
+          seen (get cubes canonical [])
           next (conj seen x)]
       (if (= 5 (count next))
         (apply min next)


fix(deps): update dependency org.clojure:clojure to v1.10.1 (#78)

--- technologies/clojure/project.clj
+++ technologies/clojure/project.clj
@@ -3,7 +3,7 @@
   :url "http://example.com/FIXME"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[org.clojure/clojure "1.10.0"]
+  :dependencies [[org.clojure/clojure "1.10.1"]
                  [javax.servlet/servlet-api "2.5"]
                  [ring/ring-core "1.7.1"]
                  [http-kit "2.3.0"]