refined project.clj

refined project.clj

--- ext/chrome/project.clj
+++ ext/chrome/project.clj
@@ -2,8 +2,7 @@

   :dependencies [[org.clojure/clojure "1.8.0"]
                  [org.clojure/clojurescript "1.9.473"]
-                 [domina "1.0.3"]
-                 ]
+                 [domina "1.0.3"]]

   :plugins [[lein-figwheel "0.5.9"]
             [lein-cljsbuild "1.1.5"]
@@ -16,13 +15,12 @@
                                   [com.cemerick/piggieback "0.2.1"]]
                    :cljsbuild
                    {:builds [{:id "dev"
-                              :source-paths ["src"]
+                              :source-paths ["src" "externs"]
                               :figwheel {
                                          :open-urls ["http://localhost:3449/popup.html"]
                                          }
                               :compiler {:main "owl.web.core"
-                                         :externs
-                                         ["externs/chrome_extensions.js"]
+                                         :externs ["chrome_extensions.js"]
                                          :asset-path "js/out"
                                          :output-to "resources/public/js/owl.js"
                                          :output-dir "resources/public/js/out"
@@ -32,15 +30,14 @@
                    }
              :pro {:cljsbuild
                    {:builds
-                    [{:source-paths ["src"]
-                      :compiler {
-                                 :externs
-                                 ["externs/chrome_extensions.js"]
+                    [{:source-paths ["src" "externs"]
+                      :compiler {:externs ["chrome_extensions.js"]
                                  :output-to "resources/public/js/owl.js"
                                  ;; :closure-output-charset "US-ASCII"
                                  :optimizations :advanced
                                  :pretty-print false}
                       }]}
+
                    :pack {:mapping [{:source-paths ["manifest.json"
                                                     "resources/public"]
                                      :target-path "target/pro"
@@ -50,8 +47,10 @@
              }

-  :figwheel {:css-dirs ["resources/public/css"]
+  :figwheel {
+             :css-dirs ["resources/public/css"]
              :open-file-command "emacsclient"
+             :server-logfile ".figwheel.log"
              }

   :aliases {"release"     ["with-profile" "pro"


Fix group chat info labels

Fix group chat info labels

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/profile/group_chat/styles.cljs
+++ src/status_im/ui/screens/profile/group_chat/styles.cljs
@@ -9,7 +9,8 @@
   {:background-color (colors/alpha colors/blue 0.1)
    :border-radius    50})

-(def action-label
+; Action label style is expected to be a fn
+(defn action-label [_]
   {:color colors/blue})

 (def action-separator
@@ -18,4 +19,4 @@
    :margin-left      50})

 (def action-icon-opts
-  {:color colors/blue})+  {:color colors/blue})


`add-module-lesson!` - use keyword arguments

And change the function signature of `find-free-row-for-lesson`. This
cuts down the usage of the `ModulesMapLesson` type.

Signed-off-by: Pang Yan Han <22594c345857f664c61cd411f607c4d40a9d4af9@gmail.com>

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -476,10 +476,8 @@

    The `moduleMapLesson` parameter should be a lesson from the `ModulesMap`
    global"
-  [moduleMapLesson]
-  (let [ttDay     (get-timetable-day (:day moduleMapLesson))
-        startTime (:startTime moduleMapLesson)
-        endTime   (:endTime moduleMapLesson)]
+  [day startTime endTime]
+  (let [ttDay (get-timetable-day day)]
     (:rowIndex
       (reduce
         (fn [result ttRow]
@@ -537,14 +535,12 @@
   "Adds a single lesson of a module the timetable.
    Returns a `ModulesSelectedLessonInfo` object augmented with the `:divElem`,
    `:moduleCode`, `:lessonType` and `:lessonGroup` keys."
-  [moduleCode moduleName lessonType lessonGroup modulesMapLesson bgColorCssClass
-   isActuallySelected?]
-  (let [rowNum    (find-free-row-for-lesson modulesMapLesson)
-        day       (:day modulesMapLesson)
-        startTime (:startTime modulesMapLesson)
-        endTime   (:endTime modulesMapLesson)
+  [& {:keys [moduleCode moduleName lessonType lessonGroup
+             day startTime endTime venue
+             bgColorCssClass isActuallySelected?]}]
+  (let [; TODO: Change find-free-row-for-lesson
+        rowNum    (find-free-row-for-lesson day startTime endTime)
         slotsOcc  (- endTime startTime)
-        venue     (:venue modulesMapLesson)

         [hourClass minuteClass]
         (get-css-hour-minute-classes-for-time startTime)
@@ -757,12 +753,18 @@
                                                           lessonGroup)

             augLessonInfoSeq
-            (doall (map (fn [modulesMapLesson]
-                          (add-module-lesson! moduleCode moduleName lessonType
-                                              lessonGroup modulesMapLesson
-                                              bgColorCssClass
-                                              isActuallySelected?))
-                        modulesMapLessonSeq))
+            (doall
+              (map (fn [modulesMapLesson]
+                     (add-module-lesson!
+                       :moduleCode moduleCode, :moduleName moduleName,
+                       :lessonType lessonType, :lessonGroup lessonGroup,
+                       :day        (:day modulesMapLesson),
+                       :startTime  (:startTime modulesMapLesson),
+                       :endTime    (:endTime modulesMapLesson),
+                       :venue      (:venue modulesMapLesson),
+                       :bgColorCssClass bgColorCssClass,
+                       :isActuallySelected? isActuallySelected?))
+                   modulesMapLessonSeq))

             lessonInfoSeq       (map #(dissoc %1 :divElem :moduleCode
                                               :lessonType :lessonGroup)


Eliminate some extra gl calls

Eliminate some extra gl calls

--- src/cljs/robinson/webglterminal.cljs
+++ src/cljs/robinson/webglterminal.cljs
@@ -16,6 +16,8 @@
             [cljs-webgl.texture :as texture]
             [cljs-webgl.constants.texture-parameter-name :as texture-parameter-name]
             [cljs-webgl.constants.texture-filter :as texture-filter]
+            [cljs-webgl.constants.texture-target :as texture-target]
+            [cljs-webgl.constants.texture-unit :as texture-unit]
             [cljs-webgl.shaders :as shaders]
             [cljs-webgl.constants.draw-mode :as draw-mode]
             [cljs-webgl.constants.data-type :as data-type]
@@ -240,10 +242,17 @@

           ;; Draws character c at position [x y] on the terminal canvas using gl.
           draw-character   (fn [c x y]
-                             (let [uvs (character->uvs (get c :character))]
+                             (let [uvs        (character->uvs (get c :character))
+                                   uvs-buffer (square-texture-buffer-fn uvs)]
                              ;(log/info "character->pos" (str character->pos))
                              ;(log/info "Drawing character" (str c) "uvs" (str uvs))
-                             (buffers/draw!
+                             (.bindBuffer gl buffer-object/array-buffer, uvs-buffer)
+                             (.enableVertexAttribArray gl 1)
+                             (.vertexAttribPointer gl 1, 2, data-type/float, false, 0, 0)
+                             (.uniformMatrix4fv gl (.getUniformLocation gl shader-prog, "uMVMatrix"), nil, (get-position-matrix [x y -1.0]))
+                             (.drawArrays gl draw-mode/triangle-strip, 0, 4)
+
+                             #_(buffers/draw!
                                gl
                                :shader shader-prog
                                :draw-mode draw-mode/triangle-strip
@@ -335,13 +344,32 @@
         (refresh [this]
           (.requestAnimationFrame js/window (fn []
             (buffers/clear-color-buffer gl 0.0 0.0 0.0 1.0)
+            (let [uPMatrix (.getUniformLocation gl shader-prog "uPMatrix")
+                  _        (.uniformMatrix4fv gl uPMatrix nil (get-ortho-matrix gl))
+                  _        (.bindBuffer gl buffer-object/array-buffer, square-vertex-buffer)
+                  _        (.enableVertexAttribArray gl 0)
+                  _        (.vertexAttribPointer gl 0, 3, data-type/float, false, 0, 0)
+
+                  _        (.activeTexture gl texture-unit/texture0)
+                  _        (.bindTexture gl texture-target/texture-2d characters-texture)
+                  uSampler (.getUniformLocation gl shader-prog, "uSampler")
+                  _        (.uniform1i gl uSampler, 0)
+                  _        (.disable gl capability/sample-coverage)
+                  _        (.disable gl capability/blend)
+                  _        (.disable gl capability/cull-face)
+                  _        (.disable gl capability/stencil-test)
+                  _        (.enable gl capability/dither)
+                  _        (.disable gl capability/scissor-test)
+                  _        (.disable gl capability/depth-test)
+                  _        (.disable gl capability/polygon-offset-fill)
+                  _        (.disable gl capability/sample-alpha-to-coverage)]
             (doseq [row (range rows)
                     col (range columns)]
               (let [c         (get-in @character-map [row col])
                     x         (long (* col 12))
                     y         (long (* (inc row) 16))
                     highlight (= @cursor-xy [col row])]
-                (draw-character c x (- y 16)))))))
+                (draw-character c x (- y 16))))))))
         (clear [this]
           (let [c (make-terminal-character \space default-fg-color default-bg-color #{})]
           (doseq [row (range rows)


Changed footer

Changed footer

--- src/cljs/todogo_cljs/components.cljs
+++ src/cljs/todogo_cljs/components.cljs
@@ -48,7 +48,7 @@
 (def footer
   [:footer {:class "footer"}
    [:div {:class "container"}
-    [:p {:class "text-muted"} "© 2016 Company, Inc."]]])
+    [:p {:class "text-muted"} "© 2016 TODOGO"]]])

 (defn bread-crumbs [crumbs]


convert frame delays to milliseconds and fix really low delays

--- src/clojure/clj_image2ascii/core.clj
+++ src/clojure/clj_image2ascii/core.clj
@@ -75,13 +75,23 @@
       :color? (if color? true false)   ; forcing an explicit true/false because i am nitpicky like that
       :image  (ImageToAscii/convert final-image color?)})))

+(defn- fix-gif-frame-delay [delay]
+  ; based on the findings here: http://nullsleep.tumblr.com/post/16524517190/animated-gif-minimum-frame-delay-browser-compatibility
+  ; basically, we should not allow any delay less then 0.02s (20ms) because none of the major browsers support it
+  ; and this library is primarily intended for web use, where we want to mimic GIF-like playback (even though we
+  ; won't be held by the same limitations since we will be using javascript for our animation)
+  (let [ms (* delay 10)]
+    (if (< ms 20)
+      20
+      ms)))
+
 (defn- get-ascii-gif-frames [^ImageInputStream image-stream scale-to-width color?]
   (->> (AnimatedGif/read image-stream)
        (mapv
          (fn [^ImageFrame frame]
            (-> (.image frame)
                (convert-image scale-to-width color?)
-               (assoc :delay (.delay frame)))))))
+               (assoc :delay (fix-gif-frame-delay (.delay frame))))))))

 (defn convert-animated-gif-frames
   ([^ImageInputStream image-stream color?]


Fixed capitalization of GitHub in settings page.

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -459,7 +459,7 @@
                                      "Select this option to run builds in our Ubuntu 14.04 (Trusty) container."
                                      "This container is currently in beta."
                                      "Our default container is Ubuntu 12.04 (Precise)."
-                                       [:p [:strong "Please note that you need to trigger a build by pushing commits to Github (instead of rebuilding) to apply the new setting."]]]}))
+                                       [:p [:strong "Please note that you need to trigger a build by pushing commits to GitHub (instead of rebuilding) to apply the new setting."]]]}))
             ]]])))))

 (defn dependencies [project-data owner]


Fix test-raise.

Fix test-raise.

--- test/datomish/test/util.cljc
+++ test/datomish/test/util.cljc
@@ -14,7 +14,8 @@
      (let [caught
            (try
              (do
-               (util/raise "succeed" {})
+               (util/raise "succeed" {:foo 1})
                "fail")
              (catch :default e e))]
-       (is (= "succeed" (aget caught "data"))))))
+       (is (= "succeed" (aget caught "message")))
+       (is (= {:foo 1} (aget caught "data"))))))


Removed back button

Removed back button

--- src/webapp/client/react/components/company_details.cljs
+++ src/webapp/client/react/components/company_details.cljs
@@ -50,12 +50,6 @@
      )
    (dom/div #js {:style #js {:padding-bottom "20px"}} "")

-   (dom/button #js {:onClick
-                    (fn [e]
-                      (om/update! company-details [:clicked]  true))
-                    :style
-                    #js {:margin-top "40px"}}
-                "Back")

    ))


added java additional options

added java additional options

--- src/ctia/task/codegen.clj
+++ src/ctia/task/codegen.clj
@@ -39,7 +39,8 @@
           :gemDescription description
           :gemAuthor "Cisco Security Business Group -- Advanced Threat"
           :gemAuthorEmail "cisco-intel-api-support@cisco.com"}
-   :java {}})
+   :java {:useRxJava true
+          :fullJavaUtil true}})

 (defn spec-uri
   "compose the full path of the swagger spec to generate from"


Use serializable isolation level

Use serializable isolation level

--- src/territory_bro/db/core.clj
+++ src/territory_bro/db/core.clj
@@ -37,9 +37,7 @@

 (defn transactional* [f]
   (conman/with-transaction
-    ; TODO wait for conman >0.2.4
-    ;[t-conn *conn* :isolation :serializable]
-    [t-conn *conn*]
+    [t-conn *conn* :isolation :serializable]
     (f)))

 (defmacro transactional [& body]


Added Freese Layout to GUI

Added Freese Layout to GUI

by now without any kind of angle control.

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

--- src/conexp/contrib/draw/lattices.clj
+++ src/conexp/contrib/draw/lattices.clj
@@ -20,6 +20,7 @@
         [conexp.layouts.util     :only (scale-layout)]
         [conexp.layouts.base     :only (lattice,
                                         annotation)]
+        [conexp.layouts.freese   :only (freese-layout)]
         [conexp.layouts.force    :only (force-layout,
                                         layout-energy,
                                         *repulsive-amount*,
@@ -107,7 +108,8 @@

   ;; layouts
   (let [layouts {"standard" *standard-layout-function*,
-                 "inf-add"  inf-additive-layout},
+                 "inf-add"  inf-additive-layout,
+                 "freese"   freese-layout},
         ^JButton fit (make-button buttons "Fit"),
         ^JComboBox combo-box (make-combo-box buttons (keys layouts))]
     (action-on fit


Remove storytime.

Remove storytime.

--- src/tryclojure/views/home.clj
+++ src/tryclojure/views/home.clj
@@ -36,8 +36,6 @@
       (javascript-tag
        (str "mode = '" mode "';"))]]]))

-(defpage "/storytime" []
-  (repl-html "story" "Storytime"))

 (defpage "/repl" []
   (repl-html "isla" "Try Isla"))


Override meta too.

Override meta too.

--- src/clj/com/draines/postal/core.clj
+++ src/clj/com/draines/postal/core.clj
@@ -23,7 +23,7 @@
                  {:from "foo@lolz.dom"
                   :to "bar@lolz.dom"}
         {:keys [host port from to num delay threads]}
-        (merge (meta defaults) defaults profile)]
+        (merge (meta defaults) defaults (meta profile) profile)]
     (println (format "sent %s msgs to %s:%s"
                      (spam host port from to num delay threads)
                      host port))))


Move gen-page-list-normalize up

Move gen-page-list-normalize up

--- src/clj/comic_reader/sites/util.clj
+++ src/clj/comic_reader/sites/util.clj
@@ -7,15 +7,16 @@
       {:name (process-name name)
        :url (process-url url)})))

+(defn gen-page-list-normalize [base-url fmt-string extract-chapter]
+  (fn [{[name] :content
+        {chapter :value} :attrs}]
+    {:name name
+     :url (format fmt-string
+                  base-url (extract-chapter name))}))
+
 (defn gen-add-key-from-url [key extract-pattern & [process]]
   (let [process (or process identity)]
     (fn [{:keys [url] :as comic-map}]
       (let [[_ data] (re-find extract-pattern url)]
         (assoc comic-map
                key (process data))))))
-
-(defn gen-page-list-normalize [base-url fmt-string extract-chapter]
-  (fn [{{chapter :value} :attrs [name] :content}]
-    {:name name
-     :url (format fmt-string
-                  base-url (extract-chapter name))}))


Suuport old spelling in hyphenation

Suuport old spelling in hyphenation

before it was just pretending to

--- src/clj/hyphen_keeper/hyphenate.clj
+++ src/clj/hyphen_keeper/hyphenate.clj
@@ -3,7 +3,14 @@
             [clojure.string :as string])
   (:import ch.sbs.jhyphen.Hyphenator))

-(def hyphenator (new Hyphenator (io/file "/usr/share/hyphen/hyph_de_DE.dic")))
+(def hyphen-dictionaries
+  {0 "/usr/share/hyphen/hyph_de_DE_OLDSPELL.dic"
+   1 "/usr/share/hyphen/hyph_de_DE.dic"})
+
+(def hyphenators
+  (zipmap
+   (keys hyphen-dictionaries)
+   (map #(new Hyphenator (io/file %)) (vals hyphen-dictionaries))))

 (defn hyphenate
   "Hyphenate the given text by inserting the given `hyphen` char"
@@ -12,4 +19,9 @@
   ([spelling text hyphen]
    (if (string/blank? text)
      ""
-     (.hyphenate hyphenator text hyphen nil))))
+     (let [hyphenator
+           (get hyphenators
+                ;; if a valid spelling was provided use it, otherwise
+                ;; just use new spelling
+                (if (contains? hyphen-dictionaries spelling) spelling 1))]
+       (.hyphenate hyphenator text hyphen nil)))))


Properly handle non-collection types when emitting accumulated data

--- src/cljs/asciinema_player/core.cljs
+++ src/cljs/asciinema_player/core.cljs
@@ -48,24 +48,25 @@
   ([coll] (coll->chan coll (fn [_ v] v) nil))
   ([coll reducer init]
    (let [ch (chan)
-         start (js/Date.)]
+         start (js/Date.)
+         reducer (fnil reducer init)]
      (go
        (loop [coll coll
               virtual-time 0
               wall-time (elapsed-time-since start)
-              acc init]
+              acc nil]
          (if-let [[delay data] (first coll)]
            (let [new-virtual-time (+ virtual-time delay)
                  ahead (- new-virtual-time wall-time)]
              (if (pos? ahead)
                (do
-                 (when-not (empty? acc)
+                 (when-not (nil? acc)
                    (>! ch acc))
                  (<! (timeout (* 1000 ahead)))
                  (>! ch data)
-                 (recur (rest coll) new-virtual-time (elapsed-time-since start) init))
+                 (recur (rest coll) new-virtual-time (elapsed-time-since start) nil))
                (recur (rest coll) new-virtual-time wall-time (reducer acc data)))))
-         (when-not (empty? acc)
+         (when-not (nil? acc)
            (>! ch acc)))
        (close! ch))
      ch)))


Users in atom

Users in atom

--- src/cljs/browser_rotation/core.cljs
+++ src/cljs/browser_rotation/core.cljs
@@ -36,44 +36,38 @@
       ^{:key (k link)}
       [:img {:id i :src (value link) :width 100 :height 100 }]])])

-(defn add-user [users text]
-  (swap! users conj text))
+(defonce users (atom []))

-(defn atom-input [users]
+(defn add-user [text]
+  (let [updated (conj @users text)]
+    (reset! users updated)))
+
+(defn atom-input []
    [:input {:type "text"
             :placeholder "Developer name"
             :on-key-down #(case (.-which %)
-                           13 (add-user users (-> % .-target .-value))) }])
+                           13 (add-user (-> % .-target .-value))
+                           nil) }])

-(defn browser-rotation [users]
+(defn browser-rotation []
   (let [days ["Monday" "Tuesday" "Wednesday" "Thursday" "Friday"]]
-       [users (atom ["Kristoffer"
-                     "Lennart"
-                     "Dennis"
-                     "Victoria"
-                     "Martin"
-                     "Mikael"
-                     "Kalle"])]
-    [:div
-    [atom-input @users]
-    [:table
-     [:tr
-      [:th]
-      (for [day days]
-        ^{:key day} [:th day])
+    [:span
+     [:div
+      [atom-input]]
+     [:div
+      [:table
+       [:tr
+        [:th]
+        (for [day days]
+          ^{:key day} [:th day])]
+
         (map-indexed
           (fn [i user]
-            [browser-cycle user i]) users)]]]))
+            [browser-cycle user i]) @users)]]]))

 (defn home-page []
-  [:div [:h2 "Welcome to browser-rotation"]
-   [:div [:a {:href "#/about"} "go to about page"]]
-   [:h3 "Browser schedule"]
+  [:div [:h2 "Create your own browser rotation schedule"]
    [:div [browser-rotation]]])
-
-(defn about-page []
-  [:div [:h2 "About browser-rotation"]
-   [:div [:a {:href "#/"} "go to the home page"]]])

 (defn current-page []
   [:div [(session/get :current-page)]])
@@ -84,9 +78,6 @@

 (secretary/defroute "/" []
   (session/put! :current-page #'home-page))
-
-(secretary/defroute "/about" []
-  (session/put! :current-page #'about-page))

 ;; -------------------------
 ;; History


Alt with browser name

Alt with browser name

--- src/cljs/browser_rotation/core.cljs
+++ src/cljs/browser_rotation/core.cljs
@@ -45,7 +45,7 @@
    (for [link (browser-links i)]
      [:td
       ^{:key (k link)}
-      [:img {:id i :src (value link) :width 100 :height 100 }]])])
+      [:img {:id i :src (value link) :width 100 :height 100 :alt (k link) }]])])

 (defn add-user [text]
   (let [updated (conj @users text)]


graph-tour:: some neat explanations

graph-tour:: some neat explanations

--- src/clojure_learning/graph_tour.clj
+++ src/clojure_learning/graph_tour.clj
@@ -21,9 +21,27 @@

 ;; if duplicate-vertexes -> false
   ;; if connected-graph
-    ;; if every edge has even-degree -> eulerian
+    ;; if every edge has even-degree -> (zero? (rem (count adjacents) 2)) -> eulerian
       ;; if there's more than 2 edges with odd-degree -> false
         ;; eulerian
+
+;; eulerian::
+;; 1 --- 2
+;; |   / |
+;; |  /  |
+;; | /   |
+;; 3     4 --- 5
+;;
+;; -> 1 {2}, 2 {3}, 4 {2}, 5 {1} --> <= 2 odd edges! OK
+
+;; not eulerian:
+;; 1 --- 2
+;;    / |
+;;   /  |
+;;  /   |
+;; 3    4 --- 5
+
+;; -> 1 {1}, 2 {3}, 3 {1}, 4 {2}, 5 {1} -> odd edges > 2 (is 4)

 (ns clojure-learning.graph-tour
   (use (clojure repl test)))


Add activate flag event for proper flag activation independently of state.

--- src/uxbox/data/workspace.cljs
+++ src/uxbox/data/workspace.cljs
@@ -84,6 +84,17 @@
       (if shape
         (assoc-in state [:workspace :drawing] shape)
         (update-in state [:workspace] dissoc :drawing)))))
+
+;; --- Activate Workspace Flag
+
+(defrecord ActivateFlag [flag]
+  rs/UpdateEvent
+  (-apply-update [_ state]
+    (update-in state [:workspace :flags] conj flag)))
+
+(defn activate-flag
+  [flag]
+  (ActivateFlag. flag))

 ;; --- Copy to Clipboard

@@ -172,7 +183,7 @@
                    :x-axis (:grid/x-axis opts c/grid-x-axis)
                    :y-axis (:grid/y-axis opts c/grid-y-axis)}]
       (->> (uw/send! worker message)
-           (rx/map #(toggle-flag :alignment/indexed))))))
+           (rx/map #(activate-flag :alignment/indexed))))))

 (defn initialize-alignment-index
   [id]


Move shape while other shape is selected (#17)

--- src/uxbox/ui/shapes/icon.cljs
+++ src/uxbox/ui/shapes/icon.cljs
@@ -37,8 +37,10 @@
           (dom/stop-propagation event)
           (if (kbd/shift? event)
             (rs/emit! (uds/select-shape id))
-            (rs/emit! (uds/deselect-all)
-                      (uds/select-shape id))))
+            (do
+              (rs/emit! (uds/deselect-all)
+                        (uds/select-shape id))
+              (uuc/acquire-action! "ui.shape.move"))))

         :else
         (do


Problem added - "Analyzing a Tic-Tac-Toe Board"

--- src/foreclojure/data_set.clj
+++ src/foreclojure/data_set.clj
@@ -751,9 +751,23 @@
            :description "The ->> macro threads an expression x through a variable number of forms. First, x is inserted as the last item in the first form, making a list of it if it is not a list already.  Then the first form is inserted as the last item in the second form, making a list of that form if necessary.  This process continues for all the forms.  Using ->> can sometimes make your code more readable."
            :tags ["elementary"]
            :tests ["(= (__ (map inc (take 3 (drop 2 [2 5 4 1 3 6]))))\n   (->> [2 5 4 1 3 6] (drop 2) (take 3) (map inc) (__))\n   11)"]})
+
+(insert! :problems
+          {:_id 73
+           :title "Analyze a Tic-Tac-Toe Board"
+           :times-solved 0
+           :description "A tic-tac-toe board is represented by a two dimensional vector. X is represented by :x, O is represented by :o, and empty is represented by :e.  A player wins by placing three Xs or three Os in a horizontal, vertical, or diagonal row.  Write a function which analyzes a tic-tac-toe board and returns :x if X has won, :o if O has won, and :e if neither player has won."
+           :tags ["medium" "game"]
+           :tests ["(= :e (__ [[:e :e :e]\n           [:e :e :e]\n           [:e :e :e]]))"
+		   "(= :x (__ [[:x :e :o]\n           [:x :e :e]\n           [:x :e :o]]))"
+		   "(= :o (__ [[:e :x :e]\n           [:o :o :o]\n           [:x :e :x]]))"
+		   "(= :e (__ [[:x :e :o]\n           [:x :x :e]\n           [:o :x :o]]))"
+		   "(= :x (__ [[:x :e :e]\n           [:o :x :e]\n           [:o :e :x]]))"
+		   "(= :o (__ [[:x :e :o]\n           [:x :o :e]\n           [:o :e :x]]))"
+		   "(= :e (__ [[:x :o :x]\n           [:x :o :x]\n           [:o :x :o]]))"]})

       (insert! :problems
-           {:_id 73
+           {:_id 74
             :title "Power Set"
             :times-solved 0
             :description "A power set is the set of all subsets of a given set. Given a list, produce a set of sublists while preserving the order of elements."


show 'opt-in' screen to recovery

show 'opt-in' screen to recovery

Signed-off-by: Andrey Shovkoplyas <b713972e59b8e606e23253c4a13e948139fea4d1@gmail.com>

--- src/status_im/ui/screens/accounts/recover/events.cljs
+++ src/status_im/ui/screens/accounts/recover/events.cljs
@@ -47,7 +47,8 @@
       (when-not (string/blank? public-key)
         (-> db
             (accounts-events/add-account account)
-            (assoc :dispatch [:login-account address password]))))))
+            (assoc :dispatch [:login-account address password])
+            (assoc :dispatch-later [{:ms 2000 :dispatch [:navigate-to :usage-data]}]))))))

 (handlers/register-handler-fx
   :recover-account


find-by-id method is added to crud protocol

--- src/clj/modern_cljs/repository/newsrepository.clj
+++ src/clj/modern_cljs/repository/newsrepository.clj
@@ -6,18 +6,19 @@
 (defrecord News [id, title, short-text, full-text, creation-date])

 (defprotocol CrudRepository
-  (find-all [x])
-  (find-by-id [id]))
+  (find-all [this])
+  (find-by-id [this id]))

 (defrecord NewsRepositoryComponent [dbconfig]
   CrudRepository
-  (find-all [x]
+  (find-by-id [this id]
+    (let [news-items (sql/query dbconfig ["select * from news where news_id = ?" id])]
+      (for [news news-items]
+        (->News (news :news_id) (news :title) (news :short_text) (news :full_text) (news :creation_date)))))
+  (find-all [this]
     (let [news-list (sql/query dbconfig ["SELECT * FROM news"])]
       (for [news news-list]
-        (->News (news :news_id) (news :title) (news :short_text) (news :full_text) (news :creation_date)))))
-  (find-by-id [id]
-    ("abc"))
-  )
+        (->News (news :news_id) (news :title) (news :short_text) (news :full_text) (news :creation_date))))))

 ;instance of news repo
 (def news-repo-component (NewsRepositoryComponent. dbconfig/mysql-db))
@@ -26,6 +27,10 @@
   (let [news-list (find-all news-repo-component)]
     (for [news news-list]
       (println news))))
+
+(defn news-repo-find-by-id-example [id]
+  (let [news (find-by-id news-repo-component id)]
+    (println news)))

 (defn load-all-news []
   (sql/query dbconfig/mysql-db ["SELECT * FROM news"]


supporting replicas, labels, update_config, restart_policy

#226

--- src/clj/swarmpit/docker/engine/mapper/compose.clj
+++ src/clj/swarmpit/docker/engine/mapper/compose.clj
@@ -23,34 +23,52 @@
        (map #(fn stack-name %))
        (into {})))

-(defn environment
+(defn variables
   [variables]
   (map #(str (:name %) "=" (:value %)) variables))
-
-(defn service-volumes
-  [mounts]
-  (map #(str (:host %) "=" (:containerPath %) (when (:readOnly %) ":ro")) mounts))

 (defn resource
   [{:keys [cpu memory]}]
   {:cpus   (when (< 0 cpu) (str cpu))
    :memory (when (< 0 memory) (str memory "M"))})

+(defn remove-defaults
+  [map defaults]
+  (->> (keys defaults)
+       (filter #(= (% defaults) (% map)))
+       (apply dissoc map)))
+
 (defn service
   [stack-name service]
   {(keyword (alias :serviceName stack-name service))
    {:image       (-> service :repository :image)
-    :environment (->> service :variables
-                      (map #(str (:name %) "=" (:value %))))
+    :environment (-> service :variables (variables))
     :ports       (->> service :ports
                       (map #(str (:hostPort %) ":" (:containerPort %) (when (= "udp" (:protocol %)) "/udp"))))
     :volumes     (->> service :mounts
                       (map #(str (alias :host stack-name %) "=" (:containerPath %) (when (:readOnly %) ":ro"))))
     :networks    (->> service :networks (map #(alias :networkName stack-name %)))
-    :deploy      {:mode      (when-not (= "replicated" (:mode service)) (:mode service))
-                  :placement {:constraints (->> service :deployment :placement (map :rule))}
-                  :resources {:reservations (-> service :resources :reservation resource)
-                              :limits       (-> service :resources :limit resource)}}}})
+    :deploy      {:mode           (when-not (= "replicated" (:mode service)) (:mode service))
+                  :replicas       (some-> (:replicas service) (#(when (< 1 %) %)))
+                  :labels         (-> service :labels (variables))
+                  :update_config  (-> service :deployment :update
+                                      (rename-keys {:failureAction :failure_action})
+                                      (update :delay #(str % "s"))
+                                      (remove-defaults
+                                        {:parallelism    1
+                                         :delay          "0s"
+                                         :order          "stop-first"
+                                         :failure_action "pause"}))
+                  :restart_policy (-> service :deployment :restartPolicy
+                                      (rename-keys {:attempts :max_attempts})
+                                      (update :delay #(str % "s"))
+                                      (remove-defaults
+                                        {:condition    "any"
+                                         :delay        "5s"
+                                         :max_attempts 0}))
+                  :placement      {:constraints (->> service :deployment :placement (map :rule))}
+                  :resources      {:reservations (-> service :resources :reservation resource)
+                                   :limits       (-> service :resources :limit resource)}}}})

 (defn network
   [stack-name net]


Fixed error in Pagie Hogeweg problem form move to Plush

--- src/clojush/problems/regression/pagie_hogeweg.clj
+++ src/clojush/problems/regression/pagie_hogeweg.clj
@@ -1,14 +1,14 @@
-; pagie_hogeweg_no_erc.clj
+; pagie_hogeweg.clj
 ;
 ; The Pagie-Hogeweg problem without a float ERC; instead, just
 ; uses the constant 1.0 as an atom generator.

 (ns clojush.problems.regression.pagie-hogeweg
   (:use clojush.pushgp.pushgp)
-  (:require clojush.examples.pagie-hogeweg))
+  (:require clojush.problems.regression.pagie-hogeweg-with-erc))

 (def argmap
-  (merge clojush.examples.pagie-hogeweg/argmap
+  (merge clojush.problems.regression.pagie-hogeweg-with-erc/argmap
          {:atom-generators (list 1.0
                                  'x
                                  'y


Fixing problem with starting embedded elasticsearch server.

--- src/cmr/elastic_utils/embedded_elastic_server.clj
+++ src/cmr/elastic_utils/embedded_elastic_server.clj
@@ -32,7 +32,7 @@
   [{:keys [http-port transport-port data-dir]}]
   (.. (ImmutableSettings/settingsBuilder)
       (put "node.name" "embedded-elastic")
-      (put "path.conf" "resources")
+      (put "path.conf" ".")
       (put "path.data" data-dir)
       (put "http.port" (str http-port))
       (put "transport.tcp.port" (str transport-port))


more comments

more comments

--- dada-demo/src/main/clojure/org/dada/demo/whales.clj
+++ dada-demo/src/main/clojure/org/dada/demo/whales.clj
@@ -496,3 +496,5 @@
 ;; - djoin
 ;; - dpivot
 ;; - fix remaining broken queries
+;; - fix exception on client shutdown
+;; - fix occasional npe on executing summarised sum weight split ocean


[#431] Small backend code cleanups

[#431] Small backend code cleanups

--- backend/src/akvo/lumen/lib/aggregation/pie.clj
+++ backend/src/akvo/lumen/lib/aggregation/pie.clj
@@ -4,22 +4,21 @@
             [akvo.lumen.lib.aggregation.utils :as utils]
             [clojure.java.jdbc :as jdbc]))

-(defn run-query [tenant-conn table-name column-name filter-sql]
+(defn- run-query [tenant-conn table-name column-name filter-sql]
   (rest (jdbc/query tenant-conn
-                    [(format "SELECT %s, count(*) FROM %s WHERE %s GROUP BY %s"
-                             column-name table-name filter-sql column-name)]
+                    [(format "SELECT %1$s, count(*) FROM %2$s WHERE %3$s GROUP BY %1$s"
+                             column-name table-name filter-sql)]
                     {:as-arrays? true})) )

-(defn query [tenant-conn dataset query]
-  (let [columns (:columns dataset)
-        filter-sql (filter/sql-str (:columns dataset) (get query "filters"))
+(defn query
+  [tenant-conn {:keys [columns table-name]} query]
+  (let [filter-sql (filter/sql-str columns (get query "filters"))
         bucket-column (utils/find-column columns (get query "bucketColumn"))
         bucket-column-name (get bucket-column "columnName")
         bucket-column-title (get bucket-column "title")
-        table-name (:table-name dataset)
         counts (run-query tenant-conn table-name bucket-column-name filter-sql)]
     (http/ok {"metadata" {"bucketColumnTitle" bucket-column-title}
               "data" (mapv (fn [[bucket-value bucket-count]]
                              {"bucketValue" bucket-value
                               "bucketCount" bucket-count})
-                           counts)})) )
+                           counts)})))


properly serialize keywords/symbols/vars

fix a few coding mistakes in custom error handlers

--- src/yeller/clojure/client.clj
+++ src/yeller/clojure/client.clj
@@ -1,34 +1,42 @@
 (ns yeller.clojure.client
   (:require [clojure.walk :refer [stringify-keys]]
             [clojure.edn :as edn]
-            [clojure.java.io :as io])
+            [clojure.java.io :as io]
+            wall.hack)
   (:import (com.yellerapp.client
              YellerHTTPClient
              YellerClient
              YellerExtraDetail
-             YellerErrorHandler)))
+             YellerErrorHandler)
+           (com.fasterxml.jackson.databind
+             JsonSerializer
+             ObjectMapper
+             module.SimpleModule)
+           (com.fasterxml.jackson.core Version)))

 (def client-version "yeller-clojure-client: 1.2.1")

 (defn default-io-error-handler [backend error]
-  (.println *err* (str "Yeller: an io error ocurred whilst talking to yeller: " error)))
+  (.println *err* (str "Yeller: an io error ocurred whilst talking to yeller: "))
+  (.printStackTrace error *err*))

 (defn default-auth-error-handler [backend error]
-  (.println *err* (str "Yeller: an authentication error ocurred whilst talking to yeller: " error)))
+  (.println *err* (str "Yeller: an authentication error ocurred whilst talking to yeller: " error))
+  (.printStackTrace error *err*))

 (defn set-error-handlers! [client options]
-  (if (or (:io-error-handler options)
-          (:auth-error-handler options))
-    (.setErrorHandler
-      client
-      (reify
-        YellerErrorHandler
-        (reportAuthError [this backend e]
-          ((:auth-error-handler options default-auth-error-handler)
-             backend e))
-        (reportIOError [this backend e]
-          ((:auth-io-handler options default-io-error-handler)
-             backend e))))))
+  (if (or (:auth-error-handler options)
+          (:io-error-handler options))
+    (let [auth (:auth-error-handler options default-auth-error-handler)
+          io (:io-error-handler options default-io-error-handler)]
+      (.setErrorHandler
+        client
+        (reify
+          YellerErrorHandler
+          (reportAuthError [this backend e]
+            (auth backend e))
+          (reportIOError [this backend e]
+            (io backend e)))))))

 (defn- ^"[Ljava.lang.String;" make-endpoint-array
   "turns a seq of endpoints into
@@ -91,6 +99,31 @@
   (if (:application-packages options)
     (.setApplicationPackages client (make-app-package-array (:application-packages options)))
     (.setApplicationPackages client (make-app-package-array (default-application-packages)))))
+
+(def named-serializer
+  (proxy [JsonSerializer] []
+    (serialize [named generator provider]
+      (if (namespace named)
+        (.writeString generator (str (namespace named) "/" (name named)))
+        (.writeString generator (name named))))))
+
+(def var-serializer
+  (proxy [JsonSerializer] []
+    (serialize [v generator provider]
+      (if-let [n (:ns (meta v))]
+        (.writeString generator (str n "/" (:name (meta v))))
+        (.writeString generator (:name (meta v)))))))
+
+(defn ^ObjectMapper object-mapper
+  "a Jackson ObjectMapper that serializes symbols, keywords and vars 'correctly'"
+  []
+  (let [mapper (ObjectMapper.)
+        module (SimpleModule.)]
+   (.addSerializer module clojure.lang.Keyword named-serializer)
+   (.addSerializer module clojure.lang.Var var-serializer)
+   (.addSerializer module clojure.lang.Symbol named-serializer)
+   (.registerModule mapper module)
+    mapper))

 (defn ^YellerClient client
   "Creates a new client from a map of configuration settings. Required settings:
@@ -118,6 +151,7 @@
   (assert (and (sequential? (:application-packages options []))
             (every? string? (:application-packages options []))) (str "Yeller :application-packages must be a sequential collection of strings."))
   (let [client (YellerHTTPClient. (:token options))]
+    (.withObjectMapper client (object-mapper))
     (set-error-handlers! client options)
     (set-urls! client options)
     (set-debug! client options)


Bugfix - logic inversion

Bugfix - logic inversion

--- src/grimoire/api/fs/read.clj
+++ src/grimoire/api/fs/read.clj
@@ -98,7 +98,7 @@

 (defmethod api/-list-notes ::fs/Config [config thing]
   {:pre [(t/thing? thing)]}
-  (if-not (t/versioned? thing)
+  (if (t/versioned? thing)
     (let [versions (api/thing->prior-versions config thing)]
       (if (succeed? versions)
         (succeed


remove duplication action of data accessor

--- src_patient/patient/subs.cljs
+++ src_patient/patient/subs.cljs
@@ -33,9 +33,7 @@
          data-key (get-data-key remote-data)
          practs (->> (get remote-data data-key)
                      vals
-                     (map :resource)
-                     (filter #((set gen-pract-ids) (:id %)))
-                     )]
+                     #_(filter #((set gen-pract-ids) (:id %))))]
      (if (= (:status remote-data) :succeed)
        (assoc remote-data data-key practs)
        remote-data)


Fix small bug in uri template parsing

Fix small bug in uri template parsing

When there were no more variables in the string,
the eventual piece of string left after that got discarded,
while it should be instead attached at the end of the arguments
vector.

--- src/gogolica/generate.clj
+++ src/gogolica/generate.clj
@@ -93,11 +93,10 @@
               (recur (concat result-acc [pre (get args->symbols arg)])
                      post
                      (rest matches)))
-            result-acc))]
-    ;; When path template does not have vars to substitute, shortcircuit
-    (if (seq matches)
-      (template->path-vector' [] path-template matches)
-      (list path-template))))
+            (if template ;; we have no matches anymore, but there might be some string still
+              (concat result-acc [template])
+              result-acc)))]
+    (template->path-vector' [] path-template matches)))

 (defn generate-path
   [template-uri parameters]


Put loading overlay on page stack

Put loading overlay on page stack

--- src/home/cljs/virt/home.cljs
+++ src/home/cljs/virt/home.cljs
@@ -39,6 +39,12 @@
                              :onClick #(put! comm [:navigate [:new]])}
                         "New")))))))

+(defn loading [_ _]
+  (reify
+    om/IRender
+    (render [_]
+      (dom/div #js {:id "loading"} "Loading..."))))
+
 (defn list-item [channel owner]
   (reify
     om/IRenderState
@@ -73,30 +79,28 @@
   (reify
     om/IInitState
     (init-state [_]
-      {:comm (chan)
-       :show-loading true})
+      {:comm (chan)})
     om/IWillMount
     (will-mount [_]
-      (om/set-state! owner :show-loading true)
       (let [nav-chan (listen-navigation)]
         (go (while true
           (om/update! app [:page-stack] (path-to-stack routes (<! nav-chan))))))
-      (let [comm
-            (om/get-state owner :comm)
-            channels-loading
-            (go
-              (let [loc (<! (get-geolocation))]
-                (om/update! app [:geolocation] loc)
-                (let [response (<! (http/get "/api/channels" {:query-params loc}))]
-                  (om/update! app [:channels] (:body response))
-                  (om/set-state! owner :show-loading false))))
-            apps-loading
-            (go
-              (let [response (<! (http/get "/api/apps"))]
-                (om/update! app [:apps] (:body response))))]
+      (let [comm (om/get-state owner :comm)]
         (go
-          ; Wait for data to load before registering callbacks
-          (<! (async/merge [channels-loading apps-loading]))
+          ; Load channels and apps in parallel (mostly for illustration purposes for now)
+          (let [channels-loading
+                (go
+                  (let [loc (<! (get-geolocation))]
+                    (om/update! app [:geolocation] loc)
+                    (let [response (<! (http/get "/api/channels" {:query-params loc}))]
+                      (om/update! app [:channels] (:body response)))))
+                apps-loading
+                (go
+                  (let [response (<! (http/get "/api/apps"))]
+                    (om/update! app [:apps] (:body response))))]
+            ; Wait for data to load before continuing
+            (while (some? (<! (async/merge [channels-loading apps-loading]))))
+            (om/transact! app [:page-stack] #(pop %)))
           (while true
             (let [[msg data] (<! comm)]
               (case msg
@@ -131,16 +135,16 @@
                :opts params}]
         (dom/div nil
           (dom/div #js {:id "header"}
-            (om/build header app (assoc m :state {:show-back-button (not= page :home)
+            (om/build header app (assoc m :state {:show-back-button (= page :new)
                                                   :show-new-button (= page :home)})))
           (dom/div #js {:id "content"}
-            (if (om/get-state owner :show-loading)
-              (dom/div #js {:id "loading"} "Waiting for location...")
-              (case page
-                :new (om/build new-channel nil m)
-                :home (om/build channel-list (:channels app) m)))))))))
+            (case page
+              :loading (om/build loading nil)
+              :new (om/build new-channel nil m)
+              :home (om/build channel-list (:channels app) m))))))))

-(let [stack (path-to-stack routes (.. js/document -location -pathname))
+(let [page-stack (path-to-stack routes (.. js/document -location -pathname))
+      stack (conj page-stack [:loading nil])
       [_ home-params] (stack 0)]
   (swap! app-state assoc :page-stack stack)
   (om/root main app-state {:target (.getElementById js/document "app")


Additional test added into format_date_test module

--- test/zg/format_date_test.clj
+++ test/zg/format_date_test.clj
@@ -47,7 +47,8 @@
     (testing "the function zg.format-date/format-date."
         (let [date (new java.util.Date 116 01 01 12 00)]
             (is (not (nil? (format-date date))))
-            (is (= (type (format-date date)) java.lang.String)))))
+            (is (= (type (format-date date)) java.lang.String))
+            (is (= (count (format-date date)) 19)))))

 (deftest test-format-date-2
     "Check the function zg.format-date/format-date"
@@ -59,3 +60,10 @@
         (let [date (new java.util.Date 0 00 01 00 00)]
             (is (= "1900-01-01 00:00:00" (format-date date))))))

+(deftest test-format-current-date
+    "Check the function zg.format-date/format-current-date"
+    (testing "the function zg.format-date/format-current-date."
+        (is (not (nil? (format-current-date))))
+        (is (= (type (format-current-date))))
+        (is (= (count (format-current-date)) 19))))
+


Tests now use master-settings instead of ssl-paths

--- test/puppetlabs/master/certificate_authority_test.clj
+++ test/puppetlabs/master/certificate_authority_test.clj
@@ -283,7 +283,8 @@
                        :hostcert    (str ssldir "/certs/master.pem")
                        :localcacert (str ssldir "/certs/ca.pem")
                        :hostprivkey (str ssldir "/private_keys/master.pem")
-                       :hostpubkey  (str ssldir "/public_keys/master.pem")}
+                       :hostpubkey  (str ssldir "/public_keys/master.pem")
+                       :dns-alt-names ""}
       ssldir-contents (settings->master-dir-paths master-settings)]

   (deftest initialize-ca!-test
@@ -321,7 +322,7 @@
   (deftest initialize-master!-test
     (let [serial-number-file (temp-serial-number-file)]
       (try
-        (initialize-master! ssldir-contents "master" "Puppet CA: localhost"
+        (initialize-master! master-settings "master" "Puppet CA: localhost"
                             (utils/pem->private-key cakey)
                             (utils/pem->cert cacert)
                             512
@@ -395,7 +396,7 @@
   (deftest initialize!-test
     (testing "Generated SSL file"
       (try
-        (initialize! ca-settings ssldir-contents "master" 512)
+        (initialize! ca-settings master-settings "master" 512)
         (doseq [file (concat (vals cadir-contents) (vals ssldir-contents))]
           (testing file
             (is (fs/exists? file))))
@@ -413,7 +414,7 @@
           (doseq [file no-dirs]
             (spit file "unused content"))

-          (initialize! ca-settings ssldir-contents "master" 512)
+          (initialize! ca-settings master-settings "master" 512)

           (doseq [file no-dirs]
             (is (= "unused content" (slurp file))
@@ -424,10 +425,10 @@
     (testing "Keylength"
       (doseq [[message f expected]
               [["can be configured"
-                (partial initialize! ca-settings ssldir-contents "master" 512)
+                (partial initialize! ca-settings master-settings "master" 512)
                 512]
                ["has a default value"
-                (partial initialize! ca-settings ssldir-contents "master")
+                (partial initialize! ca-settings master-settings "master")
                 utils/default-key-length]]]
         (testing message
           (try


Add generators for symbols, namespaced symbols,

and namespaced keywords. Also improve the generation of keywords to
include : characters, which are allowed by the spec.

Signed-off-by: Reid Draper <1f4d9895740d1b07c3b2f21f4b03e23d1086f158@gmail.com>

--- src/main/clojure/clojure/test/check/generators.clj
+++ src/main/clojure/clojure/test/check/generators.clj
@@ -11,7 +11,7 @@
   (:import java.util.Random)
   (:refer-clojure :exclude [int vector list hash-map map keyword
                             char boolean byte bytes sequence
-                            not-empty])
+                            not-empty symbol namespace])
   (:require [clojure.core :as core]
             [clojure.test.check.rose-tree :as rose]))

@@ -479,10 +479,74 @@
   "Generate alpha-numeric strings."
   (fmap clojure.string/join (vector char-alpha-numeric)))

+(defn- +-or---digit?
+  "Returns true if c is \\+ or \\- and d is non-nil and a digit.
+
+  Symbols that start with +3 or -2 are not readable because they look
+  like numbers."
+  [c ^Character d]
+  (core/boolean (and d
+                     (or (= \+ c)
+                         (= \- c))
+                     (Character/isDigit d))))
+
+(def namespace-segment
+  "Generate the segment of a namespace."
+  (->> (tuple char-keyword-first (vector char-keyword-rest))
+       (such-that (fn [[c [d]]] (not (+-or---digit? c d))))
+       (fmap (fn [[c cs]] (clojure.string/join (cons c cs))))))
+
+(def namespace
+  "Generate a namespace (or nil for no namespace)."
+  (->> (vector namespace-segment)
+       (fmap (fn [v] (when (seq v)
+                       (clojure.string/join "." v))))))
+
+(def keyword-segment-rest
+  "Generate segments of a keyword (between \\:)"
+  (->> (tuple char-keyword-rest (vector char-keyword-rest))
+       (fmap (fn [[c cs]] (clojure.string/join (cons c cs))))))
+
+(def keyword-segment-first
+  "Generate segments of a keyword that can be first (between \\:)"
+  (->> (tuple char-keyword-first (vector char-keyword-rest))
+       (fmap (fn [[c cs]] (clojure.string/join (cons c cs))))))
+
 (def keyword
-  "Generate keywords."
-  (->> (tuple char-keyword-first (vector char-keyword-rest))
-       (fmap (fn [[c cs]] (core/keyword (clojure.string/join (cons c cs)))))))
+  "Generate keywords without namespaces."
+  (->> (tuple keyword-segment-first (vector keyword-segment-rest))
+       (fmap (fn [[c cs]]
+               (core/keyword (clojure.string/join ":" (cons c cs)))))))
+
+(def keyword-ns
+  "Generate keywords with optional namespaces."
+  (->> (tuple namespace char-keyword-first (vector char-keyword-rest))
+       (fmap (fn [[ns c cs]]
+               (core/keyword ns (clojure.string/join (cons c cs)))))))
+
+(def char-symbol-first
+  (frequency [[10 char-alpha]
+              [5 char-symbol-special]
+              [1 (return \.)]]))
+
+(def char-symbol-rest
+  (frequency [[10 char-alpha-numeric]
+              [5 char-symbol-special]
+              [1 (return \.)]]))
+
+(def symbol
+  "Generate symbols without namespaces."
+  (frequency [[100 (->> (tuple char-symbol-first (vector char-symbol-rest))
+                        (such-that (fn [[c [d]]] (not (+-or---digit? c d))))
+                        (fmap (fn [[c cs]] (core/symbol (clojure.string/join (cons c cs))))))]
+              [1 (return '/)]]))
+
+(def symbol-ns
+  "Generate symbols with optional namespaces."
+  (frequency [[100 (->> (tuple namespace char-symbol-first (vector char-symbol-rest))
+                        (such-that (fn [[_ c [d]]] (not (+-or---digit? c d))))
+                        (fmap (fn [[ns c cs]] (core/symbol ns (clojure.string/join (cons c cs))))))]
+              [1 (return '/)]]))

 (def ratio
   "Generates a `clojure.lang.Ratio`. Shrinks toward 0. Not all values generated
@@ -493,10 +557,10 @@
            (such-that (complement zero?) int))))

 (def simple-type
-  (one-of [int char string ratio boolean keyword]))
+  (one-of [int char string ratio boolean keyword keyword-ns symbol symbol-ns]))

 (def simple-type-printable
-  (one-of [int char-ascii string-ascii ratio boolean keyword]))
+  (one-of [int char-ascii string-ascii ratio boolean keyword keyword-ns symbol symbol-ns]))

 (defn container-type
   [inner-type]


Don't catch ThreadDeath inside of a test

ThreadDeath should not be caught and continued, so we simply re-raise
the exception if a ThreadDeath exception is raised inside of a test.

--- src/main/clojure/clojure/test/check/properties.clj
+++ src/main/clojure/clojure/test/check/properties.clj
@@ -13,7 +13,9 @@
 (defn- apply-gen
   [function]
   (fn [args]
-    (let [result (try (apply function args) (catch Throwable t t))]
+    (let [result (try (apply function args)
+                   (catch java.lang.ThreadDeath t (throw t))
+                   (catch Throwable t t))]
       {:result result
        :function function
        :args args})))


FIX #17

FIX #17

--- resources/leiningen/new/closp/clj/routes/user.clj
+++ resources/leiningen/new/closp/clj/routes/user.clj
@@ -44,8 +44,9 @@
   (not (vali/errors? :id :pass :confirm :captcha)))

 (defn admin-page [params locale tconfig]
-  (let [users (cjmp/trace "all users" (db/get-all-users (get params :filter)))]
-    (layout/render "user/admin.html" (merge {:users       users :roles auth/available-roles
+  (let [users (cjmp/trace "all users" (db/get-all-users (get params :filter)))
+        users-cleaned (map #(assoc % :is_active (if (or (= (:is_active %) false) (= (:is_active %) 0)) false true)) users)]
+    (layout/render "user/admin.html" (merge {:users       users-cleaned :roles auth/available-roles
                                              :admin_title (t locale tconfig :admin/title)}
                                             params))))

@@ -82,7 +83,7 @@
     (if-let [user (db/get-user-by-email username)]
       (try
         (cond
-          (= false (:is_active user)) (login-page {:error :user/activate_account})
+          (or (= 0 (:is_active user)) (= false (:is_active user))) {:error (t locale tconfig :user/activate_account)}
           (= false (hashers/check password (get user :pass ""))) (login-page
                                                                    {:error (t locale tconfig :user/pass_correct)})
           :else (do (sess/put! :role (:role user)) (sess/put! :identity username)


delaney.clj: refactored (extract ...) and renamed it to (pair ...)

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -233,10 +233,11 @@
 (defn- parse-number-lists [str]
   (map parse-numbers (-> str s/trim (s/split #","))))

-(defn- extract [data free]
-  (let [step (fn [[_ free] val]
-               [[(first free), val] (disj free (first free) val)])]
-    (rest (map first (reductions step [nil (into #{} free)] data)))))
+(defn- pairs [data free]
+  (when (seq free)
+    (let [pair [(first free) (first data)]
+          rest-free (filter (comp not (set pair)) free)]
+      (lazy-seq (cons pair (pairs (rest data) rest-free))))))

 (defmethod dsymbol String [code]
   (let [parts (-> code s/trim
@@ -249,7 +250,7 @@
         d-set (reduce (fn [sym i]
                         (reduce (fn [ds [D E]] (glue ds i D E))
                                 sym
-                                (extract (nth gluings i) (range 1 (inc size)))))
+                                (pairs (nth gluings i) (range 1 (inc size)))))
                       (DSymbol. 0 0 {} {})
                       (range 0 (inc dim)))
         d-sym (reduce (fn [sym i]


Improves logging when we stop launching synthetic pods (#1663)

--- scheduler/src/cook/kubernetes/compute_cluster.clj
+++ scheduler/src/cook/kubernetes/compute_cluster.clj
@@ -424,15 +424,31 @@
               total-nodes (-> @current-nodes-atom keys count)
               {:keys [image user command max-pods-outstanding max-total-pods max-total-nodes]
                :or {command "exit 0" max-total-pods 32000 max-total-nodes 1000}} synthetic-pods-config]
-          (log/info "In" name "compute cluster there are" total-pods "pods and" total-nodes
-                    "nodes of a max of" max-total-pods "pods and" max-total-nodes "nodes")
-          (log/info "In" name "compute cluster, for pool" pool-name "there are" num-synthetic-pods
-                    "outstanding synthetic pod(s), and a max of" max-pods-outstanding "are allowed")
+
+          (when (>= total-pods max-total-pods)
+            (log/warn "In" name "compute cluster, total pods are maxed out"
+                      {:max-total-pods max-total-pods
+                       :total-pods total-pods}))
+          (when (>= total-nodes max-total-nodes)
+            (log/warn "In" name "compute cluster, nodes are maxed out"
+                      {:max-total-nodes max-total-nodes
+                       :total-nodes total-nodes}))
+          (when (>= num-synthetic-pods max-pods-outstanding)
+            (log/warn "In" name "compute cluster, synthetic pods are maxed out"
+                      {:max-synthetic-pods max-pods-outstanding
+                       :synthetic-pods num-synthetic-pods}))
+
           (let [max-launchable (min (- max-pods-outstanding num-synthetic-pods)
                                     (- max-total-nodes total-nodes)
                                     (- max-total-pods total-pods))]
             (if (not (pos? max-launchable))
-              (log/info "In" name "compute cluster, cannot launch more synthetic pods")
+              (log/warn "In" name "compute cluster, cannot launch more synthetic pods"
+                        {:max-synthetic-pods max-pods-outstanding
+                         :max-total-nodes max-total-nodes
+                         :max-total-pods max-total-pods
+                         :synthetic-pods num-synthetic-pods
+                         :total-nodes total-nodes
+                         :total-pods total-pods})
               (let [using-pools? (config/default-pool)
                     synthetic-task-pool-name (when using-pools? pool-name)
                     new-jobs (remove (fn [{:keys [job/uuid]}]


(SERVER-1142) Wrap entire clojure subtree with clojure-handler

Previously each clojure handler was wrapped with the
clojure-request-wrapper. This had the unfortunate consequence that we
could easily add a new clojure route in the future and forget to wrap it
with authentication or parameter parsing. This commit adds a call to
wrap-routes to wrap the entire clojure subtree with both authentication
and parameter parsing to avoid that.

--- src/clj/puppetlabs/services/master/master_core.clj
+++ src/clj/puppetlabs/services/master/master_core.clj
@@ -406,13 +406,12 @@
 (schema/defn ^:always-validate
   v3-clojure-routes :- bidi-schema/RoutePair
   "v3 route tree for the clojure side of the master service."
-  [clojure-request-wrapper :- IFn
-   jruby-service :- (schema/protocol jruby-protocol/JRubyPuppetService)
+  [jruby-service :- (schema/protocol jruby-protocol/JRubyPuppetService)
    get-code-content-fn :- IFn]
   (let [environment-class-handler
-        (clojure-request-wrapper (environment-class-handler jruby-service))
+        (environment-class-handler jruby-service)
         static-file-content-handler
-        (clojure-request-wrapper (static-file-content-request-handler get-code-content-fn))]
+        (static-file-content-request-handler get-code-content-fn)]
     (comidi/routes
      (comidi/GET ["/environment_classes" [#".*" :rest]] request
                  (environment-class-handler request))
@@ -430,7 +429,9 @@
    get-code-content-fn :- IFn]
   (comidi/context "/v3"
                   (v3-ruby-routes ruby-request-handler)
-                  (v3-clojure-routes clojure-request-wrapper jruby-service get-code-content-fn)))
+                  (comidi/wrap-routes
+                   (v3-clojure-routes jruby-service get-code-content-fn)
+                   clojure-request-wrapper )))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Lifecycle Helper Functions


typos fixed

typos fixed

--- src/cljc/matthiasn/systems_toolbox_sente/mock.cljc
+++ src/cljc/matthiasn/systems_toolbox_sente/mock.cljc
@@ -22,7 +22,7 @@
                    :sente-mock-out-chan (chan)})}))

 (defn all-msgs-handler
-  "Handler all incoming messages. Reformats message into a map with the metadata stored separately
+  "Handler for all incoming messages. Reformats message into a map with the metadata stored separately
   as it would otherwise not survive the EDN/Transit serialization when the message is sent over the
   WebSocket connection. Here, the same is done so the communication has the comparable property
   of only containing EDN-serializable data. :sente-uid is assigned to message metadata from "
@@ -44,11 +44,10 @@
    :opts             cfg})

 (defn connect-sente-mocks
-  "Connects two sente mock components with each other. As of now, it's a 1-on-1 relationship,
-  so there's no special configuration such as assign :sente-uid assignirequired."
+  "Connects two sente mock components with each other. As of now, it's a 1-on-1 relationship."
   {:added "0.5.4"}
   [cmp-1 cmp-2]
   (let [cmp-1-state @(:cmp-state cmp-1)
         cmp-2-state @(:cmp-state cmp-2)]
     (pipe (:sente-mock-out-chan cmp-1-state) (:sente-mock-in-chan cmp-2-state))
-    (pipe (:sente-mock-out-chan cmp-2-state) (:sente-mock-in-chan cmp-1-state))))+    (pipe (:sente-mock-out-chan cmp-2-state) (:sente-mock-in-chan cmp-1-state))))


Delete access token cookie when it is invalid

--- src/cljs/org/broadinstitute/firecloud_ui/main.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/main.cljs
@@ -312,7 +312,8 @@
              (attempt-auth token (fn [{:keys [success? status-code]}]
                                    (cond
                                      (= 401 status-code) ; maybe bad cookie, not auth failure
-                                     (swap! state assoc :user-status :not-logged-in)
+                                     (do (utils/delete-access-token-cookie)
+                                         (swap! state assoc :user-status :not-logged-in))
                                      (= 403 status-code)
                                      (swap! state assoc :user-status :not-activated)
                                      ;; 404 just means not registered


Hack to make it easier to re-auth with Rawls when necessary.

--- src/cljs/org/broadinstitute/firecloud_ui/main.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/main.cljs
@@ -80,7 +80,7 @@
 ;; Content to display when logged in via Google
 (react/defc LoggedIn
   {:render
-   (fn [{:keys [props state]}]
+   (fn [{:keys [props]}]
      (let [nav-context (nav/parse-segment (:nav-context props))
            page (keyword (:segment nav-context))]
        (when-not (contains? (set (map :key top-nav-bar-items)) page)
@@ -105,7 +105,12 @@
         (let [item (first (filter #(= (% :key) page) top-nav-bar-items))]
           (if item
             [(item :component) {:nav-context nav-context}]
-            [:div {} "Page not found."]))]))})
+            [:div {} "Page not found."]))
+        [:div {:style {:margin "1em 1em -1em 0" :fontSize "smaller" :textAlign "right"}}
+         [:a {:href "https://rawls-dev.broadinstitute.org/authentication/register"
+              :target "_blank"
+              :style {:color "red"}}
+          "Force workspace service authentication"]]]))})

 ;; Content to display when logged out
 (react/defc LoggedOut


delaney.clj: added more Java method wrappers

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -346,6 +346,15 @@
   (every? (fn [[a b]] (= a b))
           (into {} (-> ds java-dsymbol .getMapToCanonical))))

+(defn minimal [ds]
+  (-> ds java-dsymbol .minimal dsymbol))
+
+(defn dual [ds]
+  (-> ds java-dsymbol .dual dsymbol))
+
+(defn invariant [ds]
+  (into [] (.invariant (java-dsymbol ds))))
+
 (defn automorphisms [ds]
   (for [m (-> ds java-dsymbol DSMorphism/automorphisms)]
     (into {} (for [D (elements ds)] [D (.get m (Integer. D))]))))


Do not do anything if server has no changes

There was a bug before where we were asking the queries to update even
when there were no changes

--- src/webapp/framework/client/coreclient.cljs
+++ src/webapp/framework/client/coreclient.cljs
@@ -1334,35 +1334,40 @@

+;{:data-source     :todo_items
+; :table           nil
+; :where           nil
+; :db-table        "todo_items"
+; :params          nil
+; :order           nil
+; :realtime        true}
+
 (log (str "Checking server for data updates ..."))
 (js/setInterval
  #(go
    ;(log (pr-str (count (keys @client-query-cache))))
-   (let [x (remote  !check-for-server-updates  {:client-data-session-id  @data-session-id} )
-         y (-> x :queries keys first)
-         xxx           (merge y {:data-source (keyword (get y :db-table)) :realtime true :table nil})
-         xx y
+
+   (let [x            (remote  !check-for-server-updates  {:client-data-session-id  @data-session-id} )
+         y            (-> x :queries keys first)
+         ]
+     (if y
+     (let [
+         xxx          (merge y {:data-source (keyword (get y :db-table)) :realtime true :table nil})
          new-key2     (dissoc (dissoc xxx :start) :end)
-         new-key      {:data-source     :todo_items
-                       :table           nil
-                       :where           nil
-                       :db-table        "todo_items"
-                       :params          nil
-                       :order           nil
-                       :realtime        true}
          ]
-     (log "Client realtime: " new-key2)
+
+     (log "Client realtime: " y)
      (>! client-query-cache-requests  {
                                   :query-key     new-key2

                                   :subset-range  {
-                                                  :start   (:start  xx)
-                                                  :end     (:end    xx)
+                                                  :start   (:start  y)
+                                                  :end     (:end    y)
                                                   ;:start    1
                                                   ;:end      20
                                                   } })

-     )) 3000)
+     )))) 3000)


Simplify the test code

Simplify the test code

--- test/mdr2/test/archive.clj
+++ test/mdr2/test/archive.clj
@@ -14,7 +14,8 @@
   (fs/mkdirs (env :archive-spool-dir))
   (fs/mkdirs (env :archive-periodical-spool-dir))
   (fs/mkdirs (env :archive-other-spool-dir))
-  (test-fn)
+  (with-redefs [clojure.java.jdbc/insert! mock-jdbc-insert]
+    (test-fn))
   (fs/delete-dir (env :archive-spool-dir))
   (fs/delete-dir (env :archive-periodical-spool-dir))
   (fs/delete-dir (env :archive-other-spool-dir)))
@@ -35,32 +36,30 @@
            (.getPath (file (env :archive-spool-dir) "dam123" "dam123.rdf")))))

   (testing "add master to db"
-    (with-redefs [clojure.java.jdbc/insert! mock-jdbc-insert]
-      (is (= (do
-               (#'mdr2.archive/add-to-db {:id 123 :volumes 1} :master)
-               @mock-db)
-             {:verzeichnis "dam123",
-              :sektion "master",
-              :aktion "save",
-              :transaktions_status "pending",
-              :abholer "NN",
-              :archivar "NN",
-              :flags "x"}))))
+    (is (= (do
+             (#'mdr2.archive/add-to-db {:id 123 :volumes 1} :master)
+             @mock-db)
+           {:verzeichnis "dam123",
+            :sektion "master",
+            :aktion "save",
+            :transaktions_status "pending",
+            :abholer "NN",
+            :archivar "NN",
+            :flags "x"})))

   (testing "add iso to db"
-    (with-redefs [clojure.java.jdbc/insert! mock-jdbc-insert]
-      (is (= (do
-               (#'mdr2.archive/add-to-db
-                {:id 123 :volumes 1 :library_signature 7}
-                :dist-master)
-               @mock-db)
-             {:verzeichnis "ds7",
-              :sektion "cdimage",
-              :aktion "save",
-              :transaktions_status "pending",
-              :abholer "NN",
-              :archivar "NN",
-              :flags "x"})))))
+    (is (= (do
+             (#'mdr2.archive/add-to-db
+              {:id 123 :volumes 1 :library_signature 7}
+              :dist-master)
+             @mock-db)
+           {:verzeichnis "ds7",
+            :sektion "cdimage",
+            :aktion "save",
+            :transaktions_status "pending",
+            :abholer "NN",
+            :archivar "NN",
+            :flags "x"}))))

 (deftest periodicals-single
   (testing "archiving of periodical single volume"
@@ -70,8 +69,9 @@
           iso-name (str dam-number ".iso")
           spool-dir (env :archive-periodical-spool-dir)]
       (archive/archive production)
-      (is (fs/exists? (fs/file spool-dir dam-number "produkt" iso-name)))
-      (is (fs/exists? (fs/file spool-dir dam-number rdf-name))))))
+      (are [file] (fs/exists? file)
+           (fs/file spool-dir dam-number "produkt" iso-name)
+           (fs/file spool-dir dam-number rdf-name)))))

 (deftest periodicals-multiple
   (testing "archiving of periodical multi volume"
@@ -81,8 +81,9 @@
           rdf-name (str dam-number ".rdf")
           spool-dir (env :archive-periodical-spool-dir)]
       (archive/archive production)
-      (is (fs/exists? (fs/file spool-dir dam-number "produkt" iso-name)))
-      (is (fs/exists? (fs/file spool-dir dam-number rdf-name))))))
+      (are [file] (fs/exists? file)
+           (fs/file spool-dir dam-number "produkt" iso-name)
+           (fs/file spool-dir dam-number rdf-name)))))

 (deftest other-single
   (testing "archiving of other production single volume"


Simplify the definition of for-all*

Simplify the definition of for-all*

--- src/main/clojure/clojure/test/check/properties.clj
+++ src/main/clojure/clojure/test/check/properties.clj
@@ -27,13 +27,11 @@

 (defn- apply-gen
   [function]
-  (fn [args-rose]
-    (gen/gen-pure
-      (gen/rose-fmap
-        (fn [args] (let [result (try (apply function args) (catch Throwable t t))]
-                     {:result result
-                      :function function
-                      :args args})) args-rose))))
+  (fn [args]
+    (let [result (try (apply function args) (catch Throwable t t))]
+      {:result result
+       :function function
+       :args args})))

 (defn for-all*
   "Creates a property (properties are also generators). A property
@@ -46,8 +44,9 @@
   (for-all* [gen/int gen/int] (fn [a b] (>= (+ a b) a)))
   "
   [args function]
-  (gen/gen-bind (apply gen/tuple args)
-                (apply-gen function)))
+  (gen/fmap
+    (apply-gen function)
+    (apply gen/tuple args)))

 (defn binding-vars
   [bindings]


Adding defaults

Adding defaults

--- src/leiningen/docstring_checker.clj
+++ src/leiningen/docstring_checker.clj
@@ -1,11 +1,18 @@
 (ns leiningen.docstring-checker
-  (:require [leiningen.core.eval :as lein]))
+  (:require [leiningen.core.eval :as lein]
+            [leiningen.compile :as lein-compile]
+            [bultitude.core :as b]))

 (defn- docstring-checker-version [{:keys [plugins]}]
   (some (fn [[plugin-name version]]
           (when (= plugin-name 'docstring-checker/docstring-checker)
             version))
         plugins))
+
+(defn get-packages [paths]
+  (map #(re-pattern (str "^" (name %)))
+       (b/namespaces-on-classpath :classpath
+                                  (map clojure.java.io/file paths))))

 (defn docstring-checker
   "Linter that checks all public vars in a Leiningen project have docstrings."
@@ -15,4 +22,7 @@
    (update-in project [:dependencies] conj ['docstring-checker (docstring-checker-version project)])
    `(do
       (require 'docstring-checker.core)
-      (docstring-checker.core/check-docstrings ~(:docstring-checker project)))))
+      (if ~(:docstring-checker project)
+        (docstring-checker.core/check-docstrings ~(:docstring-checker project))
+        (docstring-checker.core/check-docstrings {:include (vector ~@(get-packages (:source-paths project)))
+                                                  :exclude []})))))


test hook

test hook

--- src/main/cawala/api/read.clj
+++ src/main/cawala/api/read.clj
@@ -6,7 +6,7 @@
                      :person/relation :friend}
                  2  {:db/id 2 :person/name "Sally" :person/age 22
                      :person/relation :friend}
-                 3  {:db/id 3 :person/name "Allie" :person/age 63
+                 3  {:db/id 3 :person/name "Allie" :person/age 62
                      :person/relation :enemy}
                  4  {:db/id 4 :person/name "Zoe" :person/age 32
                      :person/relation :friend}


filter more unwanted compile output in .jar libs

this is far too common ... should really get rid of classpath
indexing just because of this.

--- src/main/shadow/build/classpath.clj
+++ src/main/shadow/build/classpath.clj
@@ -933,6 +933,7 @@
            #"^com/google/javascript"
            ;; way too many jars contain a public folder
            #"^public/"
+           #"^out/(.+)\.js$"
            ;; these files fail to parse correctly but we don't need them anyways
            #"^jdk/nashorn/*"
            #"goog/transpile\.js"


actually filter ...

actually filter ...

--- src/main/shadow/build/classpath.clj
+++ src/main/shadow/build/classpath.clj
@@ -1052,25 +1052,28 @@
           (.disableThreads)
           (.initOptions co))

+        ignore-patterns
+        #{#"node_modules/"
+          ;; temp files created by emacs are in the same directory
+          ;; named demo/.#foo.cljs are hidden and ignored on osx/linux
+          ;; but not hidden on windows so need to filter them
+          #"\.#"
+          ;; cljs.core aot
+          #"\.aot\.js$"
+          ;; closure library test files
+          #"^goog/demos/"
+          #"^goog/(.+)_test\.js$"
+          #"goog/transpile\.js"
+          ;; closure compiler support and test files
+          #"^com/google/javascript"
+          #"^jdk/nashorn/*"
+          ;; just in case the :output-dir of a dev build is on the classpath
+          #"^public/"
+          #"cljs-runtime/"}
+
         index
         {:ignore-patterns
-         #{#"node_modules/"
-           ;; temp files created by emacs are in the same directory
-           ;; named demo/.#foo.cljs are hidden and ignored on osx/linux
-           ;; but not hidden on windows so need to filter them
-           #"\.#"
-           ;; cljs.core aot
-           #"\.aot\.js$"
-           ;; closure library test files
-           #"^goog/demos/"
-           #"^goog/(.+)_test\.js$"
-           #"goog/transpile\.js"
-           ;; closure compiler support and test files
-           #"^com/google/javascript"
-           #"^jdk/nashorn/*"
-           ;; just in case the :output-dir of a dev build is on the classpath
-           #"^public/"
-           #"cljs-runtime/"}
+         ignore-patterns

          :classpath-excludes
          [#"resources(/?)$"
@@ -1104,7 +1107,11 @@
      ;; wait before moving on
      :compiler-options co
      :compiler cc
-     :index-ref (atom index)}))
+     :index-ref (atom index)
+     ;; FIXME: ugly duplication because of should-ignore-resource? being used as an api method
+     ;; this is also kept in the index-ref but having outside namespaces deref the index-ref
+     ;; is uglier than duplicating this little bit
+     :ignore-patterns ignore-patterns}))

 (defn stop [cp])


Add run-command function that resolves and runs commands

This function uses the :query and :process-result functions that
can be defined via workflo.macros.command/configure! to query the
cache for data and process the results after they are returned from
the command implementation.

--- src/main/workflo/macros/command.clj
+++ src/main/workflo/macros/command.clj
@@ -34,18 +34,45 @@

 ;;;; Command registry

-(defonce ^:private command-registry (atom {}))
+(defonce ^:private +registry+ (atom {}))

 (defn register-command!
-  [cmd-name]
+  [cmd-name env]
   (let [cmd-sym        (util/unqualify cmd-name)
         definition-sym (util/prefix-form-name 'definition cmd-sym)
-        definition     (resolve definition-sym)]
-    (swap! command-registry assoc name definition)))
+        definition     (symbol (str (ns-name *ns*))
+                               (str definition-sym))]
+    (swap! +registry+ assoc cmd-name definition)))
+
+(defn registered-commands
+  []
+  @+registry+)

 (defn resolve-command
   [cmd-name]
-  (get @command-registry cmd-name))
+  (let [cmd (get @+registry+ cmd-name)]
+    (when (nil? cmd)
+      (let [err-msg (str "Failed to resolve command '" cmd-name "'")]
+        (throw (Exception. err-msg))))
+    cmd))
+
+(defn run-command
+  [cmd-name data]
+  (let [definition-sym (resolve-command cmd-name)
+        definition     @(resolve definition-sym)]
+    (when (:data-spec definition)
+      (assert (s/valid? (:data-spec definition) data)
+              (str "Command data is invalid:"
+                   (s/explain-str (:data-spec definition) data))))
+    (let [cache-query    (some-> definition :cache-query)
+          query-result   (some-> (get-config :query)
+                                 (apply [cache-query]))
+          command-result ((:implementation definition)
+                          query-result data)]
+      (if (get-config :process-result)
+        (-> (get-config :process-result)
+            (apply [command-result]))
+        command-result))))

 ;;;; The defcommand macro

@@ -81,8 +108,8 @@
                                                      query-keys)))
                           (map util/form->defn))
          all-forms   (cond-> all-forms
-                       cache-query (conj {:form-name 'cache-query
-                                          :form-body '()}))
+                       cache-query (conj {:form-name 'cache-query})
+                       data-spec   (conj {:form-name 'data-spec}))
          forms-map   (zipmap (map (comp keyword :form-name) all-forms)
                              (map (fn [form]
                                     (symbol (str (ns-name *ns*))
@@ -93,17 +120,21 @@
          query-form  (when cache-query
                        `((~'def ~(util/prefix-form-name 'cache-query
                                                         name-sym)
-                          ~cache-query)))
+                          '~cache-query)))
+         spec-form   (when data-spec
+                       `((~'def ~(util/prefix-form-name 'data-spec
+                                                        name-sym)
+                          ~data-spec)))
          definition  `(~'def ~(util/prefix-form-name 'definition
                                                      name-sym)
                        ~forms-map)]
      `(do
         ~@form-fns
         ~@query-form
+        ~@spec-form
         ~definition))))

 (defmacro defcommand
   [name & forms]
-  (let [cmd-expr (defcommand* name forms &env)]
-    (register-command! name)
-    cmd-expr))
+  (register-command! name &env)
+  (defcommand* name forms &env))


Fix typo.

Fix typo.

--- src/oc/storage/resources/common.clj
+++ src/oc/storage/resources/common.clj
@@ -21,7 +21,7 @@

 (def Slug "Valid slug used to uniquely identify a resource in a visible URL." (schema/pred slug/valid-slug?))

--(def Attachment {
+(def Attachment {
   :file-name lib-schema/NonBlankStr
   :file-type lib-schema/NonBlankStr
   :file-size schema/Num


Rearrange functions

Rearrange functions

--- src/onyx/messaging/aeron.clj
+++ src/onyx/messaging/aeron.clj
@@ -360,6 +360,23 @@
       (pm/peer-channels id)
       ch-k))

+(defn send-messages-short-circuit [ch batch]
+  (when ch
+    (doseq [segment batch]
+      (>!! ch segment))))
+
+(defn ack-segments-short-circuit [ch acks]
+  (when ch
+    (doseq [ack acks]
+      (>!! ch ack))))
+
+(defn complete-message-short-circuit [ch completion-id]
+  (when ch
+    (>!! ch completion-id)))
+
+(defn retry-segment-short-circuit [ch retry-id]
+  (when ch
+    (>!! ch retry-id)))

 (def ^:const publication-backpressured (long -2))
 (def ^:const publication-not-connected (long -1))
@@ -371,10 +388,6 @@
                  (= result publication-not-connected)))
       (.idle ^IdleStrategy (:send-idle-strategy messenger) 0))))

-(defn send-messages-short-circuit [ch batch]
-  (when ch
-    (doseq [segment batch]
-      (>!! ch segment))))

 (defmethod extensions/send-messages AeronConnection
   [messenger event {:keys [id channel] :as conn-info} batch]
@@ -383,11 +396,6 @@
     (let [pub ^Publication (get-publication messenger conn-info)
           [len unsafe-buffer] (protocol/build-messages-msg-buf (:compress-f messenger) id batch)]
       (send-pub messenger pub unsafe-buffer 0 len))))
-
-(defn ack-segments-short-circuit [ch acks]
-  (when ch
-    (doseq [ack acks]
-      (>!! ch ack))))

 (defmethod extensions/internal-ack-segments AeronConnection
   [messenger event {:keys [id channel] :as conn-info} acks]
@@ -398,10 +406,6 @@
         (let [unsafe-buffer (protocol/build-acker-message id (:id ack) (:completion-id ack) (:ack-val ack))]
           (send-pub messenger pub unsafe-buffer 0 protocol/ack-msg-length))))))

-(defn complete-message-short-circuit [ch completion-id]
-  (when ch
-    (>!! ch completion-id)))
-
 (defmethod extensions/internal-complete-message AeronConnection
   [messenger event completion-id {:keys [id channel] :as conn-info}]
   (if ((:short-circuitable? messenger) channel)
@@ -409,10 +413,6 @@
     (let [pub ^Publication (get-publication messenger conn-info)
           unsafe-buffer (protocol/build-completion-msg-buf id completion-id)]
       (send-pub messenger pub unsafe-buffer 0 protocol/completion-msg-length))))
-
-(defn retry-segment-short-circuit [ch retry-id]
-  (when ch
-    (>!! ch retry-id)))

 (defmethod extensions/internal-retry-segment AeronConnection
   [messenger event retry-id {:keys [id channel] :as conn-info}]


add env/origin script param to account for different envs

--- src/open_company/lib/bot.clj
+++ src/open_company/lib/bot.clj
@@ -42,13 +42,18 @@
     (assoc-in ctx [:stakeholder-update :note] note)
     ctx))

+(defn add-origin [params ctx]
+  (if-let [origin (get-in ctx [:request :headers "origin"])]
+    (assoc params :env/origin origin)
+    params))
+
 (defn ctx->trigger [script-id ctx]
   {:pre [(map? (:company ctx)) (map? (:user ctx))]}
   (let [rid (strip-prefix (-> ctx :user :user-id))
         bot (-> ctx :user :bot)]
     {:api-token   (:jwtoken ctx)
      :bot         bot
-     :script      {:id script-id, :params (-> ctx add-su-note script-params)}
+     :script      {:id script-id, :params (-> ctx add-su-note script-params (add-origin ctx))}
      :receiver    (case script-id
                     :onboard {:type :user, :id rid}
                     :stakeholder-update {:type :all-members})}))


Add rand-chord pitch fn

Add rand-chord pitch fn

--- src/overtone/music/pitch.clj
+++ src/overtone/music/pitch.clj
@@ -378,6 +378,19 @@
            chord (resolve-chord chord-name)]
        (set (map #(+ % root) chord)))))

+(defn rand-chord
+  "Generates a random list of MIDI notes with cardinality num-pitches bound
+  within the range of the specified root and pitch-range and only containing
+  pitches within the specified chord-name. Similar to Impromptu's pc:make-chord"
+  [root chord-name num-pitches pitch-range]
+  (let [chord (chord root chord-name)
+        root (note root)
+        max-pitch (+ pitch-range root)
+        roots (range 0 max-pitch 12)
+        notes (flatten (map (fn [root] (map #(+ root %) chord)) roots))
+        notes (take-while #(<= % max-pitch) notes)]
+    (sort (choose-n num-pitches notes))))
+
 ; midicps
 (defn midi->hz
   "Convert a midi note number to a frequency in hz."


Add type hints

Add type hints

--- src/play_clj/core_global.clj
+++ src/play_clj/core_global.clj
@@ -25,13 +25,13 @@
 (defn game
   [key]
   (case key
-    :width (.getWidth (Gdx/graphics))
-    :height (.getHeight (Gdx/graphics))
-    :fps (.getFramesPerSecond (Gdx/graphics))
-    :is-fullscreen? (.isFullscreen (Gdx/graphics))
-    :is-touched? (.isTouched (Gdx/input))
-    :x (.getX (Gdx/input))
-    :y (.getY (Gdx/input))
+    :width (.getWidth ^Graphics (Gdx/graphics))
+    :height (.getHeight ^Graphics (Gdx/graphics))
+    :fps (.getFramesPerSecond ^Graphics (Gdx/graphics))
+    :is-fullscreen? (.isFullscreen ^Graphics (Gdx/graphics))
+    :is-touched? (.isTouched ^Input (Gdx/input))
+    :x (.getX ^Input (Gdx/input))
+    :y (.getY ^Input (Gdx/input))
     nil))

 (defmacro input-key


logging fix

logging fix

--- src/polismath/simulation.clj
+++ src/polismath/simulation.clj
@@ -5,6 +5,7 @@
         polismath.named-matrix
         polismath.conversation
         clj-time.coerce
+        clojure.tools.logging
         plumbing.core
         clj-time.local))


Fixing entry id database migration.

Fixing entry id database migration.

--- metadata-db-app/src/migrations/026_fix_entry_ids.clj
+++ metadata-db-app/src/migrations/026_fix_entry_ids.clj
@@ -10,8 +10,8 @@
   (doseq [t (h/get-collection-tablenames)]
     (println (str "Table: " t))

-    ;; Set version id to a default value. Only DIF9 should have had null
-    (h/sql (format "update %s set version_id = 'Not provided' where version_id is null and format = 'DIF'" t))
+    ;; Set version id to a default value.
+    (h/sql (format "update %s set version_id = 'Not provided' where version_id is null" t))

     ;; Version id does not allow null values anymore
     (h/sql (format "alter table %s modify (VERSION_ID not null)" t))


Adjusted Output.

Adjusted Output.

--- src/leiningen/ancient.clj
+++ src/leiningen/ancient.clj
@@ -130,7 +130,7 @@
               (let [releases (filter (complement qualified?) vs)
                     snapshots (filter snapshot? vs)
                     qualified (filter #(and (not (snapshot? %)) (qualified? %)) vs)]
-                (println (str "  * " (count vs) " versions found."))
+                (println (str "  * " (count vs) " version(s) found."))
                 (print-version "latest release" (first releases))
                 (print-version "latest SNAPSHOT" (first snapshots))
                 (print-version "latest qualified" (first qualified))


Deprecation notice for :namespaces in project.clj.

--- src/leiningen/compile.clj
+++ src/leiningen/compile.clj
@@ -43,6 +43,8 @@
   "Returns a seq of the namespaces that are compilable, regardless of whether
   their class files are present and up-to-date."
   [project]
+  (when (:namespaces project)
+    (println "WARNING: :namespaces in project.clj is deprecated; use :aot."))
   (let [nses (or (:aot project) (:namespaces project))
         nses (if (= :all nses)
                (namespaces-in-dir (:source-path project))


trim-v for create-game

trim-v for create-game

--- test/cljs/go_client/handlers/game_test.cljs
+++ test/cljs/go_client/handlers/game_test.cljs
@@ -6,9 +6,9 @@

 (def starting-db db/default-db)

-(deftest create-game-creates-a-new-game
+(deftest creating-a-new-game
          (let [starting-number-of-games (count (:games starting-db))
                expected-number-of-games (inc starting-number-of-games)
-               changed-db (game/create-game starting-db [:foo "title"])]
+               changed-db (game/create-game starting-db ["title"])]
            (is (= expected-number-of-games (count (:games changed-db))))))


should return nil

should return nil

--- test/celestial/integration/workflows/openstack.clj
+++ test/celestial/integration/workflows/openstack.clj
@@ -63,5 +63,5 @@
               (status tenant id) => :in-use
               (wf/destroy (spec)) => nil
               (status tenant id) => :available
-              (delete id tenant))
+              (delete id tenant) => nil)
          ))))


configurable temp directory path

configurable temp directory path

--- src/cljam/util.clj
+++ src/cljam/util.clj
@@ -15,7 +15,9 @@
 ;; Disk cache
 ;; ----------

-(def temp-dir (let [dir-path (.getPath (file (System/getProperty "java.io.tmpdir") "cljam"))]
+(def temp-dir (let [system-tmp-dir-path (or (System/getenv "TMPDIR")
+                                            (System/getProperty "java.io.tmpdir"))
+                    dir-path (.getPath (file system-tmp-dir-path "cljam"))]
                 (.mkdirs (file dir-path))
                 dir-path))


fixed tests

fixed tests


in-ns good but ccw doesn't recognize it as a namespace so fail

--- src/random/learning/clojure/usetheoverridexns.clj
+++ src/random/learning/clojure/usetheoverridexns.clj
@@ -1,26 +1,28 @@
-(ns random.learning.clojure.usetheoverridexns
-  (:refer-clojure :exclude [sorted?])
-  (:use [random.learning.clojure.overridex])
-  (:refer-clojure :exclude [sorted?])
+;not bad, but ccw functionality lost: switching to this namespace(on load and on demand)
+(clojure.core/in-ns 'random.learning.clojure.usetheoverridexns)
+(clojure.core/require '[clojure.core :as cc])
+
+;  (:refer-clojure :exclude [sorted?])
+  (cc/use '[random.learning.clojure.overridex])
+  ;(:refer-clojure :exclude [sorted?])
   ;(:require [random.learning.clojure.overridex])
-  )
+  ;)

-(println clojure.core/*ns*)
+(cc/println clojure.core/*ns*)
 ;the following only works if pasted in REPL, cause ccw seems to be loading clojure.core after executing this file
-(clojure.core/map
+#_(clojure.core/map
   #(clojure.core/ns-unmap clojure.core/*ns* %)
   (clojure.core/keys
     (clojure.core/ns-publics 'clojure.core)
     )
   )

-(require '[clojure.core :as cc])
 ;require
 ;(refer '[clojure.core :as cc])

-(and
-  (= false (sorted? '(1 2)))
-  (= true (sorted? (sorted-set 1 2))))
+(cc/and
+  (cc/= false (sorted? '(1 2)))
+  (cc/= true (sorted? (cc/sorted-set 1 2))))

 ;;
 ;; Clojure 1.5.0-RC16


Suppress Server header.

Suppress Server header.

--- src/cavm/core.clj
+++ src/cavm/core.clj
@@ -43,6 +43,7 @@
   (:import [com.google.api.client.json.gson GsonFactory])
   (:import [com.google.api.client.http.javanet NetHttpTransport])
   (:import [com.google.api.client.googleapis.auth.oauth2 GoogleIdToken GoogleIdToken$Payload GoogleIdTokenVerifier GoogleIdTokenVerifier$Builder])
+  (:import [org.eclipse.jetty.server HttpConnectionFactory])
   (:gen-class))

 (defn- in-data-path [root path]
@@ -225,8 +226,17 @@
 (def max-threads
   (delay (max 80 (* 2 (.availableProcessors (Runtime/getRuntime))))))

+(defn configurator [server]
+  ; disable Server header.
+  (doseq [conn (filter #(instance? HttpConnectionFactory %)
+                       (mapcat
+                         #(.getConnectionFactories %)
+                         (.getConnectors server)))]
+    (.setSendServerVersion (.getHttpConfiguration conn) false)))
+
 (defn- serv [app host port {:keys [keystore password]} ws-config]
-  (run-jetty app {:websockets ws-config
+  (run-jetty app {:configurator configurator
+                  :websockets ws-config
                   :allow-null-path-info true
                   :host host
                   :port port


Performance tweaks for top level form selection

--- src/lt/plugins/cljrefactor/util.cljs
+++ src/lt/plugins/cljrefactor/util.cljs
@@ -61,8 +61,6 @@
 ;; Improved form selection utils
 ;; ==================================

-(defn whitespace? [ch]
-  (some #{\space \newline \tab} right-char))

 (defn- end-pair? [ch]
   (some #{\) \} \]} ch))
@@ -82,17 +80,6 @@
 (defn get-ch [ed loc]
   (get (editor/line ed (:line loc)) (:ch loc)))

-(defn end-loc [ed]
-  (let [last-line (editor/last-line ed)]
-    {:line last-line
-     :ch (max 0 (dec (editor/line-length ed last-line)))}))
-
-(defn end-loc? [ed loc]
-  (= (end-loc ed) loc))
-
-(defn start-loc? [ed loc]
-  (and (= 0 (:line loc))
-       (= 0 (:ch loc))))

 (defn string|comment? [ed loc]
@@ -107,8 +94,7 @@
        (str-contains? t "comment") true
        (and (str-contains? t "string")
             (not
-             (and (end-pair? ch) (= \" left-ch) (not (= "string"
-                                                        (editor/->token-type ed (editor/adjust-loc loc 1))))))) true
+             (and (end-pair? ch) (= \" left-ch) (not (= "string" (editor/->token-type ed (editor/adjust-loc loc 1))))))) true
        :else false))))

@@ -122,21 +108,21 @@
                                (max (dec (editor/line-length ed (:line neue))) 0)
                                0))))))

-(defn move-loc [ed dir loc]
+(defn move-loc [ed dir loc & {:keys [line]}]
   (when loc
-    (let [len (editor/line-length ed (:line loc))
+    (let [len (if line
+                (count line)
+                (editor/line-length ed (:line loc)))
           neue (editor/adjust-loc loc (if (= dir :left) -1 1))]
       (cond
        (< (:ch neue) 0) (move-loc-line ed loc :up)
        (>= (:ch neue) len) (move-loc-line ed loc :down)
        :else neue))))

-(defn peek-ch [ed dir loc]
-  (when-let [next-loc (move-loc ed dir loc)]
-    (get-ch ed next-loc)))

 (defn within-range [[start end] cur]
   (>= end (:line cur) start))
+

 (defn loc-next-end-pair [ed loc]
@@ -149,13 +135,13 @@
               (not (within-range search-range cur)))
         nil
         (let [ch (get line (:ch cur))
-              next-loc (move-loc ed :right cur)
+              next-loc (move-loc ed :right cur :line line)
               next-line (if (not= (:line cur) (:line next-loc))
                           (editor/line ed (:line next-loc))
                           line)]
           (cond
-           (and (or (start-pair? ch) (end-pair? ch))
-                (string|comment? ed cur)) (recur next-loc next-line level)
+           (not (or (start-pair? ch) (end-pair? ch))) (recur next-loc next-line level)
+           (string|comment? ed cur) (recur next-loc next-line level)
            (start-pair? ch) (recur next-loc next-line (inc level))
            (and (end-pair? ch) (= 0 level)) cur
            (end-pair? ch) (recur next-loc next-line (dec level))
@@ -173,14 +159,13 @@
               (not (within-range search-range cur)))
         nil
         (let [ch (get line (:ch cur))
-              next-loc (move-loc ed :left cur)
+              next-loc (move-loc ed :left cur :line line)
               next-line (if (not= (:line cur) (:line next-loc))
                           (editor/line ed (:line next-loc))
                           line)]
           (cond
-           (and (or (= ch (get opposites pair-ch))
-                    (= ch pair-ch))
-                (string|comment? ed cur)) (recur next-loc next-line level)
+           (not (or (= ch (get opposites pair-ch)) (= ch pair-ch))) (recur next-loc next-line level)
+           (string|comment? ed cur) (recur next-loc next-line level)
            (= ch (get opposites pair-ch)) (recur next-loc next-line (inc level))
            (and (= ch pair-ch) (= 0 level)) cur
            (= ch pair-ch) (recur next-loc next-line (dec level))
@@ -207,14 +192,17 @@
 (defn get-top-level-form
   ([ed] (get-top-level-form ed (editor/->cursor ed)))
   ([ed loc]
-   (if-let [[start end] (some->> (get-bounds-matching ed loc)
-                                 (iterate (partial get-next-bounds-matching ed))
-                                 (take-while identity)
-                                 last)]
-
-     {:form-str (editor/range ed start (update-in end [:ch] inc))
-      :start start
-      :end (update-in end [:ch] inc)}
+   (reset! loc-counts {:start 0
+                       :end 0})
+   (if-let [[start end] (time (some->> (get-bounds-matching ed loc)
+                                       (iterate (partial get-next-bounds-matching ed))
+                                       (take-while identity)
+                                       last))]
+
+     (do
+       {:form-str (editor/range ed start (update-in end [:ch] inc))
+       :start start
+       :end (update-in end [:ch] inc)})
      (let [line (:line loc)
            line-str (editor/line ed (:line loc))]
        {:form-str line-str


Add warning comment.

Add warning comment.

--- src/cavm/core.clj
+++ src/cavm/core.clj
@@ -35,7 +35,7 @@
 (def data-path (str fs/*cwd*))

 (defn- in-data-path [path]
-  (boolean (fs/child-of? data-path path)))
+  (boolean (fs/child-of? data-path path))) ; XXX not working??

 (defn- filehash [file]
   "fixme")


silly namespace collision causing trouble, that's why u don't use global imports

--- src/mediakeys/hotkeys.clj
+++ src/mediakeys/hotkeys.clj
@@ -1,6 +1,6 @@
 (ns mediakeys.hotkeys
     (:use [mediakeys.file :only [DEFAULT_KEYS save-keys!]]
-           clojure.core.async))
+          [clojure.core.async :only [chan go-loop <! pipe put!]]))

 (import [com.tulskiy.keymaster.common Provider HotKeyListener])
 (import [javax.swing KeyStroke])
@@ -16,17 +16,13 @@
         (go-loop []
             (let [value (<! channel)]
                 (when not-nil? value
-                    (go-loop [unflattened (f value)]
-                        (let [inner-value (<! unflattened)]
-                            (when (not-nil? inner-value)
-                                (>! return inner-value)
-                                (recur unflattened))))
+                    (pipe (f value) return)
                     (recur))))
         return))

 (def new-provider!
     (let [provider (atom nil)]
-        (fn yosup [ ]
+        (fn [ ]
             (when @provider
                 (doto @provider
                     (.reset)
@@ -36,11 +32,10 @@
             @provider)))

 (def new-keys!
-    (let [keys (atom nil)]
+    (let [keys (atom DEFAULT_KEYS)]
         (fn ([] @keys)
             ([key-update]
-                (swap! keys #(merge key-update))
-                @keys))))
+                (swap! keys #(merge % key-update))))))

 (defn register-keys [^Provider provider keys]
     (let [return (chan)]
@@ -53,6 +48,7 @@
         return))

 (defn keypress-channel! [key-change]
+    (println "KEYCHANGE" key-change)
     (let [old-keys (new-keys!)]
         (try
             (let [keys (new-keys! key-change)