Finalized refactor for re-frame.

Finalized refactor for re-frame.

--- src-cljs/tea_time/core.cljs
+++ src-cljs/tea_time/core.cljs
@@ -64,7 +64,6 @@
 (re-frame/register-handler
   :process-teas-response
   (fn [app-db [_ response]]
-    (println response)
     (assoc-in app-db [:teas-list] response)))

 (re-frame/register-handler
@@ -90,7 +89,6 @@
               :error-handler (fn [response]
                                (println "DELETE-TEA ERROR" response))
               :handler (fn [response]
-                         (println tea-name " deleted.")
                          (re-frame/dispatch [:load-teas])))))

 (re-frame/register-handler
@@ -117,7 +115,7 @@
     (ajax/GET (str "/api/teas/" id "/update/" new-name)
               :error-handler (fn [response]
                                (println "UPDATE-TEA ERROR " response))
-              :handler (fn [response] (println response)))
+              :handler (fn [response] (re-frame/dispatch [:load-teas])))
     app-db))

@@ -130,16 +128,7 @@
 (re-frame/register-handler
   :initialize-db
   (fn [_ _]
-    {:teas-list []
-     :new-tea ""}))
-
-(defn new-tea-entered
-  [app-state [_ new-tea-input]]
-  (assoc-in app-state [:new-tea] new-tea-input))
-
-(re-frame/register-handler
-  :new-tea-entry
-  new-tea-entered)
+    {:teas-list []}))

 (re-frame/register-handler
   :replace-tea
@@ -160,14 +149,19 @@
   (fn [db]
     (reaction (:new-tea @db))))

-;; This fn needs to be put into re-frame handlers.
-
-(defn post-to-teas-db
-  "Sends an Ajax Request to the API route to post the tea from the form to the database"
-  [tea-name]
-  (ajax/POST "/api/newtea" {:params {:new-tea tea-name} :format :json}
-             :handler (fn [] (println "New Tea Posted"))
-             :error-handler (fn [err] (println "New Tea Failed To Post" err))))
+(re-frame/register-handler
+  :tea-posted
+  (fn [app-state]
+    (re-frame/dispatch [:load-teas])))
+
+(re-frame/register-handler
+  :create-tea
+  (fn [app-state [_ tea-name]]
+    (ajax/POST "/api/newtea" {:params {:new-tea tea-name}
+                              :format :json
+                              :handler #(re-frame/dispatch [:tea-posted])
+                              :error-handler (fn [err] (println "New Tea Failed To Post" err))})
+    app-state))

 (defn value-event
   [event]
@@ -196,8 +190,8 @@
                         (re-frame/dispatch [:delete-tea (:name tea)]))
             :style {:margin-right "10px"}}
            "Delete"]]]
-        [:tr
-         [:td.pull-left {:on-click #(swap! edit? not)} (:name tea)]]))))
+        [:tr {:on-click #(swap! edit? not)}
+         [:td.pull-left (:name tea)]]))))

 (defn tealister
   "The page component for listing tea"
@@ -217,19 +211,17 @@
 (defn tea-adder
   "A component for the tea-adder form"
   []
-  (let [tmp-new-tea (re-frame/subscribe [:new-tea])
-        test-atom (reagent/atom "Testing")]
+  (let [tmp-new-tea (reagent/atom "")]
     (fn []
-      (println @tmp-new-tea)
       [:div.row
        [:div.col-md-12
         [:input.form-control {:type "text"
                               :placeholder "Name of New Tea"
                               :value @tmp-new-tea
-                              :on-change #(re-frame/dispatch [:new-tea-entry (value-event %)])}]
-        [:input.btn.btn-primary {:type "button"
-                                 :value (str "Add " @tmp-new-tea)
-                                 :on-click #(println "button clicked")}]]])))
+                              :on-change #(reset! tmp-new-tea (value-event %))}]
+        [:button.btn.btn-primary.pull-right {:style {:margin-top "10px"}
+                                             :on-click #(re-frame/dispatch [:create-tea @tmp-new-tea]
+                                                                           (reset! tmp-new-tea ""))} (str "Add " @tmp-new-tea)]]])))

 (defn list-page []
   [:div.container


Use new resolve- fn for lookup.

Use new resolve- fn for lookup.

--- test/isla/test/interpreter.clj
+++ test/isla/test/interpreter.clj
@@ -21,7 +21,7 @@
 (deftest test-existing-obj-assignment-to-var
   (let [env (interpret (parse "isla is a person\nfriend is isla\nisla age is 1")
                        (library/get-initial-env extra-types))]
-    (is (= (lookup-ref "friend" env)
+    (is (= (resolve- {:ref "friend"} env)
            (new isla.test.interpreter.Person 1 "" :undefined)))))


WebSource : Web pages have their html tags removed, by default

--- src/hydrant/sources/web.clj
+++ src/hydrant/sources/web.clj
@@ -1,5 +1,6 @@
 (ns hydrant.sources.web
   (:require [itsy.core :as spider]
+            [itsy.extract :refer [html->str]]
             [hydrant.service :refer [Service]]
             [hydrant.core :refer [add-data-source events-to-flows]]
             [taoensso.timbre :as log]))
@@ -7,7 +8,7 @@

 (defn generate-event [root-url url body]
   {:timestamp (System/currentTimeMillis)
-   :sourceId root-url
+   :sourceId url
    :rootUrl root-url
    :eventName "web-crawl"
    :url url
@@ -19,9 +20,13 @@
   (let [event (generate-event root-url url body)]
     (events-to-flows (vector event))))

-(defn create-crawler [root-url url-limit]
+(defn create-crawler [root-url url-limit remove-tags]
   (spider/crawl {:url root-url
-                 :handler (fn [{:keys [url body]}] (crawler-fn root-url url body))
+                 :handler (fn [{:keys [url body]}]
+                            (if remove-tags
+                              (let [body (html->str body)]
+                                (crawler-fn root-url url body))
+                              (crawler-fn root-url url body)))
                  :workers 3
                  :url-limit url-limit
                  :url-extractor spider/extract-all
@@ -32,6 +37,7 @@

 (defrecord WebSource [^String root-url
                       ^Integer  url-limit
+                      remove-html-tags
                       crawler
                       running]

@@ -40,20 +46,20 @@
     (locking this
       (when-not @running
         (reset! running true)
-        (reset! crawler (create-crawler root-url url-limit))
-        (log/info "Started WebCrawlerSource"))))
+        (reset! crawler (create-crawler root-url url-limit remove-html-tags))
+        (log/info "Started WebSource, traversing " root-url))))

   (stop [this]
     (locking this
       (when @running
         (spider/stop-workers @crawler) ;;blocking call
         (reset! running false)
-        (log/info "Stopped WebCrawlerSource")))))
+        (log/info "Stopped WebSource, traversing " root-url)))))

 (defn web-source
-  [{:keys [ root-url page-crawl-limit]}]
-  (let [source (WebSource. root-url page-crawl-limit (atom nil) (atom nil))]
+  [{:keys [ root-url page-crawl-limit remove-html-tags] :or {remove-html-tags true}}]
+  (let [source (WebSource. root-url page-crawl-limit remove-html-tags (atom nil) (atom nil))]
     (add-data-source :web-source source)))

 (comment
@@ -63,7 +69,7 @@
       (println print-friendly)))

   (with-redefs [data-to-flows dtf]
-    (let [service (WebSource. "http://www.google.com" 50 (atom nil) (atom nil))]
+    (let [service (WebSource. "http://www.google.com" 50 true (atom nil) (atom nil))]
       (.start service)
       (Thread/sleep 30000) ;stay within this context (so that dtf function is used)
       (.stop service)))


Don't log to stdout if logging to Logentries

--- src/kinesis_logger/core.clj
+++ src/kinesis_logger/core.clj
@@ -11,18 +11,26 @@
                       :stream-name (env :stream-name)}
    :logentries-token (env :logentries-token)})

-(log/merge-config!
- (merge
+(def logging-config
   {:level      :info
    ;; reduce logging from the slf4j adapter to WARN
    :middleware [(fn min-level-for-ns [msg]
                   (when
                       (or (not= "slf4j-timbre.adapter" (:?ns-str msg))
                           (log/level>= (:level msg) :warn))
-                    msg))]}
-  (when (:logentries-token config)
-    {:appenders {:logentries (logentries-appender {:token (:logentries-token config)
-                                                   :output-fn raw-output})}})))
+                    msg))]
+
+   :timestamp-opts log/default-timestamp-opts
+
+   :output-fn log/default-output-fn
+
+   :appenders (if-let [token (:logentries-token config)]
+                {:logentries (logentries-appender
+                              {:token     token
+                               :output-fn raw-output})}
+                {:println (log/println-appender {:stream :auto})})})
+
+(log/set-config! logging-config)

 (defrecord Logger [config]
   kinesis/RecordProcessor
@@ -53,6 +61,7 @@
   (launch-worker! config))

 (comment
+  (require '[kinesis-logger.core :refer :all])
   (launch-worker! config)
   (future-cancel *logger-thread*)
   (.shutdown *worker*))


fix contains? attributes order

fix contains? attributes order

--- src/kixi/hecuba/webutil.clj
+++ src/kixi/hecuba/webutil.clj
@@ -40,7 +40,7 @@

 (defn update-stringified-lists [body [selector]]
   (if
-    (contains? selector body)
+    (contains? body selector)
     (update-in body [selector] json-list)
     (assoc body selector nil)))


Mark mock tweets as favorites

Mark mock tweets as favorites

--- tutorial.moan/src/tutorial/moan/lib.clj
+++ tutorial.moan/src/tutorial/moan/lib.clj
@@ -7,8 +7,10 @@
   [{:id 1
     :text "This is a fantastic tweet"
     :author {:name "Elon Musk"
-             :username "fakeelonmusk"}}
+             :username "fakeelonmusk"}
+    :favorite? true}
    {:id 2
     :text "Lord but I dislike poetry. How can anyone remember words that aren't put to music?"
     :author {:name "Arliden"
-             :username "arl_the_bard"}}])
+             :username "arl_the_bard"}
+    :favorite? true}])


Fix a typo in connector description

Fix a typo in connector description

--- src/lt/plugins/js/node.cljs
+++ src/lt/plugins/js/node.cljs
@@ -276,7 +276,7 @@
 (def nodejs-lang (object/create ::nodejs-lang))

 (scl/add-connector {:name "NodeJS"
-                    :desc "Start a nodejs procss by picking a .js file to run"
+                    :desc "Start a nodejs process by picking a .js file to run"
                     :connect (fn []
                                (dialogs/file nodejs-lang :connect!))})


Add `static` tests

Add `static` tests

--- test/io/perun_test.clj
+++ test/io/perun_test.clj
@@ -139,6 +139,10 @@
   [data]
   (str "" (:content (:entry data)) ""))

+(defn render-static
+  [data]
+  "
static
")
+
 (deftesttask default-tests []
   (comp (add-txt-file :path "2017-01-01-test.md" :content md-content)
         (boot/with-pre-wrap fileset
@@ -217,6 +221,11 @@
         (testing "atom-feed"
           (file-exists? :path "public/atom.xml"
                         :msg "`atom-feed` should write atom.xml"))
+
+        (p/static :renderer 'io.perun-test/render-static)
+        (testing "static"
+          (content-check :path "public/index.html"
+                         :content "
static
"))

         (p/render :renderer 'io.perun-test/render)

@@ -343,6 +352,16 @@
           (file-exists? :path "foo/test-atom.xml"
                         :msg "`atom-feed` should write test-atom.xml"))

+        (p/static :renderer 'io.perun-test/render-static
+                  :out-dir "laphroiag"
+                  :page "neat.html"
+                  :meta {:statique "affirmative"})
+        (testing "static"
+          (content-check :path "laphroiag/neat.html"
+                         :content "
static
")
+          (value-check :path "laphroiag/neat.html"
+                       :value-fn #(meta= %1 %2 :statique "affirmative")))
+
         (p/render :renderer 'io.perun-test/render
                   :filterer :markdown-set
                   :extensions [".htm"]


[#1152] Exclude postgres jar

[#1152] Exclude postgres jar

--- backend/project.clj
+++ backend/project.clj
@@ -38,7 +38,7 @@
                  [ring/ring-defaults "0.3.1"]
                  [ring/ring-json "0.4.0"]
                  [selmer "1.11.1"]
-                 [net.postgis/postgis-jdbc "2.2.1"]]
+                 [net.postgis/postgis-jdbc "2.2.1" :exclusions [org.postgresql/postgresql]]
   :uberjar-name "akvo-lumen.jar"
   :repl-options {:timeout 120000}
   ;; :pedantic? :abort


Update PAMELA version in clj.clj

Update PAMELA version in clj.clj

Signed-off-by: Tom Marble <b248307e886b80bf9cb4014595572a835b049bf4@info9.net>

--- src/main/clj/pamela/cli.clj
+++ src/main/clj/pamela/cli.clj
@@ -242,7 +242,7 @@
 (defn pamela
   "PAMELA command line processor. (see usage for help)."
   {:added "0.2.0"
-   :version "0.2.2-SNAPSHOT"}
+   :version "0.2.3-SNAPSHOT"}
   [& args]
   (when (and (:pamela-version env)
           (not= (:pamela-version env) (:version (meta #'pamela))))


Fix recent colors.

Fix recent colors.

--- src/uxbox/ui/workspace/options.cljs
+++ src/uxbox/ui/workspace/options.cljs
@@ -143,7 +143,7 @@
               (rs/emit! (dw/update-fill-attrs sid value))))
           (on-color-change [event]
             (let [value (dom/event->value event)]
-              (change-fill {:fill value})))
+              (change-fill {:color value})))
           (on-opacity-change [event]
             (let [value (dom/event->value event)
                   value (parse-float value 1)]
@@ -164,7 +164,7 @@
           :value (:fill shape "")
           :on-change on-color-change}]]

-       (recent-colors shape #(change-fill {:fill %}))
+       (recent-colors shape #(change-fill {:color %}))

        ;; SLIDEBAR FOR ROTATION AND OPACITY
        [:span "Opacity"]


more work on generating on grammar and lexical subsets

--- src/babel/italiano/lab.cljc
+++ src/babel/italiano/lab.cljc
@@ -366,22 +366,21 @@
   (let [verb-set #{"arrabbiarsi" "fermarsi" "parlare" "sedersi"}
         grammar
         (filter
-         #(contains? verbcoach-grammar (u/get-in % [:rule]))
+         #(contains? present-perfect-grammar (u/get-in % [:rule]))
          (:grammar model))
         spec {:root {:italiano {:italiano "arrabbiarsi"}}
+              :modified false
               :synsem {:cat :verb
-                       :modified false
-                       :sem {:tense :past
-                             :aspect :progressive}
+                       :essere true
+                       :sem {:tense :present
+                             :aspect :perfect}
                        :subcat []}}
         index-fn (create-index-fn verb-set grammar)]
-    (repeatedly
-     #(println
-       (morph (binding [babel.generate/println? false
-                        babel.generate/truncate? true
-                        babel.generate/grammar grammar
-                        babel.generate/index-fn index-fn]
-                (time (generate spec model))))))))
+    (binding [babel.generate/println? true
+              babel.generate/truncate? false
+              babel.generate/grammar grammar
+              babel.generate/index-fn index-fn]
+      (time (generate spec model)))))

 ;; this is a lot like a lexical compilation default map.
 (def rule-matcher
@@ -413,12 +412,10 @@
               (get rule-matcher key-in-rule-matcher))))
         (keys rule-matcher))))

-(defn generate-for-verbcoach
+(defn generate-arrabbiarsi
   "generate sentences efficiently given specific constraints."
   []
-  (let [verb-set #{"arrabbiarsi" "chiamarsi"
-                   "fermarsi"    "parlare"
-                   "sedersi"     "vedere"}
+  (let [verb-set #{"arrabbiarsi"}
         specs
         (map (fn [root]
                {:root {:italiano {:italiano root}}})
@@ -426,39 +423,109 @@
         tense-specs [{:synsem {:cat :verb
                                :sem {:tense :present
                                      :aspect :perfect}
-                               :subcat []}}
-                     {:synsem {:cat :verb
-                               :sem {:tense :future}
-                               :subcat []}}
-                     {:synsem {:cat :verb
+                               :subcat []}}]]
+                                        ;                     {:synsem {:cat :verb
+                                        ;                               :sem {:tense :future}
+                                        ;                               :subcat []}}]]
+                                        ;                     {:synsem {:cat :verb
+                                        ;                               :sem {:tense :present
+                                        ;                                     :aspect :simple}}]]
+
+    (let [chosen-spec
+          (unify (first (shuffle specs))
+                 (first (shuffle tense-specs)))]
+      (let [generate-with-grammar-set
+            (rule-matcher-reducer chosen-spec)
+            grammar
+            (filter (fn [rule-structure]
+                      (contains? generate-with-grammar-set
+                                 (u/get-in rule-structure [:rule])))
+                    (:grammar model))]
+        (println (str "grammar-set for spec:" (strip-refs chosen-spec) ":" generate-with-grammar-set))
+        (binding [babel.generate/println? true
+                  babel.generate/truncate? false
+                  babel.generate/index-fn (create-index-fn verb-set grammar)
+                  babel.generate/grammar grammar]
+          (time (generate chosen-spec model)))))))
+
+(defn generate-for-verbcoach
+  "generate sentences efficiently given specific constraints."
+  []
+  (let [verb-set #{"arrabbiarsi"}
+
+        specs
+        (map (fn [root]
+               {:root {:italiano {:italiano root}}})
+             verb-set)
+        tense-specs [{:synsem {:cat :verb
                                :sem {:tense :present
-                                     :aspect :simple}}}]]
+                                     :aspect :perfect}
+                               :subcat []}}]]
+                                        ;                     {:synsem {:cat :verb
+                                        ;                               :sem {:tense :future}
+                                        ;                               :subcat []}}]]
+                                        ;                     {:synsem {:cat :verb
+                                        ;                               :sem {:tense :present
+                                        ;                                     :aspect :simple}}]]
+
     (repeatedly
-     #(do (println "")
-          (println
-           (let [chosen-spec
-                 (unify (first (shuffle specs))
-                        (first (shuffle tense-specs)))]
-             (let [generate-with-grammar-set
-                   (rule-matcher-reducer chosen-spec)
-                   grammar
-                   (filter (fn [rule-structure]
-                             (contains? generate-with-grammar-set
-                                        (u/get-in rule-structure [:rule])))
-                           (:grammar model))]
-               ;;               (println (str "grammar-set for spec:" (strip-refs chosen-spec) ":" generate-with-grammar-set))
-               (morph (binding [babel.generate/println? false
-                                babel.generate/truncate? false
-                                babel.generate/index-fn (create-index-fn verb-set grammar)
-                                babel.generate/grammar grammar]
-                        (time (generate chosen-spec model)))))))))))
-
+     #(do ;;(println "")
+        (println
+         (let [chosen-spec
+               (unify (first (shuffle specs))
+                      (first (shuffle tense-specs)))]
+           (let [generate-with-grammar-set
+                 (rule-matcher-reducer chosen-spec)
+                 grammar
+                 (filter (fn [rule-structure]
+                           (contains? generate-with-grammar-set
+                                      (u/get-in rule-structure [:rule])))
+                         (:grammar model))]
+             (println (str "grammar-set for spec:" (strip-refs chosen-spec) ":" generate-with-grammar-set))
+             (morph-ps (binding [babel.generate/println? false
+                                 babel.generate/truncate? false
+                                 babel.generate/index-fn (create-index-fn verb-set grammar)
+                                 babel.generate/grammar grammar]
+                         (time (generate chosen-spec model)))))))))))
+
+(def verbcoach-pronouns
+  (fn [v]
+    (or
+     (and (= :noun (u/get-in v [:synsem :cat]))
+          (not (= :acc (u/get-in v [:synsem :case]))))
+     (and (= :noun (u/get-in v [:synsem :cat]))
+          (= :acc (u/get-in v [:synsem :case]))
+          (= true (u/get-in v [:synsem :reflexive]))))))
+
+(def
+  verbcoach-index-paths
+  [[:italiano :italiano]
+   [:synsem :aux]
+   [:synsem :cat]
+   [:synsem :essere]
+   [:synsem :infl]
+   [:synsem :sem :pred]])
+
+(def verbcoach-index-fn
+  (fn [spec]
+    (let [lexicon
+          (into {}
+                (for [[k vals] (:lexicon model)]
+                  (let [filtered-vals
+                        (filter verbcoach-pronouns
+                                vals)]
+                    (if (not (empty? filtered-vals))
+                      [k filtered-vals]))))]
+      (lookup-spec spec (create-indices lexicon verbcoach-index-paths)
+                   verbcoach-index-paths))))
+
+
 (defn stampare
-  "generate arrabiarsi sentences with a grammar subset."
+  "generate 'stampare' sentences with a grammar subset."
   []
   (let [grammar
         (filter
-         #(contains? verbcoach-grammar (u/get-in % [:rule]))
+         #(contains? present-grammar (u/get-in % [:rule]))
          (:grammar model))
         spec {:root {:italiano {:italiano "stampare"}}
               :synsem {:cat :verb


fix bot db fns

fix bot db fns

--- src/braid/server/db/bot.clj
+++ src/braid/server/db/bot.clj
@@ -53,16 +53,18 @@
 (defn bot-watch-thread!
   [conn bot-id thread-id]
   ; need to verify that thread is in bot's group
-  @(d/transact [[:db/add [:bot/id bot-id]
-                 :bot/watched [:thread/id thread-id]]]))
+  @(d/transact conn
+     [[:db/add [:bot/id bot-id]
+       :bot/watched [:thread/id thread-id]]]))

 (defn bots-watching-thread
   [conn thread-id]
-  (->> (d/q '[:find (pull ?b pull-pattern)
-              :in $ pull-pattern ?thread-id
-              :where
-              [?t :thread/id ?thread-id]
-              [?b :bot/watched ?t]
-              [?t :thread/group ?g]
-              [?b :bot/group ?g]])
+  (some->> (d/q '[:find [(pull ?b pull-pattern) ...]
+                  :in $ pull-pattern ?thread-id
+                  :where
+                  [?t :thread/id ?thread-id]
+                  [?b :bot/watched ?t]
+                  [?t :thread/group ?g]
+                  [?b :bot/group ?g]]
+                (d/db conn) bot-pull-pattern thread-id)
        (into #{} (map db->bot))))


Allow a :dont-test in namespace metadata as well

--- src/cake/tasks/coverage.clj
+++ src/cake/tasks/coverage.clj
@@ -18,12 +18,14 @@
           (:source-path *project*)))

 (defn testable-symbols [namespaces]
-  (bake (:use [useful.debug :only [?]])
-    [namespaces namespaces]
-    (for [n namespaces
-          [sym var] (ns-publics (find-ns (doto n require)))
-          :when (and (bound? var) (fn? @var) (not (-> var meta :dont-test)))]
-      (apply symbol (map str [n sym])))))
+  (bake [namespaces namespaces]
+    (letfn [(test? [var] (not (-> var meta :dont-test)))]
+      (for [n namespaces
+            :let [n (find-ns (doto n require))]
+            :when (test? n)
+            [sym var] (ns-publics n)
+            :when (and (bound? var) (fn? @var) (test? var))]
+        (apply symbol (map str [n sym]))))))

 (defn clj-test-files []
   (apply concat (map (comp find-clojure-sources-in-dir file)


remove logging statement

remove logging statement

--- src/clj/flambo/function.clj
+++ src/clj/flambo/function.clj
@@ -69,7 +69,6 @@

 (defn PairFlatMapFunction-call [this x]
   (let [ret (-call this x)]
-    (log/debug ret)
     (for [v ret
           :let [[a b] v]]
       (Tuple2. a b))))


Add ability to clear a specific turn flag.

--- src/clj/game/core-flags.clj
+++ src/clj/game/core-flags.clj
@@ -69,6 +69,12 @@

 (defn clear-turn-register! [state]
   (swap! state assoc-in [:stack :current-turn] nil))
+
+(defn clear-turn-flag!
+  "Remove any entry associated with card for the given flag"
+  [state side card flag]
+  (swap! state update-in [:stack :current-turn flag]
+         #(remove (fn [map] (= (:cid (map :card)) (:cid %2))) %1) card))

 (defn register-persistent-flag!
   "A flag that persists until cleared."


Include a newline at the end of JSON responses.

--- src/clj/shale/resources.clj
+++ src/clj/shale/resources.clj
@@ -31,8 +31,9 @@
             m))

 (defn jsonify [m]
-  (json/generate-string
-    (json-keys m)))
+  (-> (json-keys m)
+      json/generate-string
+      (str "\n")))

 (defn is-json-content? [context]
   (if (#{:put :post} (get-in context [:request :request-method]))


Re-enable caching of Stencil templates

Re-enable caching of Stencil templates

--- src/clj/sparqlab/sparql.clj
+++ src/clj/sparqlab/sparql.clj
@@ -46,9 +46,6 @@
               (.equals other n2)))
           (.equals n1 n2))))))

-; Disable Stencil's caching for testing
-(set-cache (clojure.core.cache/ttl-cache-factory {} :ttl 0))
-
 (derive ::describe ::construct)

 ; ----- Private functions -----


Change the default to easy

Change the default to easy

--- src/cljs/db_quiz/state.cljs
+++ src/cljs/db_quiz/state.cljs
@@ -13,12 +13,12 @@
          :on-turn (rand-nth [:player-1 :player-2])
          :options {:data-source :dbpedia
                    :despoilerify? true
-                   :difficulty :normal
+                   :difficulty :easy
                    :doc ""
                    :labels :numeric
                    :selectors #{:persons
                                 :places
-                                :works}
+                                :films}
                    :share-url ""}
          :players {:player-1 "Dmitrij"
                    :player-2 "Paní M."}


updater changes

updater changes

--- src/cljs/smgui/updater.cljs
+++ src/cljs/smgui/updater.cljs
@@ -30,6 +30,11 @@
   (-> (nw-updater. manifest)
       (lift-instance :checkNewVersion :download :unpack :install)))

+(defn updater-unpack [updater filename manifest]
+  (let [c (chan)]
+    (.unpack updater filename (node/node-callback c) manifest)
+    c))
+
 (defn call-async [instance method & args]
   (let [c (chan)
         args (conj (vec args) (node/node-callback c))
@@ -56,7 +61,7 @@
               (let [_ (.log js/console "Found update, downloading")
                     filename (<? (.download updater))
                     _ (.log js/console "Downloaded, unpacking" filename)
-                    new-app-path (<? (.unpack updater filename))
+                    new-app-path (<? (updater-unpack updater filename manifest))
                     _ (.log js/console "Unpacked, running updater")]
                 (.runInstaller updater
                                new-app-path


Updating the scores

Updating the scores

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -57,6 +57,7 @@
    ;; From the turn you can deduce the number of turn left
    ;; There is an invariant holding: total score = 12 * 3 + turn
    ;; TODO - Enhance the display to show the available moves (compute them once)
+   :player (rand-nth players)
    :scores
    {:blue 12
     :red 12
@@ -137,16 +138,20 @@
     :green :blue))

 (defn- apply-move
-  [board {:keys [winner taken] :as move}]
-  (reduce #(assoc-in %1 %2 winner) board taken))
+  [game {:keys [winner looser taken] :as move}]
+  (-> game
+    (assoc :board (reduce #(assoc-in %1 %2 winner) (:board game) taken))
+    (update-in [:scores winner] + (count taken))
+    (update-in [:scores looser] - (count taken))
+    ))

 (defn play-move
   "On player playing the move [x y]" ;; TODO - Handle the scores
-  [board [x y] player]
-  (let [moves (get (available-moves-at board [x y]) player nil)]
+  [{:keys [player board] :as game} [x y]]
+  (let [moves (get (available-moves-at board [x y]) player)]
     (if moves
-      (reduce apply-move (assoc-in board [x y] player) moves)
-      board)))
+      (reduce apply-move (assoc-in game [:board x y] player) moves)
+      game)))

 ;; -----------------------------------------
@@ -180,7 +185,7 @@
     {:on-click
      (fn []
        (prn [x y])
-       (swap! board play-move [x y] :blue))
+       (swap! app-state play-move [x y]))
      }))

 (defn greeting []


update

update

--- src/clojure_fabric/user.clj
+++ src/clojure_fabric/user.clj
@@ -16,7 +16,8 @@

 (defonce ^:dynamic *user* nil)

-(defrecord User [name roles certificate])
+(defrecord Enrollment [private-key certificate])
+(defrecord User [name roles enrollment])

 (defn %make-user [m]
   (map->User m))
@@ -53,7 +54,7 @@
   ([]
    (get-enrollment-certificate *user*))
   ([user]
-   (:certificate user)))
+   (get-in user [:enrollment :certificate])))

 ;;; set_name
 ;;; Immutable


Minor documentation improvements.

Minor documentation improvements.

--- diceware-clj/src/diceware/core.clj
+++ diceware-clj/src/diceware/core.clj
@@ -6,12 +6,12 @@
   (:gen-class))

 (defn one-roll
-  "return one random die roll"
+  "return an int from a roll of a single die"
   []
   (inc (securerandom/rand-int 6)))

 (defn five-rolls
-  "return a keyword formed from five random die rolls, such as :12346"
+  "return a keyword formed from a roll of five dice, such as :12346"
   []
   (->> (repeatedly 5 one-roll) ; e.g, => (1 2 3 4 6)
        (apply str)             ; e.g, => "12346"


Add new entry into table at the correct posistion.

--- src/clojure/my/stuff/fitlogger/main.clj
+++ src/clojure/my/stuff/fitlogger/main.clj
@@ -5,12 +5,13 @@
               [neko.resource :as res]
               [neko.find-view :refer [find-view]]
               [neko.threading :refer [on-ui]]
-              [neko.ui :refer [config]]
+              [neko.ui :refer [config make-ui]]
               [neko.ui.mapping :refer [defelement]]
               [clojure.string :refer [join split-lines split]]
               [clojure.java.io :as io]
               [my.stuff.fitlogger.sebas :as seb])
     (:import (android.widget EditText TextView)
+             (android.view ViewGroup)
              (java.util Calendar)
              (java.io File)
              (android.app Activity)
@@ -60,7 +61,7 @@
               m)))

 (defn format-listing [lst]
-  (apply conj [:table-layout {}]
+  (apply conj [:table-layout {:id :table}]
          (map (fn [[_ measurements]]
                 (format-measurements measurements))
               lst)))
@@ -87,20 +88,29 @@

 (defn csv->listing [entries]
   (reduce (fn [l e] (csv-list->entry l (split e #",")))
-          (sorted-map)
+          (sorted-map-by >)
           entries))

 (def listing (atom (sorted-map-by >)))

-(defn update-ui [activity]
-;  (set-elmt activity :listing (format-listing @listing))
+(defn index-of-key [key map]
+  (count (take-while #(not= key %) (keys map))))
+
+(defn update-table [activity key m]
+  (let [idx (index-of-key key m)
+        row (format-measurements (m key))]
+    (on-ui (.addView (find-view activity :table) (make-ui (*a) row) idx))
+    row))
+
+(defn update-ui [activity date-key]
+  (update-table activity date-key @listing)
   (set-elmt activity :weight "")
   (set-elmt activity :bf "")
   (set-elmt activity :water "")
   (set-elmt activity :muscle ""))

-(def logfile "log3.csv")
+(def logfile "log5.csv")

 (defn write-logfile [activity t]
   (let [file (File. (.getFilesDir activity) logfile)]
@@ -130,7 +140,7 @@
                       %
                       [:date :weight :bf :water :muscle]))
       (write-logfile activity (listing->csv @listing))
-      (update-ui activity))))
+      (update-ui activity date-key))))

 (defn date-picker [activity]
   (proxy [DialogFragment DatePickerDialog$OnDateSetListener] []


Caught a bug while building Ruby version

--- src/computer_build/vhdl.clj
+++ src/computer_build/vhdl.clj
@@ -70,7 +70,8 @@
 (defmethod to-vhdl :if [[type condition & body]]
   (list
     (spaces "if" (to-vhdl condition) "then")
-    (map to-vhdl body)))
+    (map to-vhdl body)
+    "end if;"))

 (defmethod to-vhdl :and [[type condA condB]]
   (spaces (to-vhdl condA) "and" (to-vhdl condB)))


add more comment about thinking about maybe monad

--- src/monad/clojure/monad.clj
+++ src/monad/clojure/monad.clj
@@ -279,7 +279,7 @@
 ;;make youself a do notation

 (def list-m {:return (fn [v] (list v))
-             :>>=   (fn [mv f]
+             :>>=    (fn [mv f]
                        (mapcat f mv))})

 (let [bind (:>>= list-m)
@@ -295,10 +295,10 @@
   (if (seq bindings)
     `(-> ~val
          ((:>>= ~m) (fn [~name]
-                       ~(m-steps m (vec bindings) body))))
+                      ~(m-steps m (vec bindings) body))))
     `(-> ~val
          ((:>>= ~m) (fn [~name]
-                       ((:return ~m) ~body))))))
+                      ((:return ~m) ~body))))))

 (defmacro do-m [m bindings body]
   (m-steps m bindings body))
@@ -326,7 +326,7 @@
 ;;(add 1 nil)                                                 ;;CompilerException java.lang.NullPointerException

 (def monad-maybe {:return (fn [v] v)
-                  :>>=   (fn [mv f]
+                  :>>=    (fn [mv f]
                             (when mv
                               (f mv)))})

@@ -335,5 +335,22 @@
                      b mb]
         (+ a b)))

+(macroexpand '(do-m monad-maybe [a ma
+                                 b mb]
+                    (+ a b)))
+
+((:>>= monad-maybe)
+  ma
+  (clojure.core/fn [a]
+    (clojure.core/->
+      mb
+      ((:>>= monad-maybe)
+        (clojure.core/fn [b]
+          ((:return monad-maybe) (+ a b)))))))
+
 (m-add 1 2)
-(m-add 1 nil)+(m-add 1 nil)
+
+;;可以看到maybe monad可以进行类似控制流切换的作用 也就是某一个值是nil的时候直接做类似break的操作 也就是返回了不再去做后面的所有操作了
+;;使用maybe monad的好处就是我们可以不再使用类似continuation这样晦涩的技术 而是利用monad来做控制流的切换 来对复杂的逻辑做判断逻辑的封装
+;;从上面的宏扩展结果就可以看到加入ma是nil 那么就不会再继续进行计算了 直接返回了nil 如果不是 那就把ma传入给后续的单参函数 cps风格的computation


Two tests for function -main

Two tests for function -main

--- test/hurvinek/core_test.clj
+++ test/hurvinek/core_test.clj
@@ -141,3 +141,26 @@
                    "  -p, --port   PORT  port number\n"
                    "  -h, --help         show this help\n"))))))

+(deftest test-main-1
+    (testing "hurvinek.core/-main"
+        (are [x y] (= x y)
+           (with-out-str (-main "-h"))
+           (str
+           "{:display {:app-name \"Hurvinek\"}, :server {:url-prefix \"/\"}}\n"
+           "Usage:\n"
+           "  -p, --port   PORT  port number\n"
+           "  -h, --help         show this help\n")
+           (with-out-str (-main "--help"))
+           (str
+           "{:display {:app-name \"Hurvinek\"}, :server {:url-prefix \"/\"}}\n"
+           "Usage:\n"
+           "  -p, --port   PORT  port number\n"
+           "  -h, --help         show this help\n"))))
+
+(deftest test-main-2
+    (testing "hurvinek.core/-main"
+        ; use mock instead of jetty/run-jetty
+        (with-redefs [jetty/run-jetty (fn [app port] app)]
+        ; use mock instead of jetty/run-jetty
+        (is (= app (-main))))))
+


Add github banner.

Add github banner.

--- aviary-www/src/main/clj/aviary_www/markup.clj
+++ aviary-www/src/main/clj/aviary_www/markup.clj
@@ -5,6 +5,7 @@

 (def defaults
   {:title "Aviary"
+   :url "https://github.com/wkf/aviary"
    :styles ["css/out/screen.css"
             "//fonts.googleapis.com/css?family=Raleway:500"
             "//fonts.googleapis.com/css?family=Crimson+Text"
@@ -49,7 +50,7 @@
        [:h1]]
       [:main]]])

-  [{:keys [title scripts requires styles]} content]
+  [{:keys [title url scripts requires styles]} content]

   [:title] (html/content title)
   [:head] (html/prepend
@@ -60,6 +61,7 @@
               #(html [:script {:type "text/javascript" :src %}]) scripts)
             (map
               #(html [:script {:type "text/javascript"} (str "goog.require('" % "')")]) requires))
+  [:a (html/has [:img.ribbon])] (html/set-attr :href url)
   [:header :h1] (html/content title)
   [:main] (html/content content))


spreadsheet example: removed bug in formula initialization; cell points in root of the state now, not in :cells sub-tree.

--- examples/examples/spreadsheet.cljs
+++ examples/examples/spreadsheet.cljs
@@ -8,15 +8,17 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Helpers

+(declare read-formula)
+
 (defn- formula? [s]
   (string? (first (re-matches #"^=.*" s))))

 (defn- write-formula [s state]
-  (let [formula (get-in state [:cells (:focus state) :formula])]
+  (let [formula (get-in state [(:focus state) :formula])]
     (str formula " " s)))

 (defn- cell-value [xy state]
-  (let [cell (get-in state [:cells xy])]
+  (let [cell (state xy)]
     (if (:formula cell)
       (read-formula (:formula cell) state)
       (:value cell))))
@@ -27,7 +29,7 @@
 (def ops {"/" / "*" * "+" + "-" -})

 (defn resolve-var [xy env]
-  (get-in env [:cells xy :value]))
+  (get-in env [xy :value]))

 (defn string->token [s env]
   (or (ops s)
@@ -63,16 +65,15 @@
   (match message

     [[:display xy] :click _]
-    (if (= (:mode state) :formula)
-
+    (case (:mode state)
+
+      :formula
       (let [formula (write-formula xy state)]
         [[(source-mode xy)
           (display-mode (:source state))
           [[:edit (:focus state)] :value formula]]
-         (assoc state
-           (:focus state)
-           formula :source xy)])
-
+         (assoc state :source xy (:focus state) {:formula formula})])
+
       [[(edit-mode xy)
         (display-mode (:edit state))]
        (assoc state :edit xy)])
@@ -81,19 +82,18 @@
     [[] (assoc state :focus xy)]

     [[:edit xy] :focus? false]
-    (if (= (:mode state) :formula)
-      [[] state]
+    (case (:mode state)
+
+      :formula [[] state]
+
       [[(display-mode xy)
         [[:display xy] :value (cell-value (:focus state) state)]]
        (assoc state :mode :done)])

     [[:edit xy] :value v]
     (if (formula? v)
-      [[(formula-mode xy)]
-       (-> (assoc state :mode :formula)
-           (assoc-in [:cells xy :formula] v))]
-      [[] (-> (assoc state :mode :value)
-              (assoc-in [:cells xy :value] v))])
+      [[(formula-mode xy)] (assoc state :mode :formula xy {:formula v})]
+      [[]                  (assoc state :mode :value   xy {:value   v})])

     [[:edit xy] :key-down 13]
     [[(display-mode xy)


only show pennies if we have to

only show pennies if we have to

--- src-cljs/frontend/components/plan.cljs
+++ src-cljs/frontend/components/plan.cljs
@@ -121,10 +121,16 @@
             (for [{:keys [cust instant added?]} (reverse history)]
               [:div (str cust (if added? " was marked active at " " was marked inactive at ") instant)])]))))))

-(defn format-stripe-cents [cents]
+(defn format-stripe-cents
+  "Formats Stripe's currency values into ordinary dollar format
+   500 -> $5
+   489 -> $4.89"
+  [cents]
   (let [pennies (mod cents 100)
         dollars (/ (- cents pennies) 100)]
-    (gstring/format "$%d.%02d" dollars pennies)))
+    (when (pos? pennies)
+      (gstring/format "$%d.%02d" dollars pennies)
+      (gstring/format "$%d" dollars))))

 (defn invoice-component [{:keys [invoice-id]} owner]
   (reify


Render 'Document Date' as 'Date'.

Render 'Document Date' as 'Date'.

--- src-cljs/pepa/components/document.cljs
+++ src-cljs/pepa/components/document.cljs
@@ -15,7 +15,13 @@
   (:require-macros [cljs.core.async.macros :refer [go go-loop]])
   (:import [goog.i18n DateTimeFormat DateTimeParse]))

-(defmulti meta-value (fn [[kw val] owner opts] kw))
+(defmulti meta-title (fn [[prop val] owner opts] prop))
+(defmulti meta-value (fn [[prop val] owner opts] prop))
+
+(ui/defcomponentmethod meta-title :default [[prop _] _ _]
+  (render [_]
+    [:span.title {:key "title"}
+     (s/capitalize (name prop))]))

 (ui/defcomponentmethod meta-value :default [[key value] _ _]
   (render [_]
@@ -74,6 +80,10 @@
     (when date
       (.format formatter date))))

+(ui/defcomponentmethod meta-title :document-date [_ _ _]
+  (render [_]
+    [:span.title {:key "title"} "Date"]))
+
 (ui/defcomponentmethod meta-value :document-date [[_ date] owner _]
   (init-state [_]
     {:editing? false
@@ -103,25 +113,23 @@

 (ui/defcomponent multi-meta-item [prop owner _]
   (render [_]
-    (let [name (name prop)
-          title (s/capitalize name)]
+    (let [name (name prop)]
       [:li {:class name, :key name}
-       [:span.title {:key "title"} title]
+       (om/build meta-title [prop "Multiple"])
        (om/build meta-value [:default "Multiple"])])))

 (ui/defcomponent meta-item [[prop value] owner _]
   (render-state [_ state]
-    (let [name (name prop)
-          title (s/capitalize name)]
+    (let [name (name prop)]
       [:li {:class name, :key name}
-       [:span.title {:key "title"} title]
+       (om/build meta-title [prop value])
        (om/build meta-value [prop value]
                  {:state state})])))

 ;;; TODO: Support mass-edit here
 (defn ^:private property-changed! [document property value]
   (assert (contains? #{:title :document-date} property))
-  (println "Updating property" property "on document" (:id @document))
+  (println "Updating property" property "on document" (:id @document) (str "[" (pr-str value) "]"))
   (api/update-document! (assoc @document property value)))

 (ui/defcomponent meta-table [documents]


[#455] WIP Use Keycloak client service account for API calls

--- backend/src/akvo/lumen/component/keycloak.clj
+++ backend/src/akvo/lumen/component/keycloak.clj
@@ -28,11 +28,27 @@
   (-> (client/get (format "%s/.well-known/openid-configuration" issuer))
       :body json/decode))

-(defn request-options [{:keys [openid-config credentials]}]
-  (let [params (merge {"grant_type" "password"} credentials)
-        response (client/post (get openid-config "token_endpoint")
-                              {:form-params params})
-        access-token (-> response :body json/decode (get "access_token"))]
+(defn password-grant?
+  [credentials]
+  (every? #(contains? credentials %) ["client_id" "password" "username"]))
+
+(defn client-credentials-grant?
+  [credentials]
+  (every? #(contains? credentials %) ["client_id" "client_secret"]))
+
+(defn request-options
+  [{:keys [openid-config credentials]}]
+  (let [params
+        (cond
+          (password-grant? credentials)
+          (merge {"grant_type" "password"} credentials)
+          (client-credentials-grant? credentials)
+          (merge {"grant_type" "client_credentials"} credentials)
+          :else (throw (Exception. "Unsupported oidc grant_type")))
+        resp (client/post (get openid-config "token_endpoint")
+                          {:form-params params})
+        access-token (-> resp
+                         :body json/decode (get "access_token"))]
     {:headers {"Authorization" (str "bearer " access-token)
                "Content-Type" "application/json"}}))

@@ -136,6 +152,9 @@
 (defn keycloak [{:keys [client-id url realm user password]}]
   (map->KeycloakAgent {:issuer (format "%s/realms/%s" url realm)
                        :api-root (format "%s/admin/realms/%s" url realm)
-                       :credentials {"username" user
-                                     "password" password
-                                     "client_id" client-id}}))
+                       :credentials {;; "username" user
+                                     ;; "password" password
+                                     ;; "client_id" client-id
+                                     "client_id" "lumen-confidential"
+                                     "client_secret"
+                                     "caed3964-09dd-4752-b0bb-22c8e8ffd631"}}))


add :env to *context*

add :env to *context*

--- src/cake.clj
+++ src/cake.clj
@@ -34,7 +34,9 @@
                      (read-config (File. ".cake/config"))))

 (defn context [env]
-  (get-in *project* [:environments (keyword (or env (*config* "env") :dev))]))
+  (let [env (keyword (or env (*config* "env") :dev))]
+    (assoc (get-in *project* [:environments env])
+      :env env)))

 (if-ns (:require [clj-stacktrace.repl :as clj-stacktrace])
   (do


Bumps version to 1.53.8-SNAPSHOT

Bumps version to 1.53.8-SNAPSHOT

--- scheduler/project.clj
+++ scheduler/project.clj
@@ -13,7 +13,7 @@
 ;; See the License for the specific language governing permissions and
 ;; limitations under the License.
 ;;
-(defproject cook "1.53.7"
+(defproject cook "1.53.8-SNAPSHOT"
   :description "This launches jobs on a Mesos cluster with fair sharing and preemption"
   :license {:name "Apache License, Version 2.0"}
   :dependencies [[org.clojure/clojure "1.8.0"]


add parse-process func

add parse-process func

--- src/sandbox/multithread.clj
+++ src/sandbox/multithread.clj
@@ -50,7 +50,7 @@
   medium-op op3;
  unlock l1;")

-(defn fire-a-process [grammar program process-id priority]
+(defn fire-process [grammar program process-id priority]
   {:process-id process-id
    :instructions (flatten (gen-program (insta/parser grammar) program))
    :priority priority})
@@ -210,21 +210,19 @@
        (reduce +)
        (* 2)))

+(defn parse-processes [language programs]
+  (vec (map #(fire-process language
+                             (:program %)
+                             (:process-id %)
+                             (:priority %))
+            programs)))
+
 (defn schedule-programs [language programs]
-  (let [processes (into [] (map #(fire-a-process language
-                                                 (:program %)
-                                                 (:process-id %)
-                                                 (:priority %))
-                                programs))
+  (let [processes (parse-processes language programs)
         timeout (total-time processes)
-;;=> "timeout" is the total length of all processes executed one
-;;   after the other.
         locks (ref (prepare-locks processes))
         scheduled (ref (prepare-scheduled processes))
         processes-cycles  (gen-processes-cycles processes)]
-;;=> We prepare "locks" and "scheduled" refs, and the weighted
-;;   process repetitions that the scheduler will have to cycle
-;;   through
     (loop [quantum 0
            remaining-processes processes-cycles]
 ;;=> We loop


Fix tests to use renamed (de)serialize-object

--- test/adzerk/boot_cljs/util_test.clj
+++ test/adzerk/boot_cljs/util_test.clj
@@ -19,18 +19,18 @@

 (deftest basic-exception-test
   (let [original (Exception. "foo")
-        a (deserialize-exception (serialize-exception original))]
+        a (deserialize-object (serialize-object original))]
     (is (= "foo" (.getMessage a)))))

 (deftest ex-data-test
   (let [original (ex-info "foo" {:a 1})
-        a (deserialize-exception (serialize-exception original))]
+        a (deserialize-object (serialize-object original))]
     (is (= "foo" (.getMessage a)))
     (is (= {:a 1} (ex-data a)))))

 (deftest cause-test
   (let [original (Exception. "foo" (Exception. "bar"))
-        a (deserialize-exception (serialize-exception original))]
+        a (deserialize-object (serialize-object original))]
     (is (= "bar" (.getMessage (.getCause a))))))

 (defn drop-first-line [s]
@@ -40,11 +40,10 @@
       (->> (string/join "\n"))))

 (deftest stack-trace-test
-  ; First line differs as it contains the name of Exception class
   (let [original (Exception. "foo")
-        a (deserialize-exception (serialize-exception original))]
-    (is (= (drop-first-line (with-out-str (st/print-stack-trace original)))
-           (drop-first-line (with-out-str (st/print-stack-trace a)))))))
+        a (deserialize-object (serialize-object original))]
+    (is (= (with-out-str (st/print-stack-trace original))
+           (with-out-str (st/print-stack-trace a))))))

 (deftest merge-cause-ex-data-test
   (is (= {:a 1 :b 2} (merge-cause-ex-data (ex-info "a" {:a 1} (ex-info "b" {:b 2}))))))


disable many params test for cljs because of bug in cljs

--- test/com/rpl/specter/core_test.cljc
+++ test/com/rpl/specter/core_test.cljc
@@ -523,6 +523,7 @@
             ))
         ))))

+#?(:clj
 (deftest large-params-test
   (let [path (apply s/comp-paths (repeat 25 s/keypath))
         m (reduce
@@ -532,3 +533,6 @@
             (reverse (range 25)))]
     (is (= :a (s/select-one (apply path (range 25)) m)))
     ))
+;;TODO: there's a bug in clojurescript that won't allow
+;; non function implementations of IFn to have more than 20 arguments
+)


test import and spacing cleanup

test import and spacing cleanup

--- test/hatti/views/dataview_test.cljs
+++ test/hatti/views/dataview_test.cljs
@@ -1,10 +1,10 @@
 (ns hatti.views.dataview-test
-  (:require-macros [cljs.test :refer (is deftest testing)]
-                   [dommy.macros :refer [sel sel1]])
-  (:require [cljs.test :as t]
-            [dommy.core :as dommy]
+  (:require-macros [cljs.test :refer (is deftest testing)])
+  (:require [chimera.seq :refer [in?]]
+            [cljs.test :as t]
+            [dommy.core :as dommy :refer-macros [sel1]]
             [hatti.shared :as shared]
-            [hatti.utils :refer [in?]]
+
             [hatti.utils.om.state :as state]
             [hatti.views :refer [tabbed-dataview]]
             [hatti.test-utils :refer [big-thin-data
@@ -59,8 +59,8 @@
     (let [disabled-views [:map :table :chart]
           data-atom (shared/empty-app-state)
           _ (state/transact-app-state! data-atom
-                                        [:views :disabled]
-                                        #(identity disabled-views))
+                                       [:views :disabled]
+                                       #(identity disabled-views))
           tabbed-view (tabbed-dataview-container data-atom)]
       (doseq [tab (-> tabbed-view (sel1 :div.tab-bar) (sel :.inactive))]
         (is (in? disabled-views


Delete the scratch file I was working on - it's now permanently in the git history if I need it

--- src/foreclojure/scratch.clj
+++ src/foreclojure/scratch.clj
@@ -1,27 +0,0 @@
-;;; Wrote this while trying to roll my own version of Last-Modified header
-;;; management. It turned out that Ring already has a middleware for this
-;;; (I was looking in Compojure instead of Ring), so this code isn't
-;;; necessary, but I'm disinclined to throw it out, since it's an interesting
-;;; example of how to work with HTTP dates in Clojure
-
-;; DateFormat isn't thread-safe, so don't globally def one
-(defn rfc-date-formatter []
-  (doto (SimpleDateFormat. "EEE, dd MMM yyyy HH:mm:ss 'GMT'")
-    (.setCalendar (-> "GMT"
-                      (TimeZone/getTimeZone)
-                      (Calendar/getInstance)))))
-
-(defn format-date [date]
-  (.format (rfc-date-formatter) date))
-
-(defn parse-date [date-str]
-  (.parse (rfc-date-formatter) date-str))
-
-(defn wrap-modtime [handler]
-  (fn [request]
-    (when-let [{body :body :as resp} (handler request)]
-      (if (instance? File body)
-        (let [modtime (.lastModified ^File body)]
-          (assoc-in resp [:headers "Last-Modified"]
-                    (format-date (Date. modtime))))
-        resp))))


islands still incorrect

islands still incorrect

--- src/tenbytenbot/tactics.clj
+++ src/tenbytenbot/tactics.clj
@@ -44,20 +44,43 @@

-(defn- neighbours-4 [pos relevant-positions]
+(defn- neighbours-4 [pos filled yet-to-visit]
+  "aux"
   (let [[x y] pos
-        potentials set([[(dec x) y]
-                        [(inc x) y]
-                        [x (dec y)]
-                        [x (inc y)]])]
-    (intersection potentials relevant-positions)))
+        neig (conj (filter
+                      (partial contains? filled)
+                      [[(dec x) y]
+                       [(inc x) y]
+                       [x (dec y)]
+                       [x (inc y)]]) pos)]
+    (loop [changed false
+           neig neig
+           yet-to-visit yet-to-visit]
+      (if (empty? neig)
+        {:changed changed :yet-to-visit yet-to-visit}
+        (let [f (first neig)
+              n (next neig)]
+          (if (contains? yet-to-visit f)
+            (recur true    n (disj yet-to-visit f))
+            (recur changed n       yet-to-visit)))))))

-;; (defn number-of-islands [board]
+
+(defn number-of-islands [board]
 ;;   "TODO http://prismoskills.appspot.com/lessons/Arrays/Count_blobs_in_matrix.jsp"
-;;   (loop [left-to-visit (set (m/filled-positions board))
-;;          result 0]
+   (let [filled (set (m/filled-positions board))]
+     (loop [yet-to-visit filled
+            result 0]
+       (if (empty? yet-to-visit)
+         result
+         (let [r (neighbours-4 (first yet-to-visit) filled yet-to-visit)]
+           (recur (:yet-to-visit r) (if (:changed r) (inc result) result)))))))
+
+
+(number-of-islands (m/from-string "##.#
+##..
+..##"))


Random given names (using Wikipedia list)

--- src/test_utils/sandbox.cljc
+++ src/test_utils/sandbox.cljc
@@ -18,3 +18,26 @@
   (map clj-str/join
        (map #(concat ["0x"] %)
             (take 4 (map clj-str/join (partition 2 (hex-uuid)))))))
+
+(defn random-given-name-path []
+  "Return a 'path' to a given name from [Wikipedia](https://en.wikipedia.org/wiki/List_of_most_popular_given_names)"
+  (let [regions (concat (repeat 8 :americas)
+                        (repeat 4 :europe)
+                        (repeat 4 :asia)
+                        [:africa :oceania])
+        gender (concat (repeat 6 :male)
+                       (repeat 4 :female))
+        target {:americas {:male 20
+                           :female 20}
+                :europe {:male 50
+                         :female 50}
+                :asia {:male 32
+                       :female 30}
+                :africa {:male 9
+                         :female 9}
+                :oceania {:male 4
+                          :female 4}}
+        candidates [(rand-nth regions) (rand-nth gender)]]
+    (flatten [candidates
+              (inc (rand-int (get-in target candidates)))
+              (inc (rand-int 10))])))


Increase read timeout to 30 seconds

Increase read timeout to 30 seconds

--- src/lcmap/aardvark/core.clj
+++ src/lcmap/aardvark/core.clj
@@ -44,7 +44,7 @@
 ;; with `environ-cfg` values during startup.

 (def default-cfg {:database  {:cluster {:contact-points "cassandra"
-                                        :socket-options {:read-timeout-millis 20000}
+                                        :socket-options {:read-timeout-millis 30000}
                                         :query-options {:consistency :quorum}}
                               :default-keyspace "lcmap_landsat"
                               :schema {:setup false :teardown false}}


HTTP error codes handling

HTTP error codes handling

--- src/leiningen/fore_prob.clj
+++ src/leiningen/fore_prob.clj
@@ -1,7 +1,6 @@
 (ns leiningen.fore-prob
   "Populate the current project with a 4clojure problem."
   (:require [clj-http.client :as http]
-            [cheshire.core   :as json]
             [clojure.java.io :as io])
   (:use [clojure.string :as cs :exclude [replace reverse]]))

@@ -12,7 +11,7 @@
            (replace \. \/))))

 (defn- title->fn [title]
-  (.toLowerCase (cs/replace title #"[^\w]" "-")))
+  (.toLowerCase (cs/replace title #"\W" "-")))

 (defn- drop-replace-me [fn]
   (let [t (slurp fn)
@@ -34,11 +33,12 @@
 ;; Allow something that might have quotes to live in a string.
 (defn- enquote [s]
   (cs/replace s  "\"" "\\\""))
+
 ;; XXX - Format too?
 (defn- expand-prob [prob tests]
   (->>
    (map #(cs/replace % #"\b__\b" (str prob "-solution")) tests)
-   (map #(cs/replace % "\\r?\\n" "\n")) ; XXX \r isn't getting replaced.
+   (map #(cs/replace % #"\r?\n" "\n"))
    (map #(cs/join " " ["(is" % "\"" (enquote %) "\")"]))
    (cs/join "\n")))

@@ -57,17 +57,22 @@

 (def fore-url "http://4clojure.com/api/problem/")

-;; TODO - Create projects from a problem (maybe use the spawn plugin?).
+(defn get-prob [n]
+  (let [req (http/get (str fore-url n) {:as :json
+                                        :throw-exceptions false})]
+    (if (= (req :status) 200)
+      ;; we don't need scores here and it's polluting debugging logs
+      (dissoc (req :body) :scores))))
+
 (defn fore-prob [project prob-num]
-  (try
-    ;; TODO - Check HTTP status.
-    (let [json (json/parse-string
-                 (:body (http/get (str fore-url prob-num))))
-          title (json :title)]
-      (if-not (write-tests project json) ; spit returns nil by default hence
-                                         ; the inversion of logic.
-        (println (str "Problem \"" title "\" added!"))
-        (println (str "Problem \"" title "\" has already been added!"))))
-    (catch Exception e
-      (println (str "Failed setting problem " prob-num ": " (.getMessage e)))
-      (shutdown-agents))))
+  (if-let [prob (get-prob prob-num)]
+    (try
+      (let [title (prob :title)]
+        (if-not (write-tests project prob) ; spit returns nil by default hence
+                                           ; the inversion of logic.
+          (println (str "Problem \"" title "\" added!"))
+          (println (str "Problem \"" title "\" has already been added!"))))
+      (catch Exception e
+        (println (str "Failed setting problem " prob-num ": " (.getMessage e)))
+        (shutdown-agents)))
+    (println "Cannot get problem" prob-num "(HTTP status != 200).")))


Update ring-devel dependencies

Update ring-devel dependencies

--- ring-devel/project.clj
+++ ring-devel/project.clj
@@ -8,7 +8,7 @@
                  [ring/ring-core "1.7.1"]
                  [hiccup "1.0.5"]
                  [clj-stacktrace "0.2.8"]
-                 [ns-tracker "0.3.1"]]
+                 [ns-tracker "0.4.0"]]
   :aliases {"test-all" ["with-profile" "default:+1.8:+1.9:+1.10" "test"]}
   :profiles
   {:1.8  {:dependencies [[org.clojure/clojure "1.8.0"]]}


move result html over to engine

move result html over to engine

--- src/chat/client/views/new_message.cljs
+++ src/chat/client/views/new_message.cljs
@@ -38,7 +38,16 @@
               (remove (fn [t]
                         (contains? thread-tag-ids (t :id))))
               (filter (fn [t]
-                        (fuzzy-matches? (t :name) query)))))))])
+                        (fuzzy-matches? (t :name) query)))
+              (map (fn [tag]
+                     {:html
+                      (dom/div #js {:className "tag-match"}
+                        (dom/div #js {:className "color-block"
+                                      :style #js {:backgroundColor (helpers/tag->color tag)}})
+                        (dom/div #js {:className "tag-name"}
+                          (tag :name))
+                        (dom/div #js {:className "group-name"}
+                          (:name (store/id->group (tag :group-id)))))}))))))])

 ; TODO: autocomplete mentions
@@ -129,12 +138,7 @@
                                                  (dispatch! :tag-thread {:thread-id (config :thread-id)
                                                                          :id (tag :id)})
                                                  (close-autocomplete!))}
-                          (dom/div #js {:className "color-block"
-                                        :style #js {:backgroundColor (helpers/tag->color tag)}})
-                          (dom/div #js {:className "tag-name"}
-                            (tag :name))
-                          (dom/div #js {:className "group-name"}
-                            (:name (store/id->group (tag :group-id))))))
+                          (tag :html)))
                       results))
                   (dom/div #js {:className "result"}
                     "No Results")))))))))


Break up make-jmessage to accept existing Session.

--- src/clj/com/draines/postal/message.clj
+++ src/clj/com/draines/postal/message.clj
@@ -43,24 +43,28 @@
                         (.setContent (:content part) (:type part))))))
     (.setContent jmsg mp)))

-(defn make-jmessage [msg]
-  (let [{:keys [sender from to cc bcc date subject body host port]} msg
-        props (doto (java.util.Properties.)
-                (.put "mail.smtp.host" (or host "not.provided"))
-                (.put "mail.smtp.port" (or port "25"))
-                (.put "mail.smtp.from" (or sender from)))
-        session (Session/getInstance props)
-        jmsg (MimeMessage. session)]
-    (add-recipients! jmsg Message$RecipientType/TO to)
-    (add-recipients! jmsg Message$RecipientType/CC cc)
-    (add-recipients! jmsg Message$RecipientType/BCC bcc)
-    (.setFrom jmsg (InternetAddress. from))
-    (.setSubject jmsg subject)
-    (if (string? body)
-      (.setText jmsg body)
-      (add-multipart! jmsg body))
-    (.setSentDate jmsg (or date (make-date)))
-    jmsg))
+(defn make-jmessage
+  ([msg]
+     (let [{:keys [sender from host port]} msg
+           props (doto (java.util.Properties.)
+                   (.put "mail.smtp.host" (or host "not.provided"))
+                   (.put "mail.smtp.port" (or port "25"))
+                   (.put "mail.smtp.from" (or sender from)))
+           session (Session/getInstance props)]
+       (make-jmessage msg session)))
+  ([msg session]
+     (let [{:keys [from to cc bcc date subject body]} msg
+           jmsg (MimeMessage. session)]
+       (add-recipients! jmsg Message$RecipientType/TO to)
+       (add-recipients! jmsg Message$RecipientType/CC cc)
+       (add-recipients! jmsg Message$RecipientType/BCC bcc)
+       (.setFrom jmsg (InternetAddress. from))
+       (.setSubject jmsg subject)
+       (if (string? body)
+         (.setText jmsg body)
+         (add-multipart! jmsg body))
+       (.setSentDate jmsg (or date (make-date)))
+       jmsg)))

 (deftest test-simple
   (let [m {:from "fee@bar.dom"


renamed GET function

renamed GET function

--- src/clj/hospital_scheduler/handler.clj
+++ src/clj/hospital_scheduler/handler.clj
@@ -14,7 +14,18 @@

 ;; HTTP routes
 (defroutes app-routes
-  (GET "/events-summary" [] (response rs/read-summary))
-  (PUT "/create-event" {:params params} (rs/create-event params))
-  (POST "/update-event/:id" {:params params} (rs/update-event id params))
-  (DELETE "/delete-event/:id" [] (rs/delete-event id)))
+  (GET "/events-summary" [] (response rs/read-events))
+  (PUT "/create-event" {params :params} (rs/create-event params))
+  (POST "/update-event/:id" {id :id params :params} (rs/update-event id params))
+  (DELETE "/delete-event/:id" [id] (rs/delete-event [id])))
+
+(def app
+  (-> (handler/api app-routes)
+      (middleware/wrap-json-body)
+      (middleware/wrap-json-response)
+      (cors/wrap-cors (re-pattern (str "^http://"
+                                       (env :db-url) ":" (env :db-port)
+                                       "/events-summary$")))))
+
+(defn -main [& args]
+  (run-jetty #'app {:port 3000}))


Remove 'Apply for a badge' -link

Remove 'Apply for a badge' -link

--- src/cljs/salava/gallery/ui/routes.cljs
+++ src/cljs/salava/gallery/ui/routes.cljs
@@ -17,15 +17,13 @@
                ["/pages"    p/handler]
                [["/pages/" :user-id] p/handler]
                ["/profiles" u/handler]
-               [["/badgeview/" :badge-content-id] bv/handler]
-               ["/getbadge" (placeholder [:p "Apply for a badge"])]]})
+               [["/badgeview/" :badge-content-id] bv/handler]]})

 (defn ^:export navi [context]
   {"/gallery"          {:weight 40 :title (t :gallery/Gallery)        :top-navi true  :breadcrumb (t :gallery/Gallery " / " :gallery/Sharedbadges)}
    "/gallery/badges"   {:weight 41 :title (t :gallery/Sharedbadges)   :site-navi true :breadcrumb (t :gallery/Gallery " / " :gallery/Sharedbadges)}
    "/gallery/pages"    {:weight 42 :title (t :gallery/Sharedpages)    :site-navi true :breadcrumb (t :gallery/Gallery " / " :gallery/Sharedpages)}
    "/gallery/profiles" {:weight 43 :title (t :gallery/Sharedprofiles) :site-navi true :breadcrumb (t :gallery/Gallery " / " :gallery/Sharedprofiles)}
-   "/gallery/getbadge" {:weight 44 :title (t :gallery/Applybadge)     :site-navi true :breadcrumb (t :gallery/Gallery " / " :gallery/Applybadge)}
    "/gallery/badges/\\d+" {:breadcrumb (t :gallery/Gallery " / " :gallery/Sharedbadges)}
    "/gallery/pages/\\d+" {:breadcrumb (t :gallery/Gallery " / " :gallery/Sharedpages)}
    "/gallery/badgeview/\\w+" {:breadcrumb (t :gallery/Gallery " / " :gallery/Viewbadge)}})


CMR-804: Added code to skip concepts that have expired delete times.

--- src/cmr/indexer/data/elasticsearch.clj
+++ src/cmr/indexer/data/elasticsearch.clj
@@ -15,6 +15,7 @@
             [cmr.system-trace.core :refer [deftracefn]]
             [cmr.umm.core :as umm]
             [clj-time.core :as t]
+            [clj-time.format :as f]
             [cmr.common.time-keeper :as tk]
             [cheshire.core :as json]))

@@ -168,16 +169,28 @@
                             (let [umm-concept (umm/parse-concept concept)
                                   delete-time (get-in umm-concept
                                                       [:data-provider-timestamps :delete-time])
-                                  ttl (when delete-time (t/in-millis (t/interval (tk/now)
-                                                                                delete-time)))
+                                  now (tk/now)
+                                  ttl (when delete-time
+                                        (if (t/after? delete-time now)
+                                          (t/in-millis (t/interval now delete-time))
+                                          0))
                                   elastic-doc (concept->elastic-doc context concept umm-concept)
                                   elastic-doc (if ttl
                                                 (assoc elastic-doc :_ttl ttl)
                                                 elastic-doc)]
-                              (merge elastic-doc {:_index index-name
-                                                  :_type type
-                                                  :_version revision-id
-                                                  :_version_type "external_gte"}))))
+                              (if (or (nil? ttl)
+                                        (> ttl 0))
+                                (merge elastic-doc {:_index index-name
+                                                   :_type type
+                                                   :_version revision-id
+                                                   :_version_type "external_gte"})
+                                (info
+                                  (str
+                                    "Skipping expired concept ["
+                                    concept-id
+                                    "] with delete-time ["
+                                    (f/unparse (f/formatters :date-time) delete-time)
+                                    "]"))))))
                         (catch Throwable e
                           (error e (str "Skipping failed catalog item. Exception trying to convert concept to elastic doc:"
                                         (pr-str concept))))))


fixed server side variable thing

fixed server side variable thing

--- src/nn/views/complector.clj
+++ src/nn/views/complector.clj
@@ -3,9 +3,5 @@
             [nn.views.css :as css]
             [nn.views.html :as page]
             ))
-
-(defn main-page []
-  (page/main-page))
-
 (defn xp []
   (page/experiment-page css/xp))


load_all.clj: update

load_all.clj: update

--- src/org/altlaw/load_all.clj
+++ src/org/altlaw/load_all.clj
@@ -12,7 +12,7 @@
    org.altlaw.jobs.analyze.cite_fields
    org.altlaw.jobs.analyze.merge
    org.altlaw.jobs.post.distindex
-   org.altlaw.jobs.post.savecontent
+   org.altlaw.jobs.post.makecontent

    org.altlaw.test.run
    org.altlaw.test.www
@@ -23,6 +23,7 @@
    org.altlaw.util.files
    org.altlaw.util.hadoop
    org.altlaw.util.hadoop.SeqFileToFiles
+   org.altlaw.util.hadoop.SeqFileTextToFiles
    org.altlaw.util.log
    org.altlaw.util.lucene
    org.altlaw.util.markdown


rename on-lossy-event to on-latest-event

--- src/overtone/libs/event.clj
+++ src/overtone/libs/event.clj
@@ -108,12 +108,14 @@
   (log-event "Registering sync event handler:: " event-type key)
   (handlers/add-sync-handler! handler-pool event-type key handler))

-(defn on-lossy-event
+(defn on-latest-event
   "Runs handler on a separate thread to the thread that generated the
   event - however event order is preserved per thread similar to
   on-sync-event. However, only the last matching event will trigger the
   handler with all intermediate events being dropped if the handler fn
   is still executing.
+
+  *Warning* - is not guaranteed to be triggered for all matching events.

   Useful for low-latency sequential handling of events despite
   potentially long-running handler fns where handling the most recent


Implement rich text field #46

Implement rich text field #46

--- src/flatgui/samples/forms/richtext.clj
+++ src/flatgui/samples/forms/richtext.clj
@@ -14,8 +14,7 @@
             [flatgui.widgets.window :as window]
             [flatgui.widgets.textrich :as textrich]
             [flatgui.widgets.panel :as panel]
-            [flatgui.widgets.button :as button])
-  (:import (flatgui.core IFGEvolveConsumer)))
+            [flatgui.widgets.button :as button]))

 (def sample-text "If you can fill the unforgiving minute With sixty seconds’ worth of distance run, Yours is the Earth and everything that’s in it, And — which is more — you’ll be a Man, my son!")

@@ -33,8 +32,15 @@
 (fg/defevolverfn text-position-matrix :position-matrix (m/translation gap (+ (header-&-toolpanel-h component) gap)))

 (fg/defevolverfn :rendition
-  (if (and (= (get-reason) [:text->]) (get-property [:text->] :pressed))
+  (cond
+
+    (and (= (get-reason) [:text->]) (get-property [:text->] :pressed))
     (textrich/rendition-input-data-evolver component old-rendition {:type :string :data "TEST"})
+
+    (and (= (get-reason) [:image->]) (get-property [:image->] :pressed))
+    (textrich/rendition-input-data-evolver component old-rendition {:type :image :data "http://flatgui.org/resources/icon.png" :size {:w 0.5 :h 0.5}})
+
+    :else
     (textrich/rendition-evolver component)))

 (def window
@@ -49,6 +55,11 @@
       {:position-matrix (m/translation 0.125 0.5)
        :clip-size (m/defpoint 0.375 0.375)
        :text "T"})
+
+    (fg/defcomponent button/button :image->
+      {:position-matrix (m/translation 0.625 0.5)
+       :clip-size (m/defpoint 0.375 0.375)
+       :text "I"})

     (fg/defcomponent
       textrich/textrich
@@ -66,25 +77,4 @@
      :background (awt/color 9 17 26)
      :font "bold 14px sans-serif"
      :evolvers {:clip-size component/clip-size-to-host}}
-    window))
-
-;;;
-;;; Tool button bindings: simulate input data
-;;;
-
-;(defn create-addtopic-consumer [jd-node]
-;  (reify IFGEvolveConsumer
-;    (getTargetPath [_this] [:mainframe :topiclist-tab :add-topic-button])
-;    (getTargetProperties [_this] [:pressed])
-;    (acceptEvolveResult [_this sessionId container _reason]
-;      (if (:pressed container)
-;        (let [topic-count (.getTopicCount jd-node)
-;              topic-name (str "topic-" topic-count) ]
-;          (do
-;            (println "[JD]" sessionId "Adding topic " topic-name)
-;            (.addTopic jd-node topic-name)))))))
-;
-;
-;(defn setup-bindings [container]
-;  (println "[JD] Initializing control binding consumers...")
-;  (.addEvolveConsumer container (addtopic/create-addtopic-consumer *jd-node*)))+    window))


Added minor comment regarding :cljsbuild :figwheel setting

--- src/leiningen/new/figwheel/project.clj
+++ src/leiningen/new/figwheel/project.clj
@@ -22,6 +22,7 @@
               [{:id "dev"
                 :source-paths ["src"]

+                ;; If no code is to be run, set :figwheel true for continued automagical reloading
                 :figwheel {:on-jsload "{{name}}.core/on-js-reload"}

                 :compiler {:main {{name}}.core


counter: app is started now

counter: app is started now

--- examples/counter/src/app/core.cljs
+++ examples/counter/src/app/core.cljs
@@ -9,7 +9,10 @@
   []
   (let [app (mvsa/app counter/spec)
         [app-view-model app-view] (mvsa/connect-ui app counter/view-model counter/view)]
+    ((:dispatch-signal app) :on-start)
+
     (r/render app-view (.getElementById js/document "root"))
+
     (assoc app :view-model app-view-model)))

 (def app (main))


reordered body

reordered body

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_bio/part_of.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_bio/part_of.clj
@@ -10,11 +10,11 @@
           (?/protein rdfs/subClassOf ?/r)
           )
   :body (
-          (?/loc rdfs/subClassOf obo/GO_0051179) ;localization
-          (?/loc rdfs/subClassOf ?/of1)
-          (?/of1 rdf/type owl/Restriction)
           (?/of1 owl/onProperty obo/RO_0002313) ;transports or maintains localization of
           (?/of1 owl/someValuesFrom ?/protein)
+          (?/of1 rdf/type owl/Restriction)
+          (?/loc rdfs/subClassOf ?/of1)
+          (?/loc rdfs/subClassOf obo/GO_0051179) ;localization

           (?/loc rdfs/subClassOf ?/to1)
           (?/to1 rdf/type owl/Restriction)


Cleanup ns form

Cleanup ns form

- Run clean-ns
- Get rid of refer :all

--- src/refactor_nrepl/util.clj
+++ src/refactor_nrepl/util.clj
@@ -1,9 +1,11 @@
 (ns refactor-nrepl.util
-  (:require [clojure.tools.namespace.find :refer [find-clojure-sources-in-dir]]
-            [clojure.tools.analyzer.ast :refer :all]
-            [clojure.tools.namespace.parse :refer [read-ns-decl]]
-            [clojure.string :as str]
-            [clojure.set :as set])
+  (:require [clojure
+             [set :as set]
+             [string :as str]]
+            [clojure.tools.analyzer.ast :refer [nodes]]
+            [clojure.tools.namespace
+             [find :refer [find-clojure-sources-in-dir]]
+             [parse :refer [read-ns-decl]]])
   (:import java.io.PushbackReader
            java.util.regex.Pattern))


Remove tests/bench; replaced by riemann-bench.

--- test/riemann/test/bench.clj
+++ test/riemann/test/bench.clj
@@ -1,140 +0,0 @@
-(ns riemann.test.bench
-  (:use riemann.core
-        riemann.common
-        riemann.logging
-        riemann.transport.udp
-        riemann.transport.tcp
-        clojure.test
-        clojure.java.shell
-        [clojure.string :only [trim-newline]]
-        [incanter core charts]
-        [riemann.client :only [tcp-client udp-client close-client send-event]])
-  (:require riemann.streams))
-
-(defn git-version
-  "Returns a human-readable version name for this commit."
-  []
-  (if (re-matches #"^\n*$" (:out (sh "git" "status" "-s")))
-    ; Unchanged commit.
-    (str
-      (trim-newline (:out (sh "git" "show" "-s" "--format=%ci" "HEAD")))
-      " "
-      (trim-newline (:out (sh "git" "rev-parse" "HEAD" :out "UTF-8"))))
-
-    ; Changed commit.
-    "HEAD"))
-(def git-version-memo (memoize git-version))
-
-(defn now
-  "Current high-res time, in ms"
-  []
-  (/ (. System nanoTime) 1000000.0))
-
-(defmacro time*
-  "Evaluates expr and returns the time it took in ms"
-  [expr]
-  `(let [start# (. System (nanoTime))
-         ret# ~expr]
-     (/ (- (. System (nanoTime)) start#) 1000000.0)))
-
-(defn record
-  "Returns [times, latencies] of calling f"
-  ([f opts]
-   (let [n    (or (:n opts) 100)
-         t0   (now)]
-     (loop [i n
-            times []
-            latencies []]
-       (if (zero? i)
-         [times latencies]
-         (recur (dec i)
-                (conj times (- (now) t0))
-                (conj latencies (time* (f)))))))))
-
-(defn throughput
-  "Returns [times, throughputs] of tape"
-  ([tape opts]
-   (let [[times latencies] tape
-         samples (min (dec (count times)) (max 1 (or (:samples opts) 1000)))
-         sample-size (/ (dec (count times)) samples)
-         selected-times (take-nth sample-size times)
-         throughputs (map (fn [[t1 t2]]
-                            (/ sample-size (- t2 t1)))
-                          (partition 2 1 selected-times))]
-     [(drop-last selected-times) throughputs])))
-
-(defn latencies
-  [tape opts]
-  tape)
-
-(defn save-graph [graph opts]
-  (let [file (str "bench/" (git-version-memo) "/" (:title opts) ".png")]
-    (sh "mkdir" "-p" (str "bench/" (git-version-memo)))
-    (save graph file :width 1024)
-    (println "Wrote" file)))
-
-(defn latency-graph
-  "Graphs latencies, with options."
-  ([tape] (latency-graph tape {}))
-  ([tape opts]
-   (let [title (str (:title opts) " latency")
-         [times latencies] (latencies tape opts)]
-     (doto (scatter-plot (map #(/ % 1000) times)
-                         latencies
-                         :title title
-                         :x-label "Time (s)"
-                         :y-label "Latency (ms)")
-       (set-stroke :width 1) ; huh
-       (save-graph {:title title})))))
-
-(defn throughput-graph
-  "Graphs throughput of tape, with options."
-  ([tape] (throughput-graph tape {}))
-  ([tape opts]
-   (let [title (str (:title opts) " throughput")
-         [times throughput] (throughput tape opts)]
-     (doto (scatter-plot (map #(/ % 1000) times)
-                         (map (partial * 1000) throughput)
-                         :title title
-                         :x-label "Time (s)"
-                         :y-label "Reqs/s")
-       (save-graph {:title title})))))
-
-(defn multigraph [f opts]
-  (let [tape (record f opts)]
-    (latency-graph tape opts)
-    (throughput-graph tape opts)))
-
-(defn core-package
-  ([] (core-package [{}]))
-  ([opts]
-   (let [servers [(tcp-server) (udp-server)]
-         streams (or (:streams opts) [])
-         core    (suppress "riemann.core"
-                           (transition! (core) {:streams streams
-                                                :services servers}))]
-     {:core core
-      :servers servers
-      :streams streams})))
-
-(deftest ^:bench drop-tcp-events
-         (let [{:keys [core]} (core-package)
-               client (tcp-client)]
-           (try
-             (multigraph
-               #(send-event client {:service "test" :metric 0.1})
-               {:title "drop tcp events"
-                :n 100000})
-             (finally
-               (stop! core)))))
-
-(deftest ^:bench drop-udp-events
-         (let [{:keys [core]} (core-package)
-               client (udp-client)]
-           (try
-             (multigraph
-               #(send-event client {:service "test" :metric 0.1} false)
-               {:title "drop udp events"
-                :n 100000})
-             (finally
-               (stop! core)))))


Reduce log level of query time display.

Reduce log level of query time display.

--- metlog-vault/src-server/metlog_vault/data.clj
+++ metlog-vault/src-server/metlog_vault/data.clj
@@ -21,10 +21,10 @@
       (app req))))

 (defn call-with-query-logging [ name actual-args fn ]
-  (log/info "query" name actual-args)
+  (log/debug "query" name actual-args)
   (let [begin-t (. System (nanoTime))
         result (fn)]
-    (log/info "query time" name "-" (/ (- (. System (nanoTime)) begin-t) 1000000.0))
+    (log/debug "query time" name "-" (/ (- (. System (nanoTime)) begin-t) 1000000.0))
     result))

 (defmacro defquery [ name lambda-list & body ]


Accelerate entities

Accelerate entities


comment out compare test for now

comment out compare test for now

--- test/transit/test/core.cljs
+++ test/transit/test/core.cljs
@@ -160,7 +160,7 @@

 ;; Test UUID comparison

-(deftest test-uuid-compare
+#_(deftest test-uuid-compare
   (is (zero?
         (compare (t/read r "{\"~#'\":\"~u550e8400-e29b-41d4-a716-446655440000\"}")
                  #uuid "550e8400-e29b-41d4-a716-446655440000"))))


convert-specs! does not convert regexs

convert-specs! does not convert regexs

--- src/spec_tools/visitor.cljc
+++ src/spec_tools/visitor.cljc
@@ -167,14 +167,15 @@

 (defn convert-specs!
   "Collects all registered subspecs from a spec and
-  transforms their registry values into Spec Records."
+  transforms their registry values into Spec Records.
+  Does not convert clojure.spec regex ops."
   [spec]
   (let [specs (visit spec (spec-collector))
         report (atom #{})]
     (doseq [[k v] specs]
       (if (keyword? v)
         (swap! report into (convert-specs! v))
-        (when-not (st/spec? v)
+        (when-not (or (s/regex? v) (st/spec? v))
           (let [s (st/create-spec {:spec v})]
             (s/def-impl k (s/form s) s)
             (swap! report conj k)))))


Use a transducer instead of a lazy sequence

--- src/suricatta/dsl/pgsql.clj
+++ src/suricatta/dsl/pgsql.clj
@@ -45,7 +45,7 @@
 (extend-protocol proto/ISQLType
   java.sql.Array
   (-convert [self]
-    (into [] (map proto/-convert (.getArray self)))))
+    (into [] (map proto/-convert) (.getArray self))))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Fixed crop detection

Fixed crop detection

--- src/video_server/ffmpeg.clj
+++ src/video_server/ffmpeg.clj
@@ -39,7 +39,7 @@
   (let [output (:err (exec "ffmpeg" "-y" "-ss" start "-i" input "-f" "matroska"
                            "-t" duration "-an" "-sn" "-vf" "cropdetect=24:2:0"
                            "-crf" 51 "-preset" "ultrafast" "/dev/null"))]
-    (distinct (re-seq #"crop=[0-9:]*" output))))
+    (distinct (re-seq #"crop=[0-9:]+" output))))

 (defn- crop-size
   "Returns the number of pixels in the crop detection."


Updated video size labels

Updated video size labels


Grade school sorted test now checks against a sorted map.

--- grade-school/grade_school_test.clj
+++ grade-school/grade_school_test.clj
@@ -33,9 +33,9 @@
   (is (= [] (grade-school/grade db 1))))

 (deftest sorted-grade-school
-  (is (= { 3 ["Kyle"]
-           4 ["Christopher" "Jennifer"]
-           6 ["Kareem"] }
+  (is (= (sorted-map 3 ["Kyle"]
+                     4 ["Christopher" "Jennifer"]
+                     6 ["Kareem"] )
          (-> db
              (grade-school/add "Jennifer" 4)
              (grade-school/add "Kareem" 6)


Fix jar nameing in test runner.

Fix jar nameing in test runner.

--- test/run.clj
+++ test/run.clj
@@ -15,7 +15,7 @@

 (defn boot-servers []
   (println "Booting servers...")
-  (let [path (str "fleetdb-standalone-" server/fleetdb-version ".jar")]
+  (let [path (str "fleetdb-" server/fleetdb-version "-standalone.jar")]
     (when-not (file/exist? path)
       (println path "missing: run `lein uberjar`")
       (System/exit 1))


Include system-classpath and classpath namespaces in all-namespaces

--- src/yetibot/core/loader.clj
+++ src/yetibot/core/loader.clj
@@ -23,7 +23,9 @@
   (get-config ::plugins-config [:plugins]))

 (defn all-namespaces []
-  (ns/find-namespaces (cp/classpath)))
+  (concat
+   (ns/find-namespaces (cp/system-classpath))
+   (ns/find-namespaces (cp/classpath))))

 (defn find-namespaces [pattern]
   (filter #(re-matches pattern (str %)) (all-namespaces)))


Updated metadata in Clojure project file

--- clojure/project.clj
+++ clojure/project.clj
@@ -1,8 +1,8 @@
 (defproject biotool "0.1.0-SNAPSHOT"
-  :description "FIXME: write description"
-  :url "http://example.com/FIXME"
-  :license {:name "Eclipse Public License"
-            :url "http://www.eclipse.org/legal/epl-v10.html"}
+  :description "An example bioinformatics tool to demonstrate good programming practices"
+  :url "https://github.com/biotool-paper/biotool"
+  :license {:name "MIT"
+            :url "https://opensource.org/licenses/MIT"}
   :dependencies [[org.clojure/clojure "1.8.0"]
                  [clj-biosequence "0.5.2"]
                  [org.clojure/tools.cli "0.3.5"]


Use Langohr 2.3.2

Use Langohr 2.3.2

--- clojure/project.clj
+++ clojure/project.clj
@@ -4,4 +4,4 @@
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
   :dependencies [[org.clojure/clojure     "1.5.1"]
-                 [com.novemberain/langohr "1.7.0"]])
+                 [com.novemberain/langohr "2.3.2"]])


Centering build timings containers label.

--- src-cljs/frontend/components/build_timings.cljs
+++ src-cljs/frontend/components/build_timings.cljs
@@ -125,11 +125,13 @@
     (draw-containers! x-scale step)))

 (defn draw-label! [chart number-of-containers]
+  (let [[x-trans y-trans] [-25 (+ (/ (timings-height number-of-containers) 2) 40)]
+        rotation          -90]
   (-> chart
       (.append "text")
       (.attr "class" "y-axis-label")
-      (.attr "transform" (gstring/format "translate(%d,%d) rotate(%d)" -25 90 -90))
-      (.text "CONTAINERS")))
+      (.attr "transform" (gstring/format "translate(%d,%d) rotate(%d)" x-trans y-trans rotation))
+      (.text "CONTAINERS"))))

 (defn draw-axis! [chart axis class-name]
   (-> chart


CMR-1341: Fixing system int test project.

--- system-int-test/project.clj
+++ system-int-test/project.clj
@@ -13,6 +13,9 @@
                  ;; included for access to messages
                  [nasa-cmr/cmr-search-app "0.1.0-SNAPSHOT"]
                  [nasa-cmr/cmr-ingest-app "0.1.0-SNAPSHOT"]
+
+                 ;; Needed for access to cubby test util
+                 [nasa-cmr/cmr-cubby-app "0.1.0-SNAPSHOT"]

                  ;; included to allow access to catalog rest and db connection code
                  [nasa-cmr/cmr-bootstrap-app "0.1.0-SNAPSHOT"]


fix token transactions

fix token transactions

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

--- src/status_im/models/transactions.cljs
+++ src/status_im/models/transactions.cljs
@@ -137,12 +137,11 @@
 (defn- get-token-transfer-logs
   ;; NOTE(goranjovic): here we use direct JSON-RPC calls to get event logs because of web3 event issues with infura
   ;; we still use web3 to get other data, such as block info
-  [web3 current-block-number chain-tokens direction address cb]
+  [web3 current-block-number from-block chain-tokens direction address cb]
   {:pre [web3 (integer? current-block-number) (map? chain-tokens) (keyword? direction) (string? address) (fn? cb)]}
   (let [[from to] (if (= :inbound direction)
                     [nil (add-padding (ethereum/normalized-address address))]
                     [(add-padding (ethereum/normalized-address address)) nil])
-        from-block (limited-from-block current-block-number @latest-block-checked)
         args {:jsonrpc "2.0"
               :id      2
               :method  constants/web3-get-logs
@@ -150,15 +149,18 @@
                          :fromBlock from-block
                          :topics    [constants/event-transfer-hash from to]}]}
         payload (.stringify js/JSON (clj->js args))]
-    (reset! latest-block-checked current-block-number)
     (status/call-private-rpc payload
                              (response-handler web3 current-block-number chain-tokens direction ethereum/handle-error cb))))

 (defn- get-token-transactions
-  [web3 chain-tokens direction address cb]
-  {:pre [web3 (map? chain-tokens) (keyword? direction) (string? address) (fn? cb)]}
+  [web3 chain-tokens address cb]
+  {:pre [web3 (map? chain-tokens) (string? address) (fn? cb)]}
   (ethereum/get-block-number web3
-                             #(get-token-transfer-logs web3 % chain-tokens direction address cb)))
+                             (fn [current-block-number]
+                               (let [from-block (limited-from-block current-block-number @latest-block-checked)]
+                                 (reset! latest-block-checked current-block-number)
+                                 (get-token-transfer-logs web3 current-block-number from-block chain-tokens :inbound address cb)
+                                 (get-token-transfer-logs web3 current-block-number from-block chain-tokens :outbound address cb)))))

 ;; --------------------------------------------------------------------------
 ;; etherscan transactions
@@ -248,12 +250,10 @@
                           success-fn
                           error-fn
                           chaos-mode?)
-  (doseq [direction [:inbound :outbound]]
-    (get-token-transactions web3
-                            chain-tokens
-                            direction
-                            account-address
-                            success-fn)))
+  (get-token-transactions web3
+                          chain-tokens
+                          account-address
+                          success-fn))

 ;; -----------------------------------------------------------------------------
 ;; Helpers functions that help determine if a background sync should execute


pre-allocated lazy-seq EOF object, don't need a new one for every parsing

--- src/cheshire/core.clj
+++ src/cheshire/core.clj
@@ -90,15 +90,17 @@
      (.createJsonParser ^SmileFactory (or *smile-factory* smile-factory) bytes)
      true (or keywords? false) nil array-coerce-fn)))

+(def ^{:doc "Object used to determine end of lazy parsing attempt."}
+  eof (Object.))
+
 ;; Lazy parsers
 (defn- parsed-seq*
   "Internal lazy-seq parser"
   [^JsonParser parser ^Boolean keywords? array-coerce-fn]
-  (let [eof (Object.)]
-    (lazy-seq
-     (let [elem (parse parser true keywords? eof array-coerce-fn)]
-       (when-not (identical? elem eof)
-         (cons elem (parsed-seq* parser keywords? array-coerce-fn)))))))
+  (lazy-seq
+   (let [elem (parse parser true keywords? eof array-coerce-fn)]
+     (when-not (identical? elem eof)
+       (cons elem (parsed-seq* parser keywords? array-coerce-fn))))))

 (defn parsed-seq
   "Returns a lazy seq of Clojure objects corresponding to the JSON read from


tests for scale layers

tests for scale layers

--- test/cortex/layers_test.clj
+++ test/cortex/layers_test.clj
@@ -11,5 +11,12 @@
             [clojure.test.check.clojure-test :refer (defspec)]))

 (deftest test-scale
-  (let [a (layers/scale [2] [1 2] [30 40])]
-    (is (m/equals [31 42] (calc-output a [1 1])))))
+  (testing "array valued scale and constant"
+    (let [a (layers/scale [2] [1 2] [30 40])]
+     (is (m/equals [31 42] (calc-output a [1 1])))))
+  (testing "scalar scale and constant"
+    (let [a (layers/scale [2] 2 10)]
+      (is (m/equals [12 14] (calc-output a [1 2])))))
+  (testing "matrix values constant"
+    (let [a (layers/scale [2 2] nil 1)]
+      (is (m/equals [[2 3] [4 5]] (calc-output a [[1 2] [3 4]]))))))


Tag-prevent framework.

Tag-prevent framework.

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -668,6 +668,43 @@
   (when (>= (get-in @state [side :agenda-point]) (get-in @state [side :agenda-point-req]))
     (system-msg state side "wins the game")))

+
+(defn tag-prevent [state side n]
+  (swap! state update-in [:tag :tag-prevent] (fnil #(+ % n) 0)))
+
+(defn tag-count [state side n {:keys [unpreventable unboostable] :as args}]
+  (-> n
+      (+ (or (when (not unboostable) (get-in @state [:tag :tag-bonus])) 0))
+      (- (or (when (not unpreventable) (get-in @state [:tag :tag-prevent])) 0))
+      (max 0)))
+
+(defn resolve-tag [state side n args]
+  (when (pos? n)
+    (gain state :runner :tag n)
+    (trigger-event state side :runner-gain-tag n)))
+
+(defn tag-runner
+  ([state side n] (tag-runner state side n nil))
+  ([state side n {:keys [unpreventable unboostable card] :as args}]
+    (swap! state update-in [:tag] dissoc :tag-bonus :tag-prevent)
+    (trigger-event state side :pre-tag card)
+    (let [n (tag-count state side n args)]
+      (let [prevent (get-in @state [:prevent :tag :all])]
+        (if (and (pos? n) (not unpreventable) (pos? (count prevent)))
+          (do (system-msg state :runner "has the option to avoid tags")
+              (show-prompt
+                state :runner nil (str "Avoid any of the " n " tags?") ["Done"]
+                (fn [choice]
+                  (let [prevent (get-in @state [:tag :tag-prevent])]
+                    (system-msg state :runner
+                                (if prevent
+                                  (str "avoids " (if (= prevent Integer/MAX_VALUE) "all" prevent)
+                                       (if (< 1 prevent) " tags" " tag"))
+                                  "will not avoid tags"))
+                    (resolve-tag state side (max 0 (- n (or prevent 0))) args)))))
+          (resolve-tag state side n args))))))
+
+
 (defn resolve-trash [state side {:keys [zone type] :as card} {:keys [unpreventable cause keep-server-alive] :as args} & targets]
   (let [cdef (card-def card)
         moved-card (move state (to-keyword (:side card)) card :discard {:keep-server-alive keep-server-alive})]


prevent from going negative when paying or losing a quantity

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -32,11 +32,10 @@
                  (>= (- (get-in @state [side attr]) cost) 0))
                costs)
              (or (not forfeit-cost) (not (empty? scored))))
-      {:costs costs, :forfeit-cost forfeit-cost, :scored scored}
-    )))
+      {:costs costs, :forfeit-cost forfeit-cost, :scored scored})))

 (defn apply-loss [state side [attr value]]
-  (swap! state update-in [side attr] #(- (or % 0) value)))
+  (swap! state update-in [side attr] #(max 0 (- (or % 0) value))))

 (defn pay [state side card & args]
   (when-let [{:keys [costs forfeit-cost scored]} (apply can-pay? state side args)]


import api

import api

--- src/fugue/ide/ui.cljs
+++ src/fugue/ide/ui.cljs
@@ -1,6 +1,7 @@
 (ns fugue.ide.ui
   (:require [reagent.core :as r]
             [cljs.js]
+            [fugue.demo.demo-loader :as demo-loader]
             [fugue.ide.util :refer [log]]
             [fugue.ide.popup :as popup]
             [fugue.ide.editor :as editor]
@@ -14,7 +15,6 @@
   (s/layout
     state
     (fn [id name value active]
-      (print (::s/toggles state))
       [:div {:class-name (if active "window focused" "window")
              :on-mouse-down #(on-box-click id)}
        (cond
@@ -51,8 +51,9 @@
   {:eval cljs.js/js-eval
    :context :statement
    :load (fn [m cb]
-           (if-let [source (get-in state [:files (str :name m)])]
-             (cb {:lang :clj :source source})
+           (print m)
+           (if (= "live.api" (str (:name m)))
+             (cb {:lang :clj :source demo-loader/api})
              (cb nil)))})

 (defn on-eval [state result]


removing x permission

removing x permission