New functionality: render-test-results in HTML form

--- src/emender_service/server.clj
+++ src/emender_service/server.clj
@@ -100,6 +100,14 @@
         (-> (http-response/response (html-renderer/render-configuration-page configuration))
             (http-response/content-type "text/html"))))

+(defn render-test-results
+    [request]
+    (let [job-id (-> request :params (get "job"))]
+        (if job-id
+            (let [output-html (db-interface/read-html-results-for-job-id job-id)]
+                (-> (http-response/response output-html)
+            (http-response/content-type "text/html"))))))
+
 (defn return-file
     "Creates HTTP response containing content of specified file.
      Special value nil / HTTP response 404 is returned in case of any I/O error."
@@ -154,7 +162,7 @@
         "/errors"                (render-errors         request)
         "/log"                   (render-log            request)
         "/configuration"         (render-configuration  request)
-        ))
+        "/rendered-test-results" (render-test-results   request)))

 (defn handler
     "Handler that is called by Ring for all requests received from user(s)."


dreher buchstaben

dreher buchstaben

--- src/hello_world/core.clj
+++ src/hello_world/core.clj
@@ -24,7 +24,7 @@

 ;(first (jdbc/query mysql-db [(str "select * from konten where Name='" name "'")])))
 (jdbc/execute! mysql-db ["UPDATE konten SET Kontostand = Kontostand - 1 WHERE Kontostand > 0 AND Name = ?" name])
-(jdbc/execute! mysql-db ["UPDATE konten SET Kontostand = Kontostand + 1 WHERE NurZahlen = 0 AND Name = ?" emfpaenger]))
+(jdbc/execute! mysql-db ["UPDATE konten SET Kontostand = Kontostand + 1 WHERE NurZahlen = 0 AND Name = ?" empfaenger]))
 ;(jdbc/update! mysql-db :konten {:Kontostand 99} ["Name = ?" name]))
 ; maybe this sets the guthaben to 99


move docstring to comment

move docstring to comment

Signed-off-by: Yen-Chin Lee <082d453d72dce940e12089a4ad48b97cfe1f3ec4@gmail.com>

--- src/emulator_chip8/opcode.cljc
+++ src/emulator_chip8/opcode.cljc
@@ -44,6 +44,7 @@
 (defn make-handler-sets
   "Create possible opcode set for opcode-list"
   [opcode]
+  ;; TODO: cljs lack format
   (let [code (format "%04X" opcode)
         ZNNN (format "%SNNN" (subs code 0 1))
         ZXNN (format "%SXNN" (subs code 0 1))
@@ -58,12 +59,13 @@
   "Parse the code to find how many VX, VY, NNN, NN, N
   and create argument lists."
   [opcode]
+  ;; TODO: cljs lack format
   (let [code (format "%04X" opcode)]
-    {:NNN (subs code 1 4)
-     :NN  (subs code 2 4)
-     :N   (subs code 3 4)
-     :VX  (subs code 1 2)
-     :VY  (subs code 2 3)}))
+    {:NNN (read-string (subs code 1 4))
+     :NN  (read-string (subs code 2 4))
+     :N   (read-string (subs code 3 4))
+     :VX  (read-string (subs code 1 2))
+     :VY  (read-string (subs code 2 3))}))

 (defn find-match-handler
   "Search for matching handler in handler list.
@@ -93,166 +95,167 @@
 ;; defmulti ?
 ;; http://www.braveclojure.com/multimethods-records-protocols/

+;; Execute machine language subroutine at address NNN
 (defop :0NNN
-  "Execute machine language subroutine at address NNN"
-  )
-
+  )
+
+;; Clear the screen
 (defop :00E0
-  "Clear the screen"
-  [])
-
+  )
+
+;; Return from a subroutine
 (defop :00EE
-  "Return from a subroutine"
-  [])
-
+  )
+
+;; Jump to address NNN
 (defop :1NNN
-  "Jump to address NNN"
   (merge state {:PC NNN}))

+;; Execute subroutine starting at address NNN
 (defop :2NNN
-  "Execute subroutine starting at address NNN"
-  )
-
+  )
+
+;; Skip the following instruction if the value of register VX equals NN
 (defop :3XNN
-  "Skip the following instruction if the value of register VX equals NN"
   (if (= (nth (:VX state) VX) NN)
     ;; skip next
     (println "TODO")
     ))

+;; Skip the following instruction if the value of register VX is not equal to NN
 (defop :4XNN
-  "Skip the following instruction if the value of register VX is not equal to
-  NN"
-  )
-
+  )
+
+;; Skip the following instruction if the value of register VX is equal to the
+;; value of register VY
 (defop :5XY0
-  "Skip the following instruction if the value of register VX is equal to the value of register VY"
-  )
-
+  )
+
+;; Store number NN in register VX.
 (defop :6XNN
-  "Store number NN in register VX."
   (merge state {:VX (assoc (:VX state) VX)})
   )

+;; Add the value NN to register VX.
 (defop :7XNN
-  "Add the value NN to register VX."
-  )
-
+  )
+
+;; Store the value of register VY in register VX.
 (defop :8XY0
-  "Store the value of register VY in register VX"
-  )
-
+  )
+
+;; Set VX to VX OR VY.
 (defop :8XY1
-  "Set VX to VX OR VY"
-  )
-
+  )
+
+;; Set VX to VX AND VY.
 (defop :8XY2
-  "Set VX to VX AND VY"
-  )
-
+  )
+
+;; Set VX to VX XOR VY.
 (defop :8XY3
-  "Set VX to VX XOR VY"
-  )
-
+  )
+
+;; Add the value of register VY to register VX.
+;;  Set VF to 1 if a carry occurs
+;;  Set VF to 0 if a carry does not occur.
 (defop :8XY4
-  "Add the value of register VY to register VX.
-  Set VF to 1 if a carry occurs
-  Set VF to 0 if a carry does not occur."
-  )
-
+  )
+
+;; Subtract the value of register VY from register VX
+;; Set VF to 0 if a borrow occurs
+;; Set VF to 1 if a borrow does not occur.
 (defop :8XY5
-  "Subtract the value of register VY from register VX
-  Set VF to 0 if a borrow occurs
-  Set VF to 1 if a borrow does not occur."
-  )
-
+  )
+
+;; Store the value of register VY shifted right one bit in register VX.
+;; Set register VF to the least significant bit prior to the shift.
 (defop :8XY6
-  "Store the value of register VY shifted right one bit in register VX.
-  Set register VF to the least significant bit prior to the shift."
-  )
-
+  )
+
+;; Set register VX to the value of VY minus VX
+;; Set VF to 00 if a borrow occurs
+;; Set VF to 01 if a borrow does not occur
 (defop :8XY7
-  "Set register VX to the value of VY minus VX
-  Set VF to 00 if a borrow occurs
-  Set VF to 01 if a borrow does not occur"
-  )
-
+  )
+
+;; Store the value of register VY shifted left one bit in register VX.
+;; Set register VF to the most significant bit prior to the shift.
 (defop :8XYE
-  "Store the value of register VY shifted left one bit in register VX.
-  Set register VF to the most significant bit prior to the shift."
-  )
-
+  )
+
+;; Skip the following instruction if the value of register VX is not equal to
+;; the value of register VY.
 (defop :9XY0
-  "Skip the following instruction if the value of register VX is not equal to
-  the value of register VY."
-  )
-
+  )
+
+;; Store memory address NNN in register I
 (defop :ANNN
-  "Store memory address NNN in register I"
-  )
-
+
+  )
+
+;; Jump to address NNN + V0
 (defop :BNNN
-  "Jump to address NNN + V0"
-  )
-
+  )
+
+;; Set VX to a random number with a mask of NN
 (defop :CXNN
-  "Set VX to a random number with a mask of NN"
-  )
-
+  )
+
+;; Draw a sprite at position VX, VY with N bytes of sprite data starting at the
+;; address stored in I. Set VF to 01 if any set pixels are changed to unset, and
+;; 00 otherwise
 (defop :DXYN
-  "Draw a sprite at position VX, VY with N bytes of sprite data starting at the
-  address stored in I. Set VF to 01 if any set pixels are changed to unset, and
-  00 otherwise"
-  )
-
+  )
+
+;; Skip the following instruction if the key corresponding to the hex value
+;; currently stored in register VX is pressed.
 (defop :EX9E
-  "Skip the following instruction if the key corresponding to the hex value
-  currently stored in register VX is pressed."
-  )
-
+  )
+
+;; Skip the following instruction if the key corresponding to the hex value
+;; currently stored in register VX is not pressed.
 (defop :EXA1
-  "Skip the following instruction if the key corresponding to the hex value
-  currently stored in register VX is not pressed."
-  )
-
+  )
+
+;; Store the current value of the delay timer in register VX.
 (defop :FX07
-  "Store the current value of the delay timer in register VX."
-  )
-
+  )
+
+;; Wait for a keypress and store the result in register VX.
 (defop :FX0A
-  "Wait for a keypress and store the result in register VX."
-  )
-
+  )
+
+;; Set the delay timer to the value of register VX.
 (defop :FX15
-  "Set the delay timer to the value of register VX."
-  )
-
+  )
+
+;; Set the sound timer to the value of register VX.
 (defop :FX18
-  "Set the sound timer to the value of register VX."
-  )
-
+  )
+
+;; Add the value stored in register VX to register I.
 (defop :FX1E
-  "Add the value stored in register VX to register I."
-  )
-
+  )
+
+;; Set I to the memory address of the sprite data corresponding to the
+;; hexadecimal digit stored in register VX.
 (defop :FX29
-  "Set I to the memory address of the sprite data corresponding to the
-  hexadecimal digit stored in register VX."
-  )
-
+  )
+
+;; Store the binary-coded decimal equivalent of the value stored in register VX
+;; at addresses I, I + 1, and I + 2.
 (defop :FX33
-  "Store the binary-coded decimal equivalent of the value stored in register VX
-  at addresses I, I + 1, and I + 2."
-  )
-
+  )
+
+;; Store the values of registers V0 to VX inclusive in memory starting at
+;;  address I, I is set to I + X + 1 after operation.
 (defop :FX55
-  "Store the values of registers V0 to VX inclusive in memory starting at
-  address I, I is set to I + X + 1 after operation."
-  )
-
+  )
+
+;; Fill registers V0 to VX inclusive with the values stored in memory starting
+;; at address I, I is set to I + X + 1 after operation.
 (defop :FX65
-  "Fill registers V0 to VX inclusive with the values stored in memory starting
-  at address I, I is set to I + X + 1 after operation."
   )

 ;;;; Simple Testing Area
@@ -277,6 +280,7 @@
   (make-handler-sets 0xf155)  ; => #{:FXY5 :FNNN :FXYN :FX55 :F155 :FXNN}
   (make-handler-args 0xf155)  ; =>  {:NNN 155, :NN 55, :N 5, :VX 1, :VY 5}
   (find-match-handler @opcode-list 0xf155) ; => :FX55
+
   ;; build the opmap with :type
   (build-opmap 0xf155) ; => {:NNN 155, :NN 55, :N 5, :VX 1, :VY 5, :type :FX55}


Add a configuration property for the config file location.

--- metlog-agent/src/metlog_agent/core.clj
+++ metlog-agent/src/metlog_agent/core.clj
@@ -105,7 +105,7 @@
 (defn -main
   "Agent entry point"
   [& args]
-  (maybe-load-config-file "config.clj")
+  (maybe-load-config-file (config-property "agent.configurationFile" "config.clj"))

   (doseq [ [ poll-interval sensors ] (group-by :poll-interval (all-sensors))]
     (log/info "Scheduling poll job @" poll-interval "msec. for" (map :sensor-name sensors))


initial implementation

initial implementation

--- src/lt/plugins/auto_paren.cljs
+++ src/lt/plugins/auto_paren.cljs
@@ -78,6 +78,27 @@
                             (passthrough)))
                         (passthrough))))

+(defn pre-cursor-indent [ed {:keys [line ch]}]
+  (let [tabs (editor/option ed :indentWithTabs)
+        unit (editor/option ed :indentUnit)
+        precursor (.substring (editor/line ed line) 0 ch)
+        whitespace (count (re-find (if tabs #"^\t*$" #"^ *$") precursor))]
+    [(quot whitespace unit) (mod whitespace unit)]))
+
+(behavior ::backspace-indent
+          :triggers #{:backspace!}
+          :reaction (fn [ed]
+                      (if-not (or (editor/selection? ed)
+                                  (> (.-length (.getSelections (editor/->cm-ed ed))) 1))
+                        (let [cursor (editor/->cursor ed)
+                              unit (editor/option ed :indentUnit)
+                              [indent rem] (pre-cursor-indent ed cursor)
+                              cursor (if (> rem 0) (adjust-loc (editor/->cursor ed) (- unit rem)) cursor)
+                              [indent rem] (if (> rem 0) (pre-cursor-indent ed cursor) [indent rem])]
+                          (if (and (> indent 0) (zero? rem))
+                            (editor/replace ed (adjust-loc cursor (- unit)) cursor "")
+                            (passthrough)))
+                        (passthrough))))

 (cmd/command {:command :editor.close-pair
               :hidden true


install package sources in init phase

install package sources in init phase

--- main/src/dda/pallet/dda_managed_ide/infra/java_script.clj
+++ main/src/dda/pallet/dda_managed_ide/infra/java_script.clj
@@ -43,6 +43,20 @@
     :aptitude ["npm"]))

 (s/defn
+  init-nodejs
+  [facility :- s/Keyword
+   config :- NodeJs]
+  (let [{:keys [version]} config]
+    (actions/as-action
+      (logging/info (str facility "-init system: init-nodejs")))
+    (actions/package-source (str "nodejs_" version)
+      :aptitude
+      {:url (str "https://deb.nodesource.com/node_" version)
+       :release "bionic"
+       :scopes ["main"]
+       :key-url "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"})))
+
+(s/defn
   install-nodejs
   "get and install install-nodejs"
   [facility :- s/Keyword
@@ -50,14 +64,19 @@
   (let [{:keys [version]} config]
     (actions/as-action
       (logging/info (str facility "-install system: install-nodejs")))
-    (actions/package-source (str "nodejs_" version)
-      :aptitude
-      {:url (str "https://deb.nodesource.com/node_" version)
-       :release "bionic"
-       :scopes ["main"]
-       :key-url "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"})
-    (actions/package-manager :update)
     (actions/packages :aptitude ["nodejs"])))
+
+(s/defn
+  init-yarn
+  [facility :- s/Keyword]
+  (actions/as-action
+    (logging/info (str facility "-init system: init-yarn")))
+  (actions/package-source "yarn"
+    :aptitude
+    {:url "https://dl.yarnpkg.com/debian/"
+     :release "stable"
+     :scopes ["main"]
+     :key-url "https://dl.yarnpkg.com/debian/pubkey.gpg"}))

 (s/defn
   install-yarn
@@ -65,26 +84,23 @@
   [facility :- s/Keyword]
   (actions/as-action
     (logging/info (str facility "-install system: install-yarn")))
-  (actions/package-source "yarn"
+  (actions/packages :aptitude ["nodejs"]))
+
+(s/defn init-asciinema
+  [facility :- s/Keyword]
+  (actions/as-action
+    (logging/info (str facility "-init system: init-asciinema")))
+  (actions/package-source "asciinema"
     :aptitude
-    {:url "https://dl.yarnpkg.com/debian/"
-     :release "stable"
+    {:url "http://ppa.launchpad.net/zanchey/asciinema/ubuntu "
+     :release "bionic"
      :scopes ["main"]
-     :key-url "https://dl.yarnpkg.com/debian/pubkey.gpg"})
-  (actions/package-manager :update)
-  (actions/packages :aptitude ["nodejs"]))
+     :key-url "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x9D2E234C0F833EAD"}))

 (s/defn install-asciinema
   [facility :- s/Keyword]
   (actions/as-action
     (logging/info (str facility "-install-system: install-asciinema")))
-  (actions/package-source "asciinema"
-    :aptitude
-    {:url "http://ppa.launchpad.net/zanchey/asciinema/ubuntu "
-     :release "bionic"
-     :scopes ["main"]
-     :key-url "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x9D2E234C0F833EAD"})
-  (actions/package-manager :update)
   (actions/packages :aptitude ["asciinema" "imagemagick" "gifsicle"])
   (actions/exec-checked-script
     "install asciicast2gif"
@@ -103,6 +119,20 @@
             "https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh")
     ("chmod" "755" "boot")))

+(s/defn init-system
+  [facility :- s/Keyword
+   contains-java-script? :- s/Bool
+   js :- JavaScript
+   settings]
+  (let [{:keys [nodejs]} js]
+    (when contains-java-script?
+      (when (contains? js :nodejs)
+        (init-nodejs facility nodejs)))
+    (when (contains? settings :install-yarn)
+      (init-yarn facility))
+    (when (contains? settings :install-asciinema)
+       (init-asciinema facility))))
+
 (s/defn install-system
   [facility :- s/Keyword
    contains-java-script? :- s/Bool


Active and deleted words from glossary

Active and deleted words from glossary

--- src/zg/server.clj
+++ src/zg/server.clj
@@ -390,9 +390,11 @@
             "/active-words-in-whitelist"  (process-active-words  request title emender-page :whitelist)
             "/active-words-in-blacklist"  (process-active-words  request title emender-page :blacklist)
             "/active-words-in-atomic-typos"  (process-active-words     request title emender-page :atomic-typos)
+            "/active-words-in-glossary"      (process-active-words     request title emender-page :glossary)
             "/deleted-words-in-whitelist"    (process-deleted-words request title emender-page :whitelist)
             "/deleted-words-in-blacklist"    (process-deleted-words request title emender-page :blacklist)
             "/deleted-words-in-atomic-typos" (process-deleted-words     request title emender-page :atomic-typos)
+            "/deleted-words-in-glossary"     (process-deleted-words     request title emender-page :glossary)
             "/add-word-to-blacklist"    (process-add-word      request title emender-page :blacklist)
             ;"/find-words"       (process-find-words    request)
             "/add-words-to-whitelist"   (process-add-words     request title emender-page :whitelist)


Use larger entity for collision detection instead

--- dungeon-crawler/desktop/src-common/dungeon_crawler/utils.clj
+++ dungeon-crawler/desktop/src-common/dungeon_crawler/utils.clj
@@ -48,8 +48,8 @@
   [{:keys [x y x-feet y-feet id] :as e} e2 min-distance]
   (let [x-diff (- (+ x x-feet) (+ (:x e2) (:x-feet e2)))
         y-diff (- (+ y y-feet) (+ (:y e2) (:y-feet e2)))
-        x-distance (+ (min (entity-width e) (entity-width e2)) min-distance)
-        y-distance (+ (min (entity-height e) (entity-height e2)) min-distance)]
+        x-distance (+ (max (entity-width e) (entity-width e2)) min-distance)
+        y-distance (+ (max (entity-height e) (entity-height e2)) min-distance)]
     (and (not= id (:id e2))
          (> (:health e2) 0)
          (< (Math/abs (double x-diff)) x-distance)
@@ -104,8 +104,8 @@
   [{:keys [x y x-feet y-feet] :as npc} me]
   (let [x-diff (- (+ x x-feet) (+ (:x me) (:x-feet me)))
         y-diff (- (+ y y-feet) (+ (:y me) (:y-feet me)))
-        x-dist (+ (min (entity-width npc) (entity-width me)) attack-distance)
-        y-dist (+ (min (entity-height npc) (entity-height me)) attack-distance)]
+        x-dist (+ (max (entity-width npc) (entity-width me)) attack-distance)
+        y-dist (+ (max (entity-height npc) (entity-height me)) attack-distance)]
     [(get-npc-axis-velocity npc x-diff x-dist)
      (get-npc-axis-velocity npc y-diff y-dist)]))


fix rendering of todo items

fix rendering of todo items

--- labs/architecture-examples/om/src/todomvc/app.cljs
+++ labs/architecture-examples/om/src/todomvc/app.cljs
@@ -4,7 +4,7 @@
             [om.core :as om]
             [om.dom :as dom :include-macros true]
             [todomvc.utils :refer [pluralize now guid]]
-            [todomvc.item :as todo-item]))
+            [todomvc.item :as item]))

 (enable-console-print!)

@@ -35,7 +35,7 @@
                       :onChange #(toggle-all % todos)})
       (dom/ul #js {:id "todo-list"}
         (into-array
-          (map #(om/render todos [%] chans :id)
+          (map #(om/render item/todo-item todos [%] chans :id)
             todos (range (count todos))))))))

 (defn footer [{:keys [todos] :as app} opts]


CMR-4204: Updated db migration to truncate variable_name value before alter table.

--- metadata-db-app/src/migrations/060_update_var_association_var_name_length.clj
+++ metadata-db-app/src/migrations/060_update_var_association_var_name_length.clj
@@ -16,4 +16,5 @@
   "Migrates the database down from version 60."
   []
   (println "migrations.060-update-var-association-var-name-length down...")
+  (h/sql "update METADATA_DB.cmr_variable_associations set variable_name = SUBSTR(variable_name, 0, 80)")
   (h/sql "alter table METADATA_DB.cmr_variable_associations modify variable_name VARCHAR(80)"))


add specs

add specs

--- modules/reitit-middleware/src/reitit/ring/middleware/alpha/muuntaja.cljc
+++ modules/reitit-middleware/src/reitit/ring/middleware/alpha/muuntaja.cljc
@@ -1,12 +1,16 @@
 (ns reitit.ring.middleware.alpha.muuntaja
   (:require [muuntaja.core :as m]
-            [muuntaja.middleware]))
+            [muuntaja.middleware]
+            [clojure.spec.alpha :as s]))
+
+(s/def ::muuntaja (partial instance? m/Muuntaja))

 (defn create-format-middleware
   ([]
    (create-format-middleware m/default-options))
   ([options]
    {:name ::formats
+    :spec (s/keys :opt-un [::muuntaja])
     :compile (fn [{:keys [muuntaja]} _]
                (let [options (or muuntaja options)]
                  (if options


change ui route to correct folder

change ui route to correct folder

--- backend/src/lambdaui/core.clj
+++ backend/src/lambdaui/core.clj
@@ -46,7 +46,7 @@
             (route/resources "/" {:root "public"})
             (GET "/" [] (ring.util.response/redirect "ui/index.html"))
             (GET "/ui/config.js" [] (create-config pipeline))
-            (route/resources "/ui" {:root "public/target"})
+            (route/resources "/ui" {:root "public"})
             )))


reindex

reindex

--- src/ophion/db.clj
+++ src/ophion/db.clj
@@ -24,6 +24,19 @@
     (.setProperty base "storage.cassandra.keyspace" (or (name keyspace) "ophion"))
     (.setProperty base "storage.cassandra.frame-size-mb" "60")
     (JanusGraphFactory/open base)))
+
+(defn property-index-name
+  [index]
+  (string/join "-" (concat (map name (keys index)) ["index"])))
+
+(defn edge-index-name
+  [edge-label index]
+  (string/join
+   "-"
+   (concat
+    [(name edge-label)]
+    (sort (map name (keys index)))
+    ["vertex-centric-index"])))

 (defn janus-get-property-key
   [manage [key type]]
@@ -54,10 +67,6 @@
             db-index index)]
     (.buildCompositeIndex db)))

-(defn property-index-name
-  [index]
-  (string/join "-" (concat (map name (keys index)) ["index"])))
-
 (defn janus-get-property-index
   [manage index]
   (let [index-name (property-index-name index)]
@@ -85,15 +94,6 @@
         property-index (janus-get-property-index manage index)]
     (.get (.updateIndex manage property-index SchemaAction/REINDEX))
     (.commit manage)))
-
-(defn edge-index-name
-  [edge-label index]
-  (string/join
-   "-"
-   (concat
-    [(name edge-label)]
-    (sort (map name (keys index)))
-    ["vertex-centric-index"])))

 (defn janus-edge-index
   [graph edge-label index]


start a new document when you go to /

start a new document when you go to /

--- src/pc/server.clj
+++ src/pc/server.clj
@@ -6,6 +6,7 @@
             [compojure.core :refer (defroutes routes GET POST ANY)]
             [compojure.handler :refer (site)]
             [compojure.route]
+            [datomic.api :refer [db q] :as d]
             [org.httpkit.server :as httpkit]
             [pc.datomic :as pcd]
             [pc.http.datomic :as datomic]
@@ -16,6 +17,7 @@
             [pc.stefon]
             [ring.middleware.session :refer (wrap-session)]
             [ring.middleware.session.cookie :refer (cookie-store)]
+            [ring.util.response :refer (redirect)]
             [stefon.core :as stefon]))

 (defn log-request [req resp ms]
@@ -45,7 +47,12 @@
         ;; TODO: take tx-date as a param
         {:status 200
          :body (pr-str {:layers (layer/find-by-document (pcd/default-db) {:db/id (Long/parseLong id)})})})
-   (GET "/" [] (content/app))
+   (GET "/document/:document-id" [document-id]
+        (content/app))
+   (GET "/" []
+        (let [[document-id] (pcd/generate-eids (pcd/conn) 1)]
+          @(d/transact (pcd/conn) [{:db/id document-id :document/name "Untitled"}])
+          (redirect (str "/document/" document-id))))
    (compojure.route/resources "/" {:root "public"
                                    :mime-types {:svg "image/svg"}})
    (GET "/chsk" req ((:ajax-get-or-ws-handshake-fn sente-state) req))


save this fn to calculate the timespread of blocks

--- src/block_chain/queries.clj
+++ src/block_chain/queries.clj
@@ -133,3 +133,12 @@
 (defn wallet-addr [db] (get-in db [:default-key :address]))

 (defn root-block [db] (last (longest-chain db)))
+
+(defn blocks-time-spread [db]
+  (->> db
+       longest-chain
+       (drop-last)
+       (map #(get-in % [:header :timestamp]))
+       (partition 2 1)
+       (map (partial apply -))
+       (map #(/ % 1000.0))))


fix infinite loop in merge-source-maps.

fix infinite loop in merge-source-maps.

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -92,14 +92,15 @@
                new-cols
                (loop [col-map-seq (seq col-map) new-cols (sorted-map)]
                  (if col-map-seq
-                   (let [[col {:keys [gline gcol]}] (first col-map-seq)]
-                     (recur (rest col-map-seq)
+                   (let [[col infos] (first col-map-seq)]
+                     (recur (next col-map-seq)
                        (assoc new-cols col
-                         (get-in closure-map [(+ gline line-offset) gcol]))))
+                         (reduce (fn [v {:keys [gline gcol]}]
+                                   (into v (get-in closure-map [(+ gline line-offset) gcol])))
+                                 [] infos))))
                    new-cols))]
-           (recur (rest line-map-seq)
-             (assoc new-lines line
-               (new-cols))))
+           (recur (next line-map-seq)
+             (assoc new-lines line new-cols)))
          new-lines))))

 (comment


added read-edn-file

added read-edn-file

--- src/clj/datasplash/core.clj
+++ src/clj/datasplash/core.clj
@@ -1,6 +1,6 @@
 (ns datasplash.core
-  (:require [taoensso.nippy :as nippy :refer [thaw freeze]]
-            [cognitect.transit :as transit])
+  (:require [cognitect.transit :as transit]
+            [clojure.edn :as edn])
   (:import [datasplash.fns ClojureDoFn ClojureSerializableFn]
            [java.io InputStream OutputStream]
            [java.util UUID]
@@ -10,7 +10,7 @@
            [com.google.cloud.dataflow.sdk.transforms
             DoFn DoFn$Context ParDo DoFnTester Create PTransform
             SerializableFunction WithKeys GroupByKey]
-           [com.google.cloud.dataflow.sdk.values PCollection TupleTag]
+           [com.google.cloud.dataflow.sdk.values PCollection TupleTag PBegin]
            [com.google.cloud.dataflow.sdk.coders ByteArrayCoder StringUtf8Coder CustomCoder Coder$Context]
            [com.google.cloud.dataflow.sdk.transforms.join KeyedPCollectionTuple CoGroupByKey])
   (:gen-class))
@@ -111,6 +111,7 @@
     (.output c result)))

 (def to-edn (partial (map-op identity :to-edn (StringUtf8Coder/of)) to-edn*))
+(def from-edn (partial dmap #(edn/read-string %)))

 (defn sfn
   ^SerializableFunction [f]
@@ -175,13 +176,38 @@
                    (TextIO$Write/to to))))))
   ([to pcoll] (write-text-file to {} pcoll)))

+(defn read-text-file
+  ([from options ^PBegin p]
+   (let [opts (assoc options :label :read-text-file)]
+     (-> p
+         (.apply (with-opts base-schema opts
+                   (TextIO$Read/from from))))))
+  ([from p] (read-text-file from {} p)))
+
+(defn- read-edn-file-transform
+  [from options]
+  (let [safe-opts (dissoc options :name)]
+    (proxy [PTransform] []
+      (apply [p]
+        (->> p
+             (read-text-file from options)
+             (from-edn options))))))
+
+(defn read-edn-file
+  ([from options ^Pipeline p]
+   (let [opts (assoc options :label :read-edn-file)]
+     (-> p
+         (.apply (with-opts base-schema opts
+                   (read-edn-file-transform from opts))))))
+  ([from p] (read-edn-file from {} p)))
+
 (defn- write-edn-file-transform
   [to options]
   (let [safe-opts (dissoc options :name)]
     (proxy [PTransform] []
       (apply [^PCollection pcoll]
         (->> pcoll
-             (to-edn)
+             (to-edn options)
              (write-text-file to options))))))

 (defn write-edn-file
@@ -204,9 +230,7 @@

 (defn cogroup-transform
   ([options]
-   (let [opts (-> options
-                  (assoc :label :raw-cogroup)
-                  (dissoc :name))]
+   (let [opts (assoc options :label :raw-cogroup)]
      (proxy [PTransform] []
        (apply [^KeyedPCollectionTuple pcolltuple]
          (let [ordered-tags (->> pcolltuple
@@ -255,12 +279,16 @@
 (defn -main
   [& args]
   (let [p (make-pipeline args)
-        first-in (->> p
-                      (generate-input [{:key :a :foo 12} {:key :b :foo 5} {:key :a :foo 42} {:key :c :val "never"}] {:name "gengen1"}))
-        second-in (->> p
-                       (generate-input [{:key :a :val 10} {:key :b :val 5} {:key :a :val 42}] {:name "gengen"}))
-        final (->> (cogroup-by {:name :join} [[first-in :key] [second-in :key :required]] (fn [[k res]] (apply merge res)))
-                   (write-edn-file "tessst.edn" {:name :output-edn}))
+        proc (->> p
+                  (read-edn-file "sample.edn" {:name :input-edn})
+                  (dfilter (fn [{:keys [last-state] :as all}] (println all) (= last-state :sent)))
+                  (write-edn-file "tessst.edn" {:name :output-edn}))
+        ;; first-in (->> p
+        ;;               (generate-input [{:key :a :foo 12} {:key :b :foo 5} {:key :a :foo 42} {:key :c :val "never"}] {:name "gengen1"}))
+        ;; second-in (->> p
+        ;;                (generate-input [{:key :a :val 10} {:key :b :val 5} {:key :a :val 42}] {:name "gengen"}))
+        ;; final (->> (cogroup-by {:name :join} [[first-in :key] [second-in :key :required]] (fn [[k res]] (apply merge res)))
+        ;;            (write-edn-file "tessst.edn" {:name :output-edn}))
         ;; first-in (->> p
         ;;               (generate-input [{:key :a :foo 12} {:key :b :foo 5} {:key :a :foo 42}] {:name "gengen1"})
         ;;               (dgroup-by :key {:name :group-by-fi}))


update instructions

update instructions

--- src/clj/easynxc/handler.clj
+++ src/clj/easynxc/handler.clj
@@ -21,7 +21,7 @@
    [:body {:class "body-container"}
     [:div#app
      [:div {:class "main"}
-      [:p "hello and welcome to easynxc. to use this site find a video from youtube or soundcloud or something and add \"easynxc.com/\" to the beginning of it"]
+      [:p "hello and welcome to easynxc. to use this site find a video from youtube or soundcloud or something and add \"easynxc.com/\" to the beginning of the URL"]
       [:p "so if for example you wanted to try it with " [:a {:href "https://www.youtube.com/watch?v=5GL9JoH4Sws"} "https://www.youtube.com/watch?v=5GL9JoH4Sws"] ", you'd go to " [:a {:href "/https://www.youtube.com/watch?v=5GL9JoH4Sws"} "easynxc.com/https://www.youtube.com/watch?v=5GL9JoH4Sws"]]
       [:p "move the mouse to change speed, and click to lock/unlock your speed. when locked, your speed gets added to the URL so you can share with friends. i like the example at about 1.4x " [:a {:href "/https://www.youtube.com/watch?nxc=1.40&v=5GL9JoH4Sws"} "easynxc.com/https://www.youtube.com/watch?nxc=1.40&v=5GL9JoH4Sws"]]
       [:p [:a {:href "https://github.com/parkeristyping/easynxc-clj"} "github"]]]]]))


removed whitespace.

removed whitespace.

--- src/clj/forma/reproject.clj
+++ src/clj/forma/reproject.clj
@@ -3,7 +3,7 @@
 ;; sinusoidal grid at arbitrary resolution.

 (ns forma.reproject
-  (:use cascalog.api
+  (:use cascalog.api
         [forma.matrix.utils :only (idx->colrow
                                    colrow->idx)])
   (:require [forma.source.modis :as m]))


Corp state support for Corporate Scandal

--- src/clj/game/core-turns.clj
+++ src/clj/game/core-turns.clj
@@ -21,7 +21,7 @@
                         :hand (zone :hand (take 5 corp-deck))
                         :discard [] :scored [] :rfg [] :play-area []
                         :servers {:hq {} :rd{} :archives {}}
-                        :click 0 :credit 5 :bad-publicity 0
+                        :click 0 :credit 5 :bad-publicity 0 :has-bad-pub 0
                         :hand-size-base 5 :hand-size-modification 0
                         :agenda-point 0
                         :click-per-turn 3 :agenda-point-req 7 :keep false}


reduce qr code size

reduce qr code size

--- src/clj/salava/page/pdf.clj
+++ src/clj/salava/page/pdf.clj
@@ -191,7 +191,7 @@
                                                                [:table {:no-split-cells? true :width 100 :border false :cell-border false :spacing 5}
                                                                 [[:phrase.generic {:style :bold :size 12} (:tag %)]]
                                                                 [[:cell
-                                                                  [:table {:align :center :width-percent 100 :border false :num-cols 4 :padding 2}
+                                                                  [:table {:align :center :width-percent 100 :border false :num-cols 4 :padding 1}
                                                                    (into [[:cell {:colspan 5}]] (for [badge (:badges %)
                                                                                :let [b (pdf-generator-helper ctx user-id (list (:id badge)))
                                                                                content (-> b first :content first)]]
@@ -230,10 +230,10 @@

                                                                                [:spacer 0]]))))
                                                                             [[:cell {:colspan 2}[:line {:dotted true}]]]))
-                                                              [:table {:no-split-cells? true :width 100 :border false :cell-border false :spacing 5}
-                                                               [[:phrase.generic {:style :bold :size 12 :leading 20} (:title %)]]
+                                                              [:table {:no-split-cells? true :width 100 :border false :cell-border false :spacing 3}
+                                                               [[:phrase.generic {:style :bold :size 12} (:title %)]]
                                                                [[:cell
-                                                                 [:table {:align :center :width-percent 100 :border false :num-cols 4 :padding 2}
+                                                                 [:table {:align :center :width-percent 100 :border false :num-cols 4 :padding 1}
                                                                   (into [[:cell {:colspan 5}]] (for [badge (:badges %)
                                                                                :let [b (pdf-generator-helper ctx user-id (list (:id badge)))
                                                                                content (-> b first :content first)]]
@@ -307,7 +307,7 @@
                                content (-> (mapv template $blocks)
                                            (conj   [[:pdf-table {:align :right :width-percent 100 :cell-border false}
                                                      nil
-                                                     [[:pdf-cell [:paragraph [:chunk [:image {:width 85 :height 85 :base64 true} $qr_code]]"\n"
+                                                     [[:pdf-cell [:paragraph [:chunk [:image {:width 60 :height 60 :base64 true} $qr_code]]"\n"
                                                                   [:phrase [:chunk.link {:style :italic} (str site-url "/app/page/view/" $id)]]]]]]]))]


Convert positions sequence to vector for performance

--- src/cljam/pileup/pileup.clj
+++ src/cljam/pileup/pileup.clj
@@ -57,6 +57,7 @@
   (let [read-alignments-memo (memoize read-alignments)]
     (->> (rpositions start end)
          (partition-all step)
+         (map vec)
          (map (fn [positions]
                 (let [pos (if (= (count positions) step)
                             (nth positions center)


Optimizations

Optimizations

--- src/cljs/triboard/core.cljs
+++ src/cljs/triboard/core.cljs
@@ -119,17 +119,19 @@
    :looser :empty
    :taken [pos]})

-(defn with-available-moves ;; TODO - This should be optimized: much too slow (50-60 ms)
+(defn with-available-moves ;; TODO - This should be optimized: much too slow (35-60 ms)
   "Compute all available moves on the board"
   [{:keys [board] :as game}]
-  (merge game
-    {:moves
-     (into {}
-       (comp
-         (filter #(= (get-in board %) :empty))
-         (map (juxt identity #(available-moves-at board %))))
-       all-positions)}
-    ))
+  (time
+    (merge game
+     {:moves
+      (into {}
+        (comp
+          (filter #(= (get-in board %) :empty))
+          (map (juxt identity #(available-moves-at board %)))
+          (filter (comp not-empty second)))
+        all-positions)}
+     )))

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


Allow for blank args in defclass

Allow for blank args in defclass

Just as a convience to the user. If they forget to add the empty
parens for most of the methods, we just add it for them.

--- src/show/core.clj
+++ src/show/core.clj
@@ -2,16 +2,22 @@
   (:require [clojure.set :refer [difference]]))

 (def valid-lifecycle-methods
-  '#{initial-state default-props will-mount did-mount
+  '#{initial-state default-props render will-mount did-mount
      will-receive-props should-update will-update did-update
      will-unmount})
+
+(defn- allow-blank-arg-list [args body]
+  (if (and (not (nil? body)) (vector? args))
+    [args body]
+    [[] (conj body args)]))

 ;; To allow for a little sugar, we inject the symbol passed into defclass
 ;; to be mapped to this in the final lifecycle function.
 (defn- build-lifecycle-fn [component-arg [name args & body]]
-  (let [name       (keyword name)
-        final-args (vec (concat component-arg args))]
-    (hash-map name (concat '(fn) [final-args] body))))
+  (let [name        (keyword name)
+        [args body] (allow-blank-arg-list args body)
+        final-args  (vec (concat component-arg args))]
+    (hash-map name  (concat '(fn) [final-args] body))))

 (defn- extract-forms [forms]
   (if (string? (first forms))
@@ -23,7 +29,6 @@
     (assert (empty? misses)
             (str "Invalid lifecycle method names: ( " (clojure.string/join ", " misses) " )"))))

-
 (defmacro defclass
   "Defines a new React component class"
   [name & forms]


don't let a misbehaving ws-handler kill the loop

--- src/pc/server.clj
+++ src/pc/server.clj
@@ -119,7 +119,10 @@
     (async/tap mult tap)
     (async/go-loop []
                    (when-let [req (async/<! tap)]
-                     (ws-handler req)
+                     (try
+                       (ws-handler req)
+                       (catch Exception e
+                         (log/error e)))
                      (recur)))))

 (defn sente-init []


qa with stats

qa with stats

--- src/picsou/qa.clj
+++ src/picsou/qa.clj
@@ -4,10 +4,14 @@

 (defn go []
   (let [all (j/parse-string (slurp "resources/export.json"))
-        en (get (first (filter #(= "en" (% "body")) all)) "start")]
-    (doseq [[phrase start end] en]
-      (when (<= end (count phrase))
-        (let [s (subs phrase start end)
-              _ (prn s)
-              {:keys [winners] :as res} (p/parse s p/default-context :en$core [{:dim :time :label "T"}])]
-          (prn (map :value winners)))))))
+        en (get (first (filter #(= "en" (% "body")) all)) "start")
+        results (for [[phrase start' end'] en :when (<= end' (count phrase))]
+                  (let [s (subs phrase start' end')
+                        {:keys [winners] :as res} (p/parse s p/default-context :en$core [{:dim :time :label "T"}])
+                        {:keys [start end value] :as first-winner} (first winners)
+                        covers? (and start
+                                     (= 0 start)
+                                     (= (count s) end))]
+                    [s covers? value]))]
+    (prn (count results))
+    (prn (count (filter second results)))))


remove aside width style comment

remove aside width style comment

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -127,11 +127,7 @@
         (html
          [:aside.app-aside {:class (concat
                                     (when-not aside-opened? ["closed"])
-                                    (if chat-mobile-open? ["show-chat-on-mobile"] ["show-people-on-mobile"]))
-                            ; :style {:width (if aside-opened?
-                            ;                  (get-in app state/aside-width-path)
-                            ;                  0)}
-                            }
+                                    (if chat-mobile-open? ["show-chat-on-mobile"] ["show-people-on-mobile"]))}
           [:button.aside-switcher {:on-click #(cast! :chat-mobile-toggled)
                                    ;; :class (if chat-mobile-open? "chat-mobile" "people-mobile")
                                    }


SAP results row.

SAP results row.

--- src-cljs/kixi/hecuba/tabs/profiles.cljs
+++ src-cljs/kixi/hecuba/tabs/profiles.cljs
@@ -223,6 +223,26 @@
                (text-control profile_data state owner :appliances_strategy "Appliances Strategy")
                (text-control profile_data state owner :cellar_basement_issues "Cellar Basement Issues")])]))]))))

+(defn sap-results-row [profiles owner]
+  (reify
+    om/IRenderState
+    (render-state [_ state]
+      (html
+       [:div.col-md-12
+        (for [profile profiles]
+          (let [profile_data (:profile_data profile)]
+            [:div {:class (profile-column-width)}
+             (bs/panel
+              "SAP Results"
+              [:div
+               (text-control profile_data state owner :sap_rating "SAP Rating")
+               (text-control profile_data state owner :sap_performed_on "SAP Performed On")
+               (text-control profile_data state owner :sap_assessor "SAP Assessor")
+               (text-control profile_data state owner :sap_version_issue "SAP Version Issue")
+               (text-control profile_data state owner :sap_version_year "SAP Version Year")
+               (text-control profile_data state owner :sap_regulations_date "SAP Regulations Date")
+               (text-control profile_data state owner :sap_software "Name of SAP Software")])]))]))))
+
 (defn profile-rows [profiles owner]
   (reify
     om/IRenderState
@@ -239,7 +259,7 @@
          (om/build fireplaces-row profiles)
          (om/build glazing-row profiles)
          (om/build issues-row profiles)
-         ;; (om/build sap-results profiles)
+         (om/build sap-results-row profiles)
          ;; (om/build documents profiles)
          ;; (om/build co-heating profiles)
          ;; (om/build air-tightness profiles)


Better number filtering.

Better number filtering.

--- src-cljs/kixi/hecuba/widgets/chart.cljs
+++ src-cljs/kixi/hecuba/widgets/chart.cljs
@@ -22,7 +22,8 @@
                              str
                              (str/split #"-"))
         data             (into [] (->> measurements
-                                       (filter #(number? (:value %)))
+                                       (filter #(or (number? (:value %))
+                                                    (re-matches #"[^A-DF-Za-z]+" (:value %))))
                                        (map #(assoc % :id device_id))
                                        (map #(assoc % :timestamp (tf/parse amon-date (:timestamp %))))))
         unit             (get-in cursor [:unit])


Adds notifications based on environment variables

--- src/rmfu/core.clj
+++ src/rmfu/core.clj
@@ -20,10 +20,20 @@
     [ring.util.http-response :refer :all]
     [compojure.api.sweet :refer :all]))

+(defn check-env
+  "Checks if an environment variable exists"
+  [env-var]
+  (if (nil? (System/getenv env-var))
+    (str env-var " is missing.")
+    (str env-var ": " (System/getenv env-var))))
+
 (if (env :dev?)
   (do
     (println (format "_______ ENV DEV: %s   " (env :dev?)))
-    (println (format "_______ CLIENT URL: %s" (env :client-url)))))
+    (println (format "_______ CLIENT URL: %s" (env :client-url)))
+    (println (check-env "RMFU_SECRET"))
+    (println (check-env "RMFU_FROM_EMAIL"))
+    (println (check-env "MANDRILL_API_KEY"))))

 (def secret (System/getenv "RMFU_SECRET"))

@@ -194,7 +204,8 @@
           (wrap-file "resources/public")))                  ;; server static files from this directory

 (defn -main [port]
-  (jetty/run-jetty app {:port (Integer. port)}))
+    (jetty/run-jetty app {:port (Integer. port)}))

 (defn -dev [port]
+
   (jetty/run-jetty (wrap-reload #'app) {:port (Integer. port)}))


Fix unused var.

Fix unused var.

--- src/onyx/peer/task_compile.clj
+++ src/onyx/peer/task_compile.clj
@@ -50,7 +50,7 @@

 (defn compile-start-task-functions [lifecycles task-name]
   (let [matched (select-applicable-lifecycles lifecycles task-name)
-        fs (resolve-lifecycle-functions lifecycles
+        fs (resolve-lifecycle-functions matched
                                         :lifecycle/start-task?
                                         (fn [lifecycle f]
                                           (fn [event]
@@ -62,7 +62,7 @@

 (defn compile-lifecycle-handle-exception-functions [lifecycles task-name]
   (let [matched (select-applicable-lifecycles lifecycles task-name)
-        fs (resolve-lifecycle-functions lifecycles
+        fs (resolve-lifecycle-functions matched
                                         :lifecycle/handle-exception
                                         (fn [lifecycle f]
                                           (fn [event phase e]


close kill-ch earlier in shutdown to improve switching time

--- src/onyx/peer/virtual_peer.clj
+++ src/onyx/peer/virtual_peer.clj
@@ -53,6 +53,7 @@
   (stop [{:keys [outbox-ch kill-ch group-id id state] :as component}]
     (taoensso.timbre/info (format "Stopping Virtual Peer %s" (:id component)))

+    (close! kill-ch)

     (when-let [f (:lifecycle-stop-fn state)]
       (common/stop-lifecycle-safe! f :peer-left state))
@@ -62,7 +63,6 @@
           :peer-parent id
           :args {:id id
                  :group-id group-id}})
-    (close! kill-ch)

     (assoc component
            :state nil :group-ch nil :outbox-ch nil :kill-ch nil :id nil


Spike a macro for transactional tests. Derby seems to honor a commit even after a rollback. Email out to Stephen Gilardi about a rollback API that doesn't require raising an exception.

--- clj_record/test/core_test.clj
+++ clj_record/test/core_test.clj
@@ -5,6 +5,16 @@
     [clj-record.test.model.product :as product])
   (:use clojure.contrib.test-is))

+
+(defmacro deftxntest [name & body]
+  `(deftest ~name
+    (clojure.contrib.sql/with-connection clj-record.config/db
+      (clojure.contrib.sql/transaction
+        (try
+          ~@body
+          (finally
+            (println "about to rollback on " (clojure.contrib.sql/connection))
+            (.rollback (clojure.contrib.sql/connection))))))))

 (deftest table-name-is-permissive-about-input-type
   (are (= _1 (core/table-name _2))
@@ -17,16 +27,14 @@
     "manufacturers"  (manufacturer/table-name)
     "products"       (product/table-name)))

-(deftest insert-returns-id-of-new-record
+(deftxntest insert-returns-id-of-new-record
   (let [id (manufacturer/insert {:name "ACME"})
         acme (manufacturer/get-record id)]
-    (is (= "ACME" (acme :name)))
-    (manufacturer/destroy-record {:id id})))
+    (is (= "ACME" (acme :name)))))

-(deftest get-record-by-id
+(deftxntest get-record-by-id
   (let [humedai (manufacturer/create {:name "Humedai Motors"})]
-    (is (= humedai (manufacturer/get-record (:id humedai))))
-    (manufacturer/destroy-record humedai)))
+    (is (= humedai (manufacturer/get-record (:id humedai))))))

 (deftest get-record-throws-if-not-found
   (is (thrown? IllegalArgumentException (manufacturer/get-record -1))))
@@ -60,7 +68,8 @@
     (manufacturer/update {:id id :name "Schmoomdai Motors" :founded "2008"})
     (is (=
       {:name "Schmoomdai Motors" :grade 90 :founded "2008"}
-      (select-keys (manufacturer/get-record id) [:name :grade :founded])))))
+      (select-keys (manufacturer/get-record id) [:name :grade :founded])))
+    (manufacturer/destroy-record humedai)))

 (deftest to-conditions
   (are (= _1 (core/to-conditions _2))


Temp code for ReflectiveEncoder

Temp code for ReflectiveEncoder

--- src/cortex/impl/layers.cljc
+++ src/cortex/impl/layers.cljc
@@ -440,6 +440,61 @@
                       (m/clone input-tmp)
                       (m/clone output-tmp))))

+;(defrecord ReflectiveEncoder
+;  [up down input-tmp output-tmp]
+;  cp/PModule
+;    (cp/calc [this input]
+;      (let [new-up (cp/calc up input)]
+;        (if (identical? new-up up)
+;          this
+;          (ReflectiveEncoder. new-up down input-tmp output-tmp))))
+;
+;    (cp/output [m]
+;      (cp/output up))
+;
+;  cp/PNeuralTraining
+;    (forward [this input]
+;      (m/assign! input-tmp input)
+;      (let [up (cp/calc up input)
+;            _ (m/assign! output-tmp (cp/output up)) ;; output-tmp contains output from up
+;            down (cp/forward down output-tmp)
+;            ]
+;        (ReflectiveEncoder. up down input-tmp output-tmp)))
+;
+;    (backward [this input output-gradient]
+;      (let [down (cp/backward down output-tmp error)
+;            _ (m/assign! input-tmp (cp/output down)) ;; use input-tmp for reconstructed input
+;            up (cp/forward up input-tmp)
+;            _ (m/add! output-tmp (cp/input-gradient down)) ;; output-tmp contains gradient
+;            up (cp/backward up input output-tmp)
+;            ]
+;        (ReflectiveEncoder. up down input-tmp output-tmp)))
+;
+;    (input-gradient [this]
+;      (cp/input-gradient up))
+;
+;    cp/PGradient
+;    (gradient [this]
+;      (concat (cp/gradient up) (cp/gradient down)))
+;
+;    cp/PParameters
+;    (parameters [this]
+;      (concat (cp/parameters up) (cp/parameters down)))
+;
+;    (update-parameters [this parameters]
+;      (let [nup (cp/parameter-count up)
+;            ndown (cp/parameter-count down)
+;            up (cp/update-parameters up (m/subvector parameters 0 nup))
+;            down (cp/update-parameters down (m/subvector parameters nup ndown))]
+;        (ReflectiveEncoder. up down input-tmp output-tmp)))
+;
+;    cp/PModuleClone
+;      (clone [this]
+;        (ReflectiveEncoder. (cp/clone up)
+;                            (cp/clone down)
+;                            (m/clone input-tmp)
+;                            (m/clone output-tmp))))
+

 #?(:clj
    (defrecord KSparse [^long k]


changed width to 100%

changed width to 100%

--- src/error_codes/gorilla.clj
+++ src/error_codes/gorilla.clj
@@ -35,19 +35,19 @@
   padding-bottom: 40px;
   }
   .wrap {
-  width:1000px;
+  width:100%;
   margin:0 auto;
   }
   .left {
   float:left;
-  width:500px;
+  width:50%;
   }
   .right{
   float:right;
-  width:500px;
+  width:50%;
   }
   .summary-div{
-  width:1000px;
+  width:100%;
   display:block;
   }
   .boxed {
@@ -58,7 +58,7 @@
   border:1px solid black;
   }
   table-div{
-  width:1000px;
+  width:100%;
   }
   table td{
   border:1px solid black;


Macros: Simplify definition of `our-if-not-1`.

--- test/com/nomistech/clojure_the_language/macros/examples.clj
+++ test/com/nomistech/clojure_the_language/macros/examples.clj
@@ -53,9 +53,8 @@

 ;;;; How would we define `if-not` if it wasn't already in Clojure?

-(defmacro our-if-not-1
-  ([test then else]
-   (list 'if test else then)))
+(defmacro our-if-not-1 [test then else]
+  (list 'if test else then))

 (fact
   (let [x 99]


fix notes updated-at test

fix notes updated-at test

--- test/open_company/unit/resources/company/company_create.clj
+++ test/open_company/unit/resources/company/company_create.clj
@@ -81,8 +81,8 @@

     (let [add-section (fn [c section-name] (assoc c section-name (merge {:title (name section-name) :description "x"})))]
       (facts "it adds timestamps to notes"
-        (let [co      (c/add-placeholder-sections (c/->company r/open r/coyote))
-              w-note  (-> co (add-section :growth) (assoc-in [:growth :notes :body] "A Note"))
+        (let [w-note  (-> r/open (add-section :growth) (assoc-in [:growth :notes :body] "A Note"))
+              co      (c/->company w-note r/coyote)
               company (c/create-company! co)
               from-db (c/get-company (:slug r/open))]
           (get-in from-db [:updated-at]) => (:updated-at company)


Fix ns docstring style on poly1305 ns.

Fix ns docstring style on poly1305 ns.

--- src/clojure/buddy/core/mac/poly1305.clj
+++ src/clojure/buddy/core/mac/poly1305.clj
@@ -15,16 +15,16 @@

 (ns buddy.core.mac.poly1305
   "Poly1305-AES is a cryptographic message authentication code
-(MAC) written by Daniel J. Bernstein. It can be used to verify the
-data integrity and the authenticity of a message.
+  (MAC) written by Daniel J. Bernstein. It can be used to verify the
+  data integrity and the authenticity of a message.

-The security of Poly1305-AES is very close to the underlying AES
-block cipher algorithm. As a result, the only way for an attacker
-to break Poly1305-AES is to break AES.
+  The security of Poly1305-AES is very close to the underlying AES
+  block cipher algorithm. As a result, the only way for an attacker
+  to break Poly1305-AES is to break AES.

-Poly1305-AES offers also cipher replaceability. If anything does
-go wrong with AES, it can be substituted with identical security
-guarantee."
+  Poly1305-AES offers also cipher replaceability. If anything does
+  go wrong with AES, it can be substituted with identical security
+  guarantee."
   (:import org.bouncycastle.crypto.generators.Poly1305KeyGenerator
            org.bouncycastle.crypto.macs.Poly1305
            org.bouncycastle.crypto.params.KeyParameter


Form validation

Form validation

--- src/clojurescript/skuld/show_group.cljs
+++ src/clojurescript/skuld/show_group.cljs
@@ -7,9 +7,9 @@
             [goog.events :as events]
             [reagent.core :as r]
             [ajax.core :refer [GET]]
-            [clojure.string :as s])
-  (:import [goog.net Jsonp]
-           [goog Uri]))
+            [clojure.string :as s]))
+
+(def log js/console.log)

 (extend-type js/NodeList
   ISeqable
@@ -22,9 +22,10 @@
 (defn event-handler [state [event-name value]]
   (case event-name
     :group-info (-> state
-                    (update :group-info merge value)
+                    (update :group-info merge (update value :members sort))
                     (assoc-in [:expense-form :shared-with]
-                              (into {} (map #(vec [% true]) (:members value)))))
+                              (into {} (map #(vec [% true]) (:members value))))
+                    (assoc-in [:expense-form :payed-by] (first (:members value))))
     :shared-with (update-in state [:expense-form :shared-with value] not)
     :change-amount (assoc-in state [:expense-form :amount] value)
     :change-payed-by (assoc-in state [:expense-form :payed-by] value)
@@ -51,9 +52,12 @@

 (def el-value #(-> % .-target .-value))

+(def is-float (comp not js/window.isNaN js/window.parseFloat))
+
 (defn amount-input []
   (let [amount (r/track #(-> @app-state :expense-form :amount))
-        error-class (r/track #(if (not (re-matches #"[\d,.]*" @amount)) "has-error"))
+        valid-amount #(or (empty? %1) (is-float %1))
+        error-class (r/track #(if (not (valid-amount @amount)) "has-error"))
         on-change #(dispatch [:change-amount (el-value %)])]
     (fn []
       [:div {:class (s/join " " ["form-group" @error-class])}
@@ -63,12 +67,23 @@
                 :on-change on-change
                 :value @amount}]])))

-(defn submit-expense-form [value]
-  (let [expense-form (@app-state :expense-form)
-        shared-with (->> (expense-form :shared-with)
-                         (filter second)
-                         (map first))]
-    (.log js/console (clj->js (assoc expense-form :shared-with shared-with)))))
+(defn prepare-formdata [data]
+  (-> data
+      (update :shared-with #(->> %
+                                 (filter (comp true? second))
+                                 (map first)))
+      (update :amount js/window.parseFloat)))
+
+(defn validate-form-data [data]
+  (and (is-float (:amount data))
+       (every? false? (map empty? (vals (select-keys data [:payed-by :shared-with]))))))
+
+(defn submit-expense-form [e]
+  (let [clj->json-str (comp js/window.JSON.stringify clj->js)
+        form-data (prepare-formdata (:expense-form @app-state))]
+    (if (validate-form-data form-data)
+      (log (clj->json-str form-data))
+      (log "Validation error"))))

 (defn expense-form []
   (let [members (r/track #(-> @app-state :group-info :members))


Improve /about/version accuracy

Improve /about/version accuracy

--- src/foreclojure/version.clj
+++ src/foreclojure/version.clj
@@ -3,10 +3,14 @@
         compojure.core
         [clojure.java.shell :only [sh]]))

+;; fetch this at load time rather than on demand, so that it's accurate even
+;; if someone checks out a different revision to poke at without restarting
+;; the server (eg to diagnose bugs in a release)
+(def sha (:out (sh "git" "rev-parse" "--verify" "HEAD")))
+
 (def-page version []
-  (let [sha (:out (sh "git" "rev-parse" "--verify" "HEAD"))]
-    [:p "SHA: "
-     [:a {:href (str "http://github.com/dbyrne/4clojure/commit/" sha)} sha]]))
+  [:p "SHA: "
+   [:a {:href (str "http://github.com/dbyrne/4clojure/commit/" sha)} sha]])

 (defroutes version-routes
-  (GET ["/about/version"] [] (version)))+  (GET ["/about/version"] [] (version)))


Replace use of an atom with the letfn macro

--- src/io/aviso/rook/async.clj
+++ src/io/aviso/rook/async.clj
@@ -170,11 +170,8 @@
   ([handler]
    (wrap-with-loopback handler :loopback-handler))
   ([handler k]
-   (let [loopback-handler (atom nil) ; for want of a this
-         handler' (fn [request]
-                    (let [this @loopback-handler
-                          wrapped (rook/arg-resolver-middleware handler (rook/build-map-arg-resolver k this))
-                          request' (assoc request k this)]
-                      (wrapped request')))]
-     (reset! loopback-handler handler')
+   (letfn [(handler' [request]
+                     (let [wrapped (rook/arg-resolver-middleware handler (rook/build-map-arg-resolver k handler'))
+                           request' (assoc request k handler')]
+                       (wrapped request')))]
      handler')))


added dev leiningen profile: "dive"

added dev leiningen profile: "dive"

--- cljx/plongeur-clj/project.clj
+++ cljx/plongeur-clj/project.clj
@@ -48,4 +48,6 @@
                                  [lein-kibit "0.1.2"]]
                        :main user }}

+  :aliases {"dive" ["with-profile" "+dev" "repl"]}
+
   )


Clarify docstring

Clarify docstring

--- src/sparql_to_graphviz/cli.clj
+++ src/sparql_to_graphviz/cli.clj
@@ -63,7 +63,7 @@
     :parse-fn io/as-file
     :default *out*
     :default-desc "STDOUT"]
-   [nil "--min-support MIN_SUPPORT" "Filter classes and properties by minimum percentage"
+   [nil "--min-support MIN_SUPPORT" "Filter classes and properties by minimum frequency in percent"
     :id ::spec/min-support
     :parse-fn util/->integer
     :validate [(partial s/valid? ::spec/min-support) "Percentage must be a number between 0 and 100."]


Made comments a little more clear.

Made comments a little more clear.

--- data_collection/profanity-power-index/src/profanity_power_index/core.clj
+++ data_collection/profanity-power-index/src/profanity_power_index/core.clj
@@ -18,7 +18,8 @@
   (comp
     ;; Split on the carriage return. These occur only at the end of a tweet.
     (mapcat (fn [s] (str/split s #"\r")))
-    ;; Now partition the incoming vectors by a blank string.
+    ;; Now partition the incoming vectors by a blank string, which works because
+    ;; the tweet boundary is \r\n, so \n returns true for str/blank?
     ;; This groups the tweet chunks into vectors, and the boundaries into
     ;; empty strings.
     (partition-by str/blank?)
@@ -104,13 +105,15 @@
             "tweet"
             ;; Extract the id from the tweet.
             (:id_str t)
-            ;; Convert the document to JSON for elasticsearch indexing.
+            ;; The tweet itself, which doesn't need to be converted to JSON
+            ;; explicitly.
             t))]]))

 (defn -main
   [& args]

-  (let [env (-> "env.edn" io/resource io/file slurp edn/read-string)
+  (let [env
+          (-> "env.edn" io/resource io/file slurp edn/read-string)
         options
           (parse-opts
             args


Proper capitalisation for nREPL

Proper capitalisation for nREPL

--- app/dev/nrepl.clj
+++ app/dev/nrepl.clj
@@ -18,7 +18,7 @@
                        #'cemerick.piggieback/wrap-cljs-repl
                        )))]
     (spit ".nrepl-port" (:port server))
-    (println "NREPL port:" (:port server))
+    (println "nREPL port:" (:port server))
     server))

 (def server (start-nrepl))


more reasonable limit for url in places table

--- src/lobos/migrations.clj
+++ src/lobos/migrations.clj
@@ -13,7 +13,7 @@
                                   (varchar :special 150)
                                   (double :lat)
                                   (double :lon)
-                                  (varchar :url 50)
+                                  (varchar :url 75)
                                   (varchar :tel 20)
                                   (boolean :freifunk )
                                   (check :name (> (length :name) 1))


Fixed anti-forgery token problem

Fixed anti-forgery token problem

--- src/freecoin/views/transaction_form.clj
+++ src/freecoin/views/transaction_form.clj
@@ -52,7 +52,7 @@
                    :method "POST"}
             [:input {:name "__anti-forgery-token"
                      :type "hidden"
-                     :value (get-in ctx [:session "__anti-forgery-token"])}]
+                     :value (get-in ctx [:request :session "__anti-forgery-token"])}]
             [:input {:name "recipient"
                      :type "hidden"
                      :value email}]


Adding transforms to core

Adding transforms to core

--- src/main/clojure/stl_collector/core.clj
+++ src/main/clojure/stl_collector/core.clj
@@ -1,3 +1,4 @@
 (ns stl-collector.core
   (:require [stl-collector.reader :as r]
-              [stl-collector.writer :as w]))
+            [stl-collector.writer :as w]
+            [stl-collector.transforms :as t]))


[#2254] Refactor & working version

[#2254] Refactor & working version

--- backend/src/akvo/lumen/lib/update.clj
+++ backend/src/akvo/lumen/lib/update.clj
@@ -16,6 +16,21 @@
 (hugsql/def-db-fns "akvo/lumen/lib/job-execution.sql")
 (hugsql/def-db-fns "akvo/lumen/lib/transformation.sql")
 (hugsql/def-db-fns "akvo/lumen/lib/dataset.sql")
+
+(defn columns-used-in-txs [initial-dataset-version latest-dataset-version]
+  (log/debug :columns (walk/keywordize-keys (:columns initial-dataset-version)))
+  (log/debug :all-txs (walk/keywordize-keys (:transformations latest-dataset-version)))
+  (let [res (loop [columns (-> initial-dataset-version :columns walk/keywordize-keys)
+                   txs (-> latest-dataset-version :transformations walk/keywordize-keys)
+                   cols0 #{}]
+              (let [tx (first txs)
+                    cols1 (apply  conj cols0 (engine/columns-used (first txs) columns))]
+                (if-let [txs (seq (next txs))]
+                  (recur (engine/undif-columns tx columns) txs cols1)
+                  cols1))
+              )]
+    (log/error :YUPIE res)
+    res))

 (defn- successful-update
   "On a successful update we need to create a new dataset-version that
@@ -91,8 +106,16 @@
     (with-open [importer (import/dataset-importer (get data-source-spec "source") import-config)]
       (let [initial-dataset-version  (initial-dataset-version-to-update-by-dataset-id conn {:dataset-id dataset-id})
             imported-dataset-columns (vec (:columns initial-dataset-version))
-            importer-columns         (p/columns importer)]
-        (if-let [compatible-errors (compatible-columns-error? imported-dataset-columns importer-columns)]
+            importer-columns         (p/columns importer)
+
+            columns-used (columns-used-in-txs
+                          initial-dataset-version
+                          (latest-dataset-version-by-dataset-id tenant-conn {:dataset-id dataset-id}))
+            imported-dataset-columns-checked (reduce (fn [c co]
+                                                       (if (contains? columns-used (get co "columName"))
+                                                         (conj c co)
+                                                         c)) [] imported-dataset-columns)]
+        (if-let [compatible-errors (compatible-columns-error? imported-dataset-columns-checked importer-columns)]
           (failed-update conn job-execution-id
                          (cond-> "Column mismatch"
                            (seq (:missed-columns compatible-errors))
@@ -156,18 +179,5 @@
      (lib/ok {"updateId" job-execution-id}))))

-(defn consistency? [initial-dataset-version latest-dataset-version]
-  (log/error :columns (walk/keywordize-keys (:columns initial-dataset-version)))
-  (log/error :all-txs (walk/keywordize-keys (:transformations latest-dataset-version)))

-  (let [res (loop [columns (-> initial-dataset-version :columns walk/keywordize-keys)
-                   txs (-> latest-dataset-version :transformations walk/keywordize-keys)
-                   cols0 []]
-              (let [tx (first txs)
-                    cols1 (apply conj cols0 (engine/columns-used (first txs) columns))]
-                (if-let [txs (seq (next txs))]
-                  (recur (engine/undif-columns tx columns) txs cols1)
-                  cols1))
-              )]
-    (log/error :YUPIE res)))


import msg update

import msg update

--- src/spcr/core.clj
+++ src/spcr/core.clj
@@ -70,7 +70,7 @@
    (POST "/upload" {{{tempfile-path :tempfile} "file"} :multipart-params}
          (do
            (import-file tempfile-path)
-           (response "Import successful!"))))
+           (response "Import successful! Go back to review your data"))))
   (c-route/resources "/"))


Make eastwood happy.

Make eastwood happy.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -536,7 +536,7 @@
     [:td {:class "small-12 large-12" :valign "middle" :align "center"}
       [:center
         (spacer 8)
-        (when-not (empty? must-see)
+        (when (seq must-see)
           [:table
             {:cellpadding "0"
              :cellspacing "0"
@@ -553,9 +553,9 @@
                     [:tr
                       [:td {:class "small-12 large-12 columns"}
                         (digest-post-block user p)]]])]]])
-        (when-not (empty? must-see)
+        (when (seq must-see)
           (spacer 16))
-        (when-not (empty? non-must-see)
+        (when (seq non-must-see)
           [:table
             {:cellpadding "0"
              :cellspacing "0"


Remove labels tr if there are none.

Remove labels tr if there are none.

--- src/oc/email/content.clj
+++ src/oc/email/content.clj
@@ -371,11 +371,12 @@
                   :cellspacing "0"
                   :border "0"
                   :class "row digest-post-block"}
-                 [:tr
-                   [:td
-                     [:div.oc-labels
-                       (for [label (:labels entry)]
-                         (label-block label))]]]
+                 (when (seq (:labels entry))
+                   [:tr
+                     [:td
+                       [:div.oc-labels
+                         (for [label (:labels entry)]
+                           (label-block label))]]])
                   [:tr
                     [:td
                       [:span.digest-post-attribution


placing marks and selected marked history

--- src/ophion/aggregate.clj
+++ src/ophion/aggregate.clj
@@ -5,19 +5,6 @@
    [cheshire.core :as json]
    [taoensso.timbre :as log]
    [ophion.mongo :as mongo]))
-
-(defn outgoing
-  [from label]
-  [{:$match {:from from :label label}}
-   {:$project {:gid true :from true :to true}}
-   {:$lookup
-    {:from "element"
-     :localField "to"
-     :foreignField "gid"
-     :as "outgoing"}}
-   {:$unwind "$outgoing"}
-   {:$replaceRoot {:newRoot "$outgoing"}}
-   {:$project {:_id false}}])

 (defn has
   [state where]
@@ -37,8 +24,16 @@
       :localField "gid"
       :foreignField "to"
       :as "from"}}
-    {:$project {:to {:$filter {:input "$from" :as "o" :cond {:$eq ["$$o.label" label]}}}}}
+    {:$project
+     {:history "$_history"
+      :to
+      {:$filter
+       {:input "$from"
+        :as "o"
+        :cond
+        {:$eq ["$$o.label" label]}}}}}
     {:$unwind "$from"}
+    {:$addFields {"from._history" "$history"}}
     {:$replaceRoot {:newRoot "$from"}}]
    where))

@@ -50,8 +45,16 @@
       :localField "gid"
       :foreignField "from"
       :as "to"}}
-    {:$project {:to {:$filter {:input "$to" :as "o" :cond {:$eq ["$$o.label" label]}}}}}
+    {:$project
+     {:history "$_history"
+      :to
+      {:$filter
+       {:input "$to"
+        :as "o"
+        :cond
+        {:$eq ["$$o.label" label]}}}}}
     {:$unwind "$to"}
+    {:$addFields {"to._history" "$history" "to.yellol" "1333"}}
     {:$replaceRoot {:newRoot "$to"}}]
    where))

@@ -64,6 +67,7 @@
       :foreignField "gid"
       :as "from"}}
     {:$unwind "$from"}
+    {:$addFields {"from._history" "$_history"}}
     {:$replaceRoot {:newRoot "$from"}}]
    where))

@@ -76,6 +80,7 @@
       :foreignField "gid"
       :as "to"}}
     {:$unwind "$to"}
+    {:$addFields {"to._history" "$_history"}}
     {:$replaceRoot {:newRoot "$to"}}]
    where))

@@ -91,6 +96,22 @@
    (to-edge state where)
    (to-vertex state {})))

+(defn mark
+  [state label]
+  (let [path (str "_history." label)]
+    [{:$addFields {path "$$ROOT"}}
+     {:$project
+      {(str path "._history") false
+       (str path "._id") false}}]))
+
+(defn select
+  [state labels]
+  [{:$project
+    (reduce
+     (fn [project label]
+       (assoc project label (str "$_history." label)))
+     {} labels)}])
+
 (def steps
   {:where has
    :from-edge from-edge
@@ -98,7 +119,9 @@
    :from-vertex from-vertex
    :to-vertex to-vertex
    :from from
-   :to to})
+   :to to
+   :mark mark
+   :select select})

 (defn apply-step
   [steps step state]


Produce keys of time value representing fields

--- src/tick/core.clj
+++ src/tick/core.clj
@@ -10,7 +10,7 @@
    [java.time Clock ZoneId ZoneOffset Instant Duration Period DayOfWeek Month ZonedDateTime LocalTime LocalDateTime LocalDate Year YearMonth ZoneId OffsetDateTime OffsetTime]
    [java.time.format DateTimeFormatter]
    [java.time.temporal ChronoUnit ChronoField TemporalAdjusters]
-   [clojure.lang ILookup]))
+   [clojure.lang ILookup Seqable]))

 (def ^{:dynamic true} *clock* nil)

@@ -273,6 +273,12 @@
    :year-of-era ChronoField/YEAR_OF_ERA})

 (deftype FieldsLookup [t]
+  Seqable
+  (seq [_]
+    (->> field-map
+         (filter (fn [[k v]] (.isSupported t (get field-map k))))
+         (into {})
+         seq))
   ILookup
   (valAt [_ fld]
     (when-let [f (get field-map fld)]


The Demand ugen can take a non :dr trigger as an argument, so don't enforce only :dr inputs - this should be part of the ugen check fns

--- src/overtone/sc/ugen.clj
+++ src/overtone/sc/ugen.clj
@@ -244,10 +244,8 @@
                  (and (= "A2K" (:name ugen))
                       (= :ar (:rate-name bad-input)))
                  ;; Special case demand rate ugens which may have kr ugens plugged into them
-                 ;; Unless it's a Demand ugen which only allows dr ugens to be connected
                  (and (= :dr cur-rate)
-                      (= :kr (:rate-name bad-input))
-                      (not (= "Demand" (:name ugen)))))
+                      (= :kr (:rate-name bad-input))))

         (let [ugen-name (real-ugen-name ugen)
               in-name (real-ugen-name bad-input)


Fix comment style

Fix comment style

--- src/toucan/db.clj
+++ src/toucan/db.clj
@@ -273,8 +273,8 @@
   [honeysql-form & {:as options}]
   (jdbc/query (connection)
               (honeysql->sql honeysql-form)
-              ; FIXME: This has already been fixed in `clojure.java.jdbc`, so
-              ;        this option can be removed when using >= 0.7.10.
+              ;; FIXME: This has already been fixed in `clojure.java.jdbc`, so
+              ;;        this option can be removed when using >= 0.7.10.
               (into options {:identifiers u/lower-case})))

 (defn reducible-query


Fixes #79; last-timestamp in poller is now correct. Wasn't updating correctly

--- src/polismath/poller.clj
+++ src/polismath/poller.clj
@@ -113,7 +113,8 @@
       ; Get and split new votes
       (let [new-votes (poll pg-spec @last-timestamp)
             zid-votes (group-by :zid new-votes)]
-        ; For each conv...
+        (println "XXXX - last:" (last new-votes) "max: " (apply max 0 @last-timestamp (map :created new-votes)))
+        ; For each conv...
         (doseq [[zid votes] zid-votes]
           (let [lastVoteTimestamp (:created (last votes))
                 start-time        (System/currentTimeMillis)
@@ -138,7 +139,7 @@
               (mongo-upsert-results (mongo-collection-name "bidToPid")))))

         ; Update last-timestamp, if needed
-        (when-let [last-vote (last new-votes)]
-          (swap! last-timestamp (fn [_] (:created last-vote))))))))
+        (swap! last-timestamp
+               (fn [last-ts] (apply max 0 last-ts (map :created new-votes))))))))


refactoring send-lines fn in GraphiteUDPClient (#972)

--- src/riemann/graphite.clj
+++ src/riemann/graphite.clj
@@ -58,11 +58,7 @@
       (.send ^DatagramSocket (:socket this) datagram)))
   (send-lines [this lines]
     (doseq [line lines]
-      (let [bytes (.getBytes ^String line)
-            length (count line)
-            addr (InetAddress/getByName (:host this))
-            datagram (DatagramPacket. bytes length ^InetAddress addr port)]
-        (.send ^DatagramSocket (:socket this) datagram))))
+      (send-line this line)))
   (close [this]
     (.close ^DatagramSocket (:socket this))))


New function for parsing boolean values from INI files

--- src/zg/config.clj
+++ src/zg/config.clj
@@ -27,6 +27,12 @@
     [^String string]
     (java.lang.Float/parseFloat string))

+(defn parse-boolean
+    "Parse the given string as a boolean value."
+    [^String string]
+    (or (= string "true")
+        (= string "True")))
+
 (defn load-configuration
     "Load configuration from the provided INI file."
     [^String ini-file-name]


Added strict type check to return-file function

--- src/zg/server.clj
+++ src/zg/server.clj
@@ -321,7 +321,7 @@
 (defn return-file
     "Creates HTTP response containing content of specified file.
      Special value nil / HTTP response 404 is returned in case of any I/O error."
-    [file-name content-type]
+    [^String file-name content-type]
     (let [file (new java.io.File "www" file-name)]
         (log/info "Returning file " (.getAbsolutePath file))
         (if (.exists file)


Retrofit aggregate to work like transformer.

--- src/onyx/peer/aggregate.clj
+++ src/onyx/peer/aggregate.clj
@@ -6,38 +6,41 @@
               [onyx.extensions :as extensions]
               [onyx.queue.hornetq :refer [take-segments]]
               [onyx.peer.transform :as transformer]
-              [taoensso.timbre :refer [debug]]
+              [taoensso.timbre :refer [debug fatal]]
               [dire.core :refer [with-post-hook!]]))

-(def n-pipeline-threads 1)
-
-(defn consumer-loop [event session consumers halting-ch session-ch]
-  (go (loop []
-        (let [consumer (first consumers)
-              f #(extensions/consume-message (:onyx.core/queue event) consumer)
-              msgs (doall (take-segments f (:onyx/batch-size (:onyx.core/task-map event))))]
-          (>! session-ch {:session session :halting-ch halting-ch :msgs msgs}))
-        (when (<! halting-ch)
-          (recur)))))
+(defn consumer-loop [event session input consumer halting-ch session-ch]
+  (go
+   (try
+     (loop []
+       (let [f (fn [] {:input input
+                      :message (extensions/consume-message (:onyx.core/queue event) consumer)})
+             msgs (doall (take-segments f (:onyx/batch-size (:onyx.core/task-map event))))]
+         (>! session-ch {:session session :halting-ch halting-ch :msgs msgs}))
+       (when (<! halting-ch)
+         (recur)))
+     (catch Exception e
+       (fatal e)))))

 (defn inject-pipeline-resource-shim
   [{:keys [onyx.core/queue onyx.core/ingress-queues onyx.core/task-map] :as event}]
-  (let [rets
+  (let [session (extensions/bind-active-session queue (first (vals ingress-queues)))
+        consumers (map (fn [[task queue-name]]
+                         {:input task
+                          :consumer (extensions/create-consumer queue session queue-name)})
+                       ingress-queues)
+        halting-ch (chan 0)
+        read-ch (chan 1)
+        rets
         {:onyx.aggregate/queue
-         (->> (range n-pipeline-threads)
-              (map (fn [x] {:session (extensions/bind-active-session queue (first ingress-queues))}))
-              (map (fn [x] (assoc x :consumers (map (partial extensions/create-consumer queue (:session x))
-                                                   ingress-queues))))
-              (map (fn [x] (assoc x :halting-ch (chan 0)))))
-         :onyx.aggregate/read-ch (chan n-pipeline-threads)
+         {:session session
+          :consumers consumers
+          :halting-ch halting-ch}
+         :onyx.aggregate/read-ch read-ch
          :onyx.core/reserve? true
          :onyx.transform/fn (operation/resolve-fn task-map)}]
-    (doseq [queue-bundle (:onyx.aggregate/queue rets)]
-      (consumer-loop event
-                     (:session queue-bundle)
-                     (:consumers queue-bundle)
-                     (:halting-ch queue-bundle)
-                     (:onyx.aggregate/read-ch rets)))
+    (doseq [c consumers]
+      (consumer-loop event session (:input c) (:consumer c) halting-ch read-ch))
     (merge event rets)))

 (defn inject-temporal-resource-shim
@@ -47,8 +50,10 @@
   ;;; in the pipeline.
   {:onyx.core/session :placeholder})

-(defn read-batch-shim [event]
+(defn read-batch-shim [{:keys [onyx.core/queue] :as event}]
   (let [{:keys [session halting-ch msgs]} (<!! (:onyx.aggregate/read-ch event))]
+    (doseq [msg msgs]
+      (extensions/ack-message queue (:message msg)))
     (merge event
            {:onyx.core/session session
             :onyx.core/batch msgs
@@ -60,10 +65,12 @@

 (defn close-pipeline-resources-shim [{:keys [onyx.core/queue] :as event}]
   (close! (:onyx.aggregate/read-ch event))
-  (doseq [queue-bundle (:onyx.aggregate/queue event)]
-    (close! (:halting-ch queue-bundle))
-    (doseq [c (:consumers queue-bundle)] (extensions/close-resource queue c))
-    (extensions/close-resource queue (:session queue-bundle)))
+  (close! (:halting-ch (:onyx.aggregate/queue event)))
+
+  (doseq [c (:consumers (:onyx.aggregate/queue event))]
+    (extensions/close-resource queue (:consumer c)))
+
+  (extensions/close-resource queue (:session (:onyx.aggregate/queue event)))
   event)

 (defmethod l-ext/start-lifecycle? :aggregator


util/tsv.clj: added read-tsv-stream

util/tsv.clj: added read-tsv-stream

--- src/org/altlaw/util/tsv.clj
+++ src/org/altlaw/util/tsv.clj
@@ -5,16 +5,28 @@
                     FileInputStream)
            (java.util.zip GZIPInputStream)))

+(defn read-tsv-stream
+  "Reads a gzip-compressed binary stream of a tab-separated-value file
+  with two columns.  Returns a map of string=>string."
+  [#^InputStream stream]
+  (with-open [reader (BufferedReader.
+                      (InputStreamReader.
+                       (GZIPInputStream. stream) "UTF-8"))]
+    (reduce (fn [map #^String line]
+              (let [[#^String key value] (.split line "\t")]
+                (assoc map key value)))
+            {} (line-seq stream))))
+
+(defn write-tsv-stream
+  "Writes a gzip-compressed binary stream of a tab-separated-value
+  file containing two columns, drawing data from the given map."
+  [stream map]
+  )
+
 (defn load-tsv-map
   "Reads a gzip-compressed tab-separated-value file with two columns.
   Returns a map of string=>string."
   [file]
-  (with-open [stream (BufferedReader.
-                      (InputStreamReader.
-                       (GZIPInputStream.
-                        (FileInputStream. file))))]
-      (reduce (fn [map #^String line]
-                  (let [[#^String key value] (.split line "\t")]
-                    (assoc map key value)))
-              {} (line-seq stream))))
+  (with-open [stream (FileInputStream. file)]
+    (read-tsv-stream stream)))


util/zip.clj: added gzip-bytes

util/zip.clj: added gzip-bytes

--- src/org/altlaw/util/zip.clj
+++ src/org/altlaw/util/zip.clj
@@ -45,6 +45,14 @@
           (.closeEntry in)
           (recur (.getNextEntry in)))))))

+(defn gzip-bytes [bytes]
+  (let [input (ByteArrayInputStream. bytes)
+        output (ByteArrayOutputStream.)
+        gzip-output (GZIPOutputStream. output)]
+    (IOUtils/copy input gzip-output)
+    (.close gzip-output)
+    (.toByteArray output)))
+
 (defn gzip-utf8-string
   "Converts a string to gzipped UTF-8 text, returns a byte array."
   [s]


formatting

formatting

--- src/overtone/inst/piano.clj
+++ src/overtone/inst/piano.clj
@@ -19,21 +19,19 @@
                 stretch 0.1
                 sustain 0.1]
   (let [snd (apply mda-piano [:freq (midicps note)
-                        :gate gate
-                        :vel vel
-                        :decay decay
-                        :release release
-                        :hard hard
-                        :velhard velhard
-                        :muffle muffle
-                        :velmuff velmuff
-                        :velcurve velcurve
-                        :stereo stereo
-                        :tune tune
-                        :random random
-                        :stretch stretch
-                       :sustain sustain])]
+                              :gate gate
+                              :vel vel
+                              :decay decay
+                              :release release
+                              :hard hard
+                              :velhard velhard
+                              :muffle muffle
+                              :velmuff velmuff
+                              :velcurve velcurve
+                              :stereo stereo
+                              :tune tune
+                              :random random
+                              :stretch stretch
+                              :sustain sustain])]
     (detect-silence snd 0.005 :action FREE)
     (* 1 snd))) ;;TODO: figure out why this mul is required
-
-(definst foo [] (mda-piano))


Use 'when' because there is no else condition

--- src/play_clj/core_utils.clj
+++ src/play_clj/core_utils.clj
@@ -6,7 +6,7 @@
     (find-first :player? entities)
     (find-first #(= :menu (:id %)) entities)"
   [match-fn entities]
-  (some #(if (match-fn %) %) entities))
+  (some #(when (match-fn %) %) entities))

 (defmacro on-gl
   "Runs the macro body on the GL thread.


minor typo

minor typo

--- src/push/type/item/char.clj
+++ src/push/type/item/char.clj
@@ -46,7 +46,7 @@
 (def scalar->asciichar
   (core/build-instruction
     scalar->asciichar
-    "`:scalar->asciichar` pops the top `:sclar` value, reduces it modulo 128, and pushes the `:char` that is represented by that ASCII value"
+    "`:scalar->asciichar` pops the top `:scalar` value, reduces it modulo 128, and pushes the `:char` that is represented by that ASCII value"
     :tags #{:string :conversion :base}
     (d/consume-top-of :scalar :as :arg)
     (d/calculate [:arg]


fixed loading the error template

fixed loading the error template

--- src/selmer/validator.clj
+++ src/selmer/validator.clj
@@ -73,7 +73,7 @@

{{error}}

-
In {{file}} {% if line %}on line {{line}}{% endif %}.

+
In {{template}}{% if line %} on line {{line}}{% endif %}.

        {% if validation-errors %}
          {% for error in validation-errors %}
@@ -122,11 +122,11 @@
             doall
             (clojure.string/join "The template contains orphan tags: "))
        {:type :selmer-validation-error
+        :error-template error-template
+        :template template
         :validation-errors
         (for [{:keys [tag-name line] :as tag} error-tags]
-          (error-map "Found an orphan closing tag" (format-tag tag) line template))
-        :error-template
-        (decode-path (resource-path "validation-error-page.html"))})))
+          (error-map "Found an orphan closing tag" (format-tag tag) line template))})))
   ([error tag line template]
    (let [tag (format-tag tag)]
      (throw


CMR-493: Fixed typo in require.

CMR-493: Fixed typo in require.

--- src/cmr/system_int_test/utils/search_util.clj
+++ src/cmr/system_int_test/utils/search_util.clj
@@ -8,7 +8,7 @@
             [cmr.system-int-test.utils.url-helper :as url]
             [cmr.common.util :as u]
             [camel-snake-kebab :as csk]
-            [clojure.walk]]))
+            [clojure.walk]))

 (defn params->snake_case
   "Converts search parameters to snake_case"


Use empty-state component

Use empty-state component

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -9,6 +9,7 @@
             [frontend.components.inputs :as inputs]
             [frontend.components.pieces.button :as button]
             [frontend.components.pieces.card :as card]
+            [frontend.components.pieces.empty-state :as empty-state]
             [frontend.components.pieces.form :as form]
             [frontend.components.pieces.dropdown :as dropdown]
             [frontend.components.pieces.icon :as icon]
@@ -1843,36 +1844,6 @@
                                                            [:delete-provisioning-profile
                                                             (select-keys profile [:project-name :vcs-type :uuid])])}))}]}))))

-(defn no-keys-empty-state [{:keys [project-name add-key]} owner]
-  (reify
-    om/IRender
-    (render [_]
-      (html
-        [:div {:data-component `no-keys-empty-state}
-         [:i.octicon.octicon-key]
-         [:div.info
-          [:span.highlight project-name]
-          [:span " has no "]
-          [:span.highlight "Apple Code Signing Identities"]
-          [:span "  yet"]]
-         (button/button {:on-click add-key :kind :primary} "Upload Key")
-         [:div.sub-info "Apple Code Signing requires a valid Code Signing Identity (p12) file"]]))))
-
-(defn no-profiles-empty-state [{:keys [project-name add-profile]} owner]
-  (reify
-    om/IRender
-    (render [_]
-      (html
-        [:div {:data-component `no-profiles-empty-state}
-         [:i.octicon.octicon-key]
-         [:div.info
-          [:span.highlight project-name]
-          [:span " has no "]
-          [:span.highlight "provisioning profiles"]
-          [:span "  yet"]]
-         (button/button {:on-click add-profile :kind :primary} "Upload Profile")
-         [:div.sub-info "Apple Code Signing requires a valid provisioning profile (mobileprovision)"]]))))
-
 (defn p12-upload-modal [{:keys [close-fn error-message project-name vcs-type]} owner]
   (reify
     om/IInitState
@@ -1991,8 +1962,12 @@
              (om/build p12-key-table {:rows (->> osx-keys
                                                  (map (partial merge {:project-name project-name
                                                                       :vcs-type vcs-type})))})
-             (om/build no-keys-empty-state {:project-name project-name
-                                            :add-key #(om/set-state! owner :show-modal? true)}))
+             (empty-state/empty-state {:icon [:i.octicon.octicon-key]
+                                       :heading (str project-name " has no code signing identities yet")
+                                       :subheading "Apple Code Signing requires a valid Code Signing Identity (p12) file."
+                                       :action (button/button {:on-click #(om/set-state! owner :show-modal? true)
+                                                               :kind :primary}
+                                                              "Upload Key")}))
            (when show-modal?
              (om/build p12-upload-modal {:close-fn #(om/set-state! owner :show-modal? false)
                                          :error-message error-message
@@ -2031,8 +2006,12 @@
              (om/build provisioning-profiles-table {:rows (->> osx-profiles
                                                               (map (partial merge {:project-name project-name
                                                                                :vcs-type vcs-type})))})
-             (om/build no-profiles-empty-state {:project-name project-name
-                                                :add-profile #(om/set-state! owner :show-modal? true)}))
+             (empty-state/empty-state {:icon [:i.octicon.octicon-key]
+                                       :heading (str project-name " has no provisioning profiles yet")
+                                       :subheading "Apple Code Signing requires a valid provisioning profile (mobileprovision)."
+                                       :action (button/button {:on-click #(om/set-state! owner :show-modal? true)
+                                                               :kind :primary}
+                                                              "Upload Profile")}))
            (when show-modal?
              (om/build provisioning-profile-upload-modal
                        {:close-fn #(om/set-state! owner :show-modal? false)


s/condp =/case

s/condp =/case

--- src-cljs/frontend/components/project_settings.cljs
+++ src-cljs/frontend/components/project_settings.cljs
@@ -967,7 +967,7 @@
         :else nil))

 (defn checkout-key-description [key project]
-  (condp = (:type key)
+  (case (:type key)
     "deploy-key" (str (vcs-url/project-name (:vcs_url project)) " deploy key")
     "github-user-key" (str (:login key) " user key")
     "bitbucket-user-key" (str (:login key) " user key")


Update core.clj

Update core.clj

--- src/swagger_gen/core.clj
+++ src/swagger_gen/core.clj
@@ -53,13 +53,6 @@
   (when-let [definitions (get-definitions spec)]
     (map normalize-definition definitions)))

-;; Paths
-;;
-;; The main task we need to do here is to flatten some nested
-;; structures i.e [ /route [method1 method2]  ]
-;
-;; **********************************************************************
-
 (defn params-of-type
   [swagger-route param-type]
   (->> swagger-route


Housekeeping

Housekeeping

--- src/taoensso/faraday.clj
+++ src/taoensso/faraday.clj
@@ -72,7 +72,7 @@
             java.nio.ByteBuffer))

 ;;;; TODO
-;; * Finish up outstanding API: as-map types, Rotary PRs, non-PR forks.
+;; * Finish up any outstanding API stuff: as-map types, Rotary PRs, non-PR forks.
 ;; * Benchmarks, further tests.
 ;; * Long-term: async API, auto throughput adjusting, ...?

@@ -404,10 +404,7 @@
     prim-kvs   - {<hash-key> <val>} or {<hash-key> <val> <range-key> <val>}.
     update-map - {<attr> [<#{:put :add :delete}> <optional value>]}.
     :return    - e/o #{:none :all-old :updated-old :all-new :updated-new}.
-    :expected  - a map of item attribute/condition pairs, all of which must be
-                 met for the operation to succeed. e.g.:
-                   {<attr> <expected-value> ...}
-                   {<attr> false ...} ; Attribute must not exist"
+    :expected  - {<attr> <#{<expected-value> false}> ...}."
   [creds table prim-kvs update-map & [{:keys [return expected]
                                        :or   {return :none}}]]
   (as-map


Add missing impl for icon-raw for get-vertex-point geom func.

--- src/uxbox/main/geom.cljs
+++ src/uxbox/main/geom.cljs
@@ -168,6 +168,7 @@
   [shape id]
   (case (:type shape)
     :icon (get-rect-vertext-point shape id)
+    :icon-raw (get-rect-vertext-point shape id)
     :rect (get-rect-vertext-point shape id)
     :circle (get-circle-vertext-point shape id)
     :text (get-rect-vertext-point shape id)))