remove advancements from stolen agendas

remove advancements from stolen agendas

--- src/clj/game/core.clj
+++ src/clj/game/core.clj
@@ -884,13 +884,12 @@
   (gain-agenda-point state side n))

 (defn steal [state side card]
-  (let [c (move state :runner card :scored)]
+  (let [c (move state :runner (dissoc card :advance-counter) :scored)]
     (resolve-ability state :runner (:stolen (card-def c)) c nil)
     (system-msg state :runner (str "steals " (:title c) " and gains " (:agendapoints c)
                                    " agenda point" (when (> (:agendapoints c) 1) "s")))
     (swap! state update-in [:runner :register :stole-agenda] #(+ (or % 0) (:agendapoints c)))
     (gain-agenda-point state :runner (:agendapoints c))
-    (set-prop state :runner c :advance-counter 0)
     (when-let [current (first (get-in @state [:corp :current]))]
       (say state side {:user "__system__" :text (str (:title current) " is trashed.")})
       (trash state side current))


more checker

more checker

--- src/clj/neb/types.clj
+++ src/clj/neb/types.clj
@@ -79,6 +79,7 @@
              :checker char?
              :example [\a \测 \å \∫ \≤ \œ]}
    :text    {:id      3 :dynamic? true
+             :checker string?
              :example ["The morpueus engine" "这是一段测试文本 abc"]
              :encoder (fn [^String string] (.getBytes string string-encoding))
              :decoder (fn [^bytes byte-arr] (String. byte-arr string-encoding))
@@ -118,22 +119,27 @@
              :checker (fn [uuid] (instance? UUID uuid))
              :example [`(UUID/randomUUID) `(UUID/randomUUID)]}
    :pos2d   {:id      15
+             :checker (fn [p2d] (and (coll? p2d) (= 2 (count p2d))))
              :example [[1.0, 2.0] [3.0 4.0]]
              :encoder double-array
              :decoder vec}
    :pos3d   {:id      16
+             :checker (fn [p3d] (and (coll? p3d) (= 3 (count p3d))))
              :example [[1.0, 2.0 3.0] [3.0 4.0 5.0]]
              :encoder double-array
              :decoder vec}
    :pos4d   {:id      17
+             :checker (fn [p4d] (and (coll? p4d) (= 4 (count p4d))))
              :example [[1.0, 2.0 3.0 1024.0] [3.0 4.0 4096.0 12.0]]
              :encoder double-array
              :decoder vec}
    :geo     {:id      18
+             :checker (fn [p2d] (and (coll? p2d) (= 2 (count p2d))))
              :example [`(map float [31.12 121.30]) `(map float [40.30 71.51])]
              :encoder float-array
              :decoder vec}
    :date    {:id      19
+             :checker (fn [d] (instance? Date d))
              :example [`(Date.)]}
    :obj     {:id      20 :dynamic? true
              :encoder nippy/freeze


Remove index from article content, which caused some errors

--- src/clojournal/db.clj
+++ src/clojournal/db.clj
@@ -10,6 +10,5 @@

 (defn create-indexes []
   (mc/ensure-index db "articles" (array-map :title 1) {:name "by-title"})
-  (mc/ensure-index db "articles" (array-map :content 1) {:name "by-content"})
   (mc/ensure-index db "articles" (array-map :author 1) {:name "by-author"})
   (mc/ensure-index db "articles" (array-map :tags 1) {:name "by-tags"}))


import backend progress

import backend progress

--- src/dbquery/core.clj
+++ src/dbquery/core.clj
@@ -71,16 +71,19 @@
                {:status 401 :body "invalid user or password"})
              (fn [e] {:status 500 :body (.getMessage e)}))))

+(defn read-csv [file separator has-header]
+  (let [csv (csv/read-csv (FileReader. file) :separator separator)
+        first (first csv)]
+    {:header (if has-header first (for [i (range  (count first))] (str "Col" i)))
+     :rows (if has-header (rest csv) csv)}
+    )
+  )
+
 (defn handle-file-upload [{{file :file separator :separator has-header :hasHeader} :params}]
   ;; extract
   (log/info "separator:" separator)
-  (let [csv (csv/read-csv (FileReader. (file :tempfile)) :separator (.charAt separator 0))
-        first (first csv)
-        has-header? (Boolean/parseBoolean has-header)
-        header (if has-header? first (for [i (range  (count first))] (str "Col" i)))
-        rows (if has-header? (rest csv) csv)
-        ]
-    {:body {:header header :rows (take 4 rows) :file (.getAbsolutePath (file :tempfile))}})
+  (let [{header :header rows :rows} (read-csv (file :tempfile) (.charAt separator 0) (Boolean/parseBoolean has-header))]
+    {:body {:header header :rows (take 4 rows) :file (.getName (file :tempfile))}})
   )

 (defn handle-exec-sql [req ds-id]
@@ -114,11 +117,13 @@
   (let [ds (get-ds ds-id)]
     {:body  (data-types ds)}))

-(defn handle-data-import [ds-id {{file-details :fileDetails dest :dest} :body}]
+(defn handle-data-import [ds-id {{{file :file separator :separator header :has-header} :inputFile dest :dest} :body}]
   (let [ds (get-ds ds-id)
         table (if (= "_" (dest :table))
                 (create-table ds (dest :newTable) (dest :columns) nil)
                 (dest :table))
+        filePath (System/getProperties)
+        data (read-csv (file :tempfile) (.charAt separator 0) (Boolean/parseBoolean has-header))
         result (load-data ds table file-details (dest :mappings))]
     {:body result}
     )


fmt-bash takes argument specifying function name

--- src/nml/core.clj
+++ src/nml/core.clj
@@ -200,7 +200,7 @@

 ;; formatting

-(defn- fmt-bash [m]
+(defn- fmt-bash [m fname]
   (let [ms  (sort m)
         eq #(string/replace % "\"" "\\\"")
         f0  (fn [[dataref values]]
@@ -209,7 +209,7 @@
         f1  (fn [[name nvseq]]
               (let [x (strmap f0 nvseq)]
                 (str "'" name "') case \"$2\" in " x "*) echo '';;esac;;" )))]
-    (str "ooo(){ case \"$1\" in " (strmap f1 ms) "*) echo '';;esac; }\n")))
+    (str fname "(){ case \"$1\" in " (strmap f1 ms) "*) echo '';;esac; }\n")))

 (defn- fmt-namelist [m]
   (let [f0 (fn [[dataref values]]


src/wlmmap/i18n.clj: Fix typo

src/wlmmap/i18n.clj: Fix typo

--- src/wlmmap/i18n.clj
+++ src/wlmmap/i18n.clj
@@ -14,7 +14,7 @@
                  :b "This map has been developed during "
                  :c "It allows you to explore cultural heritage treasures of the world."
                  :d "Blue markers are for monuments with a photo."
-                 :e "Red markers are for monuments without one."
+                 :e "Red markers are for monuments without a photo."
                  :f "All the pictures are from "
                  :g ", available under a free license."
                  :h "The code behind this website is available from "
@@ -26,15 +26,13 @@
                 :about "À propos"
                 :links "Liens"}
          :links {:intro "Ces liens directs affichent immédiatement les monuments sur la carte."}
-         :about {
-                 :a "À propos"
+         :about {:a "À propos"
                  :b "Cette carte a été développée pour "
                  :c "Elle permet d'explorer les monuments historiques du monde entier."
                  :d "Les points en rouge indiquent des monuments avec photo."
-                 :e "Les points en bleu indiquent des monuments <b>sans</b> photo."
+                 :e "Les points en bleu indiquent des monuments sans photo."
                  :f "Toutes les images viennent de "
                  :g ", disponibles sous licence libre."
                  :h "Le code derrière ce site web est disponible depuis "
                  :i "J'apprécie les remarques, critiques et suggestions! "
-                 :j "Envoyez-moi un e-mail"
-                 }}}})
+                 :j "Envoyez-moi un e-mail"}}}})


Fix not.

Fix not.

--- src/quil/applet.clj
+++ src/quil/applet.clj
@@ -350,7 +350,7 @@
                               (catch Exception e
                                 (println "Exception in Quil draw-fn for sketch" title ": " e "\nstacktrace: " (with-out-str (print-cause-trace e)))
                                 (Thread/sleep 1000))))
-        draw-fn           (if (not (:no-safe-draw options)) safe-draw-fn draw-fn)
+        draw-fn           (if (:no-safe-draw options) draw-fn safe-draw-fn)

         on-close-fn       (let [close-fn (or (:on-close options) no-fn)]
                             (if (:exit-on-close options)


Docstring grammar

Docstring grammar

--- src/fatlip/plot.cljs
+++ src/fatlip/plot.cljs
@@ -789,7 +789,7 @@

 (defn plot
-  "Generates coordinates all paths in a FlatGraph"
+  "Generates coordinates for all paths in a FlatGraph"
   [flat-graph max-slope min-arc-radius layer-sep node-sep char-sep]
   (let [{:keys [layers characters]} flat-graph
         node-ys (FlatGraph->node-ys flat-graph node-sep char-sep)


fix exception handling for failed emails

--- src/pc/email.clj
+++ src/pc/email.clj
@@ -195,10 +195,10 @@
     (try+
       (log/infof "sending access-grant email for %s" eid)
       (send-access-grant-email db eid)
-      (catch Object e
-        (.printStackTrace e)
+      (catch Object t
+        (.printStackTrace (:throwable &throw-context))
         (unmark-sent-email eid :email/access-grant-created)
-        (throw+ e)))
+        (throw+ t)))
     (log/infof "not re-sending access-grant email for %s" eid)))

 (defmethod send-entity-email :email/access-request-created
@@ -207,10 +207,10 @@
     (try+
       (log/infof "sending access-request email for %s" eid)
       (send-access-request-email db eid)
-      (catch Exception e
-        (.printStackTrace e)
+      (catch Object t
+        (.printStackTrace (:throwable &throw-context))
         (unmark-sent-email eid :email/access-request-created)
-        (throw+ e)))
+        (throw+ t)))
     (log/infof "not re-sending access-request email for %s" eid)))


Implement majority of the defentity macro code generation

--- src/main/workflo/macros/entity.clj
+++ src/main/workflo/macros/entity.clj
@@ -42,6 +42,13 @@
   (let [entity (resolve-entity entity-name)]
     (:schema entity)))

+;;;; Utilities
+
+(defn prefixed-form-name
+  [form prefix]
+  (symbol (str (ns-name *ns*))
+          (str (util/prefix-form-name (:form-name form) prefix))))
+
 ;;;; The defentity macro

 (s/fdef defentity*
@@ -52,8 +59,44 @@
   ([name forms]
    (defentity* name forms nil))
   ([name forms env]
-   `(do
-      )))
+   (let [args-spec       :workflo.macros.specs.entity/defentity-args
+         args            (if (s/valid? args-spec [name forms])
+                           (s/conform args-spec [name forms])
+                           (throw (Exception.
+                                   (s/explain-str args-spec
+                                                  [name forms]))))
+         description     (:description (:forms args))
+         auth            (:auth (:forms args))
+         validation      (:validation (:forms args))
+         schema          (:schema (:forms args))
+         forms           (-> (:forms args)
+                             (select-keys [:auth :validation :schema])
+                             (vals))
+         name-sym        (util/unqualify name)
+         forms-map       (zipmap (map (comp keyword :form-name) forms)
+                                 (map #(prefixed-form-name % name-sym)
+                                      forms))
+         auth-form       (when auth
+                           `((~'defn ~(util/prefix-form-name 'auth
+                                                             name-sym)
+                              []
+                              ~@(:form-body auth))))
+         validation-form (when validation
+                           `((~'def ~(util/prefix-form-name 'validation
+                                                            name-sym)
+                              ~@(:form-body validation))))
+         schema-form     (when schema
+                           `((~'def ~(util/prefix-form-name 'schema
+                                                            name-sym)
+                              ~@(:form-body schema))))
+         definition      `(~'def ~(util/prefix-form-name 'definition
+                                                         name-sym)
+                           ~forms-map)]
+     `(do
+        ~@auth-form
+        ~@validation-form
+        ~@schema-form
+        ~definition))))

 (defmacro defentity
   [name & forms]


Add missing `*` on tmp-dir constant.

Add missing `*` on tmp-dir constant.

--- src/datoteka/core.clj
+++ src/datoteka/core.clj
@@ -55,7 +55,7 @@
 (def ^:dynamic *cwd* (pt/-path (.getCanonicalPath (java.io.File. "."))))
 (def ^:dynamic *sep* (System/getProperty "file.separator"))
 (def ^:dynamic *home* (pt/-path (System/getProperty "user.home")))
-(def ^:dynamic *tmp-dir (pt/-path (System/getProperty "java.io.tmpdir")))
+(def ^:dynamic *tmp-dir* (pt/-path (System/getProperty "java.io.tmpdir")))
 (def ^:dynamic *no-follow* (LinkOption/values))
 (def ^:dynamic *os-name* (System/getProperty "os.name"))
 (def ^:dynamic *system* (if (.startsWith *os-name* "Windows") :dos :unix))


Return results as-is

Return results as-is

--- worker/src/patavi/worker/pirate/core.clj
+++ worker/src/patavi/worker/pirate/core.clj
@@ -95,6 +95,6 @@
         (let [call (format "exec(%s, params)" method)
               result (pirate/parse R call)]
           {:method method
-           :results (assoc (json/decode result)
-                      :_embedded (pirate/retrieve R "files"))}))
+           :results (json/decode result)
+           :_embedded (pirate/retrieve R "files")}))
       (catch Exception e (throw (Exception. (cause e) e))))))


Remove Closure ns that not longer exists

--- planck-cljs/src/planck/bundle.cljs
+++ planck-cljs/src/planck/bundle.cljs
@@ -91,7 +91,6 @@
    [goog.iter.Iterator]
    [goog.json]
    [goog.json.EvalJsonProcessor]
-   [goog.json.HybridJsonProcessor]
    [goog.json.NativeJsonProcessor]
    [goog.json.Replacer]
    [goog.json.Reviver]


cleaned the records business that we are not even using

--- src/crawler/dom.clj
+++ src/crawler/dom.clj
@@ -130,6 +130,37 @@
            (.getValue))
        (catch Exception e nil)))

+(defn child-position
+  [parent a-w3c-node]
+  (let [child-node-list (.getChildNodes parent)
+        child-nodes-cnt (.getLength child-node-list)]
+    (.indexOf
+     (map
+      #(.isSameNode
+        a-w3c-node
+        (.item child-node-list %))
+      (range child-nodes-cnt))
+     true)))
+
+(defn is-first-child?
+  [a-w3c-node]
+  (let [parent (.getParentNode a-w3c-node)]
+    (and parent
+         (= 0 (child-position
+               parent a-w3c-node)))))
+
+(defn is-last-child?
+  [a-w3c-node]
+  (let [parent (.getParentNode a-w3c-node)]
+    (and parent
+         (=
+          (-
+           (.getLength
+            (.getChildNodes parent))
+           1)
+          (child-position
+           parent a-w3c-node)))))
+
 (defn tag-id-class-node
   "Returns a list containing a tag's name, its id
 - formatted slightly - and its classes - formatted slightly"
@@ -140,25 +171,34 @@
         silent-fail-attr  (fn [attr key] (try (.getValue
                                               (.getNamedItem attr key))
                                              (catch Exception e nil)))
+

-        attributes        (.getAttributes a-w3c-node)]
-
-    (list (.getNodeName a-w3c-node)
+        attributes        (.getAttributes a-w3c-node)
+
+        is-first?         (is-first-child? a-w3c-node)
+
+        is-last?          (is-last-child? a-w3c-node)]
+
+    (list (.getNodeName a-w3c-node)               ; name
           (-> attributes
               (silent-fail-attr "id")
-              format-attr)
+              format-attr)                        ; id
           (map
            format-attr
            (-> attributes
                (silent-fail-attr "class")
-               (silent-fail-split #"\s+"))))))
+               (silent-fail-split #"\s+")))       ; class
+
+          is-first?
+
+          is-last?)))

 (defn tag-id-class->xpath
   "Args:
     a-tag-id-class : a tag, its id and a list of classes
    Returns:
     a component that fits in an xpath"
-  [[tag id class-list]]
+  [[tag id class-list is-first? is-last?]]
   (let [formatted-id      (format "contains(@id,'%s')" id)
         formatted-classes (map
                            #(format "contains(@class,'%s')" %)
@@ -166,8 +206,24 @@

     (if (not (empty? class-list))
-      (map #(format "%s[%s]" tag %) formatted-classes)
-      (list tag))))
+      (map #(cond (and (not is-first?)
+                       (not is-last?))
+                  (format "%s[%s]" tag %)
+
+                  is-first?
+                  (format "%s[%s][1]" tag %)
+
+                  is-last?
+                  (format "%s[%s][last()]" tag %)) formatted-classes)
+      (cond (and (not is-first?)
+                 (not is-last?))
+            (list tag)
+
+            is-first?
+            (list (format "%s[1]" tag))
+
+            is-last?
+            (list (format "%s[last()]" tag))))))

 (defn tag-node->xpath
   [a-tagnode]
@@ -276,25 +332,30 @@
                                       (.getAttributes)
                                       (.getNamedItem "href"))
                                   (try
-                                    (not= (-> a-tag
-                                              (.getAttributes)
-                                              (.getNamedItem "rel")
-                                              (.getValue))
-                                          "nofollow")
+                                    (not=
+                                     (-> a-tag
+                                         (.getAttributes)
+                                         (.getNamedItem "rel")
+                                         (.getValue))
+                                     "nofollow")
                                     (catch NullPointerException e true))

-                                  (not= (uri/scheme (-> a-tag
-                                                        (.getAttributes)
-                                                        (.getNamedItem "href")
-                                                        (.getValue)))
-                                        "javascript")
-                                  (not (some #{(uri/resolve-uri
-                                                url
-                                                (-> a-tag
-                                                    (.getAttributes)
-                                                    (.getNamedItem "href")
-                                                    (.getValue)))}
-                                             (set blacklist)))))
+                                  (not=
+                                   (uri/scheme
+                                    (-> a-tag
+                                        (.getAttributes)
+                                        (.getNamedItem "href")
+                                        (.getValue)))
+                                   "javascript")
+                                  (not
+                                   (some
+                                    #{(uri/resolve-uri
+                                       url
+                                       (-> a-tag
+                                           (.getAttributes)
+                                           (.getNamedItem "href")
+                                           (.getValue)))}
+                                    (set blacklist)))))
                            a-tags)

            nodes-xpaths   (map
@@ -310,286 +371,15 @@
                                               (.getNamedItem "href")
                                               (.getValue))]
                                  {:node x
-                                  :href (try (uri/fragment
-                                              (uri/resolve-uri url link) nil)
-                                             (catch Exception e nil))
-                                  :text (-> x
-                                            (.getTextContent))}))
+                                  :href (try
+                                          (uri/fragment
+                                           (uri/resolve-uri url link)
+                                           nil)
+                                          (catch Exception e nil))
+                                  :text (.getTextContent x)}))
                              a-tags-w-hrefs)))]

        (reduce
         (fn [acc [an-xpath node]]
-          (merge-with concat acc {an-xpath [node]})) {} nodes-xpaths))))
-
-(defn minimum-maximal-xpath-set-processed
-  "This helper routine exists so we don't reparse
-the page several times"
-  [processed-pg]
-  (let [a-tags        ($x:node+ ".//a" processed-pg)
-
-        href-nodes    (filter
-                       identity (map #(-> %
-                                          (.getAttributes)
-                                          (.getNamedItem "href"))
-                                     a-tags))
-
-        links         (set (map #(.getNodeValue %) href-nodes))
-
-        xpaths-a-tags (map
-                       first
-                       (reverse
-                        (sort-by
-                         second
-                         (anchor-tag-xpaths-nodes a-tags))))]
-
-    (:xpaths (-> (reduce
-                  (fn [acc xpath]
-                    (let [xpath-links (set
-                                       (filter
-                                        #(not (re-find file-format-ignore-regex %))
-                                        (filter
-                                         identity
-                                         (map #(try (uri/fragment (-> % :attrs :href StringEscapeUtils/unescapeHtml) nil)
-                                                    (catch Exception e nil))
-                                              ($x xpath processed-pg)))))]
-                      (if (= (clj-set/intersection (:links acc) xpath-links)
-                             xpath-links)
-                        acc
-                        (merge-with clj-set/union acc {:links  xpath-links
-                                                       :xpaths #{xpath}}))))
-                  {:xpaths (set [])
-                   :links  (set [])}
-                  xpaths-a-tags)))))
-
-(defn minimum-maximal-xpath-set
-  "A maximal xpath set is a set of xpaths
-sufficient to span all the anchor tags on a
-page. The minimum here refers to the cardinality
-of the xpath set."
-  [page-src src-link]
-  (let [processed (html->xml-doc page-src)
-        xpaths    (minimum-maximal-xpath-set-processed processed)]
-    (reduce
-     (fn [acc [xpath hrefs]]
-       (merge-with clojure.set/union acc {xpath hrefs}))
-     {}
-     (map
-      vector
-      xpaths
-      (map
-       (fn [xpath]
-         (set
-          (filter
-           #(not (re-find file-format-ignore-regex (first %)))
-           (filter
-            #(-> % first identity)
-            (map
-             (fn [res]
-               (let [link (-> res
-                              :attrs
-                              :href
-                              StringEscapeUtils/unescapeHtml)
-                     text (->> res
-                               :text
-                               utils/tokenize)]
-                 [(try
-                    (uri/resolve-uri
-                     src-link
-                     (uri/fragment
-                      (if (= "javascript" (uri/scheme link))
-                        nil link)
-                      nil))
-                    (catch Exception e nil))
-                  text]))
-             (filter
-              identity ($x xpath processed))))))) xpaths)))))
-
-(defn node-path-to-root
-  "A version of path-root-seq for
-org.w3c.dom.Node objects"
-  ([a-node]
-     (node-path-to-root a-node []))
-
-  ([a-node cur-path]
-     (let [parent (.getParentNode a-node)]
-       (if parent
-         (recur parent (cons a-node cur-path))
-         (cons a-node cur-path)))))
-
-(defn xpath->records
-  "Nodes that are immediate children of the LCA
-of the nodes returned by an xpath.
-Processed page is the output of html->xml-doc.
-This routine is not correct and we don't really
-care about its correctness for now"
-  [xpath processed-page]
-  (let [nodes ($x:node+ xpath processed-page)]
-    (loop [cur-nodes nodes prev-nodes []]
-      (let [potential-parent (reduce (fn [acc v]
-                                       (if (and acc
-                                                (.isSameNode acc v))
-                                         acc
-                                         nil))
-                                     cur-nodes)]
-        (if-not potential-parent
-          (recur (map #(.getParentNode %) cur-nodes) cur-nodes)
-          (reduce (fn [acc v]
-                    (if (empty? acc)
-                      [v]
-                      (if (.isSameNode (last acc) v)
-                        acc
-                        (conj acc v))))
-                  []
-                  prev-nodes))))))
-
-(defn tooltips
-  [a-node]
-  (try
-    ($x:text+ ".//@title" a-node)
-    (catch RuntimeException e '())))
-
-(defn relative-dates
-  [a-node]
-  (filter
-   #(= (count %) 1)
-   (map
-    dates/dates-in-text
-    (tooltips a-node))))
-
-(defn neighborhood-text
-  "Text from the neighborhood of the elements
-returned by this xpath on our page"
-  [xpath processed-page]
-  (map #(dates/dates-in-text
-         (str/join
-          " "
-          (str/split (.getTextContent %) #"\s+")))
-       (xpath->records xpath processed-page)))
-
-(defn xpath-records-dates-processed-page
-  [xpath processed-page]
-  (let [num-records      (count
-                          (xpath->records
-                           xpath processed-page))
-
-        dategroups-found (count
-                          (filter
-                           (fn [x] (> (count x) 0))
-                           (neighborhood-text xpath processed-page)))]
-
-    (when-not (= num-records 0)
-      {:ratio (/ dategroups-found num-records)
-       :num-records num-records})))
-
-(defn xpath-records-dates
-  "An xpath returns nodes. We check how many of these
-result in nodes that are indexed by a clear date"
-  [xpath processed-pg]
-  (xpath-records-dates-processed-page xpath processed-pg))
-
-(defn xpaths-ranked
-  ([page-src]
-     (xpaths-ranked page-src 0.70))
-  ([page-src ratio]
-     (let [processed-pg (html->xml-doc page-src)
-           xpaths       (:xpaths (minimum-maximal-xpath-set-processed processed-pg))]
-       (reverse
-        (sort-by
-         (fn [x] (:num-records (second x)))
-         (filter
-          #(> (:ratio (second %)) ratio)
-          (filter
-           #(identity (second %))
-           (map (fn [xpath]
-                  (list
-                   xpath
-                   (xpath-records-dates xpath processed-pg)))
-                xpaths))))))))
-
-(defn same-node-set?
-  "Checks if the nodes returned are the same"
-  [node-set1 node-set2]
-  (reduce
-   (fn [out-acc a-node]
-     (and
-      out-acc
-      (reduce
-       (fn [acc another-node]
-         (or acc (.isEqualNode a-node another-node)))
-       false
-       node-set2)))
-   true
-   node-set1))
-
-(defn xpath-nodes
-  [xpath page-src]
-  (let [processed (html->xml-doc page-src)]
-    ($x:node+ xpath processed)))
-
-(defn equal-xpaths?
-  "Xpaths are equal either if the strings are the same
-or the returned records/nodes in the page are the same"
-  [xpath1 xpath2 page-src]
-  (or (= xpath1 xpath2)
-      (same-node-set? (xpath-nodes xpath1 page-src)
-                      (xpath-nodes xpath2 page-src))))
-
-(defn resolve-anchor-nodes
-  ([xpath node]
-     (resolve-anchor-nodes xpath node node))
-  ([xpath node stored]
-   (let [parent-node                (.getParentNode node)
-         anchor-children            ($x:node+ ".//a" parent-node)
-         xpaths-to-anchor-children  (reduce
-                                     (fn [acc x]
-                                       (merge-with + acc {x 1}))
-                                     {}
-                                     (map #(first (xpath-to-node %)) anchor-children))]
-
-     (cond (> (xpaths-to-anchor-children xpath) 1)
-           [(first (xpath-to-node node)) node]
-
-           (= (.getNodeName parent-node) "#document")
-           [xpath stored]
-
-           :else
-           (recur xpath parent-node stored)))))
-
-(defn minimum-maximal-xpath-records
-  "Given a set of xpaths, we compute the xpaths that
-are sufficient to generate all the distinct records"
-  [xpaths processed-page]
-
-  (let [xpath-nodes      (map #($x:node+ % processed-page) xpaths)
-        xpaths-nodes-map (into {} (map vector xpaths xpath-nodes))
-        potential-recs   (map (fn [[xpath nodes]]
-                                (map (fn [node]
-                                       (resolve-anchor-nodes xpath node)) nodes))
-                              xpaths-nodes-map)]
-    (into {}
-          (map
-           (fn [[xpath nodes]]
-             [xpath (distinct nodes)])
-           (reduce
-            (fn [acc [xpath node]]
-              (merge-with concat acc {xpath [node]}))
-            {}
-            (partition 2 (flatten potential-recs)))))))
-
-(defn date-indexed-records-filter
-  "records-sets: returned by minimum-maximal-xpath-records"
-  [records-sets]
-  (first
-   (filter
-    #(> (count %) 5)
-    records-sets)))
-
-(defn node-text
-  "Text = text nodes + tooltips"
-  [a-node]
-  (apply
-   str
-   (.getTextContent a-node)
-   (str/join " " (tooltips a-node))))
-
-
+          (merge-with
+           concat acc {an-xpath [node]})) {} nodes-xpaths))))


1.3-ifying examples.simple-regression

1.3-ifying examples.simple-regression

--- src/examples/simple_regression.clj
+++ src/examples/simple_regression.clj
@@ -3,8 +3,8 @@
 ;; Lee Spector, lspector@hampshire.edu, 2010

 (ns examples.simple-regression
-  (:require [clojush] [clojure.contrib.math])
-  (:use [clojush] [clojure.contrib.math]))
+  (:use [clojush]
+	[clojure.math.numeric-tower]))

 ;;;;;;;;;;;;
 ;; Integer symbolic regression of x^3 - 2x^2 - x (problem 5 from the


player is centered in the middle

player is centered in the middle

--- src/runner/dom.cljs
+++ src/runner/dom.cljs
@@ -29,6 +29,7 @@
             (dom/div nil
                      (dom/p nil (controller-keys (:controller state)))))))

+
 ;; screen coordinates
 ;; ----------------------------------------------------------------------------

@@ -38,13 +39,16 @@
 (def screen-height (fn [_] js/window.innerHeight))

-
-
 ;; player view
 ;; ----------------------------------------------------------------------------

-(defn player-width [radius]
-  (let [width (* radius physics-to-pixel 2)
+(defn player-width
+  "on-screen width"
+  [radius]
+  (* radius physics-to-pixel 2))
+
+(defn ps-size [radius]
+  (let [width (player-width radius)
         radius (/ width 2)]
     {:width width
      :height width
@@ -52,17 +56,22 @@
      :-moz-border-radius radius
      :border-radius radius}))

-(defn player-position [x y]
+(defn player-x
+  "on-screen x position"
+  [radius]
+  (- (/ (screen-width) 2) (* radius physics-to-pixel)))
+
+(defn ps-position [x y radius]
   {:bottom (js/Math.round (* physics-to-pixel y))
-   :left (js/Math.round (* physics-to-pixel x))})
+   :left (js/Math.round (player-x radius))})

 (defn player-style
   "construct a style string from a js array. e.g position = #js [0, 9.8]"
   [player]
   (clj->js (merge {:position "absolute"
                   :background-color "orange"}
-                 (player-width (:radius player))
-                 (player-position (:x player) (:y player)))))
+                 (ps-size (:radius player))
+                 (ps-position (:x player) (:y player) (:radius player)))))

 (defn player-view [player owner]
@@ -71,12 +80,6 @@
     (render [_]
             (dom/div #js {:style (player-style player)} "player"))))

-;; width: 50px;
-;; height: 50px;
-;; -webkit-border-radius: 25px;
-;; -moz-border-radius: 25px;
-;; border-radius: 25px;
-;; background-color:orange;

 ;; game view/wrapper
 ;; ----------------------------------------------------------------------------


Lint error

Lint error

--- src/metabase/util/infer_spaces.clj
+++ src/metabase/util/infer_spaces.clj
@@ -7,15 +7,15 @@

 ; # Build a cost dictionary, assuming Zipf's law and cost = -math.log(probability).
 ; words = open("words-by-frequency.txt").read().split()
-(def words (s/split-lines (slurp (io/file (io/resource "words-by-frequency.txt")))))
+(def ^:const ^:private words (s/split-lines (slurp (io/file (io/resource "words-by-frequency.txt")))))

 ; wordcost = dict((k, log((i+1)*log(len(words)))) for i,k in enumerate(words))
-(def word-cost
+(def ^:const ^:private word-cost
   (apply hash-map (flatten (map-indexed
     (fn [idx word] [word (Math/log (* (+ idx 1) (Math/log (count words))))]) words))))

 ; maxword = max(len(x) for x in words)
-(def max-word (apply max (map count words)))
+(def ^:const ^:private max-word (apply max (map count words)))

 ; def infer_spaces(s):
 ;     """Uses dynamic programming to infer the location of spaces in a string
@@ -27,7 +27,7 @@
 ;     def best_match(i):
 ;         candidates = enumerate(reversed(cost[max(0, i-maxword):i]))
 ;         return min((c + wordcost.get(s[i-k-1:i], 9e999), k+1) for k,c in candidates)
-(defn best-match
+(defn- best-match
   [i s cost]
   (let [candidates (reverse (subvec cost (max 0 (- i max-word)) i))]
     (apply min-key first (map-indexed (fn [k c] [(+ c (get word-cost (subs s (- i k 1) i) 9e9999)) (+ k 1)]) candidates))))
@@ -37,7 +37,7 @@
 ;     for i in range(1,len(s)+1):
 ;         c,k = best_match(i)
 ;         cost.append(c)
-(defn build-cost-array
+(defn- build-cost-array
   [s]
   (loop [i 1
          cost [0]]
@@ -57,6 +57,7 @@
 ;
 ;     return " ".join(reversed(out))
 (defn infer-spaces
+  "Splits a string with no spaces into words using magic"
   [input]
   (let [s (s/lower-case input)
         cost (build-cost-array s)]


Small `content-pre-wrap` refactor; pass only `pod` instead of `options`, and make it optional

--- src/io/perun.clj
+++ src/io/perun.clj
@@ -115,7 +115,7 @@
       (commit fileset tmp))))

 (defn content-pre-wrap
-  [parse-form file-exts tracer options]
+  [parse-form file-exts tracer & [pod]]
   (let [tmp     (boot/tmp-dir!)
         prev-fs (atom nil)]
     (boot/with-pre-wrap fileset
@@ -124,7 +124,7 @@
                                (boot/by-ext file-exts)
                                add-filedata)
             input-metadata (->>
-                            (if-let [pod (:pod options)]
+                            (if pod
                               (pod/with-call-in @pod ~(parse-form changed-files))
                               (eval (parse-form changed-files)))
                             (trace tracer))
@@ -183,12 +183,12 @@
   [m meta    META edn "metadata to set on each entry; keys here will be overridden by metadata in each file"
    o options OPTS edn "options to be passed to the markdown parser"]
   (let [pod     (create-pod markdown-deps)
-        options (merge +markdown-defaults+ {:pod pod} *opts*)]
+        options (merge +markdown-defaults+ *opts*)]
     (content-pre-wrap
-     (fn [files] `(io.perun.markdown/parse-markdown ~files ~(dissoc options :pod)))
+     (fn [files] `(io.perun.markdown/parse-markdown ~files ~options))
      ["md" "markdown"]
      :io.perun/markdown
-     options)))
+     pod)))

 (deftask global-metadata
   "Read global metadata from `perun.base.edn` or configured file.


add CSS overflow to GCSFilePreviewLink

add CSS overflow to GCSFilePreviewLink

--- src/cljs/org/broadinstitute/firecloud_ui/common/dialog.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/dialog.cljs
@@ -112,7 +112,7 @@
                [OKCancelForm
                 {:header "File Details"
                  :content (react/create-element
-                            [:div {}
+                            [:div {:style {:overflow "auto"}}
                              (labeled "Google Bucket" (:bucket-name props))
                              (labeled "Object" (:object props))
                              (when (:loading? @state)


Extraneous space

Extraneous space

--- src/grimoire/api.clj
+++ src/grimoire/api.clj
@@ -134,7 +134,6 @@
           :when (<= (semver/cmp v current) 0)]
       (path->thing (str (thing->path v) "/" unv-path)))))

-
 ;; Read things
 ;;--------------------
 (defn read-notes


Write the empty map not nil

Write the empty map not nil

--- src/grimoire/doc.clj
+++ src/grimoire/doc.clj
@@ -315,7 +315,7 @@
           ;; write placeholder meta
           ;;----------------------------------------
           (reduce (fn [acc f]
-                    (api/write-meta (:datastore config) acc nil)
+                    (api/write-meta (:datastore config) acc {})
                     (f acc))
                   (t/->Group groupid)
                   [#(t/->Artifact % artifactid)
@@ -349,7 +349,7 @@
           ;; write placeholder meta
           ;;----------------------------------------
           (reduce (fn [acc f]
-                    (api/write-meta (:datastore config) acc nil)
+                    (api/write-meta (:datastore config) acc {})
                     (f acc))
                   (t/->Group groupid)
                   [#(t/->Artifact % artifactid)


If close requested, close via send on last element

This allows zero or 1 element seqs to be treated the same way as single
return value sends, so for http, no stream is created.

--- web/src/immutant/web/async.clj
+++ web/src/immutant/web/async.clj
@@ -150,15 +150,13 @@
                            (assoc options
                              :on-success #(deliver latch nil)
                              :on-error   (partial deliver latch)
-                             :close?     false))
+                             :close?     (and close? (not (seq items)))))
                          (if-let [err @latch]
                            (notify ch on-error err)
                            (when (seq items)
                              (recur (first items) (rest items)))))))]
         (when-not (= ::notified result)
-          (notify ch on-success)))
-      (when close?
-        (close ch))))
+          (notify ch on-success)))))

   File
   (dispatch-message [message ch options]


Fix syntax error on ui (introduced in previous commit).

--- frontend/src/uxbox/main/ui.cljs
+++ frontend/src/uxbox/main/ui.cljs
@@ -166,7 +166,7 @@

 (defn init
   []
-  (rt/init routes))
+  (rt/init routes)
   (mx/mount (app) (dom/get-element "app"))
   (mx/mount (lightbox) (dom/get-element "lightbox"))
   (mx/mount (loader) (dom/get-element "loader")))


unused func removed

unused func removed

--- src/etaoin/driver.clj
+++ src/etaoin/driver.clj
@@ -18,11 +18,6 @@
 (defn dispatch-driver
   [driver & _]
   (:type driver))
-
-(defn prepend
-  "Puts an element into a seq's head returning a new lazy seq."
-  [seq x]
-  (cons x seq))

 (defn append-args
   [args extra]


Add Request/Response Logging

Add Request/Response Logging

--- src/lens/app.clj
+++ src/lens/app.clj
@@ -1,6 +1,7 @@
 (ns lens.app
   (:use plumbing.core)
-  (:require [bidi.bidi :as bidi]
+  (:require [clojure.tools.logging :as log]
+            [bidi.bidi :as bidi]
             [bidi.ring :as bidi-ring]
             [io.clojure.liberator-transit]
             [ring.middleware.params :refer [wrap-params]]
@@ -23,6 +24,14 @@
       resp
       {:status 404})))

+(defn wrap-log [handler]
+  (fn [req]
+    (let [resp (handler req)]
+      (log/info (pr-str {:request (select-keys req [:remote-addr :request-method
+                                                    :uri :query-string :headers])
+                         :response (select-keys resp [:status :headers])}))
+      resp)))
+
 (defnk app [db-uri context-path :as opts]
   (assert (re-matches #"/(?:.*[^/])?" context-path))
   (let [routes (routes context-path)
@@ -33,4 +42,5 @@
         (wrap-cors)
         (wrap-connection db-uri)
         (wrap-keyword-params)
-        (wrap-params))))
+        (wrap-params)
+        (wrap-log))))


Fix more bugs, works on all small instances tested so far.

--- src/exp/sahucs_nc.clj
+++ src/exp/sahucs_nc.clj
@@ -176,7 +176,7 @@
 (defn expand-sa-node [node #^HashMap cache next-best state reward-to-state last-context
                       #^IdentityHashMap stack-node-depths depth]
   (assert (not (.containsKey stack-node-depths node)))
-  (println (apply str (repeat depth \ )) "Entering " (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "at depth" depth ", " (count (first @(:result-vec-and-map-atom node))) ", " (cutoff (:queue node)) next-best last-context reward-to-state)
+ ; (println (apply str (repeat depth \ )) "Entering " (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "at depth" depth ", " (count (first @(:result-vec-and-map-atom node))) ", " (cutoff (:queue node)) next-best last-context reward-to-state)
 ;  (println (apply str (repeat depth \ )) "States on queue are: " (util/map-map (fn [[k v]] [[(spos (:state k)) (map env/action-name (:remaining-actions k))] (- v)]) (into {} (filter #(< (second %) Double/POSITIVE_INFINITY) (queues/pq-peek-pairs (:queue node))))))
   (.put stack-node-depths node depth)
   (let [good-queue (:queue node)
@@ -209,13 +209,13 @@
                  clean)

 ;          (println (apply str (repeat depth \ )) (count clean) (count dirtied) (count still-dirty))
-          (when (= (first (env/action-name (:action node))) 'nav)
-            (let [[_ dx dy] (env/action-name (:action node))]
-              (doseq [[ss sr] (stitch-effect-map clean state 0 #_ reward-to-state)]
-                (println ss sr clean new-results (env/action-name (:action node)))
-                (let [[sx sy] (map #(env/get-var state %) '[[atx] [aty]])]
-                  (when-not (= (- sr) (+ (util/abs (- sx dx)) (util/abs (- sy dy))))
-                     (println "ERROR" [sx sy] [dx dy] sr (:min-cycle-depth (:entry (meta ss))) reward-to-state) #_ (dr/debug-repl))))))
+;          (when (= (first (env/action-name (:action node))) 'nav)
+;            (let [[_ dx dy] (env/action-name (:action node))]
+;              (doseq [[ss sr] (stitch-effect-map clean state 0 #_ reward-to-state)]
+;                (println ss sr clean new-results (env/action-name (:action node)))
+;                (let [[sx sy] (map #(env/get-var state %) '[[atx] [aty]])]
+;                  (when-not (= (- sr) (+ (util/abs (- sx dx)) (util/abs (- sy dy))))
+;                     (println "ERROR" [sx sy] [dx dy] sr (:min-cycle-depth (:entry (meta ss))) reward-to-state) #_ (dr/debug-repl))))))

           (doseq [entry (concat good-roots (map #(:entry (meta (key %))) dirtied))]
             (assert (util/xor (not (:sanode entry)) (:cutoff (meta entry))))
@@ -225,7 +225,7 @@
               (- (or (:cutoff (meta entry)) (:reward-to-state entry))))) ;(if-let [n  (:sanode entry)] (cutoff (:queue n)) 0)
           (.remove stack-node-depths node) ;; TODO: catchup!!

-          (println (apply str (repeat depth \ )) "Returning from" (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "With cutoffs" cut (cutoff good-queue) ", ns"  (util/map-keys spos (stitch-effect-map catchup state reward-to-state) ) (count catchup) (count new-results))
+       ;   (println (apply str (repeat depth \ )) "Returning from" (env/action-name (:action node)) (map #(env/get-var state %) '[[atx] [aty]]) "With cutoffs" cut (cutoff good-queue) ", ns"  (util/map-keys spos (stitch-effect-map catchup state reward-to-state) ) (count catchup) (count new-results))
           (assert (<= (cutoff good-queue) init-cutoff))

           (PartialResult (stitch-effect-map
@@ -284,7 +284,7 @@
                      (extend-cutoff-depth-map cutoff-depth-map (:cutoff rec) cd depth)
                      (concat (when (and (>= b-cd depth) (< cd depth))
 ;                               (util/assert-is (<=  (+ b-rts (:cutoff rec))  rcut (- neg-reward)) "%s %s %s ; %s %s %s" (cutoff (:queue b-sa)) b-rts (:cutoff rec) b-cd depth cd)
-                               [(vary-meta entry assoc :cutoff rcut)])
+                               [(vary-meta entry assoc :cutoff (min rcut (- neg-reward)))]) ;; sometimes bad becomes good becomes bad.
                              (doall (for [n sbn] (queues/g-pq-remove! good-queue n)))
                              good-roots)))))))))

@@ -312,7 +312,7 @@
         init  (env/initial-state e)
         root  (get-sa-node cache init (hierarchy/TopLevelAction e [(hierarchy/initial-plan henv)]))]
     (loop [cutoff 0 last-cutoff 0]
-        (println "\ncutoff" cutoff "\n")
+;        (println "\ncutoff" cutoff "\n")
       (let [result (expand-sa-node root cache cutoff init 0.0 0 (IdentityHashMap.) 0)]
         (cond (not (empty? (:result-map result)))
                 (let [[k v] (util/first-maximal-element val (:result-map result))]


Added a model for proxies in Redis.

Added a model for proxies in Redis.

Refs #60.

--- src/shale/redis.clj
+++ src/shale/redis.clj
@@ -101,19 +101,30 @@
 (defmodel SessionInRedis
   "A session, as represented in redis."
   :model-name "sessions"
-  {(s/optional-key :webdriver-id) s/Str
-   (s/optional-key :tags)       #{s/Str}
-   (s/optional-key :reserved)     s/Bool
-   (s/optional-key :current-url)  s/Str
-   (s/optional-key :browser-name) s/Str
-   (s/optional-key :node-id)      s/Str})
+  {(s/optional-key :webdriver-id)   s/Str
+   (s/optional-key :tags)         #{s/Str}
+   (s/optional-key :reserved)       s/Bool
+   (s/optional-key :current-url)    s/Str
+   (s/optional-key :browser-name)   s/Str
+   (s/optional-key :node-id)        s/Str})

 (defmodel NodeInRedis
   "A node, as represented in redis."
   :model-name "nodes"
-  {(s/optional-key :url)          s/Str
-   (s/optional-key :max-sessions) s/Int
-   (s/optional-key :tags)       #{s/Str}})
+  {(s/optional-key :url)            s/Str
+   (s/optional-key :max-sessions)   s/Int
+   (s/optional-key :tags)         #{s/Str}})
+
+(s/defschema IPAddress
+  (s/pred #(re-matches #"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" %)))
+
+(defmodel ProxyInRedis
+  "A proxy, as represented in redis."
+  :model-name "proxies"
+  {(s/optional-key :public-ip) IPAddress
+   :type                       (s/enum :socks5 :http)
+   :private-host-and-port      s/Str
+   (s/optional-key :active)    s/Bool})

 ;; model fetching
 (defn model-key [model-schema id]


Fix reserved slugs, use activity instead of for-you.

--- src/oc/storage/resources/board.clj
+++ src/oc/storage/resources/board.clj
@@ -72,7 +72,7 @@

 ;; ----- Board Slug -----

-(def reserved-slugs #{"create-board" "settings" "boards" "all-posts" "drafts" "must-see" "bookmarks" "inbox" "new" "following" "unfollowing" "home" "topics" "for-you"})
+(def reserved-slugs #{"create-board" "settings" "boards" "all-posts" "drafts" "must-see" "bookmarks" "inbox" "new" "following" "unfollowing" "home" "topics" "activity"})

 (declare list-boards-by-org)
 (defn taken-slugs


Update labels to use xss filtering and add some test comments at the bottom.

--- src/oc/storage/resources/label.clj
+++ src/oc/storage/resources/label.clj
@@ -1,6 +1,6 @@
 (ns oc.storage.resources.label
   (:require [oc.lib.schema :as lib-schema]
-            [clojure.set :as clj-set]
+            [oc.lib.html :as lib-html]
             [taoensso.timbre :as timbre]
             [schema.core :as schema]
             [oc.storage.resources.common :as common]
@@ -12,19 +12,22 @@
 (def table-name common/label-table-name)
 (def primary-key :uuid)

-(def reserved-properties
-  (clj-set/union common/reserved-properties #{:used-by}))
-
 (def reserved-slugs #{})

 (def ignored-properties
   "Properties of a resource that are ignored during an update."
-  (clj-set/union reserved-properties #{:team-id :utm-data}))
+  common/reserved-properties)

 (defn ignore-props
   "Remove any ignored properties from the org."
   [label]
   (apply dissoc label ignored-properties))
+
+(defn clean-input [label]
+  (as-> label l
+    (if (:name l)
+      (update l :name #(lib-html/strip-xss-tags (or % "")))
+      l)))

 ;; Utilities

@@ -65,14 +68,15 @@
    org-uuid :- lib-schema/UniqueID
    author :- lib-schema/Author]
   (let [ts (db-common/current-timestamp)]
-    {primary-key (db-common/unique-id)
-     :created-at ts
-     :updated-at ts
-     :org-uuid org-uuid
-     :name label-name
-     :slug (slug/slugify label-name) ;; Will be adjusted later during save
-     :author author
-     :used-by [{:user-id (:user-id author) :count 0}]}))
+    (-> {primary-key (db-common/unique-id)}
+        (assoc :created-at ts)
+        (assoc :updated-at ts)
+        (assoc :org-uuid org-uuid)
+        (assoc :name label-name)
+        (clean-input)
+        (assoc :slug (slug/slugify label-name)) ;; Will be adjusted later during save
+        (assoc :author author)
+        (assoc :used-by [{:user-id (:user-id author) :count 0}]))))

 (schema/defn ^:always-validate create-label!
   "
@@ -96,7 +100,10 @@
   {:pre [(db-common/conn? conn)]}
   (timbre/debugf "Updating label %s (%s) for org %s user %s" (:name updating-label) (:uuid updating-label) (:org-uuid updating-label) (-> updating-label :author :user-id))
   (when-let [original-label (get-label conn label-uuid)]
-    (let [updated-label (merge original-label (ignore-props updating-label))]
+    (let [updated-label (->> updating-label
+                             ignore-props
+                             clean-input
+                            (merge original-label))]
       (schema/validate common/Label updated-label)
       (db-common/update-resource conn table-name primary-key label-uuid updated-label))))

@@ -161,4 +168,38 @@
 (schema/defn ^:always-validate list-labels-by-org-user :- [common/Label]
   [conn org-uuid :- lib-schema/UniqueID user-id :- lib-schema/UniqueID]
   {:pre [(db-common/conn? conn)]}
-  (db-common/read-resources conn table-name :org-uuid-user-id-labels [[org-uuid user-id]]))+  (db-common/read-resources conn table-name :org-uuid-user-id-labels [[org-uuid user-id]]))
+
+(comment
+  (require '[oc.storage.resources.org :as org])
+  (require '[oc.storage.resources.entry :as entry])
+  (require '[clojure.pprint :refer (pprint)])
+
+  (def carrot (org/get-org conn "carrot"))
+  (def author (:author carrot))
+  (println (create-label! conn (->label "My label test" (:uuid carrot) author)))
+
+  (def test-xss (create-label! conn (->label "<style>Test</style>out" (:uuid carrot) author)))
+  (delete-label! conn (:uuid test-xss))
+
+  (def test-label (get-label conn (:uuid carrot) "my-label-test"))
+
+  (update-label! conn (:uuid test-label) {:name "My label test updated"})
+  (:name (get-label conn (:uuid carrot) "my-label-test"))
+
+  (pprint (list-labels-by-org conn (:uuid carrot)))
+
+
+  (label-slug-for-org conn (:uuid carrot) "My label test") ;; => my-label-test-1
+
+  (label-used-by! conn (:uuid test-label) (:uuid carrot) author)
+
+  (def tmp-labels (list-labels-by-org-user conn (:uuid carrot) (:user-id author)))
+
+  (labels-used-by! conn (mapv :uuid (take 2 tmp-labels)) (:uuid carrot) author)
+
+  (labels-unused-by! conn (mapv :uuid (take 2 tmp-labels)) (:uuid carrot) author)
+
+  (delete-label! conn (:uuid test-label))
+
+  (get-label conn (:uuid carrot) "my-label-test"))


checkbox :checked

checkbox :checked

--- src/ez_form/field.clj
+++ src/ez_form/field.clj
@@ -88,7 +88,8 @@
                                           (some #(= value %) (:value-added field)))
                                         (= value (:value opts))
                                         (= "on" (:value opts))
-                                        (= "on" value)))
+                                        (= "on" value)
+                                        (true? value)))
                                  {:checked true}))]
                 [:label {:for id} label]]))
            options)
@@ -97,7 +98,9 @@
                                                        (or checked?
                                                            (= value (:value opts))
                                                            (= "on" (:value opts))
-                                                           (= "on" value)))
+                                                           (true? (:value opts))
+                                                           (= "on" value)
+                                                           (true? value)))
                                                     {:checked true}))])))

 (defmethod field :radio [field form-options]


Refactored :focus-state evolvers into smaller functions

--- src/flatgui/focus.clj
+++ src/flatgui/focus.clj
@@ -175,9 +175,187 @@
 (defn focus-uninterested? [component]
   (and (not (:closed-focus-root component)) (not (:focusable component))))

+(fg/defaccessorfn focus-state-keyboard [component old-focus-state this-mode]
+  (if (and
+        (= :has-focus this-mode)
+        (keyboard/key-pressed? component)
+        (= (keyboard/get-key component) KeyEvent/VK_TAB))
+    {:mode :throws-focus
+     :focused-child nil
+     :throw-mode (cond
+                   (and (inputbase/with-ctrl? component) (inputbase/with-shift? component)) :out-of-cycle-prev
+                   (inputbase/with-ctrl? component) :out-of-cycle-next
+                   (inputbase/with-shift? component) :prev
+                   :else :next)}
+    old-focus-state))
+
+(fg/defaccessorfn focus-state-mouse [component old-focus-state this-mode]
+  (cond
+    (and (:focusable component) (#{:none :parent-of-focused :throws-focus} this-mode))
+    {:mode :requests-focus
+     :focused-child (:focused-child old-focus-state)}
+    (and (:closed-focus-root component) (#{:none :throws-focus :requests-focus} this-mode))
+    (having-focus-state component "closed root by mouse")
+    (and (focus-uninterested? component) (not= :parent-of-focused this-mode))
+    (do
+      (log-debug "Trigger received by focus-uninterested" (:id component))
+      (got-trigger))
+    :else old-focus-state))
+
+(fg/defaccessorfn focus-state-parent [component old-focus-state this-mode parent-id parent-focus-state parent-focused-child parent-mode]
+  (case parent-mode
+    ;; If parent has focus temporarily, I take focus back (*2)
+    ;; Otherwise my parent has focus permanently and my state is clean
+    :has-focus (if (= parent-focused-child (:id component)) ; This condition means that parent has focus temporarily
+                 ;; Parent keeps latest throwing direction in :throw-mode in this case. Track it for further use
+                 (assoc (having-focus-state component (str "from parent " parent-id " that kept temporary")) :throw-mode (:throw-mode parent-focus-state))
+                 clean-state)
+    :got-trigger (if (= this-mode :got-trigger)
+                   clean-state
+                   (if (:focusable component)
+                     having-focus-state
+                     (if-let [child-id (get-in-cycle component :first nil)]
+                       (focus-child-by-direction child-id :next)
+                       old-focus-state)))
+    :none clean-state
+    :parent-of-focused (if (= parent-focused-child (:id component))
+                         ;; If my parent is :parent-of-focused and I am :parent-of-focused,
+                         ;; then no changes needed here.
+                         (if (not= this-mode :parent-of-focused)
+                           ;; My parent is ready to give me focus.
+                           ;;   If I have any child requesting focus then I give focus to it.
+                           ;;   Otherwise I leave focus with myself. (*1)
+                           ;;   Else, if I am acutally not focusable then I pass focus to the first
+                           ;;   child in my cycle
+                           (if-let [child-id (if-let [requesting-child-id
+                                                      (:id (first (filter
+                                                                    #(= :requests-focus (:mode (:focus-state %)))
+                                                                    (for [[_ c] (:children component)] c))))]
+                                               requesting-child-id
+                                               (if (not (:focusable component))
+                                                 (get-in-cycle
+                                                   component
+                                                   ;; In case latest focus movent direction is tracked
+                                                   ;; in :throw-mode - use it to determine firt or last
+                                                   (if (= :prev (:throw-mode parent-focus-state))
+                                                     :last
+                                                     :first)
+                                                   nil)))]
+                             (focus-child-by-direction child-id (:throw-mode parent-focus-state))
+                             (if (:accepts-focus? component)
+                               (having-focus-state component (str "from parent " parent-id " that requested"))
+                               {:mode :throws-focus
+                                :throw-mode :out-of-cycle-next}))
+                           ;; No change in state but track focus movent direction
+                           (assoc old-focus-state :throw-mode (:throw-mode parent-focus-state)))
+
+                         ;; Another component next to me has focus, therefore my state is clean
+                         clean-state)
+
+    ;; My parent is requesting focus. No changes for my state yet
+    :requests-focus old-focus-state
+
+    ;; My parent is going to throw focus. No changes for my state yet
+    :throws-focus old-focus-state))
+
+(fg/defaccessorfn focus-state-child [component old-focus-state this-mode]
+  (let [this-focused-child (:focused-child old-focus-state)
+        child-id (nth (fg/get-reason) 1)
+        child-focus-state (get-property [:this child-id] :focus-state)
+        child-mode (:mode child-focus-state)
+        child-throw-mode (:throw-mode child-focus-state)]
+    (case child-mode
+      ;; Nothing to change in this case
+      :none old-focus-state
+
+      ;; If my child is the parent of focused component (or parent of parent ...)
+      ;; then I'm :parent-of-focused as well
+      :parent-of-focused (focus-child-by-direction child-id child-throw-mode)
+
+      ;; My child has focus itself - same thing
+      :has-focus (focus-child-by-direction child-id child-throw-mode)
+
+      :requests-focus (case this-mode
+                        ;; I'm the parent of focused component (no matter which exactly) and my child requests
+                        ;; focus - then I note that this child becomes the new focus owner. My :mode stays the same
+                        :parent-of-focused (focus-child-by-direction child-id (:throw-mode old-focus-state))
+
+                        ;; If I have focus and my child requests it - I give focus to it
+                        :has-focus (focus-child child-id)
+
+                        ;; If my child wants focus but I don't have it - I start requesting focus in order to give
+                        ;; it to my child as soon as I have it (*1)
+                        :none {:mode :requests-focus
+                               :focused-child nil}
+
+                        ;; If my child request focus and I request focus as well - there is nothing that can be
+                        ;; changed about this
+                        :requests-focus old-focus-state
+
+                        ;; My child request focus and I throw focus - then I let this child get focus
+                        :throws-focus (focus-child child-id))
+
+      :throws-focus (case child-throw-mode
+                      ;; My child throws focus in :prev direction. Give focus to previous child.
+                      ;; But if I'm not a closed root then there may be no previous child,
+                      ;; get-in-cycle returns nil in this case. Rethrow it out in this case
+                      :prev (if-let [prev-child (get-in-cycle component :prev this-focused-child)]
+                              (if (= prev-child this-focused-child)
+                                ;; My child throws focus, but there is no other component to take it.
+                                ;; So I take it temporarily and child will take back within the next step. (*2)
+                                ;; Latest movement direction is tracked to be used within the next step
+                                (temporarily-taken-from-state component (str "prev, reason: " child-id) this-focused-child :prev)
+                                (focus-child-by-direction prev-child :prev))
+                              {:mode :throws-focus
+                               :throw-mode :prev
+                               :focused-child this-focused-child})
+
+                      ;; My child throws focus in :next direction. Give focus to next child.
+                      ;; But if I'm not a closed root then there may be no next child,
+                      ;; get-in-cycle returns nil in this case. Rethrow it out in this case
+                      :next (if-let [next-child (get-in-cycle component :next this-focused-child)]
+                              (if (= next-child this-focused-child)
+                                ;; My child throws focus, but there is no other component to take it.
+                                ;; So I take it temporarily and child will take back within the next step. (*2)
+                                ;; Latest movement direction is tracked to be used within the next step
+                                (temporarily-taken-from-state component (str "next, reason: " child-id) this-focused-child :next)
+                                (focus-child-by-direction next-child :next))
+                              {:mode :throws-focus
+                               :throw-mode :next
+                               :focused-child this-focused-child})
+
+                      ;; Rethrow up to nearest closed cycle root
+                      :out-of-cycle-prev {:mode :throws-focus
+                                          :throw-mode (if (:closed-focus-root component)
+                                                        :prev
+                                                        :out-of-cycle-prev)
+                                          :focused-child this-focused-child}
+
+                      ;; Rethrow up to nearest closed cycle root
+                      :out-of-cycle-next {:mode :throws-focus
+                                          :throw-mode (if (:closed-focus-root component)
+                                                        :next
+                                                        :out-of-cycle-next)
+                                          :focused-child this-focused-child})
+
+      :got-trigger (cond
+                     ;; Trigger finally made it to focusable
+                     (and (:focusable component) (not= :parent-of-focused this-mode)) ;maybe accepts-focus? instead of focusable
+                     (having-focus-state component "trigger")
+                     ;; Trigger reached non focusable, but one that possibly has where to give focus
+                     (or
+                       (:closed-focus-root component)
+                       (get-in-cycle component :first nil))
+                     (if-let [first-to-give (get-in-cycle component :first nil)]
+                       (temporarily-taken-from-state component "trigger" first-to-give nil)
+                       (got-trigger))
+                     ;; Just give chance further
+                     :else
+                     (got-trigger))
+      old-focus-state)))
+
 (fg/defevolverfn :focus-state
   (let [reason (fg/get-reason)
-        this-focused-child (:focused-child old-focus-state)
         this-mode (:mode old-focus-state)
         parent-id (get-property [] :id)
         parent-focus-state (get-property [] :focus-state)
@@ -186,182 +364,16 @@
     (cond

       (keyboard/key-event? component)
-      (if (and
-            (= :has-focus this-mode)
-            (keyboard/key-pressed? component)
-            (= (keyboard/get-key component) KeyEvent/VK_TAB))
-        {:mode :throws-focus
-         :focused-child nil
-         :throw-mode (cond
-                       (and (inputbase/with-ctrl? component) (inputbase/with-shift? component)) :out-of-cycle-prev
-                       (inputbase/with-ctrl? component) :out-of-cycle-next
-                       (inputbase/with-shift? component) :prev
-                       :else :next)}
-        old-focus-state)
+      (focus-state-keyboard component old-focus-state this-mode)

       (mouse/mouse-left? component)
-      (cond
-        (and (:focusable component) (#{:none :parent-of-focused :throws-focus} this-mode))
-        {:mode :requests-focus
-         :focused-child this-focused-child}
-        (and (:closed-focus-root component) (#{:none :throws-focus :requests-focus} this-mode))
-        (having-focus-state component "closed root by mouse")
-        (and (focus-uninterested? component) (not= :parent-of-focused this-mode))
-        (do
-          (log-debug "Trigger received by focus-uninterested" (:id component))
-          (got-trigger))
-        :else old-focus-state)
+      (focus-state-mouse component old-focus-state this-mode)

       (and (fgc/parent-reason? reason) parent-mode)
-      (case parent-mode
-        ;; If parent has focus temporarily, I take focus back (*2)
-        ;; Otherwise my parent has focus permanently and my state is clean
-        :has-focus (if (= parent-focused-child (:id component)) ; This condition means that parent has focus temporarily
-                     ;; Parent keeps latest throwing direction in :throw-mode in this case. Track it for further use
-                     (assoc (having-focus-state component (str "from parent " parent-id " that kept temporary")) :throw-mode (:throw-mode parent-focus-state))
-                     clean-state)
-        :got-trigger (if (= this-mode :got-trigger)
-                       clean-state
-                       (if (:focusable component)
-                         having-focus-state
-                         (if-let [child-id (get-in-cycle component :first nil)]
-                           (focus-child-by-direction child-id :next)
-                           old-focus-state)))
-        :none clean-state
-        :parent-of-focused (if (= parent-focused-child (:id component))
-                             ;; If my parent is :parent-of-focused and I am :parent-of-focused,
-                             ;; then no changes needed here.
-                             (if (not= this-mode :parent-of-focused)
-                               ;; My parent is ready to give me focus.
-                               ;;   If I have any child requesting focus then I give focus to it.
-                               ;;   Otherwise I leave focus with myself. (*1)
-                               ;;   Else, if I am acutally not focusable then I pass focus to the first
-                               ;;   child in my cycle
-                               (if-let [child-id (if-let [requesting-child-id
-                                                          (:id (first (filter
-                                                                        #(= :requests-focus (:mode (:focus-state %)))
-                                                                        (for [[_ c] (:children component)] c))))]
-                                                   requesting-child-id
-                                                   (if (not (:focusable component))
-                                                     (get-in-cycle
-                                                       component
-                                                       ;; In case latest focus movent direction is tracked
-                                                       ;; in :throw-mode - use it to determine firt or last
-                                                       (if (= :prev (:throw-mode parent-focus-state))
-                                                         :last
-                                                         :first)
-                                                       nil)))]
-                                 (focus-child-by-direction child-id (:throw-mode parent-focus-state))
-                                 (if (:accepts-focus? component)
-                                   (having-focus-state component (str "from parent " parent-id " that requested"))
-                                   {:mode :throws-focus
-                                    :throw-mode :out-of-cycle-next}))
-                               ;; No change in state but track focus movent direction
-                               (assoc old-focus-state :throw-mode (:throw-mode parent-focus-state)))
-
-                             ;; Another component next to me has focus, therefore my state is clean
-                             clean-state)
-
-        ;; My parent is requesting focus. No changes for my state yet
-        :requests-focus old-focus-state
-
-        ;; My parent is going to throw focus. No changes for my state yet
-        :throws-focus old-focus-state)
+      (focus-state-parent component old-focus-state this-mode parent-id parent-focus-state parent-focused-child parent-mode)

       (fgc/child-reason? reason)
-      (let [child-id (nth reason 1)
-            child-focus-state (get-property [:this child-id] :focus-state)
-            child-mode (:mode child-focus-state)
-            child-throw-mode (:throw-mode child-focus-state)]
-        (case child-mode
-          ;; Nothing to change in this case
-          :none old-focus-state
-
-          ;; If my child is the parent of focused component (or parent of parent ...)
-          ;; then I'm :parent-of-focused as well
-          :parent-of-focused (focus-child-by-direction child-id child-throw-mode)
-
-          ;; My child has focus itself - same thing
-          :has-focus (focus-child-by-direction child-id child-throw-mode)
-
-          :requests-focus (case this-mode
-                            ;; I'm the parent of focused component (no matter which exactly) and my child requests
-                            ;; focus - then I note that this child becomes the new focus owner. My :mode stays the same
-                            :parent-of-focused (focus-child-by-direction child-id (:throw-mode old-focus-state))
-
-                            ;; If I have focus and my child requests it - I give focus to it
-                            :has-focus (focus-child child-id)
-
-                            ;; If my child wants focus but I don't have it - I start requesting focus in order to give
-                            ;; it to my child as soon as I have it (*1)
-                            :none {:mode :requests-focus
-                                   :focused-child nil}
-
-                            ;; If my child request focus and I request focus as well - there is nothing that can be
-                            ;; changed about this
-                            :requests-focus old-focus-state
-
-                            ;; My child request focus and I throw focus - then I let this child get focus
-                            :throws-focus (focus-child child-id))
-
-          :throws-focus (case child-throw-mode
-                          ;; My child throws focus in :prev direction. Give focus to previous child.
-                          ;; But if I'm not a closed root then there may be no previous child,
-                          ;; get-in-cycle returns nil in this case. Rethrow it out in this case
-                          :prev (if-let [prev-child (get-in-cycle component :prev this-focused-child)]
-                                  (if (= prev-child this-focused-child)
-                                    ;; My child throws focus, but there is no other component to take it.
-                                    ;; So I take it temporarily and child will take back within the next step. (*2)
-                                    ;; Latest movement direction is tracked to be used within the next step
-                                    (temporarily-taken-from-state component (str "prev, reason: " child-id) this-focused-child :prev)
-                                    (focus-child-by-direction prev-child :prev))
-                                  {:mode :throws-focus
-                                   :throw-mode :prev
-                                   :focused-child this-focused-child})
-
-                          ;; My child throws focus in :next direction. Give focus to next child.
-                          ;; But if I'm not a closed root then there may be no next child,
-                          ;; get-in-cycle returns nil in this case. Rethrow it out in this case
-                          :next (if-let [next-child (get-in-cycle component :next this-focused-child)]
-                                  (if (= next-child this-focused-child)
-                                    ;; My child throws focus, but there is no other component to take it.
-                                    ;; So I take it temporarily and child will take back within the next step. (*2)
-                                    ;; Latest movement direction is tracked to be used within the next step
-                                    (temporarily-taken-from-state component (str "next, reason: " child-id) this-focused-child :next)
-                                    (focus-child-by-direction next-child :next))
-                                  {:mode :throws-focus
-                                   :throw-mode :next
-                                   :focused-child this-focused-child})
-
-                          ;; Rethrow up to nearest closed cycle root
-                          :out-of-cycle-prev {:mode :throws-focus
-                                              :throw-mode (if (:closed-focus-root component)
-                                                            :prev
-                                                            :out-of-cycle-prev)
-                                              :focused-child this-focused-child}
-
-                          ;; Rethrow up to nearest closed cycle root
-                          :out-of-cycle-next {:mode :throws-focus
-                                              :throw-mode (if (:closed-focus-root component)
-                                                            :next
-                                                            :out-of-cycle-next)
-                                              :focused-child this-focused-child})
-
-          :got-trigger (cond
-                         ;; Trigger finally made it to focusable
-                         (and (:focusable component) (not= :parent-of-focused this-mode)) ;maybe accepts-focus? instead of focusable
-                         (having-focus-state component "trigger")
-                         ;; Trigger reached non focusable, but one that possibly has where to give focus
-                         (or
-                           (:closed-focus-root component)
-                           (get-in-cycle component :first nil))
-                         (if-let [first-to-give (get-in-cycle component :first nil)]
-                           (temporarily-taken-from-state component "trigger" first-to-give nil)
-                           (got-trigger))
-                         ;; Just give chance further
-                         :else
-                         (got-trigger))
-          old-focus-state))
+      (focus-state-child component old-focus-state this-mode)

       :else ; Neither event type - ignore
       old-focus-state)))


Removed unused defn

Removed unused defn

--- src/oxcart/passes/fn_reduction.clj
+++ src/oxcart/passes/fn_reduction.clj
@@ -62,15 +62,6 @@
    (pattern/def->symbol wrapping-def)
    (count params)
    (method-variadic? method)))
-
-
-(defn munge-callsite
-  "λ Invoke-AST → Invoke-AST
-
-  This function rewrites invoke AST nodes, returning a new invoke node
-  which targets an arity munged function."
-  [ast]
-  )

 (defn fn-is-multiple-arity?


update header

update header

--- src/stipe/piece.clj
+++ src/stipe/piece.clj
@@ -24,7 +24,7 @@
            :href "/favicon.ico"}]
    (h/include-css "/css/style.css")
    [:link {:rel "stylesheet"
-           :href "https://fonts.googleapis.com/css?family=Source+Code+Pro|Source+Sans+Pro"}]
+           :href "https://fonts.googleapis.com/css?family=Source+Code+Pro"}]
    js])

 (defn nav [title]


need to convert :source-content into JS array

--- src/main/cljs/cljs/source_map.cljs
+++ src/main/cljs/cljs/source_map.cljs
@@ -249,7 +249,7 @@
                                      (map (set/map-invert @names->idx)
                                        (range (count @names->idx))))}
             (:sources-content opts)
-            (doto (gobj/set "sourcesContent" (:sources-content opts))))]
+            (doto (gobj/set "sourcesContent" (into-array (:sources-content opts)))))]
       (.stringify js/JSON source-map-file-contents))))

 ;; -----------------------------------------------------------------------------


add arity overload for count()

add arity overload for count()

--- src/main/clojure/org/dada/core.clj
+++ src/main/clojure/org/dada/core.clj
@@ -414,6 +414,11 @@
    (let [strategy (make-count-reducer-strategy (.getMetadata model) tgt-metadata)
 	view-name-fn (fn [arg] "count()")
 	reducer (make-reducer model :count key-value strategy tgt-metadata view-name-fn)]
+    (connect model reducer)))
+  ([#^Model model key-type key-value #^Metadata tgt-metadata model-key]
+   (let [strategy (make-count-reducer-strategy (.getMetadata model) tgt-metadata)
+	view-name-fn (fn [arg] (.toString model-key))
+	reducer (make-reducer model :count key-value strategy tgt-metadata view-name-fn)]
     (connect model reducer))))

 ;;----------------------------------------


Add the validations to the core example

Add the validations to the core example

--- src/themis/core.clj
+++ src/themis/core.clj
@@ -102,13 +102,15 @@
          (:has-pet t-map)
          nil))

-  (require '[themis.validators :refer [simple-predicate]])
+  (require '[themis.validators :refer [from-predicate]])
+  (require '[themis.predicates :as preds])

   (def paul-rules [[[:name :first] [(fn [t-map data-point opt-map] (and (= data-point "Paul")
                                                                         {:a 1 :b 2}))]]
+                   [[:pets 0] [(from-predicate preds/longer-than? 20 "Too short; Needs to be longer than 20")]]
                    [[:pets 0 0] [[::w-pets {:pet-name-starts ""}]
-                                 (simple-predicate char?)
-                                 (simple-predicate #(= % \w) "The first letter is not `w`")]]
+                                 (from-predicate char?)
+                                 (from-predicate #(= % \w) "The first letter is not `w`")]]
                    ;[[:*] ['degrandis-pets]] ;This is valid, but we can also just write:
                    [:* 'degrandis-pets]])


Change fx to use blend modes

Change fx to use blend modes

--- src/examples/fx.clj
+++ src/examples/fx.clj
@@ -21,6 +21,16 @@
         (< h 300) [x 0 c]
         (< h 360) [c 0 x]))))

+(defn dot [u v]
+  (reduce + 0 (map * u v)))
+
+(defn norm [v]
+  (Math/sqrt (reduce + 0 (map (fn [x] (* x x)) v))))
+
+(defn unit [v]
+  (let [l (norm v)]
+    (map #(/ % l) v)))
+
 (def font (CP437Font. "http://dwarffortresswiki.org/images/b/be/Pastiche_8x8.png" :green 2 false))

 (defn -main [& _]
@@ -34,13 +44,21 @@
        :font (constantly font)}
      ;; fx-mul layer is a multiplicative blend layer
      :fx-mul {
-       :layers [:rainbow]
+       :layers [:dark]
        :columns 16
        :rows 16
        :pos [0 0]
        :font (constantly font)
        :gl-blend-equation :gl-func-add
-       :gl-blend-func [:gl-dst-color :gl-zero]}}
+       :gl-blend-func [:gl-dst-color :gl-zero]}
+     :fx-add {
+       :layers [:light]
+       :columns 16
+       :rows 16
+       :pos [0 0]
+       :font (constantly font)
+       :gl-blend-equation :gl-func-add
+       :gl-blend-func [:gl-one :gl-one]}}
     {:title "Zaffre demo"
      :screen-width (* 16 16)
      :screen-height (* 16 16)
@@ -50,29 +68,38 @@
       (let [last-key    (atom nil)]
         ;; Every 33ms, draw a full frame
         (zat/do-frame terminal 33
-          (let [key-in (or @last-key \?)]
+          (let [key-in (or @last-key \?)
+                t      (/ (.getTime (new java.util.Date)) 1000)
+                ;; light pos
+                lx     (+ (* 5 (Math/cos t)) 8.0)
+                ly     (+ (* 5 (Math/sin t)) 8.0)]
             ; text
+            (doseq [y (range 16)]
+              (zutil/put-string terminal :text 0 y "a b c d e f g h "))
             (zutil/put-string terminal :text 0 0 "Hello world")
-            (zutil/put-string terminal :text 1 1 "Rainbow")
-            (doseq [[i c] (take 23 (map-indexed (fn [i c] [i (char c)]) (range (int \a) (int \z))))]
-              (zutil/put-string terminal :text 0 (inc i) (str c) [128 (* 10 i) 0] [0 0 50]))
             (zutil/put-string terminal :text 12 0 (str key-in))
             ; fx (note the only characters we're drawing if full-cell boxes
             (doseq [y (range 16)]
-              (zutil/put-string terminal :rainbow 0 y (apply str (repeat 16 " "))))
+              (zutil/put-string terminal :dark 0 y (apply str (repeat 16 " ")))
+              (zutil/put-string terminal :light 0 y (apply str (repeat 16 " "))))
+            (zat/set-bg! terminal :light 8 8 [32 32 16])
             (doseq [x (range 16)
                     y (range 16)]
-                (zat/set-bg! terminal :rainbow x y [255, 255, 255]))
-            (doseq [x (range (count "Rainbow"))
-                    :let [rgb (hsv->rgb (double (rand 360)) 1.0 1.0)]]
-                (zat/set-bg! terminal :rainbow (inc x) 1 rgb))))
-      ;; get key presses in fg thread
-      (zevents/add-event-listener terminal :keypress
-        (fn [new-key]
-          (reset! last-key new-key)
-          (case new-key
-            ;; quit on \q keypress
-            \q (zat/destroy! terminal)
-            nil)))))))
+                (zat/set-bg! terminal :dark x y [32, 32, 128])
+                (let [rlx (- lx x) ;; vector from x, y to lx, ly
+                      rly (- ly y)
+                      rlz 3
+                      rl  [rlx rly rlz]
+                      d   (norm rl) ; distance from [x y] to light
+                      i (min 1.0 (/ (* 8.5 (dot (unit [0 0 1]) (unit rl))) (* d d)))]
+                  (zat/set-bg! terminal :light x y (mapv (partial * i) [255 255 128]))))))
+        ;; get key presses in fg thread
+        (zevents/add-event-listener terminal :keypress
+          (fn [new-key]
+            (reset! last-key new-key)
+            (case new-key
+              ;; quit on \q keypress
+              \q (zat/destroy! terminal)
+              nil)))))))


Avoid getting browser warning from moment-js.

Check if date is valid using `new Date(date)` before trying
to use moment(date).format("ll").

Signed-off-by: Njagi Mwaniki <b6a4ba60ad861b9c9afb6daea7294be4be68f44c@urbanslug.com>

--- src/hatti/ona/forms.cljs
+++ src/hatti/ona/forms.cljs
@@ -219,10 +219,10 @@
                                (filter #(contains? names (field-key %)))
                                (map #(str "☑ " (get-label % language) " "))
                                string/join))
-    (time-based? field) (let [formatted-date (-> answer js/moment (.format "ll"))]
-                          (if (= formatted-date "Invalid date")
-                            answer
-                            formatted-date))
+    (time-based? field) (if (or  (js/isNaN (new js/Date answer))
+                                 (= (.toString (new js/Date answer)) "Invalid Date"))
+                          answer
+                          (-> answer js/moment (.format "ll")))
     (or (image? field)
         (video? field)) (let [image (:download_url answer)
                               thumb (or (:small_download_url answer) image)


(maint) improve log message when validating messages slightly

--- src/puppetlabs/cthun/websockets.clj
+++ src/puppetlabs/cthun/websockets.clj
@@ -21,8 +21,8 @@
   (log/info "Received message from client")
   (log/info "Validating Message...")
   (if (validation/validate-message message)
-    (log/info "Message is valid JSON")
-    (log/info "Message is invalid JSON")))
+    (log/info "Message is valid")
+    (log/info "Message is invalid")))

 (defn- on-bytes
   "OnMessage (binary) websocket event handler"


finished the convert function to parse the h1-h4 elements and return markdown that satisfies the test case

--- src/watney/core.clj
+++ src/watney/core.clj
@@ -26,5 +26,9 @@
 (defn convert
   "Convert the HTML string given into Markdown"
   [html-string]
-  html-string)
+  (-> html-string
+      parse
+      convert-entity
+      (str "\n")))

+


Add function to add properties from a hash map to a grafter triple-template.

--- src/grafter/rdf.clj
+++ src/grafter/rdf.clj
@@ -92,6 +92,13 @@
   (map (partial quad graph-uri)
        (apply triplify triples)))

+(defn add-properties [triple-template hash-map]
+  "Appends the key/value pairs from the supplied hash-map into the
+  triple-template form.  Assumes it is given a vector representing a
+  single subject."
+  (reduce conj triple-template
+          (mapcat vector hash-map)))
+
 (defmacro graphify [row-bindings & forms]
   "Takes a vector in fn binding form (where destructuring is
 supported) followed by a series of graph or triplify forms and


Added support for Number type hints

Added support for Number type hints

--- src/hiccup/core.clj
+++ src/hiccup/core.clj
@@ -209,6 +209,7 @@
       (vector? expr) (compile-tag expr)
       (literal? expr) expr
       (hint? expr String) expr
+      (hint? expr Number) expr
       (seq? expr) (compile-form expr)
       :else `(render-html ~expr))))


Transform earlier

Transform earlier

--- src/kevin/loader.clj
+++ src/kevin/loader.clj
@@ -221,7 +221,6 @@
     (go (while (<! control-chan) true))))

 (defn load-movies []
-  (ensure-transformed-movies "data/movies.list.gz" "data/movies.transformed")
   (let [work-chan    (chan 128)
         tx-data-chan (chan 1)
         tx-chan (batch tx-data-chan 50)
@@ -262,15 +261,12 @@
     (async/<!! control-chan)))

 (defn load-actors []
-  (ensure-transformed-actors "data/actors.list.gz" "data/actors.transformed" :start-at "THE ACTORS LIST")
   (load-actors-from "data/actors.transformed"))

 (defn load-actresses []
-  (ensure-transformed-actors "data/actresses.list.gz" "data/actresses.transformed" :start-at "THE ACTRESSES LIST")
   (load-actors-from "data/actresses.transformed"))

 (defn load-genres []
-  (ensure-transformed-genres "data/genres.list.gz" "data/genres.transformed")
   (let [work-chan    (chan 128)
         tx-data-chan (chan 1)
         tx-chan (batch tx-data-chan 50)
@@ -290,6 +286,11 @@
     (async/<!! control-chan)))

 (defn -main [& args]
+  (println "\nTransforming files for faster load...")
+  (ensure-transformed-movies "data/movies.list.gz" "data/movies.transformed")
+  (ensure-transformed-actors "data/actors.list.gz" "data/actors.transformed" :start-at "THE ACTORS LIST")
+  (ensure-transformed-actors "data/actresses.list.gz" "data/actresses.transformed" :start-at "THE ACTRESSES LIST")
+  (ensure-transformed-genres "data/genres.list.gz" "data/genres.transformed")
   (let [system (system/start (system/system))]
     (alter-var-root #'conn (constantly (:conn (:db system))))
     (time (do


using (:k m) instead of (get m k)

using (:k m) instead of (get m k)

--- src/storaged/src/leela/storaged/network/actions/metrics.clj
+++ src/storaged/src/leela/storaged/network/actions/metrics.clj
@@ -34,14 +34,14 @@
              :limit (nil-or integer?)
              :offset (nil-or integer?)} params
              (with-limit (get params :limit default-limit)
-               (if-let [offset (get params :offset)]
-                 (c*/fetch-metric (get params :plane)
-                                  (get params :metric)
-                                  (get params :bucket)
+               (if-let [offset (:offset params)]
+                 (c*/fetch-metric (:plane params)
+                                  (:metric params)
+                                  (:bucket params)
                                   offset)
-                 (c*/fetch-metric (get params :plane)
-                                  (get params :metric)
-                                  (get params :bucket))))))
+                 (c*/fetch-metric (:plane params)
+                                  (:metric params)
+                                  (:bucket params))))))

 (defn get-index-handler [params]
   (when-map {:plane integer?


Make top buttons  of IDE fit on an iPhone in portrait mode

Just reduced the spacing between the buttons a bit to acheive this

--- idecode/myappshare/mainapp.cljs
+++ idecode/myappshare/mainapp.cljs
@@ -227,11 +227,11 @@
             (if (large-screen) (img {:style {:display "inline-block" :marginTop "-0.0em"} :src "appshare_logo_dark_background.png"}))

             (button {:className    (if (small-screen) "btn btn-default" "btn-lg btn-default")
-                     :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"}
+                     :style       {:display "inline-block" :marginLeft (if (small-screen) "2px"  "30px") :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"}
                      :onClick     #(write-ui app [:mode] "browse")} "Home")

             (button {:className    (if (small-screen) "btn btn-default" "btn-lg btn-default")
-                     :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"
+                     :style       {:display "inline-block" :marginLeft (if (small-screen) "2px"  "30px") :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"
                                    :opacity (if (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse")) "1.0" "0.4")
                                    }
                      :disabled  (if (or (= (read-ui app [:mode]) nil) (= (read-ui app [:mode]) "browse")) "" "true")
@@ -239,7 +239,7 @@
                                       (remote !newapp {})) } "New")

             (button {:className    (if (small-screen) "btn btn-default"  "btn-lg btn-default")
-                     :style {:display "inline-block" :marginLeft "30px"
+                     :style {:display "inline-block" :marginLeft (if (small-screen) "2px"  "30px")
                              :fontFamily "Ubuntu"    :fontSize "1em"       :marginTop "0.3em"
                              :opacity  (if (= (read-ui app [:mode]) "view")  "1.0" "0.4")
                              }
@@ -262,7 +262,7 @@

             (button {:className    (if (small-screen) "btn btn-default"  "btn-lg btn-default")
-                        :style       {:display "inline-block" :marginLeft "30px" :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"
+                        :style       {:display "inline-block" :marginLeft (if (small-screen) "2px"  "30px") :fontFamily "Ubuntu" :fontSize "1em" :marginTop "0.3em"
                                       :opacity  (if (= (read-ui app [:mode]) "edit")  "1.0" "0.4")

                                       }


Stop first; preserve the exception

Stop first; preserve the exception

--- src/vip/data_processor/pipeline.clj
+++ src/vip/data_processor/pipeline.clj
@@ -60,11 +60,13 @@
     (log/info (pr-str (select-keys result [:import-id :public-id :db :xml-output-file])))
     (log/debug (pr-str (select-keys result [:spec-version :fatal :critical :stop])))

+    (when-let [stop (:stop result)]
+      (psql/fail-run import-id nil)
+      (log/error "Stopping run of" import-id "due to:" stop))
+
     (when-let [ex (:exception result)]
       (psql/fail-run import-id (with-out-str (stacktrace/print-throwable ex)))
       (log/error (with-out-str (stacktrace/print-stack-trace ex))))

-    (when-let [stop (:stop result)]
-      (psql/fail-run import-id stop)
-      (log/error "Stopping run of" import-id "due to:" stop))
+
     result))


Update spray.clj

Update spray.clj

--- src/swagger_gen/language/spray.clj
+++ src/swagger_gen/language/spray.clj
@@ -81,4 +81,3 @@
         args (filter route-arg? (route-parts path))]
     {:route route
      :args (parenthesize (mapv normalize-route-arg args))}))
-