Comment for munch.clj

Comment for munch.clj

--- src/clj/minijava/munch.clj
+++ src/clj/minijava/munch.clj
@@ -6,8 +6,9 @@
 (= (type x) t)
 )

+
 (defn emit [x]
-
+;;I'm not sure what the best way to implement this is yet. But emit just appends x to the end of a list, so theres not too much to it.
 )

 ;;ir is the root of the ir tree to munch; args is an (optional) list of the 'children' of the root node, for pattern matching purposes.


Swapped binding to atom, and now emit works properly.

--- src/clj/minijava/munch.clj
+++ src/clj/minijava/munch.clj
@@ -7,14 +7,14 @@
 (= (type x) t)
 )

-(def *instr* '())
+(def *instr* (atom '()))

 (defn emit [x]
 ;;I'm not sure what the best way to implement this is yet. But emit just appends x to the end of a list, so theres not too much to it.
 ;;emit should return nil.
 	(do
-			(binding [*instr* (cons x *instr*)])
+			(reset! *instr* (cons x (deref *instr*)))
 	nil)
 )

@@ -33,7 +33,7 @@
 ;;Entry function to maximal munch.
 (defn select [irtree]
 	(do
-		(binding [*instr* '()]) ;;reset instr to empty list
+		(reset! *instr* '()) ;;reset instr to empty list
 		(munch irtree)
 		 *instr*))


Reduce initial window size

Reduce initial window size

--- src/clj/nightcode/core.clj
+++ src/clj/nightcode/core.clj
@@ -37,7 +37,7 @@

 (defn -start [^nightcode.core app ^Stage stage]
   (let [root (FXMLLoader/load (io/resource "main.fxml"))
-        scene (Scene. root 1242 768)
+        scene (Scene. root 1200 600)
         project-tree (.lookup scene "#project_tree")
         content (.lookup scene "#content")]
     (swap! *runtime-state assoc


Send new request before reporting result

--- src/clj_tutorials/core.clj
+++ src/clj_tutorials/core.clj
@@ -97,8 +97,8 @@
         (chan-http-get-with-timeout url timeout c))
     (go-loop [i 0]
       (let [[result c] (async/alts! cs)]
+        (chan-http-get-with-timeout url timeout c)
         (>! results result)
-        (chan-http-get-with-timeout url timeout c)
         (when (<= i number-of-requests)
           (recur (inc i)))))
     (repeatedly number-of-requests #(<!! results))))


Add :free-attack-once state-map

Add :free-attack-once state-map

--- src/cljs/zetawar/data.cljs
+++ src/cljs/zetawar/data.cljs
@@ -142,6 +142,23 @@
                             {:attack-unit  :done
                              :capture-base :done}}
        :moved-0-attacked-1 {:transitions
+                            {:attack-unit  :done
+                             :capture-base :done}}
+       :done               {}}}
+
+     :free-attack-once
+     {:start-state :start
+      :built-state :done
+      :states
+      {:start              {:transitions
+                            {:move-unit    :moved-1-attacked-0
+                             :attack-unit  :moved-0-attacked-1
+                             :repair-unit  :done
+                             :capture-base :done}}
+       :moved-0-attacked-1 {:transitions
+                            {:move-unit    :done
+                             :capture-base :done}}
+       :moved-1-attacked-0 {:transitions
                             {:attack-unit  :done
                              :capture-base :done}}
        :done               {}}}


Fix reflection.

Fix reflection.

--- src/clojure/parkour/fs.clj
+++ src/clojure/parkour/fs.clj
@@ -78,4 +78,6 @@
 (defn path-list
   "List the entries in the directory at path `p`."
   ([p] (path-list (path-fs p) p))
-  ([fs p] (map #(.getPath ^FileStatus %) (.listStatus fs (path p)))))
+  ([fs p]
+     (->> (.listStatus ^FileSystem fs (path p))
+          (map #(.getPath ^FileStatus %) ))))


Simplify

Simplify

--- src/advent_2017/day_08.cljc
+++ src/advent_2017/day_08.cljc
@@ -13,8 +13,8 @@

 (def data (->> (repeatedly #(read {:eof nil} input)) (take-while some?) (s/conform ::instr)))

-(defn inc [a b] (+ a b))
-(defn dec [a b] (- a b))
+(def inc +)
+(def dec -)
 (def != not=)

 (def register-history


Use unchecked math

Use unchecked math

--- src/advent_2017/day_15.cljc
+++ src/advent_2017/day_15.cljc
@@ -1,5 +1,7 @@
 (ns advent-2017.day-15
   #?(:cljs (:require-macros [advent-2017.day-15 :refer [solve a-gen b-gen multiples]])))
+
+#?(:clj (set! *unchecked-math* :warn-on-boxed))

 (when #?(:clj true :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))

@@ -10,8 +12,8 @@
     `(loop [sum# 0 ~a input-a ~b input-b count# 0]
        (if (== count# ~max-count)
          sum#
-         (let [next-a# ~a-gen
-               next-b# ~b-gen]
+         (let [next-a# (long ~a-gen)
+               next-b# (long ~b-gen)]
            (if (== (bit-and next-a# 0xFFFF) (bit-and next-b# 0xFFFF))
              (recur (inc sum#) next-a# next-b# (inc count#))
              (recur sum# next-a# next-b# (inc count#)))))))


Fix a little bit

Fix a little bit

--- src/antlion_clojure/bot.clj
+++ src/antlion_clojure/bot.clj
@@ -453,7 +453,7 @@
         (map->Payload
           {:type :message
            :channel channel-id
-           :text (str "ﾜｰﾆﾝ!つ = [Co2濃度" (:value co2) "ppmを超えました")})))))
+           :text (str "ﾜｰﾆﾝ!つ = [Co2濃度" max-ppm "ppmを超えました]")})))))

 (defn register-events!
   [{:keys [slack dynamodb] :as opt}]
@@ -470,7 +470,8 @@
     (println ";; Starting BotComponent")
     (register-events! {:slack slack
                        :dynamodb dynamodb})
-    (go-loop [in {:value 0}]
+    (go-loop [in {:value (or (some-> (dynamodb/get-lemming-last-state dynamodb) :state)
+                             0)}]
       (when in
         (lemming-handler this in)
         (recur (<! (subscribe lemming-repository)))))


change the mutation record structure

change the mutation record structure

--- src_cljs/rrm/corecljs.cljs
+++ src_cljs/rrm/corecljs.cljs
@@ -34,7 +34,7 @@
                           :is-searched-results false
                           :user nil}))

-(def serverhost "http://192.168.0.114:9000/")
+(def serverhost "http://localhost:9000/")

 (defn set-key-value [k v]
   (reset! storage (assoc @storage k v)))
@@ -494,51 +494,64 @@

 (defn mutation-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
-                             :mutationnumber (.-mutationnumber dmt)
+                             :mutationnumber (.-mutationnumber (.-numbers dmt))
                              :nameofthefirstparty (.-nameofthefirstparty dmt)
                              :nameofthesecondparty (.-nameofthesecondparty dmt)
                              :dateofinstitution (.-dateofinstitution dmt)
                              :nameofpo (.-nameofpo dmt)
                              :dateofdecision (.-dateofdecision dmt)
                              :title (.-title dmt)
-                             :khasranumber (.-khasranumber dmt)
-                             :khatakhatuninumber (.-khasranumber dmt)
+                             :khasranumber (.-khasranumber (.-numbers dmt))
+                             :khatakhatuninumber (.-khasranumber (.-numbers dmt))
                              :area (.-area dmt)
-                             :o2number (.-o2number dmt)
-                             :o4number (.-o4number dmt)
-                             :o6number (.-o6number dmt)
-                             :racknumber (.-racknumber dmt)
+                             :o2number (.-o2number (.-numbers dmt))
+                             :o4number (.-o4number (.-numbers dmt))
+                             :o6number (.-o6number (.-numbers dmt))
+                             :racknumber (.-racknumber (.-numbers dmt))
                              :receiveddate (.-receiveddate dmt)
                              :remarks (.-remarks dmt)
-                             :villageid (.-villageid dmt)
-                             :subdivisionid (.-subdivisionid dmt)
-                             :districtid (.-districtid dmt)
+                             :villageid (.-id (.-village dmt))
+                             :subdivisionid (.-id (.-subdivision dmt))
+                             :districtid (.-id (.-district dmt))
                              :isactive true})
         focus (r/atom nil)]
     (fn [] [mutation-template
-            "Mutation Update Form"
-            update-data
-            focus
-            #(update-form-onclick update-data focus) sub-division-id])))
-
+           "Mutation Update Form"
+           update-data
+           focus
+           #(update-form-onclick update-data focus) sub-division-id])))
+
+(defn map-mutation-data [mut]
+  {:id (if (nil? (mut :id))0 (int (mut :id))) :nameofthefirstparty (mut :nameofthefirstparty)
+   :nameofthesecondparty (:nameofthesecondparty mut) :dateofinstitution (mut :dateofinstitution) :nameofpo (mut :nameofpo)
+   :dateofdecision (:dateofdecision mut) :title (:title mut) :area (:area mut)
+   :numbers {:mutationnumber (mut :mutationnumber) :khasranumber (mut :khasranumber) :racknumber (mut :racknumber)
+             :o4number (mut :o4number) :o2number (mut :o2number) :khatakhatuninumber (mut :khatakhatuninumber)
+             :o6number (mut :o6number)}
+   :village {:id (str (mut :villageid))  :name ""}
+   :subdivision {:id (mut :subdivisionid) :name ""}
+   :district {:id (mut :districtid) :name ""}
+   :remarks (mut :remarks)})

 (defn add-form-onclick [data-set focus]
   (if (= nil (form-validator @data-set))
     (let [onres (fn[json]
                   (secretary/dispatch! "/"))
-          data (swap! data-set dissoc :districtid :subdivisionid)]
+                                        ; data (swap! data-set dissoc :districtid :subdivisionid)
+          ]
       (http-post (str serverhost "mutations")
-                     onres  (.serialize (Serializer.) (clj->js data))))
+                 onres  (.serialize (Serializer.) (clj->js (map-mutation-data @data-set)))))
     (reset! focus "on")))

 (defn update-form-onclick [data-set focus]
   (if (= nil (form-validator @data-set))
-     (let [onres (fn[data]
-                   (secretary/dispatch! "/"))
-           data (swap! data-set dissoc :districtid :subdivisionid)]
-          (http-put (str serverhost "mutations/" (:id @data-set))
-                    onres (.serialize (Serializer.) (clj->js data)))))
-    (reset! focus "on"))
+    (let [onres (fn[data]
+                  (secretary/dispatch! "/"))
+         ; data (swap! data-set dissoc :districtid :subdivisionid)
+          ]
+      (http-put (str serverhost "mutations/" (:id @data-set))
+                onres (.serialize (Serializer.) (clj->js (map-mutation-data @data-set))))))
+  (reset! focus "on"))

 (defn form-cancel [event]
   (secretary/dispatch! "/"))
@@ -680,7 +693,7 @@
         [:th "Name of The SecondParty"]
         [:th "Date of Institution"]
         [:th "Name of P.O"]
-        ;;  [:th "Name of Districts"]
+        [:th "Name of District"]
         [:th "Name of Village"]
         [:th "SubDivisionName"]
         [:th " "]
@@ -689,14 +702,14 @@
       [:tbody
        (for [mt mutations]
          ^{:key (.-id mt)} [:tr
-                            [:td (.-mutationnumber mt)]
+                            [:td (.-mutationnumber (.-numbers mt))]
                             [:td (.-nameofthefirstparty mt)]
                             [:td (.-nameofthesecondparty mt)]
                             [:td (.-dateofinstitution mt)]
                             [:td (.-nameofpo mt)]
-                            ;; [:td (.-districtname mt)]
-                            [:td (.-villagename mt)]
-                            [:td (.-subdivisionname mt)]
+                            [:td (.-name (.-district  mt))]
+                            [:td (.-name (.-village mt))]
+                            [:td (.-name (.-subdivision mt))]
                             [:td [:a {:href "javascript:;" :on-click  #(click-update (.-id mt))  :class "btn btn-success btn-sm glyphicon glyphicon-edit"}]]
                             [:td  [:a {:href "javascript:;" :on-click #(delete(.-id mt))  :class "btn btn-danger btn-sm glyphicon glyphicon-remove"}] ]])]]
      [:div{:class "col-xs-6 col-centered col-max"} [shared-state 0]]]]])
@@ -2765,6 +2778,7 @@
                 (let [dt (getdata json)]
                   (set-key-value :mutations (.-data dt))
                   (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
+                  (js/console.log (.-mutationnumber (.-numbers (first (get-value! :mutations)))))
                   (set-key-value :page-location  [render-mutations (get-value! :mutations)])))
         dist-res (fn[json] (set-key-value :districts (getdata json)))]
     (do


log native form.

log native form.

--- src/metabase/query_processor.clj
+++ src/metabase/query_processor.clj
@@ -436,11 +436,13 @@
    If this is an MBQL query then we first call `mbql->native` which builds a database dependent form for execution and
    then we pass that form into the `execute-query` function for final execution.

-   If the query is already a NATIVE query then we simply pass it through to `execute-query` unmodified."
+   If the query is already a *native* query then we simply pass it through to `execute-query` unmodified."
   [query]
-  (let [native-form  (if-not (mbql-query? query)
-                       (:native query)
-                       (driver/mbql->native (:driver query) query))
+  (let [native-form  (u/prog1 (if-not (mbql-query? query)
+                                (:native query)
+                                (driver/mbql->native (:driver query) query))
+                       (when-not *disable-qp-logging*
+                         (log/debug (u/format-color 'green "NATIVE FORM:\n%s\n" (u/pprint-to-str <>)))))
         native-query (if-not (mbql-query? query)
                        query
                        (assoc query :native native-form))


Fixed variable name error

Fixed variable name error

2d4d721 did not rename all variables correctly.

--- src/ardoq/analytics_clj.clj
+++ src/ardoq/analytics_clj.clj
@@ -44,7 +44,7 @@
      (let [the-callback (if callback (reify Callback (onResponse [this success message] (callback success message))))
            traits (reduce (fn [t [k v]] (.put t (name k) v)) (Traits.) traits)
            options (reduce (fn [t [k v]] (.put t (name k) v)) (Context.) options)]
-       (.identify client user-id traits timestamp c the-callback))))
+       (.identify client user-id traits timestamp options the-callback))))

 (defn track


add trailing slash to make tests pass on circleCI

--- test/nha/run.clj
+++ test/nha/run.clj
@@ -1,7 +1,8 @@
 (ns nha.run
   (:require  [clojure.test :as t]
              [boot.core :as boot]
-             [adzerk.boot-test :as boot-test])
+             [adzerk.boot-test :as boot-test]
+             [clojure.java.io :as io])
   (:import [java.nio.file Files Path Paths]
            [java.nio.file.attribute BasicFileAttributes]))

@@ -11,7 +12,9 @@
 (def js-expected-path "test/resources/samples/js/expected/")
 ;;(def js-output-path "test/resources/samples/js/minified/")
 ;;(def js-output-path (Files/createTempDirectory "boot_uglify" (into-array java.nio.file.attribute.FileAttribute []))) ;; problem: appends timestamp to file names inside this folder
-(def js-output-path (System/getProperty "java.io.tmpdir"))
+
+;; this is inconsistent depending on the platform, so always make sure it ends with a trailing slash
+(def js-output-path (str (.getPath (io/file (System/getProperty "java.io.tmpdir"))) "/"))
 ;; (def js-output-path (.getPath (boot/tmp-dir!)))

 (defn setup-tests [test-out-dir]


remove inspector

remove inspector

--- src/clj/ceres/inspector.clj
+++ src/clj/ceres/inspector.clj
@@ -1,67 +0,0 @@
-(ns ceres.inspector
-  (:require [ceres.curator :refer [get-tweets get-mentions get-retweets get-replies]]
-            [incanter.stats :refer [dice-coefficient-str]]))
-
-;; from http://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#Clojure
-
-(defn nextelt
-  "Given two characters, the previous row, and a row we are
-  building, determine out the next element for this row."
-  [char1 char2 prevrow thisrow position]
-  (if (= char1 char2)
-    (prevrow (- position 1))
-    (+ 1 (min
-      (prevrow (- position 1))
-      (prevrow position)
-      (last thisrow)))))
-
-
-(defn nextrow
-  "Based on the next character from string1 and the whole of string2
-  calculate the next row. Initially thisrow contains one number."
-  [char1 str2 prevrow thisrow]
-  (let [char2 (first str2)
-        position (count thisrow)]
-    (if (= (count thisrow) (count prevrow))
-      thisrow
-      (recur
-        char1
-        (rest str2)
-        prevrow
-        (conj thisrow (nextelt char1 char2 prevrow thisrow position))))))
-
-
-(defn levenshtein-distance
-  "Calculate the Levenshtein distance between two strings."
-  ([str1 str2]
-  (let [row0 (vec (map first (map vector (iterate inc 1) str2)))]
-    (levenshtein-distance 1 (vec (cons 0 row0)) str1 str2)))
-  ([row-nr prevrow str1 str2]
-    (let [next-row (nextrow (first str1) str2 prevrow (vector row-nr))
-          str1-remainder (.substring str1 1)]
-      (if (= "" str1-remainder)
-        (last next-row)
-        (recur (inc row-nr) next-row str1-remainder str2)))))
-
-
-(defn create-index [users]
-  (->> (map
-        (fn [user]
-          (vec [user
-                (->> (get-tweets user)
-                     (map #(vec [(:id %)
-                                 (into {} [[:tweet %]
-                                           [:retweets {}]
-                                           [:replies {}]
-                                           [:shared {}]])]))
-                     vec
-                     (into {}))]))
-        users)
-       vec
-       (into {})))
-
-(comment
-
-  (time (dice-coefficient-str "Linkspartei: Abschied von Rot-Rot-Grün http://t.co/bvuMUtt8oi via @faz_net" "Fußball-Nationalmannschaft : Löws Klein-Klein  http://t.co/t83EYklLE5 via @faz_net"))
-
-  )


Add with credentials to both GET & POST, to make newest Safari work.

--- src/cljs/movement/util.cljs
+++ src/cljs/movement/util.cljs
@@ -18,6 +18,7 @@
 (defn GET [url & [opts]]
   (let [base-opts {:format          (edn-request-format)
                    :response-format (edn-response-format)
+                   :with-credentials true
                    :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                       :request #(assoc-in % [:headers "authorization"]
                                                                           (str "Token " (session/get :token)))})]}]
@@ -26,6 +27,7 @@
 (defn POST [url & [opts]]
   (let [base-opts {:format          (edn-request-format)
                    :response-format (edn-response-format)
+                   :with-credentials true
                    :interceptors    [(to-interceptor {:name    "Token Interceptor"
                                                       :request #(assoc-in % [:headers "authorization"]
                                                                           (str "Token " (session/get :token)))})]


remove 400 case from default error handler, using else

--- src/cljs/swarmpit/ajax.cljs
+++ src/cljs/swarmpit/ajax.cljs
@@ -19,14 +19,13 @@
 (defn- command-error
   [{:keys [body headers]} status]
   (cond
-    (= 400 status) (message/error (str (or (:error body) body)))
     (and (= 401 status)
          (= "swarmpit" (:x-backend-server headers))) (router/set-location {:handler :login})
     (and (= 403 status)
          (= "swarmpit" (:x-backend-server headers))) (router/set-location {:handler :unauthorized})
     (= 404 status) (router/set-route {:handler :not-found})
     (= 500 status) (message/error (str (or (:cause body) "Server request failed")))
-    :else (message/error (str (or body "Server request failed")))))
+    :else (message/error (str (or (:error body) body "Server request failed")))))

 (defn- command
   "Customized ajax command:


ajax -> stringify else mssg

ajax -> stringify else mssg

--- src/cljs/swarmpit/ajax.cljs
+++ src/cljs/swarmpit/ajax.cljs
@@ -19,13 +19,14 @@
 (defn- command-error
   [{:keys [body headers]} status]
   (cond
+    (= 400 status) (message/error (str (or (:error body) body)))
     (and (= 401 status)
          (= "swarmpit" (:x-backend-server headers))) (router/set-location {:handler :login})
     (and (= 403 status)
          (= "swarmpit" (:x-backend-server headers))) (router/set-location {:handler :unauthorized})
     (= 404 status) (router/set-route {:handler :not-found})
     (= 500 status) (message/error (str (or (:cause body) "Server request failed")))
-    :else (message/error body)))
+    :else (message/error (str (or body "Server request failed")))))

 (defn- command
   "Customized ajax command:


Removing warnings

Removing warnings

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -325,11 +325,9 @@
 (defn show-top-panel
   [scores player]
   [:div.scores
-   (concat
-     [[top-panel-button #(reset! app-state (new-game)) (special-char "↻")]]
-     (show-scores scores player)
-     [[top-panel-button #(swap! app-state update :help not) "?"]]
-     )])
+   [top-panel-button #(reset! app-state (new-game)) (special-char "↻")]
+   (show-scores scores player)
+   [top-panel-button #(swap! app-state update :help not) "?"]])

 (defn run-game []
   [:div


Use greyscale (unavailable) image if unit isn't affordable

--- src/cljs/zetawar/views.cljs
+++ src/cljs/zetawar/views.cljs
@@ -269,8 +269,11 @@
       (into [:div.unit-picker]
             (for [{:keys [unit-type/id] :as unit-type} unit-types]
               (let [;; TODO: replace with unit-type-image
+                    color-or-grey (if (:affordable unit-type)
+                                    color
+                                    "unavailable")
                     image (->> (string/replace (:unit-type/image unit-type)
-                                               "COLOR" color)
+                                               "COLOR" color-or-grey)
                                (str "/images/game/"))
                     media-class (if (:affordable unit-type)
                                   "media clickable"


Improve file blob store logic.

Improve file blob store logic.

Now checks for existing blobs and makes stored blob files read-only.

--- src/vault/store/file.clj
+++ src/vault/store/file.clj
@@ -30,6 +30,31 @@
                                    (subs (inc (count root)))
                                    (string/split #"/"))]
       (blob/ref algorithm (string/join digest)))))
+
+
+; As a long-term idea, this could try to buffer in memory up to a certain
+; threshold before spooling to disk.
+(defn- spool-tmp-file!
+  "Spool input stream to a temporary landing file."
+  ^java.io.File
+  [root content]
+  (let [tmp-file (io/file root "tmp" (str "landing-" (System/currentTimeMillis)))]
+    (io/make-parents tmp-file)
+    (io/copy content tmp-file)
+    tmp-file))
+
+
+(defn- store-blob-file!
+  "Integrates a landing file into the blob store."
+  ^java.io.File
+  [^java.io.File tmp
+   ^java.io.File file]
+  (io/make-parents file)
+  (when-not (.renameTo tmp file)
+    (throw (RuntimeException.
+             (str "Failed to rename landing file " tmp
+                  " to stored blob " file))))
+  (.setWritable file false false))

 (defn- probe-content-type
@@ -93,18 +118,13 @@

   (store! [this content]
-    (let [tmp (io/file root "tmp"
-                       (str "landing-" (System/currentTimeMillis)))]
-      (io/make-parents tmp)
-      (io/copy content tmp)
-      (let [blobref (blob/digest algorithm tmp)
-            file (blobref->file root blobref)]
-        (io/make-parents file)
-        (when-not (.renameTo tmp file)
-          (throw (RuntimeException.
-                   (str "Failed to rename landing file " tmp
-                        " to stored blob " file))))
-        blobref)))
+    (let [tmp (spool-tmp-file! root content)
+          blobref (blob/digest algorithm tmp)
+          file (blobref->file root blobref)]
+      (if (.exists file)
+        (.delete tmp)
+        (store-blob-file! tmp file))
+      blobref))

   (remove! [this blobref]


Don't start deployer when running app in prod mode (#143)

--- src/name_bazaar/server/core.cljs
+++ src/name_bazaar/server/core.cljs
@@ -9,6 +9,7 @@
     [mount.core :as mount]
     [name-bazaar.server.api]
     [name-bazaar.server.db]
+    [name-bazaar.server.deployer]
     [name-bazaar.server.emailer]
     [name-bazaar.server.syncer]
     [name-bazaar.shared.smart-contracts]
@@ -37,6 +38,7 @@
                                       (log/warn "Ethereum node went offline")
                                       (mount/stop #'name-bazaar.server.syncer/syncer
                                                   #'name-bazaar.server.emailer/emailer))}})
+      (mount/except [#'name-bazaar.server.deployer/deployer])
       (mount/start))
   (log/warn "System started" {:config (medley/dissoc-in @config [:emailer :private-key])}))


Fix protocols.

Fix protocols.

--- src/onyx/plugin/bench_plugin.clj
+++ src/onyx/plugin/bench_plugin.clj
@@ -54,10 +54,10 @@
   (seal-resource [this event])

   p-ext/PipelineInput
-  (ack-message [_ _ message-id]
+  (ack-segment [_ _ message-id]
     (swap! pending-messages dissoc message-id))

-  (retry-message
+  (retry-segment
     [_ _ message-id]
     (when-let [msg (get @pending-messages message-id)]
       (swap! retry conj msg)


Minor style improvement

Minor style improvement

--- src/foreclojure/social.clj
+++ src/foreclojure/social.clj
@@ -31,7 +31,7 @@
        "text=" (URLEncoder/encode status)
        "&url=" (URLEncoder/encode
 	        (str "https://4clojure.com/problem/" id))
-       "&related=4clojure"
+       "&related=4clojure"
        "\">"
        (or anchor-text "Twitter")
        "</a>"))
@@ -52,7 +52,7 @@
       (->> (gist/new-gist {} filename text)
            :repo
            (str "https://gist.github.com/"))
-      (catch Throwable _ nil))))
+      (catch Throwable _))))

 (defn tweet-solution [id gist-url & [link-text]]
   (let [status-msg (str "Check out how I solved problem #"


Added fetch middleware

Added fetch middleware

--- src/wishlistd/server.clj
+++ src/wishlistd/server.clj
@@ -1,7 +1,9 @@
 (ns wishlistd.server
-  (:require [noir.server :as server]))
+  (:require [noir.server :as server]
+  	        [noir.fetch.remotes :as remotes]))

 (server/load-views "src/wishlistd/views/")
+(server/add-middleware remotes/wrap-remotes)

 (defn -main [& m]
   (let [mode (keyword (or (first m) :dev))


Add simple printing of individual failures

--- src/radicalzephyr/boot_junit.clj
+++ src/radicalzephyr/boot_junit.clj
@@ -56,6 +56,16 @@
       (println (style (.getDisplayName ignored) :yellow))
       (println))))

+(defn- print-failed-tests [test-failures]
+  (when (seq test-failures)
+    (println "Failed:")
+    (println)
+    (doseq [failure test-failures]
+      (println (.getTestHeader failure))
+      (println (style (.getTrace failure)
+                      :red))
+      (println))))
+
 (defn- run-listener [packages]
   (let [running-tests (atom #{})
         ignored-tests (atom #{})]
@@ -68,7 +78,7 @@
       (testRunFinished [result]
         (println "\n")
         (print-ignored-tests @ignored-tests)
-
+        (print-failed-tests (.getFailures result))
         (when (> (.getFailureCount result) 0)
           (println (result->map result))))


Add logging/done to module command success cases

--- src/containium/commands.clj
+++ src/containium/commands.clj
@@ -110,22 +110,26 @@
                    (let [path (or path (get @path-cache name))
                          descriptor (when path (modules/module-descriptor (as-file path)))]
                      (swap! path-cache assoc name path)
-                     (modules/activate! (:modules systems) name descriptor command-logger))
+                     (modules/activate! (:modules systems) name descriptor command-logger)
+                     (logging/done command-logger true))
                    (do (error-command command-logger "Missing name argument.")
                        (logging/done command-logger false)))

       "deactivate" (if name
-                     (modules/deactivate! (:modules systems) name command-logger)
+                     (do (modules/deactivate! (:modules systems) name command-logger)
+                         (logging/done command-logger true))
                      (do (error-command command-logger "Missing name argument.")
                          (logging/done command-logger false)))

       "kill" (if name
-               (modules/kill! (:modules systems) name command-logger)
+               (do (modules/kill! (:modules systems) name command-logger)
+                   (logging/done command-logger true))
                (do (error-command command-logger "Missing name argument.")
                    (logging/done command-logger false)))

       "versions" (if name
-                   (modules/versions (:modules systems) name command-logger)
+                   (do (modules/versions (:modules systems) name command-logger)
+                       (logging/done command-logger true))
                    (do (error-command command-logger "Missing name argument")
                        (logging/done command-logger false)))


fix: instances info should be vector

fix: instances info should be vector

--- src/dokkaa_builder/apps.clj
+++ src/dokkaa_builder/apps.clj
@@ -32,13 +32,13 @@
   (let [backends (choose-backends)
         front-url (default-frontend-url app-name)
         old-isntances (get-in @apps [(keyword app-name) :instances])
-        new-instances (doall (for [{cli :client host-port :port} backends]
-                           (let [id (docker/run cli image
-                                      :tag tag
-                                      :cmd command
-                                      :port-bindings {host-port port})
-                                 upstream (upstream-url cli host-port)]
-                             {:id id, :host upstream})))]
+        new-instances (vec (for [{cli :client host-port :port} backends]
+                             (let [id (docker/run cli image
+                                        :tag tag
+                                        :cmd command
+                                        :port-bindings {host-port port})
+                                   upstream (upstream-url cli host-port)]
+                               {:id id, :host upstream})))]
     (when old-isntances (router/delete-domain front-url))
     (apply router/add-domain front-url (map :host new-instances))
     (swap! apps assoc (keyword app-name) {:image      image


Start implementing reflection

Start implementing reflection

This is a horribly broken check-in, but I have to do what I can manage
in a super-limited time frame right now

--- src/frereth_common/util.clj
+++ src/frereth_common/util.clj
@@ -1,5 +1,10 @@
 (ns frereth-common.util
-  (:require [puget.printer :as puget]))
+  (:require [puget.printer :as puget]
+            [ribol.core :refer (raise)]
+            [schema.core :as s]))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; TODO

 ;; Global functions like this are bad.
 ;; Especially since I'm looking at a
@@ -9,6 +14,35 @@
 ;; instead
 (puget/set-color-scheme! :keyword [:bold :green])

+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Internal
+
+(defn describe-annotations
+  [as]
+  (raise :not-implemented))
+
+(s/defn interpret-modifiers :- s/Keyword
+  [ms :- s/Int]
+  (raise :not-implemented))
+
+(defn describe-field
+  [f]
+  {:name (.getName f)
+   :annotations (map describe-annotations (.getDeclaredAnnotations f))
+   :modifiers (interpret-modifiers (.getModifiers f))})
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Public
+
 (defn pretty
   [& os]
   (with-out-str (apply puget/cprint os)))
+
+(defn dir
+  [something]
+  (let [k (class something)
+        fields (.getDeclaredFields k)
+        useful-fields (map describe-field fields)
+        methods (.getDeclaredMethods k)]
+    {:fields useful-fields}
+    (raise :not-implemented)))


fix load-deps bugs

fix load-deps bugs

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -130,8 +130,10 @@

 (defn load-deps
   ([bound-vars ana-env lib deps cb]
-   (analyze-deps bound-vars lib deps nil cb))
+   (analyze-deps bound-vars ana-env lib deps nil cb))
   ([bound-vars ana-env lib deps opts cb]
+   (when (:verbose opts)
+     (debug-prn "Loading dependencies"))
    (let [compiler @(:*compiler* bound-vars)]
      (binding [ana/*cljs-dep-set* (vary-meta (conj (:*cljs-dep-set* bound-vars) lib)
                                     update-in [:dep-path] conj lib)]
@@ -144,7 +146,7 @@
              (debug-prn "Loading" dep))
            (require bound-vars dep opts
              (fn [_]
-               (load-deps bound-vars lib (next deps) opts cb))))
+               (load-deps bound-vars ana-env lib (next deps) opts cb))))
          (cb))))))

 (defn analyze-deps
@@ -232,7 +234,7 @@
                    (cb ast)))]
          (cond
            (and load (seq deps))
-           (load-deps bound-vars name deps (dissoc opts :macros-ns)
+           (load-deps bound-vars ana-env (:name ast) deps (dissoc opts :macros-ns)
              check-uses-and-load-macros)

            (and (not load) (:*analyze-deps* bound-vars) (seq deps))


PLD: remove subs without a download URLs, handle missing small URL, handle already fully qualified URLs

--- src/hatti/views/photos.cljs
+++ src/hatti/views/photos.cljs
@@ -16,10 +16,12 @@
 (def num-columns 3)

 (defn- make-url
-  "Remove the API namespace prefix from a URI string and convert to a fully
-   qualified URL."
-  [str]
-  (remote/make-url (replace str #"/api/v1" "")))
+  "If not a fully qualified URL, remove the API namespace prefix from a URI
+   string and convert to a fully qualified URL."
+  [s]
+  (if (= (subs s 0 4) "http")
+    s
+    (remote/make-url (replace s #"/api/v1" ""))))

 (defn- build-caption
   [item]
@@ -74,7 +76,13 @@
 (defn- build-photos
   "Build photos for photoswipe from a set of form data."
   [data]
-  (let [data-with-attachments (filter #(get % constants/_attachments) data)
+  ;; Remove data without an attachment or download URL
+  (let [data-with-attachments (filter
+                               (fn [datum]
+                                 (seq
+                                  (map #(get % constants/download-url)
+                                       (get datum constants/_attachments))))
+                               data)
         total (reduce #(+ %1 (count (get %2 constants/_attachments)))
                       0 data-with-attachments)]
     (loop [data-left data-with-attachments
@@ -90,18 +98,20 @@
             result
             (map-indexed
              (fn [j attachment]
-               {:src (resize-image
-                      (make-url (get attachment constants/download-url))
-                      width-px
-                      width-px)
-                :thumb (make-url (get attachment constants/small-download-url))
-                :title (format "%s/%s | Submission %s"
-                               (+ photo-index j) total rank)
-                :date (get datum constants/_submission_time)
-                :id (get datum constants/_id)
-                :rank rank
-                :w width-px
-                :h width-px})
+               (let [download-url (get attachment constants/download-url)]
+                 {:src (resize-image (make-url download-url)
+                                     width-px
+                                     width-px)
+                  :thumb (make-url
+                          (or (get attachment constants/small-download-url)
+                              download-url))
+                  :title (format "%s/%s | Submission %s"
+                                 (+ photo-index j) total rank)
+                  :date (get datum constants/_submission_time)
+                  :id (get datum constants/_id)
+                  :rank rank
+                  :w width-px
+                  :h width-px}))
              attachments))
            (+ photo-index (count attachments))))
         result))))


add progress bar

add progress bar

--- src/solar_system_of_js/draw.cljs
+++ src/solar_system_of_js/draw.cljs
@@ -1,6 +1,7 @@
 (ns solar-system-of-js.draw
   (:require
     [solar-system-of-js.state :refer [state]]
+    [solar-system-of-js.nav :refer [num-slides]]
     [solar-system-of-js.canvas :refer [width height
                                        fill-style!
                                        stroke-style!
@@ -440,6 +441,19 @@
   (scale! zoom zoom)
   (rotate! angle))

+(defn draw-progress!
+  []
+  (let [i (:slide @state)
+        end-i (dec num-slides)
+        len (* width (/ i end-i))]
+
+    (begin-path!)
+    (move-to! 0 0)
+    (line-to! len 0)
+    (line-width! 10)
+    (stroke-style! "#ACC")
+    (stroke!)))
+
 (defn draw!
   "Draw the current state of the application."
   []
@@ -467,5 +481,6 @@
   (draw-dart! (:dart @state))
   (draw-clojurescript! (:clojurescript @state))

-  (restore!))
-
+  (restore!)
+  (draw-progress!))
+


cleanup

cleanup

Former-commit-id: 70f204681b94eeed4bde0aaf970a4a0e53058452

--- src/status_im/chat/handlers.cljs
+++ src/status_im/chat/handlers.cljs
@@ -46,10 +46,10 @@

 (defn invoke-suggestions-handler!
   [{:keys [current-chat-id] :as db} _]
-  (let [commands (get-in db [:chats current-chat-id :commands])
-        {:keys [command content]} (get-in db [:chats current-chat-id :command-input])
-        path     [(if (commands command) :commands :responses)
-                  (:name command)
+  (let [{:keys [command content]} (get-in db [:chats current-chat-id :command-input])
+        {:keys [name type]} command
+        path     [(if (= :command type) :commands :responses)
+                  name
                   :params
                   0
                   :suggestions]
@@ -78,11 +78,11 @@
   (assoc-in db [:chats current-chat-id :input-text] text))

 (defn invoke-command-preview!
-  [{:keys [current-chat-id staged-command] :as db} _]
-  (let [commands (get-in db [:chats current-chat-id :commands])
-        {:keys [command content]} staged-command
-        path     [(if (commands command) :commands :responses)
-                  (:name command)
+  [{:keys [current-chat-id staged-command]} _]
+  (let [{:keys [command content]} staged-command
+        {:keys [name type]} command
+        path     [(if (= :command type) :commands :responses)
+                  name
                   :preview]
         params   {:value content}]
     (j/call current-chat-id
@@ -258,18 +258,18 @@
                            (dissoc new-command :rendered-preview))))

 (defn invoke-commands-handlers!
-  [{:keys [new-commands current-chat-id] :as db}]
-  (let [commands (get-in db [:chats current-chat-id :commands])]
-    (doseq [{:keys [content] :as com} new-commands]
-      (let [{:keys [command content]} content
-            path   [(if (commands command) :commands :responses)
-                    command
-                    :handler]
-            params {:value content}]
-        (j/call current-chat-id
-                path
-                params
-                #(dispatch [:command-handler! com %]))))))
+  [{:keys [new-commands current-chat-id]}]
+  (doseq [{:keys [content] :as com} new-commands]
+    (let [{:keys [command content]} content
+          type (:type command)
+          path [(if (= :command type) :commands :responses)
+                command
+                :handler]
+          params {:value content}]
+      (j/call current-chat-id
+              path
+              params
+              #(dispatch [:command-handler! com %])))))

 (defn handle-commands
   [{:keys [new-commands]}]


[Fixes #10751] Remove messages & list when blocking

Signed-off-by: Andrea Maria Piana <39e16ece3c2d27e1889178b15ddb376e524032f8@gmail.com>

--- src/status_im/contact/block.cljs
+++ src/status_im/contact/block.cljs
@@ -23,19 +23,17 @@
                               (fn [[message-id {:keys [from]}]]
                                 (when (= from public-key)
                                   message-id))
-                              (get-in db [:chats chat-id :messages]))
+                              (get-in db [:messages chat-id]))
         db (-> db
                ;; remove messages
-               (update-in [:chats chat-id :messages]
+               (update-in [:messages chat-id]
                           #(apply dissoc % removed-messages-ids))
-               ;; remove message groups
-               (update-in [:chats chat-id]
-                          dissoc :message-list)
                (update-in [:chats chat-id]
                           assoc
                           :unviewed-messages-count unviewed-messages-count
                           :last-message last-message))]
-    {:db (update-in db [:chats chat-id :message-list] message-list/add-many (vals (get-in db [:chats chat-id :messages])))}))
+    {:db (assoc-in db [:message-lists chat-id]
+                   (message-list/add-many nil (vals (get-in db [:messages chat-id]))))}))

 (fx/defn contact-blocked
   {:events [::contact-blocked]}


🔊 Improve dispatcher's logging

🔊 Improve dispatcher's logging

Why:
- If a command failed due to validation failure (e.g. foreign key
  check), the exception was thrown before logging "Dispatch command",
  so the command wasn't logged anywhere
- Exceptions were not logged in the dispatcher, which made it harder to
  read test failure logs, because Kaocha would show the stack trace high
  up as an assertion failure, but the dispatcher log would be very low
  at the end of the stdout
- The full stack trace does not need to be logged in the dispatcher,
  because it will be logged by the caller (the API layer or tests), so
  logging only the exception message avoids logging the same stack trace
  twice
- The exception must not be wrapped into a generic "command failed"
  exception, because it would prevent the caller from handling the
  various exception types differently (e.g. HTTP response codes)

--- src/territory_bro/dispatcher.clj
+++ src/territory_bro/dispatcher.clj
@@ -130,13 +130,17 @@
                (pprint/pprint object))))

 (defn command! [conn state command]
-  (let [command (-> command
-                    (commands/sorted-keys)
-                    (validate-command conn state))
-        _ (log/info "Dispatch command:" (pretty-str command))
-        command-handler (or (get command-handlers (namespace (:command/type command)))
-                            (throw (AssertionError.
-                                    (str "No command handler for command: " (pr-str command)))))
-        events (command-handler conn command state)]
-    (log/info "Produced events:" (pretty-str events))
-    events))
+  (let [command (commands/sorted-keys command)]
+    (try
+      (log/info "Dispatch command:" (pretty-str command))
+      (let [command (validate-command command conn state)
+            command-handler (or (get command-handlers (namespace (:command/type command)))
+                                (throw (AssertionError.
+                                        (str "No command handler for command: " (pr-str command)))))
+            events (command-handler conn command state)]
+        (log/info "Produced events:" (pretty-str events))
+        events)
+      (catch Throwable t
+        ;; the full stack trace will be logged at a higher level
+        (log/warn "Command failed:" (str t))
+        (throw t)))))


Doc Hover: "no doc" message for local symbol (instead of Exception)

--- ccw.util/src/clj/ccw/util/doc_utils.clj
+++ ccw.util/src/clj/ccw/util/doc_utils.clj
@@ -26,13 +26,15 @@
     :text (format "%s:\n%s" title body)))

 (defn render-identity [renderer name ns]
-  (condp = renderer
-    :html (format "%s %s" name (or ns ""))
-    :text (format "%s %s" name (or ns ""))))
+  (when-not (str/blank? name)
+    (condp = renderer
+      :html (format "%s %s" name (or ns ""))
+      :text (format "%s %s" name (or ns "")))))

 (defn- render-sections [renderer sections no-sections-text]
   (let [s (condp = renderer
-            :html (apply str (mapcat vector (repeat "
") (keep identity sections) (repeat "
")))
+            :html (when-let [sections (keep identity sections)]
+                    (apply str (mapcat vector (repeat "
") sections (repeat "
"))))
             :text (str/join "\n\n" (keep identity sections)))]
     (if (str/blank? s)
       (condp = renderer
@@ -55,7 +57,7 @@
       (str "(" optional-meta ")"))))

 (defn header-doc [renderer {:keys [name ns] :as m}]
-  (when name
+  (when-not (str/blank? name)
     (render-lines renderer
                   [(render-identity renderer name ns)
                    (optional-meta m)])))


Uncommented pending specs I accidentally left commented.

--- spec/freefrog/governance_circles_spec.clj
+++ spec/freefrog/governance_circles_spec.clj
@@ -96,7 +96,7 @@
         (apply (second op) (into [sample-anchor role] (drop 2 op)))))))

 ;; Section 2.2.3
-#_(describe "Lead Link Role"
+(describe "Lead Link Role"
   (it "doesn't add domains to the Lead Link")
   (it "doesn't add accountabilities to the Lead Link")
   (it "doesn't remove domains from Lead Link")
@@ -107,7 +107,7 @@
   (it "can delegate a predefined accountability from Lead Link to a policy"))

 ;; Section 2.4
-#_(describe "Role Assignment"
+(describe "Role Assignment"
   ;; Appendix A/Lead Link
   (it "can assign someone to a role")

@@ -119,7 +119,7 @@
   (it "can remove someone from a role"))

 ;; Section 2.5
-#_(describe "Elected Roles"
+(describe "Elected Roles"
   ;; Section 2.5.1
   (it "won't assign the person in the Lead Link role to the Facilitator
     or Rep Link role")


Prevent job dying if peer-replica-view changes

--- src/onyx/peer/function.clj
+++ src/onyx/peer/function.clj
@@ -27,9 +27,8 @@
              pick-peer-fns (:pick-peer-fns @peer-replica-view)
              grouped (group-by #(t/vector (:route %) (:hash-group %)) segments)]
          (run! (fn [[[route hash-group] segs]]
-                 (let [pick-peer-fn (get pick-peer-fns (get egress-tasks route))
-                       target (pick-peer-fn hash-group)]
-                   (when target
+                 (when-let [pick-peer-fn (get pick-peer-fns (get egress-tasks route))]
+                   (when-let [target (pick-peer-fn hash-group)]
                      (when-let [site (peer-site peer-replica-view target)]
                        (onyx.extensions/send-messages messenger event site segs)))))
                grouped))))


Update new.renderer for lein 2.1

Update new.renderer for lein 2.1

--- src/leiningen/droid/new.clj
+++ src/leiningen/droid/new.clj
@@ -17,10 +17,10 @@
   file is simply slurped and the content returned unchanged."
   [name]
   (fn [template & [data]]
-    (let [path (string/join "/" [name (sanitize template)])]
+    (let [res (-> (io/file name (sanitize template)) .getPath io/resource)]
       (if data
-        (render-text (slurp-resource path) data)
-        (io/input-stream (io/resource path))))))
+        (render-text (slurp-resource res) data)
+        (io/input-stream res)))))

 (defn package-to-path [package-name]
   (string/replace package-name #"\." "/"))


carry-schema: fix project url

carry-schema: fix project url

--- contrib/schema/project.clj
+++ contrib/schema/project.clj
@@ -1,7 +1,7 @@
 (defproject
   carry-schema "0.1.0"
   :description "Carry middleware for model validation using Schema."
-  :url "https://github.com/metametadata/carry/tree/master/contrib/history"
+  :url "https://github.com/metametadata/carry/tree/master/contrib/schema"
   :license {:name "MIT" :url "http://opensource.org/licenses/MIT"}

   :dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]


Rewrite partition-limited fn.

Rewrite partition-limited fn.

--- src/merkle_db/partition.clj
+++ src/merkle_db/partition.clj
@@ -48,6 +48,89 @@
                   ::record/first-key
                   ::record/last-key])
     #(= data-type (:data/type %))))
+
+
+
+;; ## Construction Functions
+
+; TODO: make this private
+(defn ^:no-doc partition-limited
+  "Returns a sequence of partitions of the elements of `coll` such that:
+  - No partition has more than `limit` elements
+  - The minimum number of partitions is returned
+  - Partitions are approximately equal in size
+
+  Note that this counts (and hence realizes) the input collection."
+  [limit coll]
+  (let [cnt (count coll)
+        n (min (int (Math/ceil (/ cnt limit))) cnt)]
+    (when (pos? cnt)
+      (letfn [(split [i] (int (* (/ i n) cnt)))
+              (take-parts
+                [i xs]
+                (when (seq xs)
+                  (lazy-seq
+                    (let [length (- (split (inc i)) (split i))
+                          [head tail] (split-at length xs)]
+                      (cons head (take-parts (inc i) tail))))))]
+        (take-parts 0 coll)))))
+
+
+(defn- store-tablet!
+  "Store the given tablet data. Returns a tuple of the family key and named
+  link to the new node."
+  [store family-key tablet]
+  (let [tablet (cond-> tablet
+                 (not= family-key :base)
+                 (tablet/prune))]
+    (when (seq (tablet/read-all tablet))
+      [family-key
+       (mdag/link
+         (if (namespace family-key)
+           (str (namespace family-key) ":" (name family-key))
+           (name family-key))
+         (mdag/store-node! store nil tablet))])))
+
+
+(defn from-records
+  "Constructs a new partition from the given map of record data. The records
+  will be split into tablets matching the given families, if provided. Returns
+  the node data for the persisted partition."
+  [store params records]
+  (let [records (vec (sort-by first (patch/remove-tombstones records))) ; TODO: don't sort?
+        limit (or (::limit params) default-limit)
+        families (or (::record/families params) {})]
+    (when (< limit (count records))
+      (throw (ex-info
+               (format "Cannot construct a partition from %d records overflowing limit %d"
+                       (count records) limit)
+               {::record/count (count records)
+                ::limit limit})))
+    (when (seq records)
+      (->>
+        {:data/type data-type
+         ::tablets (into {}
+                         (map #(store-tablet! store (key %) (tablet/from-records (val %))))
+                         (record/split-data families records))
+         ::membership (into (bloom/create limit)
+                            (map first)
+                            records)
+         ::record/count (count records)
+         ::record/families families
+         ::record/first-key (first (first records))
+         ::record/last-key (first (last records))}
+        (mdag/store-node! store nil)
+        (::node/data)))))
+
+
+(defn partition-records
+  "Divides the given records into one or more partitions. Returns a sequence of
+  node data for the persisted partitions."
+  [store params records]
+  (->> records
+       (patch/remove-tombstones)
+       (partition-limited (::limit params default-limit))
+       (mapv #(from-records store params %))))

@@ -134,35 +217,6 @@

 ;; ## Update Functions
-
-; TODO: make this private
-(defn ^:no-doc partition-limited
-  "Returns a sequence of partitions of the elements of `coll` such that:
-  - No partition has more than `limit` elements
-  - The minimum number of partitions is returned
-  - Partitions are approximately equal in size
-
-  Note that this counts the collection."
-  [limit coll]
-  (let [cnt (count coll)
-        n (min (int (Math/ceil (/ cnt limit))) cnt)]
-    (when (pos? cnt)
-      (->>
-        [nil
-         (->> (range (inc n))
-              (map #(int (* (/ % n) cnt)))
-              (partition 2 1))
-         coll]
-        (iterate
-          (fn [[_ [[start end :as split] & splits] xs]]
-            (when-let [length (and split (- end start))]
-              [(seq (take length xs))
-               splits
-               (drop length xs)])))
-        (drop 1)
-        (take-while first)
-        (map first)))))
-

 (defn- load-tablet
   "Loads data from the given value into a tablet."


Dispatch rendering by spec operator

Dispatch rendering by spec operator

--- src/pinpointer/printer.cljc
+++ src/pinpointer/printer.cljc
@@ -1,24 +1,29 @@
 (ns pinpointer.printer
   (:refer-clojure :exclude [pr prn pr-str])
-  (:require [fipp.edn :as edn]
+  (:require [clojure.spec.alpha :as s]
+            [fipp.edn :as edn]
             [fipp.engine :as fipp]
             [fipp.visit :as visit]))

-(defn- with-highlighting [printer f & args]
-  (if (empty? (:trace printer))
-    [:group "<<<" (apply f (:base-printer printer) args) ">>>"]
-    (apply f (:base-printer printer) args)))
+(defmulti render
+  (fn [{:keys [spec]} f printer x] (when (seq? spec) (first spec))))
+(defmethod render :default [_ f printer x]
+  (f (:base-printer printer) x))

-(defn- pop-trace [printer]
+(defn- wrap [f printer x]
+  (cond (empty? (:trace printer))
+        [:group "<<<" (f (:base-printer printer) x) ">>>"]
+
+        (= x (:val (first (:trace printer))))
+        (render (first (:trace printer)) f printer x)
+
+        :else (f (:base-printer printer) x)))
+
+(defn pop-trace [printer]
   (update printer :trace rest))

-(defn- pop-trace-if-matches [printer x]
-  (if (= x (:val (first (:trace printer))))
-    (pop-trace printer)
-    printer))
-
 (defn- pretty-coll [printer open xs sep close f]
-  (let [xform (comp (map #(f printer %))
+  (let [xform (comp (map-indexed #(f printer %1 %2))
                     (interpose sep))
         ys (sequence xform xs)]
     [:group open ys close]))
@@ -26,54 +31,56 @@
 (defrecord HighlightPrinter [base-printer trace]
   visit/IVisitor
   (visit-unknown [this x]
-    (with-highlighting this visit/visit-unknown x))
+    (wrap visit/visit-unknown this x))
   (visit-nil [this]
-    (with-highlighting this visit/visit-nil))
+    (wrap (fn [printer _] (visit/visit-nil printer)) this nil))
   (visit-boolean [this x]
-    (with-highlighting this visit/visit-boolean x))
+    (wrap visit/visit-boolean this x))
   (visit-string [this x]
-    (with-highlighting this visit/visit-string x))
+    (wrap visit/visit-string this x))
   (visit-character [this x]
-    (with-highlighting this visit/visit-character x))
+    (wrap visit/visit-character this x))
   (visit-symbol [this x]
-    (with-highlighting this visit/visit-symbol x))
+    (wrap visit/visit-symbol this x))
   (visit-keyword [this x]
-    (with-highlighting this visit/visit-keyword x))
+    (wrap visit/visit-keyword this x))
   (visit-number [this x]
-    (with-highlighting this visit/visit-number x))
+    (wrap visit/visit-number this x))
   (visit-seq [this x]
-    (with-highlighting this
-      (fn [_]
-        (let [printer (pop-trace-if-matches this x)]
-          (edn/pretty-coll printer "(" x :line ")" visit/visit)))))
+    (wrap visit/visit-seq this x))
   (visit-vector [this x]
-    (with-highlighting this
-      (fn [_]
-        (let [printer (pop-trace-if-matches this x)]
-          (edn/pretty-coll printer "[" x :line "]" visit/visit)))))
+    (wrap visit/visit-vector this x))
   (visit-map [this x]
-    (with-highlighting this
-      (fn [_]
-        (let [printer (pop-trace-if-matches this x)]
-          (edn/pretty-coll printer "{" x [:span "," :line] "}"
-            (fn [printer [k v]]
-              [:span (visit/visit printer k) " " (visit/visit printer v)]))))))
+    (wrap visit/visit-map this x))
   (visit-set [this x]
-    (with-highlighting this
-      (fn [_]
-        (let [printer (pop-trace-if-matches this x)]
-          (edn/pretty-coll printer "#{" x :line "}" visit/visit)))))
+    (wrap visit/visit-set this x))
   (visit-tagged [this x]
-    (with-highlighting this visit/visit-tagged x))
+    (wrap visit/visit-tagged this x))
   (visit-meta [this meta x]
-    (with-highlighting this #(visit/visit-meta %1 meta %2) x))
+    (wrap #(visit/visit-meta %1 meta %2) this x))
   (visit-var [this x]
-    (with-highlighting this visit/visit-var x))
+    (wrap visit/visit-var this x))
   (visit-pattern [this x]
-    (with-highlighting this visit/visit-pattern x))
+    (wrap visit/visit-pattern this x))
   (visit-record [this x]
-    (with-highlighting this visit/visit-record x))
+    (wrap visit/visit-record this x))
   )
+
+(defmethod render `s/tuple [{[n] :steps} _ printer x]
+  (pretty-coll printer "[" x :line "]"
+    (fn [printer i x]
+      (visit/visit (cond-> printer (= i n) pop-trace) x))))
+
+(defmethod render `s/map-of [{[key k-or-v] :steps} _ printer x]
+  (pretty-coll printer "{" x [:span "," :line] "}"
+    (fn [printer i [k v]]
+      (let [kprinter (cond-> printer
+                       (and (= k key) (= k-or-v 0))
+                       pop-trace)
+            vprinter (cond-> printer
+                       (and (= k key) (= k-or-v 1))
+                       pop-trace)]
+        [:span (visit/visit kprinter k) " " (visit/visit vprinter v)]))))

 (defn highlight-printer [trace]
   (let [base-printer (edn/map->EdnPrinter {:symbols {}})]


Fixed missing vectorz implementation issue with first several conv updates

--- src/polismath/stormspec.clj
+++ src/polismath/stormspec.clj
@@ -4,6 +4,7 @@
             [polismath.queued-agent :as qa]
             [polismath.conv-man :as cm]
             [polismath.db :as db]
+            [clojure.core.matrix :as ccm]
             [environ.core :as env]
             [clojure.string :as string]
             [clojure.newtools.cli :refer [parse-opts]]
@@ -13,6 +14,12 @@
         polismath.utils
         polismath.conversation)
   (:gen-class))
+
+
+; XXX - storm hack. Solves issue where one process or thread has started loading vectorz, but the other
+; doesn't know to wait (at least this is what seems to be the case)
+(ccm/set-current-implementation :vectorz)
+(ccm/matrix [[1 2 3] [4 5 6]])

 (defspout sim-reaction-spout ["zid" "last-timestamp" "reactions"] {:prepare true}


Add shadow-cljs.edn as a "known root file"

Fixes project-root detection for shadow-cljs projects that don't
also have a project.clj or deps.edn file

--- src/refactor_nrepl/core.clj
+++ src/refactor_nrepl/core.clj
@@ -62,7 +62,7 @@
          start (if (fs/directory? path-or-file-in-project)
                  path-or-file-in-project
                  (fs/parent path-or-file-in-project))
-         names-at-root #{"project.clj" "build.boot" "build.gradle" "pom.xml" "deps.edn"}
+         names-at-root #{"project.clj" "build.boot" "build.gradle" "pom.xml" "deps.edn" "shadow-cljs.edn"}
          known-root-file? (fn [^File f] (some (fn [known-root-name]
                                                 (.endsWith (.getCanonicalPath f)
                                                            known-root-name))


Don't move unlinked controller origin.

Don't move unlinked controller origin.

When switching a show view from one linked controller to another, the
origin of the formerly-linked controller was being jumped to match that
of the new selection.

--- src/afterglow/web/routes/show_control.clj
+++ src/afterglow/web/routes/show_control.clj
@@ -503,7 +503,8 @@
       (swap! clients update-in [page-id] assoc :move-handler move-handler :linked-controller controller)
       (swap! clients assoc-in [page-id :controller-info :selected] controller)
       (controllers/add-move-listener controller move-handler)
-      (move-view page-info (controllers/current-left controller) (controllers/current-bottom controller)))))
+      (move-view (dissoc page-info :linked-controller)
+                 (controllers/current-left controller) (controllers/current-bottom controller)))))

 (defn- handle-link-controller-event
   "Process a request to specify a controller to link to."


use cond logic

use cond logic

--- src/clj/org/openforis/ceo/db/projects.clj
+++ src/clj/org/openforis/ceo/db/projects.clj
@@ -711,7 +711,7 @@

 (defn- exterior-ring [coords]
   (map (fn [[a b]] [(tc/val->double a) (tc/val->double b)])
-        (first coords)))
+       (first coords)))

 (defn- same-ring? [[start1 :as ring1] ring2]
   (and (some #(= % start1) ring2)
@@ -785,62 +785,64 @@
         (when-let [imagery-list (:projectImageryList params)]
           (call-sql "delete_project_imagery" project-id)
           (insert-project-imagery project-id imagery-list))
-        (when (= "unpublished" (:availability original-project))
-          (cond
-            (or (not= plot-distribution (:plot_distribution original-project))
-                (if (#{"csv" "shp"} plot-distribution)
-                  plot-file-base64
-                  (or (not (same-polygon-boundary? (tc/jsonb->clj boundary) (tc/jsonb->clj (:boundary original-project))))
-                      (not= num-plots (:num_plots original-project))
-                      (not= plot-shape (:plot_shape original-project))
-                      (not= plot-size (:plot_size original-project))
-                      (not= plot-spacing (:plot_spacing original-project)))))
-            (do
-              (call-sql "delete_plots_by_project" project-id)
-              (when (#{"csv" "shp"} (:plot_distribution original-project))
-                (call-sql "delete_project_tables" project-id))
-              (create-project-plots project-id
-                                    lon-min
-                                    lat-min
-                                    lon-max
-                                    lat-max
-                                    plot-distribution
-                                    num-plots
-                                    plot-spacing
-                                    plot-shape
-                                    plot-size
-                                    sample-distribution
-                                    samples-per-plot
-                                    sample-resolution
-                                    plot-file-name
-                                    plot-file-base64
-                                    sample-file-name
-                                    sample-file-base64
-                                    allow-drawn-samples?))
-
-            (or (not= sample-distribution (:sample_distribution original-project))
-                (if (#{"csv" "shp"} sample-distribution)
-                  sample-file-base64
-                  (or (not= samples-per-plot (:samples_per_plot original-project))
-                      (not= sample-resolution (:sample_resolution original-project)))))
-            (do
-              (call-sql "delete_all_samples_by_project" project-id)
-              (when (#{"csv" "shp"} (:sample_distribution original-project))
-                (call-sql "delete_project_sample_table" project-id))
-              (recreate-samples project-id
-                                sample-distribution
-                                plot-shape
-                                plot-size
-                                samples-per-plot
-                                sample-resolution
-                                sample-file-name
-                                sample-file-base64))
+        (cond
+          (not= "unpublished" (:availability original-project))
+          nil
+
+          (or (not= plot-distribution (:plot_distribution original-project))
+              (if (#{"csv" "shp"} plot-distribution)
+                plot-file-base64
+                (or (not (same-polygon-boundary? (tc/jsonb->clj boundary) (tc/jsonb->clj (:boundary original-project))))
+                    (not= num-plots (:num_plots original-project))
+                    (not= plot-shape (:plot_shape original-project))
+                    (not= plot-size (:plot_size original-project))
+                    (not= plot-spacing (:plot_spacing original-project)))))
+          (do
+            (call-sql "delete_plots_by_project" project-id)
+            (when (#{"csv" "shp"} (:plot_distribution original-project))
+              (call-sql "delete_project_tables" project-id))
+            (create-project-plots project-id
+                                  lon-min
+                                  lat-min
+                                  lon-max
+                                  lat-max
+                                  plot-distribution
+                                  num-plots
+                                  plot-spacing
+                                  plot-shape
+                                  plot-size
+                                  sample-distribution
+                                  samples-per-plot
+                                  sample-resolution
+                                  plot-file-name
+                                  plot-file-base64
+                                  sample-file-name
+                                  sample-file-base64
+                                  allow-drawn-samples?))
+
+          (or (not= sample-distribution (:sample_distribution original-project))
+              (if (#{"csv" "shp"} sample-distribution)
+                sample-file-base64
+                (or (not= samples-per-plot (:samples_per_plot original-project))
+                    (not= sample-resolution (:sample_resolution original-project)))))
+          (do
+            (call-sql "delete_all_samples_by_project" project-id)
+            (when (#{"csv" "shp"} (:sample_distribution original-project))
+              (call-sql "delete_project_sample_table" project-id))
+            (recreate-samples project-id
+                              sample-distribution
+                              plot-shape
+                              plot-size
+                              samples-per-plot
+                              sample-resolution
+                              sample-file-name
+                              sample-file-base64))

           ;; NOTE: Old stored questions can have a different format than when passed from the UI.
           ;;       This is why we check whether the survey questions are different on the front (for now).
-            (or update-survey
-                (and (:allow_drawn_samples original-project) (not allow-drawn-samples?)))
-            (reset-collected-samples project-id)))
+          (or update-survey
+              (and (:allow_drawn_samples original-project) (not allow-drawn-samples?)))
+          (reset-collected-samples project-id))
         (data-response ""))
       (data-response (str "Project " project-id " not found.")))))


Fixed bug in (concepts :next-closure ctx)

and made it a little bit faster.

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

--- src/conexp/contrib/algorithms/bitwise.clj
+++ src/conexp/contrib/algorithms/bitwise.clj
@@ -82,7 +82,7 @@
   "Computes concepts with various algorithms, given as first argument."
   (fn [& args] (first args)))

-;; NextClosure with BitSets
+;; NextClosure with BitSets (:next-closure)

 (defn- lectic-<_i
   ""
@@ -111,8 +111,12 @@
   ""
   [base-count clop #^BitSet A]
   (loop [i (dec base-count)]
-    (if (== -1 i)
+    (cond
+      (== -1 i)
       nil
+      (.get A i)
+      (recur (dec i))
+      :else
       (let [A_i (oplus base-count clop A i)]
 	(if (lectic-<_i base-count i A A_i)
 	  A_i
@@ -140,15 +144,15 @@
 	       (object-prime (attribute-prime bitset)))

 	intents (take-while identity
-			    (iterate #(next-closed-set object-count clop %) (BitSet.)))]
+			    (iterate #(next-closed-set attribute-count clop %) (BitSet.)))]
     (map (fn [bitset]
 	   [(to-hashset object-vector (attribute-prime bitset))
 	    (to-hashset attribute-vector bitset)])
 	 intents)))

-;; Krajca-Outrata-Vychodil
+;; Krajca-Outrata-Vychodil (:vok)

-;; In-Close
+;; In-Close (:in-close)

 ;;;


Improve translate block UX

Improve translate block UX

--- src/teach_by_friends/shared/scenes/chapters_scene.cljs
+++ src/teach_by_friends/shared/scenes/chapters_scene.cljs
@@ -256,6 +256,12 @@
                             :align-items "center"
                             :justify-content "center"}
                     :blur-type "dark"}
+         [ui/touchable-opacity {:style {:position "absolute"
+                                        :top 0
+                                        :right 0
+                                        :bottom 0
+                                        :left 0}
+                                :on-press #(nav/dismiss-modal! navigator "none")}]
          [ui/view {:style {:border-top-color "rgb(155,155,155)"
                            :border-top-width 1
                            :border-bottom-color "rgb(155,155,155)"
@@ -270,7 +276,11 @@
                            :padding-right 15}}
           [ui/view {:style {:flex-direction "row"}}
            [ui/text {:style {:color "white" :font-size 14 :flex 1}} term]
-           [ui/touchable-opacity {:on-press #(nav/dismiss-modal! navigator "none")}
+           [ui/touchable-opacity {:on-press #(nav/dismiss-modal! navigator "none")
+                                  :hit-slop {:top 10
+                                             :right 10
+                                             :bottom 10
+                                             :left 10}}
             [ui/image {:source (get-icon :close)
                        :style {:width 16
                                :height 16}}]]]
@@ -285,7 +295,10 @@
              (into [ui/view]
                    (for [tr-term @translate]
                      [ui/text {:style {:color "white" :font-size 14}} tr-term])))
-           [ui/text {:style {:color "rgb(155,155,155)" :font-size 14}} "In sentence:"]
+           [ui/text {:style {:color "rgb(155,155,155)"
+                             :font-size 14
+                             :margin-top 10}}
+            "In sentence:"]
            [sentence-with-term sentence term]]]]))))


Add photo to properties table.

Add photo to properties table.

--- src-cljs/kixi/hecuba/tabs/hierarchy/properties.cljs
+++ src-cljs/kixi/hecuba/tabs/hierarchy/properties.cljs
@@ -37,7 +37,7 @@
     [:div.col-md-12
      [:table {:className "table table-hover"}
       [:thead
-       [:tr [:th "Property Code"] [:th "Type"] [:th "Address"]
+       [:tr [:th "Photo"] [:th "Property Code"] [:th "Type"] [:th "Address"]
         [:th "Region"] [:th "Ownership"] [:th "Technologies"] [:th "Monitoring Hierarchy"]]]
       (for [property-details (sort-by #(-> % :property_code) (:data properties))]
         (let [property_data (:property_data property-details)
@@ -48,6 +48,9 @@
                        (history/update-token-ids! history :properties id))
             :className (if (= id (:selected properties)) "success")
             :id (str table-id "-selected")}
+           [:td (when-let [pic (:path (first (:photos property-details)))]
+                  [:img.img-thumbnail.tmg-responsive
+                   {:src (str "https://s3-us-west-2.amazonaws.com/get-embed-data/" pic)}])]
            [:td (:property_code property-details)]
            [:td (:property_type property_data)]
            [:td (slugs/postal-address property_data)]


Catch exception when updating offer metrics

--- scheduler/src/cook/mesos/scheduler.clj
+++ scheduler/src/cook/mesos/scheduler.clj
@@ -411,12 +411,16 @@
   "Gets a list of offers from mesos. Decides what to do with them all--they should all
    be accepted or rejected at the end of the function."
   [conn driver fid pending-jobs offer]
-  (histograms/update!
-    offer-size-cpus
-    (get-in offer [:resources :cpus]))
-  (histograms/update!
-    offer-size-mem
-    (get-in offer [:resources :mem]))
+  (try
+    (histograms/update!
+     offer-size-cpus
+     (get-in offer [:resources :cpus]))
+    (histograms/update!
+     offer-size-mem
+     (get-in offer [:resources :mem]))
+    (catch Throwable t
+      (log/warn t "Error in updating offer metrics:" (ex-data t))))
+
   (timers/time!
     handle-resource-offer!-duration
     (try


Inline code must be on one line.

Inline code must be on one line.

--- scheduling/src/immutant/scheduling.clj
+++ scheduling/src/immutant/scheduling.clj
@@ -29,7 +29,7 @@

   * :in - a period after which f will be called
   * :at - a time after which f will be called
-  * :every - the period between calls
+  * :every - the period between calls
   * :until - stops the calls at a specific time
   * :limit - limits the calls to a specific count
   * :cron - calls f according to a [Quartz-style](http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-06) cron spec
@@ -138,13 +138,13 @@

 (defoption limit
   "When {{every}} is specified, this helper limits the invocations by
-  count, including the first one, e.g. `(-> (every :hour) (limit
-  10))`. When {{until}} and `limit` are combined, whichever triggers
+  count, including the first one, e.g. `(-> (every :hour) (limit 10))`.
+  When {{until}} and `limit` are combined, whichever triggers
   first ends the iteration. See {{schedule}}.")

 (defoption cron
-  "Helper that takes a Quartz-style cron spec, e.g. `(cron \"0 0 12 ?
-   * WED\")`, see the [Quartz docs](http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-06)
+  "Helper that takes a Quartz-style cron spec, e.g. `(cron \"0 0 12 ? * WED\")`,
+   see the [Quartz docs](http://quartz-scheduler.org/documentation/quartz-2.2.x/tutorials/tutorial-lesson-06)
    for more details.")

 (defoption singleton


Allow running op without feeding its value

By passing nil as its value: `(run-graph {:my-op nil})`

Needed for the `train` op in the linreg graph.

--- src/tensorflow_clj/core.clj
+++ src/tensorflow_clj/core.clj
@@ -64,7 +64,9 @@
   (assert session)
   (let [runner (.runner session)]
     (doseq [[feed-op feed-value] feed-ops]
-      (.feed runner (name feed-op) (tensor feed-value)))
+      (if feed-value
+        (.feed runner (name feed-op) (tensor feed-value))
+        (.addTarget runner (name feed-op))))
     (doseq [fetch-op fetch-ops]
       (.fetch runner (name fetch-op)))
     (vec (map tensor->clj (.run runner)))))


doplnil jsem funkcni update-rel-exts edeposit/edeposit#555

--- src/edeposit/amqp/kramerius/xml/foxml.clj
+++ src/edeposit/amqp/kramerius/xml/foxml.clj
@@ -4,7 +4,10 @@
             [clojure.zip :as zip]
             [clojure.pprint :as pp]
             [clojure.java.io :as io]
+            [clojure.string :as s]
+            [clojure.xml :as x]
             [me.raynes.fs :as fs]
+            [clojure.java.shell :as shell]
             )
   )

@@ -63,15 +66,61 @@
       [:foxml:datastream {:VERSIONABLE "false" :STATE "A" :CONTROL_GROUP "E" :ID "IMG_FULL"}
        [:foxml:datastreamVersion {:MIMETYPE (-> full-file :mimetype) :CREATED created :ID "IMG_FULL.0"}
         [:foxml:contentLocation
-         {:REF (str "file:" (-> full-file :storage_path))
-          :TYPE "URL"}]]]
+         {:REF (str "file:" (-> full-file :storage_path)) :TYPE "URL"}]]]

       [:foxml:datastream {:VERSIONABLE "false" :STATE "A" :CONTROL_GROUP "E" :ID "IMG_PREVIEW"}
        [:foxml:datastreamVersion {:MIMETYPE (-> preview-file :mimetype) :CREATED created :ID "IMG_PREVIEW.0"}
         [:foxml:contentLocation
-         {:REF (str "file:" (-> preview-file :filename))
-          :TYPE "URL"}]]]
+         {:REF (str "file:first-page/" (-> preview-file :filename)) :TYPE "URL"}]]]
       ]
      )
     )
   )
+
+(defn update-rels
+  [root archive-mount dir-pointer originals-mount]
+  (let [loc (-> root zip/xml-zip)]
+    (let [new-full-ref (fn [ref]
+                         (str "file:///"
+                              (s/join "/"
+                                      (map (fn [path] (-> path
+                                                         (s/replace #"^file:" "")
+                                                         (s/replace #"^[/]+" "")))
+                                           [originals-mount ref]))))
+          new-preview-ref (fn [ref]
+                            (str "file:///"
+                                 (s/join "/"
+                                         (map (fn [path] (-> path
+                                                            (s/replace #"^file:" "")
+                                                            (s/replace #"^[/]+" "")))
+                                              [archive-mount dir-pointer ref]))))
+          ]
+      (-> (zx/xml1-> loc :foxml:datastream [(zx/attr= :ID "IMG_FULL")]
+                     :foxml:datastreamVersion :foxml:contentLocation)
+          (zip/edit update-in [:attrs] update-in [:REF] new-full-ref)
+          (zip/root)
+          (zip/xml-zip)
+          (zx/xml1-> :foxml:datastream [(zx/attr= :ID "IMG_PREVIEW")]
+                     :foxml:datastreamVersion :foxml:contentLocation)
+          (zip/edit update-in [:attrs] update-in [:REF] new-preview-ref)
+          (zip/root)
+        )
+      )
+    )
+  )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


Use not-empty, not seq, so that we don't mess up their binding

--- src/useful/experimental.clj
+++ src/useful/experimental.clj
@@ -183,7 +183,7 @@
   [name wrappers-var doc args & body]
   `(let [impl# (fn ~args ~@body)]
      (defn ~name ~doc [& args#]
-       (let [wrappers# (seq @~wrappers-var)]
+       (let [wrappers# (not-empty @~wrappers-var)]
          (if-not wrappers#
            (apply impl# args#)
            (with-bindings {~wrappers-var


Added exception handling to get-price-from-url.

--- src/hackerati_interval_web_app/scrape.clj
+++ src/hackerati_interval_web_app/scrape.clj
@@ -21,16 +21,14 @@
   #"(?s).*?<b>Price.*?(\$\d+\.?\d*).*")

 (defn fetch-url [url]
-  (with-open [inputstream  (-> (java.net.URL. url)
-                               .openConnection
-                               (doto (.setRequestProperty "Accept" *accept*)
-                                 (.setRequestProperty "User-Agent"
-                                                      *user-agent*)
-                                (.setRequestProperty "Accept-Encoding"
-                                                     *accept-encoding*)
-                                (.setRequestProperty "Accept-Language"
-                                                     *accept-language*))
-                               .getContent)]
+  (with-open [inputstream
+              (-> (java.net.URL. url)
+                  .openConnection
+                  (doto (.setRequestProperty "Accept" *accept*)
+                    (.setRequestProperty "User-Agent" *user-agent*)
+                    (.setRequestProperty "Accept-Encoding" *accept-encoding*)
+                    (.setRequestProperty "Accept-Language" *accept-language*))
+                  .getContent)]
     (slurp inputstream)))

 (defn get-price-from-url
@@ -40,11 +38,12 @@
   (let [parse-$ #(if (= (first %1) \$)
                    (Float/parseFloat (apply str (rest %1)))
                    (Float/parseFloat %1))]
-    (->> url
-         fetch-url
-         (re-matches price-regex)
-         second
-         parse-$)))
+    (try (->> url
+              fetch-url
+              (re-matches price-regex)
+              second
+              parse-$)
+         (catch Exception e (str "Warning: couldn't not fetch price for " url)))))

 (defn get-price-from-urls
   "URL should be from Amazon's mobile website


token consumption working

token consumption working

--- server/src/gratefulplace/db/transactions/password_reset.clj
+++ server/src/gratefulplace/db/transactions/password_reset.clj
@@ -15,4 +15,14 @@
   [user]
   (db/t [{:db/id (:db/id user)
           :user/password-reset-token (generate-token)
-          :user/password-reset-token-generated-at (now)}]))+          :user/password-reset-token-generated-at (now)}]))
+
+;; TODO handle case where token is already consumed?
+(defn consume-token
+  [user, new-password]
+  (db/t (conj (map #(vector :db/retract (:db/id user) % (get user %))
+                   [:user/password-reset-token
+                    :user/password-reset-token-generated-at])
+              (c/mapify {:id (:db/id user)
+                         :new-password new-password}
+                        mr/change-password->txdata))))


Pre-condition for application/json content type on json-body

--- src/leiningen/new/cljskel/test_common.clj
+++ src/leiningen/new/cljskel/test_common.clj
@@ -1,12 +1,15 @@
 (ns {{name}}.test-common
-    (:require [cheshire.core :as json]
-              [clojure.string :as str]
-              [environ.core :refer [env]]))
+  (:require [cheshire.core :as json]
+            [clojure.string :as str]
+            [environ.core :refer [env]]))

 (defn url+ [& suffix]
   (apply str (format (env :service-url) (env :service-port)) suffix))

 (defn json-body
-  "Reads the body of the request as json and parses it into a map with keywords."
+  "Reads the body of the request as json and parses it into a map with keywords.
+
+   Fails pre-condition if content type is not application/json."
   [resp]
+  {:pre [(re-matches #"application/json.+" (get-in resp [:headers "content-type"]))]}
   (json/parse-string (:body resp) true))


placeholder: lazy sequence in Clojure again

--- clojure/lazy_seq_again.clj
+++ clojure/lazy_seq_again.clj
@@ -1,9 +1,11 @@
 (defrecord Square [x y])
 (defrecord Delta [dx dy])
-(defrecord SpiralMemory [memory square delta steer-in dist])
+(defrecord SpiralMemory [memory square delta next-turn steps])

 (defn make-spiral-memory
-  [] (->SpiralMemory {(->Square 0 0) 1} (->Square 0 0) (->Delta 1 0) 1 0))
+  ([] (make-spiral-memory {(->Square 0 0) 1} 0 0 0 -1 0 0))
+  ([memory x y dx dy next-turn steps]
+   (->SpiralMemory memory (->Square x y) (->Delta dx dy) next-turn steps)))

 (defn adj-nn [x, y] (->Square      x  (inc y)))
 (defn adj-ne [x, y] (->Square (inc x) (inc y)))
@@ -23,8 +25,16 @@
     [1  0] [(adj-ne x y) (adj-nn x y) (adj-nw x y) (adj-ww x y)]))

 (defn walk
-  [{{x :x y :y} :square
-    {dx :dx dy :dy} :delta :as spiral-memory}] (identity spiral-memory))
+  [{memory :memory
+    {x :x y :y} :square
+    {dx :dx dy :dy} :delta
+    next-turn :next-turn
+    steps :steps}]
+  (let [should-turn (= steps next-turn)
+        next-turn (if (and should-turn (not (zero? dy))) (inc next-turn) next-turn)
+        steps (if should-turn 1 (inc steps))
+        [dx dy] (if should-turn [(- dy) dx] [dx dy])]
+    (make-spiral-memory memory (+ x dx) (+ y dy) dx dy next-turn steps)))

 (defn write
   [{memory :memory
@@ -40,5 +50,4 @@
    (lazy-seq
     (cons spiral-memory (write-until predicate (write-next spiral-memory))))))

-(prn (take 1 (write-until "some predicate")))
-(prn (take 2 (write-until "some predicate")))
+(map println (take 25 (write-until "some predicate")))


don't nodejs require color again

don't nodejs require color again

--- clojure/src/dnd/level.cljs
+++ clojure/src/dnd/level.cljs
@@ -1,11 +1,8 @@
 (ns dnd.level
    (:require [cljs.nodejs :as nodejs]
-             [dnd.character :refer [base-character]]
-             [dnd.color :refer [color-to-array]]
+             [dnd.character :refer [base-character egg]]
+             [dnd.color :refer [COLOR color-to-array color-name]]
              ))
-
-(def COLOR
-  (nodejs/require "color"))

 (def block {
             :x 0


fix multi-arity fn

fix multi-arity fn

--- src/clj/org/openforis/ceo/utils/type_conversion.clj
+++ src/clj/org/openforis/ceo/utils/type_conversion.clj
@@ -14,7 +14,7 @@

 (defn str->long
   ([string]
-   (str->int string -1))
+   (str->long string -1))
   ([string default]
    (if (number? string)
      string
@@ -24,7 +24,7 @@

 (defn str->float
   ([string]
-   (str->int string -1))
+   (str->float string -1))
   ([string default]
    (if (number? string)
      string


Username cannot be empty when registering

--- src/verbose_spoon/model/core.clj
+++ src/verbose_spoon/model/core.clj
@@ -16,6 +16,7 @@
     (not (re-find gatech-email-regex email)) (response "The email must be a gatech email!")
     (seq (q/check-user-email-exists-query email)) (response "This account already exists!")
     (= password "") (response "Password cannot be empty!")
+    (= username "") (response "Username cannot be empty!")
     (not= password confirmpassword) (response "Passwords don't match!")
     :else (do (q/insert-register-user username password email)
             (response "Successful Registration!"))))


update cgens to use new summary facility

--- src/overtone/sc/cgen/demand.clj
+++ src/overtone/sc/cgen/demand.clj
@@ -4,7 +4,7 @@
         [overtone.sc.cgen]))

 (defcgen duty
-  "Demand results from demand rate ugens according to a stream of duration values"
+  "Demand results according to a stream of duration values"
   [dur {:default 1.0 :doc "time values. Can be a demand ugen or any signal. The next level is acquired after duration.
 "}
    reset {:default 0.0 :doc "trigger or reset time values. Resets the list of ugens and the duration ugen when triggered. The reset input may also be a demand ugen, providing a stream of reset times."}
@@ -21,14 +21,14 @@
   (:kr (internal:duty:kr dur reset action level)))

 (defcgen t-duty
-  "A value is demanded each ugen in the list and output  as a trigger according to a stream of duration values. The unit generators in the list should be 'demand' rate.
-
-When there is a trigger at the reset input, the demand rate ugens in the list and the duration are reset.The reset input may also be a demand ugen, providing a stream of reset times."
-
+  "Demand results as trigger according to a stream of duration values"
   [dur {:default 1.0 :doc "time values. Can be a demand ugen or any signal. The next trigger value is acquired after the duration provided by the last time value."}
    reset {:default 0.0 :doc "trigger or reset time values. Resets the list of ugens and the duration ugen when triggered. The reset input may also be a demand ugen, providing a stream of reset times."}
    level {:default 1.0 :doc "demand ugen providing the output values."}
    action {:default NO-ACTION :doc "action to perform when the duration stream ends"}]
+    "A value is demanded from each ugen in the list and output  as a trigger according to a stream of duration values. The unit generators in the list should be 'demand' rate.
+
+When there is a trigger at the reset input, the demand rate ugens in the list and the duration are reset.The reset input may also be a demand ugen, providing a stream of reset times."
   (:ar (internal:t-duty:ar dur reset action level))
   (:kr (internal:t-duty:kr dur reset action level)))

@@ -40,18 +40,20 @@
   (:dr (internal:dseries:dr length start step)))

 (defcgen dgeom
-  "Generate a geometric sequence on demand. The arguments can be a number or any other ugen"
+  "Generate a geometric sequence on demand."
   [start {:default 1, :doc "start value"}
    grow {:default 2, :doc "value by which to grow ( x = x[-1] * grow )"}
    length {:default INFINITE :doc "doc number of values to create"}]
+  "The arguments can be a number or any other ugen"
   (:dr (internal:dgeom:dr length start grow)))

 (defcgen dbufwr
-  "Write a demand sequence into a buffer. All inputs can be either demand ugen or any other ugen."
+  "Write a demand sequence into a buffer."
   [input {:default 0.0 :doc "single channel input"}
    bufnum {:default 0, :doc "buffer number to read from (single channel buffer)"}
    phase {:default 0.0, :doc "index into the buffer"}
    loop {:default 1.0, :doc "when phase exceeds number of frames in buffer, loops when set to 1"}]
+  "All inputs can be either demand ugen or any other ugen."
   (:dr (internal:dbufwr:dr bufnum phase input loop)))

 (defcgen dwhite
@@ -62,24 +64,27 @@
   (:dr (internal:dwhite:dr length lo hi)))

 (defcgen diwhite
-  "Generates a sequence of random integer values between lo and hi. The arguments can be a number or any other ugen"
+  "Generates a sequence of random integer values between lo and hi."
   [lo {:default 0.0 :doc "minimum value"}
    hi {:default 1.0 :doc "maximum value"}
    length {:default INFINITE :doc "number of values to create"}]
+  "The arguments can be a number or any other ugen"
   (:dr (internal:diwhite:dr length lo hi)))

 (defcgen dbrown
-  "Generates a sequence of random values in the continuous range betweeen lo and hi, not exceeding step from one value to the next. The arguments can be a number or any other ugen"
+  "Generates a sequence of random values in the continuous range betweeen lo and hi, not exceeding step from one value to the next."
   [lo {:default 0.0 :doc "minimum value"}
    hi {:default 1.0 :doc "maximum value"}
    step {:default 0.01 :doc "maximum step for each new value"}
    length {:default INFINITE :doc "number of values to create"}]
+  "The arguments can be a number or any other ugen"
   (:dr (internal:dbrown:dr length lo hi step)))

 (defcgen dibrown
-  "Generates a sequence of random integer values betweeen lo and hi, not exceeding step from one value to the next. The arguments can be a number or any other ugen"
+  "Generates a sequence of random integer values betweeen lo and hi, not exceeding step from one value to the next."
   [lo {:default 0.0 :doc "minimum value"}
    hi {:default 1.0 :doc "maximum value"}
    step {:default 0.01 :doc "maximum step for each new value"}
    length {:default INFINITE :doc "number of values to create"}]
+  "The arguments can be a number or any other ugen"
   (:dr (internal:dibrown:dr length lo hi step)))


Clarify docstrings for sample & generate

TCHECK-108

--- src/main/clojure/clojure/test/check/generators.cljc
+++ src/main/clojure/clojure/test/check/generators.cljc
@@ -143,7 +143,10 @@

 (defn sample
   "Return a sequence of `num-samples` (default 10)
-  realized values from `generator`."
+  realized values from `generator`.
+
+  Note that this function is a dev helper and is not meant to be used
+  as part of a larger generator."
   ([generator]
    (sample generator 10))
   ([generator num-samples]
@@ -153,7 +156,10 @@

 (defn generate
   "Returns a single sample value from the generator, using a default
-  size of 30."
+  size of 30.
+
+  Note that this function is a dev helper and is not meant to be used
+  as part of a larger generator."
   {:added "0.8.0"}
   ([generator]
      (generate generator 30))


Remove logging from help docs

Remove logging from help docs

--- src/yetibot/core/models/help.clj
+++ src/yetibot/core/models/help.clj
@@ -37,7 +37,6 @@
    ;; metadata on the sub-command functions, as is the case when creating
    ;; aliases)
    (when-let [cmds (->> cmds (remove nil?) seq)]
-     (info "add-docs" {:alias? alias?} prefix (pr-str cmds))
      ;; add to the docs atom using prefix string as the key
      (let [docs-atom (if alias? alias-docs docs)
            cmds (->> cmds


narrow screen experiments in scrollspy

narrow screen experiments in scrollspy

--- src/prais2/everything_else.cljs
+++ src/prais2/everything_else.cljs
@@ -26,7 +26,7 @@
   [:.container
    [:#sidebar.row {:style {:position "relative"}}

-    [:#faq-sidebar.col-md-3.affix {:style {:top "120px"}}
+    [:#faq-sidebar.col-sm-3.affix {:style {:top "120px"}}
      [:h1 content/title]
      [:ul.nav.nav-list
       (for [six (range (count faq-sections))
@@ -42,7 +42,7 @@
                [:a {:href (faq-hash six fix)} (:title faq)]]))]])
       ]]

-    [:#faqs.col-md-offset-4.col-md-8
+    [:#faqs.col-sm-offset-4.col-sm-8

      (for [six (range (count faq-sections))
            :let [section (faq-sections six)]]


handles clojure.core so it can be found

handles clojure.core so it can be found

--- src/refactor_nrepl/refactor.clj
+++ src/refactor_nrepl/refactor.clj
@@ -75,7 +75,9 @@
 (defn- find-symbol-reply [{:keys [transport ns-string ns name clj-dir] :as msg}]
   (let [dir (or clj-dir ".")
         namespace (or ns (ns-from-string ns-string))
-        fully-qualified-name (str/join "/" [namespace name])
+        fully-qualified-name (if (= namespace "clojure.core")
+                               name
+                               (str/join "/" [namespace name]))
         syms (map identity (mapcat (partial find-symbol-in-file fully-qualified-name) (list-project-clj-files dir)))]
     (doseq [found-sym syms]
       (transport/send transport (response-for msg :occurrence found-sym)))


is-map-of? is not used anymore (based on coverall)

--- src/spec_tools/json_schema.cljc
+++ src/spec_tools/json_schema.cljc
@@ -180,15 +180,6 @@

 (defmethod accept-spec ::visitor/set [dispatch spec children]
   {:enum children})
-
-(defn- is-map-of?
-  "Predicate to check if spec looks like an expansion of clojure.spec.alpha/map-of."
-  [spec]
-  (let [[_ inner-spec & {:as kwargs}] (visitor/extract-form spec)
-        pred (when (seq? inner-spec) (first inner-spec))]
-    ;; (s/map-of key-spec value-spec) expands to
-    ;; (s/every (s/tuple key-spec value-spec) :into {} ...)
-    (and (= pred #?(:clj 'clojure.spec.alpha/tuple :cljs 'cljs.spec.alpha/tuple)) (= (get kwargs :into)) {})))

 (defmethod accept-spec 'clojure.spec.alpha/keys [dispatch spec children]
   (let [[_ & {:keys [req req-un opt opt-un]}] (visitor/extract-form spec)
@@ -214,13 +205,10 @@
 (defmethod accept-spec 'clojure.spec.alpha/every [dispatch spec children]
   (let [form (visitor/extract-form spec)
         type (type/resolve-type form)]
-    ;; Special case handling of s/map-of, which expands to s/every
-    (if (is-map-of? spec)
-      {:type "object" :additionalProperties (get-in (unwrap children) [:items 1])}
-      (case type
-        :map {:type "object", :additionalProperties (unwrap children)}
-        :set {:type "array", :uniqueItems true, :items (unwrap children)}
-        :vector {:type "array", :items (unwrap children)}))))
+    (case type
+      :map {:type "object", :additionalProperties (unwrap children)}
+      :set {:type "array", :uniqueItems true, :items (unwrap children)}
+      :vector {:type "array", :items (unwrap children)})))

 (defmethod accept-spec 'clojure.spec.alpha/every-kv [dispatch spec children]
   {:type "object", :additionalProperties (second children)})


Add example to call parser from initial demo

--- docs-src/modules/ROOT/examples/com/wsscode/pathom/book/intro/demo.cljs
+++ docs-src/modules/ROOT/examples/com/wsscode/pathom/book/intro/demo.cljs
@@ -25,3 +25,7 @@
      ::p/plugins [(pc/connect-plugin {::pc/register registry})
                   p/error-handler-plugin
                   p/trace-plugin]}))
+
+(comment
+  ; to call the parser and get some data out of it, run:
+  (parser {} [:answer-to-everything]))


If no workflow ID, don't create link

If no workflow ID, don't create link