Added optimize macro to precompile functions with literal arguments

--- src/hiccup.clj
+++ src/hiccup.clj
@@ -46,3 +46,23 @@
   [tag]
   (let [[_ tag id classes] (re-matches re-tag (as-str tag))]
     (str "<" tag (make-attrs {:id id, :class classes}))))
+
+(defn literal?
+  "True if the object is a literal string, keyword, number or quoted object."
+  [x]
+  (or (string? x)
+      (number? x)
+      (keyword? x)
+      (and (seq? x) (= (first x) 'quote))))
+
+(defmacro optimize
+  "Pre-compile an expression when the arguments are all literals."
+  [func & args]
+  (if (every? literal? args)
+    (eval (list* func args))
+    (list* func args)))
+
+(defn compile-tag
+  [tag & content]
+  `(let [sb# (StringBuffer.)]
+     (.append sb# (optimize make-start-tag ~tag))))


Remove keys that should not be included

Remove keys that should not be included

--- src/ctia/schemas/indicator.clj
+++ src/ctia/schemas/indicator.clj
@@ -67,14 +67,6 @@
     (s/optional-key :tags)
     (describe [s/Str]
               "Descriptors for this indicator")
-
-    (s/optional-key :observable)
-    (describe c/Observable
-              "a relevant cyber observable for this Indicator")
-
-    (s/optional-key :judgements)
-    (describe rel/RelatedJudgements
-              "related Judgements for this Indicator")

     (s/optional-key :composite_indicator_expression)
     CompositeIndicatorExpression


typo in load-deps

typo in load-deps

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -123,7 +123,7 @@
          (let [dep (first deps)]
            (when-not (or (not-empty (get-in compiler [::namespaces dep :defs]))
                          (contains? (:js-dependency-index compiler) (name dep)))
-             (require bound-vars name opts
+             (require bound-vars lib opts
                (fn [_]
                  (load-deps bound-vars lib (next deps) opts cb)))))
          (cb))))))


add description for credential template for cloud connector

--- cimi/src/com/sixsq/slipstream/ssclj/resources/credential_template_cloud.clj
+++ cimi/src/com/sixsq/slipstream/ssclj/resources/credential_template_cloud.clj
@@ -19,6 +19,15 @@
    :quota       20
    :acl         resource-acl-default})

+(def connector-template-description
+  {:connector {:displayName "Connector"
+               :category    "general"
+               :description "connector cimi href"
+               :type        "href"
+               :mandatory   true
+               :readOnly    false
+               :order       12}})
+
 (defn cred-type
   [cloud-service-type]
   (str "cloud-cred-" cloud-service-type))
@@ -39,6 +48,7 @@
 (defn gen-description
   [cloud-service-type]
   (merge ct/CredentialTemplateDescription
+         connector-template-description
          (slurp-cloud-cred-desc cloud-service-type)))

 (defn register


Remove temporary fix for #344

Remove temporary fix for #344

--- src/onyx/peer/function.clj
+++ src/onyx/peer/function.clj
@@ -38,17 +38,6 @@
 (defrecord Function [replica peer-replica-view state messenger egress-tasks]

   p-ext/PipelineInput
-
- ;;; Start temp fix for: https://github.com/onyx-platform/onyx/issues/344
-  (ack-segment [this event message-id])
-
-  (retry-segment [this event message-id])
-
-  (pending? [this event message-id])
-
-  (drained? [this event])
-  ;;; End temp fix.
-
   p-ext/Pipeline

   (read-batch


Improved doc of with-channel w.r.t. asynchronicity

--- src/org/httpkit/server.clj
+++ src/org/httpkit/server.clj
@@ -93,12 +93,16 @@
   ;; Asynchronous HTTP response (with optional streaming)
   (defn my-async-handler [request]
     (with-channel request ch ; Request's channel
-      (future ; Respond from any thread
-        (send! ch {:status  200
-                   :headers {\"Content-Type\" \"text/html\"}
-                   :body    \"This is an async response!\"}
-               ;; false ; Uncomment to use chunk encoding for HTTP streaming
-               ))))
+      ;; Make ch available to whoever can deliver the response to it; ex.:
+      (swap! clients conj ch)))   ; given (def clients (atom #{}))
+  ;; Some place later:
+  (doseq [ch @clients]
+    (swap! clients disj ch)
+    (send! ch {:status  200
+                 :headers {\"Content-Type\" \"text/html\"}
+                 :body your-async-response}
+             ;; false ; Uncomment to use chunk encoding for HTTP streaming
+             )))

   ;; WebSocket response
   (defn my-chatroom-handler [request]


update

update


Set up weights in recenter-clusters

Set up weights in recenter-clusters

--- src/polismath/clusters.clj
+++ src/polismath/clusters.clj
@@ -137,7 +137,9 @@
   "Replace cluster centers with a center computed from new positions"
   [data clusters & {:keys [weights]}]
   (map
-    #(assoc % :center (weighted-mean (matrix (get-matrix (rowname-subset data (:members %))))))
+    (fn [clst]
+      (assoc clst :center (weighted-mean (rowname-subset data (:members clst))
+                                         :weights weights)))
     clusters))


implement reset

implement reset

--- src/pomodoro/pomodoro.cljs
+++ src/pomodoro/pomodoro.cljs
@@ -64,7 +64,7 @@
 ; END timer-top

 ; START timer-controls
-(defn timer-controls [on _]
+(defn timer-controls [{:keys [on] :as cursor} _]
   (reify
     om/IRender
     (render [_]
@@ -85,7 +85,11 @@
                                    (dom/i #js {:className "icon-stop"}))))
         ;; Reset button
         (dom/div #js {:className "reset-control-outer control-outer"}
-                 (dom/div #js {:className "control-inner"}
+                 (dom/div #js {:className "control-inner"
+                               :onClick #(when (not (.valueOf on))
+                                           (om/transact!
+                                             cursor
+                                             (fn [c] (into c (default-state)))))}
                           (dom/div #js {:className "control-icon"}
                                    (dom/i #js {:className "icon-refresh"}))))))))
 ; END timer-controls
@@ -110,7 +114,7 @@
     (render [_]
       (dom/div
         #js {:className "timer-middle"}
-        (om/build timer-controls (:on cursor))
+        (om/build timer-controls cursor)
         (om/build timer-view cursor)))))
 ; END timer-middle

@@ -130,7 +134,6 @@
 (defn can-update [{:keys [stime etime on]}]
   (and (.valueOf on) (> (- etime stime) 0)))
 ; END can-update
-

 ; START pom-view
 (defn pom-view [{:keys [stime on] :as app} owner]


CMR-3685: Removed output

CMR-3685: Removed output

--- mock-echo-app/src/cmr/mock_echo/api/tokens.clj
+++ mock-echo-app/src/cmr/mock_echo/api/tokens.clj
@@ -87,7 +87,6 @@
           {:status 200})
         (GET "/current_sids" {context :request-context}
           ;; Does not require sys admin token
-          (println (pr-str context))
           (if (= "expired-token" token-id)
             ;; echo-rest returns status code 400 for request with expired token
             (ah/status-bad-request {:errors ["Token [expired-token] has expired."]})


yet more attempting

yet more attempting

--- src/mafia_votecount/models.clj
+++ src/mafia_votecount/models.clj
@@ -82,7 +82,7 @@

 (defn delete-game-by-id [id]
   (delete game
-  (where {:id (str id)})))
+  (where {:id (str ' id ')})))

 (defn delete-player-by-id [id]
   (delete player


fix cljsdoc task

fix cljsdoc task

--- src/main/cljs_api_gen/core.clj
+++ src/main/cljs_api_gen/core.clj
@@ -38,7 +38,7 @@
   (binding [*output-dir* out-dir]
     (case task
       :docset  (docset/create!)
-      :cljsdoc (let [num-skipped (build-cljsdoc! result)]
+      :cljsdoc (let [num-skipped (build-cljsdoc!)]
                  (when-not (zero? num-skipped)
                    (System/exit 1)))
       (create-catalog! options)))


added optional arg :after to docstring for `before`

--- src/midje/ideas/background.clj
+++ src/midje/ideas/background.clj
@@ -45,6 +45,7 @@

   (defmacro before
     "Code to run before a given wrapping target (:facts, :contents, :checks).
+     Take an optional keyword argument :after, for any code to run afterward.
      Used with background and against-background"
     [wrapping-target before-form & {:keys [after]}]
     (ensure-correct-form-variable `(try


Fix handling of editor atom.

Fix handling of editor atom.

--- src/mini_code_edit/editor.cljs
+++ src/mini_code_edit/editor.cljs
@@ -34,7 +34,7 @@
   [title]
   (let [title (set-title title)
         [mode mode-name] (get-mode title)]
-    (.setOption @editor "mode" mode)
+    (swap! editor #(.setOption % "mode" mode))
     (aset (by-id "mode") "innerHTML" mode-name)))

 ;; file functions -------------------------------------------------------------
@@ -88,7 +88,7 @@
   (if false
     (do
       (new-file)
-      (.setValue @editor ""))
+      (swap! editor #(.setValue % "")))
     (let [x (+ 10 (.-screenX js/window))
           y (+ 10 (.-screenY js/window))]
       (.open js/window "main.html" "_blank"
@@ -115,7 +115,7 @@
 (defn cut-func []
   (do
     (.set clipboard (.getSelection @editor))
-    (.replaceSelection @editor "")))
+    (swap! editor #(.replaceSelection % ""))))

 (defn paste-func []
   (.replaceSelection @editor (.get clipboard)))
@@ -148,7 +148,7 @@
         scroller-element (.getScrollerElement @editor)]
     (set-style! scroller-element "width" (str container-width "px"))
     (set-style! scroller-element "height" (str container-height "px"))
-    (.refresh @editor)))
+    (swap! editor #(.refresh %))))

 (defn new-editor []
   (js/CodeMirror (by-id "editor")


File left out of prior commit.

File left out of prior commit.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -81,7 +81,7 @@

 ; A resource for operations on a particular entry
 (defresource entry [conn org-slug board-slug topic-slug as-of]
-  (api-common/open-company-authenticated-resource config/passphrase) ; verify validity and presence of required JWToken
+  (api-common/open-company-anonymous-resource config/passphrase) ; verify validity of optional JWToken

   :allowed-methods [:options :get :patch :delete]

@@ -99,7 +99,7 @@
   ;; Authorization
   :allowed? (by-method {
     :options true
-    :get (fn [ctx] (access/access-level-for conn org-slug (:user ctx)))
+    :get (fn [ctx] (access/access-level-for conn org-slug board-slug (:user ctx)))
     :patch (fn [ctx] (access/allow-authors conn org-slug board-slug (:user ctx)))
     :delete (fn [ctx] (access/allow-authors conn org-slug board-slug (:user ctx)))})

@@ -132,7 +132,7 @@

 ; A resource for operations on all entries of a particular topic
 (defresource entry-list [conn org-slug board-slug topic-slug]
-  (api-common/open-company-authenticated-resource config/passphrase) ; verify validity and presence of required JWToken
+  (api-common/open-company-anonymous-resource config/passphrase) ; verify validity of optional JWToken

   :allowed-methods [:options :get :post :delete] ; :delete is handled by the topic resource

@@ -154,7 +154,7 @@
   ;; Authorization
   :allowed? (by-method {
     :options true
-    :get (fn [ctx] (access/access-level-for conn org-slug (:user ctx)))
+    :get (fn [ctx] (access/access-level-for conn org-slug board-slug (:user ctx)))
     :post (fn [ctx] (access/allow-authors conn org-slug board-slug (:user ctx)))})

   ;; Validations


Escape chars <>{}\ in ugen names for Graphviz compatibility. Also make ugen nodes link from name section of record for neatness.

--- src/overtone/repl/graphviz.clj
+++ src/overtone/repl/graphviz.clj
@@ -35,6 +35,14 @@
                  (range)
                  in-vals)))))

+(defn- graphviz-escape-chars
+  [s]
+  (let [esc-chars "<>{}\\"
+        char->esc (zipmap esc-chars
+                          (map #(str "\\" %) esc-chars))]
+    (apply str (replace char->esc s))))
+
+
 (defn- generate-node-info
   [ugs]
   (with-out-str
@@ -63,7 +71,7 @@
                                             (str "}|" (name in-name) "}"))
                                           "|"))))))
                         (print "} |"))
-                      (:name ug)
+                      "<__UG_NAME__>"(graphviz-escape-chars (:name ug))

                       " }\" style=" (cond
                                      (= :ar (:rate ug)) "\"bold, rounded\""
@@ -74,10 +82,10 @@
   (cond
    (vector? input)      (dorun (map (fn [idx i]
                                       (when (associative? i)
-                                        (println (str (:id i) " -> " (:id ug) ":" (safe-name n) "___" (safe-name (:name i)) "___" idx " ;"))))
+                                        (println (str (:id i) ":__UG_NAME__ -> " (:id ug) ":" (safe-name n) "___" (safe-name (:name i)) "___" idx " ;"))))
                                     (range)
                                     input))
-   (associative? input) (println (str (:id input) " -> " (:id ug) ":" (safe-name n) " ;"))))
+   (associative? input) (println (str (:id input) ":__UG_NAME__ -> " (:id ug) ":" (safe-name n) " ;"))))

 (defn- generate-node-connections
   [ugs]


Use TextureRegion's width/height values if none is provided

--- src/play_clj/core_graphics.clj
+++ src/play_clj/core_graphics.clj
@@ -159,10 +159,13 @@
   (.draw object batch 1))

 (defmethod draw-entity! :texture
-  [^SpriteBatch batch {:keys [^TextureRegion object x y width height]
-                       :or {x 0 y 0 width 0 height 0}}]
+  [^SpriteBatch batch {:keys [^TextureRegion object x y width height]}]
   (assert object)
-  (.draw batch object (float x) (float y) (float width) (float height)))
+  (let [x (float (or x 0))
+        y (float (or y 0))
+        width (float (or width (.getRegionWidth object)))
+        height (float (or height (.getRegionHeight object)))]
+    (.draw batch object x y width height)))

 (defn draw! [{:keys [renderer] :as screen} entities]
   (assert renderer)


Hopefully fixed weird occasional indexing issue

--- src/polismath/conversation.clj
+++ src/polismath/conversation.clj
@@ -180,11 +180,11 @@
                           :start-vectors (get-in conv [:pca :comps])
                           :iters (:pca-iters opts')))

-      ;:proj (plmb/fnk [rating-mat pca]
-              ;(sparsity-aware-project-ptpts (get-matrix rating-mat) pca))
-
-      :proj (plmb/fnk [mat pca]
-              (pca-project mat pca))
+      :proj (plmb/fnk [rating-mat pca]
+              (sparsity-aware-project-ptpts (get-matrix rating-mat) pca))
+
+;      :proj (plmb/fnk [mat pca]
+              ;(pca-project mat pca))

       :base-clusters
             (plmb/fnk [conv rating-mat proj in-conv opts']
@@ -277,7 +277,7 @@
                         {:tid tid
                          :A (agg-bucket-votes-for-tid bid-to-pid rating-mat agree? tid)
                          :D (agg-bucket-votes-for-tid bid-to-pid rating-mat disagree? tid)}))
-                      (reduce (fn [o entry] (assoc o (:tid entry) (dissoc entry :tid))))))
+                      (reduce (fn [o entry] (assoc o (:tid entry) (dissoc entry :tid))) {})))

       :repness    (plmb/fnk [rating-mat group-clusters base-clusters]
                     (->> (conv-repness rating-mat group-clusters base-clusters)


used ips listing

used ips listing

--- src/proxmox/generators.clj
+++ src/proxmox/generators.clj
@@ -156,7 +156,7 @@
 (defn list-used-ips
   "List used ips in human readable form (mainly for debugging)."
   []
-   (map #( -> % (Long/parseLong) long-to-ip) (wcar (car/zrangebyscore "ips" 0 0))))
+   (map #( -> % (Long/parseLong) long-to-ip) (wcar (car/zrangebyscore "ips" 1 1))))

 (comment


(MAINT) Deduplicate some cp-shared-* code.

--- src/puppetlabs/ezbake/core.clj
+++ src/puppetlabs/ezbake/core.clj
@@ -152,16 +152,28 @@
             (:version lein-project)
             (deputils/generate-manifest-string lein-project))))

+(defn- get-cli-app-files-in
+  [jar]
+  (deputils/find-files-in-dir-in-jar jar shared-cli-apps-prefix))
+
+(defn- get-terminus-files-in
+  [jar]
+  (deputils/find-files-in-dir-in-jar jar terminus-prefix))
+
+(defn- get-bin-files-in
+  [jar]
+  (deputils/find-files-in-dir-in-jar jar shared-bin-prefix))
+
 (defn- get-config-files-in
   [jar]
   (deputils/find-files-in-dir-in-jar jar shared-config-prefix))

-(defn cp-shared-config-files
-  [dependencies]
+(defn cp-shared-files
+  [dependencies files-fn]
   (let [files (for [{:keys [project jar]} dependencies]
-                [project jar (get-config-files-in jar)])]
-    (doseq [[project jar config-files] files]
-      (deputils/cp-files-from-jar config-files jar staging-dir))
+                [project jar (files-fn jar)])]
+    (doseq [[project jar shared-files] files]
+      (deputils/cp-files-from-jar shared-files jar staging-dir))
     ;; Return just a list of the files
     (mapcat last files)))

@@ -182,23 +194,6 @@
         rel-files             (for [config-file project-config-files]
                                 (cp-project-config-file project-config-dir config-file))]
     (concat config-files rel-files)))
-
-(defn- get-cli-app-files-in
-  [jar]
-  (deputils/find-files-in-dir-in-jar jar shared-cli-apps-prefix))
-
-(defn cp-shared-cli-app-files
-  [dependencies]
-  (let [files (for [{:keys [project jar]} dependencies]
-                [project jar (get-cli-app-files-in jar)])
-        cli-dir (str template-dir-prefix "/global/ext/cli")]
-    (doseq [[project jar cli-app-files] files]
-      (deputils/cp-files-from-jar cli-app-files jar staging-dir))
-    (doseq [f (fs/glob (fs/file cli-dir) "*")]
-      (fs/copy+ f (format "%s/%s/%s" staging-dir "ext/cli" (fs/base-name f))))
-    ;; Return just a list of the files
-    (concat (mapcat last files)
-            (map #(str "ext/cli/" %) (fs/list-dir cli-dir)))))

 (defn get-real-name
   [project-name]
@@ -234,19 +229,6 @@
         (deputils/cp-files-of-type lein-project "doc"
                                    docs-prefix get-out-dir-for-doc-file)))

-(defn- get-bin-files-in
-  [jar]
-  (deputils/find-files-in-dir-in-jar jar shared-bin-prefix))
-
-(defn cp-shared-bin-files
-  [dependencies]
-  (let [files (for [{:keys [project jar]} dependencies]
-                [project jar (get-bin-files-in jar)])]
-    (doseq [[project jar bin-files] files]
-      (deputils/cp-files-from-jar bin-files jar staging-dir))
-    ;; Return just a list of the files
-    (mapcat last files)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Upstream EZBake config handling

@@ -294,10 +276,6 @@
   [lein-project]
   (let [upstream-config-streams (deputils/file-file-in-jars lein-project "ext/ezbake.conf")]
     (reduce add-ezbake-config-to-map {} upstream-config-streams)))
-
-(defn- get-terminus-files-in
-  [jar]
-  (deputils/find-files-in-dir-in-jar jar terminus-prefix))

 (defn- prefix-project-name
   [project-name build-target]
@@ -456,12 +434,12 @@
   [_ lein-project build-target template-dir]
   (cp-template-files template-dir)
   (cp-template-files (get-template-file "global"))
-  (let [dependencies (deputils/get-dependencies-with-jars lein-project)
-        config-files (cp-shared-config-files dependencies)
-        config-files (cp-project-config-files config-files)
-        cli-app-files (cp-shared-cli-app-files dependencies)
-        bin-files (cp-shared-bin-files dependencies)
-        terminus-files (cp-terminus-files dependencies build-target)]
+  (let [dependencies    (deputils/get-dependencies-with-jars lein-project)
+        config-files    (cp-shared-files dependencies get-config-files-in)
+        config-files    (cp-project-config-files config-files)
+        cli-app-files   (cp-shared-files dependencies get-cli-app-files-in)
+        bin-files       (cp-shared-files dependencies get-bin-files-in)
+        terminus-files  (cp-terminus-files dependencies build-target)]
     (if cli-app-files
       (cp-cli-wrapper-scripts (:name lein-project)))
     (cp-doc-files lein-project)


Add pe prefix to jar project names in prefix-project-name function

It is useful to be able to have the jar project name pe prefixed when it
is a pe project. This allows package naming and conflict resolution for
the termini to be more uniform and with less hard-codedness.

--- src/puppetlabs/ezbake/core.clj
+++ src/puppetlabs/ezbake/core.clj
@@ -286,16 +286,26 @@
   [jar]
   (deputils/find-files-in-dir-in-jar jar terminus-prefix))

+(defn- prefix-project-name
+  [project build-target]
+    (if (= build-target "pe")
+      (str "pe-" (name project))
+      (str (name project))))
+
+(defn generate-terminus-map
+  [dependencies build-target]
+  (for [{:keys [project version jar]} dependencies
+        :let [terminus-files (get-terminus-files-in jar)]
+        :when (not (empty? terminus-files))]
+    [(prefix-project-name project build-target) version terminus-files jar]))
+
 (defn cp-terminus-files
   "Stage all terminus files. Returns a sequence zipping project names and
   their terminus files."
-  [dependencies]
-  (let [files (for [{:keys [project version jar]} dependencies
-                    :let [terminus-files (get-terminus-files-in jar)]
-                    :when (not (empty? terminus-files))]
-                [project version terminus-files jar])]
+  [dependencies build-target]
+  (let [files (generate-terminus-map dependencies build-target)]
     (doseq [[project version terminus-files jar] files]
-      (println (str "Staging terminus files for " (name project) " version " version))
+      (println (str "Staging terminus files for " project " version " version))
       (deputils/cp-files-from-jar terminus-files jar staging-dir))
     ;; Remove the jars from the returned data
     (map (partial take 3) files)))
@@ -419,7 +429,7 @@
   (let [dependencies (deputils/get-dependencies-with-jars lein-project)
         config-files (cp-shared-config-files dependencies)
         config-files (cp-project-config-files project config-files)
-        terminus-files (cp-terminus-files dependencies)]
+        terminus-files (cp-terminus-files dependencies build-target)]
     (cp-doc-files lein-project)
     (cp-project-file project-file)
     (rename-redhat-spec-file lein-project)


Remove old comment

Remove old comment

--- src/reagent/impl/batching.cljs
+++ src/reagent/impl/batching.cljs
@@ -25,10 +25,6 @@

 (defn compare-mount-order
   [^clj c1 ^clj c2]
-  ;; Mount order is now set in DidMount method.  I.e. the
-  ;; top-most component is mounted last and gets largest
-  ;; number. This is reverse compared to WillMount where method
-  ;; for top component gets called first.
   (- (.-cljsMountOrder c1)
      (.-cljsMountOrder c2)))


Make Closure stop whining about "dangerous use of this in static method"

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -81,27 +81,24 @@
 (defn get-props [this]
   (-> this (aget "props") (aget cljs-props)))

-(defn input-initial-state []
-  (this-as this
-           (let [props (get-props this)]
-             #js {:value (:value props)
-                  :checked (:checked props)})))
-
-(defn input-handle-change [e]
-  (this-as this
-           (let [props (get-props this)
-                 on-change (or (props :on-change) (props "onChange"))]
-             (when-not (nil? on-change)
-               (on-change e)
-               (let [target (.-target e)]
-                 (.setState this #js {:value (.-value target)
-                                      :checked (.-checked target)}))))))
-
-(defn input-will-receive-props [new-props]
-  (this-as this
-           (let [props (aget new-props cljs-props)]
-             (.setState this #js {:value (:value props)
-                                  :checked (:checked props)}))))
+(defn input-initial-state [this]
+  (let [props (get-props this)]
+    #js {:value (:value props)
+         :checked (:checked props)}))
+
+(defn input-handle-change [this e]
+  (let [props (get-props this)
+        on-change (or (props :on-change) (props "onChange"))]
+    (when-not (nil? on-change)
+      (on-change e)
+      (let [target (.-target e)]
+        (.setState this #js {:value (.-value target)
+                             :checked (.-checked target)})))))
+
+(defn input-will-receive-props [this new-props]
+  (let [props (aget new-props cljs-props)]
+    (.setState this #js {:value (:value props)
+                         :checked (:checked props)})))

 (defn input-render-setup [this jsprops]
   (let [state (aget this "state")]
@@ -140,9 +137,10 @@
     (when (input-components comp)
       (doto def
         (aset "shouldComponentUpdate" nil)
-        (aset "getInitialState" input-initial-state)
-        (aset "handleChange" input-handle-change)
-        (aset "componentWillReceiveProps" input-will-receive-props)))
+        (aset "getInitialState" #(this-as C (input-initial-state C)))
+        (aset "handleChange" #(this-as C (input-handle-change C %)))
+        (aset "componentWillReceiveProps"
+              #(this-as C (input-will-receive-props C %)))))
     (.createClass React def)))

 ;; From Weavejester's Hiccup, via pump:


Use trimmed copy when transferring larger to smaller vectors/views.

--- src/clojure/uncomplicate/neanderthal/internal/host/buffer_block.clj
+++ src/clojure/uncomplicate/neanderthal/internal/host/buffer_block.clj
@@ -272,7 +272,10 @@
 (defmacro ^:private transfer-vector-matrix [source destination]
   `(let [stor# (storage ~destination)]
      (if (and (compatible? ~source ~destination) (.isGapless stor#))
-       (copy (engine ~source) ~source (view-vctr ~destination))
+       (let [dst-view# ^VectorSpace (view-vctr ~destination)
+             n# (min (.dim ~source) (.dim dst-view#))]
+         (when (pos? n#)
+           (subcopy (engine ~source) ~source dst-view# 0 n# 0)))
        (let [da# (real-accessor ~destination)
              nav# (navigator ~destination)
              reg# (region ~destination)
@@ -287,8 +290,10 @@
 (defmacro ^:private transfer-matrix-vector [source destination]
   `(let [stor# (storage ~source)]
      (if (and (compatible? ~destination ~source) (.isGapless stor#))
-       (let [src# (view-vctr ~source)]
-         (copy (engine src#) src# ~destination))
+       (let [src-view# ^VectorSpace (view-vctr ~source)
+             n# (min (.dim src-view#) (.dim ~destination))]
+         (when (pos? n#)
+           (subcopy (engine src-view#) src-view# ~destination 0 n# 0)))
        (let [da# (real-accessor ~source)
              nav# (navigator ~source)
              reg# (region ~source)
@@ -328,8 +333,10 @@

 (defmacro ^:private transfer-vector-vector [source destination]
   `(do
-     (if (and (compatible? ~source ~destination) (fits? ~source ~destination))
-       (copy! ~source ~destination)
+     (if (compatible? ~source ~destination)
+       (when-not (identical? ~source ~destination)
+         (let [n# (min (.dim ~source) (.dim ~destination))]
+           (subcopy (engine ~source) ~source ~destination 0 n# 0)))
        (dotimes [i# (min (.dim ~source) (.dim ~destination))]
          (.set ~destination i# (.entry ~source i#))))
      ~destination))


lein-release plugin: preparing 0.3.28 release

--- re_view/project.clj
+++ re_view/project.clj
@@ -1,4 +1,4 @@
-(defproject re-view "0.3.28-SNAPSHOT"
+(defproject re-view "0.3.28"
   :description "Tiny React wrapper"
   :url "https://www.github.com/braintripping/re-view/tree/master/re_view"
   :license {:name "Eclipse Public License"


Replace put-pixel with paint-row and call .fill at end

--- src/sierpinski_sieve/core.cljs
+++ src/sierpinski_sieve/core.cljs
@@ -13,11 +13,6 @@
   (let [size 400]
     [:center [:canvas {:width size :height size :id "canvas"}]]))

-(defn put-pixel [ctx x y]
-  (doto ctx
-    (.rect x y 1 1)
-    (.fill)))
-
 (defn next-row [modulus row]
   (for [x (range 0 (inc (count row)))]
     (let [before (nth row (dec x) 0)
@@ -27,6 +22,12 @@
 (defn sieve [initial-state modulus]
   (iterate (partial next-row modulus) initial-state))

+(defn paint-row [ctx y row size]
+  (doseq [[x value] (map-indexed vector row)]
+    (let [disp-x (+ (* (- size y) 0.5) x)]
+      (if (odd? value)
+        (.rect ctx disp-x y 1 1)))))
+
 (defn paint [canvas-id size sieve]
   (when-let [canvas-element (. js/document getElementById canvas-id)]
     (when-let [ctx (.getContext canvas-element "2d")]
@@ -34,11 +35,9 @@
         (set! (.-fillStyle ctx) "black")
         (.fillRect ctx 0 0 size size)
         (set! (.-fillStyle ctx) "white")
-        (doseq [[y row] (reverse (map-indexed vector sieve))
-                [x value] (map-indexed vector row)]
-          (let [disp-x (+ (* (- size y) 0.5) x)]
-            (if (odd? value)
-              (put-pixel ctx disp-x y))))))))
+        (doseq [[y row] (reverse (map-indexed vector sieve))]
+          (paint-row ctx y row size))
+        (.fill ctx)))))

 (reagent/render-component [render-canvas]
                           (. js/document (getElementById "app")))


Make story prompt report exceptions.

Make story prompt report exceptions.

--- src/tryclojure/models/eval.clj
+++ src/tryclojure/models/eval.clj
@@ -23,10 +23,9 @@
       {:expr expr
        :result [out (eval-expr mode expr)]})
     (catch TimeoutException _
-      {:error true :message "Execution Timed Out!"})))
-    ;; (catch Exception e
-    ;;   {:error true :message (str (root-cause e))})))
-
+      {:error true :message "Execution Timed Out!"})
+    (catch Exception e
+      {:error true :message (str (root-cause e))})))

 (defmulti eval-expr (fn [mode _] mode))
 (defmethod eval-expr "isla" [_ expr] (run-isla-code expr))


Correct manga-here selectors

Correct manga-here selectors

--- resources/sites/manga-here.clj
+++ resources/sites/manga-here.clj
@@ -1,4 +1,4 @@
-{:image-selector [section#viewer.read_img]
+{:image-selector [:section#viewer.read_img :a :img]
  :manga-list-format "%s/mangalist/"
  :comic-list-selector [div.list_manga ul li a.manga_info]

@@ -7,7 +7,7 @@

  :chapter-number-pattern #"c0*\d*/"

- :page-list-selector [select#top_chapter_list option]
+ :page-list-selector [:select.wid60 :option]

  :root-url "http://www.mangahere.co/"
  :manga-url-format "%s/manga/"
@@ -17,7 +17,7 @@
  :link-name-normalize first
  :link-url-normalize identity

- :chapter-list-selector [div.manga_detail div.detail_list ul li span.left a]
+ :chapter-list-selector [:div.manga_detail :div.detail_list :ul :li :span.left :a]
  :chapter-number-match-pattern #"c0*(\d*)/"

  :comic->url-format "%s%s/"}


reorganise tests, only create test db once

--- test/clojento/magento/t_db.clj
+++ test/clojento/magento/t_db.clj
@@ -18,6 +18,9 @@
   {:adapter  "h2"
    :url      (str "jdbc:h2:mem:" (gensym))})

+(def system (atom nil))
+
+; ------------------------------------------------------------------------------

 (defn prepare-test-db []
   (log/info "preparing read-only test DB")
@@ -32,9 +35,9 @@
                       :configurator (clojento.config/static-configurator {:db db-config}))]
       (component/start system)))

-(def system (atom nil))
+; TODO review (namespace-state-changes)

-; TODO review (namespace-state-changes)
+; ------------------------------------------------------------------------------

 ; TODO wrap in (facts ...), maybe?
 (with-state-changes [(before :facts (reset! system (fresh-system (fn []) db-config-in-memory)))
@@ -61,64 +64,64 @@
                   "INSERT INTO `core_website` (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `master_login`, `master_password`, `visibility`) "
                   "VALUES (0, 'admin', 'Admin', 0, 0, 0, 0, '', '', '');"))

-; TODO wrap in (facts ...), possibly?
-(with-state-changes [(before :contents (reset! system (fresh-system prepare-test-db db-config-ro)))
-                     (after  :contents (component/stop @system))]
-  (log/info "starting tests with read-only DB")
-  (fact "migration table exists"
-        (raw-jdbc-fetch (:db @system) "SHOW TABLES;") => (contains {:table_name "ragtime_migrations", :table_schema "public"}))
-  (fact "store table exists"
-        (raw-jdbc-fetch (:db @system) "SHOW TABLES;") => (contains {:table_name "core_store", :table_schema "public"}))
-  (fact "make sure db is read-only"
-        (raw-jdbc-execute (:db @system) write-query) => (throws org.h2.jdbc.JdbcBatchUpdateException #"read only"))
-  (fact "db contains 2 websites (admin + 1) and 2 stores"
-        (count (raw-jdbc-fetch (:db @system) "SELECT * FROM core_website;")) => 2
-        (count (raw-jdbc-fetch (:db @system) "SELECT * FROM core_store;")) => 2
-        (count (run-query (:db @system) :websites [])) => 2
-        (count (run-query (:db @system) :websites [] :debug true)) => 2)
-  (fact "meta contains :hits"
-        (meta (raw-jdbc-fetch (:db @system) "SELECT * FROM core_website;"  :debug true)) => (contains {:hits 2}))
-  (log/info "completed tests with read-only DB"))
-
-(facts "get-product-data and related"
+(facts "with read-only database"
   (with-state-changes [(before :contents (reset! system (fresh-system prepare-test-db db-config-ro)))
                        (after  :contents (component/stop @system))]
     (log/info "starting tests with read-only DB")

-    (fact "get-variants-info"
-          ; not found
-          (get-variants-info (:db @system) -1) => {:has-variants false :is-variant false}
-          ; simple product
-          (get-variants-info (:db @system) 1)  => {:has-variants false :is-variant false}
-          ; configurable product
-          (get-variants-info (:db @system) 2)  => {:has-variants true  :is-variant false :variant-ids [3 4 5]}
-          ; variant (child product)
-          (get-variants-info (:db @system) 3)  => {:has-variants false :is-variant true  :product-id 2}
-          ; has meta
-          (meta (get-variants-info (:db @system) -1 :debug true)) => (contains {:hits 0}))
+    (facts "db and migrations"
+      (fact "migration table exists"
+            (raw-jdbc-fetch (:db @system) "SHOW TABLES;") => (contains {:table_name "ragtime_migrations", :table_schema "public"}))
+      (fact "store table exists"
+            (raw-jdbc-fetch (:db @system) "SHOW TABLES;") => (contains {:table_name "core_store", :table_schema "public"}))
+      (fact "make sure db is read-only"
+            (raw-jdbc-execute (:db @system) write-query) => (throws org.h2.jdbc.JdbcBatchUpdateException #"read only"))
+      (fact "db contains 2 websites (admin + 1) and 2 stores"
+            (count (raw-jdbc-fetch (:db @system) "SELECT * FROM core_website;")) => 2
+            (count (raw-jdbc-fetch (:db @system) "SELECT * FROM core_store;")) => 2
+            (count (run-query (:db @system) :websites [])) => 2
+            (count (run-query (:db @system) :websites [] :debug true)) => 2)
+      (fact "meta contains :hits"
+            (meta (raw-jdbc-fetch (:db @system) "SELECT * FROM core_website;"  :debug true)) => (contains {:hits 2})))

-    (fact "get-product-data returns found"
-          ; not found
-          (get-product-data (:db @system) -1) => (contains {:found false})
-          ; simple product
-          (get-product-data (:db @system) 1)  => (contains {:found true})
-          ; configurable product
-          (get-product-data (:db @system) 2)  => (contains {:found true})
-          ; variant (child product)
-          (get-product-data (:db @system) 3)  => (contains {:found true}))
-    (future-fact "returns is-product"
-                 (get-product-data (:db @system) -1) => (contains {:is-product false})
-                 (get-product-data (:db @system) 1)  => (contains {:is-product true})
-                 (get-product-data (:db @system) 2)  => (contains {:is-product true})
-                 (get-product-data (:db @system) 3)  => (contains {:is-product false}))
-    (future-fact "returns is-variant"
-                 (get-product-data (:db @system) -1) => (contains {:is-variant false})
-                 (get-product-data (:db @system) 1)  => (contains {:is-variant false})
-                 (get-product-data (:db @system) 2)  => (contains {:is-variant false})
-                 (get-product-data (:db @system) 3)  => (contains {:is-variant true}))
-    (future-fact "returns the product-id (id of the parent for variants)"
-                 (get-product-data (:db @system) -1) => (contains {:product-id nil})
-                 (get-product-data (:db @system) 1)  => (contains {:product-id 1})
-                 (get-product-data (:db @system) 2)  => (contains {:product-id 2})
-                 (get-product-data (:db @system) 3)  => (contains {:product-id 2}))
+    (facts "get-variants-info"
+      (fact "not found"
+            (get-variants-info (:db @system) -1) => {:has-variants false :is-variant false})
+      (fact "simple product"
+            (get-variants-info (:db @system) 1)  => {:has-variants false :is-variant false})
+      (fact "configurable product"
+            (get-variants-info (:db @system) 2)  => {:has-variants true  :is-variant false :variant-ids [3 4 5]})
+      (fact "variant (child product)"
+            (get-variants-info (:db @system) 3)  => {:has-variants false :is-variant true  :product-id 2})
+      (fact "has meta"
+            (meta (get-variants-info (:db @system) -1 :debug true)) => (contains {:hits 0})))
+
+    (facts "get-product-data"
+      (fact "found"
+            ; not found
+            (get-product-data (:db @system) -1) => (contains {:found false})
+            ; simple product
+            (get-product-data (:db @system) 1)  => (contains {:found true})
+            ; configurable product
+            (get-product-data (:db @system) 2)  => (contains {:found true})
+            ; variant (child product)
+            (get-product-data (:db @system) 3)  => (contains {:found true}))
+      (future-fact "is-product"
+                   (get-product-data (:db @system) -1) => (contains {:is-product false})
+                   (get-product-data (:db @system) 1)  => (contains {:is-product true})
+                   (get-product-data (:db @system) 2)  => (contains {:is-product true})
+                   (get-product-data (:db @system) 3)  => (contains {:is-product false}))
+      (future-fact "is-variant"
+                   (get-product-data (:db @system) -1) => (contains {:is-variant false})
+                   (get-product-data (:db @system) 1)  => (contains {:is-variant false})
+                   (get-product-data (:db @system) 2)  => (contains {:is-variant false})
+                   (get-product-data (:db @system) 3)  => (contains {:is-variant true}))
+      (future-fact "product-id (id of the parent for variants)"
+                   (get-product-data (:db @system) -1) => (contains {:product-id nil})
+                   (get-product-data (:db @system) 1)  => (contains {:product-id 1})
+                   (get-product-data (:db @system) 2)  => (contains {:product-id 2})
+                   (get-product-data (:db @system) 3)  => (contains {:product-id 2}))
+      (future-fact "has meta"
+            (meta (get-product-data (:db @system) -1 :debug true)) =not=> nil?))
+
     (log/info "completed tests with read-only DB")))


GAWB-23:fixing data-importer

GAWB-23:fixing data-importer

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/tab.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/tab.cljs
@@ -39,10 +39,10 @@
           [:div {:style {:backgroundColor "white" :padding "1em"}}
            (case last-crumb-id
              :file-import
-             [import-data/Page (select-keys props [:workspace-id :reload-data-tab])]
+             [import-data/Page (select-keys props [:workspace-id :reload :import-type])]
              :workspace-import
              [copy-data-workspaces/Page
-              (assoc (select-keys props [:workspace-id :this-realm :reload-data-tab])
+              (assoc (select-keys props [:workspace-id :this-realm :reload])
                 :crumbs (drop 2 (:crumbs @state))
                 :add-crumb #(swap! state update-in [:crumbs] conj %)
                 :pop-to-depth #(swap! state update-in [:crumbs] subvec 0 %))]
@@ -93,7 +93,8 @@
                                           :onClick #(modal/push-modal
                                                      [DataImporter {:workspace-id workspace-id
                                                                     :this-realm this-realm
-                                                                    :reload-data-tab
+                                                                    :import-type "data"
+                                                                    :reload
                                                                     (fn [entity-type]
                                                                       ((:request-refresh props))
                                                                       (react/call :refresh (@refs "entity-table") entity-type))}])}]]])


merging

merging

--- markov-clj/src/markov_clj/twitter.clj
+++ markov-clj/src/markov_clj/twitter.clj
@@ -19,7 +19,7 @@

 (def my-creds (apply make-oauth-creds
                      (clojure.string/split-lines
-                      (slurp "twitter_auth.txt"))))
+                      (slurp "resources/twitter_auth/markov_auth.txt"))))

 ; simply retrieves the user, authenticating with the above credentials
 ; note that anything in the :params map gets the -'s converted to _'s
@@ -35,8 +35,8 @@
                                (map :text)))

 (defn tweet-the-twitter [text]
-  (statuses-update :oauth-creds my-creds
-                   :params {:status text}))
+  (try (statuses-update :oauth-creds my-creds
+                    :params {:status text})))

 (defn store-followers [ids]
   (->>
@@ -69,8 +69,7 @@
 (defn create-and-send-tweet [[screen-name tweets]]
   (println screen-name tweets)
   (->> (make-valid-tweet screen-name tweets)
-       println
-       ;; tweet-the-twitter
+       tweet-the-twitter
        )
   )

@@ -93,8 +92,8 @@
        store-and-reply-to-followers
        ))

-(def ktweets (slurp "resources/koleman_tweets.txt"))
+(defn mock-user [handle]
+  (let [tweets (get-tweets handle)])
+  )

 (defn -main [] (process-followers))
-
-(process-followers)


(TK-33) Add proxy redirect test

(TK-33) Add proxy redirect test

Add a proxy redirect test to the proxy test file.

--- test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_service_proxy_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_service_proxy_test.clj
@@ -26,6 +26,17 @@
                                            ((:headers req) "cookie"))}
     {:status 404 :body "D'oh"}))

+(defn test-handler
+  [req]
+  {:status 200
+   :body   "Hello, World!"})
+
+(defn redirect-test
+  [req]
+  {:status  302
+   :headers {"Location" "http://localhost:9000/hello"}
+   :body    ""})
+
 (defmacro with-target-and-proxy-servers
   [{:keys [target proxy proxy-config proxy-opts ring-handler]} & body]
   `(with-app-with-config proxy-target-app#
@@ -36,6 +47,29 @@
          target-webserver#
          ~ring-handler
          "/hello"))
+     (with-app-with-config proxy-app#
+       [jetty9-service]
+       {:webserver ~proxy}
+       (let [proxy-webserver# (get-service proxy-app# :WebserverService)]
+         (if ~proxy-opts
+           (add-proxy-route proxy-webserver# ~proxy-config "/hello-proxy" ~proxy-opts)
+           (add-proxy-route proxy-webserver# ~proxy-config "/hello-proxy")))
+       ~@body)))
+
+(defmacro with-target-and-proxy-servers-redirect
+  [{:keys [target proxy proxy-config proxy-opts ring-handler-target ring-handler-redirect]} & body]
+  `(with-app-with-config proxy-target-app#
+     [jetty9-service]
+     {:webserver ~target}
+     (let [target-webserver# (get-service proxy-target-app# :WebserverService)]
+       (add-ring-handler
+         target-webserver#
+         ~ring-handler-target
+         "/hello")
+       (add-ring-handler
+         target-webserver#
+         ~ring-handler-redirect
+         "/redirect"))
      (with-app-with-config proxy-app#
        [jetty9-service]
        {:webserver ~proxy}
@@ -389,4 +423,25 @@
             (is (= (read-string (:body response)) params)))
           (let [response (http-get (str "http://localhost:10000/hello-proxy" query))]
             (is (= (:status response) 200))
-            (is (= (read-string (:body response)) params))))))))
+            (is (= (read-string (:body response)) params))))))
+
+    (testing "redirect test with proxy"
+      (with-target-and-proxy-servers-redirect
+        {:target                {:host "0.0.0.0"
+                                 :port 9000}
+         :proxy                 {:host "0.0.0.0"
+                                 :port 10000}
+         :proxy-config          {:host "localhost"
+                                 :port 9000
+                                 :path "/redirect"}
+         :ring-handler-target   test-handler
+         :ring-handler-redirect redirect-test}
+        (let [response (http-get (str "http://localhost:9000/hello"))]
+          (is (= (:status response) 200))
+          (is (= (:body response) "Hello, World!")))
+        (let [response (http-get (str "http://localhost:9000/redirect"))]
+          (is (= (:status response) 200))
+          (is (= (:body response) "Hello, World!")))
+        (let [response (http-get (str "http://localhost:10000/hello-proxy"))]
+          (is (= (:status response) 200))
+          (is (= (:body response) "Hello, World!")))))))


Remove outdated tests.

Remove outdated tests.

--- test/kixi/hecuba/data_test.clj
+++ test/kixi/hecuba/data_test.clj
@@ -1,390 +0,0 @@
-(ns kixi.hecuba.data-test
-  (:use clojure.test)
-  (:require [kixi.hecuba.data.validate :as v]
-            [kixi.hecuba.dev :refer (create-ref-store ->CassandraDirectCommander ->CassandraQuerier sha1-keyfn)]
-            [kixi.hecuba.protocols :refer (upsert! update! delete! item items)]
-            [kixi.hecuba.db :as db]
-            [clojurewerkz.cassaforte.client :as client]
-            [clojurewerkz.cassaforte.query :as query]
-            [clojurewerkz.cassaforte.cql :as cql]
-            [simple-check.generators :as gen]
-            [roul.random :as rr]
-            [clj-time.core :as t]
-            [clj-time.format :as tf]
-            [clj-time.coerce :as tc]
-            [clj-time.periodic :as periodic]
-            [clojure.data.json :as json]))
-
-;; Helpers
-
-(defn uuid [] (java.util.UUID/randomUUID))
-
-(defn transform-measurements
-  "Takes measurements in the format returned from the database.
-   Returns a list of maps, with all values parsed approprietly."
-  [measurements]
-  (map (fn [m]
-         (assoc-in m [:value] (read-string (:value m))))
-       measurements))
-
-;;;;;;;;;;;;;; Generate sensors ;;;;;;;;;;;;;;;
-
-(defn type-gen []
-  (gen/elements ["relativeHumidity" "temperature" "electricityConsumption" "gasAsHeatingFuel"]))
-
-(defn generate-sensor-sample [device-id period n]
-  (take n (repeatedly n #(hash-map :sensor-id (str (uuid))
-                                   :device-id device-id
-                                   :type (first (gen/sample (type-gen) 1))
-                                   :unit ""
-                                   :resolution ""
-                                   :accuracy ""
-                                   :period (first (gen/sample (gen/elements [period])))
-                                   :min ""
-                                   :max ""
-                                   :correction ""
-                                   :correctedUnit ""
-                                   :correctionFactor ""
-                                   :correctionFactorBreakdown ""
-                                   :events 0
-                                   :errors 0))))
-
-;;;;;;;;;;;;;;; Generate devices ;;;;;;;;;;;;;;
-
-(def location-gen
-  (gen/hash-map :name gen/string-alpha-numeric
-                :latitude gen/string-alpha-numeric
-                :longitude gen/string-alpha-numeric))
-
-(defn generate-device-sample
-  [n]
-  (take n (repeatedly n
-                      #(hash-map :device-id (str (uuid))
-                                 :description (first (gen/sample gen/string 1))
-                                 :parent-id (uuid)
-                                 :entity-id (uuid)
-                                 :location (json/write-str (first (gen/sample location-gen 1)))
-                                 :metadata ""
-                                 :privacy (first (gen/sample (gen/not-empty (gen/elements ["public" "private"])) 1))
-                                 :meteringPointId (uuid)))))
-
-;;;;;;;;;;;;;;;;; Generate measurements ;;;;;;;;;;;;;;;;
-
-(defn timestamps [frequency]
-  (into [] (take 50 (periodic/periodic-seq (t/now) frequency))))
-
-(defn get-month [t]
-  (format "%4d-%02d" (t/year t) (t/month t)))
-
-;; Standard measurements
-
-(defmulti generate-measurements
-  "Dispatches a call to a specific device period and generates
-  appropriate measurements."
-  (fn [sensor]
-    (:period sensor)))
-
-(defmethod generate-measurements "INSTANT"
-  [sensor]
-    (let [timestamps (timestamps (t/minutes 5))
-          type       (:type sensor)]
-    (map #(hash-map :device-id (:device-id sensor)
-                    :type type
-                    :month (get-month %)
-                    :timestamp (tc/to-date %)
-                    :value (str (rand 150))
-                    :error "false") timestamps)))
-
-(defmethod generate-measurements "PULSE"
-  [sensor]
-  (let [timestamps (timestamps (t/hours 2))
-        type       (:type sensor)]
-    (map #(hash-map :device-id (:device-id sensor)
-                    :type type
-                    :month (get-month %)
-                    :timestamp (tc/to-date %)
-                    :value (str (rand-int 100))
-                    :error "false") timestamps)))
-
-(defmethod generate-measurements "CUMULATIVE"
-  [sensor]
-   (let [timestamps (timestamps (t/minutes 15))
-         type       (:type sensor)]
-     (map-indexed (fn [i t] (hash-map :device-id (:device-id sensor)
-                                      :type type
-                                      :month (get-month t)
-                                      :timestamp (tc/to-date t)
-                                      :value (str i)
-                                      :error "false")) timestamps)))
-
-(defn measurements
-  "Iterates through all sensors and generates appropriate
-  measurements. Returns a list of maps."
-  [sensor]
-  (generate-measurements sensor))
-
-;; Invalid measurements
-(defn generate-measurements-above-median
-  "Generates measurements that contain readings 200 x median."
-  [sensor]
-  (let [timestamps (timestamps (t/minutes 5))
-        device-id  (:device_id sensor)
-        type       (:type sensor)]
-    (map-indexed (fn [i t] (hash-map :device_id device-id
-                                     :type type
-                                     :month (get-month t)
-                                     :timestamp t
-                                     :value (str (if (= 0 (mod i 50)) (* 300 (rr/rand-gaussian-int)) (rr/rand-gaussian-int)))
-                                     :error "false")) timestamps)))
-
-(defn generate-invalid-measurements
-  "Generates measurements that contain invalid readings."
-  [sensor]
-  (let [timestamps (timestamps (t/minutes 5))
-        device-id  (:device_id sensor)
-        type       (:type sensor)]
-    (map-indexed (fn [i t] (merge {:device_id device-id
-                                   :type type
-                                   :month (get-month t)
-                                   :timestamp (tc/to-date t)}
-                                  (if (= 0 (mod i 5))
-                                    {:value "Invalid reading"
-                                     :error "true"}
-                                    {:value (str (rand-int 10))
-                                     :error "false"}))) timestamps)))
-
-(defn mislabelled-measurements
-  "Generates mislabelled measurements
-   for a given sensor."
-  [sensor period]
-  (let [sensor (assoc-in sensor [:period] period)]
-    (generate-measurements sensor)))
-
-
-
-;;;;;;;;;;; Tests with Cassandra ;;;;;;;;;;;
-
-(defn converge-db
-  "Creates database schema."
-  [session]
-  (binding [client/*default-session* session]
-    (cql/create-table "devices"
-                      (query/column-definitions {:device_id :varchar
-                                                 :description :varchar
-                                                 :parent_id :uuid
-                                                 :entity_id :uuid
-                                                 :location :varchar
-                                                 :metadata :varchar
-                                                 :sensors :varchar
-                                                 :privacy :varchar
-                                                 :meteringPointId :uuid
-                                                 :primary-key [:device_id]}))
-    (cql/create-index "devices" :entity_id)
-
-    (cql/create-table "sensors"
-                      (query/column-definitions {:sensor_id :varchar
-                                                 :device_id :varchar
-                                                 :type :varchar
-                                                 :unit :varchar
-                                                 :resolution :varchar
-                                                 :accuracy :varchar
-                                                 :period :varchar
-                                                 :min :varchar
-                                                 :max :varchar
-                                                 :correction :varchar
-                                                 :correctedUnit :varchar
-                                                 :correctionFactor :varchar
-                                                 :correctionFactorBreakdown :varchar
-                                                 :events :int
-                                                 :errors :int
-                                                 :status :varchar
-                                                 :primary-key [:device_id :type]}))
-
-    (cql/create-table "measurements"
-                      (query/column-definitions {:device_id :varchar
-                                                 :type :varchar
-                                                 :month :varchar
-                                                 :timestamp :timestamp
-                                                 :value :varchar
-                                                 :error :varchar
-                                                 :primary-key [[:device_id :type :month] :timestamp]}))))
-
-(defn delete-schema
-  "Drops all tables"
-  [session]
-  (binding [client/*default-session* session]
-    (cql/drop-table "devices")
-    (cql/drop-table "sensors")
-    (cql/drop-table "measurements")))
-
-(defn validate-and-insert
-  "Updates appropriate counters and inserts data."
-  [querier commander measurement]
-  (let [t (tf/parse (:date-time-no-ms tf/formatters (get measurement "timestamp")))
-        m {:device-id (get measurement "device-id")
-           :type (get measurement "type")
-           :timestamp (tc/to-date t)
-           :value (get measurement "value")
-           :error (get measurement "error")
-           :month (get-month t)}])
-  (v/validate-measurement querier commander  measurement)
-  (upsert! commander :measurement measurement))
-
-(defn insert-measurements
-  [querier commander measurements]
-  (doseq [m measurements] (validate-and-insert querier commander m)))
-
-(defn insert-sensors
-  [session sensors]
-  (binding [client/*default-session* session]
-    (doseq [s sensors] (cql/insert "sensors" s))))
-
-(defn insert-devices
-  [session devices]
-  (binding [client/*default-session* session]
-    (doseq [d devices] (cql/insert "devices" d))))
-
-(defn get-devices
-  "Retrieves a map of n devices from the database."
-  [n]
-  (let [session (-> user/system :cassandra :session)]
-    (binding [client/*default-session* session]
-      (cql/select "devices" (query/limit n)))))
-
-(defn get-measurements
-  [device_id sensor-type month]
-  (let [session (-> user/system :cassandra :session)]
-    (binding [client/*default-session* session]
-      (cql/select "measurements" (query/where :device_id device_id
-                                              :type sensor-type
-                                              :month month)))))
-
-(deftest db-tests
-  ;; TODO Should create and use separate keyspace for tests.
-  (let [session   (get-in user/system [:cassandra :session])
-        commander (->CassandraDirectCommander (get-in user/system [:cassandra :session]))
-        querier   (->CassandraQuerier (get-in user/system [:cassandra :session]))]
-
-    (delete-schema session) ;; C* 1.2 does not support "IF (NOT) EXISTS"
-    (converge-db session)
-
-   (testing "Cumulative devices should be labelled correctly."
-      (let [devices (generate-device-sample 5)
-            sensors (reduce concat (map #(generate-sensor-sample (:device_id %) "CUMULATIVE" 1) devices))]
-        (println "Testing CUMULATIVE sensors - correct labels.")
-        (insert-devices session devices)
-        (insert-sensors session sensors)
-        (doseq [s sensors]
-          (println "Inserting measurements for sensor: " (:sensor_id s))
-          (insert-measurements querier commander (measurements s))
-          (is (v/labelled-correctly? s (sort-by :timestamp (filter #(= (:type s) (:type %))
-                                                                   (transform-measurements
-                                                                    (get-measurements (:device_id s) (:type s) "2014-2")))))))))
-    (testing "Cumulative devices should be mislabelled."
-      (let [devices (generate-device-sample 5)
-            sensors (reduce concat (map #(generate-sensor-sample (:device_id %) "CUMULATIVE" 1) devices))]
-        (println "Testing CUMULATIVE devices - mislabelled.")
-        (insert-devices session devices)
-        (insert-sensors session sensors)
-        (doseq [s sensors]
-          (println "Inserting measurements for sensor: " (:sensor_id s))
-          (insert-measurements querier commander (mislabelled-measurements s "INSTANT"))
-          (is (= false (v/labelled-correctly? s
-                                              (sort-by :timestamp
-                                                       (filter #(= (:type s) (:type %))
-                                                               (transform-measurements
-                                                                (get-measurements (:device_id s) (:type s) "2014-2"))))))))))
-
-    (testing "Should increment error counter."
-      (let [devices (generate-device-sample 5)
-            sensors (reduce concat (map #(generate-sensor-sample (:device_id %) "INSTANT" 1) devices))]
-        (println "Testing errored measurements: INSTANT")
-        (insert-devices session devices)
-        (insert-sensors session sensors)
-        (doseq [s sensors]
-          (println "Inserting measurements for sensor: " (:sensor_id s))
-          (insert-measurements querier commander (generate-invalid-measurements s))
-          (is (= 10 (:errors (db/get-counter session (:device_id s) (:type s) "errors"))))
-          (is (= "broken" (:status (db/get-sensor-status session (:type s) (:device_id s))))))))))
-
-
-;;;;;;;;;;;; Simple check tests (no C*) ;;;;;;;;;;;;
-
-;;; Mislabelled devices ;;;
-
-(deftest mislabelled-devices
-  (let [devices            (generate-device-sample 5)
-        cumulative-sensors (reduce concat (map #(generate-sensor-sample (:device_id %) "CUMULATIVE" 1) devices))
-        pulse-sensors      (reduce concat (map #(generate-sensor-sample (:device_id %) "PULSE" 1) devices))
-        instant-sensors    (reduce concat (map #(generate-sensor-sample (:device_id %) "INSTANT" 2) devices))]
-
-    (testing "Mislabelled devices"
-      (println "Testing mislabelled devices.")
-
-      (doseq [sensor cumulative-sensors]
-        (is (v/labelled-correctly? sensor
-                                   (sort-by :timestamp  (filter #(= (:type sensor) (:type %))
-                                                                (transform-measurements (measurements sensor)))))))
-
-      (doseq [sensor cumulative-sensors]
-        (is (= false (v/labelled-correctly? sensor
-                                            (sort-by :timestamp (filter #(= (:type sensor) (:type %))
-                                                                        (transform-measurements
-                                                                         (mislabelled-measurements sensor "INSTANT"))))))))
-
-      (doseq [sensor instant-sensors]
-        (is (v/labelled-correctly? sensor
-                                   (filter #(= (:type sensor) (:type %))
-                                           (transform-measurements (measurements sensor))))))
-
-      (doseq [sensor pulse-sensors]
-        (is (v/labelled-correctly? sensor
-                                   (filter #(= (:type sensor) (:type %))
-                                           (transform-measurements (measurements sensor))))))
-
-      (doseq [sensor pulse-sensors]
-        (is (= false (v/labelled-correctly? sensor
-                                            (filter #(= (:type sensor) (:type %))
-                                                    (transform-measurements (mislabelled-measurements sensor "INSTANT"))))))))))
-
-;;; 200 x median ;;;
-
-(defn less-than-200x-median-stream?
-  "Returns true if there are no measurements that are greater than their median.
-  Works in a stream."
-  [measurements]
-  (empty? (v/larger-than-median (v/median-stream measurements) measurements)))
-
-(defn less-than-200x-median?
-  "Returns true if there are no measurements that are greater than their median."
-  [measurements]
-  (empty? (v/larger-than-median (v/median measurements) measurements)))
-
-(deftest large-median
-  (let [devices            (generate-device-sample 1)
-        cumulative-sensors (reduce concat (map #(generate-sensor-sample (:device_id %) "CUMULATIVE" 1) devices))
-        pulse-sensors      (reduce concat (map #(generate-sensor-sample (:device_id %) "PULSE" 1) devices))
-        instant-sensors    (reduce concat (map #(generate-sensor-sample (:device_id %) "INSTANT" 1) devices))]
-
-    (println "Testing large median.")
-
-    (testing "Should find readings that are 200 x median in a stream"
-      (doseq [sensor instant-sensors]
-        (is (= false (less-than-200x-median-stream? (transform-measurements (generate-measurements-above-median
-                                                                               sensor)))))))
-
-    (testing "Should find no readings that are 200 x median in a stream"
-      (doseq [sensor cumulative-sensors]
-        (is (less-than-200x-median-stream? (sort-by :timestamp (transform-measurements (measurements sensor)))))))
-
-    (testing "Should find readings that are 200 x median"
-      (doseq [sensor instant-sensors]
-        (is (= false (less-than-200x-median? (transform-measurements (generate-measurements-above-median
-                                                                        sensor)))))))
-
-   (testing "Should find no readings that are 200 x median"
-      (doseq [sensor cumulative-sensors]
-        (is (less-than-200x-median? (transform-measurements (measurements sensor))))))))
-
-
-


Add tests for bind and render custom field.

Using postgresql json type for it.

--- test/suricatta/extend_test.clj
+++ test/suricatta/extend_test.clj
@@ -2,85 +2,65 @@
   (:require [clojure.test :refer :all]
             [suricatta.core :as sc]
             [suricatta.dsl :as dsl]
+            [suricatta.proto :as proto]
             [suricatta.format :refer [get-sql get-bind-values sqlvec] :as fmt]
             [cheshire.core :refer :all])
   (:import org.postgresql.util.PGobject
+           org.jooq.RenderContext
+           org.jooq.BindContext
            org.jooq.impl.DSL))

-;; (def dbspec {:subprotocol "postgresql"
-;;              :subname "//127.0.0.1/test"})
+(def dbspec {:subprotocol "postgresql"
+             :subname "//127.0.0.1/test"})

-;; (def ^:dynamic *ctx*)
+(def ^:dynamic *ctx*)

-;; (defn my-fixture
-;;   [end]
-;;   (with-open [ctx (sc/context dbspec)]
-;;     (sc/atomic ctx
-;;       (binding [*ctx* ctx]
-;;         (end)
-;;         (sc/set-rollback! ctx)))))
+(defn my-fixture
+  [end]
+  (with-open [ctx (sc/context dbspec)]
+    (sc/atomic ctx
+      (binding [*ctx* ctx]
+        (end)
+        (sc/set-rollback! ctx)))))

-;; (use-fixtures :each my-fixture)
-
-;; (defn json
-;;   [data]
-;;   (proxy [org.jooq.impl.CustomField] [nil, org.jooq.util.postgres.PostgresDataType/JSON]
-;;     (accept [ctx]
-;;       (cond
-;;        (instance? org.jooq.RenderContext ctx)
-;;        (doto ctx
-;;          (.sql "'")
-;;          (.sql (generate-string data))
-;;          (.sql "'::json"))
-
-;;        (instance? org.jooq.BindContext ctx)
-;;        (let [obj        (doto (PGobject.)
-;;                           (.setType "json")
-;;                           (.setValue (generate-string data)))
-;;              statement  (.statement ctx)
-;;              _          (println 454545 (class (.getDelegate statement)))
-;;              paramcount (.getParameterCount (.getParameterMetaData statement))]
-;;         (when (<= (.peekIndex ctx) paramcount)
-;;           (.setObject statement
-;;                       (.nextIndex ctx)
-;;                       obj)))))))
-
-
-;; (defn json
-;;   [data]
-;;   (-> (str "'" (generate-string data) "'::json")
-;;       (DSL/queryPart)))
-
-;; (defn json
-;;   [data]
-;;   (proxy [org.jooq.impl.CustomField] [nil org.jooq.util.postgres.PostgresDataType/JSON]
-;;     (toSQL [context]
-;;       (if (.inline context)
-;;         (doto context
-;;           (.sql "'")
-;;           (.sql (generate-string data))
-;;           (.sql "'::json"))
-;;         (.sql context "?")))
-;;     (bind [context]
-;;       (let [statement (.statement context)
-;;             next-index (.nextIndex context)]
-;;         (.setObject statement next-index (doto (PGobject.)
-;;                                            (.setType "json")
-;;                                            (.setValue (generate-string data))))))))
-
+(use-fixtures :each my-fixture)

 ;; (deftest inserting-json
 ;;   (sc/execute *ctx* "create table t1 (data json, k int)")
-;;   (sc/execute *ctx* ["insert into t1 (data, k) values (?, ?)" (json {:foo "bar"}) 2])
-;;   (-> (sc/fetch *ctx* "select * from t1")
+;;   (sc/execute *ctx* ["insert into t1 (data, k) values (?, ?)" (DSL/val #{:foo "bar"} datatype) 3])
+;;   (-> (sc/fetch *ctx* ["select * from t1"])
 ;;       (println)))

-;; (deftest inserting-array
-;;   (sc/execute *ctx* "create table t1 (data json, k int)")
-;;   (sc/execute *ctx* ["insert into t1 (data, k) values ({0}, {1})" (json {:foo "bar"}) 2])
-;;   (-> (sc/fetch *ctx* "select * from t1")
-;;       (println)))
+(deftype MyJson [data])

+(defn myjson
+  [data]
+  (MyJson. data))
+
+(extend-protocol proto/IParamType
+  MyJson
+  (render [self]
+    (str "'"
+         (generate-string (.-data self))
+         "'::json"))
+  (bind [self stmt index]
+    (let [obj (doto (PGobject.)
+                (.setType "json")
+                (.setValue (generate-string (.-data self))))]
+      (.setObject stmt index obj))))
+
+(deftest inserting-json
+  (sc/execute *ctx* "create table t1 (k json)")
+  (sc/execute *ctx* ["insert into t1 (k) values (?)" (myjson {:foo 1})])
+  (let [result (sc/fetch *ctx* ["select * from t1"])
+        result1 (first result)]
+    (is (= (.getValue (:k result1)) (generate-string {:foo 1})))))
+
+(deftest render-json
+  (let [q (-> (dsl/insert-into :t1)
+              (dsl/insert-values {:data (myjson {:foo 1})}))]
+    (is (= (fmt/get-sql q {:dialect :pgsql :type :inlined})
+           "insert into t1 (data) values ('{\"foo\":1}'::json)"))))

 ;; (deftest inserting-json-dsl
 ;;   (sc/execute *ctx* "create table t1 (data json)")
@@ -92,14 +72,18 @@
 ;;       (println)))

-;; (deftest inserting-arrays
-;;   (sc/execute *ctx* "create table t1 (data int[])")
-;;   (let [data [1 2 3]]
-;;     (sc/execute *ctx* ["insert into t1 (data) values (?)" data])
-;;     (-> (sc/fetch *ctx* "select * from t1")
-;;         (println))))

 ;; (deftest json-select
 ;;   (let [q (dsl/select (.as (json {:a 1}) "dd"))]
 ;;     (-> (sc/fetch *ctx* q)
 ;;         (println))))
+
+
+;; (deftest inserting-arrays
+;;   (sc/execute *ctx* "create table t1 (data int[])")
+;;   (let [data [1 2 3]]
+;;     (sc/execute *ctx* ["insert into t1 (data) values (?)" data])
+;;   (let [data (into-array Integer (map int [1 2 3]))]
+;;     (sc/execute *ctx* ["insert into t1 (data) values (?::int[])" "{1,2,3}"])
+;;     (-> (sc/fetch *ctx* "select * from t1")
+;;         (println))))


Add type of `nil`.

Add type of `nil`.


Fix documentation typo in content-type middleware

--- ring-core/src/ring/middleware/content_type.clj
+++ ring-core/src/ring/middleware/content_type.clj
@@ -25,7 +25,7 @@

   :mime-types - a map of filename extensions to mime-types that will be
                 used in addition to the ones defined in
-                ring.util.mime-types/default-mime-types"
+                ring.util.mime-type/default-mime-types"
   ([handler]
    (wrap-content-type handler {}))
   ([handler options]


CMR-2118 Fixes granule ingest validation tests.

--- system-int-test/test/cmr/system_int_test/ingest/granule_validation_test.clj
+++ system-int-test/test/cmr/system_int_test/ingest/granule_validation_test.clj
@@ -125,7 +125,7 @@
             415
             [(msg/invalid-parent-collection-for-validation
                (str "Invalid content-type: application/xml. Valid content-types: "
-                    "application/echo10+xml, application/iso:smap+xml, application/iso19115+xml, application/dif+xml, application/dif10+xml."))]
+                    "application/echo10+xml, application/iso:smap+xml, application/iso19115+xml, application/dif+xml, application/umm+json, application/dif10+xml."))]
             (d/item->concept (dg/granule collection))
             (assoc coll-concept :format "application/xml")))


with-timeout up front

with-timeout up front

--- src/atom_finder/atom_patch.clj
+++ src/atom_finder/atom_patch.clj
@@ -25,6 +25,13 @@
    )
   )

+(defmacro with-timeout [time & body]
+  `(try (thunk-timeout (fn [] ~@body) ~time :seconds)
+        (catch java.util.concurrent.TimeoutException e#
+          (do
+            (println (str "Killed operation when it exceded max duration of " ~time ", body: " '~@body))
+            nil))))
+
 (def AtomFinder (s/=> IASTTranslationUnit [IASTTranslationUnit]))
 (def AtomFinders [(s/one AtomFinder "atom-finder") AtomFinder])
 (def BeforeAfter [(s/one IASTTranslationUnit "before") (s/one IASTTranslationUnit "after")])
@@ -268,19 +275,6 @@
                         (map #(subs (str %) 1)))])
     (csv/write-csv out-file (->> flat-res (map vals)))))

-;(->> (atoms-changed-all-commits gcc-repo atoms)
-;     (take 1)
-;     pprint)
-
-(defmacro with-timeout [time & body]
-  `(try (thunk-timeout (fn [] ~@body) ~time :seconds)
-        (catch java.util.concurrent.TimeoutException e#
-          (do
-            (println (str "Killed operation when it exceded max duration of " ~time ", body: " '~@body))
-            nil))))
-
-;(with-timeout 0.1 (range 1 1000))
-
 (defn map-all-commits
   ([f repo]
    (map-all-commits pmap f repo))


Fix typo in comments of simple/core.cljs

--- examples/simple/src/simple/core.cljs
+++ examples/simple/src/simple/core.cljs
@@ -13,7 +13,7 @@
     (rf/dispatch [:timer now])))  ;; <-- dispatch used

 ;; Call the dispatching function every second.
-;; `defonce` is like `def` but it ensures only instance is ever
+;; `defonce` is like `def` but it ensures only instance one is ever
 ;; created in the face of figwheel hot-reloading of this file.
 (defonce do-timer (js/setInterval dispatch-timer-event 1000))


remove specific "dog's owner must be human" constraint: using general constraint in babel.encyclopedia instead

--- src/babel/english/lexicon.cljc
+++ src/babel/english/lexicon.cljc
@@ -502,10 +502,10 @@

    "download" {:synsem {:cat :verb
                         :sem {:pred :scaricare}}}
+
    "dog" {:synsem {:cat :noun
                    :sem {:pred :cane
-                         :pet true
-                         :spec {:of {:human true}}}}}
+                         :pet true}}}

    "earn"  {:synsem {:cat :verb
                      :sem {:pred :earn


Update lexicon.clj

Update lexicon.clj

--- src/babel/italiano/lexicon.clj
+++ src/babel/italiano/lexicon.clj
@@ -1528,6 +1528,28 @@
                          :sem {:pred :scrivere}}
                 :italiano {:passato "scritto"}}

+ "sedersi" (let [subject-semantics (ref {:animate true})
+                   subject-agr (ref :top)]
+               {:synsem {:cat :verb
+                         :essere true
+                         :sem {:pred :sit-down
+                  :present {:1sing "siedo"
+                          :2sing "siedi"
+                          :3sing "siede"
+                          :1plur "sediamo"
+                          :2plur "sedete"
+                          :3plur "siedono"}
+                         :sem {:pred :get-up
+                               :reflexive true
+                               :subj subject-semantics
+                               :obj subject-semantics}
+                         :subcat {:1 {:agr subject-agr
+                                      :sem subject-semantics}
+                                  :2 {:agr subject-agr
+                                      :pronoun true
+                                      :reflexive true
+                                      :sem subject-semantics}}}})
+
    "sgridare" {:synsem {:cat :verb
                         :sem {:subj {:human true}
                               :pred :scold}}}


fix logout

fix logout

--- frontend/controllers/navigation.cljs
+++ frontend/controllers/navigation.cljs
@@ -309,6 +309,9 @@
       nil))
   (set-page-title! (str "Org settings - " org)))

+(defmethod navigated-to :logout
+  [history-imp navigation-point _ state]
+  state)

 (defmethod post-navigated-to! :logout
   [history-imp navigation-point _ previous-state current-state]


Make competing atom updates demo able to succeed multiple times

--- test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
+++ test/com/nomistech/clojure_the_language/c_400_state_and_concurrency/s_020_atoms.clj
@@ -155,11 +155,12 @@
 ;;;; - Another atom is used to keep track of how many times the data function
 ;;;;   is called.

-(def competing-updates-atom (atom 0))
+(def competing-updates-atom (atom nil))

 (def n-competitors 1000)

 (defn demo-competition-to-modify-atom []
+  (reset! competing-updates-atom 0)
   (let [n-attempts-atom (atom 0)]
     (letfn [(get-info []
               [@competing-updates-atom


Add comments (about OOXML tags) in litedocx.wpml

--- src/bakyeono/litedocx/wpml.clj
+++ src/bakyeono/litedocx/wpml.clj
@@ -273,17 +273,25 @@
 (defn word-document-xml
   "Creates XML data for word/document.xml file in DOCX pakcage."
   [& body]
+  ;; Document
   (node :w:document word-xmlns
+        ;; w:body
         (node :w:body {}
               body
+              ;; Document Final Section Properties
               (node :w:sectPr {}
-                    (node :w:pgSz {:w:w 11907
-                                   :w:h 16839
-                                   :w:code 9})
+                    ;; Page Size
+                    (node :w:pgSz {:w:w 11907 ; Page Width
+                                   :w:h 16839 ; Page Height
+                                   :w:orient "portrait" ; Page Orientation
+                                   :w:code 9}) ; Printer Paper Code
+                    ;; Page Margins
                     (node :w:pgMar {:w:top 720
                                     :w:right 720
                                     :w:bottom 720
-                                    :w:left 720})))))
+                                    :w:left 720
+                                    :w:herader 0
+                                    :w:footer 0})))))

 (defn- ppr
   "Creates w:pPr tag node. Called by paragaph-style."
@@ -292,41 +300,56 @@
            space-before space-after space-line
            indent-left indent-right indent-first-line
            mirror-indents?]}]
+  ;; Paragraph Properties
   (node :w:pPr {}
         (when (or space-before space-after space-line)
-          (node :w:spacing (make-attrs :w:before space-before
-                                       :w:after space-after
-                                       :w:line space-line
-                                       :w:lineRule "auto")))
+          ;; Spacing Between Lines and Above/Below Paragraph
+          (node :w:spacing (make-attrs :w:before space-before ; Spacing Above Paragraph
+                                       :w:after space-after ; Spacing Below Paragraph
+                                       :w:line space-line ; Spacing Between Lines in Paragraph
+                                       :w:lineRule "auto"))) ; Type of Spacing Between Lines
         (when (or indent-left indent-right indent-first-line)
-          (node :w:ind (make-attrs :w:left indent-left
-                                   :w:right indent-right
-                                   :w:firstLine indent-first-line)))
+          ;; Paragraph Indentation
+          (node :w:ind (make-attrs :w:left indent-left ; Left Indentation
+                                   :w:right indent-right ; Right Indentation
+                                   :w:firstLine indent-first-line))) ; Additional First Line Indentation
         (when mirror-indents?
+          ;; Use Left/Right Indents as Inside/Outside Indents
           (node :w:mirrorIndents))
         (when align
+          ;; Paragraph Alignment
           (node :w:jc {:w:val align}))))

 (defn- rpr
   "Creates w:rPr tag node. Called by paragaph-style."
   [{:as options
-    :keys [font font-size font-color bold? italic? underline? strike?]}]
+    :keys [font font-size font-color bold? italics? underline? strike?]}]
+  ;; Run Properties
   (node :w:rPr {}
         (when font
-          (node :w:rFonts {:w:ascii font
-                           :w:hAnsi font
-                           :w:eastAsia font}))
+          ;; Run Fonts
+          (node :w:rFonts {:w:hint "default" ; Font Type Hint: default, eastAsia, cs
+                           :w:ascii font ; ASCII Font
+                           :w:hAnsi font ; High ASCII Font
+                           :w:eastAsia font ; East Asian Font
+                           :w:cs font})) ; Complex Script Font
         (when font-size
+          ;; Font Size
           (node :w:sz {:w:val font-size}))
         (when font-color
+          ;; Run Content Color
           (node :w:color {:w:val font-color}))
         (when bold?
+          ;; Bold
           (node :w:b {:w:val true}))
-        (when italic?
-          (node :w:b {:w:val true}))
+        (when italics?
+          ;; Italics
+          (node :w:i {:w:val true}))
         (when underline?
-          (node :w:u {:w:val "single"}))
+          ;; Underline
+          (node :w:u {:w:val "single"})) ; Underline Style
         (when strike?
+          ;; Single Strikethrough
           (node :w:strike {:w:val true}))))

 (defn paragraph-style
@@ -351,33 +374,34 @@
              space-before space-after space-line
              indent-left indent-right indent-first-line mirror-indents?]}]
   (let [font-style-name (str "character-style-of-" name)]
-    [;; paragraph style
-     (node :w:style {:w:type "paragraph"
-                     :w:styleId "normal"
-                     :w:customStyle "true"}
-           (node :w:name {:w:val name})
-           (node :w:basedOn {:w:val "a"})
+    [;; Paragraph Style Definition
+     (node :w:style {:w:type "paragraph" ; Style Type
+                     :w:styleId "normal" ; Style ID
+                     :w:customStyle "true"} ; User-Defined Style
+           (node :w:name {:w:val name}) ; Primary Style Name
+           (node :w:basedOn {:w:val "a"}) ; Parent Style ID
            (when font
-             (node :w:link {:w:val font-style-name}))
-           (node :w:qFormat)
+             (node :w:link {:w:val font-style-name})) ; Linked Style Reference
+           (node :w:qFormat) ; Primary Style
            (when (or align
                      space-before space-after space-line
                      indent-left indent-right indent-first-line mirror-indents?)
              (ppr options))
            (when (or font font-size font-color bold? italic? underline?)
              (rpr options)))
-     ;; font style of the paragraph style
      (when font
-       (node :w:style {:w:type "character"
-                       :w:styleId font-style-name
-                       :w:customStyle "true"}
-             (node :w:name {:w:val font-style-name})
-             (node :w:basedOn {:w:val "a0"})
+       ;; Font Style Definition for above Paragraph Style
+       (node :w:style {:w:type "character" ; Style Type
+                       :w:styleId font-style-name ; Style ID
+                       :w:customStyle "true"} ; User-Defined Style
+             (node :w:name {:w:val font-style-name}) ; Primary Style Name
+             (node :w:basedOn {:w:val "a0"}) ; Parent Style ID
              (rpr options)))]))

 (defn word-styles-xml
   "descripted on: http://officeopenxml.com/WPstyles.php"
   [& styles]
+  ;; Style Definitions
   (node :w:styles word-xmlns
         (flatten [default-styles styles])))


Add thread last-open-at times in :braid.server/load-threads

--- src/braid/core/server/sync.clj
+++ src/braid/core/server/sync.clj
@@ -254,7 +254,10 @@
   (let [user-tags (tag/tag-ids-for-user user-id)
         filter-tags (fn [t] (update-in t [:tag-ids] (partial into #{} (filter user-tags))))
         thread-ids (filter (partial thread/user-can-see-thread? user-id) ?data)
-        threads (map filter-tags (thread/threads-by-id thread-ids))]
+        threads (into ()
+                      (comp (map filter-tags)
+                            (map #(thread/thread-add-last-open-at % user-id)))
+                      (thread/threads-by-id thread-ids))]
     (when ?reply-fn
       (?reply-fn {:threads threads}))))


Add missing docstring.

Add missing docstring.

--- src/catacumba/impl/ratpack.clj
+++ src/catacumba/impl/ratpack.clj
@@ -77,10 +77,11 @@
     (.send response data)))

 (defn ratpack-adapter
+  "Adapt a function based handler into ratpack
+  compatible handler instance."
   [handler]
   (reify Handler
     (^void handle [_ ^Context context]
       (let [rsp (handler context)]
         (when (satisfies? IHandlerResponse rsp)
           (handle-response rsp context))))))
-


Avoid more null pointer exceptions

Avoid more null pointer exceptions

--- src/clj/comic_reader/sites.clj
+++ src/clj/comic_reader/sites.clj
@@ -158,9 +158,10 @@
    :url  ((comic-link-url-normalize)  url)})

 (defn comic-link-add-id [{:keys [url] :as comic-map}]
-  (let [[_ data] (re-find (manga-pattern) url)]
-    (assoc comic-map
-           :id data)))
+  (when url
+    (let [[_ data] (re-find (manga-pattern) url)]
+      (assoc comic-map
+             :id data))))

 (defn comic-link-normalize [link]
   (-> link
@@ -193,11 +194,12 @@
       chapter-link-add-ch-num))

 (defn extract-chapters-list [html comic-url]
-  (->> (scrape/extract-list html
-                            (chapter-list-selector)
-                            chapter-link-normalize)
-       (filter :ch-num)
-       (sort-by :ch-num)))
+  (if-let [raw-list (seq (scrape/extract-list html
+                                              (chapter-list-selector)
+                                              chapter-link-normalize))]
+    (->> raw-list
+         (filter :ch-num)
+         (sort-by :ch-num))))

 (defn comic->url [comic-id]
   (format (comic->url-format) (manga-url) comic-id))


Correct the manga-fox chapter selector

Correct the manga-fox chapter selector

--- src/clj/comic_reader/sites.clj
+++ src/clj/comic_reader/sites.clj
@@ -23,7 +23,7 @@
       (fn [comic-url]
         {:url comic-url
          :selector [:div#chapters :ul.chlist
-                    :li :div :h3 :a]
+                    :li :div #{:h3 :h4} :a]
          :normalize link->map})
       :url->feed (fn [url]
                    (some->> url


Added intercept (1) to feature vector

Added intercept (1) to feature vector

--- src/clj/forma/ops/classify.clj
+++ src/clj/forma/ops/classify.clj
@@ -17,11 +17,12 @@
        [:temp-330 :conf-50 :both-preds :count]))

 (defn unpack-feature-vec [val neighbor-val]
-  (let [[fire short _ long t-stat] val
+  (let [intercept [1]
+        [fire short _ long t-stat] val
         fire-seq (unpack-fire fire)
         [fire-neighbors & more] (unpack-neighbors neighbor-val)
         fire-neighbor (unpack-fire fire-neighbors)]
-    (into [] (concat fire-seq [short long t-stat] fire-neighbor more))))
+    (into [] (concat intercept fire-seq [short long t-stat] fire-neighbor more))))

 (defbufferop [logistic-beta-wrap [r c m]]
   "returns a vector of parameter coefficients.  note that this is


Implement Corporate Sales Team

Implement Corporate Sales Team

--- src/clj/game/cards-agendas.clj
+++ src/clj/game/cards-agendas.clj
@@ -65,6 +65,15 @@
    {:msg (msg (if (> (:credit corp) 6) "gain 7 [Credits]" "lose all credits"))
     :effect (req (if (> (:credit corp) 6)
                    (gain state :corp :credit 7) (lose state :corp :credit :all)))}
+
+   "Corporate Sales Team"
+   (let [e {:msg "gain 1 [Credit]"  :counter-cost 1
+            :effect (req (gain state :corp :credit 1)
+                         (when (zero? (:counter card))
+                           (unregister-events state :corp card)))}]
+    {:effect (effect (add-prop card :counter 10))
+     :events {:runner-turn-begins e
+              :corp-turn-begins   e}})

    "Domestic Sleepers"
    {:abilities [{:cost [:click 3] :msg "place 1 agenda counter on Domestic Sleepers"


Fix registerlink register

Fix registerlink register

--- src/clj/salava/user/routes.clj
+++ src/clj/salava/user/routes.clj
@@ -77,7 +77,7 @@
                    :body [form-content schemas/RegisterUser]
                    :summary "Create new user account"
                    (let [{:keys [email first_name last_name country language password password_verify]} form-content
-                         save                                                                           (u/register-user ctx email first_name last_name country language password password_verify)]
+                         save (u/register-user ctx email first_name last_name country language password password_verify)]
                      (if (not (private? ctx))
                                         ;(ok save)
                        (let [login-status (u/login-user ctx email password)]
@@ -87,7 +87,10 @@
                        (cond
                          (not (right-token? ctx (:token form-content)))        (forbidden)
                          (not (in-email-whitelist? ctx (:email form-content))) (ok {:status "error" :message "user/Invalidemail"})
-                         :else                                                 (ok save))))
+                         :else                                                 (let [login-status (u/login-user ctx email password)]
+                                                                                (if (= "success" (:status login-status))
+                                                                                (u/set-session ctx (ok login-status) (:id login-status))
+                                                                                (ok login-status))))))
                    )

              (POST "/activate" []


Simplify map.

Simplify map.

--- src/clj/wordbook/datastore.clj
+++ src/clj/wordbook/datastore.clj
@@ -41,7 +41,7 @@
     (clutch/put-document db word-entity)))

 (defn get-latest-words [limit]
-  (map #(:doc %) (clutch/get-view db design-doc-name :words-by-update-time
-                                  {:limit limit
-                                   :include_docs true
-                                   :descending true})))
+  (map :doc (clutch/get-view db design-doc-name :words-by-update-time
+                             {:limit limit
+                              :include_docs true
+                              :descending true})))


Move devcards.js javascript tag to correct page

--- src/clj/zetawar/views/site.clj
+++ src/clj/zetawar/views/site.clj
@@ -1,5 +1,6 @@
 (ns zetawar.views.site
   (:require
+   [clojure.pprint :refer [pprint]]
    [zetawar.views.common :refer [footer head kickstarter-alert navbar]]
    [hiccup.page :refer [html5 include-js]]
    [zetawar.site :as site])
@@ -69,13 +70,12 @@
        (kickstarter-alert)
        (:content entry)]
       (footer)
-      (include-js (site/prefix "/js/main.js"))
-      (when (site/devcards? entry)
-        (include-js (site/prefix "/js/main/devcards.js")))])))
+      (include-js (site/prefix "/js/main.js"))])))

 (defn render-devcards [data]
   (let [{:keys [entry] global-meta :meta} data]
     (html5
      (head data "Zetawar Devcards")
      [:body#devcards
-      (include-js (site/prefix "/js/main.js"))])))
+      (include-js (site/prefix "/js/main.js"))
+      (include-js (site/prefix "/js/main/devcards.js"))])))


Nil-guard md5-hex

Nil-guard md5-hex

--- src/cljs/clojuredocs/util.cljs
+++ src/cljs/clojuredocs/util.cljs
@@ -32,9 +32,11 @@
   [string]
   (md5- (string->bytes string)))

-(defn md5-hex [string]
+(defn md5-hex
   "convert utf8 string to md5 hex string"
-  (bytes->hex (md5-bytes string)))
+  [string]
+  (when string
+    (bytes->hex (md5-bytes string))))

 (defn cd-decode [s]
   (cond


Remove non-existing imports

Remove non-existing imports

--- src/cljs/movement/session.cljs
+++ src/cljs/movement/session.cljs
@@ -10,7 +10,7 @@
     [cljs.reader :as reader]
     [clojure.string :as str]
     [movement.data :as data]
-    [movement.util :refer [vec-remove handler-fn positions GET POST get-stored-sessions]]
+    [movement.util :refer [vec-remove handler-fn positions]]
     [movement.text :refer [text-edit-component text-input-component auto-complete-did-mount]]))

 #_(defn replace-movement [event {:keys [kw movement part-number]}]
@@ -332,4 +332,4 @@

          [:div.content {:style {:margin-top 0}}
-          [:a {:on-click #(session/put! :movement-session {:parts [[]] :activity "Styrketrening"})} "Klikk!"]])])))+          [:a {:on-click #(session/put! :movement-session {:parts [[]] :activity "Styrketrening"})} "Klikk!"]])])))


Add method to render a link with an associated image

--- src/cljs/sloth/views/text.cljs
+++ src/cljs/sloth/views/text.cljs
@@ -51,12 +51,14 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn make-image-message
-  [url]
-  [:span
-   (make-external-link url)
-   [:br]
-   [:img {:src url
-          :class-name "message-image"}]])
+  ([url]
+   (make-image-message url url))
+  ([url image-url]
+   [:span
+    (make-external-link url)
+    [:br]
+    [:img {:src image-url
+           :class-name "message-image"}]]))

 (def img-regex #"https?://.*\.(?:jpe?g|gif|png)")

@@ -155,7 +157,7 @@
             coords-attr (str "center=" coords)
             mark-attr (str "&markers=color:red|label:A|" coords)
             maps-static-url (str embed-url coords-attr mark-attr additional-attrs)]
-        (make-image-message maps-static-url))
+        (make-image-message url maps-static-url))
       (make-external-link url))))

 (defmethod convert-http-url :default


cleanup storage ns

cleanup storage ns

--- src/cljs/swarmpit/storage.cljs
+++ src/cljs/swarmpit/storage.cljs
@@ -1,8 +1,6 @@
 (ns swarmpit.storage
   (:refer-clojure :exclude [get remove])
   (:require [swarmpit.token :as token]
-            [swarmpit.routes :as routes]
-            [swarmpit.url :refer [dispatch!]]
             [cognitect.transit :as t]))

 (def storage (.-localStorage js/window))


Move the http-effect into an accessible function.

--- src/day8/re_frame/http_fx.cljs
+++ src/day8/re_frame/http_fx.cljs
@@ -76,13 +76,14 @@
 ;                                                                                :kind sequential?
 ;                                                                                :into [])))

-(reg-fx
-  :http-xhrio
-  (fn http-effect [request]
-    #_(when-not (s/valid? ::sequential-or-map request)
+(defn http-effect
+  [request]
+  #_(when-not (s/valid? ::sequential-or-map request)
       (throw (ex-info "http-xhrio fx: spec error" (s/explain-data ::sequential-or-map request))))
-    (let [#_ #_ [conform-val v] (s/conform ::sequential-or-map request)
-          #_ #_ seq-request-maps (if (= :seq-request-maps conform-val) v [v])
-          seq-request-maps (if (sequential? request) request [request])]
-      (doseq [request seq-request-maps]
-        (-> request request->xhrio-options ajax/ajax-request)))))
+  (let [#_ #_ [conform-val v] (s/conform ::sequential-or-map request)
+        #_ #_ seq-request-maps (if (= :seq-request-maps conform-val) v [v])
+        seq-request-maps (if (sequential? request) request [request])]
+    (doseq [request seq-request-maps]
+      (-> request request->xhrio-options ajax/ajax-request))))
+
+(reg-fx :http-xhrio http-effect)


Predicates use-result-cache? and pretty-print-edn?

--- src/emender_service/config.clj
+++ src/emender_service/config.clj
@@ -67,3 +67,10 @@
     [request]
     (-> request :configuration :config :verbose))

+(defn use-result-cache?
+    [request]
+    (-> request :configuration :result-cache :use-cache))
+
+(defn pretty-print-edn?
+    [request]
+    (-> request :configuration :result-cache :pretty-print))


Add temporary dividers.

Add temporary dividers.

Will spilt the namespace in a future refactoring.


set dictionary as default on

set dictionary as default on

--- src/fileape/parquet/writer.clj
+++ src/fileape/parquet/writer.clj
@@ -32,7 +32,7 @@
                (Configuration.)
                (.setLong "parquet.block.size" (get conf :parquet-block-size 52428800))
                (.setLong "parquet.page.size" (get conf :parquet-page-size 1048576))
-               (.setBoolean "parquet.enable.dictionary" (get conf :parquet-enable-dictionary false)))
+               (.setBoolean "parquet.enable.dictionary" (get conf :parquet-enable-dictionary true)))

         path (.makeQualified (FileSystem/getLocal conf) (Path. (.getAbsolutePath file)))
         output-format (ParquetOutputFormat. (JavaWriteSupport. schema))