[#2127] Add flow-common unit tests

[#2127] Add flow-common unit tests

error: pathspec 'backend/test/akvo/lumen/lib/import/flow_common_test.clj' did not match any file(s) known to git

--- backend/test/akvo/lumen/lib/import/flow_common_test.clj
+++ backend/test/akvo/lumen/lib/import/flow_common_test.clj
@@ -0,0 +1,99 @@
+(ns akvo.lumen.lib.import.flow-common-test
+  (:require [akvo.lumen.lib.import.flow-common :as flow-common]
+            [akvo.lumen.lib.import.common :as common]
+            [clojure.test :refer :all]))
+
+(def rqg-id "567919211")
+
+(def rqg-name "My Repeatead Group")
+
+(def rqs [{:id "587209169",
+           :name "Name",
+           :type "FREE_TEXT",
+           :order 1,
+           :variableName "_name_repeated",
+           :createdAt "2019-12-05T17:27:31.751Z",
+           :modifiedAt "2020-03-09T11:01:26.390Z"}
+          {:id "565649136",
+           :name "Age repeated",
+           :type "NUMBER",
+           :order 2,
+           :variableName "_age_repeated",
+           :createdAt "2019-12-05T17:28:00.253Z",
+           :modifiedAt "2019-12-05T17:28:32.347Z"}
+          {:id "569709126",
+           :name "ID number",
+           :type "NUMBER",
+           :order 3,
+           :variableName "id_number",
+           :createdAt "2019-12-05T17:28:46.962Z",
+           :modifiedAt "2019-12-05T17:29:08.434Z"}])
+
+(def form {:id "569469117",
+           :name "Registration Form",
+           :questionGroups
+           [{:id "559609117",
+             :name "Sample Questions",
+             :repeatable false,
+             :questions
+             [{:id "577239117",
+               :name "Free text questions",
+               :type "FREE_TEXT",
+               :order 1,
+               :variableName "_free_question",
+               :createdAt "2019-11-14T11:11:08.712Z",
+               :modifiedAt "2020-03-09T11:01:22.869Z"}
+              {:id "577259116",
+               :name "Location",
+               :type "GEO",
+               :order 2,
+               :variableName "_location_info",
+               :createdAt "2019-11-14T11:11:23.573Z",
+               :modifiedAt "2019-12-05T17:38:00.442Z"}
+              {:id "569489117",
+               :name "Numbers",
+               :type "NUMBER",
+               :order 3,
+               :variableName "_number_question",
+               :createdAt "2019-11-14T11:12:37.989Z",
+               :modifiedAt "2019-12-03T14:30:55.556Z"}
+              ],
+             :createdAt "2019-11-14T11:09:48.764Z",
+             :modifiedAt "2019-11-14T11:09:59.923Z"}
+            {:id rqg-id,
+             :name rqg-name,
+             :repeatable true,
+             :questions rqs,
+             :createdAt "2019-12-05T17:27:26.146Z",
+             :modifiedAt "2019-12-05T17:50:05.539Z"}],
+           :createdAt "2019-11-14T11:09:12.723Z",
+           :modifiedAt "2019-12-05T17:50:11.406Z",
+           :formInstancesUrl
+           "https://api-auth0.akvotest.org/flow/orgs/uat1/form_instances?survey_id=530819116&form_id=569469117",
+           :registration-form? true})
+
+(deftest rqg-in-one-column
+  (let [secret "secret"]
+    (testing "questions-responses-with-rqg-in-one-column"
+      (let [res (flow-common/questions-with-rqg-in-one-column form)
+            repeatables (filter :repeatable res)
+            rqg (first repeatables)]
+        (is (= (count res) 4))
+        (is (= (count repeatables) 1))
+        (is (= "RQG" (:type rqg)))
+        (is (= rqg-name (:name rqg)))
+        (is (= rqg-id (:id rqg)))
+        (is (= (:metadata rqg) (common/coerce flow-common/question-type->lumen-type rqs)))))
+
+    (testing "questions-responses-with-rqg-in-one-column"
+      (let [questions (flow-common/questions-with-rqg-in-one-column form)
+            no-rqg-responses [{"577239117" "no we are not"
+                               "569489117" 5.0}]
+            rqg-responses [{"565649136" 54.0, "587209169" "zave", "569709126" 9.86584572E8}
+                           {"565649136" 54.0, "587209169" "kween", "569709126" 6.9566324846E10}]
+            responses {"559609117" no-rqg-responses
+                       "567919211" rqg-responses}
+            res       (flow-common/questions-responses-with-rqg-in-one-column questions responses)]
+        (is (= res {"559609117" no-rqg-responses
+                    "567919211" [{"567919211" rqg-responses}]}))))))
+


Add general collapser service

Add general collapser service

error: pathspec 'services/collapser.clj' did not match any file(s) known to git

--- services/collapser.clj
+++ services/collapser.clj
@@ -0,0 +1,20 @@
+
+{
+ :name "collapser",
+ :path "",
+ :func (fn [eid & _]
+         (if (pg/eoi? eid)
+           (pg/done)
+           (let [pairgrps (htts/get-collapse-groups eid)]
+             (mapv #(reduce
+                     (fn[E stat]
+                       (cond (= :success E (stat :exit)) :success
+                             (= :success (stat :exit))   :mixed
+                             :else :failed))
+                     :success %)
+                   (mapv (fn[pairs]
+                           (htts/run-collapse-group pairs))
+                         pairgrps)))))
+
+ :description "Collapse duplicate sequences for each file (fq or fa) in pairs. Takes the experiement id and generates the pair groups and runs parallel collapser on each such group. pairs is a collection of vectors [fqa fa] where fqa is a fastq or fasta file (gzipped or not) and fa is the output fasta file (it will be gzipped). Sequences are collapsed to records of single instance with counts in id line."
+}


kill cluster which was too vague

kill cluster which was too vague

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pyr/bundes.git/'


api: serve static content

api: serve static content


Fix option name

Fix option name

We're running an older duct version, so have to use the old name for
the option.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/tobias/clojars-web.git/'


packaged

packaged

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/clojure-ml/cml.git/'


Write to history

Write to history

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/leif47/immutabledb-experimental.git/'


determine the real path of the shen.clj script in a more resilient fashion (it should by symlink-able)

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/michaelsbradleyjr/shen.clj.git/'


Allow any additional keys for organization membership

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/physion/ovation-webapi.git/'


Refactor: move internal header components out...

... for a more declarative root component.

fatal: unable to access 'https://github.com/Reefersleep/sleepydo.git/': The requested URL returned error: 403


Fix styling in top search bar

Fix styling in top search bar

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Reefersleep/sleepydo.git/'


p07.clj, added guard, if n < 2, n is not prime

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/drcabana/euler-fp.git/'


Don't halt indexing process when a pom can't be parsed.

--- src/clojars/search.clj
+++ src/clojars/search.clj
@@ -44,10 +44,17 @@
       (clucy/add index (with-meta doc field-settings)))))

 (defn index-repo [root]
-  (with-open [index (clucy/disk-index (config :index-path))]
-    (doseq [file (file-seq (io/file root))
-            :when (.endsWith (str file) ".pom")]
-      (index-pom index file))))
+  (let [indexed (atom 0)]
+    (with-open [index (clucy/disk-index (config :index-path))]
+      (doseq [file (file-seq (io/file root))
+              :when (.endsWith (str file) ".pom")]
+        (swap! indexed inc)
+        (when (zero? (mod @indexed 100))
+          (println "Indexed" @indexed))
+        (try
+          (index-pom index file)
+          (catch Exception e
+            (println "Failed to index" file " - " (.getMessage e))))))))

 (defn search [query]
   (if (empty? query)


Dedup

Dedup

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/couragelabs/coachbot.git/'


Fixed compojure typo

Fixed compojure typo

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/IceRaptor/ca_scheduler.git/'


Macros

Macros

error: pathspec 'src/mark-volkmann-tutorial/macros.clj' did not match any file(s) known to git

--- src/mark-volkmann-tutorial/macros.clj
+++ src/mark-volkmann-tutorial/macros.clj
@@ -0,0 +1,68 @@
+;; Macros
+;; http://java.ociweb.com/mark/clojure/article.html#Macros
+
+; new constructs in language
+; code that generates code at read-time
+; manage what is evaluated (for functions - all is evaluated)
+; e.g. if cannot be implemented as function - in fact it is special form
+
+; (doc and) dont work in LightTable
+((meta (var and)) :macro)
+((meta #'and) :macro) ; shorter way
+
+; -> avoid code duplication, when we want control evaluation
+
+(defmacro around-zero [number negative-expr zero-expr positive-expr]
+  `(let [number# ~number] ; so number is only evaluated once
+     (cond
+       (< (Math/abs number#) 1e-15) ~zero-expr
+       (pos? number#) ~positive-expr
+       true ~negative-expr)))
+
+; Reader expands to let, cond
+; number# - auto-gensym: assure that there is only one symbol like that
+; -> https://en.wikipedia.org/wiki/Hygienic_macro
+; ` - syntax quote, back-quote - prevents all from evaluation
+; ~ - unquote
+; ~@ - unquote splice list
+
+(around-zero 0.1 (println "-") (println "0") (println "+"))
+(println (around-zero 0.1 "-" "0" "+"))
+
+; do - for more than one form
+(around-zero 0.1
+             (do (log "really cold!") (println "-")) ; log is not defined
+             (println "0")
+             (println "+"))
+
+(macroexpand-1 '(around-zero 0.1 (println "-") (println "0") (println "+")))
+;; (clojure.core/let [number__6002__auto__ 0.1]
+;;   (clojure.core/cond
+;;     (clojure.core/< (java.lang.Math/abs number__6002__auto__) 1.0E-15) (println "0")
+;;     (clojure.core/pos? number__6002__auto__) (println "+")
+;;     true (println "-")))
+
+;; function that use macro
+(defn number-category [number]
+  (around-zero number "negative" "zero" "positive"))
+
+(println (number-category -0.1))
+(println (number-category 0))
+(println (number-category -0.1))
+
+
+(defmacro trig-y-category [fn degrees]
+  `(let [radians# (Math/toRadians ~degrees)
+         result# (~fn radians#)]
+     (number-category result#)))
+
+(doseq [angle (range 0 360 60)]
+  (println (trig-y-category Math/sin angle)))
+
+(macroexpand-1 '(trig-y-category Math/sin 0))
+
+; macro cannot be pased to e.g. reduce functions
+; (reduce and (repeat 3 false))
+; workaround: anonymous funtion: (fn [x y] (and x y) or #(and %1 %2)
+
+; macro are processed at read-time


fix functions order

fix functions order

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/JetBrains/imperative-nodejs.git/'


Format various date granularities properly

--- src/metabase/pulse.clj
+++ src/metabase/pulse.clj
@@ -50,19 +50,31 @@
     :else (str (cl-format nil "~,1f" n))))

 (defn- format-timestamp
-  [timestamp]
-  (let [date (c/from-long timestamp)
-        today (t/today-at 0 00)]
-    (cond
-      (t/within? (t/interval today (t/plus today (t/days 1))) date) "Today"
-      (t/within? (t/interval (t/minus today (t/days 1)) today) date) "Yesterday"
-      :else (f/unparse (f/formatter "MMM d, YYYY") date))))
+  [timestamp col]
+  (log/info timestamp)
+  (case (:unit col)
+    :hour (f/unparse (f/formatter "h a - MMM YYYY") (c/from-long timestamp))
+    :week (f/unparse (f/formatter "w - YYYY") (c/from-long timestamp))
+    :month (f/unparse (f/formatter "MMMM YYYY") (c/from-long timestamp))
+    :quarter (str "Q" (+ 1 (int (/ (t/month (c/from-long timestamp)) 3))) " - " (t/year (c/from-long timestamp)))
+    :year (str timestamp)
+    :hour-of-day (str timestamp) ; TODO: probably shouldn't even be showing sparkline for x-of-y groupings?
+    :day-of-week (str timestamp)
+    :week-of-year (str timestamp)
+    :month-of-year (str timestamp)
+    (let [date (c/from-long timestamp)
+          today (t/today-at 0 00)]
+      (cond
+        (t/within? (t/interval today (t/plus today (t/days 1))) date) "Today"
+        (t/within? (t/interval (t/minus today (t/days 1)) today) date) "Yesterday"
+        :else (f/unparse (f/formatter "MMM d, YYYY") date)))))

 (defn- format-cell
-  [value]
+  [value col]
+  (log/info value)
   (cond
-    (instance? java.util.Date value) (format-timestamp (.getTime value))
-    (number? value) (format-number value)
+    (instance? java.util.Date value) (format-timestamp (.getTime value) col)
+    (and (number? value) (not (datetime-field? col))) (format-number value)
     :else (str value)))

 (defn card-href
@@ -94,7 +106,7 @@
           [:tr {:style (str "color: " (if (odd? row-idx) color-grey-2 color-grey-3) ";")}
             (map (fn [col-idx]
                   [:td {:style (str bar-td-style (if (and bar-column (= col-idx 1)) "font-weight: 700;"))}
-                    (-> row (nth col-idx) format-cell h)])
+                    (-> row (nth col-idx) (format-cell (nth cols col-idx )) h)])
                   col-indexes)
             (if bar-column [:td {:style (str bar-td-style "width: 99%;")}
               [:div {:style (str "background-color: " color-purple "; height: 20px; width: " (float (* 100 (/ (bar-column row) max-value))) "%")} " "]])])
@@ -134,9 +146,9 @@
       (render-truncation-warning card data render-img rows-limit 2)]))

 (defn render-card-scalar
-  [card data render-img]
+  [card {:keys [cols rows] :as data} render-img]
   [:div {:style scalar-style}
-    (-> data :rows first first format-cell h)])
+    (-> rows first first (format-cell (first cols)) h)])

 (def ^:private sparkline-dot-radius 6)
 (def ^:private sparkline-thickness 4)
@@ -163,7 +175,7 @@

 (defn render-card-sparkline
   [card {:keys [rows cols] :as data} render-img]
-  (let [xs (map #(-> % first .getTime) rows)
+  (let [xs (for [row rows :let [x (first row)]] (if (instance? java.util.Date x) (.getTime x) x))
         xmin (apply min xs)
         xmax (apply max xs)
         xrange (- xmax xmin)
@@ -185,8 +197,8 @@
           [:div
             [:div {:style (str "height: 15px; margin-left: 10px; margin-right: 10px; border: 4px solid " color-grey-1 "; border-top: none; border-bottom: none;")} " "]
             [:div {:style "height: 15px; margin-left: 10px; margin-right: 10px;"}
-              [:div {:style "float: left;"} (format-timestamp xmin)]
-              [:div {:style "float: right;"} (format-timestamp xmax)]]
+              [:div {:style "float: left;"} (format-timestamp xmin (first cols))]
+              [:div {:style "float: right;"} (format-timestamp xmax (first cols))]]
           ]]]
       [:div {:style "margin-top: 20px; margin-left: 30px;"}
         (render-table card [(last rows) (first rows)] cols render-img [0 1] nil)]]))


defturtle

defturtle

fatal: unable to access 'https://github.com/tiagoantao/turtle.git/': The requested URL returned error: 403


implement start and terminate provider tasks

--- pact-jvm-provider-lein/src/main/clojure/au/com/dius/pact/provider/lein/verify_provider.clj
+++ pact-jvm-provider-lein/src/main/clojure/au/com/dius/pact/provider/lein/verify_provider.clj
@@ -1,8 +1,12 @@
 (ns au.com.dius.pact.provider.lein.verify-provider
   (:require [clojure.pprint :as pp]
             [clojure.java.io :as io]
-            [clojure.string :as str])
+            [clojure.string :as str]
+            [leiningen.core.main :as lein])
   (:import (au.com.dius.pact.provider ProviderInfo ConsumerInfo)))
+
+(defn wrap-task [verifier task-name]
+  #(lein/resolve-and-apply (.getProject verifier) [task-name]))

 (defn to-provider [verifier provider-info]
   (let [provider (ProviderInfo. (-> provider-info key str))
@@ -22,8 +26,9 @@
     (if (contains? provider-data :request-filter) (.setRequestFilter provider (.wrap verifier (eval (:request-filter provider-data)))))
     (if (contains? provider-data :state-change-request-filter) (.setStateChangeRequestFilter provider (.wrap verifier (eval (:state-change-request-filter provider-data)))))
     (if (contains? provider-data :create-client) (.setCreateClient provider (.wrap verifier (eval (:create-client provider-data)))))
-    ;def startProviderTask
-    ;def terminateProviderTask
+
+    (if (contains? provider-data :start-provider-task) (.setStartProviderTask provider (wrap-task verifier (:start-provider-task provider-data))))
+    (if (contains? provider-data :terminate-provider-task) (.setTerminateProviderTask provider (wrap-task verifier (:terminate-provider-task provider-data))))
     provider))

 (defn to-consumer [consumer-info]
@@ -36,11 +41,27 @@
     (if (contains? consumer-data :packages-to-scan) (.setPackagesToScan consumer (:packages-to-scan consumer-data)))
     consumer))

+(defn execute-start-provider-task [provider]
+  (if-let [start-task (.getStartProviderTask provider)]
+    (do
+      (lein/info (str "Executing start provider task for " (.getName provider)))
+      (start-task))))
+
+(defn execute-terminate-provider-task [provider]
+  (if-let [terminate-task (.getTerminateProviderTask provider)]
+    (do
+      (lein/info (str "Executing terminate provider task for " (.getName provider)))
+      (terminate-task))))
+
 (defn verify-providers [verifier providers]
   (let [failures (mapcat #(let [provider (to-provider verifier %)
-                           consumers (->> % val :has-pact-with (map to-consumer))]
-      (.setConsumers provider consumers)
-      (.verifyProvider verifier provider)) providers)]
+                                consumers (->> % val :has-pact-with (map to-consumer))]
+                            (.setConsumers provider consumers)
+                            (execute-start-provider-task provider)
+                            (try
+                              (.verifyProvider verifier provider)
+                              (finally (execute-terminate-provider-task provider)))
+                            ) providers)]
     (if (not-empty failures)
       (do
         (.displayFailures verifier failures)


leap_year in clojure, first version

leap_year in clojure, first version

error: pathspec 'clojure/leap/leap_year.clj' did not match any file(s) known to git

--- clojure/leap/leap_year.clj
+++ clojure/leap/leap_year.clj
@@ -0,0 +1,9 @@
+(defn divisible-by [number, divisor]
+  (= 0 (mod number divisor)))
+
+(defn leap-year [year]
+  (and
+    (divisible-by year 4)
+    (or
+      (not (divisible-by year 100))
+      (divisible-by year 400))))


tests

tests


make started message go to repl buffer

make started message go to repl buffer

--- sidecar/src/figwheel_sidecar/auto_builder.clj
+++ sidecar/src/figwheel_sidecar/auto_builder.clj
@@ -142,15 +142,16 @@
                               (mapv println errors))
                             (when-not (builder-running?)
                               (build-once* build-ids)
-                              (binding [*out* log-writer
-                                        *err* log-writer]
-                                (when-let [abuild (autobuild-ids
-                                                   { :all-builds all-builds
-                                                    :build-ids build-ids
-                                                    :figwheel-server figwheel-server })]
-                                  (println "Started Figwheel autobuilder see:" logfile-path )
-                                  (reset! state-atom { :autobuilder abuild
-                                                        :focus-ids build-ids}))))))
+                              (when-let [abuild
+                                         (binding [*out* log-writer
+                                                   *err* log-writer]
+                                           (autobuild-ids
+                                            { :all-builds all-builds
+                                              :build-ids build-ids
+                                              :figwheel-server figwheel-server }))]
+                                (println "Started Figwheel autobuilder see:" logfile-path)
+                                (reset! state-atom { :autobuilder abuild
+                                                     :focus-ids build-ids})))))
         stop-autobuild*  (fn [_]
                            (if (builder-running?)
                              (do


Add sort communities by unit count

Add sort communities by unit count

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/starcity-properties/odin.git/'


Kibit cleanup

Kibit cleanup


add validation namespace and fns

add validation namespace and fns

error: pathspec 'src/navigator/validation.clj' did not match any file(s) known to git

--- src/navigator/validation.clj
+++ src/navigator/validation.clj
@@ -0,0 +1,79 @@
+(ns navigator.validation
+  (:require [valip.core :refer [validate]]
+            [valip.predicates :refer [digits? present?]]))
+
+
+(defn valid?
+  [validator input]
+  (let [res (validator input)]
+    (if (nil? res)
+      true
+      false)))
+
+(defn validate-task-in
+  [task]
+  (validate task
+            [:task/id-sk        present? "must be present"]
+            [:task/id-sk        digits?  "must consist of digits"]
+            [:task/id-sk-origin present? "must be present"]
+            [:task/name         present? "must be present"]
+            [:task/version      present? "must be present"]
+            [:task/description  present? "must be present"]))
+
+(defn validate-comp-in
+  [comp]
+  (validate comp
+            [:comp/id-sk       present? "must be present"]
+            [:comp/id-sk       digits?  "must consist of digits"]
+            [:comp/name        present? "must be present"]
+            [:comp/description present? "must be present"]
+            [:comp/version     present? "must be present"]
+            [:comp/status      present? "must be present"]
+            [:comp/tags        present? "must be present"]))
+
+(defn validate-comp-tag-in
+  [comp-tag]
+  (validate comp-tag
+            [:comp-tag/name          present? "must be present"]
+            [:comp-tag/description   present? "must be present"]
+            [:comp-tag/version       present? "must be present"]
+            [:comp-tag/type          present? "must be present"]
+            [:comp-tag/isrequestable present? "must be present"]
+            [:comp-tag/icon          present? "must be present"]
+            [:comp-tag/status        present? "must be present"]
+            [:comp-tag/isfinal       present? "must be present"]
+            [:comp-tag/disp-ctxs     present? "must be present"]
+            [:comp-tag/child-of      present? "must be present"]))
+
+(defn validate-perf-asmt-in
+  [perf-asmt]
+  (validate perf-asmt
+            [:perf-asmt/id-sk                    present? "must be present"]
+            [:perf-asmt/id-sk                    digits?  "must consist of digits"]
+            [:perf-asmt/id-sk-origin             present? "must be present"]
+            [:perf-asmt/name                     present? "must be present"]
+            [:perf-asmt/version                  present? "must be present"]
+            [:perf-asmt/type                     present? "must be present"]
+            [:perf-asmt/duration-rating-days     present? "must be present"]
+            [:perf-asmt/comps                    present? "must be present"]
+            [:perf-asmt/credit-value-numerator   present? "must be present"]
+            [:perf-asmt/credit-value-denominator present? "must be present"]))
+
+(defn validate-user2comp-in
+  [user2comp]
+  (validate user2comp
+            [:user2comp/sis-user-id              present? "must be present"]
+            [:user2comp/comp                     present? "must be present"]
+            [:user2comp/start-date               present? "must be present"]
+            [:user2comp/proposed-completion-date present? "must be present"]
+            [:user2comp/current-score            present? "must be present"]
+            [:user2comp/final-score              present? "must be present"]
+            [:user2comp/score-denominator        present? "must be present"]
+            [:user2comp/score-type               present? "must be present"]))
+
+(defn validate-user2perf-asmt-in
+  [user2perf-asmt]
+  (validate user2perf-asmt
+            [:user2perf-asmt/user      present? "must be present"]
+            [:user2perf-asmt/perf-asmt present? "must be present"]
+            [:user2perf-asmt/grade     present? "must be present"]))


update mongo driver to use new expanded table / DB

fatal: unable to access 'https://github.com/dashkb/metabase.git/': The requested URL returned error: 403


Typos matter

Typos matter

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/democracyworks/scheduled-message-works.git/'


more dev comments

more dev comments

--- sidecar/src/figwheel_sidecar/repl_api.clj
+++ sidecar/src/figwheel_sidecar/repl_api.clj
@@ -27,27 +27,6 @@
   []
   (when *repl-api-system*
     (alter-var-root #'*repl-api-system* component/stop)))
-
-(comment
-  ;; example usage
-  (require 'figwheel-sidecar.repl-api)
-
-  (in-ns 'figwheel-sidecar.repl-api)
-
-  (start-figwheel!
-   {:figwheel-options {}
-    :build-ids ["example"]
-    :all-builds [{ :id "example"
-                  :source-paths ["src" "dev"]
-                  :compiler {:main "example.dev"
-                             :asset-path "js/out"
-                             :output-to "resources/public/js/example.js"
-                             :output-dir "resources/public/js/out"
-                             :source-map true
-                             :source-map-timestamp true
-                             :cache-analysis true
-                             :optimizations :none}}]})
-  )

 (defn figwheel-running? []
   (or *repl-api-system*


aoc2020 day 22

aoc2020 day 22

error: pathspec '2020/src/day22.clj' did not match any file(s) known to git

--- 2020/src/day22.clj
+++ 2020/src/day22.clj
@@ -0,0 +1,74 @@
+(ns day22
+  (:require [clojure.pprint :refer [pprint]]))
+
+(def test-input [[9 2 6 3 1]
+                 [5 8 4 7 10]])
+
+(def input [[28 13 25 16 38 3 14 6 29 2 47 20 35 43 30 39 21 42 50 48 23 11 34 24 41]
+            [27 37 9 10 17 31 19 33 40 12 32 1 18 36 49 46 26 4 45 8 15 5 44 22 7]])
+
+;; part 1
+(defn part-1 [input]
+  (loop [[x & xs :as deck-1] (first input)
+         [y & ys :as deck-2] (second input)]
+    (if-not (and x y)
+      (->> (or deck-1 deck-2)
+           reverse
+           (map-indexed #(* (inc %1) %2))
+           (apply +))
+      (if (< x y)
+        (recur xs (into (vec ys) [y x]))
+        (recur (into (vec xs) [x y]) ys)))))
+
+(pprint (part-1 test-input))
+(pprint (part-1 input))
+
+;; part 2
+(defn subgame [input game]
+  (loop [[x & xs :as deck-1] (first input)
+         [y & ys :as deck-2] (second input)
+         history #{}
+         round 1]
+    (cond
+      (not (and x y))
+      [deck-1 deck-2]
+
+
+      (contains? history [deck-1 deck-2])
+      [deck-1 nil]
+
+      (and (<= x (count xs))
+           (<= y (count ys)))
+      (let [[winner-1 _] (subgame [(take x xs) (take y ys)] (inc game))]
+        (if winner-1
+          (recur (into (vec xs) [x y])
+                 ys
+                 (conj history [deck-1 deck-2])
+                 (inc round))
+          (recur xs
+                 (into (vec ys) [y x])
+                 (conj history [deck-1 deck-2])
+                 (inc round))))
+
+      (< x y)
+      (recur xs
+             (into (vec ys) [y x])
+             (conj history [deck-1 deck-2])
+             (inc round))
+
+      :else
+      (recur (into (vec xs) [x y])
+             ys
+             (conj history [deck-1 deck-2])
+             (inc round)))))
+
+
+(defn part-2 [input]
+  (let [[deck-1 deck-2] (subgame input 1)]
+    (->> (or deck-1 deck-2)
+         reverse
+         (map-indexed #(* (inc %1) %2))
+         (apply +))))
+
+(pprint (part-2 test-input))
+(pprint (part-2 input))


rev section description

rev section description

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/michaelsbradleyjr/transwarp.git/'


rev notes-comments in Ideas section

rev notes-comments in Ideas section


Added geo.clj.

Added geo.clj.

error: pathspec 'src/com/lemondronor/orbital_detector/geo.clj' did not match any file(s) known to git

--- src/com/lemondronor/orbital_detector/geo.clj
+++ src/com/lemondronor/orbital_detector/geo.clj
@@ -0,0 +1,25 @@
+(ns com.lemondronor.orbital-detector.geo
+  ""
+  (:require [geo.spatial :as spatial]))
+
+(set! *warn-on-reflection* true)
+
+
+(defn bearing [a b]
+  (let [lat1 (spatial/latitude a)
+        lon1 (spatial/longitude a)
+        lat2 (spatial/latitude b)
+        lon2 (spatial/longitude b)]
+    (Math/atan2
+     (- (* (Math/cos lat1) (Math/cos lat2))
+        (* (Math/sin lat1) (Math/cos lat2) (Math/cos (- lon2 lon1))))
+     (* (Math/sin (- lon2 lon1)) (Math/cos lat2)))))
+
+
+(defn normalize-bearing [b]
+  (cond
+    (> b 180.0)
+    (normalize-bearing (- b 360.0))
+    (< b -180.0)
+    (normalize-bearing (+ b 360.0))
+    :else b))


First version of concept approximation exploration

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

error: pathspec 'src/conexp/contrib/concept_approximation.clj' did not match any file(s) known to git

--- src/conexp/contrib/concept_approximation.clj
+++ src/conexp/contrib/concept_approximation.clj
@@ -0,0 +1,34 @@
+;; Copyright (c) Daniel Borchmann. All rights reserved.
+;; The use and distribution terms for this software are covered by the
+;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+;; which can be found in the file LICENSE at the root of this distribution.
+;; By using this software in any fashion, you are agreeing to be bound by
+;; the terms of this license.
+;; You must not remove this notice, or any other, from this software.
+
+(ns conexp.contrib.concept-approximation
+  (:use conexp.main))
+
+(ns-doc "Concept Approximation as described by C. Meschke.")
+
+;;;
+
+(defn explore-approximations
+  "Performs concept approximation exploration and returns the final
+  context."
+  [context]
+  (let [att-explored-ctx (:context (explore-attributes context)),
+        obj-explored-ctx (dual-context
+                          (:context (explore-attributes
+                                     (dual-context context))))]
+    (context-subposition
+     (context-apposition context obj-explored-ctx)
+     (context-apposition att-explored-ctx
+                         (smallest-bond att-explored-ctx
+                                        obj-explored-ctx
+                                        (union (incidence att-explored-ctx)
+                                               (incidence obj-explored-ctx)))))))
+
+;;;
+
+nil


Flesh out restart-subscription logic

Flesh out restart-subscription logic

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/democracyworks/election-notification-works.git/'


Add stub for pangram

Add stub for pangram

error: pathspec 'exercises/pangram/src/pangram.clj' did not match any file(s) known to git

--- exercises/pangram/src/pangram.clj
+++ exercises/pangram/src/pangram.clj
@@ -0,0 +1,5 @@
+(ns pangram)
+
+(defn pangram? [] ;; <- Arglist goes here
+  ;; your code goes here
+  )


Added example how to use services.

Added example how to use services.

error: pathspec 'src/clojure/meerkat/examples/services.clj' did not match any file(s) known to git

--- src/clojure/meerkat/examples/services.clj
+++ src/clojure/meerkat/examples/services.clj
@@ -0,0 +1,60 @@
+(ns meerkat.examples.services
+  (:gen-class)
+  (:require [meerkat.services :as services])
+  (:import [meerkat.services Service]))
+
+(defprotocol Foo
+  (foo [this] "Produce foo object."))
+
+(defprotocol Renderer
+  (render [this foo] "Render foo object."))
+
+(defprotocol Printer
+  (print-it [this] "Print a value."))
+
+(defrecord FooService [name dependencies configuration]
+  Service
+  (configure [this new-configuration]
+    (meerkat.services/configure-service this configuration new-configuration))
+  (start [_] "start service" (println "FooService just started"))
+  (stop [_] "stop service" (println "FooService just stopped"))
+  Foo
+  (foo [this] {:name (:name this) :value1 (-> this :configuration deref :value1)}))
+
+(defrecord RendererService [name dependencies configuration]
+  Service
+  (configure [this new-configuration]
+    (meerkat.services/configure-service this configuration new-configuration))
+  (start [_] "start service" (println "RendererService just started"))
+  (stop [_] "stop service" (println "RendererService just stopped"))
+  Renderer
+  (render [this foo] (format (-> this :configuration deref :format) (:name foo) (:value1 foo))))
+
+; You should declare fields to be injected with dependencies.
+; It allows to generate code with better performance.
+(defrecord PrinterService [name dependencies configuration renderer foo]
+  Service
+  (configure [this new-configuration]
+    (meerkat.services/configure-service this configuration new-configuration))
+  (start [_] "start service" (println "PrinterService just started"))
+  (stop [_] "stop service" (println "PrinterService just stopped"))
+  Printer
+  (print-it [_]
+    (let [
+          foo-result (meerkat.examples.services/foo foo)
+          rendered-string (render renderer foo-result)]
+      (println rendered-string))))
+
+(defn -main [& args]
+  (let [services [(->PrinterService :printer [:renderer :foo] (atom {}) nil nil)
+                  (->RendererService :renderer [] (atom {}))
+                  (->FooService :foo [] (atom {}))]
+        configuration {:renderer {:format "Name of the service is %s and value1 is %s"}
+                       :foo {:value1 356}}
+        sorted-services (services/sort-services services)
+        services-with-dependencies (services/inject-dependencies sorted-services)
+        _ (services/configure-all services-with-dependencies configuration)
+        foo-printer (first (filter #(= :printer (:name %)) services-with-dependencies))]
+    (services/start-all services-with-dependencies)
+    (print-it foo-printer)
+    (services/stop-all (reverse services-with-dependencies))))


read 16.1

read 16.1

fatal: unable to access 'https://github.com/rickhall2000/joy.git/': The requested URL returned error: 403


'Hello world' Clojure style.

'Hello world' Clojure style.

fatal: unable to access 'https://github.com/pauldoo/racepoint.git/': The requested URL returned error: 403


provide test defaults for database

provide test defaults for database

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/physion/ovation-webapi.git/'


remove throwing an exception since empty list is ok

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/max-neverov/ads-client.git/'


Log reg-form-and-info too

Log reg-form-and-info too

I'm worried there might be something broken here.


slave resources

slave resources

fatal: unable to access 'https://github.com/jchli/jepsen-aurora.git/': The requested URL returned error: 403


Make all log-functions take variadic (print-style) args.

fatal: unable to access 'https://github.com/cswaroop/pepa.git/': The requested URL returned error: 403


Refactor PUT route.

Refactor PUT route.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/julianespinel/directory.git/'


one more security check to validate that user has read perms on the database they are filtering by.

--- src/metabase/api/card.clj
+++ src/metabase/api/card.clj
@@ -8,7 +8,9 @@
                              [card :refer [Card] :as card]
                              [card-favorite :refer [CardFavorite]]
                              [common :as common]
+                             [database :refer [Database]]
                              [revision :refer [push-revision]]
+                             [table :refer [Table]]
                              [user :refer [User]])))

 (defannotation CardFilterOption
@@ -35,7 +37,10 @@
   {f CardFilterOption
    id Integer}
   (when (contains? #{:database :table} f)
-    (checkp (integer? id) "id" (format "id is required parameter when filter mode is '%s'" (name f))))
+    (checkp (integer? id) "id" (format "id is required parameter when filter mode is '%s'" (name f)))
+    (case f
+      :database (read-check Database id)
+      :table    (read-check Database (:db_id (sel :one :fields [Table :database_id])))))
   (-> (case (or f :all) ; default value for `f` is `:all`
         :all      (sel :many Card (k/order :name :ASC) (k/where (or {:creator_id *current-user-id*}
                                                                     {:public_perms [> common/perms-none]})))


consistent use of next vs. rest

consistent use of next vs. rest


URL konpondu, "orria", ez "orriak"

URL konpondu, "orria", ez "orriak"

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/lnmnd/magnet.bez.git/'


equality

equality

error: pathspec 'src/latte/equal.clj' did not match any file(s) known to git

--- src/latte/equal.clj
+++ src/latte/equal.clj
@@ -0,0 +1,62 @@
+(ns latte.equal
+  "The formal definition of equality, and its basic properties."
+
+  (:refer-clojure :exclude [and or not])
+
+  (:require [latte.core :as latte :refer [defterm defthm forall assume have proof]])
+
+  (:require [latte.prop :as p :refer [<=> and or not]])
+  )
+
+(defterm equal
+  "The intuitionistic, second-order definition of equality.
+This corresponds to Leibniz's *indiscernibility of identicals*."
+  [[T :type] [x T] [y T]]
+  (forall [P (==> T :type)]
+    (<=> (P x) (P y))))
+
+(defthm eq-refl
+  "The reflexivity property of equality."
+  [[T :type] [x T]]
+  (equal T x x))
+
+(proof eq-refl :script
+  (assume [P (==> T :type)]
+    (have a (<=> (P x) (P x)) :by (p/iff-refl (P x)))
+    (qed (a))))
+
+(defthm eq-sym
+  "The symmetry property of equality."
+  [[T :type] [x T] [y T]]
+  (==> (equal T x y)
+       (equal T y x)))
+
+(proof eq-sym :script
+  (assume [Heq (equal T x y)
+           P (==> T :type)]
+    (have a (<=> (P x) (P y)) :by (Heq P))
+    (have b (<=> (P y) (P x)) :by ((p/iff-sym (P x) (P y)) (a)))
+    (have c _ :discharge [P (b)])
+    (qed c)))
+
+(defthm eq-trans
+  "The transitivity property of equality."
+  [[T :type] [x T] [y T] [z T]]
+  (==> (equal T x y)
+       (equal T y z)
+       (equal T x z)))
+
+(proof eq-trans :script
+  (assume [H1 (equal T x y)
+           H2 (equal T y z)
+           P (==> T :type)]
+    (have a (<=> (P x) (P y)) :by (H1 P))
+    (have b (<=> (P y) (P z)) :by (H2 P))
+    (have c (<=> (P x) (P z))
+          :by ((p/iff-trans (P x) (P y) (P z)) (a) (b)))
+    (have d _ :discharge [P (c)])
+    (qed d)))
+
+
+
+


remove unnecessary resources from build and add .bowerrc

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/aamedina/om-cljs.git/'


Add a better integration test

Add a better integration test

fatal: unable to access 'https://github.com/FalseProtagonist/graphagora.git/': The requested URL returned error: 403


whoops, test fix

whoops, test fix

--- test/metabase/test_utils.clj
+++ test/metabase/test_utils.clj
@@ -5,7 +5,6 @@
             [ring.adapter.jetty :as ring]
             (metabase [core :as core]
                       [db :refer :all]
-                      test-utils
                       [test-data :refer :all])))

 (declare load-test-data


fix merge conflict

fix merge conflict

--- src/metabase/driver/sync.clj
+++ src/metabase/driver/sync.clj
@@ -375,10 +375,10 @@
   [field]
   (cond
     (and (not (:special_type field))
-         (:preview_display field)                        (mark-category-field! field)
+         (:preview_display field))                       (mark-category-field! field)
     (field-values/field-should-have-field-values? field) (do (log/debug (format "Updating values for field '%s'..." @(:qualified-name field)))
                                                              (field-values/update-field-values! field)
-                                                             field))))
+                                                             field)))

 ;; ### mark-no-preview-display-field!


Add initial approach for client-server communication.

error: pathspec 'src/uxbox/repo.cljs' did not match any file(s) known to git

--- src/uxbox/repo.cljs
+++ src/uxbox/repo.cljs
@@ -0,0 +1,45 @@
+(ns uxbox.repo
+  "A main interface for access to remote resources."
+  (:refer-clojure :exclude [do])
+  (:require [postal.client :as ps]
+            [beicon.core :as rx]))
+
+(def ^:private ^:const +client+
+  "https://test.uxbox.io")
+
+(defn novelty
+  [type data]
+  (rx/from-promise
+   (ps/novelty +client+ type data)))
+
+(defn query
+  ([type]
+   (rx/from-promise
+    (ps/query +client+ type)))
+  ([type data]
+   (rx/from-promise
+    (ps/query +client+ type data))))
+
+(defmulti -do
+  (fn [type data] type))
+
+(defn do
+  "Perform a side effectfull action accesing
+  remote remote resources."
+  ([type]
+   (-do type nil))
+  ([type data]
+   (-do type data)))
+
+;; (defmethod do :login
+;;   [type data]
+;;   (rx/from-promise
+;;    (ps/novelty :login data)))
+
+(defmethod -do :login
+  [type data]
+  (->> (rx/of {:fullname "Cirilla Fiona"
+               :photo "/images/favicon.png"
+               :username "cirilla"
+               :email "cirilla@uxbox.io"})
+       (rx/delay 100)))


making new error line clickable

making new error line clickable

--- support/src/figwheel/client/heads_up.cljs
+++ support/src/figwheel/client/heads_up.cljs
@@ -142,8 +142,16 @@
           (first (keep file-and-line-number formatted-messages)))
         msg (apply str (map #(str "<div>" % "</div>") formatted-messages))]
     (display-heads-up {:backgroundColor "rgba(255, 161, 161, 0.95)"}
-                      (str (close-link) (heading "Compile Error") (file-selector-div file-name file-line msg)
-                           (if cause (str "Error on file " (:file cause) ", line " (:line cause) ", column " (:column cause)))))))
+                      (str (close-link) (heading "Compile Error")
+                           (file-selector-div file-name (or file-line (and cause (:line cause)))
+                                              (str msg
+                                                   (if cause
+                                                     (str "Error on file "
+                                                          (:file cause)
+                                                          ", line "
+                                                          (:line cause)
+                                                          ", column " (:column cause))
+                                                     "")))))))

 (defn display-system-warning [header msg]
   (display-heads-up {:backgroundColor "rgba(255, 220, 110, 0.95)" }


Add a test for jungerer.io/load-pairs!

Add a test for jungerer.io/load-pairs!

error: pathspec 'test/jungerer/io_test.clj' did not match any file(s) known to git

--- test/jungerer/io_test.clj
+++ test/jungerer/io_test.clj
@@ -0,0 +1,11 @@
+(ns jungerer.io-test
+  (:require [clojure.test :refer :all]
+            [clojure.java.io :as io]
+            [jungerer.graph :as g]
+            [jungerer.io :refer :all]))
+
+(def sample-pairs-f (io/resource "sample.pairs"))
+
+(deftest load-pairs!-test
+  (testing "returns nil if loading is succeeded"
+    (is (nil? (load-pairs! sample-pairs-f (g/directed-graph))))))


Adds logic for the snake

Adds logic for the snake

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/thorsteinson/cljs-snake.git/'


Calculate Sha512 and generate a hex-string from bytes.

error: pathspec 'src-cljs/tranjlator/hashing.cljs' did not match any file(s) known to git

--- src-cljs/tranjlator/hashing.cljs
+++ src-cljs/tranjlator/hashing.cljs
@@ -0,0 +1,21 @@
+(ns tranjlator.hashing
+  (:refer-clojure :exclude [hash])
+  (:import [goog.crypt Sha512]))
+
+(def ^:const +hex-chars+ [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \A \B \C \D \E \F])
+
+(defn hex-string
+  [bytes]
+  (->> bytes
+       (map #(bit-and (int %) 0xFF))
+       (reduce (fn [acc unsigned]
+                 (-> acc
+                     (conj (get +hex-chars+ (bit-shift-right unsigned 4)))
+                     (conj (get +hex-chars+ (bit-and unsigned 0x0F)))))
+               [])
+       (apply str)))
+
+(defn hash
+  [s]
+  (.digest (doto (Sha512.)
+             (.update s))))


update list of team members

update list of team members

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/democracyworks/election-notification-works.git/'


Keyword Transposition Cipher added challange

error: pathspec 'src/hackerrank/security/keyword_transposition.clj' did not match any file(s) known to git

--- src/hackerrank/security/keyword_transposition.clj
+++ src/hackerrank/security/keyword_transposition.clj
@@ -0,0 +1,24 @@
+;; Keyword Transposition Cipher
+;; https://www.hackerrank.com/challenges/keyword-transposition-cipher
+
+(ns hackerrank.security.keyword-transposition
+  (:require [clojure.java.io :as io])
+  (:use [clojure.string :only (split join trim)]))
+
+(defn parseInt [string]
+  (Integer/parseInt string))
+
+;; solution idea:
+
+(defn keyword-transposition
+
+  ([]
+    (let [n (parseInt (read-line))]
+        (factorial n)))
+
+  ([input]
+   (with-in-str input
+     (keyword-transposition))))
+
+;; uncomment for hackerrank:
+;; (println (keyword-transposition))


Add lighweight immutable datetime abstraction.

error: pathspec 'src/uxbox/util/datetime.cljs' did not match any file(s) known to git

--- src/uxbox/util/datetime.cljs
+++ src/uxbox/util/datetime.cljs
@@ -0,0 +1,102 @@
+;; This Source Code Form is subject to the terms of the Mozilla Public
+;; License, v. 2.0. If a copy of the MPL was not distributed with this
+;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;;
+;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
+
+(ns uxbox.util.datetime
+  (:require [cljsjs.moment]))
+
+;; A simplified immutable date time representation type.
+
+(deftype DateTime [^number v]
+  IComparable
+  (-compare [this other]
+    (if (instance? DateTime other)
+      (compare v (.-v other))
+      (throw (js/Error. (str "Cannot compare " this " to " other)))))
+
+  IPrintWithWriter
+  (-pr-writer [_ writer _]
+    (let [m (js/moment v)
+          ms (.toISOString m)]
+      (-write writer (str "#datetime \"" ms "\""))))
+
+  Object
+  (toString [this]
+    (let [m (js/moment v)]
+      (.toISOString m)))
+
+  (equiv [this other]
+    (-equiv this other))
+
+  IHash
+  (-hash [_] v))
+
+(alter-meta! #'->DateTime assoc :private true)
+
+(defn datetime
+  "Create a new DateTime instance from
+  unix offset."
+  [v]
+  {:pre [(number? v)]}
+  (DateTime. v))
+
+(defn datetime?
+  "Return true if `v` is an instance of DateTime."
+  [v]
+  (instance? DateTime v))
+
+(defn parse
+  "Parse a string representation of datetime
+  with an optional `format` parameter."
+  ([v] (parse v :offset))
+  ([v fmt]
+   (cond
+     (datetime? v) v
+     (= fmt :offset) (DateTime. v)
+     :else (let [m (if (= fmt :unix)
+                     (js/moment.unix v)
+                     (js/moment v fmt))]
+             (DateTime. (.valueOf m))))))
+
+(defn format
+  "Returns a string representation of the DateTime
+  instance with optional `fmt` format parameter.
+
+  You can use `:iso` and `:unix` shortcuts as
+  format parameter.
+
+  You can read more about format tokens here:
+  http://momentjs.com/docs/#/displaying/format/
+  "
+  ([v] (format v :iso))
+  ([v fmt]
+   (let [vm (js/moment v)]
+     (case fmt
+       :unix (.unix vm)
+       :offset (.valueOf v)
+       :iso (.toISOString vm)
+       (.format vm fmt)))))
+
+(defn now
+  "Return the current DateTime."
+  []
+  (let [vm (js/moment)]
+    (DateTime. (.valueOf vm))))
+
+(defn timeago
+  [v]
+  (let [dt (parse v)
+        vm (js/moment (.-v dt))]
+    (.fromNow vm)))
+
+;; (defn day
+;;   [v]
+;;   (let [dt (parse v)
+;;         vm (js/moment (.-v dt))
+;;         fmt #js {:sameDay "[Today]"
+;;                  :sameElse "[Today]"
+;;                  :lastDay "[Yesterday]"
+;;                  :lastWeek "[Last] dddd"}]
+;;     (.calendar vm nil fmt)))


fix uuid

fix uuid

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/james-mcelwain/vielheit-clj.git/'


Add time utilities

Add time utilities

error: pathspec 'src/cljs/hacker_agent/time.cljs' did not match any file(s) known to git

--- src/cljs/hacker_agent/time.cljs
+++ src/cljs/hacker_agent/time.cljs
@@ -0,0 +1,44 @@
+(ns hacker-agent.time)
+
+(defn- now []
+  (quot
+   (.. js/Date (now))
+   10))
+
+(defn- in-minutes [seconds]
+  (quot seconds 60))
+
+(defn- in-hours [seconds]
+  (quot (in-minutes seconds) 60))
+
+(defn- in-days [seconds]
+  (quot (in-hours seconds) 24))
+
+(defn minutes [x]
+  (* 60 x))
+
+(defn hours [x]
+  (* (minutes 60) x))
+
+(defn days [x]
+  (* (hours 24) x))
+
+(defn time-ago
+  [timestamp]
+  (let [time-diff (- (now) timestamp)]
+    (cond
+     ;; seconds
+     (< time-diff (minutes 1))
+     (let [i time-diff]
+       (str i " second" (when-not (= i 1) "s") " ago"))
+     ;; minutes
+     (< time-diff (hours 1))
+     (let [i (in-minutes time-diff)]
+       (str i " minute" (when-not (= i 1) "s") " ago"))
+     ;; hours
+     (< time-diff (days 1))
+     (let [i (in-hours time-diff)]
+       (str i " hour" (when-not (= i 1) "s") " ago"))
+     ;; days
+     :else (let [i (in-days time-diff)]
+             (str i " day" (when-not (= i 1) "s") " ago")))))


Added unit tests to verify fix for parsed xml namespace.

error: pathspec 'search-app/test/cmr/search/test/results_handlers/metadata_results_handler.clj' did not match any file(s) known to git

--- search-app/test/cmr/search/test/results_handlers/metadata_results_handler.clj
+++ search-app/test/cmr/search/test/results_handlers/metadata_results_handler.clj
@@ -0,0 +1,42 @@
+(ns cmr.search.test.results-handlers.metadata-results-handler
+  (:require [clojure.test :refer :all]
+            [clojure.data.xml :as x]
+            [cmr.search.results-handlers.metadata-results-handler :as mrh]))
+
+(deftest fix-parsed-xml-namespace-test
+  (testing "DIF collection"
+    (let [xml "<results><result><DIF xmlns=\"http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/\"
+              xmlns:dif=\"http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/\"
+              xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
+              xsi:schemaLocation=\"http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/
+              http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/dif_v9.8.4.xsd\">
+              <Entry_ID>geodata_1848</Entry_ID></DIF></result></results>"
+              parsed (x/parse-str xml)]
+      ;; Once no exception is thrown here, we can take out the workaround for fixing xml namespace
+      (is (thrown-with-msg? javax.xml.stream.XMLStreamException
+                            #"Prefix cannot be null"
+                            (x/emit-str parsed)))
+      (x/emit-str (mrh/fix-parsed-xml-namespace :dif :collection parsed))))
+
+  (testing "ECHO10 collection"
+    (let [xml "<results><result><Collection xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
+              xsi:noNamespaceSchemaLocation=\"../schemas/Collection.xsd\">
+              <ShortName>CZCSL3BCU</ShortName></Collection></result></results>"
+              parsed (x/parse-str xml)]
+      ;; Once no exception is thrown here, we can take out the workaround for fixing xml namespace
+      (is (thrown-with-msg? javax.xml.stream.XMLStreamException
+                            #"Prefix cannot be null"
+                            (x/emit-str parsed)))
+      (x/emit-str (mrh/fix-parsed-xml-namespace :echo10 :collection parsed))))
+
+  (testing "ECHO10 granule"
+    (let [xml "<results><result><Granule xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
+              xsi:noNamespaceSchemaLocation=\"../schemas/Collection.xsd\">
+              <ShortName>CZCSL3BCU</ShortName></Granule></result></results>"
+              parsed (x/parse-str xml)]
+      ;; Once no exception is thrown here, we can take out the workaround for fixing xml namespace
+      (is (thrown-with-msg? javax.xml.stream.XMLStreamException
+                            #"Prefix cannot be null"
+                            (x/emit-str parsed)))
+      (x/emit-str (mrh/fix-parsed-xml-namespace :echo10 :granule parsed)))))
+


deprecate use of config for uri

deprecate use of config for uri

we've been doing this several places, makes it
much easier to test from a regular REPL


optional rlwrap

optional rlwrap

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/michaelsbradleyjr/shen.clj.git/'


Fix ordering of opts

Fix ordering of opts

`env/default-compiler-env` probably needs that upstream dependency information...

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/modnakasta/weasel.git/'


ttest

ttest

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/clojure-ml/cml.git/'


Reorder to expected/actual

Reorder to expected/actual

This is partly for consistency but also because some clojure.test
messages assume this order.

--- test/yada/phonebook_test.clj
+++ test/yada/phonebook_test.clj
@@ -81,7 +81,7 @@
                          :follow-redirects false
                          :headers {"content-type" "application/x-www-form-urlencoded"}
                          :body (codec/form-encode {:firstname "Kath" :surname "Read" :phone "1236"})})]
-    (is (= (:status post-response) 303))
+    (is (= 303 (:status post-response)))
     (let [location (get-in post-response [:headers "location"])]
       (is (re-matches #"/phonebook/\d+" location)))
     (let [headers (set (keys (get post-response :headers)))]
@@ -95,7 +95,7 @@
                              (str prefix location)
                              {:pool test-connection-pool
                               :follow-redirects false})]
-          (is (= (:status get-response) 200)))))))
+          (is (= 200 (:status get-response))))))))

 (def boundary "BoundaryZ3oJB7WHOBmOjrEi")


Revert last commit

Revert last commit

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/batasrki/blog-post-app.git/'


Add mpileup (WIP)

Add mpileup (WIP)

error: pathspec 'src/clojure/cljam/mpileup.clj' did not match any file(s) known to git

--- src/clojure/cljam/mpileup.clj
+++ src/clojure/cljam/mpileup.clj
@@ -0,0 +1,134 @@
+(ns cljam.mpileup
+  (:require [clojure.string :as str]
+            [cljam.cigar :as cgr]
+            [cljam.io :as io]
+            [cljam.util :refer [ubyte]]
+            [cljam.util.sam-util :refer [phred->fastq fastq->phred]]))
+
+;; TODO: estiamte from actual data
+(def ^:private window-width 1250)
+(def ^:private step 2000)
+(def ^:private center (int (/ step 2)))
+
+(defn- wrap
+  [rname positions counts seq qual]
+  (map (fn [{:keys [pos count qual seq]}]
+         {:rname rname
+          :pos pos
+          :ref \N ; FIXME
+          :count count
+          :seq seq
+          :qual qual})
+       (map merge
+            (map (partial hash-map :pos) positions)
+            (map (partial hash-map :count) counts)
+            (map (partial hash-map :qual) qual)
+            (map (partial hash-map :seq) seq))))
+
+(defn- pickup-qual [aln pos]
+  (if (= (:qual aln) "*")
+    \~
+    (nth (:qual aln) pos)))
+
+(comment
+
+ (with-open [r (cljam.bam/reader "test/resources/test.sorted.bam")]
+   (mpileup r "ref"))
+
+ )
+
+(defn- count-for-alignment
+  [^clojure.lang.PersistentHashMap aln
+   ^String rname
+   ^clojure.lang.LazySeq positions]
+  (if (= rname (:rname aln))
+    (let [^Long left (:pos aln)
+          ^Long right (dec (+ left (cgr/count-ref (:cigar aln))))
+          subs-seq (cgr/substantial-seq (:cigar aln) (:seq aln))]
+      (map (fn [p]
+             (if (and (>= p left) (<= p right))
+               {:count 1
+                :seq (nth subs-seq (- p left))
+                :qual (pickup-qual aln (- p left))
+                :head (= p left)
+                :tail (= p right)}
+               {:count 0, :seq nil, :qual nil}))
+           positions))
+    (take (count positions) (repeat {:count 0, :seq nil, :qual nil}))))
+
+(defn- count-for-positions
+  [alns rname positions]
+  (if (pos? (count alns))
+    (let [cfas (map #(count-for-alignment % rname positions) alns)]
+      (wrap rname positions
+            (apply map (fn [& args]
+                         (reduce + (map :count args))) cfas)
+            (apply map (fn [& args]
+                         (str/join
+                          (map (fn [a]
+                                 (str (if (:head a) (str "^" (:qual a)))
+                                      (:seq a)
+                                      (if (:tail a) "$")))
+                               args)))
+                   cfas)
+            (apply map (fn [& args]
+                         (str/join
+                          (map :qual args)))
+                   cfas)))
+    (wrap rname positions
+          (take (count positions) (repeat 0))
+          nil nil)))
+
+(defn rpositions
+  ([^Long start ^Long end]
+     (rpositions start end start))
+  ([^Long start ^Long end ^Long n]
+     (if (>= end n)
+       (cons n
+             (lazy-seq (rpositions start end (inc n))))
+       nil)))
+
+(defn- read-alignments
+  [rdr ^String rname ^Long rlength ^Long pos]
+  (let [^Long left (let [^Long val (- pos window-width)]
+                     (if (< val 0)
+                       0
+                       val))
+        ^Long right (let [^Long val (+ pos window-width)]
+                      (if (< rlength val)
+                        rlength
+                        val))]
+    (io/read-alignments rdr {:chr rname
+                             :start left
+                             :end right
+                             :depth :deep})))
+
+(defn- search-ref
+  [refs rname]
+  (first
+   (filter (fn [r] (= (:name r) rname))
+           refs)))
+
+(defn- mpileup*
+  ([rdr ^String rname ^Long rlength ^Long start ^Long end]
+     (flatten
+      (let [parts (partition-all step (rpositions start end))]
+        (map (fn [positions]
+               (let [^Long pos (if (= (count positions) step)
+                                 (nth positions center)
+                                 (nth positions (quot (count positions) 2)))
+                     ^clojure.lang.LazySeq alns (read-alignments rdr rname rlength pos)]
+                 (count-for-positions alns rname positions)))
+             parts)))))
+
+(defn mpileup
+  ([rdr ^String rname]
+     (mpileup rdr rname -1 -1))
+  ([rdr ^String rname ^Long start* ^Long end*]
+     (let [r (search-ref (.refs rdr) rname)]
+       (if (nil? r)
+         nil
+         (mpileup* rdr
+                  rname (:len r)
+                  (if (neg? start*) 0 start*)
+                  (if (neg? end*) (:len r) end*))))))


URLa konpondu

URLa konpondu

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/lnmnd/magnet.bez.git/'


Clojure solution to problem 1

Clojure solution to problem 1

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/toroidal-code/euler.git/'


Add some tests for compojure routes.

Add some tests for compojure routes.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/julianespinel/directory.git/'


Some work on concurrency chapter

Some work on concurrency chapter

error: pathspec 'brave-true/clojure-noob/src/clojure_noob/concurrency.clj' did not match any file(s) known to git

--- brave-true/clojure-noob/src/clojure_noob/concurrency.clj
+++ brave-true/clojure-noob/src/clojure_noob/concurrency.clj
@@ -0,0 +1,149 @@
+(ns clojure-noob.concurrency
+  (require [midje.sweet :refer :all]))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; futures
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+;;(future (Thread/sleep 4000)
+;;        (println "I'll print after 4 seconds"))
+;;(println "I'll print immediately")
+
+;; Futures differ from the values you're used to, like hashes and maps,
+;; in that you have to dereference them to obtain their value
+
+
+(fact "dereference a future"
+
+  (let [result (future (println "this prints once")
+                       (+ 1 1))]
+    (deref result) => 2
+    @result => 2))
+
+(fact "time limit:"
+
+  (deref (future (Thread/sleep 1000) 0) 10 5)
+  => 5)
+
+(fact "interrogate a future to see if it's done running wit 'realized?'"
+
+  (realized? (future (Thread/sleep 1000)))
+  => false
+
+  (let [f (future)]
+    @f
+    (realized? f))
+  => true )
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; dereferencing
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; delays
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(def jackson-5-delay
+      (delay (let [message "Just call my name and I'll be there"]
+               (println "First defef:" message)
+               message)))
+
+
+(fact "deref the delay"
+
+  (force jackson-5-delay)
+;; First defef: Just call my name and I'll be there
+  => "Just call my name and I'll be there" )
+
+
+(fact "Like futures, a delay is only run once and its result is cached"
+
+  @jackson-5-delay
+  => "Just call my name and I'll be there" )
+
+
+(def gimli-headshots ["serious.jpg" "fun.jpg" "playful.jpg"])
+
+(defn email-user
+  [email-address]
+  (println "Sending headshot notification to" email-address))
+
+(defn upload-document
+  "Needs to be implemented"
+  [headshot]
+  true)
+
+
+(fact "sending email"
+
+  (let [notify (delay (email-user "and-my-axe@gmail.com"))]
+    (doseq [headshot gimli-headshots]
+      (future (upload-document headshot)
+              (force notify))))
+  ;; Sending headshot notification to and-my-axe@gmail.com
+  => nil)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;
+;; promises
+;;;;;;;;;;;;;;;;;;;;;;;
+
+(fact "promises"
+
+  (def my-promise (promise))
+  (deliver my-promise (+ 1 2))
+  @my-promise
+  => 3 )
+
+
+;; yak butter
+
+(def yak-butter-international
+  {:store "Yak Butter International"
+    :price 90
+    :smoothness 90})
+
+(def butter-than-nothing
+  {:store "Butter than Nothing"
+   :price 150
+   :smoothness 83})
+
+;; This is the butter that meets our requirements
+(def baby-got-yak
+  {:store "Baby Got Yak"
+   :price 94
+   :smoothness 99})
+
+(defn mock-api-call
+  [result]
+  (Thread/sleep 1000)
+  result)
+
+(defn satisfactory?
+  "If the butter meets our criteria, return the butter, else return false"
+  [butter]
+  (and (<= (:price butter) 100)
+       (>= (:smoothness butter) 97)
+       butter))
+
+
+(fact "'some' applies a function to each element of a collection and
+        rturns the first truthy result"
+
+  (some odd? [2 3 4 5])
+  => true
+
+  ;; return the value which has the truthy result
+  (some #(and (odd? %) %) [2 3 4 5])
+  => 3 )
+
+(fact "check each site synchronously"
+
+  (time (some (comp satisfactory? mock-api-call)
+              [yak-butter-international butter-than-nothing baby-got-yak]))
+;; => "Elapsed time: 3002.132 msecs"
+  => {:store "Baby Got Yak", :smoothness 99, :price 94})
+


[WM] correct location of created users

[WM] correct location of created users

/users is no longer a thing

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/democracyworks/user-http-api.git/'


Init/migration for sql tables

Init/migration for sql tables

error: pathspec 'src/wishlistd/models/init.clj' did not match any file(s) known to git

--- src/wishlistd/models/init.clj
+++ src/wishlistd/models/init.clj
@@ -0,0 +1,37 @@
+(ns wishlistd.models.init
+  (:require [clojure.java.jdbc :as sql]))
+
+(def db {:classname "org.postgresql.Driver"
+         :subprotocol "postgresql"
+         :subname "//localhost:5432/cwl"
+         :user "cwl"
+         :password "wish"})
+
+(defn create-wishlist []
+  (sql/with-connection db
+    (sql/create-table :wishlist
+      [:code :varchar "PRIMARY KEY"]
+      [:title :varchar "NOT NULL"]
+      [:created_at :timestamp "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"])))
+
+(defn create-wish []
+  (sql/with-connection db
+    (sql/create-table :wish
+      [:id :serial "PRIMARY KEY"]
+      [:description :varchar "NOT NULL"]
+      [:created_at :timestamp "NOT NULL" "DEFAULT CURRENT_TIMESTAMP"]
+      [:url :varchar]
+      [:wishlist_code :varchar]
+      ["constraint fk_wish_wishlist foreign key(wishlist_code) references wishlist(code) on delete cascade"])))
+
+(defn drop-tables []
+  (sql/with-connection db
+    (sql/drop-table :wish)
+    (sql/drop-table :wishlist)))
+
+(defn -main []
+  (print "Migrating database...") (flush)
+  (drop-tables)
+  (create-wishlist)
+  (create-wish)
+  (println " done"))


Remove obsolete import

Remove obsolete import

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Yleisradio/rabid.git/'


More descriptive placeholder text for browse jump. #86

--- src/clojars/web/browse.clj
+++ src/clojars/web/browse.clj
@@ -16,7 +16,7 @@
       [:form.browse-from {:method :get :action "/projects"}
        (label :from "starting from")
        [:input {:type :text :name :from :id :from
-                :placeholder (jar-name (first projects))}]
+                :placeholder "Enter a few letters..."}]
        [:input {:type :submit :value "Jump" :id :jump}]]]
      (page-description page per-page project-count)
      [:ul


Xhr library code.

Xhr library code.

error: pathspec 'src/task_tracker/app/xhr.cljs' did not match any file(s) known to git

--- src/task_tracker/app/xhr.cljs
+++ src/task_tracker/app/xhr.cljs
@@ -0,0 +1,24 @@
+(ns task-tracker.app.xhr
+  (:require [goog.events           :as events]
+            [task-tracker.app.util :as util])
+  (:import [goog.net XhrIo]
+           goog.net.EventType
+           [goog.events EventType]))
+
+(def ^:private meths
+  {:get    "GET"
+   :post   "POST"
+   :put    "PUT"
+   :delete "DELETE"})
+
+(def ^:private api-base-url "http://localhost:3141/api/")
+
+(defn xhr-req
+  [{:keys [method url data on-complete]}]
+  (let [xhr (XhrIo.)]
+    (events/listen xhr goog.net.EventType.COMPLETE
+                   (fn [e]
+                     (on-complete (util/parse-json (.getResponseText xhr)))))
+    (. xhr
+       (send (str api-base-url url) (meths method) (when data (util/write-json data))
+             #js {"Content-Type" "application/json"}))))


beginning data modelling of fight club 5 data

error: pathspec 'src/fight_club_5/model.clj' did not match any file(s) known to git

--- src/fight_club_5/model.clj
+++ src/fight_club_5/model.clj
@@ -0,0 +1,33 @@
+(ns fight-club-5.model
+  (:require [schema.core :as s]))
+
+(s/defschema Casting-Time s/Str)
+
+(s/defschema Game-Range s/Str)
+
+(s/defschema Spell-Component s/Str)
+
+(s/defschema Effect-Duration s/Str)
+
+(s/defschema Class-Name s/Str)
+
+(s/defschema Spell-Description s/Str)
+
+(s/defschema Roll s/Str)
+
+(s/defschema Magic-School (s/enum :C))
+
+(s/defschema Spell
+  {:name s/Str
+   :level s/Int
+   :school Magic-School
+   :time Casting-Time
+   :range Game-Range
+   :components #{Spell-Component}
+   :duration Effect-Duration
+   :classes [Class-Name]
+   :text [Spell-Description]
+   :roll [Roll]})
+
+(s/defschema Compendium
+  {:spells [Spell]})


Move argument-parsing code to lazytest.arguments

and add assertions

error: pathspec 'src/main/clojure/com/stuartsierra/lazytest/arguments.clj' did not match any file(s) known to git

--- src/main/clojure/com/stuartsierra/lazytest/arguments.clj
+++ src/main/clojure/com/stuartsierra/lazytest/arguments.clj
@@ -0,0 +1,76 @@
+(ns com.stuartsierra.lazytest.arguments)
+
+(defn get-arg
+  "Pops first argument from args if (pred arg) is true.
+  Returns a vector [this-arg remaining-args] or [nil args]."
+  [pred args]
+  (if (pred (first args))
+    [(first args) (next args)]
+    [nil args]))
+
+(defn get-options
+  "Extracts keyword-value pairs from head of args, until next arg is
+  not a keyword.  Returns a vector [options-map remaining-args]"
+  [args]
+  (loop [options nil args args]
+    (if (and (seq args) (keyword? (first args)))
+      (recur (assoc options (first args) (second args)) (nnext args))
+      [options args])))
+
+(defn standard-metadata
+  "Returns a metadata map with keys :ns, :file,
+  :line, :form, :doc, and :name."
+  ([form docstring]
+     `{:ns *ns*
+       :file *file*
+       :line (:line (meta ~form))
+       :form '~form
+       :doc ~docstring})
+  ([form docstring name]
+     `{:ns *ns*
+       :file *file*
+       :line (:line (meta ~form))
+       :form '~form
+       :doc ~docstring
+       :name '~name}))
+
+(defn firsts
+  "Returns a vector of the first element of each pair."
+  [coll]
+  (vec (map first (partition 2 coll))))
+
+(defn seconds
+  "Returns a vector of the second element of each pair."
+  [coll]
+  (vec (map second (partition 2 coll))))
+
+
+;;; ASSERTIONS
+
+;; get-arg
+(assert (= ["doc" '(a b)] (get-arg string? '("doc" a b))))
+(assert (= [nil '(a b)] (get-arg string? '(a b))))
+
+;; get-options
+(assert (= [{:a 1 :b 2} '(c d)] (get-options '(:a 1 :b 2 c d))))
+(assert (= [nil '(a b :c)] (get-options '(a b :c))))
+
+;; standard-metadata
+(defmacro test-macro [name docstring & body]
+  `(defn ~name ~(standard-metadata &form docstring name) [] ~@body))
+
+(test-macro test-var "hello" (+ 1 2))
+
+(let [m (meta (var test-var))]
+  (assert (= *ns* (:ns m)))
+  (assert (= 'test-var (:name m)))
+  (assert (= "hello" (:doc m)))
+  (assert (= '(test-macro test-var "hello" (+ 1 2)) (:form m)))
+  (assert (string? (:file m)))
+  (assert (integer? (:line m))))
+
+;; firsts
+(assert (= '[a b c] (firsts '[a 1 b 2 c 3])))
+
+;; seconds
+(assert (= '[1 2 3] (seconds '[a 1 b 2 c 3])))


redo recording tests

redo recording tests

error: pathspec 'test/com/billpiel/sayid/recording_test.clj' did not match any file(s) known to git

--- test/com/billpiel/sayid/recording_test.clj
+++ test/com/billpiel/sayid/recording_test.clj
@@ -0,0 +1,44 @@
+(ns com.billpiel.sayid.recording-test
+  (:require [clojure.test :as t]
+            [com.billpiel.sayid.recording :as r]
+            [com.billpiel.sayid.workspace :as w]
+            [com.billpiel.sayid.test-utils :as t-utils]))
+
+(t/deftest recording
+  (with-redefs [gensym (t-utils/mock-gensym-fn)]
+    (let [shelf '$rec
+          rec (atom (r/mk-recording []))
+          ws (w/default-workspace)]
+
+      (t/testing "save-as"
+        (t/is (= @(r/save-as! rec shelf 'test1)
+                 {:children []
+                  :depth 0
+                  :id :rec10
+                  :path [:rec10]
+                  :rec-slot '$rec/test1})))
+
+      (reset! rec {})
+
+      (t/testing "load - not forced, fails"
+        (t/is (thrown? Exception
+                       (r/load! rec shelf 'test1))))
+
+      (t/testing "load - forced"
+        (t/is (= (r/load! rec shelf 'test1 :f)
+                 {:children []
+                  :depth 0
+                  :id :rec10
+                  :path [:rec10]
+                  :rec-slot '$rec/test1})))
+
+      (t/testing "coerce & load"
+        (r/coerce&load! rec ws shelf)
+        (t/is (= @rec
+                 {:children []
+                  :depth 0
+                  :id :rec12
+                  :path [:rec12]
+                  :rec-slot nil})))
+
+      (remove-ns shelf))))


add consume tests

add consume tests

error: pathspec 'kafka-clj/test/kafka_clj/integration_v2_consume_tests.clj' did not match any file(s) known to git

--- kafka-clj/test/kafka_clj/integration_v2_consume_tests.clj
+++ kafka-clj/test/kafka_clj/integration_v2_consume_tests.clj
@@ -0,0 +1,61 @@
+(ns kafka-clj.integration-v2-consume-tests
+  (:require [kafka-clj.consumer.consumer :refer [publish-work consume! close-consumer!]]
+            [kafka-clj.consumer.work-organiser :refer [get-queue-data]]
+            [taoensso.carmine :as car :refer [wcar]]
+            [clojure.core.async :refer [alts!! chan timeout]]
+            [clojure.tools.logging :refer [info]]
+            [clojure.edn :as edn])
+  (:use midje.sweet))
+
+
+(def config (edn/read-string (slurp (str (System/getProperty "user.home") "/" ".integration/kafka-clj/conf.edn"))))
+
+(def bootstrap-brokers (:bootstrap-brokers config))
+(def topic (:topic config))
+(def redis-conf (:redis-conf config))
+
+
+;=========== Requirements ===========
+;===== This test requires a running kafka cluster and a redis server
+;===== It also requires a topic with name "ping" and it must have at least a 100 messages published
+;====================================
+
+(facts "Test Create Work Units and Consumer"
+
+  (fact "Test organiser and wait-and-do-work-unit!"
+
+        (let [ts (System/currentTimeMillis)
+              msgs 100
+              msg-ch (chan 1000)
+              consumer-conf {:redis-conf {:host "localhost" :max-active 5 :timeout 1000} :working-queue "working" :complete-queue "complete" :work-queue "work" :conf {}}
+              redis-conf (:redis-conf consumer-conf)
+              redis-conn {:pool {:max-active (get redis-conf :max-active 20)}
+                          :spec {:host  (get redis-conf :host "localhost")
+                                 :port    (get redis-conf :port 6379)
+                                 :password (get redis-conf :password)
+                                 :timeout  (get redis-conf :timeout 4000)}}
+              ]
+          ;we must close the complete processor
+          (car/wcar redis-conn
+                    (car/flushall))
+
+          (dotimes [i msgs]
+            (prn "publish " i)
+            (publish-work consumer-conf {:producer {:host "localhost" :port 9092} :topic "ping" :partition 0 :offset i :len 10}))
+
+          ;check that we have successfully published all messages to the work queue
+          (count (get-queue-data consumer-conf (:work-queue consumer-conf))) => msgs
+
+          (let [consumer (consume! (assoc consumer-conf :msg-ch msg-ch))]
+            (Thread/sleep 2000)
+            (dotimes [i msgs]
+              (let [[v ch] (alts!! [msg-ch (timeout 1000)])]
+                (prn "GOT VAL >>>>>>>>====== i " i " v = " v  " ch " ch)
+                (count v) => 1
+                ))
+            ;check that the queues are in a consistent state
+            (count (get-queue-data consumer-conf (:complete-queue consumer-conf))) => msgs
+            (count (get-queue-data consumer-conf (:work-queue consumer-conf))) => 0
+            (count (get-queue-data consumer-conf (:working-queue consumer-conf))) => 0
+
+            (close-consumer! consumer)))))


Start add liquid forecast diagram

Start add liquid forecast diagram

error: pathspec 'src/clj_simple_chart/ncs/liquidprodpp/liquid_pp_forecast.clj' did not match any file(s) known to git

--- src/clj_simple_chart/ncs/liquidprodpp/liquid_pp_forecast.clj
+++ src/clj_simple_chart/ncs/liquidprodpp/liquid_pp_forecast.clj
@@ -0,0 +1,206 @@
+(ns clj-simple-chart.ncs.liquidprodpp.liquid-pp-forecast
+  (:require [clj-simple-chart.core :as core]
+            [clj-simple-chart.opentype :as opentype]
+            [clj-simple-chart.axis.core :as axis]
+            [clj-simple-chart.chart :as chart]
+            [clj-simple-chart.ncs.liquidprodpp.liquidppdata :as production]
+            [clj-simple-chart.ncs.raw-production :refer [date-range]]
+            [clj-simple-chart.translate :refer [translate translate-y]]
+            [clj-simple-chart.rect :as rect]
+            [clj-simple-chart.point :as point]
+            [clj-simple-chart.area :as clj-area]
+            [clj-simple-chart.area-center-text :as act]
+            [clojure.string :as string]
+            [clojure.string :as str]
+            [clj-simple-chart.ncs.oilforecast.forecastdata :as forecastdata]))
+
+(def marg 10)
+(def two-marg (* 2 marg))
+
+(def svg-width 900)
+(def svg-height 500)
+
+(def data production/by-date)
+(def buckets (vec (reverse (sort (keys production/empty-buckets)))))
+
+;"#d62728",  //red
+;"#ff7f0e", //orange
+;"#8c564b", //brown
+;"#1f77b4", //blue
+;"#e377c2", //pink
+;"#17becf", //cyan
+;"#bcbd22", //gusjegul
+;"#9467bd", //purple
+;"#7f7f7f", //gray
+;"#2ca02c", //green
+
+(def bucket-to-fill (zipmap buckets
+                            (reverse [
+                                      "#e377c2"             ; pink
+                                      "#2ca02c"             ;green
+                                      "#9467bd"             ; purple
+                                      "#17becf"             ; cyan
+                                      "#1f77b4"             ; blue
+
+                                      "#8c564b"             ; brown
+                                      "#ff7f0e"             ; orange
+                                      "#d62728"             ; red
+                                      ;"#9467bd"                      ; purple
+                                      ])))
+
+(def sub-domain buckets)
+
+(def forecast (forecastdata/forecast-monthly forecastdata/current-forecast))
+
+(def x-domain (date-range (:date (first data)) "2025-12"))
+
+(def x-ticks (filter #(or (= % "1971-12")
+                          (.endsWith % "5-12")
+                          (.endsWith % "0-12"))
+                     x-domain))
+
+(def available-width (- svg-width (* 2 marg)))
+
+(def last-data (last data))
+
+(def months ["ignore"
+             "januar" "februar" "mars" "april" "mai"
+             "juni" "juli" "august" "september" "oktober" "november" "desember"])
+
+(defn months-str [v]
+  (let [parts (string/split v #"-0?")]
+    (str (nth months (read-string (last parts)))
+         " " (first parts))))
+
+(def feltmogning-ex-txt (str "Nedtappingsgrad: Prosent produsert av opprinneleg utvinnbart"
+                             ;(:prfYear (first data)) "–" (:prfYear (last data))
+
+                             ))
+
+(def header (opentype/stack
+              {:width available-width}
+              [{:text (str "Oljeproduksjon etter nedtappingsgrad")
+                :font "Roboto Bold" :font-size 30}
+               {:text (str "Produksjon per " (months-str (:date last-data)) ": "
+                           (string/replace (format "%.2f" (get last-data :sum)) "." ",")
+                           " millionar fat/dag")
+                :font "Roboto Bold" :font-size 16 :margin-top 1}
+               {:text feltmogning-ex-txt :font "Roboto Regular" :font-size 16 :margin-top 3}
+
+
+               {:text "Oljeproduksjon, millionar fat/dag" :font "Roboto Bold" :font-size 16 :valign :bottom :align :right}
+               {:text "12 månadar glidande gjennomsnitt" :margin-top 1 :font "Roboto Bold" :font-size 16 :valign :bottom :align :right}]))
+
+(def footer (opentype/stack
+              {:width available-width}
+              [{:margin-top 4 :text "Kjelde: Oljedirektoratet. \"Olje\" inkluderer råolje, kondensat og NGL." :font "Roboto Regular" :font-size 14}
+               {:text "Diagram © Refsdal.Ivar@gmail.com" :font "Roboto Regular" :font-size 14 :valign :bottom :align :right}]))
+
+(def xx {:type        :ordinal-linear
+         :tick-values x-ticks
+         :tick-format (fn [x] (subs x 0 4))
+         :orientation :bottom
+         :domain      x-domain
+         :sub-domain  buckets})
+
+(def yy {:type               :linear
+         :orientation        :right
+         :axis-text-style-fn (fn [x] {:font "Roboto Bold"})
+         :tick-format        (fn [x] (str/replace (format "%.1f" x) "." ","))
+         :domain             [0 3.5]})
+
+(def available-height (- svg-height (+ (+ 3 marg)
+                                       (:height (meta header))
+                                       (:height (meta footer)))))
+
+(def c (chart/chart {:width  available-width
+                     :height available-height
+                     :x      xx
+                     :y      yy}))
+
+(def x (:x c))
+(def y (:y c))
+
+(def yfn (partial point/center-point y))
+(def xfn (partial point/center-point x))
+
+(defn make-rect [opts]
+  (map (fn [[k fill]]
+         {:p                (:date opts)
+          :c                k
+          :stroke           "black"
+          :stroke-width-top 1.4
+          :fill             fill
+          :text
+                            {:fill      "white"
+                             :font      "Roboto Black"
+                             :font-size 15
+                             :text      (str/replace (format "%.1f" (double (get opts k 0)))
+                                                     "." ",")}
+          :h                (get opts k 0)})
+       bucket-to-fill))
+
+(def flat (vec (flatten (mapv make-rect data))))
+
+(def last-text (vec (flatten (make-rect (last data)))))
+
+
+(defn make-txt [{dato :date year :year :as opts}]
+  [:g {:transform (translate (xfn dato) (yfn (get opts :sum)))}
+   [:circle {:r 2.5}]
+   [:line {:stroke "black" :stroke-width 1 :fill "black" :y2 -8}]
+   (opentype/text {:dy "-.71em" :text-anchor "middle" :text (str "" (subs dato 0 4) "")})
+   (opentype/text {:dy          "-1.71em"
+                   :font        "Roboto Bold"
+                   :text-anchor "middle"
+                   :text        (string/replace (format "%.2f" (get opts :sum)) "." ",")})])
+
+(defn diagram []
+  [:svg {:xmlns "http://www.w3.org/2000/svg" :width svg-width :height svg-height}
+   [:g {:transform (translate marg marg)}
+    header
+    [:g {:transform (translate (:margin-left c) (+ (:height (meta header)) (:margin-top c)))}
+     (axis/render-axis (:y c))
+     (clj-area/area c flat)
+     #_(act/area-center-text c last-text)
+     [:g (map make-txt (filter #(some #{(:date %)}
+                                      [;"1971-12"
+                                       "1975-12"
+                                       "1980-12"
+                                       "1985-12"
+                                       "1990-12"
+                                       "1995-12"
+                                       ;"2000-12"
+                                       "2001-12"
+                                       "2005-12"
+                                       "2010-12"
+                                       "2013-12"
+                                       "2015-12"]) data))]
+     (axis/render-axis (:x c))]
+    (let [infotext (opentype/stack #_{:fill         "lightgray"
+                                      :fill-opacity 0.3
+                                      :margin       5}
+                     {}
+                     (flatten
+                       [{:text          "Nedtappingsgrad" :font "Roboto Black" :font-size 16
+                         :margin-bottom 2}
+                        (mapv (fn [k]
+                                {:text      (str (subs k 3) "%")
+                                 :font-size 16
+                                 :font      "Roboto Bold"
+                                 :rect      {:fill (get bucket-to-fill k)
+                                             :size nil}})
+                              (sort (keys production/empty-buckets)))
+                        #_{:text "Siste tall for kategori i kvitt" :font "Roboto Regular" :font-size 14}]))]
+      [:g {:transform (translate 0 #_(- (+ (:margin-left c) (:plot-width c))
+                                        (:width (meta infotext))
+                                        10)
+                                 (+ 0 (+ (:height (meta header)) (:margin-top c))))}
+       infotext
+       ]
+      )
+
+    [:g {:transform (translate-y (+ (:height (meta header)) available-height))} footer]]])
+
+(defn render-self []
+  (core/render "./img/ncs-svg/liquids-pp-forecast.svg" "./img/ncs-png/liquids-pp-forecast.png" (diagram)))


Simplify cors headers

Simplify cors headers

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/physion/ovation-webapi.git/'


Initial commit.

Initial commit.

--- project.clj
+++ project.clj
@@ -0,0 +1,7 @@
+(defproject com.lemonodor/syllables "0.1.2-SNAPSHOT"
+  :description "Clojure library for counting syllables in words."
+  :url "https://github.com/wiseman/clj-syllables"
+  :license {:name "MIT License"
+            :url "http://opensource.org/licenses/MIT"}
+  :deploy-repositories [["releases" :clojars]]
+  :dependencies [[org.clojure/clojure "1.6.0"]])


database namespace: import methods from core-utility and uri-utility

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/colophon/clarango.git/'


add support for url params in routes

add support for url params in routes

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/starcity-properties/odin.git/'


Silence Websocket error logs unless verbose is on

Fix #14

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/modnakasta/weasel.git/'


Remove HTML tags from fullmoobiesonyoutube messages

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/benzap/baconbot.git/'


Add variants

Add variants

error: pathspec 'src/detritus/variants.clj' did not match any file(s) known to git

--- src/detritus/variants.clj
+++ src/detritus/variants.clj
@@ -0,0 +1,24 @@
+(ns detritus.variants
+  (:require [detritus.update :refer [take-when]]))
+
+(defmacro defvariant
+  {:doc "Defines a variant constructor with a namespace qualified tag, and keyword named members."
+   :arglists '([name doc-string? attr-map? members])}
+  [vname & args]
+  (let [[?docstring args] (take-when string? "" args)
+        [?attr-map args]  (take-when map? {} args)
+        members           (first args)
+
+        ;; FIXME inline guards are a bad habit of mine
+        _                 (assert (vector? members) "Members is not a vector!")
+        _                 (assert (every? symbol? members) "Members may contain only symbols!")
+
+        kw-members        (map (comp keyword name) members)
+        kw-tag            (keyword (name (ns-name *ns*))
+                                   (name vname))
+        ?attr-map         (assoc ?attr-map
+                                 :variant true
+                                 :members kw-members
+                                 :tag kw-tag)]
+    `(defn ~vname ~?docstring ~?attr-map ~members
+       [~kw-tag (hash-map ~@(interleave kw-members members))])))


Added empty clojure file for site functions.

error: pathspec 'src/clj_formal_specifications_app/site.clj' did not match any file(s) known to git

--- src/clj_formal_specifications_app/site.clj
+++ src/clj_formal_specifications_app/site.clj
@@ -0,0 +1 @@
+(ns clj-formal-specifications-app.site)


more notes

more notes

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/michaelsbradleyjr/transwarp.git/'


don't need ' to indicate empty list

don't need ' to indicate empty list


Autocommit off!

Autocommit off!

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/couragelabs/crispy-tatertot.git/'


added cidernrepl init script

added cidernrepl init script

error: pathspec 'src/dj/init/cidernrepl.clj' did not match any file(s) known to git

--- src/dj/init/cidernrepl.clj
+++ src/dj/init/cidernrepl.clj
@@ -0,0 +1,15 @@
+(ns dj.init.cidernrepl)
+
+(require '[cemerick.pomegranate :as cp]
+         '[cemerick.pomegranate.aether :as a])
+
+(cp/add-dependencies
+ :coordinates '[[refactor-nrepl "2.3.1"]
+                [cider/cider-nrepl "0.14.0"]]
+ :repositories (merge a/maven-central
+                      {"clojars" "https://clojars.org/repo"}))
+
+(require '[clojure.tools.nrepl.server]
+         '[cider.nrepl])
+
+(clojure.tools.nrepl.server/start-server :port 9000 :handler cider.nrepl/cider-nrepl-handler)


Fix spelling.

Fix spelling.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/croeder/clojure-koans-work.git/'


Transduce maximum value to avoid intermediate collections.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/dignati/om-charts.git/'


Added a skeleton for a 2d branching generator in Clojure.

error: pathspec 'clojure/org/gavrog/clojure/branchings2d.clj' did not match any file(s) known to git

--- clojure/org/gavrog/clojure/branchings2d.clj
+++ clojure/org/gavrog/clojure/branchings2d.clj
@@ -0,0 +1,8 @@
+(ns org.gavrog.clojure.branchings
+  (:use (org.gavrog.clojure [generators :only [make-backtracker results]])))
+
+(defn branchings [d-set min-face-degree min-vert-degree min-curvature]
+  (make-backtracker
+    {:root []
+     :extract (fn [[]])
+     :children (fn [[]])}))