small fix

small fix

--- src/cljs/salava/extra/application/ui/application.cljs
+++ src/cljs/salava/extra/application/ui/application.cljs
@@ -346,12 +346,13 @@
 (defn pro-badges-grid [state]
   (let [show-issuer-info-atom (cursor state [:show-issuer-info])
         badges (shuffle-pro-badges 4 state)
-        badge-count (count badges)]
+        ;badge-count (count badges)
+        ]
     (when (and (not (empty? badges)) (not @show-issuer-info-atom))
       (into [:div.panel {:class "row wrap-grid"
                          :id    "grid"
                          :style {:padding "10px"}}
-             [:h3 [:i.fa.fa-star ] (str (if (> badge-count 1) (t :extra-application/Featuredbadges) (t :extra-application/Featuredbadge) ) " (" badge-count ")")]
+             [:h3 [:i.fa.fa-star ] (str (if (> badge-count 1) (t :extra-application/Featuredbadges) (t :extra-application/Featuredbadge) ) #_" (" badge-count ")")]
              [:hr]]
             (for [element-data badges]
               (badge-grid-element element-data state))))))


[#8] Commented out REPL play code

[#8] Commented out REPL play code

--- src/akvo/notifications/message_shredder.clj
+++ src/akvo/notifications/message_shredder.clj
@@ -85,4 +85,4 @@
     (lb/publish chan exchange queue message
                 :content-type "text/plain" :type "clojure.test")))

-(publish-message "Haj from Clojure!")
+                                        ; (publish-message "Haj from Clojure!")


Fix KLD for inconsistencies

Fix KLD for inconsistencies

--- src/angelic/search/summary_graphs_newer.clj
+++ src/angelic/search/summary_graphs_newer.clj
@@ -220,7 +220,26 @@
 ;; Find and locally update all nodes that need updating
 ;; Return a conservative estimate of nodes that may be in cycles
 ;; TODO: add cycle checking.
+;; Note we always include a node if its child in active set.
 (defn update-and-find-cycles! [active-nodes]
+  (let [active-set (IdentityHashMap.)]
+    (letfn [(add! [n]
+              (.put active-set n true)
+              (doseq [p (parent-nodes n)]
+                (chase! p n)))
+            (chase! [p c]
+              (when @(:summary-atom p)
+                (when-not (.containsKey active-set p)
+                  (when (or (update-summary-dec?! p)
+                            (some #(identical? (summary/source %) c) (summary/children (summary p))))
+                    (add! p)))))]
+      (doseq [n active-nodes]
+        (when (update-summary-dec?! n)
+          (add! n)))
+      (keys active-set))))
+
+(comment
+  (defn update-and-find-cycles! [active-nodes]
   (let [active-set (IdentityHashMap.)
         chase      (fn chase [n]
                      (when @(:summary-atom n)
@@ -231,7 +250,7 @@
                              (chase p))))))]
     (doseq [n active-nodes]
       (chase n))
-    (keys active-set)))
+    (keys active-set))))

 ;; Summaries of nodes may have decreased.  Propagate these changes upwards


[inbox] Only update-threads! when thread ids change

--- src/braid/core/client/ui/views/threads.cljs
+++ src/braid/core/client/ui/views/threads.cljs
@@ -66,7 +66,8 @@

        :component-will-receive-props
        (fn [this [_ next-props]]
-         (when (not= ((r/props this) :threads) (next-props :threads))
+         (when (not= (set (map :id ((r/props this) :threads)))
+                     (set (map :id (next-props :threads))))
            (update-threads! (next-props :threads))))

        :reagent-render


Use object interop in RenderQueue

Use object interop in RenderQueue

--- src/reagent/impl/batching.cljs
+++ src/reagent/impl/batching.cljs
@@ -1,9 +1,7 @@
 (ns reagent.impl.batching
   (:refer-clojure :exclude [flush])
-  (:require [reagent.debug :refer-macros [dbg assert-some]]
-            [reagent.impl.util :refer [is-client]]
-            [clojure.string :as string]
-            [goog.object :as gobj]))
+  (:require [reagent.debug :refer-macros [assert-some]]
+            [reagent.impl.util :refer [is-client]]))

 ;;; Update batching

@@ -42,48 +40,49 @@
 ;; Set from ratom.cljs
 (defonce ratom-flush (fn []))

-;; TODO: Use interop properties instead of gobj
+(defn run-funs [fs]
+  (dotimes [i (alength fs)]
+    ((aget fs i))))
+
+(defn enqueue [queue fs f]
+  (assert-some f "Enqueued function")
+  (.push fs f)
+  (.schedule queue ))
+
 (deftype RenderQueue [^:mutable ^boolean scheduled?]
   Object
-  (enqueue [this k f]
-    (assert-some f "Enqueued function")
-    (when (nil? (gobj/get this k))
-      (gobj/set this k (array)))
-    (.push (gobj/get this k) f)
-    (.schedule this))
-
-  (run-funs [this k]
-    (when-some [^array fs (gobj/get this k)]
-      (gobj/set this k nil)
-      (dotimes [i (alength fs)]
-        ((gobj/get fs i)))))
-
   (schedule [this]
     (when-not scheduled?
       (set! scheduled? true)
       (next-tick #(.run-queues this))))

   (queue-render [this c]
-    (.enqueue this "componentQueue" c))
+    (when (nil? (.-componentQueue this))
+      (set! (.-componentQueue this) (array)))
+    (enqueue this (.-componentQueue this) c))

   (add-before-flush [this f]
-    (.enqueue this "beforeFlush" f))
+    (when (nil? (.-beforeFlush this))
+      (set! (.-beforeFlush this) (array)))
+    (enqueue this (.-beforeFlush this) f))

   (add-after-render [this f]
-    (.enqueue this "afterRender" f))
+    (when (nil? (.-afterRender this))
+      (set! (.-afterRender this) (array)))
+    (enqueue this (.-afterRender this) f))

   (run-queues [this]
     (set! scheduled? false)
     (.flush-queues this))

   (flush-after-render [this]
-    (.run-funs this "afterRender"))
+    (run-funs (.-afterRender this)))

   (flush-queues [this]
-    (.run-funs this "beforeFlush")
+    (run-funs (.-beforeFlush this))
     (ratom-flush)
-    (when-some [cs (gobj/get this "componentQueue")]
-      (gobj/set this "componentQueue" nil)
+    (when-some [cs (.-componentQueue this)]
+      (set! (.-componentQueue this) nil)
       (run-queue cs))
     (.flush-after-render this)))


Remove unnecessary structure for completion candidates

--- src/reply/completion/jline.clj
+++ src/reply/completion/jline.clj
@@ -11,7 +11,7 @@
     (complete [^ConsoleReader reader ^java.util.List candidates pos]
       (let [buf (.getCursorBuffer reader)]
         (if (= 1 (.size candidates))
-          (let [value (:candidate (.get candidates 0))]
+          (let [value (.get candidates 0)]
             (if (= value (.toString buf))
               false
               (do (CandidateListCompletionHandler/setBuffer
@@ -24,11 +24,11 @@
               (CandidateListCompletionHandler/setBuffer
                 reader
                 (completion/get-unambiguous-completion
-                  (map :candidate candidates))
+                  candidates)
                 pos))
             (CandidateListCompletionHandler/printCandidates
               reader
-              (map :candidate candidates))
+              candidates)
             (.redrawLine reader)
             true))))))

@@ -38,17 +38,18 @@
       (let [buffer (or buffer "")
             prefix (or (completion/get-word-ending-at buffer cursor) "")
             prefix-length (.length prefix)
-            possible-completions (completion/get-candidates completions prefix)
-            get-full-completion (fn [candidate]
-                                  {:candidate candidate :buffer buffer})]
+            possible-completions (completion/get-candidates completions prefix)]
         (if (or (empty? possible-completions) (zero? prefix-length))
           -1
           (do
-            (.addAll candidates (map get-full-completion possible-completions))
+            (.addAll candidates possible-completions)
             (- cursor prefix-length)))))))

 (defn make-var-completer [ns]
-  (let [collections (concat (map keys ((juxt ns-publics ns-refers ns-imports) ns))
+  (let [collections (concat (map keys ((juxt ns-publics
+                                             ns-refers
+                                             ns-imports)
+                                       ns))
                             [(map str (all-ns))])]
     (make-completer
       (mapcat (comp sort (partial map str))


using :body_html propery to display post body

--- src/saved_for_reddit/core.cljs
+++ src/saved_for_reddit/core.cljs
@@ -9,7 +9,8 @@
             [alandipert.storage-atom :refer [local-storage]]
             [dommy.core :as dommy]
             [cljs-time.coerce :as timec]
-            [cljs-time.format :as timef])
+            [cljs-time.format :as timef]
+            [goog.string :refer [unescapeEntities]])
   (:require-macros [cljs.core.async.macros :refer [go]]))

 (enable-console-print!)
@@ -44,9 +45,9 @@

 (defn post-html [p]
   (let [link? (nil? (:title p))
-        title (if link? (:link_title p) (:title p))
+        title (unescapeEntities (if link? (:link_title p) (:title p)))
         url (if link? (:link_url p) (:url p))
-        body (:body p)
+        body (if (not (nil? (:body_html p))) (unescapeEntities (:body_html p)))
         subreddit (:subreddit p)
         author (:author p)
         created-on-epoch-local (+ (:created_utc p) (* 3600 (.getTimezoneOffset (js/Date.))))
@@ -57,8 +58,7 @@
        [:a {:href url} title] " "
        [:a {:href (str "https://www.reddit.com/r/" subreddit)} [:span {:class "badge"} subreddit]]]]
      [:div {:class "panel-body"}
-      (if (not (clojure.string/blank? body))
-        [:p body [:br]])
+      [:div {:dangerouslySetInnerHTML {:__html body}}]
       [:small "submitted by " [:a {:href (str "https://www.reddit.com/user/" author)} [:small author]]
        " on " created-on-str]]]))


reorganize examples

reorganize examples

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -206,100 +206,7 @@

 ;; --------------------------------------------------------
-;; Example 4-a: Adding logs around functions
-;; --------------------------------------------------------
-
-(defn log-enter-message
-  [fct-name arg-list arg-values]
-  (str
-    "Entering the function " fct-name " with args "
-    (vec (mapcat vector arg-list arg-values))))
-
-(defn compile-log-message
-  [form bindings]
-  (let [fct-name (-> form second str)]
-    `(log-enter-message ~fct-name (quote ~bindings) ~bindings)
-    ))
-
-(defmacro defn-log
-  [name bindings body]
-  `(defn ~name
-     ~bindings
-     (println ~(compile-log-message &form bindings))
-     ~body))
-
-(defn-log add-with-log
-  [a b]
-  (+ a b))
-
-(defn test-add-with-log
-  []
-  (println
-    (walk/macroexpand-all
-      '(defn-log add-with-log [a b] (+ a b))))
-  (add-with-log 1 2))
-
-;; --------------------------------------------------------
-;; Example 4-b: Adding logs based on run time option (no overhead)
-;; --------------------------------------------------------
-
-(def default-logger (partial println "INFO:"))
-(def logger (atom default-logger))
-
-(defmacro defn-log-2
-  [name bindings body]
-  `(defn ~name
-     ~bindings
-     (if-let [log-fct# @logger]
-       (log-fct# ~(compile-log-message &form bindings)))
-     ~body))
-
-(defn-log-2 add-with-log-2
-  [a b]
-  (+ a b))
-
-(defn test-add-with-log-2
-  []
-  (reset! logger default-logger)
-  (println (add-with-log-2 1 2))
-  (reset! logger nil)
-  (println (add-with-log-2 1 2))
-  (reset! logger default-logger))
-
-;; --------------------------------------------------------
-;; Example 4-c: Adding logs based on compile time option (no overhead)
-;; --------------------------------------------------------
-
-(def ^:const log-config-file
-  "./src/clj/algorithms_clj/macro_initiation_resource.edn")
-
-(defn logger-enabled?
-  "Read whether the log should be enabled by reading config file"
-  []
-  (let [log-config (read-string (slurp log-config-file))]
-    (-> log-config :log :enabled?)))
-
-(defmacro defn-log-3
-  [name bindings body]
-  (if (logger-enabled?)
-    `(defn-log-2 ~name
-       ~bindings
-       ~body)
-    `(defn ~name
-       ~bindings
-       ~body)))
-
-(defn-log-3 add-with-log-3
-  [a b]
-  (+ a b))
-
-(defn test-add-with-log-3
-  []
-  (reset! logger default-logger)
-  (println (add-with-log-3 1 2)))
-
-;; --------------------------------------------------------
-;; Example 5: Generating some code based on data structure
+;; Example 4: Generating some code based on data structure
 ;; - Go iteratively?
 ;; - Show the example of efficient loop generation
 ;; --------------------------------------------------------
@@ -457,6 +364,100 @@

 ;; --------------------------------------------------------
+;; Example 5-a: Adding logs around functions
+;; --------------------------------------------------------
+
+(defn log-enter-message
+  [fct-name arg-list arg-values]
+  (str
+    "Entering the function " fct-name " with args "
+    (vec (mapcat vector arg-list arg-values))))
+
+(defn compile-log-message
+  [form bindings]
+  (let [fct-name (-> form second str)]
+    `(log-enter-message ~fct-name (quote ~bindings) ~bindings)
+    ))
+
+(defmacro defn-log
+  [name bindings body]
+  `(defn ~name
+     ~bindings
+     (println ~(compile-log-message &form bindings))
+     ~body))
+
+(defn-log add-with-log
+  [a b]
+  (+ a b))
+
+(defn test-add-with-log
+  []
+  (println
+    (walk/macroexpand-all
+      '(defn-log add-with-log [a b] (+ a b))))
+  (add-with-log 1 2))
+
+;; --------------------------------------------------------
+;; Example 5-b: Adding logs based on run time option (no overhead)
+;; --------------------------------------------------------
+
+(def default-logger (partial println "INFO:"))
+(def logger (atom default-logger))
+
+(defmacro defn-log-2
+  [name bindings body]
+  `(defn ~name
+     ~bindings
+     (if-let [log-fct# @logger]
+       (log-fct# ~(compile-log-message &form bindings)))
+     ~body))
+
+(defn-log-2 add-with-log-2
+  [a b]
+  (+ a b))
+
+(defn test-add-with-log-2
+  []
+  (reset! logger default-logger)
+  (println (add-with-log-2 1 2))
+  (reset! logger nil)
+  (println (add-with-log-2 1 2))
+  (reset! logger default-logger))
+
+;; --------------------------------------------------------
+;; Example 5-c: Adding logs based on compile time option (no overhead)
+;; --------------------------------------------------------
+
+(def ^:const log-config-file
+  "./src/clj/algorithms_clj/macro_initiation_resource.edn")
+
+(defn logger-enabled?
+  "Read whether the log should be enabled by reading config file"
+  []
+  (let [log-config (read-string (slurp log-config-file))]
+    (-> log-config :log :enabled?)))
+
+(defmacro defn-log-3
+  [name bindings body]
+  (if (logger-enabled?)
+    `(defn-log-2 ~name
+       ~bindings
+       ~body)
+    `(defn ~name
+       ~bindings
+       ~body)))
+
+(defn-log-3 add-with-log-3
+  [a b]
+  (+ a b))
+
+(defn test-add-with-log-3
+  []
+  (reset! logger default-logger)
+  (println (add-with-log-3 1 2)))
+
+
+;; --------------------------------------------------------
 ;; Example 6: DFS to do a topological sort
 ;; - You list a bunch of dependencies
 ;; - You get a list of tasks to run


getting digest from manifest list

getting digest from manifest list

#441

--- src/clj/swarmpit/docker/registry/client.clj
+++ src/clj/swarmpit/docker/registry/client.clj
@@ -30,6 +30,6 @@
   (-> (execute {:method  :GET
                 :api     (str "/" repository-name "/manifests/" repository-tag)
                 :options {:headers {:Authorization (str "Bearer " token)
-                                    :Accept        "application/vnd.docker.distribution.manifest.v2+json"}}})
+                                    :Accept        "application/vnd.docker.distribution.manifest.list.v2+json"}}})
       :headers
-      :docker-content-digest))+      :docker-content-digest))


PDB-67 Switch add-resources! and add-edges! to use catalog id instead of hash

For performance reasons, its better if we use a catalog id for both the
functions add-resources! and add-edges! so we can avoid the need to do a
select beforehand.

With this in mind this patch changes the behaviour of add-catalog-metadata! to
return the full generated id's so we can pluck out the id and use that later
for add-resources! and add-edges!.

Signed-off-by: Ken Barber <470bc578162732ac7f9d387d34c4af4ca6e1b6f7@bob.sh>

--- src/com/puppetlabs/puppetdb/scf/storage.clj
+++ src/com/puppetlabs/puppetdb/scf/storage.clj
@@ -198,16 +198,17 @@
     (pos? (first replaced))))

 (defn add-catalog-metadata!
-  "Given some catalog metadata, persist it in the db"
+  "Given some catalog metadata, persist it in the db. Returns a map of the
+  inserted data including any autogenerated columns."
   [hash api-version catalog-version transaction-uuid]
   {:pre [(string? hash)
          (number? api-version)
          (string? catalog-version)
-         ((some-fn nil? string?) transaction-uuid)]}
-  (sql/insert-record :catalogs {:hash             hash
-                                :api_version      api-version
-                                :catalog_version  catalog-version
-                                :transaction_uuid transaction-uuid}))
+         ((some-fn nil? string?) transaction-uuid)]
+   :post [(map? %)]}
+  (sql/insert-values :catalogs
+    [:hash :api_version :catalog_version :transaction_uuid]
+    [hash api-version catalog-version transaction-uuid]))

 (defn update-catalog-metadata!
   "Given some catalog metadata, update the db"
@@ -252,7 +253,7 @@

   The result map has the following format:

-    {:resource [[<resouce hash> <type> <title> <tags> <exported?> <sourcefile> <sourceline> <catalog hash>] ...]
+    {:resource [[<catalog id> <resouce hash> <type> <title> <tags> <exported?> <sourcefile> <sourceline>] ...]
      :parameters [[<resource hash> <name> <value>] ...]
      :parameters_cache [[<resource hash> <parameters>] ...]}

@@ -262,10 +263,11 @@
   1. Each key corresponds to a table, and each value is a list of rows
   2. The mapping of keys and values to table names and columns is done
      by `add-resources!`"
-  [catalog-hash {:keys [type title exported parameters tags file line] :as resource} resource-hash persisted?]
-  {:pre  [(every? string? #{catalog-hash type title})]
+  [catalog-id {:keys [type title exported parameters tags file line] :as resource} resource-hash persisted?]
+  {:pre  [(number? catalog-id)
+          (every? string? #{type title})]
    :post [(= (set (keys %)) #{:resource :parameters :parameters_cache})]}
-  (let [values {:resource         [[resource-hash type title (sutils/to-jdbc-varchar-array tags) exported file line catalog-hash]]
+  (let [values {:resource         [[catalog-id resource-hash type title (sutils/to-jdbc-varchar-array tags) exported file line]]
                 :parameters       []
                 :parameters_cache []}]

@@ -278,13 +280,13 @@

 (defn add-resources!
   "Persist the given resource and associate it with the given catalog."
-  [catalog-hash refs-to-resources refs-to-hashes]
+  [catalog-id refs-to-resources refs-to-hashes]
   (let [persisted?      (resources-exist? (utils/valset refs-to-hashes))
         resource-values (for [[ref resource] refs-to-resources
                               :let [hash (refs-to-hashes ref)]]
-                          (resource->values catalog-hash resource hash (persisted? hash)))
+                          (resource->values catalog-id resource hash (persisted? hash)))
         lookup-table    [[:parameters_cache "INSERT INTO resource_params_cache (resource, parameters) VALUES (?, ?)"]
-                         [:resource "INSERT INTO catalog_resources (catalog_id,resource,type,title,tags,exported,file,line) SELECT id,?,?,?,?,?,?,? FROM catalogs WHERE hash = ?"]
+                         [:resource "INSERT INTO catalog_resources (catalog_id,resource,type,title,tags,exported,file,line) VALUES (?,?,?,?,?,?,?,?)"]
                          [:parameters "INSERT INTO resource_params (resource,name,value) VALUES (?,?,?)"]]]
     (sql/transaction
      (doseq [[lookup the-sql] lookup-table
@@ -301,16 +303,16 @@

   For example, if the source of an edge is {'type' 'Foo' 'title' 'bar'},
   then we'll lookup a resource with that key and use its hash."
-  [catalog-hash edges refs-to-hashes]
-  {:pre [(string? catalog-hash)
+  [catalog-id edges refs-to-hashes]
+  {:pre [(number? catalog-id)
          (coll? edges)
          (map? refs-to-hashes)]}
-  (let [the-sql "INSERT INTO edges (catalog_id,source,target,type) SELECT id,?,?,? FROM catalogs WHERE hash=?"
+  (let [the-sql "INSERT INTO edges (catalog_id,source,target,type) VALUES (?,?,?,?)"
         rows    (for [{:keys [source target relationship]} edges
                       :let [source-hash (refs-to-hashes source)
                             target-hash (refs-to-hashes target)
                             type        (name relationship)]]
-                  [source-hash target-hash type catalog-hash])]
+                  [catalog-id source-hash target-hash type])]
     (apply sql/do-prepared the-sql rows)))

 (defn add-catalog!
@@ -337,12 +339,12 @@

               (when-not exists?
                 (inc! (:new-catalog metrics))
-                (add-catalog-metadata! hash api-version version transaction-uuid)
-                (let [refs-to-hashes (zipmap (keys resources) resource-hashes)]
+                (let [catalog-id     (:id (add-catalog-metadata! hash api-version version transaction-uuid))
+                      refs-to-hashes (zipmap (keys resources) resource-hashes)]
                   (time! (:add-resources metrics)
-                         (add-resources! hash resources refs-to-hashes))
+                         (add-resources! catalog-id resources refs-to-hashes))
                   (time! (:add-edges metrics)
-                         (add-edges! hash edges refs-to-hashes))))))
+                         (add-edges! catalog-id edges refs-to-hashes))))))

            hash)))


Simplify batch

Simplify batch

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -96,12 +96,11 @@

 (defn insert-batch
   [table records]
-  (execute
-   (render-query
-    (query/batch-query
-     (apply
-      query/queries
-      (map #(query/insert-query table %) records))))))
+  (->> (map #(query/insert-query table %) records)
+       (apply query/queries)
+       query/batch-query
+       render-query
+       execute))

 (defn update
   [& query-params]


Sort required namespaces

Sort required namespaces

--- src/com/billpiel/sayid/nrepl_middleware.clj
+++ src/com/billpiel/sayid/nrepl_middleware.clj
@@ -1,19 +1,20 @@
 (ns com.billpiel.sayid.nrepl-middleware
-  (:require [clojure.stacktrace :as st]
-            [com.billpiel.sayid.core :as sd]
-            [com.billpiel.sayid.query2 :as q]
-            [com.billpiel.sayid.string-output2 :as so]
-            [com.billpiel.sayid.view :as v]
-            [com.billpiel.sayid.trace :as tr]
-            [clojure.tools.reader :as r]
-            [clojure.tools.reader.reader-types :as rts]
-            [com.billpiel.sayid.util.other :as util]
-            [clojure.tools.namespace.find :as ns-find]
-            [com.billpiel.sayid.util.find-ns :as find-ns]
-            [tamarin.core :as tam]
-            [nrepl.middleware :refer [set-descriptor!]]
-            [nrepl.misc :refer [response-for]]
-            [nrepl.transport :as t]))
+  (:require
+   [clojure.stacktrace :as st]
+   [clojure.tools.namespace.find :as ns-find]
+   [clojure.tools.reader :as r]
+   [clojure.tools.reader.reader-types :as rts]
+   [com.billpiel.sayid.core :as sd]
+   [com.billpiel.sayid.query2 :as q]
+   [com.billpiel.sayid.string-output2 :as so]
+   [com.billpiel.sayid.trace :as tr]
+   [com.billpiel.sayid.util.find-ns :as find-ns]
+   [com.billpiel.sayid.util.other :as util]
+   [com.billpiel.sayid.view :as v]
+   [nrepl.middleware :refer [set-descriptor!]]
+   [nrepl.misc :refer [response-for]]
+   [nrepl.transport :as t]
+   [tamarin.core :as tam]))

 (def views (atom {}))
 (def selected-view (atom nil))


very rough first draft of a point spec

very rough first draft of a point spec

--- src/tile_game/coordinates.cljc
+++ src/tile_game/coordinates.cljc
@@ -1,4 +1,6 @@
-(ns tile-game.coordinates)
+(ns tile-game.coordinates
+  (:require [clojure.spec :as s]
+            [clojure.spec.gen :as gen]))

 (defn ^:private abs
   [x]
@@ -13,6 +15,8 @@
 (defn add [[x y] [dx dy]]
   [(+ x dx) (+ y dy)])

+(s/def ::point (s/tuple int? int?))
+(comment (gen/sample (s/gen ::point)))
 (defn adjacent-to
   "Lists adjacent coordinates in clockwise order"
   [p]


nothing really

nothing really

--- src/turbo_eureka/ios/core.cljs
+++ src/turbo_eureka/ios/core.cljs
@@ -32,7 +32,6 @@
       (let [[val c] (alts! [input closer])]
         (when-not (or (= c closer) (nil? val))
           (try
-            (println val)
             (some-> @webview (.postMessage val))
             (catch :default e
               (.trace js/console e)))
@@ -54,11 +53,6 @@
                        :on-message #(a/put! output %)}]])
        :component-will-unmount
          (fn [_] (a/put! closer :close) (a/close! closer))})))
-
-
-
-
-

 (defn selection-view [action-channel]
   (let [drag-model (atom {:dragging? false
@@ -87,8 +81,6 @@

               [view {:style (-> s/selection-view :details)}
                 [text (:description item)]]]))))))
-
-

 (defn list-view-item [action-channel item]
   [touchable-opacity {:on-press #(a/put! action-channel [:list-item-view/select item])}


Support agenda callback

Support agenda callback

--- org-mode/src/com/gfredericks/org_agenda.clj
+++ org-mode/src/com/gfredericks/org_agenda.clj
@@ -469,11 +469,8 @@
             lt))))))

 (defn write-to-agenda-file
-  [deets-by-file {:keys [preamble] :as cfg} now]
-  (let [today (.toLocalDate now)
-        {:keys [triage deadlines by-day past-log]} (synthesize-agenda deets-by-file today)
-        custom-prefix (:custom-prefix cfg (constantly nil))
-        format-todo (fn [{:keys [done todo priority-cookie header] :as item}]
+  [agenda cfg]
+  (let [format-todo (fn [{:keys [done todo priority-cookie header] :as item}]
                       (format "%s%s %s%s%s"
                               (cond-> (or done todo)
                                 (= "[#C]" priority-cookie)
@@ -481,7 +478,7 @@
                               (if priority-cookie
                                 (str " " priority-cookie)
                                 "")
-                              (if-let [prefix (custom-prefix today item)]
+                              (if-let [prefix (:custom-prefix item)]
                                 (str prefix " ")
                                 "")
                               (if (:repeat? item)
@@ -504,7 +501,7 @@
                                            (if (= 1 (priority item))
                                              "  "
                                              "")
-                                           (if-let [lt (later-today-time item now)]
+                                           (if-let [lt (:later-today-time item)]
                                              (format "(not until %s) " lt)
                                              "")
                                            (format-todo item)))
@@ -516,7 +513,7 @@
                               (filter first)
                               (sort-by first)
                               (run! (fn [[[t1 t2] item]]
-                                      (let [past? (compare/< (.atZone (or t2 t1) CHICAGO) now)
+                                      (let [past? (:past? item)
                                             t1 (.toLocalTime t1)
                                             t2 (some-> t2 .toLocalTime)]
                                         (printf "      %s%s%s: %s %s\n"
@@ -532,93 +529,124 @@
                                                   (:header item))
                                                 ;; once we figure out enough elisp to stop using links this
                                                 ;; can just be implicit
-                                                (make-org-link item "(link)")))))))]
+                                                (make-org-link item "(link)")))))))
+        {:keys [deadlines triage today future past]} agenda]
     (with-atomic-write-to cfg
-      (when preamble
+      (when-let [preamble (:preamble cfg)]
         (println preamble))
       (when (seq deadlines)
         (println "== DEADLINES ==")
         (println "(TODO: show upcoming deadlines based on the -0d cookie)")
-        (doseq [item (sort-by (juxt (comp - priority) :created-at :file :line-number) deadlines)]
+        (doseq [item deadlines]
           (print-todo-line item {}))
         (println))
       (when (seq triage)
         (println "== TRIAGE ==")
-        (doseq [item (sort-by (juxt (comp - priority) :created-at :file :line-number) triage)]
+        (doseq [item triage]
           (print-todo-line item {}))
         (println))
-      (let [stats-by-date
-            (into {}
-                  (for [[date {:keys [todos calendar-events]}] (sort by-day)
-                        :let [[total-cal-time count-without-duration] (summarize-calendar-events calendar-events)]]
-                    [date
-                     {:unefforted-count (->> todos
-                                             (remove :effort)
-                                             ;; TODO: this is calculated in two places; either make a
-                                             ;; function or add a :needs-effort? attr to the map
-                                             (remove #(= "t" (get (:properties %) "EFFORT_EXEMPT")))
-                                             (count))
-                      :total-effort (->> todos
-                                         (keep :effort)
-                                         (reduce #(.plus %1 %2) Duration/ZERO))
-                      :total-cal-time total-cal-time
-                      :count-without-duration count-without-duration}]))]
-        (doseq [[date {:keys [todos calendar-events]}] (sort by-day)
-                :when (compare/<= today date)
-                :let [{:keys [unefforted-count total-effort total-cal-time count-without-duration]}
-                      (stats-by-date date)]]
-          (println (format "== %s =="
-                           (if (= date today)
-                             "TODAY"
-                             (format-org-local-date date))))
-          (when-not (.isZero total-effort)
-            (println (format "  Total effort: %s" (format-effort total-effort))))
-          (when-not (.isZero total-cal-time)
-            (println (format "  Total calendar time: %s" (format-effort total-cal-time))))
-          (when (pos? unefforted-count)
-            (println (format "# (%d items with no effort estimate)" unefforted-count)))
-          (when (pos? count-without-duration)
-            (println (format "# (%d calendar items with no duration)" count-without-duration)))
+      (let [print-stats
+            (fn [{:keys [total-effort total-cal-time unefforted-count count-without-duration]}]
+              (when-not (.isZero total-effort)
+                (println (format "  Total effort: %s" (format-effort total-effort))))
+              (when-not (.isZero total-cal-time)
+                (println (format "  Total calendar time: %s" (format-effort total-cal-time))))
+              (when (pos? unefforted-count)
+                (println (format "# (%d items with no effort estimate)" unefforted-count)))
+              (when (pos? count-without-duration)
+                (println (format "# (%d calendar items with no duration)" count-without-duration))))]
+        (println "== TODAY ==")
+        (let [{:keys [stats todos calendar-events]} today]
+          (when-not stats
+            (throw (ex-info "Dang 1" {})))
+          (print-stats stats)
           (print-calendar calendar-events)
-          ;; TODO: we shouldn't be putting things in the calendar if they're
-          ;; scheduled in the past...
-          (->> todos
-               (sort-by (juxt #(later-today-time % now) ;; put future things at the bottom
-                              (comp - priority)
-                              ;; move rep entries to the bottom for the future blocks, so that
-                              ;; nonrepeating items stick out
-                              (if (= date today) (constantly nil) :repeat?)
-                              relevant-date
-                              :file
-                              :line-number))
-               (run! (fn [item] (print-todo-line item {}))))
-          (when (= date today)
-            (println "\n\n--------------------------------------------------------------------------------")
-            (println "|                                  future                                      |")
-            (println "--------------------------------------------------------------------------------")
-            (print-table ["date" "tot" "-e" "-d" "tot-e" "tot-d"]
-                         (for [date (sort (keys by-day))
-                               :when (compare/< today date)
-                               :let [{:keys [unefforted-count total-effort total-cal-time count-without-duration]}
-                                     (stats-by-date date)]]
-                           {"date"  (format-org-local-date date)
-                            "tot"   (format-effort (.plus total-effort total-cal-time))
-                            "-e"    unefforted-count
-                            "-d"    count-without-duration
-                            "tot-e" (format-effort total-effort)
-                            "tot-d" (format-effort total-cal-time)})))
+          (run! #(print-todo-line % {}) todos))
+        (println "\n\n--------------------------------------------------------------------------------")
+        (println "|                                  future                                      |")
+        (println "--------------------------------------------------------------------------------")
+        (print-table ["date" "tot" "-e" "-d" "tot-e" "tot-d"]
+                     (for [[date {:keys [stats]}] future
+                           :let [{:keys [unefforted-count total-effort total-cal-time count-without-duration]} stats]]
+                       {"date"  (format-org-local-date date)
+                        "tot"   (format-effort (.plus total-effort total-cal-time))
+                        "-e"    unefforted-count
+                        "-d"    count-without-duration
+                        "tot-e" (format-effort total-effort)
+                        "tot-d" (format-effort total-cal-time)}))
+        (println)
+        (doseq [[date {:keys [todos calendar-events stats]}] future]
+          (println (format "== %s ==" (format-org-local-date date)))
+          (when-not stats
+            (throw (ex-info "Dang" {})))
+          (print-stats stats)
+          (print-calendar calendar-events)
+          (run! #(print-todo-line % {}) todos)
           (println)))
       (println "\n\n--------------------------------------------------------------------------------")
       (println "|                                   past                                       |")
       (println "--------------------------------------------------------------------------------")
-      (doseq [[date {:keys [calendar-events past-log]}] (reverse (sort by-day))
-              :when (compare/<= date today)]
+      (doseq [[date {:keys [calendar-events past-log]}] past]
         (println)
         (println (format "== LOG: %s ==" (format-org-local-date date)))
         (print-calendar calendar-events)
         (doseq [item past-log]
           (print-todo-line item {:omit-effort? true}))))))

+(defn calculate-agenda
+  [deets-by-file cfg now]
+  (let [today (.toLocalDate now)
+        {:keys [triage deadlines by-day past-log]} (synthesize-agenda deets-by-file today)
+        custom-prefix (:custom-prefix cfg (constantly nil))
+        stats-by-date (into {}
+                            (for [[date {:keys [todos calendar-events]}] (sort by-day)
+                                  :let [[total-cal-time count-without-duration] (summarize-calendar-events calendar-events)]]
+                              [date
+                               {:unefforted-count (->> todos
+                                                       (remove :effort)
+                                                       ;; TODO: this is calculated in two places; either make a
+                                                       ;; function or add a :needs-effort? attr to the map
+                                                       (remove #(= "t" (get (:properties %) "EFFORT_EXEMPT")))
+                                                       (count))
+                                :total-effort (->> todos
+                                                   (keep :effort)
+                                                   (reduce #(.plus %1 %2) Duration/ZERO))
+                                :total-cal-time total-cal-time
+                                :count-without-duration count-without-duration}]))
+        not-past (for [[date {:keys [todos calendar-events]}] (sort by-day)
+                       :when (compare/<= today date)]
+                   [date {:stats          (stats-by-date date)
+                          :todos          (->> todos
+                                               (map #(assoc %
+                                                            :later-today-time (later-today-time % now)
+                                                            :custom-prefix (custom-prefix today %)))
+                                               (sort-by (juxt :later-today-time ;; put future things at the bottom
+                                                              (comp - priority)
+                                                              ;; move rep entries to the bottom for the future blocks, so that
+                                                              ;; nonrepeating items stick out
+                                                              (if (= date today) (constantly nil) :repeat?)
+                                                              relevant-date
+                                                              :file
+                                                              :line-number)))
+                          :calendar-events (->> calendar-events
+                                                (map (juxt timetable-slot identity))
+                                                (filter first)
+                                                (sort-by first)
+                                                (map (fn [[[t1 t2] item]]
+                                                       (let [past? (compare/< (.atZone (or t2 t1) CHICAGO) now)
+                                                             t1 (.toLocalTime t1)
+                                                             t2 (some-> t2 .toLocalTime)]
+                                                         (assoc item
+                                                                :timetable-slot [t1 t2]
+                                                                :past? past?)))))}])]
+    {:deadlines (sort-by (juxt (comp - priority) :created-at :file :line-number) deadlines)
+     :triage    (sort-by (juxt (comp - priority) :created-at :file :line-number) triage)
+     :today     (second (first not-past))
+     :future    (rest not-past)
+     :past      (for [[date :as date+item] (reverse (sort by-day))
+                      :when (compare/<= date today)]
+                  date+item)}))
+
 (defn all-agenda-data
   [directory now]
   (into {} (for [file (all-org-files directory)]
@@ -627,10 +655,20 @@
 (defn do-once
   [{:keys [directory] :as cfg} now]
   (let [by-file (all-agenda-data directory now)]
-    (write-to-agenda-file by-file cfg now)))
+    (write-to-agenda-file (calculate-agenda by-file cfg now) cfg)))

 (defn watch
-  [{:keys [directory reset-all-file] :as cfg}]
+  "cfg:
+
+  :directory        the directory containing org files
+  :agenda-file      the file the agenda will be written to
+  :reset-all-file   a file which, when touched, causes *all* org files
+                    to be reloaded
+  :refresh-file     a file which, when touched, triggers a regeneration
+                    of the agenda
+  :callback         (optional) function of the agenda data that is called
+                    each time the agenda changes"
+  [{:keys [directory reset-all-file callback] :as cfg}]
   (let [q (LinkedBlockingQueue.)]
     (run! #(.add q %) (all-org-files directory))
     (let [do-refresh-all (fn []
@@ -661,7 +699,10 @@
                     by-file (into by-file
                                   (for [file all]
                                     [file (agenda-data-for-file file today)]))]
-                (write-to-agenda-file by-file cfg now)
+                (let [agenda (calculate-agenda by-file cfg now)]
+                  (write-to-agenda-file agenda cfg)
+                  (when callback
+                    (callback agenda)))
                 (log/infof "Updated at %s with %d changed files in %dms"
                            (pr-str (java.util.Date.))
                            (count all)


Clarify a TODO comment on pages events.

Clarify a TODO comment on pages events.

--- src/uxbox/main/data/pages.cljs
+++ src/uxbox/main/data/pages.cljs
@@ -172,7 +172,7 @@
   [event]
   (instance? PagePersisted event))

-;; TODO: add specs
+;; TODO: add page spec

 (defn page-persisted
   [data]


Adds utility function to easily clear localStorage

--- src/wordsmith/persistence.cljs
+++ src/wordsmith/persistence.cljs
@@ -23,3 +23,9 @@
   (let [ks (.keys js/Object js/localStorage)
         filtered (filter #(= (.substring % 0 prefix-length) prefix) ks)]
     (mapv #(.substring % prefix-length) filtered)))
+
+(defn clear-local-storage []
+  (doseq [t (get-all-titles)]
+    (remove-document t)))
+
+(aset js/window "clearLocalStorage" wordsmith.persistence/clear-local-storage)


:bug: Fix strange bug on db connection handling.

This need investigation.

--- backend/src/uxbox/db.clj
+++ backend/src/uxbox/db.clj
@@ -27,7 +27,7 @@
                   (assoc :password password)
                   (str))]
     (log/info "creating connection pool with" dburi)
-    (pg/pool dburi {:system system :max-size 8})))
+    (pg/pool dburi {:system system :max-size 1})))

 (defstate pool
   :start (create-pool cfg/config system))


commented first-cycle-type again

commented first-cycle-type again

--- src/mafia_votecount/scraper/team_liquid.clj
+++ src/mafia_votecount/scraper/team_liquid.clj
@@ -265,10 +265,10 @@
                      (drop-while #(< (first %) first-index))
                      (into (sorted-map)))
         cycle-posts (cycle-changes indexed hosts)
-        first-cycle-type (-> (first cycle-posts)
-                             (val)
-                             (:message)
-                             (is-cycle-change?))
+       ; first-cycle-type (-> (first cycle-posts)
+       ;                      (val)
+       ;                      (:message)
+       ;                      (is-cycle-change?))
         day-ranges (-> cycle-posts
                        (keys)
                        ; hosts can just add a line break before the night 0 message though so maybe not so important after all...?


코드내용 -> 소스내용

코드내용 -> 소스내용


game update working

game update working

--- src/shl/controllers/game.clj
+++ src/shl/controllers/game.clj
@@ -9,19 +9,10 @@
             [shl.dao.game :as dao]))

 (defn update [gameid home-goals away-goals overtime shootout playdate]
-  (when-not (and (str/blank? gameid)
-                 (str/blank? home-goals)
-                 (str/blank? away-goals)
-                 (str/blank? overtime)
-                 (str/blank? shootout)
-                 (str/blank? playdate))
-    (dao/update-game (Integer/parseInt gameid)
-                     (Integer/parseInt home-goals)
-                     (Integer/parseInt away-goals)
-                     (Boolean/valueOf overtime)
-                     (Boolean/valueOf shootout)
-                     (time/parse time-utils/formatter playdate)))
-  (response (dao/get-game (Integer/parseInt gameid))))
+  (when-not (nil? playdate)
+    (dao/update-game gameid home-goals away-goals overtime shootout
+                    (time/parse time-utils/formatter playdate)))
+  (response (dao/get-game gameid)))

 (defn get-conference-games [conferenceid]
   (response (dao/get-conference-games (Integer/parseInt conferenceid))))
@@ -29,7 +20,7 @@
 (defroutes app-routes
   (context "/games" [] (defroutes game-routes
     (GET ["/conference/:id/" :id #"[0-9]+"] [id] (get-conference-games id))
-    (POST "/" [gameid homegoals awaygoals
+    (POST "/" [id homegoals awaygoals
               overtime shootout playdate]
-      (update gameid homegoals awaygoals overtime shootout playdate)))))
+      (update id homegoals awaygoals overtime shootout playdate)))))