Bump deps, remove deps, cleanup

Bump deps, remove deps, cleanup

--- project.clj
+++ project.clj
@@ -1,28 +1,21 @@
-(defproject multiplex "0.3.4-dev"
+(defproject multiplex "0.3.5"
   :description "A little tumblelog"
   :url "https://github.com/winks/multiplex"
   :dependencies
-  [[org.clojure/clojure "1.9.0"]
-   [org.clojure/data.json "0.2.6"]
-   [org.clojure/java.jdbc "0.3.7"]
-   [org.clojure/tools.trace "0.7.9"]
-   [clj-rss "0.2.3"]
-   [clj-time "0.14.4"]
+  [[org.clojure/clojure "1.10.1"]
+   [org.clojure/data.json "0.2.7"]
+   [org.clojure/java.jdbc "0.5.8"]
+   [clj-rss "0.2.5"]
+   [clj-time "0.15.2"]
    [compojure "1.6.1"]
-   [digest "1.4.8"]
+   [digest "1.4.9"]
    [korma "0.3.3"]
    [lib-noir "0.9.9"]
-   [markdown-clj "1.0.2"]
+   [markdown-clj "1.10.1"]
    [ring-server "0.5.0"]
-   [selmer "1.11.7"]
-   [com.taoensso/timbre "4.10.0"]
-   [com.taoensso/tower "3.1.0-beta5" :exclusions [org.clojure/clojure]]
-   [mysql/mysql-connector-java "5.1.31"]
-   [org.postgresql/postgresql "42.2.2.jre7"]
-   [log4j "1.2.17" :exclusions [javax.mail/mail
-                                javax.jms/jms
-                                com.sun.jdmk/jmxtools
-                                com.sun.jmx/jmxri]]]
+   [selmer "1.12.18"]
+   [mysql/mysql-connector-java "5.1.48"]
+   [org.postgresql/postgresql "42.2.10.jre7"]]
   :plugins [[lein-ring "0.12.5"]
             [lein-kibit "0.1.8"]]
   :ring {:handler multiplex.handler/app,
@@ -33,9 +26,7 @@
    :production {:ring {:open-browser? false
                        :stacktraces?  false
                        :auto-reload?  false}}
-   :dev {:dependencies [[ring/ring-mock "0.3.2"]
-                        [ring/ring-core "1.6.3"]
-                        [pjstadig/humane-test-output "0.8.3"]]
+   :dev {:dependencies [[ring/ring-core "1.8.0"]]
          :env {:dev true}
          :ring {:open-browser? false}}}
   :min-lein-version "2.7.0")


lein-release plugin: preparing 0.38 release

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject tyranitar "0.38-SNAPSHOT"
+(defproject tyranitar "0.38"
   :description "Tyranitar service"
   :url "http://wikis.in.nokia.com/NokiaMusicArchitecture/Tyranitar"


finish incomplete code in image cache

finish incomplete code in image cache

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@9447 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- plugins/SlideExplorer2/src/slide_explorer/cache.clj
+++ plugins/SlideExplorer2/src/slide_explorer/cache.clj
@@ -3,7 +3,8 @@
   (:require [clojure.core.cache :as cache]
             [slide-explorer.image :as image])
   (:use [clojure.core.cache :only (defcache CacheProtocol)])
-  (:import [java.util.concurrent Executors]))
+  (:import (java.util.concurrent Executors)
+           (java.io File)))

 (def file-service (Executors/newFixedThreadPool 1))

@@ -17,14 +18,15 @@
 (defn- add-image
   [cache-agent dir key image]
   (send-off cache-agent assoc key image)
-    (.submit file-service #(image/write-processor (key-map-to-file-name dir key) image))
+    (.submit file-service
+             #(image/write-processor (key-map-to-file-name dir key) image))
   nil)

 (defn- get-image
   [cache-agent dir key]
-  (send-off cache-agent #(.hit %1 %2) key)
   (or (clojure.core/get @cache-agent key)
       (do
+        (send-off cache-agent #(.hit %1 %2) key)
         (.submit file-service
                  #(let [image (image/read-processor (key-map-to-file-name dir key))]
                     (send-off cache-agent assoc key image)))
@@ -44,34 +46,22 @@
   (has [this key]
        "Checks if image is available in cache."))

-(deftype ImageCache [cache-agent dir memory-cache-size]
+(deftype ImageCache [cache-agent dir]
   ImageCacheProtocol
     (add [_ key image] (add-image cache-agent dir key image))
     (get [_ key] (get-image cache-agent dir key))
     (has [_ key] (has-image @cache-agent dir key))
   clojure.lang.IRef
-    (addWatch [_ Object IFn] (.addWatch cache-agent Object IFn))
+    (addWatch [this Object IFn] (do (.addWatch cache-agent Object IFn) this))
     (deref [_] (.deref cache-agent))
     (getValidator [_] (.getValidator cache-agent))
     (getWatches [_] (.getWatches cache-agent))
-    (removeWatch [_ Object] (.removeWatch cache-agent Object))
-    (setValidator [_ IFn] (.setValidator cache-agent IFn))
-  )
+    (removeWatch [this Object] (do (.removeWatch cache-agent Object) this))
+    (setValidator [_ IFn] (.setValidator cache-agent IFn)))

 (defn image-cache
-  "Creates an image cache that uses a LRU policy to store memory-cache-size images in memory,
-   and also stores all images on disk in TIFF files in the specified directory."
+  "Creates an image cache that uses a LRU policy to store memory-cache-size
+   images in memory, and also stores all images on disk in TIFF files in the
+   specified directory."
   [dir memory-cache-size]
-   (proxy [clojure.lang.Agent ImageCacheProtocol]
-           [(cache/lru-cache-factory memory-cache-size {})])
-      (add [key image] (add-image this dir key image))
-      (get [key] (get-image this dir key))
-      (has [key] (has-image this dir key))
-      (ADD
-      (toString [] (str t ". On disk: " dir)))
-
-;; test
-
-(import ij.ImageJ)
-
-(import ij.process.ByteProcessor)+  (ImageCache. (agent (cache/lru-cache-factory memory-cache-size {})) dir))


Correct where web app looks for compiled cljs files

--- src/clj/comic_reader/web_app.clj
+++ src/clj/comic_reader/web_app.clj
@@ -59,7 +59,7 @@
        [[:div.row
          [:div#app.small-12.columns]]
         [:input#history_state {:type "hidden"}]]
-       :js [(page/include-js "js/compiled/main.js")]))
+       :js [(page/include-js "js/main.js")]))

     (c/GET "/devcards" []
       (render-page
@@ -69,7 +69,7 @@
        :css [[:style (garden/css
                       [:.com-rigsomelight-devcards_rendered-card
                        [:a.button {:color "#FFF !important"}]])]]
-       :js [(page/include-js "js/compiled/devcards.js")]))
+       :js [(page/include-js "js/devcards.js")]))

     (c/context "/api/v1" []
       (cond-> (make-api-routes repository)


Rename display key in app-state

Rename display key in app-state

--- src/cljs/caves_of_cljs/core.cljs
+++ src/cljs/caves_of_cljs/core.cljs
@@ -22,8 +22,8 @@
                              (-> this
                                  (.getDOMNode)
                                  (.appendChild (.getContainer console)))
-                             (swap! state assoc :console console)))
-    :component-will-unmount (fn [this] (swap! state dissoc :console))
+                             (swap! state assoc :screen console)))
+    :component-will-unmount (fn [this] (swap! state dissoc :screen))
     :component-function (fn [state] [:div])}))

 (defn home-page [state]


Moved difficulty picker back to where it belongs, since it only affects DBpedia options

--- src/cljs/db_quiz/components.cljs
+++ src/cljs/db_quiz/components.cljs
@@ -322,7 +322,8 @@

 (defn dbpedia-options
   []
-  [:div [selector-picker]])
+  [:div [selector-picker]
+        [difficulty-picker]])

 (def advanced-options
   (let [id [:options :data-source]
@@ -353,8 +354,7 @@
   [:div
    [language-picker]
    [player-form-field :player-1 :home/player-1]
-   [player-form-field :player-2 :home/player-2]
-   [difficulty-picker]])
+   [player-form-field :player-2 :home/player-2]])

 (def start-menu
   (let [options-hidden (atom true)]


Add unfinished defineit form that saves anon user

--- src/cljs/whatishistory/core.cljs
+++ src/cljs/whatishistory/core.cljs
@@ -21,7 +21,50 @@
 ;                      #js {:success (fn [result] (js/console.log result))
 ;                           :error #(js/console.log %2)})))

-(def defn-atom (reagent/atom {:text "" :author ""}))
+(def app-atom (reagent/atom {}))
+
+(def ^:const parse-defn-class "Definition")
+
+; (defmacro handler-fn
+;   ([& body]
+;     `(fn [~'event] ~@body nil)))  ; always return nil
+
+(defn parse-init []
+  (js/Parse.initialize
+   "JSfVAQ9Qo25p2Zdyqk1KeIxt3lGXmpX0AM9TGp5Q"
+   "btvf1ywruhW5b3opO6WkrzeCp73jOsRETZ0diJ5B"))
+
+(defn generate-user-token []
+  (let [rand-str (str (js/Date.now) (rand 100000))
+        token (-> rand-str js/CryptoJS.SHA1 .toString)]
+    (str token)))
+
+; This returns a JS promise b/c that's what the signUp returns.
+(defn save-anonymous-user []
+    (let [user (js/Parse.User.)
+        token (generate-user-token)]
+    (.set user "username" token)
+    (.set user "password" token)
+    (.signUp user)))
+
+;(defn save-defn [app-atom]
+;  (let [Definition (js/Parse.Object.extend "Definition")
+;        new-defn (Definition.)
+;        new]
+;    (def defn-saved-promise (.then user-saved-promise
+;      (fn [new-defn]
+;        (.setACL new-defn usr)
+;        (.save new-defn #js {:definedby curr-user
+;                             :definition (get @app-atom :definition)
+;                             :author (condp = (get @app-atom :author)
+;                                       nil "Anonymous"
+;                                       "" "Anonymous"
+;                                       (get @app-atom :author))
+;                             :email (get @app-atom :email)
+;                             :definitionSubject "history"
+;                             :mehuman "1"}))))
+;    (.then defn-saved-promise #(js/console.log "defn saved!"))
+;    (.fail defn-saved-promise #(js/console.log "defn save failed.")))))

 (defn get-defn [idx]
   (js/Parse.Cloud.run
@@ -31,7 +74,7 @@
          (fn [result]
           (let [new-val {:text (.get result "definition")
                          :author (.get result "author")}]
-            (reset! defn-atom new-val)))
+            (reset! app-atom new-val)))
         :error #(js/console.log %2)}))

 (defn get-rand-defn []
@@ -46,35 +89,44 @@
 ;; -------------------------
 ;; Components

-(defn defn-form-content []
+(defn defn-form-content [app-atom]
   [:form {:class "defnForm"}
    [:div {:class "fieldsWrap"}
     [:input {:type "text"
              :class "authorInput"
-             :placeholder "Your Name (Optional)"}]
+             :placeholder "Your Name (Optional)"
+             :on-change (fn [evt]
+                          (swap! app-atom assoc :author evt.target.value))}]
     [:a {:class "button formToggle"} "Add Another Author's Definition"]
     [:br]
     [:input {:type "email"
              :class "emailInput"
-             :placeholder "Enter Your Email"}]
+             :placeholder "Enter Your Email"
+             :on-change (fn [evt]
+                          (swap! app-atom assoc :email evt.target.value))}]
     [:input {:type "email"
              :class "emailConfirm"
              :placeholder "Enter Your Email"}]
     [:span {:class "emailIsConfirmed no"}]
     [:textarea {:class "defnInput twelve columns"
-                :placeholder "Please compose your definition here..."}]
+                :placeholder "Please compose your definition here..."
+                :on-change (fn [evt]
+                            (swap! app-atom assoc :definition evt.target.value))}]
     [:div {:class "btnWrap"}
-     [:button {:class "button-primary defnSubmit"} "Submit"]]]])
-
-(defn defn-form []
-  [defn-form-content])
-
-(defn definition [defn-atom]
-  (fn [defn-atom]
-    (if-not (= (get @defn-atom :text) "")
+     [:button {:class "button-primary defnSubmit"
+               :on-click (fn [evt]
+                          (.preventDefault evt)
+                          (js/console.log "click"))} "Submit"]]]])
+
+(defn defn-form [app-atom]
+  [defn-form-content app-atom])
+
+(defn definition [app-atom]
+  (fn [app-atom]
+    (if-not (= (get @app-atom :text) "")
       [:section {:class "row"}
-       [:p {:class "ten columns"} (get @defn-atom :text)
-        [:span {:class "author"}" -- " (get @defn-atom :author)]]])))
+       [:p {:class "ten columns"} (get @app-atom :text)
+        [:span {:class "author"}" -- " (get @app-atom :author)]]])))

 (defn footer []
   [:footer
@@ -93,11 +145,16 @@
     (get-rand-defn)
     [:div {:class "container home"}
      [:header [:h2 {:class "title"} "What is History?"]]
-     [definition defn-atom]
+     [definition app-atom]
      [:a {:href "/defineit"} "Contribute Your Own Definition"]
      [footer]]))

 (defn defineit-page []
+  (parse-init)
+  (def usr-promise (save-anonymous-user))
+  (.then usr-promise (fn [usr]
+                       (.set usr "ip" (js/getIP))
+                       (.save usr)))
   (fn []
     [:div {:class "container defineit"}
      [:header [:h2 {:class "title"} "What is History?"]]
@@ -113,7 +170,7 @@
           much time. Ten minutes should be sufficient. It is also
           okay to cite another author who you feel expresses things
           clearly."]
-     [defn-form]]))
+     [defn-form app-atom]]))

 ; (defn about-page []
 ;   [:div [:h2 "About whatishistory"]


Simplify code to add tool-icons

Simplify code to add tool-icons

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

--- src/conexp/contrib/gui/editors/context_editor/context_editor.clj
+++ src/conexp/contrib/gui/editors/context_editor/context_editor.clj
@@ -252,16 +252,13 @@
       (doseq [icon icons]
         (if (= icon :separator)
           (.add bar (Box/createHorizontalStrut 3))
-          (let [[path alt tip fun no-return] icon
-                bctrl (make-tooltip-button
-                       tip
-                       (get-image-icon-or-string (str "context-editor/" path)
-                                                 alt))
-                handler #(if no-return
-                           (fun widget)
-                           (set-context @ectx (fun widget)))]
-            (set-handler bctrl handler)
-            (.add bar ^JComponent (get-widget bctrl)))))
+          (let [[path alt tip fun no-return] icon]
+            (.add bar (button :icon (get-image-icon-or-string (str "context-editor/" path)
+                                                              alt)
+                              :tip tip
+                              :listen [:action (if no-return
+                                                 (fn [_] (fun widget))
+                                                 (fn [_] (set-context @ectx (fun widget))))])))))
       widget))

   nil)


Readd accidentially deleted line

Readd accidentially deleted line

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

--- src/conexp/contrib/gui/editors/context_editor/context_editor.clj
+++ src/conexp/contrib/gui/editors/context_editor/context_editor.clj
@@ -263,6 +263,7 @@
                                (set-handler bctrl handler)
                                (.add toolbar ^JComponent (get-widget bctrl)))))]
       (register-keyboard-action table fill-selection-with-X "Fill-X" keystroke-fill :focus)
+      (add-widget e-ctx widget)
       (doseq [icon icons]
         (add-button bar icon))
       widget))


must have a :main before injecting the recovery app

--- sidecar/src/figwheel_sidecar/components/cljs_autobuild.clj
+++ sidecar/src/figwheel_sidecar/components/cljs_autobuild.clj
@@ -158,6 +158,7 @@
             ;; must be a fighweel build
             ;; and not a node build
             (if (and (:figwheel build-config)
+                     (:main build-config)
                      (not (= :nodejs (:target build-config))))
               (create-deadman-app-js build-config output-to-filepath e)
               (throw


fix JSDoc typo

fix JSDoc typo

--- src/main/cljs/cljs/core.cljs
+++ src/main/cljs/cljs/core.cljs
@@ -271,7 +271,7 @@
   (def ITER_SYMBOL (.-iterator js/Symbol))
   (def ITER_SYMBOL "@@iterator"))

-(def ^{:jsdoc ["@enum {string"]}
+(def ^{:jsdoc ["@enum {string}"]}
   CHAR_MAP
   #js {"-"    "_"
        ":"    "_COLON_"


Fixed failing test

Fixed failing test

--- test/time_tracker/timers/db_test.clj
+++ test/time_tracker/timers/db_test.clj
@@ -26,8 +26,9 @@
         created-timer (timers.db/create! (db/connection)
                                          project-id
                                          "gid1")
-        actual-timer  (first (jdbc/find-by-keys (db/connection) "timer"
-                                                {"project_id" project-id}))]
+        actual-timer  (timers.db/transform-timer-map
+                       (first (jdbc/find-by-keys (db/connection) "timer"
+                                                 {"project_id" project-id})))]
     (is (some? created-timer))
     (is (some? actual-timer))
     (is (contains-map? actual-timer created-timer))))


outputting same values for all keys

outputting same values for all keys

--- src/trend_compliance/core.clj
+++ src/trend_compliance/core.clj
@@ -35,17 +35,18 @@
   (filter (every-pred windows? ping-successful? trend-installed?) item))

 (def log-map (atom {}))
+(def user-map (atom {}))

 (defn create-log-map
   "take a line from detail and put into map using an atom"
   [user-map]
   (swap! log-map assoc (keyword (get user-map :Framed-IP-Address)) user-map))

-(def user-map (atom {}))
-
 (defn create-user-map
   "take a line from detail and put into map using an atom"
   [line]
+  (when (= (count (keys @user-map)) 4)
+    (create-log-map @user-map))
   (if (= (str (first line)) (re-find #"\w{3} \w{3} \d{2} \d{2}:\d{2}:\d{2} \d{4}" (str (first line))))
     (swap! user-map assoc :date (str (first line)))
     (swap! user-map assoc
@@ -71,8 +72,7 @@
   [file-name]
   (with-open [rdr (io/reader file-name)]
     (let [line (line-seq rdr)]
-      (doall (map parse-line (doall (map split-line line))))
-      (create-log-map @user-map))))
+      (doall (map parse-line (doall (map split-line line)))))))

 (defn read-csv
   "read in a csv file"


Implemented function to doubly scale fuzzy contexts

though I'm not sure whether this is correct this way...

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

--- src/conexp/contrib/fuzzy/fca.clj
+++ src/conexp/contrib/fuzzy/fca.clj
@@ -82,6 +82,28 @@
                                          (attributes context)))
                                (objects context)))))

+(defn doubly-scale-fuzzy-context
+  "Returns the doubly scaled formal context for the given fuzzy
+  context ctx."
+  [ctx]
+  (let [inz  (incidence ctx),
+        objs (set-of [g ny]
+                     [g (objects ctx),
+                      m (attributes ctx),
+                      :let [ny (inz [g m])],
+                      :when (not (zero? ny))]),
+        atts (set-of [m lambda]
+                     [g (objects ctx),
+                      m (attributes ctx),
+                      :let [lambda (inz [g m])],
+                      :when (not (zero? lambda))]),
+        inci  (set-of [[g ny] [m lambda]]
+                      [[g ny] objs,
+                       [m lambda] atts,
+                       :when (<= (f-star ny lambda)
+                                 (inz [g m]))])]
+    (make-context objs atts inci)))
+
 ;;;

 nil


Show message if argument of ref is missing

--- src/discuss/references/main.cljs
+++ src/discuss/references/main.cljs
@@ -83,7 +83,7 @@
                              :onClick #(com/jump-to-argument (:slug issue) (:uid argument))}
                         (dom/strong nil (vlib/safe-html (:text argument))))
                  (dom/div nil (t :common :author) ": " (:nickname author))
-                 (dom/div nil (t :common :issue) ": " (:title issue)))))))
+                 (dom/div nil (t :common :issue) ": " (:title issue)))))))

 (defn usage-list-view
   "List single usages of reference."
@@ -93,10 +93,14 @@
       (let [issue (:issue data)
             arguments (:arguments data)
             author (:author data)]
-        (apply dom/div nil
-               (map #(om/build single-reference-usage
-                               {:issue issue, :argument %, :author author}
-                               (lib/unique-key-dict)) arguments))))))
+        (if (some nil? [issue arguments author])
+          (dom/div #js {:className "bs-callout bs-callout-warning"}
+                   (dom/strong nil "No assigned arguments found")
+                   (dom/p nil "Maybe the assigned arguments have been removed by the author."))
+          (apply dom/div nil
+                 (map #(om/build single-reference-usage
+                                 {:issue issue, :argument %, :author author}
+                                 (lib/unique-key-dict)) arguments)))))))

 (defn usages-view
   "List with details showing the usages of the given reference."


Change to moving average for bpm sync.

Change to moving average for bpm sync.

--- src/afterglow/midi.clj
+++ src/afterglow/midi.clj
@@ -11,26 +11,35 @@
   (sync-start [this])
   (sync-stop [this]))

+;; The maximum number of clock pulse intervals to keep for averaging.
+(def ^:private max-clock-intervals 12)
+
 (defn- sync-handler
   "Called whenever a MIDI message is received from the clock source. If it is a clock pulse, update
   the ring buffer in which we are collecting timestamps, and if we have enough, calculate a BPM value
   and update the associated metronome."
-  [msg buffer metronome]
-  (when (= (:status msg) :timing-clock)
-    (let [timestamp (now)]
-      (swap! buffer conj timestamp)
-      (when (> (count @buffer) 2)
-        (let [passed (- timestamp (peek @buffer))
-              intervals (dec (count @buffer))
-              mean (/ passed intervals)]
-          (metro-bpm metronome (double (/ 60000 (* mean 24)))))))))
+  [metronome msg intervals last-timestamp]
+  (case (:status msg)
+    :timing-clock (let [timestamp (now)]
+                    (when @last-timestamp
+                      (let [delta (- timestamp @last-timestamp)]
+                        (if (< delta 1000)
+                          (do ; Not a completely ridiculous interval, so process this clock pulse
+                            (swap! intervals conj delta)
+                            (when (> (count @intervals) 2)
+                              (let [mean (/ (reduce + @intervals) (count @intervals))]
+                                (metro-bpm metronome (double (/ 60000 (* mean 24)))))))
+                          (reset! intervals (ring-buffer max-clock-intervals))))) ; Too long a gap, discard data and start over.
+                    (reset! last-timestamp timestamp))
+    (:start :stop) (reset! intervals (ring-buffer max-clock-intervals)) ; Clock is being reset!
+    nil))

 ;; A simple object which holds the values necessary to establish a link between an external
 ;; source of MIDI clock messages and the metronome driving the timing of a light show.
-(defrecord ClockSync [metronome midi-clock-source buffer]
+(defrecord ClockSync [metronome midi-clock-source intervals last-timestamp]
     IClockSync
     (sync-start [this]
-      (midi/midi-handle-events midi-clock-source (fn [msg] (sync-handler msg buffer metronome))))
+      (midi/midi-handle-events midi-clock-source (fn [msg] (sync-handler metronome msg intervals last-timestamp))))
     (sync-stop [this]
       (midi/midi-handle-events midi-clock-source (fn [msg] nil))))

@@ -39,6 +48,6 @@
   received from the named MIDI source. This synchronization can be stopped by calling the sync-stop
   function on the object returned."
   [^afterglow.rhythm.Metronome metronome ^String midi-clock-source]
-  (let [sync-handler (ClockSync. metronome (midi/midi-in midi-clock-source) (atom (ring-buffer 12)))]
+  (let [sync-handler (ClockSync. metronome (midi/midi-in midi-clock-source) (atom (ring-buffer max-clock-intervals)) (atom nil))]
     (sync-start sync-handler)
     sync-handler))


Cast default to primitive type in catch expression

--- src/clj/org/openforis/ceo/utils/type_conversion.clj
+++ src/clj/org/openforis/ceo/utils/type_conversion.clj
@@ -11,7 +11,7 @@
      (number? val)           (int val)
      :else                   (try
                                (Integer/parseInt val)
-                               (catch Exception _ default)))))
+                               (catch Exception _ (int default))))))

 (defn val->long
   ([val]
@@ -22,7 +22,7 @@
      (number? val)       (long val)
      :else               (try
                            (Long/parseLong val)
-                           (catch Exception _ default)))))
+                           (catch Exception _ (long default))))))

 ;; Warning Postgres type float is equivalent to java Double, and Postgres real is equivalent to java Float
 (defn val->float
@@ -34,7 +34,7 @@
      (number? val)        (float val)
      :else                (try
                             (Float/parseFloat val)
-                            (catch Exception _ default)))))
+                            (catch Exception _ (float default))))))

 ;; Warning Postgres type float is equivalent to java Double, and Postgres real is equivalent to java Float
 (defn val->double
@@ -46,7 +46,7 @@
      (number? val)          (double val)
      :else                  (try
                               (Double/parseDouble val)
-                              (catch Exception _ default)))))
+                              (catch Exception _ (double default))))))

 (defn val->bool
   ([val]
@@ -56,7 +56,7 @@
      val
      (try
        (Boolean/parseBoolean val)
-       (catch Exception _ default)))))
+       (catch Exception _ (boolean default))))))

 (defn json->clj
   ([json]


[#1949][#2215] Fix flow-api/check_permissions header call

--- backend/src/akvo/lumen/component/flow.clj
+++ backend/src/akvo/lumen/component/flow.clj
@@ -37,7 +37,7 @@
 (defn check-permissions
   [flow-api-url token body]
   (let [start (. System (nanoTime))
-        headers (api-headers token)
+        headers (api-headers {:token token})
         res (try
               (http.client/post*
                (str flow-api-url "/check_permissions")
@@ -48,7 +48,7 @@
                        :unexceptional-status #(<= 200 % 299)
                        :form-params body
                        :content-type :json}))
-              (catch Exception e (log/error :fail :url flow-api-url :headers headers :body body :response (ex-data e))))]
+              (catch Exception e (log/error :fail :url flow-api-url :token token :body body :response (ex-data e))))]
     (log/debug ::check-permissions :body body :res res :elapsed-time (str "Elapsed time: " (/ (double (- (. System (nanoTime)) start)) 1000000.0) " msecs"))
     res))


Try again cors matching

Try again cors matching

--- src/obb_rules_api/routes.clj
+++ src/obb_rules_api/routes.clj
@@ -46,9 +46,9 @@
 (defn setup-cors
   "Setup cors"
   [handler]
-  (cors/wrap-cors handler :access-control-allow-origin [#"http://(.+\.)?orionsbelt.eu"
-                                                        #"http://localhost:(.+)"
-                                                        #"http://orionsbelt-battlegrounds.github.io"]
+  (cors/wrap-cors handler :access-control-allow-origin [#"^http://(.+\.)?orionsbelt.eu(.*)"
+                                                        #"^http://localhost(.*)"
+                                                        #"^http://orionsbelt-battlegrounds.github.io(.*)"]
                           :access-control-allow-methods [:get :put :post :delete]))

 (def app


Upgrade karma to 4.4.1

Upgrade karma to 4.4.1


Move code to track-upload component

Move code to track-upload component

--- src/airhead_frontend/components.cljs
+++ src/airhead_frontend/components.cljs
@@ -85,12 +85,29 @@
 ;; -------------------------
 ;; Upload

+(defn track-upload [upload-state]
+  (let [{loaded      :loaded
+         total       :total
+         status      :status
+         status-body :body} @upload-state
+
+        {error-msg  :msg
+         track     :track} status-body
+
+        percentage (-> loaded
+                       (/ total) (* 100))]
+    (if (< 0 percentage 100)
+      [:progress.pure-input-1 {:max 100 :value percentage}]
+
+      [:p (if (= status 200)
+            ; TODO: show when the track appears in the library
+            "Done! It will show in the library once it gets transcoded."
+            error-msg)])))
+
 (defn upload-section []
-  (let [form-ref         (r/atom nil)
-        file-input-ref   (r/atom nil)
-
-        state (r/atom {:response nil
-                       :percentage 0})]
+  (let [form-ref       (r/atom nil)
+        file-input-ref (r/atom nil)
+        upload-state   (r/atom {})]
     ; TODO:
     ; - make state a list of chans, and append to it the retured one
     ; - loop over that list to diplay statuses
@@ -118,7 +135,7 @@
                           (let [up-chan (req/upload! form)]
                             (go-loop []
                                      (when-let [delta (<! up-chan)]
-                                       (swap! state merge delta)
+                                       (swap! upload-state merge delta)
                                        (recur))))))}
           [:i.fa.fa-upload]]]

@@ -130,18 +147,7 @@
                       (-> path (split "\\") last)  ; C:\fakepath\file-name
                       "No file selected.")))]]]

-       (let [percentage (-> (@state :loaded)
-                            (/ (@state :total)) (* 100))]
-         (when (< 0 percentage 100)
-           [:progress.pure-input-1 {:max 100 :value percentage}]))
-
-       (let [{status             :status
-              {error-msg :msg
-               track     :track} :body} @state]
-         [:p (if (= status 200)
-               ; TODO: show when the track appears in the library
-               "Done! It will show in the library once it gets transcoded."
-               error-msg)])])))
+       [track-upload upload-state]])))

 ;; -------------------------
 ;; Tracks


db/docids.clj: added max-docid

db/docids.clj: added max-docid

--- src/org/altlaw/db/docids.clj
+++ src/org/altlaw/db/docids.clj
@@ -1,5 +1,7 @@
 (ns org.altlaw.db.docids
   (:require [org.altlaw.util.simpledb :as db]))
+
+;;; PRIVATE

 (def #^{:private true} *domain* "Docids")

@@ -8,6 +10,13 @@
     ;; Ensure the key fits within SimpleDB's 1024-byte limit
     (if (< (count s) 1024)
       s (subs s 0 1024))))
+
+(def #^{:private true} *number-format* "%09d")
+
+(def #^{:private true} *base-number-string*
+     (format *number-format* 10000))
+
+;;; PUBLIC

 (defn get-docid [collection key]
   (when-let [string (get (db/get-attrs *domain*
@@ -21,8 +30,16 @@
                 {:collection collection
                  :key key
                  ;; Add leading zeros for lexicographic ordering
-                 :docid (format "%09d" docid)}))
+                 :docid (format *number-format* docid)}))

 (defn delete-docid [collection key]
   (db/delete-item *domain* (make-db-key collection key)))

+(defn max-docid []
+  (let [result (db/select-items
+                *domain*
+                (str "select docid from Docids where docid > "
+                     \' *base-number-string* \'
+                     " order by docid desc limit 1"))]
+    (Integer/parseInt (get (first (vals result)) "docid"))))
+


+log/warn if all lexical candidates fail

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -115,9 +115,11 @@
                        (do
                          (log/warn (str "no index found for spec: " (strip-refs spec)))
                          (get-lex parent :head (:index language-model))))]
-                 (log/debug (str "lightning-bolts: OPTIM size of subset of candidate heads: " (count subset) " with spec: " (strip-refs spec) " and parent:  " (:rule parent)))
+                 (log/debug (str "lightning-bolts: (optimizeme) size of subset of candidate heads: " (count subset) " with spec: " (strip-refs spec) " and parent:  " (:rule parent)))
                  (let [result (over/overh parent (lazy-shuffle subset))]
-                   (log/debug (str "lightning-bolts: OPTIM surviving candidate heads: " (count result)))
+                   (log/debug (str "lightning-bolts: (optimizeme) surviving candidate heads: " (count result)))
+                   (if (empty? result)
+                     (log/warn (str "tried: " (count subset) " lexical candidates with spec:" ( strip-refs spec) " and all of them failed as heads of parent:" (:rule parent))))
                    result)))
              parents))
           phrasal ;; 2. generate list of all phrases where the head child of each parent is itself a phrase.


whitespace

whitespace

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -74,9 +74,9 @@
                                           (map (fn [path-to-comp]
                                                  (let [complement (get paths-and-comps path-to-comp)
                                                        result (assoc-in bolt path-to-comp complement)]
-                                                   (if (= true truncate)
-                                                     (dissoc-paths result [path-to-comp])
-                                                     result)))
+                                                    (if (= true truncate)
+                                                      (dissoc-paths result [path-to-comp])
+                                                      result)))
                                                paths-to-comps)))))))))
      (map #(do-defaults % model))
      (remove #(= :fail %)))))


Back to using dag_unify.core/assoc-in

Back to using dag_unify.core/assoc-in

This reverts commit 716ff4fc9b25914d8df875dd072ea9e4b58f0642.

--- src/babel/generate.cljc
+++ src/babel/generate.cljc
@@ -1,12 +1,13 @@
 (ns babel.generate
-  (:refer-clojure :exclude [get-in deref resolve find parents])
+  (:refer-clojure :exclude [assoc-in get-in deref resolve find parents])
   (:require
    [babel.index :refer [intersection-with-identity]]
    #?(:clj [clojure.tools.logging :as log])
    #?(:cljs [babel.logjs :as log])
    [clojure.math.combinatorics :as combo]
    [clojure.string :as string]
-   [dag_unify.core :refer [copy dissoc-paths fail-path get-in fail? strip-refs unify unify!]]))
+   [dag_unify.core :refer [assoc-in assoc-in! copy create-path-in
+                           dissoc-paths fail-path get-in fail? strip-refs unify unify!]]))

 ;; during generation, will not decend deeper than this when creating a tree:
 ;; TODO: should also be possible to override per-language.


~(defn create-model): use (defn model-plus-lexicon) to create new model

--- src/babel/italiano.cljc
+++ src/babel/italiano.cljc
@@ -140,30 +140,33 @@
            true
            (str "don't know how to parse input: " (type input))))))

+;;(let [m (create-model "cane" "nero")]
+;;                 (repeatedly #(println (morph (generate {:synsem {:subcat []}
+;;                                                         :head {:phrasal true}} m)))))
+
 (defn create-model [ & words]
   (let [base-model (babel.italiano.grammar/model)
         base-lexicon
         (babel.lexiconfn/only-nonempty-vals
          (:lexicon base-model)
-         (fn [vals]
-           (filter (fn [v]
-                     (or (and (= :det (dag_unify.core/get-in v [:synsem :cat]))
-                              (= :def (dag_unify.core/get-in v [:synsem :def])))
-                         (and (= true (dag_unify.core/get-in v [:synsem :pronoun]))
-                              (= :nom (dag_unify.core/get-in v [:synsem :case])))))
-                   vals)))]
-    (merge base-model
-           {:input-words (vec words)
-            :lexical-cache (atom (cache/fifo-cache-factory {} :threshold 1024))
-            :lexicon
-            (merge
-             base-lexicon
-             (zipmap
-              (sort words)
-              (map (fn [word]
-                     (get (:lexicon base-model) word))
-                   (sort words))))})))
+         #(or (and (= :det (dag_unify.core/get-in % [:synsem :cat]))
+                   (= :def (dag_unify.core/get-in % [:synsem :def])))
+              (and (= :det (dag_unify.core/get-in % [:synsem :cat]))
+                   (= :indef (dag_unify.core/get-in % [:synsem :def])))
+              (and (= true (dag_unify.core/get-in % [:synsem :pronoun]))
+                   (= :nom (dag_unify.core/get-in % [:synsem :case])))))]
+    (merge
+     {:input-words (vec words)}
+     (babel.italiano.grammar/model-plus-lexicon
+      (merge
+       base-lexicon
+       (zipmap
+        (sort words)
+        (map (fn [word]
+               (get (:lexicon base-model) word))
+             (sort words))))))))

+


fix test to accomodate last few fixes

fix test to accomodate last few fixes

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -143,7 +143,7 @@
          (fo (generate {:modified false
                         :synsem {:cat :verb
                                  :sem {:mod '()
-                                       :obj {:pred :luisa}
+                                       :iobj {:pred :luisa}
                                        :pred :be-called
                                        :subj {:pred :lei}}}})))))


[l.d.manifest] Fix the version code bug

[l.d.manifest] Fix the version code bug

--- src/leiningen/droid/manifest.clj
+++ src/leiningen/droid/manifest.clj
@@ -74,14 +74,18 @@

 ;; ### Manifest templating

+(def ^:private version-bit-sizes
+  "Amount of bits allocated for each version bucket."
+  [9 9 9 5])
+
 (def ^:private version-maximums
   "Maximum values per each version bucket."
-  (mapv (partial bit-shift-left 1) [9 9 9 5]))
+  (mapv (partial bit-shift-left 1) version-bit-sizes))

 (def ^:private version-coefficients
   "Each part of the version number will be multiplied by the respective
   coefficient, all of which are calculated here."
-  (->> version-maximums
+  (->> version-bit-sizes
        (reductions +)
        (mapv (fn [offset] (bit-shift-left 1 (- 32 offset))))))


Fix Android version

Fix Android version

--- src/lunch_time/android/core.cljs
+++ src/lunch_time/android/core.cljs
@@ -1,32 +1,16 @@
 (ns lunch-time.android.core
   (:require [reagent.core :as r :refer [atom]]
-            [re-frame.core :refer [subscribe dispatch dispatch-sync]]
+            [re-frame.core :refer [dispatch-sync]]
             [lunch-time.events]
-            [lunch-time.subs]))
+            [lunch-time.subs]
+            [lunch-time.screens.main-screen :refer [main-screen]]))

 (def ReactNative (js/require "react-native"))

 (def app-registry (.-AppRegistry ReactNative))
-(def text (r/adapt-react-class (.-Text ReactNative)))
-(def view (r/adapt-react-class (.-View ReactNative)))
-(def image (r/adapt-react-class (.-Image ReactNative)))
-(def touchable-highlight (r/adapt-react-class (.-TouchableHighlight ReactNative)))
-
-(def logo-img (js/require "./images/cljs.png"))
-
-(defn alert [title]
-      (.alert (.-Alert ReactNative) title))

 (defn app-root []
-  (let [greeting (subscribe [:get-greeting])]
-    (fn []
-      [view {:style {:flex-direction "column" :margin 40 :align-items "center"}}
-       [text {:style {:font-size 30 :font-weight "100" :margin-bottom 20 :text-align "center"}} @greeting]
-       [image {:source logo-img
-               :style  {:width 80 :height 80 :margin-bottom 30}}]
-       [touchable-highlight {:style {:background-color "#999" :padding 10 :border-radius 5}
-                             :on-press #(alert "HELLO!")}
-        [text {:style {:color "white" :text-align "center" :font-weight "bold"}} "press me"]]])))
+ [main-screen])

 (defn init []
       (dispatch-sync [:initialize-db])


Remove unneeded import.

Remove unneeded import.

--- src/demo/web.clj
+++ src/demo/web.clj
@@ -3,8 +3,7 @@
             [immutant.web             :as web]
             [immutant.web.javax       :as javax]
             [ring.middleware.resource :as ring-resource]
-            [ring.util.response       :as ring-util])
-  (:import [javax.servlet.http HttpServlet HttpServletRequest HttpServletResponse]))
+            [ring.util.response       :as ring-util]))

 (defn echo-request
   "Echoes the request back as a string."


Have integs depend on wildfly so the build order is always correct.

--- integration-tests/project.clj
+++ integration-tests/project.clj
@@ -15,7 +15,8 @@
 (defproject org.immutant/integs "2.0.0-SNAPSHOT"
   :plugins [[lein-modules "0.3.8"]
             [lein-immutant "2.0.0-SNAPSHOT"]]
-  :dependencies [[org.immutant/immutant _]]
+  :dependencies [[org.immutant/immutant _]
+                 [org.immutant/wildfly _]]
   :aliases {"all" ^:replace ["do" "clean," "test"]}
   :profiles {:integ-base {:aliases {"test" ^:displace ["immutant" "test"]}}
              :integ-messaging {:test-paths ["../messaging/test"]}


added bootstrap-style grid

added bootstrap-style grid

- container, column, row
- offsets and blocks

credit: modified from noprompt's blog!

--- src/cljx/mesh/grid.cljx
+++ src/cljx/mesh/grid.cljx
@@ -6,6 +6,7 @@
             [garden.color :as color :refer [hsl rgb]]
             [garden.arithmetic :refer [+ - * /]]
             [garden.stylesheet :refer [at-media]]
+            [mesh.respond :as respond]
             [mesh.utils :refer [border-box clearfix reset-padding]]))

 (defn initialize [clazz gutter]
@@ -19,7 +20,9 @@
      [:&:first-child {:padding-left gutter}]
      [:&:last-child {:padding-right gutter}]]]])

-;; https://css-tricks.com/dont-overthink-it-grids/
+;; A simple Grid, based on on 1,2,4,8 columns
+;; https://css-tricks.com/dont-overthink-it-grids
+
 (defn create-minimal-grid [clazz pad]
   [[:* {:box-sizing "border-box"}]
    [clazz {:background "white"
@@ -37,6 +40,8 @@
     [:.col-1-8 {:width "12.50%"}]
     [:.out-padding {:padding [[pad 0 pad pad pad]]}
      ["[class*='col-']:last-of-type" {:padding-right pad}]]]])
+
+;; Fluid/Fractional Grids, with nesting

 (defn create-nested-units []
   [:.unit
@@ -113,3 +118,42 @@
             [:.wider
              [:.grid {:max-width width
                       :margin "0 auto"}]]))
+
+;; Bootstrap style Container=>Row=>Column based Grids with 15px margins, and offsets
+
+(def container
+  (list
+   [:& clearfix]
+   (respond/phone)
+   (respond/phablet)
+   (respond/tablet)
+   (respond/desktop)
+   (respond/hd)))
+
+(defn offset [n]
+  (let [m (min (max 0 n) 12)]
+    [:&
+     {:margin-left (% (* 100 (/ n 12.0)))}]))
+
+(defn col [n]
+  (let [m (min (max 0 n) 12)]
+    [:&
+     {:float :left
+      :position :relative
+      :min-height (px 1)
+      :padding-left (px 15)
+      :padding-right (px 15)
+      :width (% (* 100 (/ m 12.0)))}]))
+
+(def row
+  [:&
+   {:margin-right (px -15)
+    :margin-left (px -15)}
+   clearfix])
+
+(defn block [& {:as opts}]
+  [:&
+   (when-let [c (:col opts)]
+     (col c))
+   (when-let [o (:offset opts)]
+     (offset o))])


+test: no updates under cursor - no callback call for subscriber

--- test/rex/core_test.cljs
+++ test/rex/core_test.cljs
@@ -81,7 +81,9 @@
              cursor]
           (let [old-value (get state :field [])
                 event-value (get event :value :no-value)]
-            (assoc state :field (conj old-value event-value)))))
+            (if (= event-type :some-event-type)
+              (assoc state :field (conj old-value event-value))
+              state))))

       (sb/defsubscriber (cur/nest (cur/make-cursor) :field)
         (fn [store-value]
@@ -94,4 +96,10 @@
       (cr/dispatch nil (hp/test-action-creator :some-event-type :value2))
       (is (= [{:field [:value1]}
               {:field [:value1 :value2]}]
+             @watch-vec))
+
+      ;; no changes under cursor - no callback calls for subscriber
+      (cr/dispatch nil (hp/test-action-creator :other-event-type :other-value))
+      (is (= [{:field [:value1]}
+              {:field [:value1 :value2]}]
              @watch-vec)))))


Three server tests: test-get-title, test-get-emender-page, and test-get-url-prefix

--- test/zg/server_test.clj
+++ test/zg/server_test.clj
@@ -240,3 +240,39 @@
 ; Test for function behaviours
 ;

+(deftest test-get-title
+    "Check the function get-title."
+    (testing "the function get-title."
+        (are [x y] (= x (get-title y))
+            "ZG" {:configuration {:display {:app-name "ZG"}}}
+            nil  {:configuration {:display {:app-name nil}}}
+            nil  {:configuration {:display nil}}
+            nil  {:configuration {:something-else nil}}
+            nil  {:configuration nil}
+            nil  {:something-else nil}
+            nil  nil)))
+
+(deftest test-get-emender-page
+    "Check the function get-emender-page."
+    (testing "the function get-emender-page."
+        (are [x y] (= x (get-emender-page y))
+            "http://www.emender.org" {:configuration {:display {:emender-page "http://www.emender.org"}}}
+            nil  {:configuration {:display {:emender-page nil}}}
+            nil  {:configuration {:display nil}}
+            nil  {:configuration {:something-else nil}}
+            nil  {:configuration nil}
+            nil  {:something-else nil}
+            nil  nil)))
+
+(deftest test-get-url-prefix
+    "Check the function get-url-prefix."
+    (testing "the function get-url-prefix."
+        (are [x y] (= x (get-url-prefix y))
+            "http://localhost" {:configuration {:server {:url-prefix "http://localhost"}}}
+            nil  {:configuration {:server {:url-prefix nil}}}
+            nil  {:configuration {:server nil}}
+            nil  {:configuration {:something-else nil}}
+            nil  {:configuration nil}
+            nil  {:something-else nil}
+            nil  nil)))
+


Explicitly disable discovery when signing in to the account.

Signed-off-by: yenda <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@status.im>

--- src/status_im/node/core.cljs
+++ src/status_im/node/core.cljs
@@ -76,7 +76,8 @@
       (get-base-node-config)

       current-fleet
-      (assoc :NoDiscovery false
+      (assoc :NoDiscovery   false
+             :Rendezvous    false
              :ClusterConfig {:Enabled true
                              :Fleet              (name current-fleet-key)
                              :BootNodes          (pick-nodes 4 (vals (:boot current-fleet)))


Test close of close-accept-ch.

Test close of close-accept-ch.

--- src/cbfg/net-test.cljs
+++ src/cbfg/net-test.cljs
@@ -68,7 +68,22 @@
                     (and (e n (atake tn connect-result-ch) nil nil)
                          (do (aclose tn listen-ch)
                              (aclose tn connect-ch)
-                             (e n (atake tn net) :done (atake tn net))))))
+                             (e n (atake tn net) :done (atake tn net)))))
+                  (let [listen-ch (achan tn)
+                        connect-ch (achan tn)
+                        net (make-net tn listen-ch connect-ch)
+                        listen-result-ch (achan tn)]
+                    ; Close of close-accept-ch should close accept-ch and fail new connects.
+                    (aput tn listen-ch [:addr-a 1000 listen-result-ch])
+                    (let [[close-accept-ch accept-ch] (atake tn listen-result-ch)]
+                      (aclose tn close-accept-ch)
+                      (and (e n (atake tn accept-ch) nil nil)
+                           (let [connect-result-ch (achan tn)]
+                             (aput tn connect-ch [:addr-a 1000 :addr-x connect-result-ch])
+                             (and (e n (atake tn connect-result-ch) nil nil)
+                                  (do (aclose tn listen-ch)
+                                      (aclose tn connect-ch)
+                                      (e n (atake tn net) :done (atake tn net)))))))))
            "pass"
            (str "FAIL: on test-net #" @n)))))


Remove unused render-prog-frame.

Remove unused render-prog-frame.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -124,11 +124,6 @@
     (on-prog-frame-blur)))

 ; -------------------------------------------------------------------
-
-(defn render-prog-frame [prog-frame owner]
-  (apply dom/ul nil
-         (map (fn [[k v]] (dom/li nil (str k ":" (if (number? v) v (count v)))))
-              prog-frame)))

 (defn render-evts [app owner]
   (apply dom/ul nil


added test

added test

--- moebius/test/moebius/core_test.clj
+++ moebius/test/moebius/core_test.clj
@@ -135,6 +135,24 @@

+(facts "about `when-event-is`: if the condition is truthy then do something, otherwise lave the event unchanged"
+
+
+       (let [event {:eventName "event1"}]
+
+         ;; if the condition is not satisfied then don't do anything
+         (when-event-is event (= true false)
+                        (assoc event :b 2))
+         => {:eventName "event1"}
+
+
+         ;; if the condition is not satisfied then apply the body
+         (when-event-is event (= 1 1)
+                        (assoc event :b 2))
+         => {:eventName "event1" :b 2}))
+
+
+
 (facts "about `when-event-name-is`: if the eventName matches the given name, or names,
                 then do something, otherwise lave the event unchanged"


Refactor - add `remove-from-ModulesSelectedOrder!` function

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -268,6 +268,11 @@
   "Appends a module to `ModulesSelectedOrder`"
   [moduleCode]
   (set! ModulesSelectedOrder (conj ModulesSelectedOrder moduleCode)))
+
+(defn- remove-from-ModulesSelectedOrder!
+  "Removes a module from `ModulesSelectedOrder`"
+  [moduleCode]
+  (set! ModulesSelectedOrder (remove #{moduleCode} ModulesSelectedOrder)))

 (defn- select2-box-update-modules
   "Update the select2 box with the currently selected modules"
@@ -1511,8 +1516,7 @@

         (remove-module-from-document-location-hash! moduleCode)

-        ; Remove from `ModulesSelectedOrder`
-        (set! ModulesSelectedOrder (remove #{moduleCode} ModulesSelectedOrder))
+        (remove-from-ModulesSelectedOrder! moduleCode)
         (.log js/console "I hear and obey!")
         ; Update Select2 box
         (select2-box-update-modules))))


[REFACTOR] Use destructuring

[REFACTOR] Use destructuring

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

--- src/cljs/cljs_nusmods/timetable.cljs
+++ src/cljs/cljs_nusmods/timetable.cljs
@@ -280,12 +280,12 @@
                 ModulesSelected
                 [moduleCode lessonType :info]
                 (fn [modSelLessonInfoSeq]
-                  (conj (filter (fn [modSelLessonInfo]
-                                  (or (not= (:day modSelLessonInfo) day)
-                                      (not= (:startTime modSelLessonInfo)
-                                            startTime)
-                                      (not= (:endTime modSelLessonInfo)
-                                            endTime)))
+                  (conj (filter (fn [{modDay       :day
+                                      modStartTime :startTime
+                                      modEndTime   :endTime}]
+                                  (or (not= modDay day)
+                                      (not= modStartTime startTime)
+                                      (not= modEndTime endTime)))
                                 modSelLessonInfoSeq)
                         {:day day,
                          :rowNum rowIdx,


Command hints as border color, not key color.

--- src/mash_commander/keyboard.cljs
+++ src/mash_commander/keyboard.cljs
@@ -17,14 +17,13 @@
                             :textAlign "center"
                             :fontSize "30px"
                             :borderWidth "2px"
-                            :borderColor "#000"
+                            :borderColor (if (= :command potential) "#227" "#000")
                             :borderStyle "solid"
                             :borderRadius "8px"
-                            :color (condp = potential
-                                     :command "#33f"
-                                     :typing "#0b0"
-                                     :mashing "#060"
-                                     :disabled "#444")}
+                            :color (cond
+                                     (contains? #{:command :typing} potential) "#0b0"
+                                     (= :mashing potential) "#060"
+                                     :else "#444")}
                            (:style key-spec)))
                   :onMouseDown #(when-not (= :disabled potential)
                                   (mode/dispatch-keydown line-cursor owner


written error cases for build-lookup-table test

--- test/grafter/tabular_test.clj
+++ test/grafter/tabular_test.clj
@@ -215,7 +215,14 @@
       (testing "key column id"
         (is (= ((build-lookup-table ds 0 "B") row) {"B" 6})))
       (testing "key column name"
-        (is (= ((build-lookup-table ds "A" "B") row) {"B" 6}))))))
+        (is (= ((build-lookup-table ds "A" "B") row) {"B" 6}))))
+    (testing "errors"
+      (testing "no key column"
+        (is (thrown? IndexOutOfBoundsException
+                     ((build-lookup-table ds [] "B") row))))
+      (testing "key column not existing"
+        (is (thrown? IndexOutOfBoundsException
+                     ((build-lookup-table ds ["foo"] "B") row)))))))

 (comment


fix that d3 source

fix that d3 source

--- src/clj/ceres/core.clj
+++ src/clj/ceres/core.clj
@@ -26,7 +26,7 @@
   [:#react-js] (set-attr "src" "static/react/react-0.9.0.min.js")
   [:#jquery-js] (set-attr "src" "static/jquery/jquery-1.11.0.min.js")
   [:#bootstrap-js] (set-attr "src" "static/bootstrap/bootstrap-3.1.1-dist/js/bootstrap.min.js")
-  [:d3-js] (set-attr "src" "static/d3/d3.min.js")
+  [:#d3-js] (set-attr "src" "static/d3/d3.min.js")
   [:#js-files] (substitute (html [:script {:src "js/main.js" :type "text/javascript"}])))


send only articles to frontend

send only articles to frontend

--- src/clj/ceres/core.clj
+++ src/clj/ceres/core.clj
@@ -88,8 +88,7 @@
   (let [articles (mapv format-article (store tweet))
         data (extract-tweet-data tweet)]
     (swap! state update-in [:app :recent-articles] (fn [old new] (vec (take 100 (into old new)))) articles)
-    (when (not(empty? articles))
-      (doall (map #(put! % {:topic :new-article :data articles}) (-> @state :app :out-chans))))
+    (when (not(empty? articles)) (doall (map #(put! % {:topic :new-article :data articles}) (-> @state :app :out-chans))))
     (swap! state update-in [:app :recent-tweets] (fn [old new] (vec (take 100 (into [new] old)))) tweet)))


formatting

formatting

--- src/clj/flambo/api.clj
+++ src/clj/flambo/api.clj
@@ -109,10 +109,10 @@
       (.map (function double-untuple))))

 (defn sample [rdd with-replacement? fraction seed]
-    (-> rdd
-        (.map (pair-function identity))
-        (.sample with-replacement? fraction seed)
-        (.map (function untuple))))
+  (-> rdd
+      (.map (pair-function identity))
+      (.sample with-replacement? fraction seed)
+      (.map (function untuple))))

 ;;; Actions
 (defn save-as-text-file [rdd path]


Update the build data when the branch changes

Previously the chosen branch wasn't being indexed nor was it available
for notifications.  The log was the only place to see that the branch
had changed.

--- src/clj/runbld/scm.clj
+++ src/clj/runbld/scm.clj
@@ -99,7 +99,7 @@
                     (re-matches #"^[a-fA-F0-9]{5,40}$"
                                 (string/trim x)))))]
     (let [branches (cond->> [build-branch]
-                     (and (not (empty? scm-branch)))
+                     (not (empty? scm-branch))
                      (cons scm-branch)

                      (and (not (empty? env-branch))
@@ -108,6 +108,11 @@
           commit (first (take-while commit? branches))
           branch (first (drop-while commit? branches))]
       {:commit commit :branch (or branch "master")})))
+
+(defn clean-branch-name [branch]
+  (-> branch
+      (string/replace #"^refs/heads/" "")
+      (string/replace #"^origin/" "")))

 (defn checkout-dir [opts]
   (let [cwd (-> opts :process :cwd)]
@@ -133,5 +138,6 @@
         (update-workspace local branch depth)
         (clone-workspace local remote reference branch depth))
       (when commit
-        (checkout-commit local commit))))
-  opts)
+        (checkout-commit local commit)))
+    ;; Update the build data
+    (assoc-in opts [:build :branch] (clean-branch-name branch))))


Set profile thumbnail format as jpg.

Set profile thumbnail format as jpg.

--- src/uxbox/frontend/users.clj
+++ src/uxbox/frontend/users.clj
@@ -24,7 +24,7 @@
               :dst :photo
               :size [100 100]
               :quality 90
-              :format "webp"}]
+              :format "jpg"}]
     (images/populate-thumbnails user opts)))

 ;; --- Retrieve Profile


Remove unnecessary whitespace from tests

--- test/re-frame/middleware.cljs
+++ test/re-frame/middleware.cljs
@@ -15,19 +15,19 @@

 (deftest trim-v
   (let [handler (fn [db vect] vect)]
-    (is (= (handler nil [:a :b :c])
+    (is (= (handler nil [:a :b :c])
            [:a :b :c]))
-    (is (= ((middleware/trim-v handler) nil [:a :b :c])
+    (is (= ((middleware/trim-v handler) nil [:a :b :c])
            [:b :c]))))

 (deftest path
   (let [db  {:a true}
-        handler (fn
-                  [a [_]]
-                  (not a))]
+        handler (fn
+                  [a [_]]
+                  (not a))]
     (let [new-db (((middleware/path [:a])
                    handler) db [nil])]
-      (is (= (:a new-db)
+      (is (= (:a new-db)
              false)))))

@@ -38,4 +38,4 @@
              (is (= (wrapped {:a 0 :b 2} 0)               ;; no change in 'a'
                     {:a 0 :b 2}))
              (is (= (wrapped {:a 4 :b 2} 0)               ;; 'a' changed to 0
-                    {:c 2 :a 0 :b 2}))))                  ;; 'c' is a + b+                    {:c 2 :a 0 :b 2}))))                  ;; 'c' is a + b


Some reformatting

Some reformatting

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

--- src/conexp/contrib/draw/lattices.clj
+++ src/conexp/contrib/draw/lattices.clj
@@ -7,62 +7,52 @@
 ;; You must not remove this notice, or any other, from this software.

 (ns conexp.contrib.draw.lattices
-  (:use [conexp.base
-         :only (ns-doc,
-                illegal-argument,
-                with-printed-result,
-                now,
-                defvar-,
-                defmacro-,
-                defnk)]
-        [conexp.math.util
-         :only (with-doubles)]
-        [conexp.layouts
-         :only (*standard-layout-function*,
-                inf-additive-layout)]
-        [conexp.layouts.util
-         :only (scale-layout)]
-        [conexp.layouts.base
-         :only (lattice,
-                annotation)]
-        [conexp.layouts.force
-         :only (force-layout,
-                layout-energy,
-                *repulsive-amount*,
-                *attractive-amount*,
-                *gravitative-amount*)]
-        [conexp.contrib.gui.util
-         :only (with-swing-error-msg,
-                action-on)]
+  (:use [conexp.base             :only (ns-doc,
+                                        illegal-argument,
+                                        with-printed-result,
+                                        now,
+                                        defvar-,
+                                        defmacro-,
+                                        defnk)]
+        [conexp.math.util        :only (with-doubles)]
+        [conexp.layouts          :only (*standard-layout-function*,
+                                        inf-additive-layout)]
+        [conexp.layouts.util     :only (scale-layout)]
+        [conexp.layouts.base     :only (lattice,
+                                        annotation)]
+        [conexp.layouts.force    :only (force-layout,
+                                        layout-energy,
+                                        *repulsive-amount*,
+                                        *attractive-amount*,
+                                        *gravitative-amount*)]
+        [conexp.contrib.gui.util :only (with-swing-error-msg,
+                                        action-on)]
         ;; drawing
-        [conexp.contrib.draw.scenes
-         :only (scene-height,
-                scene-width,
-                add-callback-for-hook,
-                call-hook-with,
-                redraw-scene,
-                start-interaction,
-                get-zoom-factors,
-                save-image,
-                get-canvas-from-scene,
-                show-labels,
-                add-scrollbars)]
-        [conexp.contrib.draw.scene-layouts
-         :only (draw-on-scene,
-                get-layout-from-scene,
-                fit-scene-to-layout,
-                update-layout-of-scene,
-                do-nodes)]
-        [conexp.contrib.draw.nodes-and-connections
-         :only (move-interaction,
-                zoom-interaction,
-                move-node-by,
-                all-nodes-above,
-                all-nodes-below,
-                all-inf-add-influenced-nodes,
-                all-sup-add-influenced-nodes,
-                *default-node-radius*,
-                set-node-radius!)],
+        [conexp.contrib.draw.scenes                :only (scene-height,
+                                                          scene-width,
+                                                          add-callback-for-hook,
+                                                          call-hook-with,
+                                                          redraw-scene,
+                                                          start-interaction,
+                                                          get-zoom-factors,
+                                                          save-image,
+                                                          get-canvas-from-scene,
+                                                          show-labels,
+                                                          add-scrollbars)]
+        [conexp.contrib.draw.scene-layouts         :only (draw-on-scene,
+                                                          get-layout-from-scene,
+                                                          fit-scene-to-layout,
+                                                          update-layout-of-scene,
+                                                          do-nodes)]
+        [conexp.contrib.draw.nodes-and-connections :only (move-interaction,
+                                                          zoom-interaction,
+                                                          move-node-by,
+                                                          all-nodes-above,
+                                                          all-nodes-below,
+                                                          all-inf-add-influenced-nodes,
+                                                          all-sup-add-influenced-nodes,
+                                                          *default-node-radius*,
+                                                          set-node-radius!)],
         conexp.contrib.draw.buttons)
   (:import [javax.swing JFrame JPanel JButton JTextField JLabel
                         JSeparator SwingConstants BoxLayout Box


Only store one day of classifications

Only store one day of classifications

--- src/zoo_live/model/redis.clj
+++ src/zoo_live/model/redis.clj
@@ -1,5 +1,5 @@
 (ns zoo-live.model.redis
-  (:use [clj-time.core :only [day month now minus weeks]])
+  (:use [clj-time.core :only [day month now minus days]])
   (:require [taoensso.carmine :as car]
             [zoo-live.model.postgres :as p]))

@@ -18,9 +18,9 @@
         location (first (p/find-ips (:user_ip classification)))
         country (:country location)
         today (now)
-        week-ago (minus today (weeks 1))
+        day-ago (minus today (days 1))
         date (str (month today) "-" (day today))
-        prev-date (str (month week-ago) "-" (day week-ago))
+        prev-date (str (month day-ago) "-" (day day-ago))
         record (dissoc (merge classification
                               {:location location
                                :id id}) :user_ip)]
@@ -30,8 +30,8 @@
       (car/lpush "classifications" record)
       (car/ltrim "classifications" 0 99)
       (car/lpush (str "classifications-" date) record)
-      (if (= 1 (wcar* (car/exists (str "classifications-" week-ago))))
-        (car/del (str "classifications-" week-ago))))))
+      (if (= 1 (wcar* (car/exists (str "classifications-" prev-date))))
+        (car/del (str "classifications-" prev-date))))))

 (defn get-all
   ([]


Do not box operation length

Do not box operation length

--- src/plumula/delta/operation.cljc
+++ src/plumula/delta/operation.cljc
@@ -58,7 +58,7 @@
   (operation/length (operation/insert \"hi\"))
   ; returns 2
   "
-  [op]
+  ^long [op]
   (or
     (:plumula.delta/delete op)
     (:plumula.delta/retain op)


rewrite values impl for conform/encode pairs

needed to standardise type keyword to allow multimethod dispatch

--- src/crucible/values.clj
+++ src/crucible/values.clj
@@ -1,26 +1,62 @@
 (ns crucible.values
   (:require [clojure.spec :as s]
+            [camel-snake-kebab.core :refer [->PascalCase]]
             [crucible.pseudo :as pseudo]))

 (s/def ::ref keyword?)
 (s/def ::att keyword?)
-
-(defmulti function-type ::type)
-
-(s/def ::fn (s/multi-spec function-type ::type))
-
-(s/def ::xref (s/cat :ref keyword? :att (s/? keyword?)))
-
-(s/def ::value (s/or :string string?
-                     :xref ::xref
-                     :pseudo ::pseudo/parameter
-                     :function ::fn))
-
-
 (s/def ::delimiter string?)
 (s/def ::values (s/+ ::value))
+(s/def ::index (s/and pos? integer?))

-(s/def ::index (s/and pos? integer?))
+(defmulti value-type ::type)
+(defmulti encode-value ::type)
+
+(s/def ::value (s/multi-spec value-type ::type))
+
+(defmethod value-type ::xref [_]
+  (s/keys :req [::type ::ref]
+          :opt [::att]))
+
+(defmethod encode-value ::xref [{:keys [::ref ::att]}]
+  (if att
+    {"Fn::GetAtt" [ref att]}
+    {"Ref" ref}))
+
+(defmethod value-type ::pseudo [_]
+  (s/keys :req [::type ::param]))
+
+(defmethod encode-value ::pseudo [{:keys [::param]}]
+  {"Ref" (-> param name ->PascalCase str)})
+
+(defmethod value-type ::string [_]
+  (s/keys :req [::type ::value]))
+
+(defmethod encode-value ::string [{:keys [::value]}]
+  (str value))
+
+(defmethod value-type ::join [_]
+  (s/keys :req [::type ::values]
+          :opt [::delimiter]))
+
+(defmethod encode-value ::join [{:keys [::delimiter ::values]}]
+  {"Fn::Join" [(or delimiter "") (vec (map encode-value values))]})
+
+(defmethod value-type ::select [_]
+  (s/keys :req [::type ::values ::index]))
+
+(defmethod encode-value ::select [{:keys [::index ::values]}]
+  {"Fn::Select" [(str index) (vec (map encode-value values))]})
+
+(defn xref
+  ([ref]
+   {::type ::xref ::ref ref})
+  ([ref att]
+   {::type ::xref ::ref ref ::att att}))
+
+(defn pseudo [param]
+  {::type ::pseudo
+   ::param param})

 (defn join
   ([values]
@@ -30,14 +66,7 @@
     ::values values
     ::delimiter delimiter}))

-(defmethod function-type ::join [_]
-  (s/keys :req [::values]
-          :opt [::delimiter]))
-
 (defn select [index values]
   {::type ::select
    ::index index
    ::values values})
-
-(defmethod function-type ::select [_]
-  (s/keys :req [::values ::index]))


Update docstring for `content-pre-wrap`

Update docstring for `content-pre-wrap`

--- src/io/perun.clj
+++ src/io/perun.clj
@@ -219,14 +219,14 @@
   '[[org.clojure/tools.namespace "0.3.0-alpha3"]])

 (defn content-pre-wrap
-  "Wrapper for input parsing tasks. Calls `parse-form` on new or changed
-  files with extensions in `extensions`, adds `tracer` to `:io.perun/trace`
-  and writes files for subsequent tasks to process, if desired.
-  `output-extension` can be used to indicate the type of file the task produces,
-  or pass `nil` to overwrite with a file of the same name and extension. Pass
-  `pod` if one is needed for parsing. In cases where parsing only depends on the
-  content of its input files rather than their metadata, set `passthru-fn` to
-  handle setting changed metadata on files copied from the previous fileset"
+  "Wrapper for input parsing tasks. Calls the return from `render-form-fn` on
+  new or changed inputs returned from `paths-fn`, adds `tracer` to
+  `:io.perun/trace` and writes files for subsequent tasks to process, if
+  desired. Pass `pod` if one is needed for parsing. In cases where parsing only
+  depends on the content of its input files rather than their metadata, set
+  `passthru-fn` to handle setting changed metadata on files copied from the
+  previous fileset. If input files should be removed from the fileset, set
+  `rm-originals` to `true`."
   [{:keys [task-name render-form-fn paths-fn passthru-fn tracer pod rm-originals]}]
   (let [tmp  (boot/tmp-dir!)
         prev (atom {})


possibility to add trigger

possibility to add trigger

--- src/datasplash/core.clj
+++ src/datasplash/core.clj
@@ -32,7 +32,7 @@
            [java.util UUID]
            [org.joda.time DateTimeUtils DateTimeZone]
            [org.joda.time.format DateTimeFormat DateTimeFormatter]
-           [com.google.cloud.dataflow.sdk.transforms.windowing Window FixedWindows SlidingWindows Sessions]
+           [com.google.cloud.dataflow.sdk.transforms.windowing Window FixedWindows SlidingWindows Sessions Trigger]
            [org.joda.time Duration]))

 (def required-ns (atom #{}))
@@ -263,7 +263,7 @@
   (ds/map (fn [e] (ds/with-timestamp (clj-time.core/now) (* 2 e)) pcoll))
   ```"
   [timestamp result]
-  (->TimeStamped (timc/to-long timestamp) result))
+  (->TimeStamped timestamp result))

 (defn output-value!
   [^DoFn$ProcessContext context entity bindings]
@@ -1766,6 +1766,20 @@
   (or (and (instance? Duration time) time)
       (.toStandardDuration time)))

+(def accumulation-mode-enum
+  {:accumulate #(.accumulatingFiredPanes %)
+   :discard #(.discardingFiredPanes %)})
+
+(def window-schema
+  (merge
+   named-schema
+   {:trigger {:docstr "Adds a Trigger to the Window."
+              :action (fn [transform ^Trigger t] (.triggering transform t))}
+    :with-allowed-lateness {:docstr "Allow late data. Mandatory for custom trigger"
+                            :action (fn [transform d] (.withAllowedLateness (->duration d)))}
+    :accumulate-mode {:docstr "Accumulate mode when a Trigger is fired (accumulate or discard)"
+                      :action (fn [transform acc] ((get accumulation-mode-enum acc) transform))}}))
+
 (defn sliding-windows
   {:doc (with-opts-docstr
           "Apply a sliding window input PCollection (useful for unbounded PCollections).
@@ -1777,7 +1791,7 @@
 (require '[clj-time.core :as time])
 (ds/sliding-windows (time/minutes 30) (time/seconds 5) pcoll)
 ```"
-          named-schema)
+          window-schema)
    :added "0.4.1"}
   ([width step options ^PCollection pcoll]
    (let [transform (-> (->duration width)
@@ -1798,7 +1812,7 @@
 (require '[clj-time.core :as time])
 (ds/session-windows (time/minutes 10) pcoll)
 ```"
-          named-schema)
+          window-schema)
    :added "0.4.1"}
   ([gap options ^PCollection pcoll]
    (let [transform (-> (->duration gap)


improving doc

improving doc

--- src/ew_snmp/SNMPApi.clj
+++ src/ew_snmp/SNMPApi.clj
@@ -1,3 +1,9 @@
+;; # GEN-CLASS to use from java environment once we have the standalone library
+;;
+;; ### Defaults:
+;; **TransportMappingProtocol:** UDP
+;;
+;; **UDP-PORT get communication** 161
 (ns ew_snmp.SNMPApi
   (:use [ew_snmp.v2 :only [ getv2]]
         [ew_snmp.v3 :only [ getv3]])
@@ -10,62 +16,55 @@
                #^{:static true} [v3allb [String String String "[Ljava.lang.Object;"] "[Ljava.lang.Object;"]
                ]))

-;; # Defaults:
-;; **TransportMappingProtocol:** UDP
-;;
-;; **UDP-PORT get communication** 161

+;; # SNMP version 2
+;; ---

 (defn -v2
-  "SNMP v2c
-   arguments: host, community-name, object-identifier
-   return: first object"
+  "**v2**: usefull in case to have a single oid and want to return single string value
+> [host, community-name, object-identifier] => String: first object"
   [h c oid]
   (first (getv2 h c [oid]))
   )

 (defn -v2all
-  "SNMP v2c
-
-   arguments: host, community-name, object-identifier
-
-   return: objects array"
+  "**v2all**: in case to have a single oid and want to return a array of string values
+> [host, community-name, object-identifier] => [String]: all objects
+"
   [h c oid]
   (to-array (getv2 h c [oid]))
   )

 (defn -v2allb
-  "SNMP v2c
-   arguments: host, community-name, array object-identifiers \\
-   return: objects array"
+  "**v2allb**: we pass an array of oids to obtain an array of values according to
+> [host, community-name, array object-identifiers] => [String]: objects array"
   [h c oid]
   (to-array (getv2 h c oid))
   )

+;; # SNMP version 3
+;; ---

 (defn -v3
-  "SNMP v3
-
-   arguments: host, user-name, user-password, object-identifier
-
-   return: first object"
+  "**v3**: usefull in case to have a single oid and want to return single string value
+> [host, community-name, object-identifier] => String: first object"
   [ip u p oid]
   (first (getv3 ip u p [oid])))

 (defn -v3all
-  "SNMP v3
-   arguments: host, user-name, user-password, object-identifier
-   return: objects array"
+    "**v3all**: in case to have a single oid and want to return a array of string values
+> [host, community-name, object-identifier] => [String]: all objects
+"
   [ip u p oid]
   (to-array (getv3 ip u p [oid])))

  (defn -v3allb
-  "SNMP v3
-   arguments: host, user-name, user-password, array object-identifiers
-   return: objects array"
+   "**v3allb**: we pass an array of oids to obtain an array of values according to
+> [host, community-name, array object-identifiers] => [String]: objects array"
   [ip u p oid]
   (to-array (getv3 ip u p oid)))
+

 (comment
   (-v2 "localhost" "public" "1.3.6.1.2.1.1.5.0")
@@ -75,3 +74,32 @@
   (-v3all "127.0.0.1" "juanv3" "comomolalagramola" "1.3.6.1.2.1.1.5.0")
   (-v3allb "127.0.0.1" "juanv3" "comomolalagramola" ["1.3.6.1.2.1.1.5.0" "1.3.6.1.2.1.1.6.0"] )
  )
+
+;; # example of use from java
+;;
+;;     import ew_snmp.SNMPApi
+;;     class HelloJava {
+;;     public  static void  printArray(Object[] array)
+;;     {
+;;         for (int i = 0; i < array.length; i++)
+;;             {
+;;                 System.out.println("array:" + array[i]);
+;;             }
+;;     }
+;;     public static void main(String[] args) {
+;;         System.out.println("Hello from Java!");
+;;         System.out.println("v2: "+SNMPApi.v2 ("localhost", "public", "1.3.6.1.2.1.1.5.0"));
+;;         System.out.println("v2all:");
+;;         HelloJava.printArray(SNMPApi.v2all ("localhost", "public", "1.3.6.1.2.1.1.5.0"));
+;;         System.out.println("v2allb:");
+;;         HelloJava.printArray(SNMPApi.v2allb ("localhost", "public", new String[] {"1.3.6.1.2.1.1.5.0", "1.3.6.1.2.1.1.6.0"}));
+;;         System.out.println("v3: "+SNMPApi.v3 ("localhost", "juanv3", "comomolalagramola", "1.3.6.1.2.1.1.5.0"));
+;;         System.out.println("v3all:");
+;;         HelloJava.printArray(SNMPApi.v3all ("localhost","juanv3", "comomolalagramola", "1.3.6.1.2.1.1.5.0"));
+;;         System.out.println("v3allb:");
+;;         HelloJava.printArray(SNMPApi.v3allb ("localhost","juanv3", "comomolalagramola", new String[] {"1.3.6.1.2.1.1.5.0", "1.3.6.1.2.1.1.6.0"}));
+;;         System.out.println("ERROR HOST: return java.lang.NullPointerException:  "+SNMPApi.v2 ("error-host", "public", "1.3.6.1.2.1.1.5.0"));
+;;         System.out.println("ERROR community name return java.lang.NullPointerException:  "+SNMPApi.v2 ("localhost", "error-community", "1.3.6.1.2.1.1.5.0"));
+;;     }
+;; }
+;;


Add nsahtn to experiments.

Add nsahtn to experiments.

--- src/exp/experiments.clj
+++ src/exp/experiments.clj
@@ -35,12 +35,16 @@
         (condp = (:alg m)
           :ucs     e
           :htn-ucs `(hierarchy/ShopHTNEnv (taxi/simple-taxi-hierarchy ~e))
-          :sahtn   `(taxi/simple-taxi-hierarchy ~e))))
+          :sahtn   `(taxi/simple-taxi-hierarchy ~e)
+          :nsahtn   `(taxi/simple-taxi-hierarchy-nsa ~e)
+          )))
     (fn [m]
       (condp = (:alg m)
         :ucs      `(ucs/uniform-cost-search ~'init)
         :htn-ucs  `(ucs/uniform-cost-search ~'init)
-        :sahtn    `(sd/sahtn-dijkstra ~'init)))
+        :sahtn    `(sd/sahtn-dijkstra ~'init)
+        :nsahtn    `(sd/sahtn-dijkstra ~'init)
+        ))
     'exp.experiments nil 1 512 false  ::ExpResult))

 (defn pad-right [x n]


Provide owner when adding ui elements

Provide owner when adding ui elements

--- src/discuss/views.cljs
+++ src/discuss/views.cljs
@@ -155,7 +155,7 @@

 (defn add-element
   "Show form to add a new statement."
-  [data]
+  [data owner]
   (dom/div #js {:className "panel panel-default"}
            (dom/div #js {:className "panel-body"}
                     (dom/h4 #js {:className "text-center"} (get-in data [:layout :add-text]))
@@ -166,7 +166,7 @@
                                        (dom/i #js {:className "fa fa-comment"}))
                              (dom/input #js {:id        (lib/prefix-name "add-element")
                                              :className "form-control"
-                                             :onChange  #(lib/update-state-item! :user :statement (fn [_] (-> % .-target .-value)))}))
+                                             :onChange  #(om/transact! :statement (fn [_] (-> % .-target .-value)))}))
                     (when (lib/get-selection)
                       (dom/div #js {:className "input-group"}
                                (dom/span #js {:className "input-group-addon"}
@@ -181,7 +181,7 @@
                                 "Submit"))))

 (defn main-content-view
-  [data]
+  [data owner]
   (dom/div nil
            (dom/div #js {:className "text-center"}
                     (get-in data [:layout :intro])
@@ -194,9 +194,9 @@
                                  (= view :login) (login-form)
                                  :else (discussion-elements data)))))
            (when (get-in data [:layout :add?])
-             (add-element data))))
-
-(defn main-view [data]
+             (add-element data owner))))
+
+(defn main-view [data owner]
   (reify om/IRender
     (render [_]
       (dom/div #js {:id (lib/prefix-name "dialogue-main")}
@@ -204,7 +204,7 @@
                        (logo)
                        " "
                        (get-in data [:layout :title]))
-               (main-content-view data)))))
+               (main-content-view data owner)))))

 (defn reference-view [data owner]
   (reify
@@ -222,12 +222,12 @@
                           (logo #(om/set-state! owner :show (toggle-show show))))
                 (dom/span nil (:dom-post data))))))

-(defn sidebar-view [data]
+(defn sidebar-view [data owner]
   (reify om/IRender
     (render [_]
       (dom/div nil
                (logo #(sidebar/toggle!))
-               (main-content-view data)
+               (main-content-view data owner)
                (dom/h5 nil "Reference")
                (dom/div #js {:className "well well-sm"}
                         (get-in @lib/app-state [:layout :reference]))))))


Remove a debug print that I missed

Remove a debug print that I missed

--- system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_keyword_search_test.clj
@@ -542,13 +542,12 @@
                                    [(um/map->DirectoryNameType
                                      {:ShortName "CMR2654DNSN2" :LongName "CMR2654DNLN2"})])
                             (assoc :ScienceKeywords
-                                   [{:Category "Bioosphere" :Topic "biota" :Term "term"}])
+                                   [{:Category "Biosphere" :Topic "biota" :Term "term"}])
                             (assoc :ShortName "CMR2652SN2")
                             (assoc :EntryTitle "CMR2652ET2"))
                         {:format :umm-json
                          :accept-format :json})]
     (index/wait-until-indexed)
-    ; (println coll1)
     (testing "parameter searches"
       (are3 [keyword-str items]
         (let [parameter-refs (search/find-refs :collection {:keyword keyword-str})]
@@ -579,7 +578,7 @@
         [coll2]

         "testing iso-topic-category search again"
-        "Bioosphere"
+        "Biosphere"
         [coll2]))

     (testing "json query searchs"


Show reformatted source even if harnified version is incorrect

--- src/harnocode/core.cljs
+++ src/harnocode/core.cljs
@@ -143,15 +143,15 @@

 (defn validate [code img w]
   (try
-    (let [regen-before (js/escodegen.generate (js/esprima.parse code))
-          harnocode  (harnify code img w)
-          regen-after  (js/escodegen.generate (js/esprima.parse harnocode))
-          msg        (if (= regen-before regen-after)
-                      "Validate: OK"
-                      (str "Differs: " "\nFAIL"))]
+    (let [regen-before (js/escodegen.generate (js/esprima.parse code))]
       (set! (.-value (dom/getElement "before")) regen-before)
-      (set! (.-value (dom/getElement "after"))  regen-after)
-      (println msg))
+      (let [harnocode  (harnify code img w)
+            regen-after  (js/escodegen.generate (js/esprima.parse harnocode))
+            msg        (if (= regen-before regen-after)
+                        "Validate: OK"
+                        (str "Differs: " "\nFAIL"))]
+          (set! (.-value (dom/getElement "after"))  regen-after)
+          (println msg)))
     (catch js/Error e
       (println "Parse error: " e))))


Naming things is hard

Naming things is hard

--- src/doctopus/files.clj
+++ src/doctopus/files.clj
@@ -47,9 +47,9 @@

 (defn walk-the-docs
   "Walk the docs; currently only looks for Markdown Documents."
-  [doc-root]
+  [doc-root pred]
   (let [docs-all (fs/walk vector doc-root) ;; Triple of directory path, directory name, file name
-        filtered-docs (filter-the-docs docs-all markdown?)
+        filtered-docs (filter-the-docs docs-all pred)
         assembled-result (assemble-the-results doc-root filtered-docs)]
     assembled-result
     ))


Fix typo

Fix typo

--- src/expound/alpha.cljc
+++ src/expound/alpha.cljc
@@ -952,7 +952,7 @@
   (doseq [check-result (butlast check-results)]
     (explain-result check-result)
     (print "\n\n"))
-  (expain-result (last check-results)))
+  (explain-result (last check-results)))

 (s/fdef explain-results-str
         :args (s/cat :check-results (s/coll-of (s/nilable map?)))


audio playback in detail view

audio playback in detail view

--- rn-app/src/cljs/meo/ui/journal.cljs
+++ rn-app/src/cljs/meo/ui/journal.cljs
@@ -6,11 +6,13 @@
             [glittershark.core-async-storage :as as]
             [cljs.core.async :refer [<!]]
             [meo.ui.colors :as c]
+            [meo.ui.settings.common :refer [settings-icon]]
             [reagent.ratom :refer-macros [reaction]]
             [meo.ui.shared :refer [view text text-input scroll search-bar flat-list
                                    map-view mapbox-style-url point-annotation
                                    icon image logo-img swipeout keyboard-avoiding-view
-                                   touchable-opacity]]
+                                   touchable-opacity settings-list settings-list-item
+                                   rn-audio-recorder-player]]
             [cljs-react-navigation.reagent :refer [stack-navigator stack-screen]]
             [clojure.string :as s]
             [clojure.pprint :as pp]
@@ -133,7 +135,10 @@

 (defn entry-detail [cfg-map entry-local nav put-fn]
   (let [entry-detail (subscribe [:entry-detail])
-        theme (subscribe [:active-theme])]
+        theme (subscribe [:active-theme])
+        player-state (r/atom {:pos    0
+                              :status :paused})
+        recorder-player (rn-audio-recorder-player.)]
     (fn [{:keys [screenProps navigation] :as props}]
       (go (try
             (let [ts (:timestamp @entry-detail)
@@ -146,6 +151,7 @@
             entry (:entry @entry-local)
             bg (get-in c/colors [:list-bg @theme])
             text-bg (get-in c/colors [:text-bg @theme])
+            item-bg (get-in c/colors [:text-bg @theme])
             text-color (get-in c/colors [:text @theme])
             latitude (:latitude entry)
             longitude (:longitude entry)]
@@ -195,7 +201,7 @@
                        :styleURL         (get mapbox-style-url (:map-style @cfg-map))
                        :style            {:width         "100%"
                                           :height        200
-                                          :margin-bottom 100}
+                                          :margin-bottom 30}
                        :zoomLevel        15}
              [point-annotation {:coordinate [longitude latitude]}
               [view {:style {:width           24
@@ -208,7 +214,40 @@
                               :height          24
                               :backgroundColor "orange"
                               :borderRadius    12
-                              :transform       [{:scale 0.7}]}}]]]])]
+                              :transform       [{:scale 0.7}]}}]]]])
+          (when-let [audio-file (:audio_file entry)]
+            (let [status (:status @player-state)
+                  pos (h/mm-ss (.floor js/Math (:pos @player-state)))
+                  play (fn [_]
+                         (.startPlayer recorder-player audio-file)
+                         (.addPlayBackListener
+                           recorder-player
+                           #(swap! player-state assoc-in [:pos] (.-current_position %)))
+                         (swap! player-state assoc-in [:status] :play))
+                  stop (fn [_]
+                         (.stopPlayer recorder-player)
+                         (.removePlayBackListener recorder-player)
+                         (swap! player-state assoc-in [:status] :paused))]
+              [touchable-opacity {:on-press (if (= :play status) stop play)
+                                  :style    {:margin         10
+                                             :display        "flex"
+                                             :flex-direction "row"}}
+               [icon {:name  "microphone"
+                      :size  30
+                      :style {:color       (if (= :play status) "#66F" "#999")
+                              :margin-left 25}}]
+               [text {:style {:color       "#0078e7"
+                              :font-size   30
+                              :margin-left 25
+                              :font-family  "Courier"}}
+                (if (= :play status) "Stop" "Play")]
+               [text {:style {:font-size    30
+                              :color        "#888"
+                              :font-weight  "100"
+                              :margin-left  50
+                              :margin-right 25
+                              :font-family  "Courier"}}
+                pos]]))]
          #_[text {:style {:margin-top  20
                           :margin-left 10
                           :color       text-color


some more util functions

some more util functions

--- src/cljs/ubolonton/cljs_xulrunner/util.cljs
+++ src/cljs/ubolonton/cljs_xulrunner/util.cljs
@@ -1,10 +1,44 @@
-(ns ubolonton.cljs-xulrunner.util)
+(ns ubolonton.cljs-xulrunner.util
+  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
+  (:require [cljs.core.async :refer [<! >! put! timeout chan]]))

-(defn post [url data callback]
-  (let [request (XMLHttpRequest.)]
+(def Cc (.-classes js/Components))
+
+(def Ci (.-interfaces js/Components))
+
+(def Cu (.-utils js/Components))
+
+(defn class [class-id]
+  (aget Cc (str class-id)))
+
+(defn interface [interface-id]
+  (aget Ci (str interface-id)))
+
+(defn as [obj interface-id]
+  (.QueryInterface obj (interface interface-id)))
+
+(defn create [class-id interface-id]
+  (.createInstance (class class-id) (interface interface-id)))
+
+(defn xml-http-request []
+  (-> (create "@mozilla.org/xmlextras/xmlhttprequest;1" "nsIXMLHttpRequest")
+      (as "nsIJSXMLHttpRequest")
+      (as "nsIDOMEventTarget")))
+
+(defn post [url data]
+  (let [request (xml-http-request)
+        result (chan 1)]
     (doto request
       (aset "onload" (fn [event]
-                       (callback (.-responseText request))))
+                       (put! result (.-responseText request))))
       (aset "timeout" 50000)
       (.open "POST" url true)
-      (.send data))))
+      (.send data))
+    result))
+
+;;; Temp hack while piggy-backing on MozRepl for development Not
+;;; simply js/repl.print, because it's a method (using this), not a
+;;; function.
+(set-print-fn!
+ (fn [str]
+   (js/repl.print str)))


Fix exists.

Fix exists.

--- src/konserve/cache.cljc
+++ src/konserve/cache.cljc
@@ -26,7 +26,7 @@
   [store key]
   (go-locked
    store key
-   (or (cache/has? (:cache store) key)
+   (or (cache/has? @(:cache store) key)
        (<! (-exists? store key)))))

 (defn get-in


Remove server configuration from handlers

--- src/madouc/handlers.clj
+++ src/madouc/handlers.clj
@@ -6,5 +6,3 @@

 (def main-handler (routes api/handler content/handler))
-
-(def entrypoint (logger/wrap-with-logger main-handler))


running the test suite should not recompile and reload between tests!

  - This appears to have been introduced innocently during a
    refactoring http://github.com/technomancy/leiningen/commit/a9936d22
    It is a crippling bug, making test suites run an order of magnitude
    slower, as they recompile the entire app between test files.

--- src/leiningen/test.clj
+++ src/leiningen/test.clj
@@ -29,7 +29,7 @@
               add-numbers# (fn [a# b#] (if (number? a#)
                                          (+ a# b#) a#))
               summary# (reduce (fn [summary# n#]
-                                 (require n# :reload-all)
+                                 (require n#)
                                  ;; TODO: apply run-tests across all test-nses
                                  (merge-with add-numbers#
                                              summary#


Incremental voomdb updates were done incorrectly, creating corrupt data

Our use of git fast-export caused the oldest commit(s) imported to claim a
change for every file in the repo. We now use import-marks to stop that
behavior.

Note the db header bump is not because the structure of the db changed, but
rather to trigger the removal of old and possibly corrupt dbs.

--- src/leiningen/voom.clj
+++ src/leiningen/voom.clj
@@ -851,17 +851,27 @@

 (defn exported-commits
   [gitdir tip-shas seen-shas]
-  (let [marks-file (File/createTempFile "marks" ".txt")]
+  (let [long-sha (fn [sha] (first (:lines (git {:gitdir gitdir} "rev-parse" (str sha)))))
+        out-marks-file (File/createTempFile "out-marks" ".txt")
+        in-marks-file (File/createTempFile "in-marks" ".txt")]
     (try
-      (let [{:keys [out]} (apply sh "git" "fast-export" "--no-data"
-                                 (str "--export-marks=" marks-file)
-                                 (concat (map str tip-shas)
-                                         (map #(str "^" %) seen-shas)
-                                         [:dir gitdir, :out-enc :bytes]))
+      (spit in-marks-file
+            (apply str (map-indexed (fn [i sha]
+                                      (str ":" (inc i) " " (long-sha sha) "\n"))
+                                    seen-shas)))
+      (let [{:keys [out] :as rtn} (apply sh "git" "fast-export" "--no-data"
+                                         (str "--export-marks=" out-marks-file)
+                                         (concat
+                                          (when (seq seen-shas)
+                                            [(str "--import-marks=" in-marks-file)])
+                                          (map str tip-shas)
+                                          (map #(str "^" %) seen-shas)
+                                          [:dir gitdir, :out-enc :bytes]))
+            _ (assert (zero? (:exit rtn)) (pr-str (:err rtn)))
             marks (into {}
                         (map #(let [[mark sha] (s/split % #" ")]
                                 [mark (sha/mk sha)])
-                             (re-seq #"(?m)^.*$" (slurp marks-file))))
+                             (re-seq #"(?m)^.*$" (slurp out-marks-file))))
             merge-commit-fn (fn [cmd commit]
                               (if (= cmd "merge")
                                 (-> commit
@@ -906,7 +916,8 @@
                                commit)))))
               commits))))
       (finally
-       (.delete marks-file)))))
+       (.delete in-marks-file)
+       (.delete out-marks-file)))))

 (defn proj-fact-tail
   [gitdir blob-sha]
@@ -987,7 +998,7 @@
           (build-shabam (vals new-branches))
           (vary-meta assoc ::dirty true))))))

-(def voomdb-header "voom-db-7")
+(def voomdb-header "voom-db-8")

 (defn ^File git-db-file
   [gitdir]


adding more actions

adding more actions

--- test/celestial/fixtures/data.clj
+++ test/celestial/fixtures/data.clj
@@ -28,7 +28,9 @@

 (def clustered-prox (slurp-edn "fixtures/celestial-cluster.edn"))

-(def redis-actions (slurp-edn "fixtures/redis-actions.edn"))
+(def redis-deploy (slurp-edn "fixtures/redis-deploy.edn"))
+
+(def redis-runall (slurp-edn "fixtures/redis-runall.edn"))

 (def user-quota (slurp-edn "fixtures/user-quota.edn"))


enhance custom benchmarks, test core-bypass custom encoding

--- test/cheshire/test/benchmark.clj
+++ test/cheshire/test/benchmark.clj
@@ -27,6 +27,18 @@

 (deftest ^{:benchmark true} t-bench-custom
   (println "--------- Custom Benchmarks ---------")
+  (println "[+] Custom, no custom fields:")
   (bench/with-progress-reporting
     (bench/quick-bench (custom/decode (custom/encode test-obj)) :verbose))
+  (println "- - - - - - - - - - - - - - - - - - -")
+  (custom/add-encoder java.net.URL custom/encode-str)
+  (is (= "\"http://foo.com\"" (custom/encode (java.net.URL. "http://foo.com"))))
+  (let [custom-obj (assoc test-obj "url" (java.net.URL. "http://foo.com"))]
+    (println "[+] Custom, all custom fields:")
+    (bench/with-progress-reporting
+      (bench/quick-bench (custom/decode (custom/encode custom-obj)) :verbose))
+    (println "- - - - - - - - - - - - - - - - - - -")
+    (println "[+] Custom, bypass core with custom fields:")
+    (bench/with-progress-reporting
+      (bench/quick-bench (custom/decode (custom/encode* custom-obj)) :verbose)))
   (println "-------------------------------------"))


Remove usage of jet from sse tests.

Remove usage of jet from sse tests.

--- test/catacumba/sse_tests.clj
+++ test/catacumba/sse_tests.clj
@@ -5,13 +5,9 @@
             [clojure.java.io :as io]
             [clojure.pprint :refer [pprint]]
             [clojure.core.async :as async]
-            ;; [clj-http.client :as client]
-            [qbits.jet.client.websocket :as ws]
-            [qbits.jet.client.http :as http]
+            [clj-http.client :as client]
             [catacumba.core :as ct]
             [catacumba.core-tests :refer [with-server]]))
-
-(def client (http/client))

 (deftest sse-standard-handler
   (letfn [(sse-handler [context out]
@@ -26,13 +22,15 @@
             (ct/sse context sse-handler))]
     (with-server handler
       (let [p (promise)
-            response (<!! (http/get client "http://localhost:5050/" {:fold-chunked-response? false}))]
+            response (client/get "http://localhost:5050/")]
         (is (= (:status response) 200))
-        (is (= (-> response :body <!!) "data: 1\n\n"))
-        (is (= (-> response :body <!!) "data: 2\n\n"))
-        (is (= (-> response :body <!!) "event: foobar\n\n"))
-        (is (= (-> response :body <!!) "id: foobar\n\n"))
-        (is (= (-> response :body <!!) "data: 3\nid: foobar\n\n"))))))
+        (is (= (:body response)
+               (str "data: 1\n\n"
+                    "data: 2\n\n"
+                    "event: foobar\n\n"
+                    "id: foobar\n\n"
+                    "data: 3\n"
+                    "id: foobar\n\n")))))))

 (deftest sse-specific-handler
   (letfn [(sse-handler [context out]
@@ -46,10 +44,12 @@
     (with-server (with-meta sse-handler
                    {:handler-type :catacumba/sse})
       (let [p (promise)
-            response (<!! (http/get client "http://localhost:5050/" {:fold-chunked-response? false}))]
+            response (client/get "http://localhost:5050/" {:fold-chunked-response? false})]
         (is (= (:status response) 200))
-        (is (= (-> response :body <!!) "data: 1\n\n"))
-        (is (= (-> response :body <!!) "data: 2\n\n"))
-        (is (= (-> response :body <!!) "event: foobar\n\n"))
-        (is (= (-> response :body <!!) "id: foobar\n\n"))
-        (is (= (-> response :body <!!) "data: 3\nid: foobar\n\n"))))))
+        (is (= (:body response)
+               (str "data: 1\n\n"
+                    "data: 2\n\n"
+                    "event: foobar\n\n"
+                    "id: foobar\n\n"
+                    "data: 3\n"
+                    "id: foobar\n\n")))))))


Add test for file responses

Add test for file responses

--- test/compojure/test/response.clj
+++ test/compojure/test/response.clj
@@ -32,6 +32,14 @@
     (is (= (response/render (future expected-response) {})
            expected-response)))

+  (testing "with file"
+    (let [response (response/render (io/file "test/resources/test.txt") {})]
+      (is (instance? File (:body response)))
+      (is (= (get-in response [:headers "Content-Length"]) "7"))
+      (is (= (get-in response [:headers "Content-Type"]) "text/plain"))
+      (is (string? (get-in response [:headers "Last-Modified"])))
+      (is (= (slurp (:body response)) "foobar\n"))))
+
   (testing "with file URL"
     (let [response (response/render (io/resource "resources/test.txt") {})]
       (is (instance? File (:body response)))


New test test-substring-empty-result

New test test-substring-empty-result

--- test/clouseau/test_utils.clj
+++ test/clouseau/test_utils.clj
@@ -192,3 +192,12 @@
             "world"  (substring "Hello world!" 6 11)
             "world!" (substring "Hello world!" 6 12))))

+(deftest test-substring-empty-result
+    "Check the function clouseau.utils/substring."
+    (testing "the function clouseau.utils/substring."
+        (are [x y] (= x y)
+            "" (substring "Hello world!" 0 0)
+            "" (substring "Hello world!" 1 1)
+            "" (substring "Hello world!" 2 2)
+            "" (substring "Hello world!" 10 10))))
+


intersect tests

intersect tests

--- test/infinitelives/test.cljs
+++ test/infinitelives/test.cljs
@@ -7,6 +7,7 @@
             [infinitelives.utils.spatial-test]
             [infinitelives.utils.geom2-test]
             [infinitelives.utils.line-test]
+            [infinitelives.utils.intersect-test]
             [infinitelives.utils.ease-test]
             [infinitelives.utils.pathfind-test]
 ))