Wrap locking in macro

Wrap locking in macro

--- src/clj/robinson/glterminal.clj
+++ src/clj/robinson/glterminal.clj
@@ -33,6 +33,19 @@

 (set! *warn-on-reflection* true)
 (set! *unchecked-math* true)
+
+(defmacro with-gl-context
+  "Executes exprs in an implicit do, while holding the monitor of x and aquiring/releasing the OpenGL context.
+  Will release the monitor of x in all circumstances."
+  [x & body]
+  `(let [lockee# ~x]
+     (try
+       (monitor-enter lockee#)
+       (Display/makeCurrent)
+       ~@body
+       (finally
+         (Display/releaseContext)
+         (monitor-exit lockee#)))))

 (defn convert-key-code [event-char event-key on-key-fn]
   ;; Cond instead of case. For an unknown reason, case does not match event-key to Keyboard/* constants.
@@ -266,6 +279,23 @@
     (.close input-stream)
     bytebuf))

+;; Extract native libs and setup system properties
+(defn init-natives []
+  ;(System/setProperty "java.library.path", (.getAbsolutePath (File. "natives")))
+  (condp = [(LWJGLUtil/getPlatform) (.endsWith (System/getProperty "os.arch") "64")]
+    [LWJGLUtil/PLATFORM_LINUX false]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/linux/x86")))
+      [LWJGLUtil/PLATFORM_LINUX true]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/linux/x86_64")))
+    [LWJGLUtil/PLATFORM_MACOSX false]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/macosx/x86")))
+    [LWJGLUtil/PLATFORM_MACOSX false]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/macosx/x86_64")))
+    [LWJGLUtil/PLATFORM_WINDOWS false]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/windows/x86")))
+    [LWJGLUtil/PLATFORM_WINDOWS true]
+      (System/setProperty "org.lwjgl.librarypath", (.getAbsolutePath (File. "natives/windows/x86_64")))))
+
 (defn- init-display [title screen-width screen-height]
   (let [pixel-format       (PixelFormat.)
         context-attributes (ContextAttribs. 3 0)
@@ -284,6 +314,8 @@
                                                           (aset icon-array 0 (buffered-image-rgba-byte-buffer icon-image-16))
                                                           (aset icon-array 1 (buffered-image-rgba-byte-buffer icon-image-32))
                                                           icon-array))]
+    ;; init-natives must be called before the Display is created
+     (init-natives)
      (Display/setDisplayMode (DisplayMode. screen-width screen-height))
      (Display/setTitle title)
      (Display/setIcon icon-array)
@@ -351,7 +383,7 @@
   ([viewport-width viewport-height matrix-buffer]
     (let [ortho-matrix (doto (Matrix4f.)
                          (.setIdentity))
-          matrix-buffer (BufferUtils/createFloatBuffer 16)
+          matrix-buffer matrix-buffer
           zNear   10
           zFar   -10
           m00     (/ 2 viewport-width)
@@ -482,7 +514,7 @@
   (get-key-chan [_]
     key-chan)
   (apply-font! [this windows-font else-font size smooth]
-    (locking this
+    (with-gl-context this
       (reset! normal-font
               (if (= (LWJGLUtil/getPlatform) LWJGLUtil/PLATFORM_WINDOWS)
                 (make-font windows-font Font/PLAIN size)
@@ -494,18 +526,17 @@
                     font-texture-width
                     font-texture-height
                     font-texture-image]} (get @font-textures (font-key @normal-font))]
-      (log/info "screen size" screen-width "x" screen-height)
-        (Display/makeCurrent)
-        (Display/setDisplayMode (DisplayMode. screen-width screen-height))
-        (swap! font-textures update (font-key @normal-font) (fn [m] (assoc m :font-texture (texture-id font-texture-image))))
-        (Display/releaseContext))
-      (reset! antialias smooth))
-      ;TODO: resize screen (and bind texture?)
-      )
+        (log/info "screen size" screen-width "x" screen-height)
+        (try
+          (Display/setDisplayMode (DisplayMode. screen-width screen-height))
+          (swap! font-textures update (font-key @normal-font) (fn [m] (assoc m :font-texture (texture-id font-texture-image))))
+          (catch Throwable t
+            (log/error "Eror changing font" t))))
+      (reset! antialias smooth)))
   (set-cursor! [_ xy]
     (reset! cursor-xy xy))
   (refresh! [this]
-    (locking this
+    (with-gl-context this
       (let [{{:keys [vertices-vbo-id vertices-count texture-coords-vbo-id]} :buffers
              {:keys [font-texture glyph-texture fg-texture bg-texture]} :textures
              program-id :program-id
@@ -571,63 +602,70 @@
         (.flip glyph-image-data)
         (.flip fg-image-data)
         (.flip bg-image-data)
-        (Display/makeCurrent)
-        (GL11/glViewport 0 0 screen-width screen-height)
-        (GL11/glClearColor 0.0 0.0 1.0 1.0)
-        (GL11/glClear (bit-or GL11/GL_COLOR_BUFFER_BIT GL11/GL_DEPTH_BUFFER_BIT))
-        (GL20/glUseProgram program-id)
-        (GL20/glUniformMatrix4 u-PMatrix false (ortho-matrix-buffer screen-width screen-height p-matrix-buffer))
-        (GL20/glUniformMatrix4 u-MVMatrix false (position-matrix-buffer [(- (/ screen-width 2)) (- (/ screen-height 2)) -1.0 0.0]
-                                                                        [screen-width screen-height 1.0]
-                                                                        mv-matrix-buffer))
-        ; Setup vertex buffer
-        ;(GL15/glBindBuffer GL15/GL_ARRAY_BUFFER, vertices-vbo-id)
-        (except-gl-errors (str "vbo bind - glBindBuffer" vertices-vbo-id))
-        (GL20/glEnableVertexAttribArray 0);pos-vertex-attribute)
-        (except-gl-errors "vbo bind - glEnableVertexAttribArray")
-        ;;(GL20/glVertexAttribPointer 0 3 GL11/GL_FLOAT false 0 0)
-        (except-gl-errors "vbo bind - glVertexAttribPointer")
-        ; Setup uv buffer
-        ;(GL15/glBindBuffer GL15/GL_ARRAY_BUFFER, texture-coords-vbo-id)
-        (GL20/glEnableVertexAttribArray 1);texture-coords-vertex-attribute)
-        ;;(GL20/glVertexAttribPointer 1 2 GL11/GL_FLOAT false 0 0)
-        (except-gl-errors "texture coords bind")
-        ; Setup font texture
-        (GL13/glActiveTexture GL13/GL_TEXTURE0)
-        (GL11/glBindTexture GL11/GL_TEXTURE_2D font-texture)
-        (GL20/glUniform1i u-font, 0)
-        (except-gl-errors "font texture bind")
-        ; Setup uniforms for glyph, fg, bg, textures
-        (GL20/glUniform1i u-glyphs 1)
-        (GL20/glUniform1i u-fg 2)
-        (GL20/glUniform1i u-bg 3)
-        (except-gl-errors "uniformli bind")
-        (GL20/glUniform2f font-size, character-width character-height)
-        (GL20/glUniform2f term-dim columns rows)
-        (GL20/glUniform2f font-tex-dim font-texture-width font-texture-height)
-        (GL20/glUniform2f glyph-tex-dim glyph-texture-width glyph-texture-height)
-        (except-gl-errors "uniform2f bind")
-        (except-gl-errors "gl(en/dis)able")
-        ; Send updated glyph texture to gl
-        (GL13/glActiveTexture GL13/GL_TEXTURE1)
-        (GL11/glBindTexture GL11/GL_TEXTURE_2D glyph-texture)
-        (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL30/GL_RGBA8UI texture-columns texture-rows 0 GL30/GL_RGBA_INTEGER GL11/GL_UNSIGNED_BYTE glyph-image-data)
-        (except-gl-errors "glyph texture data")
-        ; Send updated fg texture to gl
-        (GL13/glActiveTexture GL13/GL_TEXTURE2)
-        (GL11/glBindTexture GL11/GL_TEXTURE_2D fg-texture)
-        (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL11/GL_RGBA texture-columns texture-rows 0 GL11/GL_RGBA GL11/GL_UNSIGNED_BYTE fg-image-data)
-        (except-gl-errors "fg color texture data")
-        ; Send updated bg texture to gl
-        (GL13/glActiveTexture GL13/GL_TEXTURE3)
-        (GL11/glBindTexture GL11/GL_TEXTURE_2D bg-texture)
-        (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL11/GL_RGBA texture-columns texture-rows 0 GL11/GL_RGBA GL11/GL_UNSIGNED_BYTE bg-image-data)
-        (GL11/glDrawArrays GL11/GL_QUADS 0 vertices-count)
-        (except-gl-errors "bg color texture data")
-        (except-gl-errors "end of refresh")
-        ;(Display/sync 60)
-        (Display/update)
-        (Display/releaseContext))))
+        (try
+          (GL11/glViewport 0 0 screen-width screen-height)
+          (except-gl-errors (str "glViewport " screen-width screen-height))
+          (GL11/glClearColor 0.0 0.0 1.0 1.0)
+          (except-gl-errors (str "glClearColor  " 0.0 0.0 1.0 1.0))
+          (GL11/glClear (bit-or GL11/GL_COLOR_BUFFER_BIT GL11/GL_DEPTH_BUFFER_BIT))
+          (except-gl-errors (str "glClear  " (bit-or GL11/GL_COLOR_BUFFER_BIT GL11/GL_DEPTH_BUFFER_BIT)))
+          (GL20/glUseProgram program-id)
+          (GL20/glUniformMatrix4 u-PMatrix false (ortho-matrix-buffer screen-width screen-height p-matrix-buffer))
+          (except-gl-errors (str "u-PMatrix - glUniformMatrix4  " u-PMatrix))
+          (GL20/glUniformMatrix4 u-MVMatrix false (position-matrix-buffer [(- (/ screen-width 2)) (- (/ screen-height 2)) -1.0 0.0]
+                                                                          [screen-width screen-height 1.0]
+                                                                          mv-matrix-buffer))
+          (except-gl-errors (str "u-MVMatrix - glUniformMatrix4  " u-MVMatrix))
+          ; Setup vertex buffer
+          ;(GL15/glBindBuffer GL15/GL_ARRAY_BUFFER, vertices-vbo-id)
+          (except-gl-errors (str "vbo bind - glBindBuffer " vertices-vbo-id))
+          (GL20/glEnableVertexAttribArray 0);pos-vertex-attribute)
+          (except-gl-errors "vbo bind - glEnableVertexAttribArray")
+          ;;(GL20/glVertexAttribPointer 0 3 GL11/GL_FLOAT false 0 0)
+          (except-gl-errors "vbo bind - glVertexAttribPointer")
+          ; Setup uv buffer
+          ;(GL15/glBindBuffer GL15/GL_ARRAY_BUFFER, texture-coords-vbo-id)
+          (GL20/glEnableVertexAttribArray 1);texture-coords-vertex-attribute)
+          ;;(GL20/glVertexAttribPointer 1 2 GL11/GL_FLOAT false 0 0)
+          (except-gl-errors "texture coords bind")
+          ; Setup font texture
+          (GL13/glActiveTexture GL13/GL_TEXTURE0)
+          (GL11/glBindTexture GL11/GL_TEXTURE_2D font-texture)
+          (GL20/glUniform1i u-font, 0)
+          (except-gl-errors "font texture bind")
+          ; Setup uniforms for glyph, fg, bg, textures
+          (GL20/glUniform1i u-glyphs 1)
+          (GL20/glUniform1i u-fg 2)
+          (GL20/glUniform1i u-bg 3)
+          (except-gl-errors "uniformli bind")
+          (GL20/glUniform2f font-size, character-width character-height)
+          (GL20/glUniform2f term-dim columns rows)
+          (GL20/glUniform2f font-tex-dim font-texture-width font-texture-height)
+          (GL20/glUniform2f glyph-tex-dim glyph-texture-width glyph-texture-height)
+          (except-gl-errors "uniform2f bind")
+          (except-gl-errors "gl(en/dis)able")
+          ; Send updated glyph texture to gl
+          (GL13/glActiveTexture GL13/GL_TEXTURE1)
+          (GL11/glBindTexture GL11/GL_TEXTURE_2D glyph-texture)
+          (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL30/GL_RGBA8UI texture-columns texture-rows 0 GL30/GL_RGBA_INTEGER GL11/GL_UNSIGNED_BYTE glyph-image-data)
+          (except-gl-errors "glyph texture data")
+          ; Send updated fg texture to gl
+          (GL13/glActiveTexture GL13/GL_TEXTURE2)
+          (GL11/glBindTexture GL11/GL_TEXTURE_2D fg-texture)
+          (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL11/GL_RGBA texture-columns texture-rows 0 GL11/GL_RGBA GL11/GL_UNSIGNED_BYTE fg-image-data)
+          (except-gl-errors "fg color texture data")
+          ; Send updated bg texture to gl
+          (GL13/glActiveTexture GL13/GL_TEXTURE3)
+          (GL11/glBindTexture GL11/GL_TEXTURE_2D bg-texture)
+          (GL11/glTexImage2D GL11/GL_TEXTURE_2D 0 GL11/GL_RGBA texture-columns texture-rows 0 GL11/GL_RGBA GL11/GL_UNSIGNED_BYTE bg-image-data)
+          (GL11/glDrawArrays GL11/GL_QUADS 0 vertices-count)
+          (except-gl-errors "bg color texture data")
+          (except-gl-errors "end of refresh")
+          ;(Display/sync 60)
+          (Display/update)
+          (except-gl-errors "end of update")
+          (catch Error e
+            (log/error "OpenGL error:" e))))))
   (clear! [_]
     (ref-set character-map character-map-cleared))
   (set-fx-fg! [_ x y fg]
@@ -811,17 +849,21 @@
                          :options {:recursive true}}])
       ;; Poll keyboard in background thread and offer input to key-chan
       (future (go-loop []
-                (locking terminal
-                  (Display/processMessages)
-                  (when (Display/isCloseRequested)
-                    (System/exit 0))
-                  (loop []
-                    (when (Keyboard/next)
-                      (when (Keyboard/getEventKeyState)
-                        (let [character (Keyboard/getEventCharacter)
-                              key       (Keyboard/getEventKey)]
-                          (convert-key-code character key on-key-fn)))
-                      (recur))))
+                (with-gl-context terminal
+                  (try
+                    (Display/processMessages)
+                    (when (Display/isCloseRequested)
+                      (Display/destroy)
+                      (System/exit 0))
+                    (loop []
+                      (when (Keyboard/next)
+                        (when (Keyboard/getEventKeyState)
+                          (let [character (Keyboard/getEventCharacter)
+                                key       (Keyboard/getEventKey)]
+                            (convert-key-code character key on-key-fn)))
+                        (recur)))
+                    (catch Exception e
+                      (log/error "Error getting keyboard input" e))))
                 (Thread/sleep 1)
                 (recur)))
       terminal)))


Badge upload route summary

Badge upload route summary

--- src/clj/salava/badge/routes.clj
+++ src/clj/salava/badge/routes.clj
@@ -121,7 +121,7 @@
                    :return schemas/Upload
                    :multipart-params [file :- upload/TempFileUpload]
                    :middleware [upload/wrap-multipart-params]
-                   :summary "Upload badge PNG-file"
+                   :summary "Upload badge PNG or SVG file"
                    :auth-rules access/authenticated
                    :current-user current-user
                    (ok (i/upload-badge ctx file (:id current-user))))


Fix bug with toggle not working anymore

Fix bug with toggle not working anymore

--- src/cljs/clojure_rest/core.cljs
+++ src/cljs/clojure_rest/core.cljs
@@ -170,7 +170,7 @@
   [cards]
   (let [all-toggled (every? #(-> % second :show-details) cards)
         toggle-card #(assoc % :show-details (not all-toggled))]
-    (map (fn [[k v]] [k (toggle-card v)]) cards)
+    (into {} (map (fn [[k v]] [k (toggle-card v)]) cards))
   ))

 (defn render-app


Get rid of regex for namespace resolution.

--- src/clojure/flambo/function.clj
+++ src/clojure/flambo/function.clj
@@ -13,8 +13,8 @@
 (def serialize-fn sfn/serialize)
 (def deserialize-serfn (memoize sfn/deserialize))
 (def deserialize-fn (memoize #(let [f (kryo/deserialize (first %))]
-                                (->> f class .getName (re-matches #"(.*?)\$.*")
-                                     second symbol require)
+                                (when (instance? clojure.lang.Var$Unbound f)
+                                  (require (.. f v ns getName)))
                                 f)))
 (def array-of-bytes-type (Class/forName "[B"))


Removing extra log line.

Removing extra log line.

--- src/com/okl/tokenmgr/tokens.clj
+++ src/com/okl/tokenmgr/tokens.clj
@@ -76,7 +76,6 @@

 (defn create-token [token description environment value]
   "creates/updates a token"
-  (log/info (str "Trying to create token " token "\nwith desc " description "\nenvt " environment "\nand value " value))
   (let [good-token (trim token)
         full-path (join "/" [base-path good-token])
         path  (if (> (.lastIndexOf token "/") -1)


Refactor to standardize use of 'rebuild!'

--- src-cljs/frontend/components/builds_table.cljs
+++ src-cljs/frontend/components/builds_table.cljs
@@ -56,7 +56,8 @@

 (defn build-row [{:keys [build project]} owner {:keys [show-actions? show-branch? show-project?]}]
   (let [url (build-model/path-for (select-keys build [:vcs_url]) build)
-        raise-build-action! (fn [event] (raise! owner [event (build-model/build-args build)]))
+        rebuild! #(raise! owner %)
+        build-args (merge (build-model/build-args build) {:component "build-row" :is-no-cache false})
         status-words (build-model/status-words build)
         should-show-cancel? (and (project-model/can-trigger-builds? project)
                                  (build-model/can-cancel? build))
@@ -71,7 +72,6 @@
                                                            :properties {:status-words status-words}})}
        (build-status-badge build)]

-
       ;; Actions should be mutually exclusive. Just in case they
       ;; aren't, use a cond so it doesn't try to render both in the
       ;; same place
@@ -82,7 +82,7 @@
            :loading-text "Cancelling..."
            :icon-name "Status-Canceled"
            :on-click #(do
-                        (raise-build-action! :cancel-build-clicked)
+                        (rebuild! [:cancel-build-clicked build-args])
                         ((om/get-shared owner :track-event) {:event-type :cancel-build-clicked}))})

         should-show-rebuild?
@@ -90,12 +90,7 @@
           {:text "rebuild"
            :loading-text "Rebuilding..."
            :icon-name "Rebuild"
-           :on-click #(do
-                        (raise-build-action! :retry-build-clicked)
-                        ((om/get-shared owner :track-event) {:event-type :rebuild-clicked
-                                                             :properties {:component "build-row"
-                                                                          :is-ssh false
-                                                                          :is-no-cache true}}))})
+           :on-click #(rebuild! [:retry-build-clicked build-args])})
         :else nil)]

      [:div.build-info
@@ -170,7 +165,7 @@
                                                                     :properties {:repo (:reponame build)
                                                                                :org (:username build)}})}
                 "#"
-                (gh-utils/pull-request-number url)])))])
+                (gh-utils/pull-request-number url)])))]

         [:div.metadata-item.revision
          [:i.octicon.octicon-git-commit]
@@ -180,7 +175,7 @@
                 :on-click #((om/get-shared owner :track-event) {:event-type :revision-link-clicked
                                                                 :properties {:repo (:reponame build)
                                                                              :org (:username build)}})}
-            (build-model/github-revision build)])]]]]))
+            (build-model/github-revision build)])])]]]))

 (defn builds-table [data owner {:keys [show-actions? show-branch? show-project?]
                                 :or {show-branch? true


Working over conexp.contrib.gui.util

Working over conexp.contrib.gui.util

again

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

--- src/conexp/contrib/gui/util.clj
+++ src/conexp/contrib/gui/util.clj
@@ -11,7 +11,7 @@
 (ns conexp.contrib.gui.util
   (:import [javax.swing JFrame JPanel JButton ImageIcon JTabbedPane
                         JLabel BorderFactory AbstractButton JFileChooser
-                        JOptionPane JComponent]
+                        JOptionPane JComponent JMenuBar]
            [javax.swing.filechooser FileNameExtensionFilter]
            [java.awt Color Dimension Graphics Graphics2D BasicStroke FlowLayout]
            [java.awt.event MouseEvent]
@@ -111,7 +111,7 @@
   "Removes given menus (as Java objects) from menu-bar of frame."
   [^JFrame frame, menus]
   (do-swing
-   (let [menu-bar (first (select frame [:JMenuBar])),
+   (let [^JMenuBar menu-bar (first (select frame [:JMenuBar])),
          new-menus (remove (set menus) (seq (.getComponents menu-bar)))]
      (.removeAll menu-bar)
      (doseq [^JComponent menu new-menus]
@@ -121,7 +121,7 @@

 ;;; Tabs

-(defn- get-tabpane
+(defn- ^JTabbedPane get-tabpane
   "Returns tabpane of the given frame."
   [frame]
   (first (select frame [:<javax.swing.JTabbedPane>])))
@@ -132,7 +132,8 @@
   [^JTabbedPane tabpane, component]
   ;; This contains code copied from TabComponentDemo and
   ;; ButtonTabComponent from the Java Tutorial
-  (let [tabbutton (button :paint (fn [^JButton this ^Graphics g]
+  (let [^JButton
+        tabbutton (button :paint (fn [^JButton this ^Graphics g]
                                    (proxy-super paintComponent g)
                                    (let [^Graphics2D g2 (.create g),
                                          delta 6]
@@ -166,8 +167,7 @@
                   (when (instance? AbstractButton component)
                     (.setBorderPainted ^AbstractButton component false)))))
       (.setBorderPainted false)
-      (.setContentAreaFilled false)
-      )))
+      (.setContentAreaFilled false))))

 (defn- make-tab-head
   "Creates and returns a panel to be used as tab component."
@@ -189,7 +189,7 @@
   "Addes given panel to the tabpane of frame with given title, if given."
   ([^JFrame frame, ^JPanel pane, ^String title]
      (do-swing
-      (let [^JTabbedPane tabpane (get-tabpane frame)]
+      (let [tabpane (get-tabpane frame)]
         (.add tabpane pane)
         (let [index (.indexOfComponent tabpane pane),
               title (if-not (.isEmpty title)
@@ -205,21 +205,21 @@
 (defn get-tabs
   "Returns a vector of all tab of the given frame."
   [frame]
-  (let [^JTabbedPane tabpane (get-tabpane frame)]
+  (let [tabpane (get-tabpane frame)]
     (vec (rest (seq (.getComponents tabpane))))))

 (defn add-tab-with-name-icon-tooltip
   "Addes given panel to the tabpane of frame, giving name icon and tooltip"
   [^JFrame frame, ^JPanel pane, name icon tooltip]
   (do-swing
-   (.addTab ^JTabbedPane (get-tabpane frame) name icon pane tooltip)
+   (.addTab (get-tabpane frame) name icon pane tooltip)
    (.validate frame)))

 (defn remove-tab
   "Removes a panel from the windows JTabbedPane."
    [^JFrame frame, ^JPanel pane]
    (do-swing
-    (.remove ^JTabbedPane (get-tabpane frame) pane)
+    (.remove (get-tabpane frame) pane)
     (.validate frame)))

 (defn current-tab
@@ -234,7 +234,7 @@
 (defn current-tab-title
   "Returns the currently selected tab's title and nil if there is none."
   [frame]
-  (let [^JTabbedPane tabpane (get-tabpane frame),
+  (let [tabpane (get-tabpane frame),
         index (.getSelectedIndex tabpane)]
     (if (= -1 index)
       nil


Fix formatting

Fix formatting

--- src/invadm/core.clj
+++ src/invadm/core.clj
@@ -71,7 +71,7 @@
               (assoc options
                      "id" (get arguments 1)
                      "due-date" (unparse-date (t/plus (parse-date (:issue-date options))
-                                                     (t/days (:net options)))))))
+                                                      (t/days (:net options)))))))

 (defn cwd []
   (System/getProperty "user.dir"))


clean up defkey docstring

clean up defkey docstring

--- src/keypin/core.clj
+++ src/keypin/core.clj
@@ -206,9 +206,10 @@
     ip   [:ip-address]
     port [:port #(< 1023 % 65535) \"Server port\" {:parser str->int :default 3000}])
   (defkey
-    {:lookup lookup-property}
+    {:lookup lookup-key}
     ip   [\"server.ip.address\"]
-    port [\"server.port\" #(< 1023 % 65535) \"Server port\" {:parser str->int :default 3000}])"
+    port [\"server.port\" #(< 1023 % 65535) \"Server port\" {:parser str->int :default 3000}])
+  See: make-key"
   [the-sym arg-vec & more]
   (let [options (if (odd? (count more))
                   (i/expect-arg the-sym map? ["Expected an option map, found" (pr-str the-sym)])


Emit client code to :source-paths so watcher will fire

--- src/adzerk/boot_reload.clj
+++ src/adzerk/boot_reload.clj
@@ -29,6 +29,7 @@
       (info "<< started reload server on %s >>\n" url))))

 (defn- write-cljs! [f url on-jsload]
+  (info "Writing %s...\n" (.getName f))
   (->> (template
          ((ns adzerk.boot-reload
             (:require
@@ -45,12 +46,14 @@

 (defn- add-init!
   [in-file out-file]
-  (-> in-file
-      slurp
-      read-string
-      (update-in [:require] conj 'adzerk.boot-reload)
-      pr-str
-      ((partial spit out-file))))
+  (let [ns 'adzerk.boot-reload]
+    (info "Adding :require %s to %s...\n" ns (.getName in-file))
+    (-> in-file
+        slurp
+        read-string
+        (update-in [:require] conj ns)
+        pr-str
+        ((partial spit out-file)))))

 (deftask reload
   "Live reload of page resources in browser via websocket.
@@ -63,9 +66,11 @@
    j on-jsload SYM sym "The (optional) callback to call when JS files are reloaded."]

   (let [pod  (make-pod)
+        src  (temp-dir!)
         tmp  (temp-dir!)
         prev (atom nil)
-        out  (doto (io/file tmp "adzerk" "boot_reload.cljs") io/make-parents)]
+        out  (doto (io/file src "adzerk" "boot_reload.cljs") io/make-parents)]
+    (set-env! :source-paths #(conj % (.getPath src)))
     (write-cljs! out (start-server @pod {:ip ip :port port}) on-jsload)
     (comp
       (with-pre-wrap fileset


note to self

note to self

--- src/agario3d/game_loop.clj
+++ src/agario3d/game_loop.clj
@@ -18,4 +18,6 @@
           (when-let [[value port] (alts! [ws-channel tick-ch])]
             (condp = port
               ws-channel (recur (player-command (:message value))) ;;this happens when we get a message from the client
+              ;;this is wrong we don't want to update game every tick because this runs for
+              ;;every connected player. We need a separate loop that runs once for all players
               tick-ch (recur (update-game))))))))  ;;this happens every tick of the game loop


add group-by function for 1.1 compatability

--- bake/bake/test.clj
+++ bake/bake/test.clj
@@ -1,4 +1,5 @@
 (ns bake.test
+  (:refer-clojure :exclude [group-by])
   (:use [cake.contrib.find-namespaces :only [find-namespaces-in-dir]]
         useful)
   (:require [clojure.test :as test]
@@ -16,6 +17,15 @@
   (cond (namespace test) :fn
         (keyword?  test) :tag
         :else            :ns))
+
+;from 1.2
+(defn- group-by [f coll]
+  (persistent!
+   (reduce
+    (fn [ret x]
+      (let [k (f x)]
+        (assoc! ret k (conj (get ret k []) x))))
+    (transient {}) coll)))

 (defn get-grouped-tests [namespaces opts]
   (let [tests (:test opts)]


Remove wrong ns docstring on test_auth ns.

--- test/uxbox/tests/test_auth.clj
+++ test/uxbox/tests/test_auth.clj
@@ -1,5 +1,4 @@
 (ns uxbox.tests.test-auth
-  "A txlog and services abstraction generic tests."
   (:require [clojure.test :as t]
             [promesa.core :as p]
             [clj-http.client :as http]


Add default meta data to imports from vubis

--- src/mdr2/views.clj
+++ src/mdr2/views.clj
@@ -212,6 +212,7 @@
   (doseq [[_ p] productions]
     (-> p
      prod/parse
+     prod/add-default-meta-data
      ;; FIXME: does it make sense to update? What if the production
      ;; has already been archived? I think we should probably make
      ;; sure the production is in certain valid states


Use bound writers for interacting with the host env.

--- src/monocle/io.clj
+++ src/monocle/io.clj
@@ -36,16 +36,16 @@
          (.release lock#)
          (.close raf#)))))

-(defn write-printer [ptr reader batch]
+(defn write-printer [pfn reader batch]
   (count
    (apply concat
           (for [b (interpose ["-- "]
                              (partition-all batch (line-seq reader)))
                 l b]
-            (.println (-> ptr java.io.PrintWriter.) l)))))
+            (pfn l)))))

 (defn write-stdout [reader batch]
-  (write-printer *out* reader batch))
+  (write-printer println reader batch))

 (defn write-stderr [reader batch]
-  (write-printer *err* reader batch))
+  (write-printer #(binding [*out* *err*] (println %)) reader batch))


Print system envs to debug Heroku deplyoment.

--- src/notes/paas.clj
+++ src/notes/paas.clj
@@ -48,6 +48,7 @@
 (defn mongo-connection-uri [uid pwd]
   "Try to figure out runtime environment and resolve associated MongoDB
   connection URI. Defaults to localhost and standard port"
+  (println "System Envs: " System/getenv)
   (cond (is-dotcloud?) (dotcloud-uri uid pwd)
         (is-open-shift?) (open-shift-uri uid pwd)
         (is-heroku?) (heroku-uri uid pwd)


Improving viz output for thesis...

Improving viz output for thesis...

* using records to show properties inside nodes
* now showing in browser using SVG and direct to ps using evince for previews

--- src/plasma/viz.clj
+++ src/plasma/viz.clj
@@ -1,6 +1,7 @@
 (ns plasma.viz
   (:use [plasma util core operator]
-        jiraph.graph)
+        jiraph.graph
+        [clojure.contrib shell-out])
   (:require [logjam.core :as log]
             [vijual :as vij]
             [clojure (zip :as zip)]))
@@ -24,48 +25,105 @@
   [plan]
   (vij/draw-tree (tree-vecs plan)))

-(defn- dot-id
-  [id]
-  (trim-id id))
-;  (apply str "ID_" (take 4 (drop 5 id))))
-
 (defn- dot-edge
-  [src tgt props]
+  [src tgt props options]
   (let [label (name (:label props))]
     (println (str "\t\"" src "\" -> \"" tgt "\" [label=\"" label "\"];"))))

+(defn- dot-record-label
+  [props options]
+  (let [props (if (coll? (:node-props options))
+                (select-keys props (:node-props options))
+                props)
+        key-vals (map
+                   (fn [[k v]]
+                     (str (if (keyword? k)
+                            (name k)
+                            k) ": "
+                          (if (uuid? v)
+                            (trim-id v)
+                            v)))
+                   props)
+        prop-lbls (apply str (interpose " | " key-vals))]
+    (str "[label=\"{ " prop-lbls "}\"];")))
+
 (defn- dot-node
-  [id]
+  [id options]
   (let [n (find-node id)
-        d-id (dot-id id)
-        edges (get-edges id)
-        label (or (:label n) d-id)
-        label (if (keyword? label)
-                (name label)
-                label)]
-    (unless (empty? edges)
-            (println (str "\t\"" d-id "\" [label=\"" label "\"];"))
-            (doseq [[tgt-id props] edges]
-              (dot-edge d-id (dot-id tgt-id) props)))))
+        d-id (trim-id id)
+        node-props (:node-props options)
+        lbl (if node-props
+              (dot-record-label (dissoc n :edges) options)
+              (or (:label n)
+                  d-id))]
+        ;edges (get-edges id)
+        ;label (or (:label n) d-id)
+        ;label (if (keyword? label)
+        ;        (name label)
+        ;        label)]
+    (println (str "\t\"" d-id "\"" lbl))
+    (doseq [[tgt-id props] (:edges n)]
+      (dot-edge d-id (trim-id tgt-id) props))))

-(defn- dot-graph
+(defn dot-graph
   "Output the dot (graphviz) graph description for the given graph."
-  [g]
+  [g options]
   (with-graph g
-    (let [nodes (node-ids :graph)]
+    (let [nodes (filter
+                  #(not= "UUID:META" %)
+                  (node-ids :graph))
+          node-props (:node-props options)]
       (with-out-str
         (println "digraph G {\n")
-        (println "\tnode [shape=doublecircle]")
-        (dot-node (root-node-id))
-        (println "\tnode [shape=circle]")
-        (doseq [n (filter #(not (= (root-node-id) %)) nodes)]
-          (dot-node n))
+        (if node-props
+          (println "\tnode [shape=Mrecord]")
+          (println "\tnode [shape=circle]"))
+        (doseq [n nodes]
+          (dot-node n options))
         (println "}")))))

 (defn save-dot-graph
-  [g path]
-  (spit path (dot-graph g)))
+  ([g path] (save-dot-graph g path {}))
+  ([g path options]
+   (spit path (dot-graph g options))))

+(def EDGE-FONT 24)
+(def NODE-FONT 24)
+(def OUT-FORMAT "ps")
+
+(defn save-graph-image
+  ([in out] (save-graph-image in out {}))
+  ([in out options]
+   (let [out-format (:out-format options OUT-FORMAT)
+         edge-font-size (:edge-font-size options EDGE-FONT)
+         node-font-size (:node-font-size options NODE-FONT)]
+   (sh "dot"
+       in
+       (str "-T" out-format)
+       (str "-Efontsize=" edge-font-size)
+       (str "-Nfontsize=" node-font-size)
+       "-o" out))))
+
+(def APP "evince")
+
+(defn show-dot-graph
+  ([g] (show-dot-graph g {}))
+  ([g options]
+   (let [out-format (:out-format options OUT-FORMAT)
+         app (:app options APP)
+         out (str "/tmp/plasma-graph." out-format)]
+     (save-dot-graph g "/tmp/plasma-graph.dot" options)
+     (save-graph-image "/tmp/plasma-graph.dot" out options)
+     (sh app out))))
+
+(defn graph->ps
+  [g]
+  (show-dot-graph g))
+
+(defn graph->browser
+  [g]
+  (show-dot-graph g {:out-format "svg" :app "chromium-browser"}))
+
 (defn- label-table
   [top bottom]
   (str "<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">\n\t"
@@ -79,10 +137,10 @@
                 :traverse (label-table "traverse" (second args))
                 :parameter (label-table "parameter"
                                 (if (uuid? (first args))
-                                  (trim-id (first args))
+                                  (trim-id (first args))
                                   (first args)))
                 (str "\"" (name type) "\""))]
-        (str "\t\"" (dot-id id) "\" [label=" label "]")))
+        (str "\t\"" (trim-id id) "\" [label=" label "]")))

 (defn- dot-plan
   [plan]
@@ -91,7 +149,7 @@
     (doseq [[id op] (:ops plan)]
       (println (dot-op op))
       (doseq [edge (:deps op)]
-        (println (str "\t\"" (dot-id id) "\" -> \"" (dot-id edge) "\""))))
+        (println (str "\t\"" (trim-id id) "\" -> \"" (trim-id edge) "\""))))
     (println "}")))

 (defn save-dot-plan


set job factory at Lifecycle/start

set job factory at Lifecycle/start

--- src/twarc/core.clj
+++ src/twarc/core.clj
@@ -142,6 +142,7 @@
 (defrecord Scheduler []
   component/Lifecycle
   (start [this]
+    (.setJobFactory (::quartz this) (make-job-factory this))
     (.start (::quartz this))
     (assoc this ::listeners (atom {})))
   (stop [this]
@@ -171,9 +172,7 @@
        (when-let [cals (:calendars options)]
          (doseq [[name cal replace update-triggers] cals]
            (.addCalendar quartz name cal (boolean replace) (boolean update-triggers))))
-       (let [scheduler (map->Scheduler {::quartz quartz ::name n})]
-         (.setJobFactory quartz (make-job-factory scheduler))
-         scheduler))))
+       (map->Scheduler {::quartz quartz ::name n}))))

 ;; TODO should be extendable
 (defn matcher


Create dist atom resources with test name

--- src/atomix_jepsen/core.clj
+++ src/atomix_jepsen/core.clj
@@ -115,7 +115,7 @@
           (let [client (trinity/client node-set)]
             (debug node "Client connected!")
             (assoc this :client client)
-            (assoc this :register (trinity/dist-atom client "register"))))
+            (assoc this :register (trinity/dist-atom client (:name test)))))
         #(do
           (debug node "Connection attempt failed. Retrying..." %)
           (Thread/sleep 2000)))))


Don't run indefinitely

Don't run indefinitely

--- src/bejeweled_bot/core.clj
+++ src/bejeweled_bot/core.clj
@@ -36,7 +36,7 @@
   ;solve
   ;move
   (def finished (promise))
-  (def timer (future (Thread/sleep 910000) (deliver finished true)))
+  (def timer (future (Thread/sleep 100000) (deliver finished true))) ;run for 100 seconds
     (dorun (map
       (fn [screenshot]
         (let


Improve test-block-store reporting.

Improve test-block-store reporting.

--- src/blocks/store/tests.clj
+++ src/blocks/store/tests.clj
@@ -94,6 +94,17 @@
                  (pr-str {:after after, :limit limit})))))))

+(defmacro ^:private test-section
+  [title & body]
+  `(do (printf "    * %s\n" ~title)
+       (let [start# (System/nanoTime)
+             result# (testing ~title
+                       ~@body)]
+         (printf "        %.3f ms\n"
+                 (/ (double (- (System/nanoTime) start#)) 1000000.0))
+         result#)))
+
+
 (defn test-block-store
   "Tests a block store implementation."
   [label store & {:keys [blocks max-size eraser]
@@ -102,27 +113,34 @@
     (throw (IllegalStateException.
              (str "Cannot run integration test on " (pr-str store)
                   " as it already contains blocks!"))))
-  (println "  *" label)
+  (printf "  Beginning %s integration tests...\n" label)
   (testing (.getSimpleName (class store))
-    (testing "querying non-existent block"
-      (is (nil? (block/stat store (multihash/sha1 "foo"))))
-      (is (nil? (block/get store (multihash/sha1 "bar")))))
-    (testing "put attributes"
-      (test-put-attributes store))
-    (let [stored-content (populate-blocks! store blocks max-size)]
-      (testing "list stats"
-        (let [stats (block/list store)]
-          (is (= (keys stored-content) (map :id stats))
-              "enumerates all ids in sorted order")
-          (is (every? #(= (:size %) (count (get stored-content (:id %)))) stats)
-              "returns correct size for all blocks"))
-        (test-list-stats store (keys stored-content) 10))
-      (doseq [[id content] stored-content]
-        (test-block store id content))
-      (let [[id content] (first (seq stored-content))]
-        (test-restore-block store id content))
-      (if eraser
-        (eraser store)
-        (doseq [id (keys stored-content)]
-          (is (true? (block/delete! store id)))))
-      (is (empty? (block/list store)) "ends empty"))))
+    (let [start-nano (System/nanoTime)]
+      (test-section "querying non-existent block"
+        (is (nil? (block/stat store (multihash/sha1 "foo"))))
+        (is (nil? (block/get store (multihash/sha1 "bar")))))
+      (test-section "put attributes"
+        (test-put-attributes store))
+      (let [stored-content (test-section (str "populating " blocks " blocks")
+                             (populate-blocks! store blocks max-size))]
+        (test-section "list stats"
+          (let [stats (block/list store)]
+            (is (= (keys stored-content) (map :id stats))
+                "enumerates all ids in sorted order")
+            (is (every? #(= (:size %) (count (get stored-content (:id %)))) stats)
+                "returns correct size for all blocks"))
+          (test-list-stats store (keys stored-content) 10))
+        (test-section "stored blocks"
+          (doseq [[id content] stored-content]
+            (test-block store id content)))
+        (test-section "re-storing block"
+          (let [[id content] (first (seq stored-content))]
+            (test-restore-block store id content)))
+        (test-section "erasing store"
+          (if eraser
+            (eraser store)
+            (doseq [id (keys stored-content)]
+              (is (true? (block/delete! store id)))))
+          (is (empty? (block/list store)) "ends empty")))
+      (printf "  Total time: %.3f ms\n"
+              (/ (double (- (System/nanoTime) start-nano)) 1000000.0)))))


fix ascii emoji set definition

fix ascii emoji set definition

--- src/chat/client/emoji.cljs
+++ src/chat/client/emoji.cljs
@@ -18,8 +18,6 @@
                        :title shortcode
                        :standby shortcode}))))

-
-(def ascii-set (set (keys ascii)))

 (def unicode {
 ":kiss_ww:" ["1f469-200d-2764-fe0f-200d-1f48b-200d-1f469","1f469-2764-1f48b-1f469"]
@@ -2201,4 +2199,4 @@
         "=#" ":no_mouth:"
     })

-
+(def ascii-set (set (keys ascii)))


expand-routes upgraded to function

expand-routes upgraded to function

--- src/clj/hellhound/http.clj
+++ src/clj/hellhound/http.clj
@@ -9,8 +9,18 @@
    [hellhound.http.handlers  :as handlers]))

 ;; hellhound.http.route shortcuts --------------------------
-(def router route/router)
-(def expand-routes route/expand-routes)
+(defn router
+  [routes]
+  (route/router routes))
+
+(defn expand-routes
+ "Produces and returns a sequence of route-maps from the given `route-spec`
+  (the route specification).
+
+  The return value is a verbose form of route-maps which is understandable by
+  Pedestal router."
+  [route-spec]
+  (route/expand-routes route-spec))

 ;; The default routes for a hellhound application.
 (def default-routes


Switch from :buildable-at to :can-build

Switch from :buildable-at to :can-build

--- src/cljs/zetawar/data.cljs
+++ src/cljs/zetawar/data.cljs
@@ -77,37 +77,50 @@
     :terrains
     {:plains        {:description "Plains"
                      :image "tilesets/elite-command/terrains/plains.png"
-                     :base-type false}
+                     :can-build []}
      :mountains     {:description "Mountains"
                      :image "tilesets/elite-command/terrains/mountains.png"
-                     :base-type false}
+                     :can-build []}
      :woods         {:description "Woods"
                      :image "tilesets/elite-command/terrains/woods.png"
-                     :base-type false}
+                     :can-build []}
      :desert        {:description "Desert"
                      :image "tilesets/elite-command/terrains/desert.png"
-                     :base-type false}
+                     :can-build []}
      :tundra        {:description "Tundra"
                      :image "tilesets/elite-command/terrains/tundra.png"
-                     :base-type false}
+                     :can-build []}
      :swamp         {:description "Swamp"
                      :image "tilesets/elite-command/terrains/swamp.png"
-                     :base-type false}
+                     :can-build []}
      :ford          {:description "Ford"
                      :image "tilesets/elite-command/terrains/ford.png"
-                     :base-type false}
+                     :can-build []}
      :shallow-water {:description "Shallow Water"
                      :image "tilesets/elite-command/terrains/shallow-water.png"
-                     :base-type false}
+                     :can-build []}
      :deep-water    {:description "Deep Water"
                      :image "tilesets/elite-command/terrains/deep-water.png"
-                     :base-type false}
+                     :can-build []}
      :base          {:description "Base"
                      :image "tilesets/elite-command/terrains/base-COLOR.png"
-                     :base-type true}
+                     :can-build [:infantry
+                                 :grenadier
+                                 :mortar
+                                 :ranger
+                                 :sniper
+                                 :medic
+                                 :engineer
+                                 :humvee
+                                 :tank
+                                 :heavy-tank
+                                 :artillery
+                                 :heavy-artillery]}
      :seaport       {:description "Seaport"
                      :image "tilesets/elite-command/terrains/seaport-COLOR.png"
-                     :base-type true}}
+                     :can-build [:frigate
+                                 :destroyer
+                                 :cruiser]}}

     :unit-state-maps
     {:move-attack-once
@@ -217,7 +230,6 @@
                 :capturing-armor 4
                 :repair 1
                 :state-map :move-attack-once
-                :buildable-at #{:base}
                 :image "tilesets/elite-command/units/infantry-COLOR.png"
                 :terrain-effects
                 {:plains    {:movement-cost 3 :armor-bonus  0 :attack-bonus  0}
@@ -247,7 +259,6 @@
                  :capturing-armor 6
                  :repair 1
                  :state-map :move-attack-once
-                 :buildable-at #{:base}
                  :image "tilesets/elite-command/units/grenadier-COLOR.png"
                  :terrain-effects
                  {:plains    {:movement-cost 4 :armor-bonus  0 :attack-bonus  0}
@@ -277,7 +288,6 @@
               :capturing-armor 4
               :repair 1
               :state-map :move-attack-once
-              :buildable-at #{:base}
               :image "tilesets/elite-command/units/mortar-COLOR.png"
               :terrain-effects
               {:plains    {:movement-cost 4 :armor-bonus  0 :attack-bonus  0}
@@ -305,7 +315,6 @@
               :capturing-armor 7
               :repair 1
               :state-map :move-attack-once
-              :buildable-at #{:base}
               :image "tilesets/elite-command/units/ranger-COLOR.png"
               :terrain-effects
               {:plains        {:movement-cost 3 :armor-bonus  0 :attack-bonus  0}
@@ -336,7 +345,6 @@
               :capturing-armor 3
               :repair 1
               :state-map :move-attack-once
-              :buildable-at #{:base}
               :image "tilesets/elite-command/units/sniper-COLOR.png"
               :terrain-effects
               {:plains    {:movement-cost 4 :armor-bonus  0 :attack-bonus  0}
@@ -364,7 +372,6 @@
              :capturing-armor 4
              :repair 1
              :state-map :move-attack-once
-             :buildable-at #{:base}
              :image "tilesets/elite-command/units/medic-COLOR.png"
              :terrain-effects
              {:plains    {:movement-cost 3 :armor-bonus  0 :attack-bonus  0}
@@ -394,7 +401,6 @@
                :capturing-armor 4
                :repair 1
                :state-map :move-attack-once
-               :buildable-at #{:base}
                :image "tilesets/elite-command/units/engineer-COLOR.png"
                :terrain-effects
                {:plains        {:movement-cost 3 :armor-bonus  0 :attack-bonus  0}
@@ -425,7 +431,6 @@
               :armor 8
               :repair 1
               :state-map :free-attack-twice
-              :buildable-at #{:base}
               :image "tilesets/elite-command/units/humvee-COLOR.png"
               :terrain-effects
               {:plains  {:movement-cost 3  :armor-bonus  0 :attack-bonus  0}
@@ -453,7 +458,6 @@
             :armor 12
             :repair 1
             :state-map :move-attack-once
-            :buildable-at #{:base}
             :image "tilesets/elite-command/units/tank-COLOR.png"
             :terrain-effects
             {:plains  {:movement-cost 3 :armor-bonus  0 :attack-bonus 0}
@@ -481,7 +485,6 @@
                   :armor 15
                   :repair 1
                   :state-map :move-attack-once
-                  :buildable-at #{:base}
                   :image "tilesets/elite-command/units/heavytank-COLOR.png"
                   :terrain-effects
                   {:plains  {:movement-cost 4 :armor-bonus  0 :attack-bonus 0}
@@ -509,7 +512,6 @@
                  :armor 6
                  :repair 1
                  :state-map :exclusive
-                 :buildable-at #{:base}
                  :image "tilesets/elite-command/units/artillery-COLOR.png"
                  :terrain-effects
                  {:plains  {:movement-cost 4 :armor-bonus  0 :attack-bonus  0}
@@ -535,7 +537,6 @@
                        :armor 8
                        :repair 1
                        :state-map :exclusive
-                       :buildable-at #{:base}
                        :image "tilesets/elite-command/units/heavyartillery-COLOR.png"
                        :terrain-effects
                        {:plains  {:movement-cost 2 :armor-bonus  0 :attack-bonus  0}
@@ -562,7 +563,6 @@
                :armor 8
                :repair 1
                :state-map :free-attack-twice
-               :buildable-at #{:seaport}
                :image "tilesets/elite-command/units/frigate-COLOR.png"
                :terrain-effects
                {:deep-water    {:movement-cost 1 :armor-bonus 0 :attack-bonus 0}
@@ -585,7 +585,6 @@
                  :armor 12
                  :repair 1
                  :state-map :free-attack-once
-                 :buildable-at #{:seaport}
                  :image "tilesets/elite-command/units/destroyer-COLOR.png"
                  :terrain-effects
                  {:deep-water {:movement-cost 1 :armor-bonus 0 :attack-bonus 0}
@@ -607,7 +606,6 @@
                :armor 15
                :repair 1
                :state-map :move-attack-twice
-               :buildable-at #{:seaport}
                :image "tilesets/elite-command/units/cruiser-COLOR.png"
                :terrain-effects
                {:deep-water {:movement-cost 1 :armor-bonus 0 :attack-bonus 0}


unit-at now recognizes can-repair

unit-at now recognizes can-repair

--- src/cljs/zetawar/subs.cljs
+++ src/cljs/zetawar/subs.cljs
@@ -248,6 +248,7 @@
                         :unit/type [:unit-type/id
                                     :unit-type/description
                                     :unit-type/can-capture
+                                    :unit-type/can-repair
                                     :unit-type/min-range
                                     :unit-type/max-range
                                     :unit-type/image]}]


Rethinking diff

Rethinking diff

--- src/cljx/transom/diff.cljx
+++ src/cljx/transom/diff.cljx
@@ -1,55 +1,47 @@
 (ns transom.diff)

 (defn snake
-  [^String s1 ^String s2 x k]
+  [^String s1 ^String s2 k y]
   (let [m (count s1)
         n (count s2)
-        y (- x k)]
+        x (+ k y)]
     (loop [x x, y y]
       (if (and (< x m) (< y n) (= (.charAt s1 x) (.charAt s2 y)))
         (recur (inc x) (inc y))
-        x))))
+        y))))

 (defn diagonals
   [cost]
   (range (- cost) (inc cost) 2))

 (defn furthest
-  [s1 s2 prev cost]
+  [s1 s2 k-map cost]
   (reduce
-    (fn [endpoints k]
-      (let [below (get endpoints (dec k) -1)
-            above (get endpoints (inc k) -1)
-            x (if (and (< k cost) (< below above))
-                above
-                (inc below))]
-        (assoc endpoints k (snake s1 s2 x k))))
-    prev
+    (fn [k-map k]
+      (let [below (k-map (dec k) -1)
+            above (k-map (inc k) -1)
+            ;; if (= below above) then below is the further k
+            y (if (and (> k (- cost)) (> below above))
+                below
+                (inc above))]
+        (assoc k-map k (snake s1 s2 k y))))
+    k-map
     (diagonals cost)))

-(defn iterate-search
-  [s1 s2]
-  (let [m (count s1)
-        n (count s2)
-        goal-x m
-        goal-k (- m n)]
-    (loop [cost 0
-           out (list)]
-      (let [f-map (furthest s1 s2 (or (first out) {}) cost)
-            out (cons f-map out)
-            [max-k max-x] (apply max-key (fn [[k v]] (+ v k)) f-map)]
-        (if (and (>= max-k goal-k) (= max-x goal-x))
-          out
-          (recur (inc cost) out))))))
-
-(defn ->edit
-  [f-maps]
-  (reduce
-    (fn [edit f-map]
-      (list))
-    (list)
-    f-maps))
-
-(defn diff
-  [s1 s2]
-  (->edit (iterate-search s1 s2)))
+(defn iterate-furthest
+  ([s1 s2]
+    (iterate-furthest s1 s2 (+ (count s1) (count s2))))
+  ([s1 s2 max-cost]
+    (let [m (count s1)
+          n (count s2)
+          sink-k (- m n)
+          sink-y n]
+      (loop [cost 0, out (list)]
+        (if (> cost max-cost)
+          nil
+          (let [k-map (furthest s1 s2 (or (first out) {}) cost)
+                max-y (k-map sink-k)
+                out (cons k-map out)]
+            (if (= max-y sink-y)
+              out
+              (recur (inc cost) out))))))))


Add more examples

Add more examples

--- src/clojure/cjcb/codes.clj
+++ src/clojure/cjcb/codes.clj
@@ -108,3 +108,46 @@
 (safe-copy "./foo.txt" "./bar.txt") ;; false

 (safe-copy "./foo.txt" "./bar.txt" :overwrite true) ;; true
+
+(with-open [reader (clojure.java.io/reader "./foo.txt")
+            writer (clojure.java.io/writer "./bar.txt")]
+  (clojure.java.io/copy reader writer))
+
+;; 4.6: deleting files or directories
+(let [silently true]
+ (clojure.java.io/delete-file "./baz.txt" silently)) ;; true
+
+(defn safe-delete [file-path]
+  (if (.exists (clojure.java.io/file file-path))
+    (try
+      (clojure.java.io/delete-file file-path)
+      (catch Exception e (str "Exception: " (.getMessage e))))
+    false))
+
+(safe-delete "./foo.txt") ;; true
+(safe-delete "./invalid-file.txt") ;; false
+
+;; Delete directory
+(defn delete-directory [dir-path]
+  (let [dir-contents (file-seq (clojure.java.io/file dir-path))
+        files-to-delete (filter #(.isFile %) dir-contents)]
+    (doseq [file files-to-delete]
+      (safe-delete (.getPath file)))
+    (safe-delete dir-path)))
+
+;; If we have just one level of directory without sub-directory
+(delete-directory "./tmp") ;; true
+
+;; 4.7: listing files in a directory using `file-seq` function
+(def list-file (file-seq (clojure.java.io/file "./src")))
+
+list-file ;; (#object[java.io.File 0x29923f72 "./src"] #object[java.io.File 0x6f993ddc "./src/java"] #object[java.io.File 0x316a75a9 "./src/java/com"] #object[java.io.File 0x4c981747 "./src/java/com/examples"] #object[java.io.File 0x7449d809 "./src/java/com/examples/Client.java"] #object[java.io.File 0x52986c81 "./src/java/com/gentest"] #object[java.io.File 0x303d9c46 "./src/java/com/gentest/AbstractJavaClass.java"] #object[java.io.File 0x3c939729 "./src/clojure"] #object[java.io.File 0x6a09922 "./src/clojure/com"] #object[java.io.File 0x17cd0113 "./src/clojure/com/curry"] #object[java.io.File 0x4bce6000 "./src/clojure/com/curry/utils"] #object[java.io.File 0x6bc49c8f "./src/clojure/com/curry/utils/calculator.clj"] #object[java.io.File 0x69af715c "./src/clojure/com/curry/utils/calc"] #object[java.io.File 0x169520e3 "./src/clojure/com/curry/utils/calc/dcf.clj"] #object[java.io.File 0x2e639c51 "./src/clojure/com/curry/utils/calc/fcf.clj"] #object[java.io.File 0x610c4df6 "./src/clojure/com/gentest"] #object[java.io.File 0x733be51a "./src/clojure/com/gentest/genclojure.clj"] #object[java.io.File 0x4c9651a6 "./src/clojure/mcj"] #object[java.io.File 0x7ea5dd71 "./src/clojure/mcj/ch_xx.clj"] #object[java.io.File 0x7d454cae "./src/clojure/mcj/c02_agents.clj"] #object[java.io.File 0x517a7529 "./src/clojure/cjapplied"] #object[java.io.File 0x2f1f15c1 "./src/clojure/cjapplied/ch08.clj"] #object[java.io.File 0x7f011b06 "./src/clojure/cjfn"] #object[java.io.File 0x28f61874 "./src/clojure/cjfn/05_destructoring.clj"] #object[java.io.File 0x2a27f37e "./src/clojure/cjfn/07_control_flow.clj"] #object[java.io.File 0x7dc15ae6 "./src/clojure/cjfn/README.md"] #object[java.io.File 0xaefa773 "./src/clojure/cjfn/09_sequences.clj"] #object[java.io.File 0x12423be2 "./src/clojure/clojure"] #object[java.io.File 0x7eb86d7 "./src/clojure/clojure/script"] #object[java.io.File 0x708afaa6 "./src/clojure/clojure/script/examples.clj"] #object[java.io.File 0x7a91ffb "./src/clojure/cjcb"] #object[java.io.File 0x437b9c7 "./src/clojure/cjcb/.#codes.clj"] #object[java.io.File 0x5fb14aa8 "./src/clojure/cjcb/codes.clj"] #object[java.io.File 0x78c9c432 "./src/clojure/cjcb/#codes.clj#"] #object[java.io.File 0x37504a17 "./src/clojure/cjcb/.# *Minibuf-2*"] #object[java.io.File 0xe9034bb "./src/clojure/cfbt"] #object[java.io.File 0x5b21dbcb "./src/clojure/cfbt/ch09.clj"] #object[java.io.File 0x6d7f6cc9 "./src/clojure/cfbt/ch05.clj"] #object[java.io.File 0x58ca8383 "./src/clojure/cfbt/ch08.clj"] #object[java.io.File 0x577051cd "./src/clojure/cfbt/ch04.clj"] #object[java.io.File 0x2da376b "./src/clojure/cfbt/ch06.clj"] #object[java.io.File 0x14d51add "./src/clojure/cfbt/ch07.clj"] #object[java.io.File 0x180f455f "./src/clojure/cfbt/ch10.clj"] #object[java.io.File 0x4da491aa "./src/clojure/clojure_walkthrough"] #object[java.io.File 0x1e96861a "./src/clojure/clojure_walkthrough/cjia"] #object[java.io.File 0x22a964e7 "./src/clojure/clojure_walkthrough/cjia/ch05_xx.clj"] #object[java.io.File 0x406ee850 "./src/clojure/clojure_walkthrough/cjia/ch03_06.clj"] #object[java.io.File 0x29ae0836 "./src/clojure/clojure_walkthrough/cjia/ch04_xx.clj"] #object[java.io.File 0x322ed4f "./src/clojure/clojure_walkthrough/cjia/ch06_xx.clj"] #object[java.io.File 0x6a452f90 "./src/clojure/clojure_walkthrough/cjia/ch09_xx.clj"] #object[java.io.File 0x5d5e66e0 "./src/clojure/clojure_walkthrough/cjia/ch08_object.clj"] #object[java.io.File 0x4683ac5 "./src/clojure/clojure_walkthrough/cjia/ch03_05.clj"] #object[java.io.File 0x10b4f792 "./src/clojure/clojure_walkthrough/cjia/ch08_xx.clj"] #object[java.io.File 0x53ce63bb "./src/clojure/clojure_walkthrough/cjia/ch03_04.clj"] #object[java.io.File 0x7d096644 "./src/clojure/clojure_walkthrough/cjia/ch03_07.clj"] #object[java.io.File 0x3872d532 "./src/clojure/clojure_walkthrough/cjia/ch07_xx.clj"] #object[java.io.File 0xfcdbdc9 "./src/clojure/clojure_walkthrough/cjia/ch03_03.clj"] #object[java.io.File 0x2f3ec430 "./src/clojure/clojure_walkthrough/cjia/readme.md"] #object[java.io.File 0x19b3acd5 "./src/clojure/clojure_walkthrough/cjia/ch10_xx.clj"] #object[java.io.File 0x37c63194 "./src/clojure/clojure_walkthrough/core.clj"] #object[java.io.File 0x5507f150 "./src/resources"])
+
+;; Let's list only files
+
+(defn only-files
+  "Filter a sequence of files/directories by .isFile property of java.io.File"
+  [file-s]
+  (filter #(.isFile %) file-s))
+
+(only-files list-file) ;; (#object[java.io.File 0x7449d809 "./src/java/com/examples/Client.java"] #object[java.io.File 0x303d9c46 "./src/java/com/gentest/AbstractJavaClass.java"] #object[java.io.File 0x6bc49c8f "./src/clojure/com/curry/utils/calculator.clj"] #object[java.io.File 0x169520e3 "./src/clojure/com/curry/utils/calc/dcf.clj"] #object[java.io.File 0x2e639c51 "./src/clojure/com/curry/utils/calc/fcf.clj"] #object[java.io.File 0x733be51a "./src/clojure/com/gentest/genclojure.clj"] #object[java.io.File 0x7ea5dd71 "./src/clojure/mcj/ch_xx.clj"] #object[java.io.File 0x7d454cae "./src/clojure/mcj/c02_agents.clj"] #object[java.io.File 0x2f1f15c1 "./src/clojure/cjapplied/ch08.clj"] #object[java.io.File 0x28f61874 "./src/clojure/cjfn/05_destructoring.clj"] #object[java.io.File 0x2a27f37e "./src/clojure/cjfn/07_control_flow.clj"] #object[java.io.File 0x7dc15ae6 "./src/clojure/cjfn/README.md"] #object[java.io.File 0xaefa773 "./src/clojure/cjfn/09_sequences.clj"] #object[java.io.File 0x708afaa6 "./src/clojure/clojure/script/examples.clj"] #object[java.io.File 0x5fb14aa8 "./src/clojure/cjcb/codes.clj"] #object[java.io.File 0x78c9c432 "./src/clojure/cjcb/#codes.clj#"] #object[java.io.File 0x5b21dbcb "./src/clojure/cfbt/ch09.clj"] #object[java.io.File 0x6d7f6cc9 "./src/clojure/cfbt/ch05.clj"] #object[java.io.File 0x58ca8383 "./src/clojure/cfbt/ch08.clj"] #object[java.io.File 0x577051cd "./src/clojure/cfbt/ch04.clj"] #object[java.io.File 0x2da376b "./src/clojure/cfbt/ch06.clj"] #object[java.io.File 0x14d51add "./src/clojure/cfbt/ch07.clj"] #object[java.io.File 0x180f455f "./src/clojure/cfbt/ch10.clj"] #object[java.io.File 0x22a964e7 "./src/clojure/clojure_walkthrough/cjia/ch05_xx.clj"] #object[java.io.File 0x406ee850 "./src/clojure/clojure_walkthrough/cjia/ch03_06.clj"] #object[java.io.File 0x29ae0836 "./src/clojure/clojure_walkthrough/cjia/ch04_xx.clj"] #object[java.io.File 0x322ed4f "./src/clojure/clojure_walkthrough/cjia/ch06_xx.clj"] #object[java.io.File 0x6a452f90 "./src/clojure/clojure_walkthrough/cjia/ch09_xx.clj"] #object[java.io.File 0x5d5e66e0 "./src/clojure/clojure_walkthrough/cjia/ch08_object.clj"] #object[java.io.File 0x4683ac5 "./src/clojure/clojure_walkthrough/cjia/ch03_05.clj"] #object[java.io.File 0x10b4f792 "./src/clojure/clojure_walkthrough/cjia/ch08_xx.clj"] #object[java.io.File 0x53ce63bb "./src/clojure/clojure_walkthrough/cjia/ch03_04.clj"] #object[java.io.File 0x7d096644 "./src/clojure/clojure_walkthrough/cjia/ch03_07.clj"] #object[java.io.File 0x3872d532 "./src/clojure/clojure_walkthrough/cjia/ch07_xx.clj"] #object[java.io.File 0xfcdbdc9 "./src/clojure/clojure_walkthrough/cjia/ch03_03.clj"] #object[java.io.File 0x2f3ec430 "./src/clojure/clojure_walkthrough/cjia/readme.md"] #object[java.io.File 0x19b3acd5 "./src/clojure/clojure_walkthrough/cjia/ch10_xx.clj"] #object[java.io.File 0x37c63194 "./src/clojure/clojure_walkthrough/core.clj"])


webhook wip

webhook wip

--- src/gh_waiting_room/service.clj
+++ src/gh_waiting_room/service.clj
@@ -6,7 +6,9 @@
               [io.pedestal.service.interceptor :refer [defon-response]]
               [clostache.parser :refer [render-resource]]
               [tentacles.issues :refer [my-issues]]
+              [tentacles.repos :refer [create-hook]]
               clojure.string
+              [clojure.data.json :as json]
               [ring.util.response :as ring-resp]))

 (def db (atom {}))
@@ -33,6 +35,11 @@
 (defn- api-options
   []
   (merge {:filter "all" :all-pages true} (gh-auth)))
+
+(defn create-webhook []
+  (create-hook "cldwalker" "gh-waiting-room" "web"
+               {:url "http://localhost:8080/webhook" :content_type "json"}
+               (assoc (gh-auth) :events ["issues"])))

 (defn- issue-filter
   [issue]
@@ -79,6 +86,12 @@
                                   (map-indexed (fn [num elem]
                                                  (assoc elem :position (inc num)))))})))

+(defn webhook-page
+  [request]
+  (prn request)
+  (prn "PARAMS" (-> request :params))
+  {:status 200})
+
 (defon-response html-content-type
   [response]
   (ring-resp/content-type response "text/html"))
@@ -86,6 +99,7 @@
 (defroutes routes
   [[["/" {:get home-page}
      ^:interceptors [(body-params/body-params) html-content-type]
+     ["/webhook" {:post webhook-page}]
      ]]])

 ;; You can use this fn or a per-request fn via io.pedestal.service.http.route/url-for


ns complex example

ns complex example

--- src/hackerrank/clojure_libs.clj
+++ src/hackerrank/clojure_libs.clj
@@ -91,5 +91,13 @@

 ;; Bringing it all together: ns
 ;; ns is actually used often then require, use & import
-(ns my-great-project.core)
+;; (ns my-great-project.core)
 ;; gives namespace
+
+;; complex ns use
+(ns my-great-project.core
+  "This namespace is CRAZY!"
+  (:use [clojure.string :only [split join]] :reload)
+  (:require clojure.stactrace [clojure.test :as test]
+    (clojure template walk) :verbose)
+  (:import (java.util Date GregorianCalendar)))


Clean up code in frontend/play.cljs

Clean up code in frontend/play.cljs

--- src/hphelper/frontend/play.cljs
+++ src/hphelper/frontend/play.cljs
@@ -23,6 +23,35 @@
 (defonce ^:private ticker-keyword-atom
   (atom #{}))

+;; Helper Functions
+(defn- map-to-str
+  "Changes an access map into a single string"
+  [am]
+  (->> am
+    (map (fn [[k v]] (str (name k) " " (-> v (* 100) int (/ 100))
+                          )))
+    sort
+    (interpose ", ")
+    (apply str)
+    )
+  )
+(defn calculate-diffs
+  "Given 2 maps, returns a map with the numerical differences between both, (- first second)"
+  [[f s]]
+  (apply merge {} (map (fn [[k v]] {k (- (get f k) v)}) s))
+  )
+(defn- ^Map calculate-last-access
+  "Returns a string of the last access change"
+  []
+  (->> @game-atom
+       :access
+       (take 2)
+       calculate-diffs
+       (filter (fn [[_ v]] (not (= 0 v))))
+       )
+  )
+
+;; Getting updates from server and loading into state
 (defn load-updates
   "Loads a map of updates into the game atom"
   [m]
@@ -86,7 +115,17 @@
       )
     )
   )
+(defn get-sg-name
+  "Gets the name of a service group by service group id"
+  [id]
+  (->> @game-atom
+       :serviceGroups
+       (some (fn [{:keys [sg_id sg_name]}] (if (= id sg_id) sg_name nil)))
+       )
+  )

+;; Begin display components
+;; Display news
 (defn news-component
   "Component for displaying news items"
   []
@@ -115,6 +154,7 @@
       )
     )
   )
+;; Display cbay
 (defn cbay-component
   "Component for displaying cbay items (and later bidding on them)" ;; TODO cbay bids
   []
@@ -143,32 +183,7 @@
       )
     )
   )
-(defn- map-to-str
-  "Changes an access map into a single string"
-  [am]
-  (->> am
-    (map (fn [[k v]] (str (name k) " " (-> v (* 100) int (/ 100))
-                          )))
-    sort
-    (interpose ", ")
-    (apply str)
-    )
-  )
-(defn calculate-diffs
-  "Given 2 maps, returns a map with the numerical differences between both, (- first second)"
-  [[f s]]
-  (apply merge {} (map (fn [[k v]] {k (- (get f k) v)}) s))
-  )
-(defn- ^String calculate-last-access
-  "Returns a string of the last access change"
-  []
-  (->> @game-atom
-       :access
-       (take 2)
-       calculate-diffs
-       (filter (fn [[_ v]] (not (= 0 v))))
-       )
-  )
+;; Display access
 (defn access-component
   "Component for displaying cbay items (and later bidding on them)" ;; TODO cbay bids
   []
@@ -300,6 +315,7 @@
       )
     )
   )
+;; Display indicies
 (defn indicies-component
   "Component for displaying cbay items (and later bidding on them)" ;; TODO cbay bids
   []
@@ -381,6 +397,7 @@
       )
     )
   )
+;; Display society missions
 (defn display-single-society-mission
   [{:keys [ssm_id ss_id c_id ssm_text ss_name]}]
   ^{:key ssm_id} [:tr [:td (shared/wrap-any ss_name)] [:td ssm_text]]
@@ -413,6 +430,7 @@
       )
     )
   )
+;; Display minions
 (defn display-single-minion
   "Displays a single minion"
   [{:keys [minion_id minion_name minion_clearance minion_cost mskills bought?] :as minion} sgid]
@@ -542,14 +560,7 @@
      )
    ]
   )
-(defn get-sg-name
-  "Gets the name of a service group by service group id"
-  [id]
-  (->> @game-atom
-       :serviceGroups
-       (some (fn [{:keys [sg_id sg_name]}] (if (= id sg_id) sg_name nil)))
-       )
-  )
+;; Display directives
 (defn display-single-directive
   [{:keys [sgm_id sgm_text sg_id c_id]}]
   ^{:key sgm_id} [:tr [:td (get-sg-name sg_id)] [:td sgm_text]]
@@ -578,26 +589,7 @@
       )
     )
   )
-(defn missions-component
-  "Component for displaying both secret society missions and directives"
-  []
-  (let [expand-atom (atom false)]
-    (fn []
-      [:div {:class "panel-info"}
-       [:div {:class "panel-heading"
-              :onClick #(swap! expand-atom not)}
-        "Directive and Society Missions"
-        ]
-       (if @expand-atom
-         [:div {:class ""}
-          [society-missions-component]
-          [directives-component]
-          ]
-         )
-       ]
-      )
-    )
-  )
+;; Display Keywords
 (defn keywords-component
   "Displays all the keywords for the mission"
   []
@@ -620,6 +612,7 @@
       )
     )
   )
+;; Display secret society minions
 (defn program-group-component
   "Displays a single service group"
   []
@@ -659,6 +652,7 @@
       )
     )
   )
+;; Display investments
 (defn- investment-table-row
   "Returns a row of an investment table"
   [[k invest-map] sgs]
@@ -775,6 +769,7 @@
       )
     )
   )
+;; Display news ticker
 (defn- ^String news-read-access
   "Returns a string of a news reader detailing an access change"
   [^Map m]
@@ -898,7 +893,7 @@
       )
     )
   )
-
+;; Display character sheet
 (defn character-component
   "Component for displaying a character sheet"
   []
@@ -971,7 +966,7 @@
       )
     )
   )
-
+;; Display admin panel
 (defn- create-stat-roller
   "When pressed, rolls a number between 1 and 20 and displays the result in the status atom as a string"
   [^Atom status n ^String player ^String stat]
@@ -1066,7 +1061,6 @@
         )
    ]
   )
-
 (defn sync-player-files
   "Saves all the player files back in the database"
   []
@@ -1161,7 +1155,7 @@
       )
     )
   )
-
+;; Display public standing of players
 (defn public-standing-component
   "Displays user's public standing, as well as upcoming live vidshows"
   []
@@ -1238,6 +1232,7 @@
     )
   )

+;; Display panel for the game in total
 (defn game-component
   "Component for displaying and playing a game"
   [^Atom g]
@@ -1258,7 +1253,6 @@
      [:tr
       [:td {:style {:width "50%"}}
        [access-component]
-       ;[missions-component] ;; Removed due to figuring out how to remove the borders easily
        [directives-component]
        [society-missions-component]
        [indicies-component]
@@ -1286,6 +1280,7 @@
    [news-ticker-component ticker-keyword-atom]
    ]
   )
+;; Top-level display panel for logging into games
 (defn play-component
   "Top-end component for playing the game"
   []


queue: use a FixedThreadPool directly

queue: use a FixedThreadPool directly

--- src/io/cyanite/engine/queue.clj
+++ src/io/cyanite/engine/queue.clj
@@ -1,8 +1,9 @@
 (ns io.cyanite.engine.queue
   "Queueing mechanism at the heart of cyanite.
    This is how we "
-  (:require [com.climate.claypoole :as cp]
-            [clojure.tools.logging :refer [warn]]))
+  (:import java.util.concurrent.Executors
+           java.util.ArrayList)
+  (:require [clojure.tools.logging :refer [warn]]))

 (defonce default-poolsize 4)

@@ -11,10 +12,28 @@
   (add! [this k e])
   (stop! [this k]))

+(defn threadpool
+  [sz]
+  (Executors/newFixedThreadPool (int sz)))
+
+(defn pool-future-call
+  [p f]
+  (.submit p f))
+
+(defmacro with-future
+  [p & body]
+  `(pool-future-call ~p (fn [] ~@body)))
+
 (defn linked-queue
   [opts]
   (java.util.concurrent.ArrayBlockingQueue.
    (int (or (:queue-capacity opts) 10e3))))
+
+(defn drain!
+  [q]
+  (let [al (ArrayList.)]
+    (.drainTo q al)
+    al))

 (defn queue-engine
   [opts]
@@ -22,19 +41,19 @@
     (reify QueueEngine
       (consume! [this k opts f]
         (let [sz   (or (:pool-size opts) default-poolsize)
-              pool (cp/threadpool sz)
+              pool (threadpool sz)
               q    (linked-queue opts)]
           (swap! state assoc k {:pool pool :queue q})
           (dotimes [i sz]
-            (cp/future
-              pool
-              (loop [elem (.take q)]
+            (with-future pool
+              (loop [elems (drain! q)]
                 (try
-                  (f elem)
+                  (doseq [elem elems]
+                    (f elem))
                   (catch Exception e
                     (warn e "could not process element on queue" i "for" k)
                     (warn (:exception (ex-data e)) "original exception")))
-                (recur (.take q)))))))
+                (recur (drain! q)))))))
       (add! [this k e]
         (if-let [q (get-in @state [k :queue])]
           (.add q e)


nil arity constraint

nil arity constraint

--- src/latte/utils.clj
+++ src/latte/utils.clj
@@ -138,7 +138,7 @@
                        [(disj itypes param) (conj ltparams param)]
                        [itypes (conj ltparams '_)])) [implicit-types []] (rest param-ty))
            lt-expr (list handler-fn def-env-var ctx-var param-var)]
-       (when (not= (count lt-params) arity)
+       (when (and arity (not= (count lt-params) arity))
          (throw (ex-info "Wrong arity for implicit type parameter handling" {:expected-arity arity
                                                                              :parameter-type param-ty})))
        [implicit-types' (if (= implicit-types' implicit-types)


Rename get-pages to get-search-pages.

Rename get-pages to get-search-pages.

--- project/scrape-summitpost-data/src/scrape_summitpost_data/get_item_texts.clj
+++ project/scrape-summitpost-data/src/scrape_summitpost_data/get_item_texts.clj
@@ -15,7 +15,7 @@
   (let [page (slurp (str base-url link))]
     (or (extract-all-pager-links page) [link])))

-(defn- get-pages
+(defn- get-search-pages
   "Given a link to a search results page from summitpost, GET every search
   results page in the pagination (or just the page if no pagination) and
   return them as a lazy sequence."
@@ -30,7 +30,7 @@
   performs multiple GET requests."
   [link]
   (->> link
-       (get-pages)
+       (get-search-pages)
        (map reaver/parse)
        (map extract-result-links)
        (apply concat)


atom is not used

atom is not used

--- src/desdemona/ui/core.cljs
+++ src/desdemona/ui/core.cljs
@@ -1,6 +1,6 @@
 (ns desdemona.ui.core
   (:require [desdemona.ui.nav :refer [nav]]
-            [reagent.core :as r :refer [atom]]
+            [reagent.core :as r]
             [reagent.session :as session]
             [secretary.core :as secretary :include-macros true]
             [accountant.core :as accountant]))


fixing delete button

fixing delete button

--- src/eatme/client/main.cljs
+++ src/eatme/client/main.cljs
@@ -128,7 +128,7 @@

 (defn remove-item-from-list [item]
   ;; (:item item) is actually the delete button that was clicked
-  (d/detach! (-> item :item .-parentNode)))
+  (d/detach! (-> item :item .-parentNode .-parentNode)))

 (defn adjust-quantity [direction value]
   (condp = direction


beispiel tseitin

beispiel tseitin

--- src/examples/logelei_2.clj
+++ src/examples/logelei_2.clj
@@ -63,4 +63,8 @@
         '(impl beutelaffen-oinken  ohrhörner-surren)
         ))

-        +
+(-> fml
+    transform-tseitin
+    generate-dimacs-clauses
+    sat-solve)


Minor readbility fixes

Minor readbility fixes

--- src/foreclojure/static.clj
+++ src/foreclojure/static.clj
@@ -50,12 +50,12 @@
    [:br][:br]
    "Some operations are prohibited for security reasons.  For instance, you will not be able to use \"def\" or switch namespaces.  In addition, some problems have special restrictions.  For example, a function which is supposed to count the number of elements in a sequence will not be allowed to use the \"count\" function.  Obviously, this would defeat the purpose.  Any special restrictions will be listed on the problem page."
    [:br][:br]
-   "Many of the easier problems on this site can be solved using only your browser.  However at some point you will want to install Clojure, and use your favorite IDE or text editor to write your code.  We prefer using Emacs, but its totally a matter of personal preference.  Writing all your code directly on the site has a few disadvantages:"
+   "Many of the easier problems on this site can be solved using only your browser.  However at some point you will want to install Clojure, and use your favorite IDE or text editor to write your code.  We prefer using Emacs, but it's totally a matter of personal preference.  Writing all your code directly on the site has a few disadvantages:"
    [:br][:br]
    [:li "4Clojure is not an IDE, and doesn't try to be"]
    [:li "4Clojure won't save any of your code for later use"]
    [:br]
-   "Check out the official "
+   "Check out the official Clojure "
    [:a {:href "http://clojure.org/getting_started"} "getting started"]
    " page for help with installation."
    [:br][:br]


cleaned up rendering code a bit

cleaned up rendering code a bit

--- src/frontend/renderer.cljs
+++ src/frontend/renderer.cljs
@@ -74,14 +74,13 @@
 (defn user-upload-progress [data]
   (let [upload (first data)
         upload-info (second data)]
-    (dom/li nil (if-not (nil? upload)
-                  (list
-                    (dom/button #js {:onClick #(core/cancel-upload (.-id upload-info))}       "CANCEL")
-                    (if (:paused? ((:uploads @app-state/app-state) (:id upload)))
-                      (dom/button #js {:onClick #(core/resume-upload!  (:id upload))} "RESUME")
-                      (dom/button #js {:onClick #(core/pause-upload!   (:id upload))} "PAUSE"))
-                    (if-not (:started? upload)
-                      "STOPPED!")))
+    (dom/li nil (when-not (nil? upload)
+                  (dom/button #js {:onClick #(core/cancel-upload (.-id upload-info))}       "CANCEL")
+                  (if (:paused? ((:uploads @app-state/app-state) (:id upload)))
+                    (dom/button #js {:onClick #(core/resume-upload!  (:id upload))} "RESUME")
+                    (dom/button #js {:onClick #(core/pause-upload!   (:id upload))} "PAUSE"))
+                  (when-not (:started? upload)
+                    "STOPPED!"))
                 (((:users @app-state/app-state) (.-uploaderid upload-info)) "name")
                 " - " (* 100 (/ (.-bytesreceived upload-info) (.-totalsize upload-info))) "% - "
                 (.-filename upload-info))))


Fix #153 Convert RDF4j SimpleLiteral types into RDFLiteral records

--- src/grafter_2/rdf4j/io.clj
+++ src/grafter_2/rdf4j/io.clj
@@ -161,7 +161,7 @@
   ;; through, as it's not really up to grafter to fail the processing,
   ;; as they might just want to pass data through rather than
   ;; understand it.
-  literal)
+  (pr/->RDFLiteral (pr/raw-value literal) (pr/datatype-uri literal)))

 (defn quad->backend-quad
   "Convert a grafter IStatement into a backend (RDF4j) statement type."


Require Riccardo's Profiles.

Require Riccardo's Profiles.

--- src/kixi/hecuba/routes.clj
+++ src/kixi/hecuba/routes.clj
@@ -18,7 +18,7 @@
    [kixi.hecuba.api.projects :as projects]
    [kixi.hecuba.api.properties :as properties]
    [kixi.hecuba.api.entities :as entities]
-   ;; [kixi.hecuba.api.profiles :as profiles]
+   [kixi.hecuba.api.profiles :as profiles]
    [kixi.hecuba.api.devices :as devices]
    [kixi.hecuba.api.measurements :as measurements]
    [kixi.hecuba.api.rollups :as rollups]


Add onChange events to form.

Add onChange events to form.

--- src/lab_notebook/core.cljs
+++ src/lab_notebook/core.cljs
@@ -32,13 +32,22 @@
             (dom/input #js {:type "text"
                             :className "form-control"
                             :value (:summary state)
+                            :onChange (fn [e]
+                                        (om/set-state! component :summary
+                                          (-> e .-target .-value)))
                             :placeholder "Summary"})
             (dom/input #js {:type "text"
                             :className "form-control"
                             :value (:date-time state)
+                            :onChange (fn [e]
+                                        (om/set-state! component :date-time
+                                          (-> e .-target .-value)))
                             :placeholder "Time"})
             (dom/textarea #js {:className "form-control":placeholder "Notes"
                                :value (:notes state)
+                               :onChange (fn [e]
+                                           (om/set-state! component :notes
+                                             (-> e .-target .-value)))
                                :rows "5"})
             (dom/button #js {:className "btn btn-primary"
                              :onClick (fn [e]
@@ -46,9 +55,9 @@
                                         (om/transact! cursor :entries
                                           (fn [entries]
                                             ((fnil conj []) entries
-                                             {:summary "summary"
-                                              :date-time "date-time"
-                                              :notes "notes"}))))}
+                                             {:summary (:summary state)
+                                              :date-time (:date-time state)
+                                              :notes (:notes state)}))))}
               "Save")))))))

 (defn app-container [cursor component]


Reorganize service tests

Reorganize service tests

This commit doesn't contain any code changes; it just reorganizes
the tests a bit so that you can run them with a little more
granularity.  In particular, it separates all of the SSL tests
that are intended to result in a successful HTTPS request into
one deftest, and all of the ones that expect a failed HTTPS
request into a separate deftest.

--- test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_service_test.clj
+++ test/clj/puppetlabs/trapperkeeper/services/webserver/jetty9_service_test.clj
@@ -191,7 +191,7 @@
             (with-app-with-empty-config app [jetty9-service])))
       "Did not encounter expected exception when no port specified in config")))

-(deftest ssl-test
+(deftest ssl-success-test
   (testing "ring request over SSL successful for both .jks and .pem
             implementations with the server's client-auth setting not set and
             the client configured provide a certificate which the CA can
@@ -206,6 +206,47 @@
           config
           default-options-for-https)))

+  (testing "ring request over SSL succeeds with a server client-auth setting
+            of 'need' and the client configured to provide a certificate which
+            the CA can validate"
+    (validate-ring-handler
+      "https://localhost:8081"
+      "jetty-ssl-pem-client-auth-need.ini"
+      default-options-for-https))
+
+  (testing "ring request over SSL succeeds with a server client-auth setting
+            of 'want' and the client configured to provide a certificate which
+            the CA can validate"
+    (validate-ring-handler
+      "https://localhost:8081"
+      "jetty-ssl-pem-client-auth-want.ini"
+      default-options-for-https))
+
+  (testing "ring request over SSL succeeds with a server client-auth setting
+            of 'want' and the client configured to not provide a certificate"
+    (validate-ring-handler
+      "https://localhost:8081"
+      "jetty-ssl-pem-client-auth-want.ini"
+      (assoc default-options-for-https
+        :keystore nil)))
+
+  (testing "ring request over SSL succeeds with a server client-auth setting
+            of 'none' and the client configured to provide a certificate which
+            the CA can validate"
+    (validate-ring-handler
+      "https://localhost:8081"
+      "jetty-ssl-pem-client-auth-none.ini"
+      default-options-for-https))
+
+  (testing "ring request over SSL succeeds with a server client-auth setting
+            of 'none' and the client configured to not provide a certificate"
+    (validate-ring-handler
+      "https://localhost:8081"
+      "jetty-ssl-pem-client-auth-none.ini"
+      (assoc default-options-for-https
+        :keystore nil))))
+
+(deftest ssl-failure-test
   (testing "ring request over SSL fails with the server's client-auth setting
             not set and the client configured to provide a certificate which
             the CA cannot validate"
@@ -235,14 +276,6 @@
             "https://localhost:8081"
             "jetty-ssl-pem.ini"))))

-  (testing "ring request over SSL succeeds with a server client-auth setting
-            of 'need' and the client configured to provide a certificate which
-            the CA can validate"
-    (validate-ring-handler
-      "https://localhost:8081"
-      "jetty-ssl-pem-client-auth-need.ini"
-      default-options-for-https))
-
   (testing "ring request over SSL fails with a server client-auth setting
             of 'need' and the client configured to provide a certificate which
             the CA cannot validate"
@@ -264,14 +297,6 @@
             "https://localhost:8081"
             "jetty-ssl-pem-client-auth-need.ini"))))

-  (testing "ring request over SSL succeeds with a server client-auth setting
-            of 'want' and the client configured to provide a certificate which
-            the CA can validate"
-    (validate-ring-handler
-      "https://localhost:8081"
-      "jetty-ssl-pem-client-auth-want.ini"
-      default-options-for-https))
-
   (testing "ring request over SSL fails with a server client-auth setting
             of 'want' and the client configured to provide a certificate which
             the CA cannot validate"
@@ -285,22 +310,6 @@
                    (str test-resources-config-dir
                         "ssl/certs/unauthorized.pem"))))))

-  (testing "ring request over SSL succeeds with a server client-auth setting
-            of 'want' and the client configured to not provide a certificate"
-    (validate-ring-handler
-      "https://localhost:8081"
-      "jetty-ssl-pem-client-auth-want.ini"
-      (assoc default-options-for-https
-             :keystore nil)))
-
-  (testing "ring request over SSL succeeds with a server client-auth setting
-            of 'none' and the client configured to provide a certificate which
-            the CA can validate"
-    (validate-ring-handler
-      "https://localhost:8081"
-      "jetty-ssl-pem-client-auth-none.ini"
-      default-options-for-https))
-
   (testing "ring request over SSL fails with a server client-auth setting
             of 'none' and the client configured to provide a certificate which
             the CA cannot validate"
@@ -310,15 +319,7 @@
       (assoc default-options-for-https
              :keystore
              (str test-resources-config-dir
-                  "ssl/unauthorized_keystore.jks"))))
-
-  (testing "ring request over SSL succeeds with a server client-auth setting
-            of 'none' and the client configured to not provide a certificate"
-    (validate-ring-handler
-      "https://localhost:8081"
-      "jetty-ssl-pem-client-auth-none.ini"
-      (assoc default-options-for-https
-        :keystore nil))))
+                  "ssl/unauthorized_keystore.jks")))))

 (deftest test-proxy-servlet
   (let [common-ssl-config {:ssl-cert    "./test-resources/config/jetty/ssl/certs/localhost.pem"
@@ -448,4 +449,4 @@
           (is (= (:body response) "Hello, World!")))
         (let [response (http-get "https://localhost:10001/hello-proxy/world" default-options-for-https)]
           (is (= (:status response) 200))
-          (is (= (:body response) "Hello, World!")))))))+          (is (= (:body response) "Hello, World!")))))))


Docstrings

Docstrings

--- src/metabase/util/urls.clj
+++ src/metabase/util/urls.clj
@@ -18,14 +18,14 @@
 (defn dashboard-url
   "Return an appropriate URL for a `Dashboard` with ID.

-     (dashboard-url 10) -> \"http://localhost:3000/dash/10\""
+     (dashboard-url 10) -> \"http://localhost:3000/dashboard/10\""
   [^Integer id]
   (format "%s/dashboard/%d" (public-settings/site-url) id))

 (defn card-url
   "Return an appropriate URL for a `Card` with ID.

-     (card-url 10) -> \"http://localhost:3000/card/10\""
+     (card-url 10) -> \"http://localhost:3000/question/10\""
   [^Integer id]
   (format "%s/question/%d" (public-settings/site-url) id))


Added cleaner watches for conv-actors

Added cleaner watches for conv-actors

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -248,6 +248,11 @@
     @conv))

+(defn add-conv-actor-watch
+  [conv-actor key f]
+  (add-watch (:conv conv-actor) key f))
+
+
 (defn new-conv-actor [init-fn & opts]
   (let [msgbox (chan Long/MAX_VALUE) ; we want this to be as big as possible, since backpressure doesn't really work
         conv (atom (init-fn)) ; keep track of conv state in atom so it can be dereffed


Don't run wrap-request-logger for requests that fetch swagger ui files

--- src/ruuvi/ring_handler.clj
+++ src/ruuvi/ring_handler.clj
@@ -47,8 +47,8 @@
       (wrap-authentication (sec/auth-backend auth-conf))
       rook/wrap-with-standard-middleware
       (rook/wrap-with-injections {:auth-conf auth-conf})
+      (middleware/wrap-request-logger request-counter)
       (swagger/wrap-swagger-ui "/doc" "/api/swagger.json")
-      (middleware/wrap-request-logger request-counter)
       middleware/wrap-x-forwarded-for
       (cors/wrap-cors
        :access-control-allow-origin #".*"


[format] Add rest of test case that I accidentally deleted

Updates #49.

--- format/testdata/issue49.clj
+++ format/testdata/issue49.clj
@@ -1,3 +1,18 @@
+(cond-> {}
+  true (assoc :a "a"
+              :b "b"))
+
+(cond->
+  {}
+  true (assoc :a "a"
+              :b "b"))
+
+(cond->
+  {}
+  true
+    (assoc :a "a"
+           :b "b"))
+
 (-> (assoc {}
       :a
         "a"


Tables for selected rounds

Tables for selected rounds

--- src/tango/cljs/client.cljs
+++ src/tango/cljs/client.cljs
@@ -449,7 +449,32 @@
       (log "ZZZZZZZZZZZZZZZzz")
       (log adj)
       (dom/tr nil
-        (dom/td nil (:adjudicator/name adj))))))
+        (dom/td nil (:adjudicator/name adj))
+        (dom/td nil "0/16")
+        (dom/td nil "X")))))
+
+(defui SelectedRoundView
+  static om/IQuery
+  (query [_])
+  Object
+  (render
+    [this]
+    (let [activity (om/props this)
+          round (:activity/source activity)]
+      (dom/div nil
+        (dom/h4 nil (str "Round: " (:activity/name activity)))
+        (dom/table
+          #js {:className "table table-hover table-condensed"}
+          (dom/thead nil
+            (dom/tr nil
+              (dom/th #js {:width "200"} "Adjudicator")
+              (dom/th #js {:width "200"} "# marks")
+              (dom/th #js {:width "200"} "Confirmed?")))
+          (apply dom/tbody nil (map #((om/factory RoundAdjudicatorView) %)
+                                    (:adjudicator-panel/adjudicators
+                                      (:round/panel round))))
+          )
+        ))))

 (defui SelectedRoundsView
   static om/IQuery
@@ -462,29 +487,8 @@
   Object
   (render
     [this]
-    (let [sa (:selected-activity (om/props this))
-          class (:activity/source (om/props this))
-
-          test (:activity/source (first sa))]
-      (log "7777777777777777777777777777777")
-      (log sa)
-      (dom/div nil
-        (dom/h2 nil (str "Count " (count sa)))
-        (dom/div nil
-          (dom/h4 nil (str (:activity/name test)))
-          (dom/table
-            #js {:className "table table-hover table-condensed"}
-            (dom/thead nil
-              (dom/tr nil
-                (dom/th #js {:width "200"} "Adjudicator")
-                (dom/th #js {:width "200"} "# marks")
-                (dom/th #js {:width "200"} "Confirmed?")))
-            (apply dom/tbody nil (map #((om/factory RoundAdjudicatorView) %)
-                                      (:adjudicator-panel/adjudicators
-                                        (:round/panel test))))
-            )
-          )
-        ))))
+    (dom/div nil
+      (map #((om/factory SelectedRoundView) %) (:selected-activity (om/props this))))))

 (defui ScheduleView
   static om/IQuery


project.clj reverted to follow the wiki instructions.

--- deploy/project.clj
+++ deploy/project.clj
@@ -4,12 +4,13 @@
   :aot :all
   :jvm-opts ["-Xmx128m" "-Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib"
             ]
-
-  :dev-dependencies [
+  :dependencies[
 		     [jsqlparser "0.7.0"]
 		     [trove "3.0.2"]
 		     [bheaven "0.0.3"]
+  ]

+  :dev-dependencies [
 		     [org.clojure/clojure "1.4.0"]
                      [storm "0.8.2"]
                     ])


Fixing show version to strip quotes

Fixing show version to strip quotes

--- src/think/release/core.clj
+++ src/think/release/core.clj
@@ -33,7 +33,8 @@
   (let [snapshot? (.endsWith version-string snapshot-indicator)
         version-string (if snapshot?
                          (.substring version-string 0 (- (.length version-string)
-                                                         (.length ^String snapshot-indicator))))
+                                                         (.length ^String snapshot-indicator)))
+                         version-string)
         matcher (re-matcher version-regex version-string)
         groups (vec (drop 1 (re-find matcher)))]
     (when-not (seq groups)
@@ -63,8 +64,8 @@

 (defn ^:private version->string
   [version]
-  (format "\"%s.%s.%s%s%s\"" (:major version) (:minor version) (:bugfix version)
-          (:rest version) (if (:snapshot version) "-SNAPSHOT" "")))
+  (format "%s.%s.%s%s%s" (:major version) (:minor version) (:bugfix version)
+          (:rest version) (if (:snapshot? version) "-SNAPSHOT" "")))

 (defn ^:private write-version-to-project
@@ -133,6 +134,9 @@
       proj-dir)))

+(defn ^:private project-list
+  []
+  (recurse-find-project-files (project-directory)))

 (defn ^:private bump-project-version
@@ -144,9 +148,11 @@
                    (str "-"
                     (.format (SimpleDateFormat. "yyyy-MM-dd-hh-mm") (Date.)))
                    ""))
-    (if (= "" (or (get version :rest) ""))
-      (update version :bugfix #(inc (or % 0)))
-      (assoc version :rest ""))))
+    (-> (if (= "" (or (get version :rest) ""))
+          (update version :bugfix #(inc (or % 0)))
+          (assoc version :rest ""))
+        (assoc :snapshot? true))))
+

 (defn ^:private project-version
@@ -164,14 +170,12 @@
 (defn list-projects
   [& args]
   (clojure.pprint/pprint [(project-directory)
-                          (recurse-find-project-files (project-directory))]))
+                          (project-list)]))

 (defn show-project-version
   [& args]
-  (println (-> (project-directory)
-               recurse-find-project-files
-               project-version)))
+  (println (project-version (project-list))))

 (defn set-version


Interim change in changing to monger

Interim change in changing to monger

--- src/timetracker/models.clj
+++ src/timetracker/models.clj
@@ -2,8 +2,6 @@
   (:require [somnium.congomongo :as mongo]))

 (defn now [] (new java.util.Date))
-
-(defn post_processor [data] (assoc-in data [:project_id] "processed"))

 (defn create [task]
   (println (str "Added " task " at " (now) ))
@@ -11,8 +9,7 @@

 (defn process []
   (println "start post process ...")
-  (let [data (mongo/fetch :tasks)
-        transformed-data (doall (map post_processor data))]
-        (mongo/update! :tasks data transformed-data :multiple true))
+  (let [data (mongo/fetch-one :tasks)]
+        (mongo/update! :tasks data (merge data {:project_id "processed"})))
   (println "... end  post process."))


Extra dox for Settings :page_facing_up:

Extra dox for Settings :page_facing_up:

--- src/metabase/models/setting.clj
+++ src/metabase/models/setting.clj
@@ -139,8 +139,10 @@
        (format  "    (%s)\n\n" symb)
        "and set its value by calling\n\n"
        (format "    (%s <new-value>)\n\n" symb)
+       (format "You can also set its value with the env var `MB_%s`.\n"
+               (s/upper-case (s/replace (name symb) #"-" "_")))
        "Clear its value by calling\n\n"
-       (format "    (%s nil)." symb)
+       (format "    (%s nil)" symb)
        (when default-value
          (format "\n\nIts default value is `%s`." default-value))))


`parseInt` => `valueOf`

`parseInt` => `valueOf`

--- src/kixi/datastore/schemastore/conformers.clj
+++ src/kixi/datastore/schemastore/conformers.clj
@@ -8,7 +8,7 @@
     x
     (if (string? x)
       (try
-        (Integer/parseInt x)
+        (Integer/valueOf x)
         (catch Exception e
           :clojure.spec/invalid))
       :clojure.spec/invalid)))


fix name

fix name

--- src/shared/dato/db/utils.cljc
+++ src/shared/dato/db/utils.cljc
@@ -119,6 +119,6 @@

 (defn ref-attr? [db attrid]
   #?(:clj  (= :db.type/ref (:value-type (d/attribute db attrid)))
-     :cljs (-> (qe-by db :db/ident attr-name)
+     :cljs (-> (qe-by db :db/ident attrid)
                :db/valueType
                (= :db.type/ref))))


add one more test to the wrapper query's props

--- src/test/compassus/tests.cljc
+++ src/test/compassus/tests.cljc
@@ -715,7 +715,8 @@

 (defmethod remote-mixins-read :foo
   [{:keys [query target]} _ _]
-  {target true})
+  {:value {:bar 42}
+   target true})

 (def update-atom (atom {}))

@@ -769,7 +770,7 @@
                            :cljs (-> (.getRenderOutput shallow-renderer)
                                    (gobj/get "props") om/get-props om/unwrap))]
       (is (every? (partial contains? (om/get-computed wrapper-props)) [:owner :factory :props]))
-      )))
+      (is (= (-> wrapper-props :foo) {:bar 42})))))

 (defui MixinPostList
   static om/IQuery


Fix reflection warning from #3032 :wrench: :warning:

--- src/metabase/driver/druid/query_processor.clj
+++ src/metabase/driver/druid/query_processor.clj
@@ -1,5 +1,6 @@
 (ns metabase.driver.druid.query-processor
   (:require [clojure.core.match :refer [match]]
+            [clojure.math.numeric-tower :as math]
             [clojure.string :as s]
             [clojure.tools.logging :as log]
             [cheshire.core :as json]
@@ -559,7 +560,7 @@
   [columns]
   (vec (for [k columns]
          (case k
-            :distinct___count (comp #(Math/round %) k)
+            :distinct___count (comp math/round k)
             :timestamp___int  (comp (fn [^String s]
                                       (when (seq s)
                                         (Integer/parseInt s)))


fix #1023

fix #1023

--- src/status_im/chat/views/message/message.cljs
+++ src/status_im/chat/views/message/message.cljs
@@ -197,13 +197,13 @@
   [{:keys [content] :as message}]
   [message-view message
    (let [parsed-text  (parse-text content)
-         simple-text? (= (count parsed-text) 2)]
+         simple-text? (and (= (count parsed-text) 2)
+                           (nil? (second parsed-text)))]
      (if simple-text?
        [autolink {:style   (st/text-message message)
                   :text    (apply str parsed-text)
                   :onPress #(browse %)}]
-       [text {:style (st/text-message message)}
-        (parse-text content)]))])
+       [text {:style (st/text-message message)} parsed-text]))])

 (defmulti message-content (fn [_ message _] (message :content-type)))


sort topology summary by name

sort topology summary by name

--- storm-core/src/clj/backtype/storm/ui/core.clj
+++ storm-core/src/clj/backtype/storm/ui/core.clj
@@ -103,8 +103,8 @@
       (.get_num_executors t)
       (.get_num_tasks t)
       ])
-   :time-cols [2]
-   :sort-list "[[2,1]]"
+   :time-cols [3]
+   :sort-list "[[0,0]]"
    ))

 (defn supervisor-summary-table [summs]


Start zookeeper when testing dashboard

Start zookeeper when testing dashboard

--- metamorphosis-dashboard/src/main/clojure/com/github/killme2008/metamorphosis/dashboard/Server.clj
+++ metamorphosis-dashboard/src/main/clojure/com/github/killme2008/metamorphosis/dashboard/Server.clj
@@ -1,6 +1,6 @@
 (ns com.github.killme2008.metamorphosis.dashboard.Server
   (:import [com.taobao.metamorphosis.server.utils MetaConfig]
-           [com.taobao.metamorphosis.server.assembly MetaMorphosisBroker]
+           [com.taobao.metamorphosis.server.assembly MetaMorphosisBroker EmbedZookeeperServer]
            [com.taobao.metamorphosis.utils ZkUtils$ZKConfig])
   (:gen-class
    :methods [[start [com.taobao.metamorphosis.server.assembly.MetaMorphosisBroker] org.eclipse.jetty.server.Server]])
@@ -25,6 +25,7 @@
         _     (.loadFromFile config "dev/server.ini")
         broker (MetaMorphosisBroker. config)
         server (com.github.killme2008.metamorphosis.dashboard.Server.)]
+    (-> (EmbedZookeeperServer/getInstance) (.start))
     (.start broker)
     (-start server broker)))


Store full hash-id as file blob names.

Store full hash-id as file blob names.

--- src/vault/blob/store/file.clj
+++ src/vault/blob/store/file.clj
@@ -24,7 +24,7 @@
       (name algorithm)
       (subs digest 0 3)
       (subs digest 3 6)
-      (subs digest 6))))
+      (digest/path-str id))))

 (defn- file->id
@@ -34,10 +34,11 @@
     (when-not (.startsWith file root)
       (throw (IllegalArgumentException.
                (str "File " file " is not a child of root directory " root))))
-    (let [[algorithm & digest] (-> file
-                                   (subs (inc (count root)))
-                                   (string/split #"/"))]
-      (digest/hash-id algorithm (string/join digest)))))
+    (-> file
+        (subs (inc (count root)))
+        (string/split #"/")
+        last
+        digest/parse-id)))

 (defmacro ^:private for-files