first part solved

first part solved

--- src/adventofcode1/twentyone.clj
+++ src/adventofcode1/twentyone.clj
@@ -16,6 +16,10 @@
    spyscope.core
    adventofcode1.spec-test-instrument-debug))

+(defn parse-int
+  [s]
+  (int (bigint s)))
+
 (defn catvec
   [a b]
   (vec (concat a b)))
@@ -52,7 +56,7 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr to] (re-find (re-matcher #"^move position (\d+) to position (\d+)$" cmd))]
-    (move-position text fr to)))
+    (move-position text (parse-int fr) (parse-int to))))

 ;; swap position X with position Y means that the letters at indexes X
 ;; and Y (counting from 0) should be swapped.
@@ -70,7 +74,7 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr to] (re-find (re-matcher #"^swap position (\d+) with position (\d+)$" cmd))]
-    (swap-position text fr to)))
+    (swap-position text (parse-int fr) (parse-int to))))

 ;; reverse positions X through Y means that the span of letters at
 ;; indexes X through Y (including the letters at X and Y) should be
@@ -89,7 +93,7 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr to] (re-find (re-matcher #"^reverse positions (\d+) through (\d+)$" cmd))]
-    (reverse-positions text fr to)))
+    (reverse-positions text (parse-int fr) (parse-int to))))

 ;; rotate left/right X steps means that the whole string should be
@@ -97,7 +101,11 @@
 ;; dabc.
 (defn rotate-right
   [text fr]
-  text)
+  (let [arr (seq text)
+        fr (mod fr (count arr))
+        cnt (- (count arr) fr)]
+    ;; 12345 2 => 45123
+    (str/join (concat (nthrest arr cnt)(take cnt arr)))))

 ;; rotate right 4 steps
@@ -105,14 +113,16 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr] (re-find (re-matcher #"^rotate right (\d+) steps?$" cmd))]
-    (rotate-right text fr)))
+    (rotate-right text (parse-int fr))))

 ;; rotate left/right X steps means that the whole string should be
 ;; rotated; for example, one right rotation would turn abcd into
 ;; dabc.
 (defn rotate-left
   [text fr]
-  text)
+  (let [arr (vec (seq text))
+        fr (mod fr (count arr))]
+    (str/join (concat (nthrest arr fr)(take fr arr)))))

 ;; rotate right 4 steps
@@ -120,12 +130,15 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr] (re-find (re-matcher #"^rotate left (\d+) steps?$" cmd))]
-    (rotate-left text fr)))
+    (rotate-left text (parse-int fr))))

 (defn rotate-based-on
   [text fr]
-  text)
+  (if-let [idx (str/index-of text fr)]
+    (rotate-right text (inc (if (>= idx 4)(inc idx) idx)))))
+
+

 ;; rotate based on position of letter X means that the whole string
 ;; should be rotated to the right based on the index of letter X
@@ -134,6 +147,9 @@
 ;; right one time, plus a number of times equal to that index, plus
 ;; one additional time if the index was at least 4.

+;; (rotate-based-on "ecabd" "d") => "decab"
+;; (rotate-based-on "abdec" "b") => "ecabd"
+
 ;; rotate based on position of letter a
 (defn parse-rotate-based-on
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
@@ -146,7 +162,11 @@
 ;; be swapped (regardless of where they appear in the string).
 (defn swap-letter
   [text fr to]
-  text)
+  (-> text
+   (str/replace fr ".")
+   (str/replace to fr)
+   (str/replace "." to)))
+

 ;; swap letter d with letter a
@@ -154,7 +174,7 @@
   "Apply cmd to text. Return text as is if cmd isn't this cmd"
   [cmd text]
   (if-let [[_ fr to] (re-find (re-matcher #"^swap letter ([a-z]+) with letter ([a-z]+)$" cmd))]
-    (swap-letter text fr to)))
+    (swap-letter text fr  to)))

 (defn call-cmd
@@ -178,12 +198,30 @@
   (if (seq l)
     (do
       (assert (first l))
-      (recur (call-cmd (first l) text)(rest l)))
+      (let [res (call-cmd (first l) text)]
+        (println (str (first l) " => " res))
+        (recur res (rest l))))
     text))

 (defn process
   ([text](process text (str/split-lines mydata)))
   ([text l](process-2 text l)))
+
+
+(def testdata
+  "swap position 4 with position 0
+swap letter d with letter b
+reverse positions 0 through 4
+rotate left 1 step
+move position 1 to position 4
+move position 3 to position 0
+rotate based on position of letter b
+rotate based on position of letter d
+")
+
+(defn sample
+  []
+  (process "abcde" (str/split-lines testdata)))

 (def mydata


Set cursor to 0 on input

Set cursor to 0 on input

--- src/cljs/cljs_webrepl/core.cljs
+++ src/cljs/cljs_webrepl/core.cljs
@@ -174,7 +174,7 @@
   (let [expression (str/trim (:input @state))]
     (when-not (str/blank? expression)
       (eval-str! expression)
-      (swap! state assoc :input ""))))
+      (swap! state assoc :input "" :cursor 0))))

 #_(defn input-key-down [state event]
     (case (.-which event)


Add initialization and default page setup

--- src/cljs/comic_reader/main.cljs
+++ src/cljs/comic_reader/main.cljs
@@ -54,3 +54,14 @@
 (defroute "/comic/:comic/:volume/:page"
   {:keys [comic volume page]}
   (session/put! :current-page comic-viewer))
+
+(defn page []
+  [(session/get :current-page)])
+
+(defn init! []
+  (secretary/set-config! :prefix "#")
+  (session/put! :current-page site-list)
+  (reagent/render-component [page]
+                            (.-body js/document)))
+
+(init!)


Add local state for folding items

Add local state for folding items

--- src/cljs/hacker_agent/core.cljs
+++ src/cljs/hacker_agent/core.cljs
@@ -97,29 +97,42 @@
       [item data])))

 (defmethod item "story" [data]
-  (let [{:keys [id by title kids type time url score]} @data]
-    [:ul
-     [:li "ID: " id]
-     [:li "Title: " title]
-     [:li "URL: " url]
-     [:li "Score: " score]
-     [:li "By: " by]
-     [:li "Time: " time]
-     [:li "Comments: "
-      (for [comment kids]
-        ^{:key comment} [render comment])]]))
+  (let [local (atom {:collapse? true
+                     :collapse-comments? true})]
+    (fn [data]
+      (let [{:keys [id by title kids type time url score]} @data]
+        (if (:collapse? @local)
+          [:p {:on-click #(swap! local update-in [:collapse?] not)} title]
+          [:ul
+           [:li "ID: " id]
+           [:li {:on-click #(swap! local update-in [:collapse?] not)} title]
+           [:li "URL: " url]
+           [:li "Score: " score]
+           [:li "By: " by]
+           [:li "Time: " time]
+           (when kids
+             [:li [:span {:on-click #(swap! local update-in [:collapse-comments?] not)}
+                   "Comments: "]
+              (when-not (:collapse-comments? @local)
+                (for [comment kids]
+                  ^{:key comment} [render comment]))])])))))

 (defmethod item "comment" [data]
-  (let [{:keys [id by kids text type time score]} @data]
-    [:ul
-     [:li "ID: " [:a {:href (str "#/items/" id)} id]]
-     [:li "By: " by]
-     [:li "Score: " score]
-     [:li {:dangerouslySetInnerHTML {:__html (str "Text: </br>" text)}}]
-     [:li "Time: " time]
-     [:li "Comments: "
-      (for [comment kids]
-        ^{:key comment} [render comment])]]))
+  (let [local (atom {:collapse-comments? true})]
+    (fn [data]
+      (let [{:keys [id by kids text type time score]} @data]
+        [:ul
+         [:li "ID: " [:a {:href (str "/#/items/" id)} id]]
+         [:li "By: " by]
+         [:li "Score: " score]
+         [:li {:dangerouslySetInnerHTML {:__html (str "Text: </br>" text)}}]
+         [:li "Time: " time]
+         (when kids
+           [:li [:span {:on-click #(swap! local update-in [:collapse-comments?] not)}
+                 "Comments: "]
+            (when-not (:collapse-comments? @local)
+              (for [comment kids]
+                ^{:key comment} [render comment]))])]))))

 (defmethod item "job" [data]
   [:p "This is a job"])


Handle borken PGNs with non-uppercased FEN tags.

--- src/clojure/clj_chess/game.cljc
+++ src/clojure/clj_chess/game.cljc
@@ -818,7 +818,8 @@
   [ecn & {:keys [include-annotations? san]
           :or {include-annotations? true san false}}]
   (let [fen (reduce (fn [fen tag-value-pair]
-                      (if-not (= (first tag-value-pair) "FEN")
+                      (if-not (= (str/upper-case (first tag-value-pair))
+                                 "FEN")
                         fen
                         (second tag-value-pair)))
                     board/start-fen
@@ -868,4 +869,4 @@
                         :pgn))]
        (if (= format :pgn)
          (keep #(from-ecn % :san true) (pgn/games-in-file file-name))
-         (keep #(from-ecn % :san false) (ecn/games-in-file file-name))))))+         (keep #(from-ecn % :san false) (ecn/games-in-file file-name))))))


add todo about swagger docs

add todo about swagger docs

--- src/club_of_naaarfs/handler.clj
+++ src/club_of_naaarfs/handler.clj
@@ -48,5 +48,5 @@

 (def app
   (routes
-    user-api
+    user-api ;; TODO: add swagger docs
     (middleware/wrap-base #'app-routes)))


Supply repl-device-port to Neko

Supply repl-device-port to Neko

--- src/leiningen/droid/compile.clj
+++ src/leiningen/droid/compile.clj
@@ -102,7 +102,7 @@
   subsequently project code depends on them to eliminate
   debug-specific code when building the release."
   [{{:keys [enable-dynamic-compilation start-nrepl-server
-            manifest-path]} :android :as project}]
+            manifest-path repl-device-port]} :android :as project}]
   (info "Compiling Clojure files...")
   (ensure-paths manifest-path)
   (debug "Project classpath:" (get-classpath project))
@@ -121,6 +121,7 @@
                      o/*start-nrepl-server* ~start-nrepl-server
                      o/*enable-dynamic-compilation* ~enable-dynamic-compilation
                      o/*package-name* ~(get-package-name manifest-path)
+                     o/*nrepl-port* ~repl-device-port
                      *compiler-options* ~compiler-options]
              (doseq [namespace# '~nses]
                (println "Compiling" namespace#)


Swing Thread Safety for «with-change-on»

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

--- src/conexp/contrib/gui/util.clj
+++ src/conexp/contrib/gui/util.clj
@@ -46,7 +46,7 @@
   `(.addChangeListener ~thing
                        (proxy [ChangeListener] []
                          (stateChanged [^ChangeEvent ~'evt]
-                           ~@body))))
+                           (do-swing ~@body)))))

 (let [all-paths (string/split (System/getProperty "java.class.path")  #":"),
       cclj-path (filter (fn [x] (re-find #"conexp-clj-[^\/]*\.jar" x)),


[#1879] Improve backend message on update dataset

Update failed. This dataset has merged columns that no longer exist in
their dataset, [name]

--- backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
+++ backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
@@ -211,7 +211,7 @@
                                                            (filter some?))]
                                  (when (not-empty column-diff-coll)
                                    column-diff-coll)))]
-        {:error(format "This version of the dataset isn't consistent thus it has merge transformations with datasets columns which were already removed from their datasets: %s" (reduce str column-diff))
+        {:error(format "Update failed. This dataset has merged columns that no longer exist in their dataset, %s" (mapv :title (select-datasets-by-id tenant-conn {:ids (mapv :dataset-id column-diff)})))
          :column-diff column-diff}))))

 (defn sources-related


Add copy latest register in vim

Add copy latest register in vim

--- src/lt/plugins/ltfiles/vim.cljs
+++ src/lt/plugins/ltfiles/vim.cljs
@@ -8,6 +8,7 @@
             [cljs.reader :as reader]
             [clojure.string :as s]
             [lt.plugins.ltfiles.popup :as popup]
+            [lt.objs.platform :as platform]
             [lt.objs.command :as cmd]))

 (defn vim-toggle-comment-selection
@@ -31,6 +32,17 @@
 (cmd/command {:command :ltfiles.vim-yank
               :desc "ltfiles: Sets text to latest yank"
               :exec set-vim-yank})
+
+(defn get-register-value [register]
+  (-> (.-registers (CodeMirror.Vim.getRegisterController))
+      (aget register) ;; pick a register
+      (aget "keyBuffer")
+      first))
+
+(cmd/command {:command :ltfiles.copy-latest-vim-register
+              :desc "ltfiles: Copies latest vim yank to system clipboard"
+              :exec (fn []
+                      (platform/copy (get-register-value "0")))})

 (defn show-registers []
   (popup/info


remove signature from destructure entries

--- src/main/cljs_api_gen/parse.clj
+++ src/main/cljs_api_gen/parse.clj
@@ -646,6 +646,7 @@
         match? #(= "destructure" (:name %))
         item (first (filter match? items))
         make-destruct #(-> item
+                           (dissoc :signature)
                            (merge (base-syntax-item (syntax-map %)))
                            (assoc :type "binding"))]
     (map make-destruct ["destructure-vector"


* benchmark/cljs/benchmark_runner.cljs: benchmark keyword invoke

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -31,6 +31,7 @@
 (println ";;; map ops")
 (simple-benchmark [coll {:foo 1 :bar 2}] (get coll :foo) 1000000)
 (simple-benchmark [coll {:foo 1 :bar 2}] (-lookup coll :foo nil) 1000000)
+(simple-benchmark [coll {:foo 1 :bar 2}] (:foo coll) 100000)
 (simple-benchmark [coll {:foo 1 :bar 2}] (assoc coll :baz 3) 100000)
 (println)


karma: If a test fails with exception, print the stacktrace (#814)

--- src/main/shadow/test/karma.cljs
+++ src/main/shadow/test/karma.cljs
@@ -48,15 +48,18 @@
       "FAIL in   " (ct/testing-vars-str result) "\n"
       (when-not (s/blank? testing-contexts-str)
         (str "\"" testing-contexts-str "\"\n"))
-      (if (and (seq? expected)
-               (seq? actual))
-        (str
-          "expected: " (format-fn indentation expected) "\n"
-          "  actual: " (format-fn indentation (second actual)) "\n"
-          (when-let [diff (format-diff indentation expected (second actual))]
-            (str "    diff: " diff "\n")))
-        (str
-          expected " failed with " actual "\n"))
+      (cond
+        (and (seq? expected)
+             (seq? actual))
+          (str
+                "expected: " (format-fn indentation expected) "\n"
+                "  actual: " (format-fn indentation (second actual)) "\n"
+                (when-let [diff (format-diff indentation expected (second actual))]
+                  (str "    diff: " diff "\n")))
+        (.hasOwnProperty actual "stack")
+          (str "Exception: " (.-stack actual))
+        :else
+          (str expected " failed with " actual "\n"))
       (when message
         (str " message: " (indent indentation message) "\n")))))


Update information_model.cljc

Update information_model.cljc

--- src/onyx/information_model.cljc
+++ src/onyx/information_model.cljc
@@ -1172,7 +1172,7 @@
              :added "0.8.0"}

             :onyx.peer/storage.zk.insanely-allow-windowing?
-            {:doc "Allows window contents to be checkpointed with Zookeeper. This is highly unadvised for anything but testing."
+            {:doc "Allows window contents to be checkpointed with ZooKeeper. This is highly unadvised for anything but testing, as ZooKeeper checkpoints are not written asynchronously, are not automatically garbage collected, and ZooKeeper does not support znodes greater than 1MB."
              :type :boolean
              :default false
              :optional? true


Check value is not nil

Check value is not nil

--- src/onyx/messaging/http_kit.clj
+++ src/onyx/messaging/http_kit.clj
@@ -67,10 +67,9 @@
         timeout-ch (timeout ms)]
     (loop [segments [] i 0]
       (if (< i (:onyx/batch-size task-map))
-        (let [[v c] (alts!! [ch timeout-ch])]
-          (if (= ch c)
-            (recur (conj segments v) (inc i))
-            segments))
+        (if-let [v (first (alts!! [ch timeout-ch]))]
+          (recur (conj segments v) (inc i))
+          segments)
         segments))))

 (defmethod extensions/send-messages HttpKit


get ordering right

get ordering right

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/aurora/examples/todomvc.cljs
+++ src/aurora/examples/todomvc.cljs
@@ -216,7 +216,7 @@
                                      (aset cur 5 nil)))
         join-itr (join-iterator #js [itr1 itr2 itr3 active?-itr child-id-itr parent-id-itr])]
     (transform (aget env "ctx") join-itr (fn [cur remember! forget! pretend!]
-                                           (pretend! "elem-child" #js [(aget cur 5) (aget cur 4) -1])
+                                           (pretend! "elem-child" #js [(aget cur 5) -1 (aget cur 4)])
                                            (pretend! "elem" #js [(aget cur 4) "input"])
                                            (pretend! "elem-attr" #js [(aget cur 4) "type" "checkbox"])
                                            (pretend! "elem-attr" #js [(aget cur 4) "checked" (aget cur 3)])
@@ -244,14 +244,14 @@
                                      (aset cur 4 nil)))
         join-itr (join-iterator #js [itr1 itr2 itr3 filter child-id-itr remove-id-itr])]
     (transform (aget env "ctx") join-itr (fn [cur remember! forget! pretend!]
-                                           (pretend! "elem-child" #js ["todo-list" (aget cur 3) -1])
+                                           (pretend! "elem-child" #js ["todo-list" (aget cur 0) (aget cur 3)])
                                            (pretend! "elem" #js [(aget cur 3) "li"])
                                            (pretend! "elem-event" #js [(aget cur 3) "onDoubleClick" (aget cur 3) nil])
-                                           (pretend! "elem-child" #js [(aget cur 3) (str (aget cur 3) "-0") 0])
+                                           (pretend! "elem-child" #js [(aget cur 3) 0 (str (aget cur 3) "-0")])
                                            (pretend! "elem-text" #js [(str (aget cur 3) "-0") (aget cur 1)])
-                                           (pretend! "elem-child" #js [(aget cur 3) (aget cur 4) 1])
+                                           (pretend! "elem-child" #js [(aget cur 3) 1 (aget cur 4)])
                                            (pretend! "elem" #js [(aget cur 4) "button"])
-                                           (pretend! "elem-child" #js [(aget cur 4) (str (aget cur 4) "-0") 0])
+                                           (pretend! "elem-child" #js [(aget cur 4) 0 (str (aget cur 4) "-0")])
                                            (pretend! "elem-text" #js [(str (aget cur 4) "-0") "x"])
                                            (pretend! "elem-event" #js [(aget cur 4) "onClick" nil nil])
                                            ))))
@@ -263,7 +263,7 @@
         filter (constant-filter 5 2 "editing")
         join-itr (join-iterator #js [itr1 itr2 itr3 filter])]
     (transform (aget env "ctx") join-itr (fn [cur remember! forget! pretend!]
-                                           (pretend! "elem-child" #js ["todo-list" "todo-editor" (aget cur 0)])
+                                           (pretend! "elem-child" #js ["todo-list" (aget cur 0) "todo-editor"])
                                            (pretend! "elem" #js ["todo-editor" "input"])
                                            (pretend! "elem-attr" #js ["todo-editor" "defaultValue" (aget cur 1)])
                                            (pretend! "elem-event" #js ["todo-editor" "onChange" "todo-editor" (aget cur 0)])
@@ -276,7 +276,7 @@
   (let [itr1 (magic-iterator (index env :todo-to-add) #js [0])
         join-itr (join-iterator #js [itr1])]
     (transform (aget env "ctx") join-itr (fn [cur remember! forget! pretend!]
-                                           (pretend! "elem-child" #js ["app" "todo-input" 1])
+                                           (pretend! "elem-child" #js ["app" 1 "todo-input"])
                                            (pretend! "elem" #js ["todo-input" "input"])
                                            (pretend! "elem-attr" #js ["todo-input" "defaultValue" (aget cur 0)])
                                            (pretend! "elem-event" #js ["todo-input" "onChange" nil nil])
@@ -289,44 +289,44 @@
     (transform (aget env "ctx") join-itr (fn [cur remember! forget! pretend!]
                                            (pretend! "elem" #js ["app" "div"])

-                                           (pretend! "elem-child" #js ["app" "todo-header" 0])
+                                           (pretend! "elem-child" #js ["app" 0 "todo-header"])
                                            (pretend! "elem" #js ["todo-header" "h1"])
-                                           (pretend! "elem-child" #js ["todo-header" "todo-header-0" 0])
+                                           (pretend! "elem-child" #js ["todo-header" 0 "todo-header-0"])
                                            (pretend! "elem-text" #js ["todo-header-0" "Todos"])

-                                           (pretend! "elem-child" #js ["app" "toggle-all" 1])
+                                           (pretend! "elem-child" #js ["app" 1 "toggle-all"])
                                            (pretend! "elem" #js ["toggle-all" "input"])
                                            (pretend! "elem-attr" #js ["toggle-all" "type" "checkbox"])
                                            (pretend! "elem-attr" #js ["toggle-all" "checked" (aget cur 0)])
                                            (pretend! "elem-event" #js ["toggle-all" "onChange" nil nil])
                                            (pretend! "elem-event" #js ["toggle-all" "onKeyDown" nil nil])

-                                           (pretend! "elem-child" #js ["app" "add-todo" 2])
+                                           (pretend! "elem-child" #js ["app" 2 "add-todo"])
                                            (pretend! "elem" #js ["add-todo" "button"])
                                            (pretend! "elem-event" #js ["add-todo" "onClick" "add-todo" nil])
-                                           (pretend! "elem-child" #js ["add-todo" "add-todo-0" 0])
+                                           (pretend! "elem-child" #js ["add-todo" 0 "add-todo-0"])
                                            (pretend! "elem-text" #js ["add-todo-0" "add"])

-                                           (pretend! "elem-child" #js ["app" "todo-list" 3])
+                                           (pretend! "elem-child" #js ["app" 3 "todo-list"])
                                            (pretend! "elem" #js ["todo-list" "ul"])

-                                           (pretend! "elem-child" #js ["app" "filter-all" 4])
+                                           (pretend! "elem-child" #js ["app" 4 "filter-all"])
                                            (pretend! "elem" #js ["filter-all" "button"])
                                            (pretend! "elem-event" #js ["filter-all" "onClick" "filter-all" nil])
-                                           (pretend! "elem-child" #js ["filter-all" "filter-all-0" 0])
+                                           (pretend! "elem-child" #js ["filter-all" 0 "filter-all-0"])
                                            (pretend! "elem-text" #js ["filter-all-0" "all"])

-                                           (pretend! "elem-child" #js ["app" "filter-active" 4])
+                                           (pretend! "elem-child" #js ["app" 4 "filter-active"])
                                            (pretend! "elem" #js ["filter-active" "button"])
                                            (pretend! "elem-event" #js ["filter-active" "onClick" "filter-active" nil])
-                                           (pretend! "elem-child" #js ["filter-active" "filter-active-0" 0])
+                                           (pretend! "elem-child" #js ["filter-active" 0 "filter-active-0"])
                                            (pretend! "elem-text" #js ["filter-active-0" "active"])

-                                           (pretend! "elem-child" #js ["app" "filter-completed" 4])
+                                           (pretend! "elem-child" #js ["app" 4 "filter-completed"])
                                            (pretend! "elem" #js ["filter-completed" "button"])
                                            (pretend! "elem-event" #js ["filter-completed" "onClick" "filter-completed" nil])
-                                           (pretend! "elem-child" #js ["filter-completed" "filter-completed-0" 0])
+                                           (pretend! "elem-child" #js ["filter-completed" 0 "filter-completed-0"])
                                            (pretend! "elem-text" #js ["filter-completed-0" "completed"])

                                            ))))
@@ -468,8 +468,8 @@
     (while (.key all-children)
       (let [cur (.key all-children)
             parent (aget cur 0)
-            child (aget cur 1)
-            pos (aget cur 2)
+            child (aget cur 2)
+            pos (aget cur 1)
             parent-el (aget built-els parent)
             child-el (aget built-els child)]
         (.push (.-props.children parent-el) child-el)


submit on a click

submit on a click

--- src/clj/hsm/controllers/coll.clj
+++ src/clj/hsm/controllers/coll.clj
@@ -42,6 +42,8 @@
       (actions/update-collection db id new-items)
       (redirect (format "/collections/%s%s" id (if is-json "?json=1" ""))))))

+(def submit-form "$(this).parent('form').submit();return false;")
+
 (defhtml render-collection
   [c]

@@ -67,13 +69,13 @@
               [:a.pull-left {:href (str "/p/" (str item el))} (str item el)]
               [:form {:method "POST" :action (format "/collections/%s/delete" (:id c))}
                 [:input {:type "hidden" :name :project :value item}]
-                [:a {:href "#" :onclick "$(this).parent('form').submit();return false;" }
+                [:a {:href "#" :onclick submit-form }
                   [:i.fa.fa-minus-circle.red]]]]))
         [:hr]
         [:form {:method "POST" :action (format "/collections/%s/add" (:id c))}
           [:div#remote
             [:input.typeahead {:type "text" :name :project :placeholder "Type to find project"}]
-            [:a.btn.btn-default {:type :submit} "Add"]]
+            [:a.btn.btn-default {:href "#" :onclick submit-form} "Add"]]
         ]]))

 (defn get-coll


more migration fixing

more migration fixing

--- src/clj_crud/system/database.clj
+++ src/clj_crud/system/database.clj
@@ -64,7 +64,7 @@
                  (->> migrations/migrations
                       reverse
                       (drop-while (fn [[migration-version migration]]
-                                    (<= current-version migration-version)))
+                                    (< current-version migration-version)))
                       (take-while (fn [[migration-version migration]]
                                     (< to-version migration-version)))
                       (map (juxt first (comp :down second))))


Fix tile loading on Windows

Fix tile loading on Windows

--- src/clojure/nightmod/screens.clj
+++ src/clojure/nightmod/screens.clj
@@ -38,9 +38,9 @@
 (def manager (asset-manager*
                (reify FileHandleResolver
                  (resolve [this file-name]
-                   (if (try (.exists (io/file file-name)) (catch Exception _))
-                     (files! :absolute file-name)
-                     (files! :internal file-name))))))
+                   (if (io/resource file-name)
+                     (files! :internal file-name)
+                     (files! :absolute file-name))))))

 ; helpers

@@ -95,14 +95,16 @@
                          (try (catch Exception _)))
                      (.getName f))
    :name (.getCanonicalPath f)
-   :image (let [f (io/file f u/screenshot-file)]
-            (try
-              (->> (play-clj.utils/load-asset (.getCanonicalPath f) Texture)
-                   texture
-                   get-center-texture
-                   :object
-                   (drawable :texture-region))
-              (catch Exception _)))})
+   :image (let [f (io/file f u/screenshot-file)
+                path (.getCanonicalPath f)]
+            (some->> (or (try (play-clj.utils/load-asset path Texture)
+                           (catch Exception _))
+                         (try (Texture. (files! :absolute path))
+                           (catch Exception _)))
+                     texture
+                     get-center-texture
+                     :object
+                     (drawable :texture-region)))})

 (defn read-new-tile
   [name]


Less naive version of invalid content-type warning that deals with the case insensitive nature of cOnTeNt-TyPe.

--- src/posthere/cljs/posthere.cljs
+++ src/posthere/cljs/posthere.cljs
@@ -113,6 +113,12 @@
       (table-rows cljs-content)
       (string-content content result))))

+(defn- warn-of-invalid-body
+  ""
+  [headers result]
+  (if (aget result "invalid-body")
+    (assoc headers "content-type" [:span [:span.glyphicon.glyphicon-warning-sign {:title invalid-body-warning}](get headers "content-type")])
+    headers))
 ;; ----- Hiccup HTML snippets for the results page -----

 (defhtml table-header
@@ -158,7 +164,7 @@
         [:th.text-center {:colspan 2} "Headers"]]]
     [:tbody
       (let [headers (js->clj (.-headers result))
-            warning-headers (if (aget result "invalid-body") (assoc headers "content-type" [:span [:span.glyphicon.glyphicon-warning-sign {:title invalid-body-warning}](get headers "content-type")]) headers)]
+            warning-headers (warn-of-invalid-body headers result)]
         (table-rows warning-headers))]])

 (defhtml result-metadata


fix error handler to cors requests, default to responseText

--- src/semtag_web/client/main.cljs
+++ src/semtag_web/client/main.cljs
@@ -9,8 +9,9 @@
   ([msg alert-type]
     (jq/prepend ($ :#main) (view/alert msg (str "alert-" (name alert-type))))))

-(defn- alert-error [path _ _ err]
-  (alert (util/error-msg path err)))
+(defn- alert-error [path a b err]
+  (let [msg (or (.-responseText a) err)]
+    (alert (util/error-msg path msg))))

 (defn backend-request
   ([path f] (backend-request path f alert-error))
@@ -18,7 +19,7 @@
   (jq/ajax
     (str "http://localhost:3000/api" path)
     {:dataType "edn"
-     :error #(alert-fn path %&)
+     :error #(apply alert-fn path %&)
      :success f
      })))


Remove unused import

Remove unused import

--- src/trumpet_server/api/rest.clj
+++ src/trumpet_server/api/rest.clj
@@ -6,7 +6,6 @@
             [compojure.route :as route]
             [compojure.handler :as handler]
             [clojure.java.io :as io]
-            [ring.adapter.jetty :as jetty]
             [cheshire.core :as json]
             [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
             [clojure.core.async :refer [go >! chan close!]]


Remove "deselect-all" debug message.

Remove "deselect-all" debug message.

--- src/uxbox/main/data/shapes.cljs
+++ src/uxbox/main/data/shapes.cljs
@@ -454,7 +454,6 @@
   "Clear all possible state of drawing, edition
   or any similar action taken by the user."
   []
-  (println "deselect-all")
   (DeselectAll.))

 (defn group-selected


Extract logic to function

Extract logic to function

--- solutions/beecrowd/1013/1013.clj
+++ solutions/beecrowd/1013/1013.clj
@@ -1,21 +1,21 @@
 (ns main
   (:require [clojure.string :as str]))
+
+(defn maior-ab
+  [a b]
+  (-> (- a b)
+      (Math/abs)
+      (+  b)
+      (+  a)
+      (/  2)))

 (defn main []
   (loop [line (read-line)]
     (when line
       (let [[a b c] (->> (str/split line #" ")
                          (map #(Integer/parseInt %)))
-            result (-> (- a b)
-                       (Math/abs)
-                       (+  b)
-                       (+  a)
-                       (/  2))
-            result (-> (- c result)
-                       (Math/abs)
-                       (+  result)
-                       (+  c)
-                       (/  2))]
+            result (maior-ab a b)
+            result (maior-ab c result)]
         (printf "%d eh o maior%n" result))
       (recur (read-line)))))


Extract exists? fn, doing null check and file exists

--- src/silly_image_store/store.clj
+++ src/silly_image_store/store.clj
@@ -1,17 +1,18 @@
 (ns silly-image-store.store
   (:require [clojure.java.io :as io]))

+(def exists? #(and % (.exists %)))
 (def file? #(.isFile %))
 (def filename #(.getName %))

 (defn load-image [& paths]
   (let [file (apply io/file paths)]
-    (if (.exists file) file nil)))
+    (if (exists? file) file nil)))

 (defn list-images [& paths]
   (let [image-directory (apply load-image paths)]
-    (if image-directory
+    (if (exists? image-directory)
       (->> image-directory
        .listFiles
        (filter file?)


mod spec

mod spec

--- src/synthesis_crawlers/core.clj
+++ src/synthesis_crawlers/core.clj
@@ -27,9 +27,7 @@

 (s/def ::attr-extractor (s/map-of keyword? string?))
 (s/def ::container-extractor string?)
-(s/def ::empty-container #(and (string? %) (= (count %) 0)))
-(s/def ::empty-attr-extractor (s/map-of keyword? nil?))
-;(s/def ::incomplete-attr-extractor (s/map-of keyword? ))
+(s/def ::complete-attr-extractor (s/map-of keyword? string?))
 (s/def ::text string?)
 (s/def ::extractors (s/map-of ::container-extractor ::attr-extractor))
 (s/fdef extract


Used Closure Long for the bit switch

Used Closure Long for the bit switch

--- src/longshi/fressian/basejs.cljs
+++ src/longshi/fressian/basejs.cljs
@@ -1,7 +1,7 @@
 (ns longshi.fressian.basejs
+  (:import [goog.math Long])
   (:require [longshi.fressian.protocols :as p]
             [longshi.fressian.ByteStream :as bs]))
-

 (def codes
   #js {
@@ -36,8 +36,8 @@
     0 64
     -1 64
     (if (neg? x)
-      (- 66 (.-length (.toString x 2)))
-      (- 64 (.-length (.toString x 2))))))
+      (- 64 (.getNumBitsAbs (.not (Long.fromNumber x))))
+      (- 64 (.getNumBitsAbs (Long.fromNumber x))))))

 (defn is-int [x]
   (zero? (js-mod x 1)))


- -> * for interface op names

- -> * for interface op names

--- src/main/cljc/mikron/buffer.cljc
+++ src/main/cljc/mikron/buffer.cljc
@@ -9,63 +9,63 @@
   #?(:clj (:import [java.nio ByteBuffer ByteOrder])))

 (definterface+ IMikronBitBuffer
-  (^long   get-bit-position* []            "Gets the current position of the buffer.")
-  (^Object set-bit-position* [^long value] "Sets the current position of the buffer.")
-
-  (^long   get-bit-index* []            "Gets the current index of the buffer.")
-  (^Object set-bit-index* [^long value] "Sets the current index of the buffer.")
-
-  (^long   get-bit-value* []            "Gets the current value at the index.")
-  (^Object set-bit-value* [^long value] "Sets the current value at the index."))
+  (^long   -get-bit-position []            "Gets the current position of the buffer.")
+  (^Object -set-bit-position [^long value] "Sets the current position of the buffer.")
+
+  (^long   -get-bit-index []            "Gets the current index of the buffer.")
+  (^Object -set-bit-index [^long value] "Sets the current index of the buffer.")
+
+  (^long   -get-bit-value []            "Gets the current value at the index.")
+  (^Object -set-bit-value [^long value] "Sets the current value at the index."))

 (deftype MikronBitBuffer [^long ^:unsynchronized-mutable value
                           ^long ^:unsynchronized-mutable index
                           ^long ^:unsynchronized-mutable position]
   IMikronBitBuffer
-  (get-bit-position* [_]
+  (-get-bit-position [_]
     position)
-  (set-bit-position* [_ value']
+  (-set-bit-position [_ value']
     (set! position (unchecked-long value')) nil)

-  (get-bit-index* [_]
+  (-get-bit-index [_]
     index)
-  (set-bit-index* [_ value']
+  (-set-bit-index [_ value']
     (set! index (unchecked-long value')) nil)

-  (get-bit-value* [_]
+  (-get-bit-value [_]
     value)
-  (set-bit-value* [_ value']
+  (-set-bit-value [_ value']
     (set! value (unchecked-long value')) nil))

 (definterface+ IMikronByteBuffer
-  (^long   take-byte* []            "Takes a byte from the buffer.")
-  (^Object put-byte*  [^long value] "Puts a byte into the buffer.")
-
-  (^long   take-short* []           "Takes a short from the buffer.")
-  (^Object put-short*  [^long value] "Puts a short into the buffer.")
-
-  (^long   take-int* []            "Takes an int from the buffer.")
-  (^Object put-int*  [^long value] "Puts an int into the buffer.")
-
-  (^long   take-long* []            "Takes a long from the buffer.")
-  (^Object put-long*  [^long value] "Puts a long into the buffer.")
-
-  (^double take-float* []               "Takes a float from the buffer.")
-  (^Object put-float*  [^double value] "Puts a float into the buffer.")
-
-  (^double take-double* []              "Takes a double from the buffer.")
-  (^Object put-double*  [^double value] "Puts a double into the buffer.")
-
-  (^bytes  take-bytes* [^long n]      "Takes a given number of bytes from the buffer.")
-  (^Object put-bytes*  [^bytes value] "Puts a given number of bytes into the buffer.")
-
-  (^bytes  take-bytes-all* [] "Takes all written bytes from the buffer.")
-
-  (^long   get-position* []            "Gets the current positio of the buffer.")
-  (^Object set-position* [^long value] "Sets the current position of the buffer.")
-
-  (^Object get-le* []              "Gets the current endianness of the buffer.")
-  (^Object set-le* [^Object value] "Sets the current endianness of the buffer."))
+  (^long   -take-byte []            "Takes a byte from the buffer.")
+  (^Object -put-byte  [^long value] "Puts a byte into the buffer.")
+
+  (^long   -take-short []           "Takes a short from the buffer.")
+  (^Object -put-short  [^long value] "Puts a short into the buffer.")
+
+  (^long   -take-int []            "Takes an int from the buffer.")
+  (^Object -put-int  [^long value] "Puts an int into the buffer.")
+
+  (^long   -take-long []            "Takes a long from the buffer.")
+  (^Object -put-long  [^long value] "Puts a long into the buffer.")
+
+  (^double -take-float []               "Takes a float from the buffer.")
+  (^Object -put-float  [^double value] "Puts a float into the buffer.")
+
+  (^double -take-double []              "Takes a double from the buffer.")
+  (^Object -put-double  [^double value] "Puts a double into the buffer.")
+
+  (^bytes  -take-bytes [^long n]      "Takes a given number of bytes from the buffer.")
+  (^Object -put-bytes  [^bytes value] "Puts a given number of bytes into the buffer.")
+
+  (^bytes  -take-bytes-all [] "Takes all written bytes from the buffer.")
+
+  (^long   -get-position []            "Gets the current positio of the buffer.")
+  (^Object -set-position [^long value] "Sets the current position of the buffer.")
+
+  (^Object -get-le []              "Gets the current endianness of the buffer.")
+  (^Object -set-le [^Object value] "Sets the current endianness of the buffer."))

 #?(:cljs
    (def NativeJsBuffer
@@ -79,56 +79,56 @@
             ^long ^:unsynchronized-mutable position
             ^boolean ^:unsynchronized-mutable le])
   IMikronByteBuffer
-  (take-byte* [_]
+  (-take-byte [_]
     #?(:clj  (unchecked-long (.get buffer))
        :cljs (with-delta position 1 (.readInt8 buffer position true))))
-  (put-byte* [_ value]
+  (-put-byte [_ value]
     #?(:clj  (.put buffer (unchecked-byte value))
        :cljs (with-delta position 1 (.writeInt8 buffer value position true))))

-  (take-short* [_]
+  (-take-short [_]
     #?(:clj  (unchecked-long (.getShort buffer))
        :cljs (with-delta position 2 (with-le le (.readInt16 buffer position true)))))
-  (put-short* [_ value]
+  (-put-short [_ value]
     #?(:clj  (.putShort buffer (unchecked-short value))
        :cljs (with-delta position 2 (with-le le (.writeInt16 buffer value position true)))))

-  (take-int* [_]
+  (-take-int [_]
     #?(:clj  (.getInt buffer)
        :cljs (with-delta position 4 (with-le le (.readInt32 buffer position true)))))
-  (put-int* [_ value]
+  (-put-int [_ value]
     #?(:clj  (.putInt buffer (unchecked-int value))
        :cljs (with-delta position 4 (with-le le (.writeInt32 buffer value position true)))))

-  (take-long* [this]
+  (-take-long [this]
     #?(:clj  (.getLong buffer)
-       :cljs (math/to (let [u (take-int* this)
-                            v (take-int* this)]
+       :cljs (math/to (let [u (-take-int this)
+                            v (-take-int this)]
                         (if le (math/from u v) (math/from v u))))))
-  (put-long* [this value]
+  (-put-long [this value]
     #?(:clj  (.putLong buffer value)
        :cljs (let [value (math/from value)
                    low   (.getLowBits value)
                    high  (.getHighBits value)]
                (if le
-                 (do (put-int* this low)  (put-int* this high))
-                 (do (put-int* this high) (put-int* this low))))))
-
-  (take-float* [_]
+                 (do (-put-int this low)  (-put-int this high))
+                 (do (-put-int this high) (-put-int this low))))))
+
+  (-take-float [_]
     #?(:clj  (double (.getFloat buffer))
        :cljs (with-delta position 4 (with-le le (.readFloat buffer position true)))))
-  (put-float* [_ value]
+  (-put-float [_ value]
     #?(:clj  (.putFloat buffer (unchecked-float value))
        :cljs (with-delta position 4 (with-le le (.writeFloat buffer value position true)))))

-  (take-double* [_]
+  (-take-double [_]
     #?(:clj  (.getDouble buffer)
        :cljs (with-delta position 8 (with-le le (.readDouble buffer position true)))))
-  (put-double* [_ value]
+  (-put-double [_ value]
     #?(:clj  (.putDouble buffer value)
        :cljs (with-delta position 8 (with-le le (.writeDouble buffer value position true)))))

-  (take-bytes* [_ n]
+  (-take-bytes [_ n]
     #?(:clj  (let [value (byte-array n)]
                (.get buffer value)
                value)
@@ -136,29 +136,29 @@
                    to   (unchecked-add position n)]
                (set! position to)
                (.slice (.-buffer buffer) from to))))
-  (put-bytes* [_ value]
+  (-put-bytes [_ value]
     #?(:clj  (.put buffer value)
        :cljs (do (.copy (.from NativeJsBuffer value) buffer position)
                  (set! position (unchecked-add position (.-byteLength value))))))

-  (take-bytes-all* [_]
+  (-take-bytes-all [_]
     #?(:clj  (let [bytes (byte-array (.position buffer))]
                (.position buffer (unchecked-int 0))
                (.get buffer bytes)
                bytes)
        :cljs (.slice (.-buffer buffer) 0 position)))

-  (get-position* [_]
+  (-get-position [_]
     #?(:clj  (.position buffer)
        :cljs position))
-  (set-position* [_ value]
+  (-set-position [_ value]
     #?(:clj  (.position buffer (unchecked-int value))
        :cljs (set! position value)))

-  (get-le* [_]
+  (-get-le [_]
     #?(:clj  (identical? ByteOrder/LITTLE_ENDIAN (.order buffer))
        :cljs le))
-  (set-le* [_ value]
+  (-set-le [_ value]
     #?(:clj  (.order buffer (if value ByteOrder/LITTLE_ENDIAN ByteOrder/BIG_ENDIAN))
        :cljs (set! le value))))

@@ -186,179 +186,179 @@
 (defn get-bit-position
   "Gets the bit position of `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(get-bit-position* (get-bit-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (get-bit-position* (get-bit-buffer buffer)))
+                     `(-get-bit-position (get-bit-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-get-bit-position (get-bit-buffer buffer)))

 (defn set-bit-position
   "Sets the bit position of `buffer` to `value`."
   #?(:clj {:inline (fn [buffer value]
-                     `(set-bit-position* (get-bit-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (set-bit-position* (get-bit-buffer buffer) value))
+                     `(-set-bit-position (get-bit-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-set-bit-position (get-bit-buffer buffer) value))

 (defn get-bit-index
   "Gets the bit index of `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(get-bit-index* (get-bit-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (get-bit-index* (get-bit-buffer buffer)))
+                     `(-get-bit-index (get-bit-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-get-bit-index (get-bit-buffer buffer)))

 (defn set-bit-index
   "Sets the bit index of `buffer` to `value`."
   #?(:clj {:inline (fn [buffer value]
-                     `(set-bit-index* (get-bit-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (set-bit-index* (get-bit-buffer buffer) value))
+                     `(-set-bit-index (get-bit-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-set-bit-index (get-bit-buffer buffer) value))

 (defn get-bit-value
   "Gets the bit value of `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(get-bit-value* (get-bit-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (get-bit-value* (get-bit-buffer buffer)))
+                     `(-get-bit-value (get-bit-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-get-bit-value (get-bit-buffer buffer)))

 (defn set-bit-value
   "Sets the bit value of `buffer` to `value`."
   #?(:clj {:inline (fn [buffer value]
-                     `(set-bit-value* (get-bit-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (set-bit-value* (get-bit-buffer buffer) value))
+                     `(-set-bit-value (get-bit-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-set-bit-value (get-bit-buffer buffer) value))

 ;; Public delegated operations

 (defn take-byte
   "Takes a byte from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-byte* (get-byte-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (take-byte* (get-byte-buffer buffer)))
+                     `(-take-byte (get-byte-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-take-byte (get-byte-buffer buffer)))

 (defn put-byte
   "Puts a byte `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-byte* (get-byte-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (put-byte* (get-byte-buffer buffer) value))
+                     `(-put-byte (get-byte-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-put-byte (get-byte-buffer buffer) value))

 (defn take-short
   "Takes a short from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-short* (get-byte-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (take-short* (get-byte-buffer buffer)))
+                     `(-take-short (get-byte-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-take-short (get-byte-buffer buffer)))

 (defn put-short
   "Puts a short `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-short* (get-byte-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (put-short* (get-byte-buffer buffer) value))
+                     `(-put-short (get-byte-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-put-short (get-byte-buffer buffer) value))

 (defn take-int
   "Takes an int from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-int* (get-byte-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (take-int* (get-byte-buffer buffer)))
+                     `(-take-int (get-byte-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-take-int (get-byte-buffer buffer)))

 (defn put-int
   "Puts an int `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-int* (get-byte-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (put-int* (get-byte-buffer buffer) value))
+                     `(-put-int (get-byte-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-put-int (get-byte-buffer buffer) value))

 (defn take-long
   "Takes a long from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-long* (get-byte-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (take-long* (get-byte-buffer buffer)))
+                     `(-take-long (get-byte-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-take-long (get-byte-buffer buffer)))

 (defn put-long
   "Puts a long `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-long* (get-byte-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (put-long* (get-byte-buffer buffer) value))
+                     `(-put-long (get-byte-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-put-long (get-byte-buffer buffer) value))

 (defn take-float
   "Takes a float from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-float* (get-byte-buffer ~buffer)))})
+                     `(-take-float (get-byte-buffer ~buffer)))})
   ^double [^MikronBuffer buffer]
-  (take-float* (get-byte-buffer buffer)))
+  (-take-float (get-byte-buffer buffer)))

 (defn put-float
   "Puts a float `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-float* (get-byte-buffer ~buffer) ~value))})
+                     `(-put-float (get-byte-buffer ~buffer) ~value))})
   [^MikronBuffer buffer ^double value]
-  (put-float* (get-byte-buffer buffer) value))
+  (-put-float (get-byte-buffer buffer) value))

 (defn take-double
   "Takes a double from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-double* (get-byte-buffer ~buffer)))})
+                     `(-take-double (get-byte-buffer ~buffer)))})
   ^double [^MikronBuffer buffer]
-  (take-double* (get-byte-buffer buffer)))
+  (-take-double (get-byte-buffer buffer)))

 (defn put-double
   "Puts a double `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-double* (get-byte-buffer ~buffer) ~value))})
+                     `(-put-double (get-byte-buffer ~buffer) ~value))})
   [^MikronBuffer buffer ^double value]
-  (put-double* (get-byte-buffer buffer) value))
+  (-put-double (get-byte-buffer buffer) value))

 (defn take-bytes
   "Takes `n` bytes from `buffer`."
   #?(:clj {:inline (fn [buffer n]
-                     `(take-bytes* (get-byte-buffer ~buffer) ~n))})
+                     `(-take-bytes (get-byte-buffer ~buffer) ~n))})
   ^bytes [^MikronBuffer buffer ^long n]
-  (take-bytes* (get-byte-buffer buffer) n))
+  (-take-bytes (get-byte-buffer buffer) n))

 (defn put-bytes
   "Puts some bytes `value` to `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(put-bytes* (get-byte-buffer ~buffer) ~value))})
+                     `(-put-bytes (get-byte-buffer ~buffer) ~value))})
   [^MikronBuffer buffer ^bytes value]
-  (put-bytes* (get-byte-buffer buffer) value))
+  (-put-bytes (get-byte-buffer buffer) value))

 (defn take-bytes-all
   "Takes all bytes from `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(take-bytes-all* (get-byte-buffer ~buffer)))})
+                     `(-take-bytes-all (get-byte-buffer ~buffer)))})
   ^bytes [^MikronBuffer buffer]
-  (take-bytes-all* (get-byte-buffer buffer)))
+  (-take-bytes-all (get-byte-buffer buffer)))

 (defn get-position
   "Gets the position of `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(get-position* (get-byte-buffer ~buffer)))})
-  ^long [^MikronBuffer buffer]
-  (get-position* (get-byte-buffer buffer)))
+                     `(-get-position (get-byte-buffer ~buffer)))})
+  ^long [^MikronBuffer buffer]
+  (-get-position (get-byte-buffer buffer)))

 (defn set-position
   "Sets the position of `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(set-position* (get-byte-buffer ~buffer) ~value))})
-  [^MikronBuffer buffer ^long value]
-  (set-position* (get-byte-buffer buffer) value))
+                     `(-set-position (get-byte-buffer ~buffer) ~value))})
+  [^MikronBuffer buffer ^long value]
+  (-set-position (get-byte-buffer buffer) value))

 (defn get-le
   "Gets the endianness of `buffer`."
   #?(:clj {:inline (fn [buffer]
-                     `(get-le* (get-byte-buffer ~buffer)))})
+                     `(-get-le (get-byte-buffer ~buffer)))})
   [^MikronBuffer buffer]
-  (get-le* (get-byte-buffer buffer)))
+  (-get-le (get-byte-buffer buffer)))

 (defn set-le
   "Sets the endianness of `buffer`."
   #?(:clj {:inline (fn [buffer value]
-                     `(set-le* (get-byte-buffer ~buffer) ~value))})
+                     `(-set-le (get-byte-buffer ~buffer) ~value))})
   [^MikronBuffer buffer value]
-  (set-le* (get-byte-buffer buffer) value))
+  (-set-le (get-byte-buffer buffer) value))

 ;; Public derived operations

@@ -514,8 +514,8 @@
     buffer))

 (definterface+ IMikronByteBufferFactory
-  (^mikron.buffer.IMikronByteBuffer allocate* [^long size]    "Allocates a buffer with size `size`.")
-  (^mikron.buffer.IMikronByteBuffer wrap*     [^bytes binary] "Wraps a binary value `binary` with a buffer."))
+  (^mikron.buffer.IMikronByteBuffer -allocate [^long size]    "Allocates a buffer with size `size`.")
+  (^mikron.buffer.IMikronByteBuffer -wrap     [^bytes binary] "Wraps a binary value `binary` with a buffer."))

 (defn byte-buffer-factory?
   "Returns `true` if `value` is an instance of `IMikronByteBufferFactory`, `false` otherwise."
@@ -524,10 +524,10 @@

 (deftype MikronByteBufferFactory []
   IMikronByteBufferFactory
-  (allocate* [_ size]
+  (-allocate [_ size]
     #?(:clj  (->MikronByteBuffer (.order (ByteBuffer/allocateDirect size) (ByteOrder/nativeOrder)))
        :cljs (->MikronByteBuffer (.allocUnsafe NativeJsBuffer size) 0 true)))
-  (wrap* [_ binary]
+  (-wrap [_ binary]
     #?(:clj  (->MikronByteBuffer (ByteBuffer/wrap binary))
        :cljs (->MikronByteBuffer (.from NativeJsBuffer binary) 0 true))))

@@ -546,12 +546,11 @@
 (defn allocate
   "Allocates a buffer with the size `size`."
   ^MikronBuffer [^long size]
-  (->MikronBuffer (->MikronBitBuffer 0 0 -1) (allocate* byte-buffer-factory size)))
+  (->MikronBuffer (->MikronBitBuffer 0 0 -1) (-allocate byte-buffer-factory size)))

 (defn wrap
   "Wraps a binary value `binary` with a buffer."
   ^MikronBuffer [^bytes binary]
-  (->MikronBuffer (->MikronBitBuffer 0 0 -1) (wrap* byte-buffer-factory binary)))

 (defn set-headers
   "Sets the headers of `buffer`."
@@ -566,6 +565,7 @@
   [^MikronBuffer buffer]
   (set-le buffer (take-boolean buffer))
   {:diffed? (take-boolean buffer)})
+  (->MikronBuffer (->MikronBitBuffer 0 0 -1) (-wrap byte-buffer-factory binary)))

 ;; Multimethod abstractions for other consumers (e.g. tests)


Fix: Wrong path for gui.

Fix: Wrong path for gui.

--- src/main/clojure/conexp/main.clj
+++ src/main/clojure/conexp/main.clj
@@ -58,12 +58,12 @@
        {:custom-eval '(do
                         (in-ns 'conexp.main)
                         (use 'clojure.repl)
-                        (require '[conexp.contrib.gui.repl-utils :as gui])
-                        (require 'conexp.contrib.gui)
+                        (require '[conexp.gui.repl-utils :as gui])
+                        (require 'conexp.gui)
                         (alter-var-root
                          (var gui/*main-frame*)
                          (fn [_]
-                           (conexp.contrib.gui/gui
+                           (conexp.gui/gui
                             :default-close-operation :exit))))
         :custom-help ""})
       ;;


Adding docker log-driver journald to service units

--- src/terraboot/elasticsearch.clj
+++ src/terraboot/elasticsearch.clj
@@ -40,7 +40,7 @@
 ExecStartPre=/usr/bin/docker pull ~{full-image-name}:~{release}
 ExecStartPre=-/usr/bin/docker kill ~{image-name}
 ExecStartPre=-/usr/bin/docker rm ~{image-name}
-ExecStart=/usr/bin/docker run --name ~{image-name} ~{option-string} ~{full-image-name}:~{release} ~{entry-point}
+ExecStart=/usr/bin/docker run --log-driver journald --name ~{image-name} ~{option-string} ~{full-image-name}:~{release} ~{entry-point}
 ExecStop=/usr/bin/docker stop ~{image-name}

 [Install]


remove hardcoded value

remove hardcoded value

--- src/terraboot/elasticsearch.clj
+++ src/terraboot/elasticsearch.clj
@@ -162,7 +162,7 @@
                                                     :timeout 5
                                                     :interval 30}
                                      :listeners [(elb-listener (if cert-name
-                                                                 {:lb-port 443 :lb-protocol "https" :port 80 :protocol "http" :cert-name "StartMastodoncNet"}
+                                                                 {:lb-port 443 :lb-protocol "https" :port 80 :protocol "http" :cert-name cert-name}
                                                                  {:port 80 :protocol "http"}))]
                                      :subnets (mapv #(id-of "aws_subnet" (stringify  vpc-name "-public-" %)) azs)
                                      :instances [(id-of "aws_instance" (vpc-unique "alerts"))]


sudo all the things

sudo all the things

--- src/matross/connections/core.clj
+++ src/matross/connections/core.clj
@@ -1,4 +1,5 @@
-(ns matross.connections.core)
+(ns matross.connections.core
+  (:import [java.io SequenceInputStream ByteArrayInputStream]))

 (defprotocol IConnect
   "Interface for matross connections"
@@ -22,3 +23,15 @@

 (defmulti get-connection
   "get a connection instance of a specific type" :type)
+
+(deftype SudoRunner
+  [runner user password]
+  IRun
+  (run [self opts]
+    (let [pw-stream (ByteArrayInputStream. (.getBytes (str password "\n")))]
+    (run runner (-> opts
+                    (update-in [:cmd] #(apply conj ["sudo" "-S" "-u" user] %1))
+                    (update-in [:in] #(SequenceInputStream. pw-stream %1)))))))
+
+(defn sudo-runner [runner user opts]
+  (new SudoRunner runner user opts))


fix(paredit): if text is empty, consider in-code? returns true

--- paredit.clj/src/paredit/core.clj
+++ paredit.clj/src/paredit/core.clj
@@ -103,8 +103,9 @@
   "Is the offset in the parse tree in a 'code partition' or not?"
   [parse-tree offset]
   (with-important-memoized
-    (let [offset-loc (-> parse-tree parsed-root-loc (loc-for-offset offset))]
-      (in-code? offset-loc))))
+    (if-let [offset-loc (-> parse-tree parsed-root-loc (loc-for-offset offset))]
+      (in-code? offset-loc)
+      true)))

 (defmulti paredit (fn [k & args] k))


Update version.

Update version.

--- metlog-vault/project.clj
+++ metlog-vault/project.clj
@@ -1,5 +1,5 @@
-(defproject metlog-vault "0.5.2-SNAPSHOT"
-  :description "Repository for long term storage of series data."
+(defproject metlog-vault "0.6.0-SNAPSHOT"
+  :description "Repository for storing and displaying time series data reported by metlog-agent.."

   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}


Dimmers should pass heads when resolving params.

--- src/afterglow/effects/dimmer.clj
+++ src/afterglow/effects/dimmer.clj
@@ -137,23 +137,23 @@
   (params/validate-param-type master Master)
   (let [full-f (if htp?  ; Assignment function for dedicated dimmer channels
                  (fn [show snapshot target previous-assignment]
-                   (clamp-rgb-int (max (master-scale master (params/resolve-param level show snapshot))
-                                       (or (params/resolve-param previous-assignment show snapshot) 0))))
-                 (fn [show snapshot target previous-assignment]
-                   (clamp-rgb-int (master-scale master (params/resolve-param level show snapshot)))))
+                   (clamp-rgb-int (max (master-scale master (params/resolve-param level show snapshot target))
+                                       (or (params/resolve-param previous-assignment show snapshot target) 0))))
+                 (fn [show snapshot target previous-assignment]
+                   (clamp-rgb-int (master-scale master (params/resolve-param level show snapshot target)))))
         full-assigners (chan-fx/build-raw-channel-assigners full-channels full-f)
         func-f (if htp?  ; Assignment function for dimmer functions on multipurpose channels
                  ;; We must scale dimmer level from 0-255 to 0-100, since function effects use percentages.
                  (fn [show snapshot target previous-assignment]
-                   (max (/ (master-scale master (params/resolve-param level show snapshot)) 2.55)
-                        (or (params/resolve-param previous-assignment show snapshot) 0)))
-                 (fn [show snapshot target previous-assignment]
-                   (/ (master-scale master (params/resolve-param level show snapshot)) 2.55)))
+                   (max (/ (master-scale master (params/resolve-param level show snapshot target)) 2.55)
+                        (or (params/resolve-param previous-assignment show snapshot target) 0)))
+                 (fn [show snapshot target previous-assignment]
+                   (/ (master-scale master (params/resolve-param level show snapshot target)) 2.55)))
         func-assigners (chan-fx/build-head-function-assigners :dimmer function-heads func-f)
         virtual-f (fn [show snapshot target previous-assignment]
                     (when previous-assignment
                       (let [resolved (params/resolve-param previous-assignment show snapshot target)
-                            fraction (/ (master-scale master (params/resolve-param level show snapshot)) 255)]
+                            fraction (/ (master-scale master (params/resolve-param level show snapshot target)) 255)]
                         (colors/create-color :h (colors/hue resolved)
                                              :s (colors/saturation resolved)
                                              :l (clamp-percent-float (* (colors/lightness resolved) fraction))


Adding some tests to cologne algorithm

Adding some tests to cologne algorithm

--- test/clj_fuzzy/cologne_test.clj
+++ test/clj_fuzzy/cologne_test.clj
@@ -14,5 +14,10 @@
   (is (= "65752682" (process "Müller-Lüdenscheidt")))
   (is (= "17863" (process "Breschnew")))
   (is (= "3412" (process "Wikipedia")))
+  (is (= "4837" (process "Xavier")))
+  (is (= "478237" (process "Christopher")))
+  (is (= "3556" (process "Wilhelm")))
+  (is (= "351" (process "Philip")))
+  (is (= "1274" (process "Patrick")))
   (is (not= (process "Meyer") (process "Müller")))
   (is (= (process "Meyer") (process "Mayr"))))


misc test fixes

misc test fixes

--- test/clj_money/reports_test.clj
+++ test/clj_money/reports_test.clj
@@ -11,7 +11,9 @@
             [clj-money.reports :as reports]
             [clj-money.test-helpers :refer [reset-db
                                             find-account
+                                            find-accounts
                                             find-commodity
+                                            find-commodities
                                             context-errors
                                             simplify-account-groups]]))

@@ -765,30 +767,32 @@
          lt-gains
          st-gains
          lt-losses
-         st-losses] (map #(->> context
-                               :accounts
-                               (filter (fn [a] (= % (:name a))))
-                               first)
-                         ["IRA" "LT Gains" "ST Gains" "LT Losses" "ST Losses"])
+         st-losses] (find-accounts context "IRA"
+                                           "LT Gains"
+                                           "ST Gains"
+                                           "LT Losses"
+                                           "ST Losses")
         [aapl
          msft
-         ge] (:commodities context)
-        p1 (trading/buy storage-spec {:transaction-date (t/local-date 2017 1 15)
+         ge] (find-commodities context "AAPL"
+                                       "MSFT"
+                                       "GE")
+        p1 (trading/buy storage-spec {:trade-date (t/local-date 2017 1 15)
                                       :commodity-id (:id aapl)
                                       :account-id (:id ira)
                                       :shares 10M
                                       :value 100M})
-        p2 (trading/buy storage-spec {:transaction-date (t/local-date 2017 1 15)
+        p2 (trading/buy storage-spec {:trade-date (t/local-date 2017 1 15)
                                       :commodity-id (:id msft)
                                       :account-id (:id ira)
                                       :shares 10M
                                       :value 100M})
-        p3 (trading/buy storage-spec {:transaction-date (t/local-date 2017 1 15)
+        p3 (trading/buy storage-spec {:trade-date (t/local-date 2017 1 15)
                                       :commodity-id (:id ge)
                                       :account-id (:id ira)
                                       :shares 10M
                                       :value 100M})
-        s1 (trading/sell storage-spec {:transaction-date (t/local-date 2017 1 31)
+        s1 (trading/sell storage-spec {:trade-date (t/local-date 2017 1 31)
                                        :commodity-id (:id aapl)
                                        :account-id (:id ira)
                                        :shares 5M


Test that different routers work correctly

--- test/cljc/reitit/core_test.cljc
+++ test/cljc/reitit/core_test.cljc
@@ -7,140 +7,80 @@

 (deftest reitit-test

-  (testing "prefix-tree-router"
-    (let [router (r/router ["/api" ["/ipa" ["/:size" ::beer]]])]
-      (is (= :prefix-tree-router (r/router-name router)))
-      (is (= [["/api/ipa/:size" {:name ::beer} nil]]
-             (r/routes router)))
-      (is (= true (map? (r/options router))))
-      (is (= (r/map->Match
-               {:template "/api/ipa/:size"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-path router "/api/ipa/large")))
-      (is (= (r/map->Match
-               {:template "/api/ipa/:size"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-name router ::beer {:size "large"})))
-      (is (= nil (r/match-by-name router "ILLEGAL")))
-      (is (= [::beer] (r/route-names router)))
-
-      (testing "name-based routing with missing parameters"
-        (is (= (r/map->PartialMatch
+  (testing "routers handling wildcard paths"
+    (are [r name]
+      (let [router (r/router ["/api" ["/ipa" ["/:size" ::beer]]] {:router r})]
+        (is (= name (r/router-name router)))
+        (is (= [["/api/ipa/:size" {:name ::beer} nil]]
+               (r/routes router)))
+        (is (= true (map? (r/options router))))
+        (is (= (r/map->Match
                  {:template "/api/ipa/:size"
                   :meta {:name ::beer}
-                  :required #{:size}
-                  :params nil})
-               (r/match-by-name router ::beer)))
-        (is (= true (r/partial-match? (r/match-by-name router ::beer))))
-        (is (thrown-with-msg?
-              ExceptionInfo
-              #"^missing path-params for route /api/ipa/:size -> \#\{:size\}$"
-              (r/match-by-name! router ::beer))))))
-
-  (testing "linear-router"
-    (let [router (r/router ["/api" ["/ipa" ["/:size" ::beer]]] {:router r/linear-router})]
-      (is (= :linear-router (r/router-name router)))
-      (is (= [["/api/ipa/:size" {:name ::beer} nil]]
-             (r/routes router)))
-      (is (= true (map? (r/options router))))
-      (is (= (r/map->Match
-               {:template "/api/ipa/:size"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-path router "/api/ipa/large")))
-      (is (= (r/map->Match
-               {:template "/api/ipa/:size"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-name router ::beer {:size "large"})))
-      (is (= nil (r/match-by-name router "ILLEGAL")))
-      (is (= [::beer] (r/route-names router)))
-
-      (testing "name-based routing with missing parameters"
-        (is (= (r/map->PartialMatch
+                  :path "/api/ipa/large"
+                  :params {:size "large"}})
+               (r/match-by-path router "/api/ipa/large")))
+        (is (= (r/map->Match
                  {:template "/api/ipa/:size"
                   :meta {:name ::beer}
-                  :required #{:size}
-                  :params nil})
-               (r/match-by-name router ::beer)))
-        (is (= true (r/partial-match? (r/match-by-name router ::beer))))
-        (is (thrown-with-msg?
-              ExceptionInfo
-              #"^missing path-params for route /api/ipa/:size -> \#\{:size\}$"
-              (r/match-by-name! router ::beer))))))
-
-  (testing "lookup-router"
-    (let [router (r/router ["/api" ["/ipa" ["/large" ::beer]]] {:router r/lookup-router})]
-      (is (= :lookup-router (r/router-name router)))
-      (is (= [["/api/ipa/large" {:name ::beer} nil]]
-             (r/routes router)))
-      (is (= true (map? (r/options router))))
-      (is (= (r/map->Match
-               {:template "/api/ipa/large"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {}})
-             (r/match-by-path router "/api/ipa/large")))
-      (is (= (r/map->Match
-               {:template "/api/ipa/large"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-name router ::beer {:size "large"})))
-      (is (= nil (r/match-by-name router "ILLEGAL")))
-      (is (= [::beer] (r/route-names router)))
-
-      (testing "can't be created with wildcard routes"
-        (is (thrown-with-msg?
-              ExceptionInfo
-              #"can't create :lookup-router with wildcard routes"
-              (r/lookup-router
-                (r/resolve-routes
-                  ["/api/:version/ping"] {})))))))
-
-  (testing "single-static-path-router"
-    (let [router (r/router ["/api" ["/ipa" ["/large" ::beer]]])]
-      (is (= :single-static-path-router (r/router-name router)))
-      (is (= [["/api/ipa/large" {:name ::beer} nil]]
-             (r/routes router)))
-      (is (= true (map? (r/options router))))
-      (is (= (r/map->Match
-               {:template "/api/ipa/large"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {}})
-             (r/match-by-path router "/api/ipa/large")))
-      (is (= (r/map->Match
-               {:template "/api/ipa/large"
-                :meta {:name ::beer}
-                :path "/api/ipa/large"
-                :params {:size "large"}})
-             (r/match-by-name router ::beer {:size "large"})))
-      (is (= nil (r/match-by-name router "ILLEGAL")))
-      (is (= [::beer] (r/route-names router)))
-
-      (testing "can't be created with wildcard routes"
-        (is (thrown-with-msg?
-              ExceptionInfo
-              #":single-static-path-router requires exactly 1 static route"
-              (r/single-static-path-router
-                (r/resolve-routes
-                  ["/api/:version/ping"] {})))))
-
-      (testing "can't be created with multiple routes"
-        (is (thrown-with-msg?
-              ExceptionInfo
-              #":single-static-path-router requires exactly 1 static route"
-              (r/single-static-path-router
-                (r/resolve-routes
-                  [["/ping"]
-                   ["/pong"]] {})))))))
+                  :path "/api/ipa/large"
+                  :params {:size "large"}})
+               (r/match-by-name router ::beer {:size "large"})))
+        (is (= nil (r/match-by-name router "ILLEGAL")))
+        (is (= [::beer] (r/route-names router)))
+
+        (testing "name-based routing with missing parameters"
+          (is (= (r/map->PartialMatch
+                   {:template "/api/ipa/:size"
+                    :meta {:name ::beer}
+                    :required #{:size}
+                    :params nil})
+                 (r/match-by-name router ::beer)))
+          (is (= true (r/partial-match? (r/match-by-name router ::beer))))
+          (is (thrown-with-msg?
+                ExceptionInfo
+                #"^missing path-params for route /api/ipa/:size -> \#\{:size\}$"
+                (r/match-by-name! router ::beer)))))
+
+      r/linear-router :linear-router
+      r/prefix-tree-router :prefix-tree-router
+      r/mixed-router :mixed-router))
+
+  (testing "routers handling static paths"
+    (are [r name]
+      (let [router (r/router ["/api" ["/ipa" ["/large" ::beer]]] {:router r})]
+        (is (= name (r/router-name router)))
+        (is (= [["/api/ipa/large" {:name ::beer} nil]]
+               (r/routes router)))
+        (is (= true (map? (r/options router))))
+        (is (= (r/map->Match
+                 {:template "/api/ipa/large"
+                  :meta {:name ::beer}
+                  :path "/api/ipa/large"
+                  :params {}})
+               (r/match-by-path router "/api/ipa/large")))
+        (is (= (r/map->Match
+                 {:template "/api/ipa/large"
+                  :meta {:name ::beer}
+                  :path "/api/ipa/large"
+                  :params {:size "large"}})
+               (r/match-by-name router ::beer {:size "large"})))
+        (is (= nil (r/match-by-name router "ILLEGAL")))
+        (is (= [::beer] (r/route-names router)))
+
+        (testing "can't be created with wildcard routes"
+          (is (thrown-with-msg?
+                ExceptionInfo
+                #"can't create :lookup-router with wildcard routes"
+                (r/lookup-router
+                  (r/resolve-routes
+                    ["/api/:version/ping"] {}))))))
+
+      r/lookup-router :lookup-router
+      r/single-static-path-router :single-static-path-router
+      r/linear-router :linear-router
+      r/prefix-tree-router :prefix-tree-router
+      r/mixed-router :mixed-router))

   (testing "route coercion & compilation"


(PDB-5022) jdbc: convert doalls to doseqs to emphasize side-effects

Aside from being more idomatic, this also satisfies eastwood's linter.

--- src/puppetlabs/puppetdb/jdbc.clj
+++ src/puppetlabs/puppetdb/jdbc.clj
@@ -271,8 +271,8 @@
     f]
    (with-db-transaction []
      (with-open [stmt (.prepareStatement ^Connection (:connection *db*) sql)]
-       (doall (map-indexed (fn [i param] (.setObject stmt (inc i) param))
-                           params))
+       (doseq [[i param] (map vector (range) params)]
+         (.setObject stmt (inc i) param))
        (.setFetchSize stmt (or fetch-size 500))
        (with-open [rset (.executeQuery stmt)]
          (try
@@ -302,8 +302,8 @@
     f]
    (with-db-transaction []
      (with-open [stmt (.prepareStatement ^Connection (:connection *db*) sql)]
-       (doall (map-indexed (fn [i param] (.setObject stmt (inc i) param))
-                           params))
+       (doseq [[i param] (map vector (range) params)]
+         (.setObject stmt (inc i) param))
        (.setFetchSize stmt 500)
        (let [fix-vals (if as-arrays?
                         #(mapv any-sql-array->vec %)


Track non-monotonic dependencies

Track non-monotonic dependencies

--- src/aurora/compiler/datalog.cljs
+++ src/aurora/compiler/datalog.cljs
@@ -80,16 +80,34 @@
 (defn preds-out [clause]
   ;; TODO check not nil
   (condp op? clause
-        '+ #{(:name (second clause))}
-        '- #{(:name (second clause))}
-        '+s #{::any}
-        '-s #{::any}
-        '> (let [from-name (:name (nth clause 1))
-                 to-name (:name (nth clause 2))]
-             (check from-name)
-             (check (or (nil? to-name) (= from-name to-name)))
-             #{(:name (nth clause 1))})
-        #{}))
+    '+ #{(:name (second clause))}
+    '- #{(:name (second clause))}
+    '+s #{::any}
+    '-s #{::any}
+    '> (let [from-name (:name (nth clause 1))
+             to-name (:name (nth clause 2))]
+         (check from-name)
+         (check (or (nil? to-name) (= from-name to-name)))
+         #{(:name (nth clause 1))})
+    #{}))
+
+(defn negs-in [clause]
+  ;; TODO check not nil
+  (condp op? clause
+    'set (apply clojure.set/union (map preds-in (nthnext clause 3)))
+    #{}))
+
+(defn negs-out [clause]
+  ;; TODO check not nil
+  (condp op? clause
+    '- #{(:name (second clause))}
+    '-s #{::any}
+    '> (let [from-name (:name (nth clause 1))
+             to-name (:name (nth clause 2))]
+         (check from-name)
+         (check (or (nil? to-name) (= from-name to-name)))
+         #{(:name (nth clause 1))})
+    #{}))

 (def empty-q
   (with-meta
@@ -240,7 +258,9 @@
         (let [[asserts retracts] (asserts+retracts kn)]
           (reduce retract (reduce assert kn asserts) retracts)))
       {::preds-in (apply union (map preds-in clauses))
-       ::preds-out (apply union (map preds-out clauses))})))
+       ::preds-out (apply union (map preds-out clauses))
+       ::negs-in (apply union (map negs-in clauses))
+       ::negs-out (apply union (map negs-out clauses))})))

 (defn chain [rules]
   (fn [kn]


fix typo

fix typo

--- src/babel/espanol/morphology.clj
+++ src/babel/espanol/morphology.clj
@@ -572,7 +572,7 @@
         (str stem "amos")

         (and (= person :1st) (= number :plur) er-type)
-        (str stem "emos")
+        (str stem "imos")

         (and (= person :1st) (= number :plur) ir-type)
         (str stem "imos")


Pass connection to db-disconnect

Pass connection to db-disconnect

--- src/servisne_info/repository.clj
+++ src/servisne_info/repository.clj
@@ -26,7 +26,7 @@
     (timbre/info "Connected")))

 (defn db-disconnect []
-  (mg/disconnect))
+  (mg/disconnect @connection))

 ; User
 (defn create-user [attributes]


fixes to ear/build.boot

fixes to ear/build.boot

Signed-off-by: Gregg Reynolds <d0f77bc71a9867acdcb4f62f012b858edad79160@norc.org>

--- examples/services/ear/build.boot
+++ examples/services/ear/build.boot
@@ -1,23 +1,35 @@
+(def +project+ 'tmp/services-app)
+(def +version+ "0.1.0-SNAPSHOT")
+
 (set-env!
- :checkouts '[[tmp/greetings "0.1.0-SNAPSHOT" :module "greetings" :port 8089]
-              [tmp.modules/main "0.1.0-SNAPSHOT" :port 8083]] ;; defaults to :module "main"
- :asset-paths #{"assets"}
+ :gae {:app-id +project+
+       :version +version+}
+
+ ;; FIXME: mv to edn file?
+ :checkouts '[[tmp/greetings "0.1.0-SNAPSHOT" :module "greetings" :port 8088]
+              [tmp.services/default "0.1.0-SNAPSHOT" :port 8083]] ;; default :module is "default"
+
+ ;; :asset-paths #{"assets"}
+
+ :source-paths #{"config"}
+
  :repositories {"clojars" "https://clojars.org/repo"
                 "central" "http://repo1.maven.org/maven2/"}
+
  :dependencies '[[migae/boot-gae "0.1.0-SNAPSHOT" :scope "test"]
                  [com.google.appengine/appengine-java-sdk LATEST :scope "test" :extension "zip"]
-                 [tmp.modules/main "0.1.0-SNAPSHOT"]
+                 [tmp.services/default "0.1.0-SNAPSHOT"]
                  [tmp/greetings "0.1.0-SNAPSHOT"]])

 (require '[migae.boot-gae :as gae])

-;; (def modules {:modules [{:coords [tmp.modules/main "0.1.0-SNAPSHOT"]
+;; (def modules {:modules [{:coords [tmp.modules/default "0.1.0-SNAPSHOT"]
 ;;                          :default true
 ;;                          :port 8088}
 ;;                         {:coords [tmp/greetings "0.1.0-SNAPSHOT"]
 ;;                          :port 8089}]})

-;; (def modules '[[tmp.modules/main "0.1.0-SNAPSHOT" :default true :port 8088]
+;; (def modules '[[tmp.modules/default "0.1.0-SNAPSHOT" :default true :port 8088]
 ;;                [tmp/greetings "0.1.0-SNAPSHOT" :port 8089]])

 ;; (task-options!


refactor conditional

refactor conditional

--- src/chat/client/new-message.cljs
+++ src/chat/client/new-message.cljs
@@ -57,37 +57,34 @@
                                            (om/set-state! owner :text (.. e -target -value)))
                                :onKeyDown
                                (fn [e]
-                                 (cond
-                                   ; enter when autocomplete -> tag
-                                   (and (= KeyCodes.ENTER e.keyCode) autocomplete-open?)
-                                   (do
-                                     (.preventDefault e)
-                                     (when-let [tag (nth results highlighted-result-index nil)]
-                                       (dispatch! :tag-thread {:thread-id (config :thread-id)
-                                                               :id (tag :id)})
-                                       (close-autocomplete!)))
-                                   ; enter otherwise -> message
-                                   (and (= KeyCodes.ENTER e.keyCode) (= e.shiftKey false))
-                                   (do
-                                     (.preventDefault e)
-                                     (dispatch! :new-message {:thread-id (config :thread-id)
-                                                              :content text})
-                                     (clear-text!))
+                                 (condp = e.keyCode
+                                   KeyCodes.ENTER
+                                   (cond
+                                     ; enter when autocomplete -> tag
+                                     autocomplete-open?
+                                     (do
+                                       (.preventDefault e)
+                                       (when-let [tag (nth results highlighted-result-index nil)]
+                                         (dispatch! :tag-thread {:thread-id (config :thread-id)
+                                                                 :id (tag :id)})
+                                         (close-autocomplete!)))
+                                     ; enter otherwise -> message
+                                     (not e.shiftKey)
+                                     (do
+                                       (.preventDefault e)
+                                       (dispatch! :new-message {:thread-id (config :thread-id)
+                                                                :content text})
+                                       (clear-text!)))

-                                   (= KeyCodes.ESC e.keyCode)
-                                   (do
-                                     (close-autocomplete!))
+                                   KeyCodes.ESC (close-autocomplete!)

-                                   (= KeyCodes.UP e.keyCode)
-                                   (do
-                                     (.preventDefault e)
-                                     (highlight-prev!))
+                                   KeyCodes.UP (do
+                                                 (.preventDefault e)
+                                                 (highlight-prev!))

-                                   (= KeyCodes.DOWN e.keyCode)
-                                   (do
-                                     (.preventDefault e)
-                                     (highlight-next!))
-                                   :else
+                                   KeyCodes.DOWN (do
+                                                   (.preventDefault e)
+                                                   (highlight-next!))
                                    (when (KeyCodes.isTextModifyingKeyEvent e)
                                      ; Don't clear if a modifier key alone was pressed
                                      (highlight-clear!))))})


don't use anti-forgery on api calls

don't use anti-forgery on api calls

--- src/clj/clj_money/web/server.clj
+++ src/clj/clj_money/web/server.clj
@@ -251,7 +251,7 @@

 (def wrapped-routes
   (wrap-routes all-routes
-               [wrap-anti-forgery                   "anti-forgery"]
+               [wrap-anti-forgery                   "anti-forgery"     (complement api?)]
                [wrap-multipart-params               "multipart params" (complement api?)]
                [wrap-keyword-params                 "keyword params"   (complement api?)]
                [wrap-json-params                    "json params"      api?]


wrap server-side error

wrap server-side error

--- src/clj/dokkaa_builder/route.clj
+++ src/clj/dokkaa_builder/route.clj
@@ -127,7 +127,15 @@
   (let [store (cookie/cookie-store {:key (env :session-secret)})]
     (site app {:session {:store store}})))

+(defn wrap-error [app]
+  (fn [req]
+    (try (app req)
+      (catch Exception e
+        {:status 500
+         :body (j/encode {:message "Internal Server Error"})}))))
+
 (def app (-> routes
+             wrap-error
              (friend/authenticate {:allow-anon? true
                                    :workflows [(github/workflow)
                                                (dworkflows/api-token)]})


Enrich the data from a vubis file with default metadata

--- src/clj/mdr2/routes/services.clj
+++ src/clj/mdr2/routes/services.clj
@@ -160,7 +160,8 @@
                         (let [tempfile (:tempfile file)
                               errors (vubis/validate (.getPath tempfile))]
                           (if (empty? errors)
-                            (let [productions (vubis/read-file tempfile)]
+                            (let [productions (->> (vubis/read-file tempfile)
+                                                   (map prod/add-default-meta-data))]
                               (if-not (nom/anomaly? productions)
                                 (ok productions)
                                 (bad-request productions)))


refine entities.cljs

refine entities.cljs

use for instead of doall + map
don't reference the atom when updating it

--- src/cljs/clj_money/entities.cljs
+++ src/cljs/clj_money/entities.cljs
@@ -78,7 +78,8 @@
        [:tr
         [:th.col-sm-10 "Name"]
         [:th.col-sm-2 " "]]
-       (doall (map #(entity-row %) @all-entities))]])
+       (for [entity @all-entities]
+         (entity-row entity))]])

 (defn management
   "Renders an entity management form"
@@ -110,4 +111,4 @@
 (defn activate
   "Sets the specified entity as the active entity"
   [entity]
-  (reset! @current entity))
+  (reset! current entity))


Use :maxHeight instead of :max-height to allow vertical scrolling in Firefox / Tor Browser. Fixes #76.

--- src/cljs/clojuredocs/sticky.cljs
+++ src/cljs/clojuredocs/sticky.cljs
@@ -57,7 +57,7 @@
                 (dom/add-class! $el :sticky)
                 (dom/set-style! $el
                   :width (str width "px")
-                  :max-height (str js/window.innerHeight "px")
+                  :maxHeight (str js/window.innerHeight "px")
                   :top (str px-offset "px")))
               (do
                 (reset! starting-offset nil)


fixed broken route from collection to unit

--- src/cljs/lokate/collections.cljs
+++ src/cljs/lokate/collections.cljs
@@ -91,6 +91,6 @@
             (om/build
               link-list (vals (:units collection))
               {:opts {:name-default "Untitled_Unit"
-                       :route-fn #(get-route :unit
+                       :route-fn #(get-route :unit-info
                                     {:c-id c-id :u-id (keyword (:id %))})
                        :props {:onContextMenu #(false)}}})))))))


Add play-clj.repl to the namespace lists

--- src/clojure/nightmod/sandbox.clj
+++ src/clojure/nightmod/sandbox.clj
@@ -59,6 +59,7 @@
                                 '[play-clj.g3d :refer :all]
                                 '[play-clj.math :refer :all]
                                 '[play-clj.physics :refer :all]
+                                '[play-clj.repl :refer :all]
                                 '[play-clj.ui :refer :all])))

 (defn run-file!
@@ -103,6 +104,7 @@
          'play-clj.g3d
          'play-clj.math
          'play-clj.physics
+         'play-clj.repl
          'play-clj.ui])

 ; set function that prevents blacklisted symbols from being in completions


Cleanup syntax around websocket connections

--- src/engulf/views/benchmarker.clj
+++ src/engulf/views/benchmarker.clj
@@ -47,4 +47,5 @@
   :else (benchmark/stop-current-benchmark)))

 (na/defpage-async "/benchmarker/stream" {} conn
-  (receive-all json-socket-ch #(na/async-push conn %1)))+  (receive-all json-socket-ch
+               (fn [m] (na/async-push conn m))))


Adds `install-entity!`

Adds `install-entity!`

--- src/great_things_done/state.cljs
+++ src/great_things_done/state.cljs
@@ -111,6 +111,13 @@
   (store-project! project)
   (db/serialize-project! project)
   project)
+
+(defn- install-entity!
+  [entity]
+  (when (is-project entity)
+    (install-project entity))
+  (when (is-task entity)
+    (install-task entity)))

 ;; `repeating` can have two values:
 ;;   - nil


Remove detail view image of pokemon

Remove detail view image of pokemon

--- frontend/src/cruncher/views.cljs
+++ frontend/src/cruncher/views.cljs
@@ -73,17 +73,18 @@
       (dom/tr #js {:id        (str "poketable-row-details-" (:id pokemon))
                    :className "collapse"}
               (dom/td #js {:className "well"})
-              (dom/td #js {:className "well" :colSpan 3} (dom/img #js {:src       (str "img/pokemon/models/" (:pokemon_id pokemon) ".png")
-                                                                       :className "pokemon-image"}))
-              (dom/td #js {:className "well" :colSpan 9}
+              (dom/td #js {:className "well" :colSpan 12}
                       (dom/div #js {:className "row"}
-                               (dom/div #js {:className "col-md-2"} "Evolves to:")
-                               (dom/div #js {:className "col-md-10"} (if (lib/pokemon-evolution pokemon)
-                                                                       (lib/pokemon-evolution pokemon)
-                                                                       "None")))
-                      (dom/div #js {:className "row"}
-                               (dom/div #js {:className "col-md-2"} "Available Candy:")
-                               (dom/div #js {:className "col-md-10"} (:candy pokemon))))))))
+                               (dom/div #js {:className "col-md-6"}
+                                        (dom/div #js {:className "row"}
+                                                 (dom/div #js {:className "col-md-4"} "Available Candy:")
+                                                 (dom/div #js {:className "col-md-8"} (:candy pokemon))))
+                               (dom/div #js {:className "col-md-6"}
+                                        (dom/div #js {:className "row"}
+                                                 (dom/div #js {:className "col-md-4"} "Evolves to:")
+                                                 (dom/div #js {:className "col-md-8"} (if (lib/pokemon-evolution pokemon)
+                                                                                (lib/pokemon-evolution pokemon)
+                                                                                "None"))))))))))
 (def poketable-entry-details (om/factory PokeTableEntryDetails {}))

 (defui PokeTableEntry


Add dummy text

Add dummy text

--- frontend/src/crunsher/views.cljs
+++ frontend/src/crunsher/views.cljs
@@ -65,7 +65,8 @@
                                            (dom/th nil "IV Defense")
                                            (dom/th nil "IV Stamina")))
                         (apply dom/tbody nil
-                               (map #(poketable-entry (lib/merge-react-key %)) (lib/inventory-pokemon)))))))
+                               (map #(poketable-entry (lib/merge-react-key %)) (lib/inventory-pokemon))))
+             (dom/div nil (controls)))))
 (def poketable (om/factory PokeTable {}))

 (defui Header
@@ -73,6 +74,9 @@
   (render [this]
     (dom/div nil
              (dom/h1 nil "Poké-Cruncher"))))
+             (dom/div #js {:className "page-header"}
+                      (dom/h1 nil "Poké-Crunsher"))
+             (dom/p nil "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."))))
 (def header (om/factory Header))

 (defn commit-component-state
@@ -90,42 +94,52 @@
     (let [email (om/get-state this :email)
           password (om/get-state this :password)
           location (om/get-state this :location)]
-      (dom/div nil
-               (dom/h5 #js {:className "text-center"} "Login")
-               (dom/div #js {:className "input-group"}
-                        (dom/span #js {:className "input-group-addon"}
-                                  (fa-icon "fa-user fa-fw"))
-                        (dom/input #js {:className   "form-control"
-                                        :onChange    #(commit-component-state this :email %)
-                                        :value       email
-                                        :placeholder "email"}))
-               (dom/div #js {:className "input-group"}
-                        (dom/span #js {:className "input-group-addon"}
-                                  (fa-icon "fa-key fa-fw"))
-                        (dom/input #js {:className   "form-control"
-                                        :onChange    #(commit-component-state this :password %)
-                                        :value       password
-                                        :type        "password"
-                                        :placeholder "password"}))
-               (dom/div #js {:className "input-group"}
-                        (dom/span #js {:className "input-group-addon"}
-                                  (fa-icon "fa-map-marker fa-fw"))
-                        (dom/input #js {:className   "form-control"
-                                        :onChange    #(commit-component-state this :location %)
-                                        :value       location
-                                        :placeholder "Düsseldorf, Germany"}))
-               (dom/button #js {:className "btn btn-default"
-                                :onClick   #(auth/login email password location "ptc")}
-                           "Login")))))
+      (dom/div #js {:className "row"}
+               (dom/div #js {:className "col-md-6 col-md-offset-3"}
+                        (dom/h5 #js {:className "text-center"} "Login")
+                        (dom/div #js {:className "input-group"}
+                                 (dom/span #js {:className "input-group-addon"}
+                                           (fa-icon "fa-user fa-fw"))
+                                 (dom/input #js {:className   "form-control"
+                                                 :onChange    #(commit-component-state this :email %)
+                                                 :value       email
+                                                 :placeholder "email"}))
+                        (dom/div #js {:className "input-group"}
+                                 (dom/span #js {:className "input-group-addon"}
+                                           (fa-icon "fa-key fa-fw"))
+                                 (dom/input #js {:className   "form-control"
+                                                 :onChange    #(commit-component-state this :password %)
+                                                 :value       password
+                                                 :type        "password"
+                                                 :placeholder "password"}))
+                        (dom/div #js {:className "input-group"}
+                                 (dom/span #js {:className "input-group-addon"}
+                                           (fa-icon "fa-map-marker fa-fw"))
+                                 (dom/input #js {:className   "form-control"
+                                                 :onChange    #(commit-component-state this :location %)
+                                                 :value       location
+                                                 :placeholder "Düsseldorf, Germany"}))
+                        (dom/button #js {:className "btn btn-default"
+                                         :onClick   #(auth/login email password location "ptc")}
+                                    "Login"))))))
 (def login (om/factory Login))
+
+(defn view-dispatcher
+  "Dispatch current template in main view by the app state."
+  []
+  (let [view (lib/current-view)]
+    (cond
+      (= view :login) (login)
+      (not (lib/logged-in?)) (login)
+      :else (poketable))))

 (defui Main
   Object
   (render [this]
     (dom/div nil
              (dom/div nil (header))
-             (dom/div nil (poketable (om/props this)))
-             (dom/div nil (controls))
-             (dom/div nil (login)))))
+             (view-dispatcher)
+             #_(dom/div nil (poketable (om/props this)))
+             #_(dom/div nil (login)))))