test/run.clj: added code to run just tests given on command line

Still runs all tests if run without arguments.

--- src/org/altlaw/test/run.clj
+++ src/org/altlaw/test/run.clj
@@ -4,5 +4,9 @@

 (defn -main [& args]
   (require 'org.altlaw.load-all)
-  (t/run-all-tests))
+  (if (or (nil? args) (empty? args))
+    (apply t/run-tests
+           (filter #(.startsWith (str (ns-name %)) "org.altlaw.")
+                   (all-ns)))
+    (apply t/run-tests (map #(find-ns (symbol %)) args))))


Re-implement core to gain performance and simplify code #44

--- flatguicore/test/flatgui/core_test.clj
+++ flatguicore/test/flatgui/core_test.clj
@@ -401,6 +401,7 @@
                      :position-matrix (m/translation 2 1)
                      :viewport-matrix m/IDENTITY-MATRIX
                      :clip-size (m/defpoint 10 10)
+                     :visible true
                      :evolvers {:a a-evolver}
                      :children {:c1 {:id :c1
                                      :popup false
@@ -408,7 +409,8 @@
                                      :look-vec []
                                      :clip-size (m/defpoint 5 5)
                                      :position-matrix (m/translation 3 2)
-                                     :viewport-matrix m/IDENTITY-MATRIX}}})
+                                     :viewport-matrix m/IDENTITY-MATRIX
+                                     :visible 1}}})
         ui-app (FGAWTAppContainer. container 1)
         _ (.initialize ui-app)
         ;container-accessor (.getContainerAccessor ui-app)


Now that ugen is a callable map, it can only be called with 20 args max unless it's called with apply. Until we find a fix for this, a work-around is to use apply which will allow n args. Use this for the mda-piano ugen to fix the inst

--- src/overtone/inst/piano.clj
+++ src/overtone/inst/piano.clj
@@ -4,34 +4,36 @@
 ;; IMPORTANT: requires the mda-piano ugen to be available on your system

 (definst piano [note 60
-                 gate 1
-                 vel 100
-                 decay 0.8
-                 release 0.8
-                 hard 0.8
-                 velhard 0.8
-                 muffle 0.8
-                 velmuff 0.8
-                 velcurve 0.8
-                 stereo 0.2
-                 tune 0.5
-                 random 0.1
-                 stretch 0.1
-                 sustain 0.1]
-  (let [snd (mda-piano :freq (midicps note)
-                       :gate gate
-                       :vel vel
-                       :decay decay
-                       :release release
-                       :hard hard
-                       :velhard velhard
-                       :muffle muffle
-                       :velmuff velmuff
-                       :velcurve velcurve
-                       :stereo stereo
-                       :tune tune
-                       :random random
-                       :stretch stretch
-                       :sustain sustain)
-        sil (detect-silence snd 0.005 :action FREE)]
+                gate 1
+                vel 100
+                decay 0.8
+                release 0.8
+                hard 0.8
+                velhard 0.8
+                muffle 0.8
+                velmuff 0.8
+                velcurve 0.8
+                stereo 0.2
+                tune 0.5
+                random 0.1
+                stretch 0.1
+                sustain 0.1]
+  (let [snd (apply mda-piano [:freq (midicps note)
+                        :gate gate
+                        :vel vel
+                        :decay decay
+                        :release release
+                        :hard hard
+                        :velhard velhard
+                        :muffle muffle
+                        :velmuff velmuff
+                        :velcurve velcurve
+                        :stereo stereo
+                        :tune tune
+                        :random random
+                        :stretch stretch
+                       :sustain sustain])]
+    (detect-silence snd 0.005 :action FREE)
     (* 1 snd))) ;;TODO: figure out why this mul is required
+
+(definst foo [] (mda-piano))


add #'bundled-asset-dir and make many of the asset ns fns private

--- src/overtone/libs/asset.clj
+++ src/overtone/libs/asset.clj
@@ -13,7 +13,7 @@

 (def ^{:dynamic true} *cache-root* (:assets OVERTONE-DIRS))

-(defn safe-url
+(defn- safe-url
   "Replace all non a-z A-Z 0-9 - chars in stringified version of url with _"
   [url]
   (let [url  (str url)
@@ -23,33 +23,33 @@
         safe (.replaceAll safe "[^a-zA-Z0-9-.]" "")]
     safe))

-(defn url-hash
+(defn- url-hash
   "Return a hash for stringified version of url"
   [url]
   (let [url (str url)]
     (str (hash url))))

-(defn cache-dir
+(defn- cache-dir
   "Returns the name of a directory to cache an asset with the given url."
   [url]
   (let [safe (safe-url url)
         hsh  (url-hash url)]
     (mk-path *cache-root* (str safe "--" hsh))))

-(defn mk-cache-dir!
+(defn- mk-cache-dir!
   "Create a new cache dir for the specified url"
   [url]
   (let [dir (cache-dir url)]
     (mkdir! dir)))

-(defn fetch-cached-path
+(defn- fetch-cached-path
   "Returns the path to the cached asset if present, otherwise nil."
   [url name]
   (let [path (mk-path (cache-dir url) name)]
     (when (path-exists? path)
       path)))

-(defn download-and-cache-asset
+(defn- download-and-cache-asset
   "Downloads the file pointed to by url and caches it on the local file system"
   [url name]
   (let [tmp-dir   (str (mk-tmp-dir!))
@@ -69,16 +69,16 @@
         (throw e)))))

 (defn asset-seq
-  "Returns a seq of asset names for a specific url"
+  "Returns a seq of previously cached asset names for a specific url"
   [url]
   (let [dir (cache-dir url)
         dir (file dir)]
     (ls-names dir)))

-(defn asset
+(defn asset-path
   "Given a url will return a path to a copy of the asset on the local file
   system. Will download and persist the asset if necessary."
-  ([url] (asset url (last (split url #"/"))))
+  ([url] (asset-path url (last (split url #"/"))))
   ([url name]
      (if-let [path (fetch-cached-path url name)]
        path
@@ -109,7 +109,7 @@
         (rm-rf! dest-dir)
         (throw e)))))

-(defn bundled-asset
+(defn bundled-asset-path
   "Given a url to a remote zipfile and either a / separated internal path or seq
   of strings will return a path to a copy of the internal extracted asset on the
   local file system. Will download, extract and persist all the assets of the
@@ -129,3 +129,10 @@
         (when (dir-empty? (cache-dir url))
           (download-unzip-and-cache-bundled-asset url))
         (fetch-cached-path url internal-path)))))
+
+(defn bundled-asset-dir
+  "Returns the cached directory of of the bundled asset. Will download, extract
+  and persist all the assets of the zipfile referended by url if necessary"
+  [url]
+  (bundled-asset-path url "")
+  (cache-dir url))


whitespace formatting

whitespace formatting

--- src/overtone/repl/shell.clj
+++ src/overtone/repl/shell.clj
@@ -9,9 +9,9 @@
   (cons [self o] (ShellStringList. (conj strlist o)))
   (empty [self] (ShellStringList. []))
   (equiv
-   [self o]
-   (and (instance? ShellStringList o)
-        (= strlist (.strlist o))))
+    [self o]
+    (and (instance? ShellStringList o)
+         (= strlist (.strlist o))))
   clojure.lang.ISeq
   (first [self] (first strlist))
   (next [self] (next strlist))


return nice error messages when examples can't be found

--- src/overtone/sc/example.clj
+++ src/overtone/sc/example.clj
@@ -84,11 +84,11 @@

 (defn- resolve-gen-name
   "If the gen is a cgen or ugen returns the :name otherwise returns name
-   unchanged"
+   unchanged assuming it's a keyword."
   [gen]
   (if (and (associative? gen)
-                          (or (= :overtone.sc.ugen/ugen (:type gen))
-                              (= :overtone.sc.cgen/cgen (:type gen))))
+           (or (= :overtone.sc.ugen/ugen (:type gen))
+               (= :overtone.sc.cgen/cgen (:type gen))))
     (keyword (:name gen))
     gen))

@@ -138,7 +138,9 @@
 (defn- longest-gen-example-key
   [gen-examples]
   (let [example-keys (keys gen-examples)]
-    (length-of-longest-string example-keys)))
+    (if example-keys
+      (length-of-longest-string example-keys)
+      0)))

 (defn examples
   "Print out examples for a specific gen. If passed a gen and a key will list
@@ -163,4 +165,6 @@
      (let [examples @examples*
            gen-name (resolve-gen-name gen)
            example (get-in examples [gen-name key])]
-       (println (:full-doc example)))))
+       (if example
+         (println (:full-doc example))
+         (println "Sorry, no example could be found for the" (name gen-name) "gen with key" key)))))


adding more transforms

adding more transforms

--- src/docker/provider.clj
+++ src/docker/provider.clj
@@ -56,14 +56,16 @@

   (status [this]
     (try+
-      (let [{:keys [running]} (:state (c/inspect :local (container-id system-id)))]
-        (if running "running" "stopped"))
+      (if-let [id (container-id system-id)]
+        (if (get-in (c/inspect :local id) [:state :running])
+          "running" "stopped")
+        false)
       (catch [:status 404] e false)))
   )

 (def starts-ks [:port-bindings :binds])

-(def create-ks [:image :exposed-ports :volumes])
+(def create-ks [:image :memory :exposed-ports :volumes])

 (defn to-binds
   "Trasnforms 22/tcp:2222 to {22/tcp [{:host-ip 0.0.0.0 :host-port 2222}]}"
@@ -78,13 +80,19 @@

 (test #'to-binds)

+(defn empty-hashes-map
+   "convert a vector [:a] to empty hash map {:a {}}"
+   [v]
+  (zipmap v (repeat {})))
+
 (defmethod translate :docker [{:keys [machine docker system-id] :as spec}]
   "Convert the general model into a docker specific one"
   (let [{:keys [node]} docker]
     (into [node system-id]
           (-> (merge machine docker)
               (mappings {:mount-bindings :binds})
-              (transform {:port-bindings to-binds})
+              (transform {:port-bindings to-binds :exposed-ports empty-hashes-map
+                          :volumes empty-hashes-map :memory #(* % 1024)})
               (selections [create-ks starts-ks])
               ))))


fix emoji autocomplete

fix emoji autocomplete

--- src/chat/client/views/new_message.cljs
+++ src/chat/client/views/new_message.cljs
@@ -20,7 +20,7 @@

 (defn simple-matches?
   [m s]
-  (re-find (re-pattern m) s))
+  (not= -1 (.indexOf m s)))

 ; fn that returns results that will be shown if pattern matches


Update builtins.clj

Update builtins.clj

--- src/iyye/subcon/knowledge/builtins.clj
+++ src/iyye/subcon/knowledge/builtins.clj
@@ -27,24 +27,40 @@
 (def iyye_human (ref 0))
 (def iyye_yumzya (ref 0))

-; Builtin relations
+; Builtin verbs and relations
 (def iyye_is_type (ref 0))
+(def iyye_is?_type (ref 0))
+(def iyye_is_type_rel (ref 0))
 (def iyye_consists_type (ref 0))
 (def iyye_create_instance (ref 0))

 (defn iyye_is_type_predicate_function [params]
-  (when (= 2 (count params))
+  (if (= 2 (count params))
     (let [[p1-type p2-type] params
-          p2-name (:Name (:atom p2-type))
-          rels1 (:Relations p1-type)]
-      (some true?
-            (for [rel rels1]
-              (= (:super (:Data rel)) p2-name)))))) ; FIXME Yumzia modal logic, FIXME 0 recursive
-
-(defn- iyye_add_relation [p1-type p2-type relation]
-  (let [is_type #(words/action-words relation)]
-    (let [p1-supertype (assoc (is_type) :Data {:super (:Name (:atom p2-type))})
-          p2-subtype (assoc (is_type) :Data {:sub (:Name (:atom p1-type))})
+          p2-name (:Name (:name (first p2-type)))
+          rels1 (:Relations (first p1-type))
+          rels2 (for [rel rels1]
+                  [rel (and p2-name (= (:super (:Data rel)) p2-name))])
+          rels3 (filter #(second %) rels2)]
+      (if (> (count rels3) 0)
+        (:Predicate (first (first rels3)))
+        (words/->Iyye_ModalPredicate :IYE :AXIOM "now" :NEVER)
+        ))
+    (words/->Iyye_Error (pr-str "No relation, unrelated: " params) pr-str)
+    )
+  ) ; FIXME Yumzia modal logic, FIXME 0 recursive
+
+(defn iyye_is_predicate_function [params]
+    (let [[relations & rest] params
+          rel (first (filter #(= "relation" (:Type (:name %))) relations))]
+      (if rel
+        ((:PredicateFunction rel) rest)
+        (words/->Iyye_Error (pr-str "No relation: " relations) pr-str))))
+
+(defn iyye_add_relation [p1-type p2-type relation]
+  (let [is_type relation]
+    (let [p1-supertype (assoc is_type :Data {:super (:Name (:name p2-type))})
+          p2-subtype (assoc is_type :Data {:sub (:Name (:name p1-type))})
           new-p1-type (assoc p1-type :Relations
                                      (conj (:Relations p1-type) p1-supertype))
           new-p2-type (assoc p2-type :Relations
@@ -55,9 +71,28 @@
         true))))

 (defn iyye_is_type_function [params]
-  (let [[p1-type p2-type] params]
-    (when (and p1-type p2-type)
-      (iyye_add_relation p1-type p2-type @iyye_is_type))))
+  (let [[relation & remaining] params]
+    ; (case (count relation)
+    ;  0 (words/->Iyye_Error (pr-str "No relation: " params) pr-str)
+      (if (and (:Predicate relation) (words/check-params relation remaining)) ; is Relation
+        ((:Function relation) (cons relation remaining))
+        (words/->Iyye_Error (pr-str "Not a relation: " relation) pr-str)))
+    ; (let [rels (filter #(and (not (nil? %)) (words/check-params % remaining)) relation)]
+    ; (if (> (count rels) 1)
+    ;  (words/->Iyye_Error (pr-str "Too many relations: " rels) pr-str)
+    ; (if (= (count rels) 1)
+    ;  ((:PredicateFunction (first rels)) remaining)
+    ;  (words/->Iyye_Error (pr-str "No relation in: " relation) pr-str)
+    )
+
+(defn iyye_is_type_function_relation [params]
+  (let [[rel type1 type2 & rest] params]
+  (if rest
+    (words/->Iyye_Error (pr-str "Too many types to relation: " params) pr-str)
+    (if type2
+      (if (words/check-params rel params)
+        (iyye_add_relation type1 type2 (words/builtin-words @iyye_is_type_rel) ))
+      (words/->Iyye_Error (pr-str "only one type for relation: " params) pr-str)))))

 (defn iyye_is_type_create_function [params]
   (let [[p1-name p2-type] params
@@ -82,13 +117,23 @@
 ;(defn ^{:source "(+ 1 a)"} aaa [a] (+ 1 a))
 ;(defmacro getsrc [func] `(:source (meta (var ~func))))

-(defn- create-iyye-builtin-relation [name types func pred-func]
+(defn create-iyye-builtin-verb [name types result func]
+  (words/create-iyye-verb
+    name
+    types result func true))
+
+(defn create-iyye-builtin-query [name types func]
+  (words/create-iyye-verb
+    name
+    types "predicate" func true))
+
+(defn create-iyye-builtin-relation [name types func pred-func]
   (words/create-iyye-relation
     name
     (words/->Iyye_ModalPredicate :IYE :AXIOM (persistence/local-time-to-string) :ALWAYS)
     types func pred-func true))

-(defn- create-entry [entry] {(:Uname (:atom entry)) entry})
+;(defn create-entry [entry] {(:Uname (:name entry)) entry})

 (defn- init-builtin-words []
   (let [type (words/create-iyye-type "type" true)
@@ -97,40 +142,60 @@
         iyye (words/create-iyye-type "iyye" true)
         human (words/create-iyye-type "human" true)
         yumzya (words/create-iyye-type "yumzya" true)
-        uname #(:Uname (:atom %))]
-    (dosync (ref-set iyye_actor (uname actor)))
-    (dosync (ref-set iyye_ai (uname ai)))
-    (dosync (ref-set iyye_iyye (uname iyye)))
+        create-entry (fn [entry] {(:Uname (:name entry)) entry})
+        uname #(:Uname (:name %))]
+     (dosync (ref-set iyye_actor (uname actor)))
+     (dosync (ref-set iyye_ai (uname ai)))
+     (dosync (ref-set iyye_iyye (uname iyye)))
     (dosync (ref-set iyye_human (uname human)))
     (dosync (ref-set iyye_yumzya (uname yumzya)))
-    (dosync (alter words/noun-words conj (create-entry type) (create-entry actor)
+    (dosync (alter words/builtin-words conj (create-entry type) (create-entry actor)
                    (create-entry ai) (create-entry iyye) (create-entry human)
                    (create-entry yumzya)))))

 (defn- init-builtin-relations []
-  (let [t_is (create-iyye-builtin-relation "is" ["type" "type"] iyye_is_type_function iyye_is_type_predicate_function)
-        t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
-        consistsof (create-iyye-builtin-relation "consists" [] iyye_consists_function iyye_is_type_predicate_function)
-        instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
-        uname #(:Uname (:atom %))]
+  (let [t_is (create-iyye-builtin-relation "type" ["type" "*"] iyye_is_type_function_relation iyye_is_type_predicate_function)
+        ;t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
+        ;  consistsof (create-iyye-builtin-relation "has" [] iyye_consists_function iyye_is_type_predicate_function)
+        ;instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
+        uname #(:Uname (:name %))
+        create-entry (fn [entry] {(:Uname (:name entry)) entry})]
+    (dosync (ref-set iyye_is_type_rel (uname t_is)))
+    ; (dosync (ref-set iyye_consists_type (uname consistsof)))
+    ;  (dosync (ref-set iyye_create_instance (uname instof)))
+    (dosync (alter words/builtin-words conj (create-entry t_is)))))
+
+(defn- init-builtin-verbs []
+  (let [t_is (create-iyye-builtin-verb "is" ["relation" "type" "*"] "relation" iyye_is_type_function)
+        t_is? (create-iyye-builtin-query "is?" ["relation" "type" "*"] iyye_is_predicate_function)
+        ;t_is2 (create-iyye-builtin-relation "is" [:UNKNOWN "type"] iyye_is_type_create_function iyye_is_type_predicate_function)
+        consistsof (create-iyye-builtin-verb "has" ["type" "*"] "relation" iyye_consists_function)
+        ;instof (create-iyye-builtin-relation "instance" ["type"] iyye_instance_function iyye_is_type_predicate_function)
+        uname #(:Uname (:name (:name %)))
+        create-entry (fn [entry] {(:Uname (:name (:name entry))) entry})]
     (dosync (ref-set iyye_is_type (uname t_is)))
+    (dosync (ref-set iyye_is?_type (uname t_is?)))
     (dosync (ref-set iyye_consists_type (uname consistsof)))
-    (dosync (ref-set iyye_create_instance (uname instof)))
-    (dosync (alter words/action-words conj (create-entry t_is) (create-entry t_is2) (create-entry consistsof) (create-entry instof)))))
-
-(defn- apply-builtin-relations []
-  (let [get-type #(words/noun-words %)
-        get-function #(:Function (words/action-words %))]
-    (do
-      ((get-function @iyye_is_type) [(get-type @iyye_ai) (get-type @iyye_actor)])
-      ((get-function @iyye_is_type) [(get-type @iyye_human) (get-type @iyye_actor)])
-      ((get-function @iyye_is_type) [(get-type @iyye_iyye) (get-type @iyye_ai)])
-      ((get-function @iyye_is_type) [(get-type @iyye_yumzya) (get-type @iyye_human)]))))
+    ;   (dosync (ref-set iyye_create_instance (uname instof)))
+    (dosync (alter words/builtin-words conj (create-entry t_is) (create-entry t_is?) (create-entry consistsof)))))
+
+(defn apply-builtin-relations []
+  (let [get-type #(words/builtin-words %)
+        get-function #(:Function (words/builtin-words %))
+        f (get-function @iyye_is_type)]
+        (when f
+          (do
+            (f [(get-type @iyye_is_type_rel) (get-type @iyye_ai) (get-type @iyye_actor)])
+            (f [(get-type @iyye_is_type_rel) (get-type @iyye_human) (get-type @iyye_actor)])
+            (f [(get-type @iyye_is_type_rel) (get-type @iyye_iyye) (get-type @iyye_ai)])
+            (f [(get-type @iyye_is_type_rel) (get-type @iyye_yumzya) (get-type @iyye_human)])))))

 (defn- init-builtins-kb []
   (init-builtin-words)
+  (init-builtin-verbs)
   (init-builtin-relations)
-  (apply-builtin-relations))
+  (apply-builtin-relations)
+  )

 ;(dorun (map #(do ( persistence/write-fact-to-db (into {} %))) @action-words))
 ; (apply str (rest (str (:When {:When :ALWAYS}))))
@@ -138,9 +203,11 @@
 (defn- init-db-kb []
   (let [types-loaded (persistence/read-knowledge-from-db "types" {})
         types (map words/create-iyye-type-from-db types-loaded)
+        create-entry (fn [entry] {(:Uname (:name entry)) entry})
         a-f (fn [col el] (conj col (create-entry el)))]
-    (dosync (alter words/action-words #(apply conj %1 %2) (persistence/read-knowledge-from-db "relations" {}))) ; {:When :ALWAYS}
-    (dosync (alter words/noun-words #(apply a-f %1  %2) types)) ; {:When :ALWAYS}
+    (dosync (alter words/builtin-words #(apply conj %1 %2) (persistence/read-knowledge-from-db "verbs" {}))) ; {:When :ALWAYS}
+    (dosync (alter words/builtin-words #(apply conj %1 %2) (persistence/read-knowledge-from-db "relations" {})))
+    (when (not-empty types) (dosync (alter words/builtin-words #(apply a-f %1 %2) types)))  ; {:When :ALWAYS}
     ; others
     ))


More tests for zero data, also removed bad paths.

--- src/videotest/blob/find_centroids_cvgray.clj
+++ src/videotest/blob/find_centroids_cvgray.clj
@@ -23,12 +23,12 @@
 (def PIX-CNT1 (* WIDTH HEIGHT 4))
 (def PIX-CNT2 (* WIDTH HEIGHT))

+(def BW-THRESH 200) ; between 0-255 (gray -> BW cut-off)
 (def this (atom nil))

 ;; bArray is the temporary byte array buffer for OpenCV cv::Mat.
 ;; iArray is the temporary integer array buffer for PImage pixels.
 (defn setup []
-  (reset! this videotest)
   (q/frame-rate 60)
   {:b-array (byte-array PIX-CNT1)
    :i-array (int-array PIX-CNT2)
@@ -38,10 +38,13 @@
    :bw-mat (Mat.)
    :camera (cv/camera 0)
    :p-image (q/create-image WIDTH HEIGHT :rgb)
-   :detector (Detector. @this 255)})
+   :detector (do
+               ; Applet must exist before Detector can be created
+               (Thread/sleep 1000)
+               (Detector. @this 255))})

 (defn gray-mat->bw-mat [gray-mat bw-mat]
-  (Imgproc/threshold gray-mat bw-mat 128 255 Imgproc/THRESH_BINARY)
+  (Imgproc/threshold gray-mat bw-mat BW-THRESH 255 Imgproc/THRESH_BINARY)
   bw-mat)

 (defn update-gray-mat
@@ -54,18 +57,14 @@
 (defn update-gray-p-image
   [{:keys [frame-mat gray-mat output-mat b-array i-array] :as state}]
   (if frame-mat
-    (let [orig-frame-mat frame-mat
-          wrapped-state (-> state
-                            (assoc-in [:frame-mat] gray-mat))]
-      (-> wrapped-state
-          (update-in [:p-image] #(cv/gray-mat->p-img gray-mat output-mat b-array i-array %))
-          (assoc-in [:frame-mat] orig-frame-mat)))
+    (update-in state [:p-image] #(cv/gray-mat->p-img gray-mat output-mat b-array i-array %))
     state))

 (defn update-blobs [{:keys [detector p-image] :as state}]
-  (.imageFindBlobs detector p-image)
-  (.loadBlobsFeatures detector)
-  (.findCentroids detector)
+  (when p-image
+    (.imageFindBlobs detector p-image)
+    (.loadBlobsFeatures detector)
+    (.findCentroids detector))
   state)

 (defn update [state]
@@ -81,14 +80,15 @@
              40 40))

 (defn draw-centroids [{:keys [detector]}]
-  (q/push-style)
-  (q/no-stroke)
-  (q/fill 0 255 0 80)
-  (if (< 0 (.getBlobsNumber detector))
+  (when (and detector
+             (< 0 (.getBlobsNumber detector)))
+    (q/push-style)
+    (q/no-stroke)
+    (q/fill 0 255 0 80)
     (dorun
      (map #(draw-centroid detector %)
-          (range 0 (.getBlobsNumber detector)))))
-  (q/pop-style))
+          (range 0 (.getBlobsNumber detector))))
+    (q/pop-style)))

 (defn draw [state]
   (let [{:keys [p-image]} state]
@@ -116,3 +116,4 @@
   :on-close on-close
   :middleware [m/fun-mode])

+(reset! this videotest)


Add test for create options

Add test for create options

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -443,6 +443,24 @@

   (is (= "
   CREATE TABLE foo(
+    a varchar,
+    b varchar,
+    c varchar,
+    d varchar,
+    PRIMARY KEY((a, b), c, d))
+  WITH COMPACT STORAGE"
+         (normalize-string
+          (create-table :foo
+                        (column-definitions {:a :varchar
+                                             :b :varchar
+                                             :c :varchar
+                                             :d :varchar
+                                             :primary-key [[:a :b] :c :d]})
+                        (with-options {:compact-storage true})
+                        ))))
+
+  (is (= "
+  CREATE TABLE foo(
     a int,
     b map<varchar, varchar>,
     PRIMARY KEY(a))"


Add basic insert tests

Add basic insert tests

--- test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
+++ test/clojure/clojurewerkz/cassaforte/new_query_api_test.clj
@@ -167,6 +167,19 @@
                (select :foo
                        (limit 42)
                        (limit 42))))
+
+  (is (= "INSERT INTO foo(asd) VALUES ('bsd');"
+         (insert :foo
+                 (value "asd" "bsd"))))
+  (is (= "INSERT INTO foo(asd) VALUES ('bsd');"
+         (insert :foo
+                 (values ["asd"] ["bsd"]))))
+
+  (is (= "INSERT INTO foo(asd) VALUES ('bsd');"
+         (insert :foo
+                 (values {"asd" "bsd"}))))
+
+
   )


Add sorting to track queries

Add sorting to track queries

--- src/ktra_indexer/db.clj
+++ src/ktra_indexer/db.clj
@@ -251,7 +251,8 @@
                  "INNER JOIN episode_tracks et USING (track_id) "
                  "INNER JOIN episodes e ON e.ep_id = et.ep_id "
                  "WHERE artist_id = "
-                 "(SELECT artist_id FROM artists WHERE name LIKE ?)")
+                 "(SELECT artist_id FROM artists WHERE name LIKE ?) "
+                 "ORDER BY track_name ASC")
             artist]))

 (defn get-all-artists
@@ -275,5 +276,6 @@
                    "INNER JOIN artists a USING (artist_id) "
                    "INNER JOIN episode_tracks et USING (track_id) "
                    "INNER JOIN episodes e ON e.ep_id = et.ep_id "
-                   "WHERE to_tsvector(t.name) @@ to_tsquery(?)")
+                   "WHERE to_tsvector(t.name) @@ to_tsquery(?)"
+                   "ORDER BY ep_name ASC")
               (s/join " & " tokens)])))


replace hardcoded html with hiccup in new ui

--- src/lambdacd/new_ui.clj
+++ src/lambdacd/new_ui.clj
@@ -2,6 +2,7 @@
   (:use compojure.core)
   (:require [compojure.route :as route]
             [hiccup.core :as hc]
+            [hiccup.page :as page]
             [clojure.data.json :as json :only [write-str]]
             [lambdacd.presentation :as presentation]
             [lambdacd.manualtrigger :as manualtrigger]
@@ -9,20 +10,21 @@
             [ring.util.response :as resp]
             [lambdacd.execution :as execution]
             [lambdacd.pipeline-state :as pipeline-state]))
-;; FIXME: proper hiccup here:
-(def page-start "
-
-  <title>LambdaCD - Pipeline</title>
-
-   <meta http-equiv=\"refresh\" content=\"5\">
-  <link rel=\"stylesheet\" type=\"text/css\" href=\"/ui2/semantic-ui/semantic.css\"/>
-<link rel=\"stylesheet\" type=\"text/css\" href=\"/ui2/css/main.css\"/>
-")

-(def page-end "
-
-
-")
+(defn- refresh-every [seconds]
+  [:meta {:http-equiv "refresh" :content (str seconds)}])
+
+(defn page [body]
+  (page/html5
+         [:head
+          [:title "LambdaCD - Pipeline"]
+          (refresh-every 5)
+          (page/include-css "/ui2/semantic-ui/semantic.css")
+          (page/include-css "/ui2/css/main.css")
+          (page/include-js "//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js")
+          (page/include-js "/ui2/semantic-ui/semantic.js")]
+          [:body
+           body]))

 (defn- icon-style-for [{status :status}]
   (case status
@@ -78,15 +80,15 @@
         history-column [:div {:class "ui three wide column"} history]
         content-column [:div {:class "ui thirteen wide column"} content]
         columns [:div {:class "ui segment stackable grid"} history-column content-column]
-        body (hc/html (list header columns))]
-    (str page-start page-end body page-end)))
+        body (list header columns)]
+    body))

 (defn- pipeline-view [pipeline-def pipeline-state build-number]
   (let [build-history (pipeline-state/history-for pipeline-state)
         pipeline-state-for-build (get pipeline-state (Integer/parseInt build-number))]
     (println "build number" build-number)
-    (body (history build-history)
-          (pipeline (presentation/display-representation pipeline-def) true pipeline-state-for-build))))
+    (hc/html (page (body (history build-history)
+          (pipeline (presentation/display-representation pipeline-def) true pipeline-state-for-build))))))

 (defn new-ui-routes [pipeline-def pipeline-state]
   (routes


fix: postgres.clj reflections

fix: postgres.clj reflections

--- src/main/clojure/pdok/postgres.clj
+++ src/main/clojure/pdok/postgres.clj
@@ -16,8 +16,8 @@
 (def joda-time-writer
   (transit/write-handler
    (constantly "lm")
-   (fn [v] (-> v tc/to-date .getTime))
-   (fn [v] (-> v tc/to-date .getTime .toString))))
+   (fn [v] (.getTime ^java.util.Date (tc/to-date v)))
+   (fn [v] (.toString ^java.lang.Long (.getTime ^java.util.Date (tc/to-date v))))))

 (def joda-time-reader
   (transit/read-handler #(-> % (tc/from-long) (tc/to-local-date-time))))
@@ -25,8 +25,8 @@
 (def joda-local-date-writer
   (transit/write-handler
    (constantly "ld")
-   (fn [v] (-> v tc/to-date .getTime))
-   (fn [v] (-> v tc/to-date .getTime .toString))))
+   (fn [v] (.getTime ^java.util.Date (tc/to-date v)))
+   (fn [v] (.toString ^java.lang.Long (.getTime ^java.util.Date (tc/to-date v))))))

 (def joda-local-date-reader
   (transit/read-handler #(tc/to-local-date (tc/from-long %))))
@@ -38,7 +38,7 @@
    str))

 (def int-reader
-  (transit/read-handler #(Integer. %)))
+  (transit/read-handler #(Integer. ^java.lang.String %)))

 (def transit-write-handlers (atom {}))
 (def transit-read-handlers (atom {}))
@@ -70,7 +70,7 @@
 (defn from-json [str]
   (if (clojure.string/blank? str)
     nil
-    (let [in (ByteArrayInputStream. (.getBytes str))
+    (let [in (ByteArrayInputStream. (.getBytes ^java.lang.String  str))
           reader (transit/reader in :json
                                  {:handlers @transit-read-handlers})]
       (transit/read reader))))
@@ -86,7 +86,7 @@
   org.joda.time.LocalDate
   (sql-value [v] (tc/to-sql-date v))
   com.vividsolutions.jts.geom.Geometry
-  (sql-value [v] (str "SRID=" (.getSRID v) ";" (.write wkt-writer v)))
+  (sql-value [v] (str "SRID=" (.getSRID v) ";" (.write ^WKTWriter wkt-writer v)))
   clojure.lang.Keyword
   (sql-value [v] (name v))
   clojure.lang.IPersistentMap
@@ -145,9 +145,9 @@

 (extend-protocol j/IResultSetReadColumn
   java.sql.Date
-  (result-set-read-column [v _ _] (LocalDate. v nlZone))
+  (result-set-read-column [v _ _] (LocalDate. ^java.sql.Date v ^DateTimeZone nlZone))
   java.sql.Timestamp
-  (result-set-read-column [v _ _] (LocalDateTime. v nlZone))
+  (result-set-read-column [v _ _] (LocalDateTime. ^java.sql.Timestamp v  ^DateTimeZone nlZone))
   java.sql.Array
   (result-set-read-column [v _ _]
     (into [] (.getArray v))))


Removed unnecessary variable

Removed unnecessary variable

--- src/riemann/stackdriver.clj
+++ src/riemann/stackdriver.clj
@@ -16,8 +16,7 @@
 (defn generate-datapoint
   "Generate datapoint from an event."
   [opts event]
-  (let [host (:host event)
-        value (:metric event)
+  (let [value (:metric event)
         service (metric-name opts event)]
     {:name service
      :value value


[WM] delete unused requires from queue ns template

--- resources/leiningen/new/kraken_works/queue.clj
+++ resources/leiningen/new/kraken_works/queue.clj
@@ -1,9 +1,6 @@
 (ns {{name}}.queue
   (:require [clojure.tools.logging :as log]
             [langohr.core :as rmq]
-            [langohr.channel :as lch]
-            [langohr.exchange :as le]
-            [langohr.queue :as lq]
             [kehaar.rabbitmq]
             [kehaar.wire-up :as wire-up]
             [{{name}}.channels :as channels]


searcher's search! behavior should use argument it's given

--- src/lt/objs/search.cljs
+++ src/lt/objs/search.cljs
@@ -116,9 +116,9 @@

 (behavior ::search!
           :triggers #{:search!}
-          :reaction (fn [this]
+          :reaction (fn [this search-info]
                       (object/raise this :clear!)
-                      (let [info (->search-info this)]
+                      (let [info (or search-info (->search-info this))]
                         (when-not (empty? (:search info))
                           (object/merge! this info)
                           (notifos/working "Searching workspace...")


don't be a tard :unamused:

don't be a tard :unamused:

--- src/metabase/routes.clj
+++ src/metabase/routes.clj
@@ -8,7 +8,7 @@

 (let [redirect-to-setup? (fn [{:keys [uri]}]                      ; Redirect naughty users who try to visit a page other than setup
                            (and (setup/token-exists?)             ; if setup is not yet complete
-                                (re-matches #"^/setup/.*$" uri)))
+                                (not (re-matches #"^/setup/.*$" uri))))
       index (fn [request]
               (if (redirect-to-setup? request) (resp/redirect (format "/setup/init/%s" (setup/token-value)))
                   (resp/resource-response "frontend_client/index.html")))]


Removed erroneous 'denotes' comment and changed 'BE' prefix to 'B'

--- resources/rules/post_identifier_merge/temp/goa/goa.clj
+++ resources/rules/post_identifier_merge/temp/goa/goa.clj
@@ -35,7 +35,7 @@
           (:optional
            ((?/record obo/BFO_0000051 ?/qualifier_fv) ; BFO:has_part
             (?/qualifier_fv rdf/type ccp/IAO_EXT_0000013) ; ccp:GAF_qualifier_field_value
-            (?/qualifier_fv rdfs/label ?/qualifier))) ; IAO:denotes
+            (?/qualifier_fv rdfs/label ?/qualifier)))
           (:or (:not (:bound ?/qualifier))
                (:not (:regex ?/qualifier "^NOT" "i")))
          )
@@ -43,7 +43,7 @@
   :reify ([?/process_sc {:ln (:sha-1 ?/process ?/participation_restriction)
                  :ns "ccp" :prefix "BP_"}]
           [?/bioentity_sc {:ln (:sha-1 ?/process ?/participating_bioentity)
-                    :ns "ccp" :prefix "BE_"}]
+                    :ns "ccp" :prefix "B_"}]
           [?/participation_restriction {:ln (:restriction)
                  :ns "ccp" :prefix "R_"}])

@@ -94,7 +94,7 @@
           (:optional
            ((?/record obo/BFO_0000051 ?/qualifier_fv) ; BFO:has_part
             (?/qualifier_fv rdf/type ccp/IAO_EXT_0000013) ; ccp:GAF_qualifier_field_value
-            (?/qualifier_fv rdfs/label ?/qualifier))) ; IAO:denotes
+            (?/qualifier_fv rdfs/label ?/qualifier)))
           (:or (:not (:bound ?/qualifier))
                (:not (:regex ?/qualifier "^NOT" "i")))

@@ -106,7 +106,7 @@
           [?/target_end_restriction {:ln (:restriction)
                  :ns "ccp" :prefix "R_"}]
           [?/bioentity_sc {:ln (:sha-1 ?/go_cc ?/bioentity)
-                     :ns "kbio" :prefix "BE_"}]
+                     :ns "kbio" :prefix "B_"}]
           [?/component_sc {:ln (:sha-1 ?/go_cc ?/bioentity)
                     :ns "kbio" :prefix "CC_"}]
           )


(PDB-3935) facts-test: Use jdbc, not pdb config to clear db, etc.

There was no need to convert the jdbc config to a pdb config for the
init/clear db functions, since they expect the former.

--- test/puppetlabs/puppetdb/http/facts_test.clj
+++ test/puppetlabs/puppetdb/http/facts_test.clj
@@ -652,13 +652,11 @@
    (fn [read-db-config write-db-config]
      (let [config (-> (svc-utils/create-temp-config)
                       (assoc :read-database read-db-config)
-                      (assoc :database write-db-config))
-           read-config (-> read-db-config defaulted-read-db-config)
-           write-config (-> write-db-config defaulted-write-db-config)]
-       (clear-db-for-testing! read-config)
-       (clear-db-for-testing! write-config)
-       (init-db read-config true)
-       (init-db write-config false)
+                      (assoc :database write-db-config))]
+       (clear-db-for-testing! read-db-config)
+       (clear-db-for-testing! write-db-config)
+       (init-db read-db-config true)
+       (init-db write-db-config false)
        (call-with-puppetdb-instance
         config
         (fn []


Port address module to Clojure

Port address module to Clojure

--- src/test_utils/address.cljc
+++ src/test_utils/address.cljc
@@ -2,7 +2,9 @@
   #?(:cljs (:require [test-utils.core :as tuc]
                      [test-utils.word-source :as ws]
                      [goog.string :as gstring]
-                     [goog.string.format])))
+                     [goog.string.format])
+     :clj (:require [test-utils.core :as tuc]
+                    [test-utils.word-source :as ws])))

 (defn house-number []
   (tuc/rand-4))
@@ -16,9 +18,11 @@
 (defn phone-number []
   ;; North America phone numbers only. See https://en.wikipedia.org/wiki/North_American_Numbering_Plan.
   ;; The generated phone numbers have the correct format but are **invalid**.
-  (str "1" #?(:cljs (gstring/format "%02d" (tuc/rand-2))) ;; area code - begins with 1
+  (str "1" #?(:cljs (gstring/format "%02d" (tuc/rand-2))
+              :clj (format "%02d" (tuc/rand-2))) ;; area code - begins with 1
        "-" "555" ;; central office, exchange, or exchange code
-       "-01" #?(:cljs (gstring/format "%02d" (tuc/rand-2))))) ;; line, subscriber, or station number
+       "-01" #?(:cljs (gstring/format "%02d" (tuc/rand-2))
+                :clj (format "%02d" (tuc/rand-2))))) ;; line, subscriber, or station number

 (defn state []


Generate random p-mon and delta-p-mon values

--- src/test_utils/sandbox.cljs
+++ src/test_utils/sandbox.cljs
@@ -126,44 +126,22 @@
                stop-duration-s]]
      [start stop])))

-(defn treatment-times []
-  (let [[start-0 stop-0] (typical-treatment-time-range)
-        next-fn (fn [[start-n-1 stop-n-1]]
-                  (typical-treatment-time-range start-n-1 stop-n-1))]
-    (iterate next-fn [start-0 stop-0])))
-
-(defn typical-stage-separation []
-  (tuc/draw-normal 45 3))
-
-(defn stage-extents []
-  (let [extent-0 (typical-stage-extent)
-        next-fn (fn [[top-n-1 bottom-n-1] extent-0]
-                   (let [bottom (- top-n-1 (typical-stage-separation))
-                         top (- bottom (typical-stage-length))]
-                     [top bottom]))]
-    (iterate next-fn extent-0)))
-
-;;; mean-traj-delta-x 824.6082 std-traj-delta-x 22.9065
-;;; mean-traj-delta-y 1048.7   std-traj-delta-y 0.6520
-;;; mean-traj-delta-z 1101.3   std-traj-delta-z 0.4614
-
-;;; mean-traj-delta-x std-traj-delta-x
-;;;  73.4429           11.4000
-;;; 226.1058            6.4168
-;;; 153.4668            6.3606
-;;; 150.1713            8.0515
-
-;;; mean-traj-delta-y std-traj-delta-y
-;;; 139.0710          11.8006
-;;;  16.4374           7.9442
-;;; 311.8567          10.0601
-;;;  61.0152          3.8705
-
-;;; mean-traj-delta-z std-traj-delta-z
-;;; 110.1814           1.9290
-;;; 122.2491           3.7357
-;;; 111.6584           4.4176
-;;; 120.4373           3.5104
+    (defn treatment-times []
+    (let [[start-0 stop-0] (typical-treatment-time-range)
+            next-fn (fn [[start-n-1 stop-n-1]]
+                    (typical-treatment-time-range start-n-1 stop-n-1))]
+        (iterate next-fn [start-0 stop-0])))
+
+    (defn typical-stage-separation []
+    (tuc/draw-normal 45 3))
+
+    (defn stage-extents []
+    (let [extent-0 (typical-stage-extent)
+            next-fn (fn [[top-n-1 bottom-n-1] extent-0]
+                    (let [bottom (- top-n-1 (typical-stage-separation))
+                            top (- bottom (typical-stage-length))]
+                        [top bottom]))]
+        (iterate next-fn extent-0)))

 (defn typical-interwell-distance [plot-angle]
   (let [euclidean-distance (tuc/draw-normal 874 37)
@@ -179,3 +157,95 @@

 (defn typical-azimuth [plot-angle]
   (tuc/draw-normal plot-angle 1.24))
+
+(defn make-line-generator [[m b]]
+  (fn [t]
+    (+ (* m t) b)))
+
+(def p-mon-generator-parameters [[-1.8590e-02   2.8583e+02]
+                                 [-3.0727e-03   6.0814e+01]
+                                 [-4.6937e-03   1.0586e+02]
+                                 [7.9858e-03   9.6910e+00]
+                                 [7.9035e-02  -1.7834e+02]
+                                 [-7.5163e-03   1.6379e+02]
+                                 [-6.5209e-03   1.2149e+02]
+                                 [-7.1622e-03   1.1633e+02]
+                                 [-6.3279e-03   1.1242e+02]
+                                 [3.4088e-02  -4.6007e+01]
+                                 [-1.6031e-02   2.8456e+02]
+                                 [-3.3784e-03   1.0165e+02]
+                                 [2.7285e-02  -4.6048e+01]
+                                 [1.0749e-01  -1.2872e+02]
+                                 [-5.3974e-03   1.3903e+02]
+                                 [-3.6674e-03   7.7673e+01]
+                                 [-3.7600e-03   7.0792e+01]
+                                 [-2.6080e-03   4.3603e+01]
+                                 [-1.6967e-02   2.7267e+02]
+                                 [-1.0160e-02   1.6014e+02]
+                                 [-6.9151e-03   1.1013e+02]
+                                 [-2.8395e-03   5.2684e+01]
+                                 [1.4582e-04   1.4241e+01]
+                                 [1.4412e-03   1.1006e+01]
+                                 [2.0431e-02  -2.4441e+01]
+                                 [6.5569e-02  -1.0583e+02]
+                                 [-1.4590e-04   4.0460e+01]
+                                 [-4.1713e-03   8.6142e+01]
+                                 [-2.7311e-03   5.5830e+01]
+                                 [7.8723e-02  -3.5040e+02]
+                                 [-1.0843e-02   1.6752e+02]
+                                 [-3.3414e-03   5.9796e+01]
+                                 [-2.7253e-03   4.5386e+01]
+                                 [-1.6702e-03   2.4405e+01]])
+
+(defn rand-stage-time-point-seconds []
+  (let [time-seconds (* 3600 (tuc/draw-normal 2.52 0.17))]
+    (* time-seconds (rand))))
+
+(defn make-pressure-generator [generator-parameters]
+  (make-line-generator (rand-nth generator-parameters)))
+
+(defn rand-p-mon []
+  (let [generator (make-pressure-generator p-mon-generator-parameters)]
+    (generator (rand-stage-time-point-seconds))))
+
+;; (defn rand-delta-p-mon []
+;;   (tuc/rand-range 1704))
+
+(def delta-p-mon-generator-parameters [[-1.8590e-02   1.1321e+03]
+                                       [-3.0727e-03   7.1547e+02]
+                                       [-4.6937e-03   6.4841e+02]
+                                       [7.9858e-03   4.8889e+02]
+                                       [7.9035e-02   2.7188e+02]
+                                       [-7.5163e-03   1.1302e+03]
+                                       [-6.5209e-03   9.6394e+02]
+                                       [-7.1622e-03   8.3598e+02]
+                                       [-6.3279e-03   7.1826e+02]
+                                       [3.4088e-02   2.6802e+02]
+                                       [-1.6031e-02   1.1028e+03]
+                                       [-3.3784e-03   6.0276e+02]
+                                       [2.7285e-02   3.9359e+02]
+                                       [1.0749e-01   4.5376e+02]
+                                       [-5.3974e-03   1.2390e+03]
+                                       [-3.6674e-03   9.3976e+02]
+                                       [-3.7600e-03   8.0181e+02]
+                                       [-2.6080e-03   6.7863e+02]
+                                       [-1.6967e-02   8.1044e+02]
+                                       [-1.0160e-02   4.8040e+02]
+                                       [-6.9151e-03   3.0316e+02]
+                                       [-2.8395e-03   1.0520e+02]
+                                       [1.4582e-04   8.8145e+00]
+                                       [1.4412e-03  -8.9868e+00]
+                                       [2.0431e-02  -4.4215e+01]
+                                       [6.5569e-02   6.2604e+01]
+                                       [-1.4590e-04   7.8367e+02]
+                                       [-4.1713e-03   7.2263e+02]
+                                       [-2.7311e-03   5.9209e+02]
+                                       [7.8723e-02   1.2100e+02]
+                                       [-1.0843e-02   1.5910e+03]
+                                       [-3.3414e-03   1.4108e+03]
+                                       [-2.7253e-03   1.3492e+03]
+                                       [-1.6702e-03   1.2961e+03]])
+
+(defn rand-delta-p-mon []
+  (let [generator (make-pressure-generator delta-p-mon-generator-parameters)]
+    (generator (rand-stage-time-point-seconds))))


Add function that checks if we need to delete a board give the remaining entries.

Delete the board only if it's a draft board and it has no more entries in it.

--- src/oc/storage/resources/board.clj
+++ src/oc/storage/resources/board.clj
@@ -8,7 +8,8 @@
             [oc.lib.slugify :as slug]
             [oc.lib.db.common :as db-common]
             [oc.storage.resources.common :as common]
-            [oc.storage.resources.org :as org-res]))
+            [oc.storage.resources.org :as org-res]
+            [oc.storage.async.notification :as notification]))

 ;; ----- RethinkDB metadata -----

@@ -251,6 +252,22 @@
   (when-let* [board (get-board conn org-uuid slug)]
     (db-common/remove-from-set conn table-name (:uuid board) "viewers" user-id)))

+;; ----- Draft board delete on emptyness ------
+
+(defn maybe-delete-draft-board
+  "Check if a board is actually a draft board and if it has no more entries remove it."
+  [conn org board remaining-entries user]
+  (timbre/info "maybe-delete-draft-board" (:uuid board) "draft?" (:draft board) "entries" (count remaining-entries))
+  (when (and ;; if it's a draft board
+             (:draft board)
+             ;; and has no more entries
+             (zero? (count remaining-entries)))
+    (timbre/info "Deleting board:" (:uuid board) "because last draft was removed.")
+    ;; Remove also the board
+    (delete-board! conn (:uuid board) remaining-entries)
+    (timbre/info "Deleted board:" (:uuid board))
+    (notification/send-trigger! (notification/->trigger :delete org {:old board} user))));)
+
 ;; ----- Collection of boards -----

 (defn list-boards


test an assoc fix pt2

test an assoc fix pt2

--- src/open_company/api/companies.clj
+++ src/open_company/api/companies.clj
@@ -156,12 +156,11 @@
   :post! (fn [{:keys [user data] :as ctx}]
            (let [company (->> (company/->company data user (find-slug conn data))
                               (company/add-core-placeholder-sections)
-                              (company/create-company! conn))
-                 ctx' (assoc (common/clone ctx) :company company)]
+                              (company/create-company! conn))]
              (timbre/info "Class of ctx" (class ctx))
-             (timbre/info "Class of ctx after into" (class (into {} ctx)))
+             (timbre/info "Class of ctx after into" (class (common/clone ctx)))
              (when (:bot user) ; Some JWTokens might not have a bot token
-               (bot/send-trigger! (bot/ctx->trigger :onboard ctx')))
+               (bot/send-trigger! (bot/ctx->trigger :onboard (assoc (common/clone ctx) :company company))))
              {:company company}))

   :handle-ok (fn [ctx] (company-rep/render-company-list (:companies ctx)))


Continue reading s3 checkpoint if partially read.

--- src/onyx/storage/s3.clj
+++ src/onyx/storage/s3.clj
@@ -82,7 +82,12 @@
         object (.getObject client object-request)
         nbytes (.getContentLength (.getObjectMetadata object))
         bs (byte-array nbytes)
-        n-read (.read (.getObjectContent object) bs)]
+        n-read (loop [offset 0]
+                 (let [n-read (.read (.getObjectContent object) bs offset (- nbytes offset))]
+                   (if-not (= n-read -1)
+                     (recur (+ offset n-read))
+                     offset)))]
+    (println "Recovered" n-read "bytes")
     (.close object)
     (when-not (= nbytes n-read)
       (throw (ex-info "Didn't read entire checkpoint."


show image previews for the chats

show image previews for the chats

--- src/pc/http/datomic.clj
+++ src/pc/http/datomic.clj
@@ -61,12 +61,14 @@
           (re-find #"(?i)@prcrsr|@danny|@daniel" (:v chat-datom))
           (let [message (format "<%s|%s>: %s"
                                 (urls/doc @document-id) @document-id (:v chat-datom))]
-            (http/post slack-url {:form-params {"payload" (json/encode {:text message :username username :icon_url icon_url})}}))
+            (http/post slack-url {:form-params {"payload" (json/encode {:text message :username username :icon_url icon_url
+                                                                        :attachments [{:image_url (urls/doc-png @document-id)}]})}}))

           (= 1 (count (get @sente/document-subs @document-id)))
           (let [message (format "<%s|%s> is typing messages to himself: \n %s"
                                 (urls/doc @document-id) @document-id (:v chat-datom))]
-            (http/post slack-url {:form-params {"payload" (json/encode {:text message :username username :icon_url icon_url})}}))
+            (http/post slack-url {:form-params {"payload" (json/encode {:text message :username username :icon_url icon_url
+                                                                        :attachments [{:image_url (urls/doc-png @document-id)}]})}}))
           :else nil)))))

 (defn admin-notify-subdomains [transaction]


Tweak output format

Tweak output format

--- src/pinpointer/core.clj
+++ src/pinpointer/core.clj
@@ -40,8 +40,9 @@
                    sval (pr-str val)]]
        (when (not= i 0)
          (newline))
-       #_(print " Problem: ")
-       #_(prn (assoc problem :val val))
+       #_(doseq [prob probs]
+         (print " Problem: ")
+         (prn (assoc prob :val val)))
        (println "   Input:" (str (subs sval 0 start)
                                  (colorize-by colorize (subs sval start end))
                                  (when (> (count sval) end)
@@ -51,9 +52,10 @@
        (doseq [[j {:keys [pred reason]}] (map-indexed vector probs)]
          (when (not= j 0)
            (print "          "))
-         (prn pred)
+         (pr pred)
          (when reason
-           (printf "(%s)\n" reason)))))))
+           (printf " (%s)" reason))
+         (newline))))))

 (defn pinpoint
   ([spec x] (pinpoint spec x {}))


Reformatting

Reformatting

--- src/player/ha_eval.cljs
+++ src/player/ha_eval.cljs
@@ -77,17 +77,19 @@
         ; No need to worry about ordering effects here, recalculating edges will not change any behaviors
         ; or entry times so there's no problem with doing it in any order.
         ;_ (println "memo hit 1" ha/memo-hit ha/guard-check)
-        ha-vals (ha/extrapolate-all ha-defs ha-vals (apply max (map :entry-time (vals ha-vals))))
+        ha-vals (ha/extrapolate-all ha-defs
+                                    ha-vals
+                                    (apply max (map :entry-time (vals ha-vals))))
         ;_ (println "extrapolations before" ha/extrapolations)
         tr-caches (with-guard-memo
-                              (reduce (fn [tr-caches [id _sid idx _deps]]
-                                        (let [ha (get ha-vals id)
-                                              tr-cache (get tr-caches id)
-                                              tr-cache (recalculate-edge ha-defs ha-vals ha tr-cache idx t)]
-                                          #_(println "T recalc" id idx)
-                                          (assoc tr-caches id tr-cache)))
-                                      tr-caches
-                                      dependencies))
+                    (reduce (fn [tr-caches [id _sid idx _deps]]
+                              (let [ha (get ha-vals id)
+                                    tr-cache (get tr-caches id)
+                                    tr-cache (recalculate-edge ha-defs ha-vals ha tr-cache idx t)]
+                                #_(println "T recalc" id idx)
+                                (assoc tr-caches id tr-cache)))
+                            tr-caches
+                            dependencies))
         ;_ (println "extrapolations after" ha/extrapolations)
         ;_ (println "memo hit 2" ha/memo-hit ha/guard-check)
         ]


cursor is just a locator, it knows nothing about state

--- src/rex/ext/cursor.cljs
+++ src/rex/ext/cursor.cljs
@@ -8,15 +8,7 @@

   (featured [this field features])

-  (zoom-in [this feature])
-
-  ;; TODO:
-  ;; get rid of update-state, get-state
-  ;; store must provide explicit interface for reducers
-  ;; for example with get-value(key), set-value(key,value) semantics
-  (update-state [this state new-local-state])
-
-  (get-state [this state]))
+  (zoom-in [this feature]))

 (deftype Cursor [items]
   ICursor
@@ -39,16 +31,16 @@
                    (not (nil? (some #(= % feature)
                                     (:features item)))))
                  items)]
-      (Cursor. items)))
-
-  (update-state [this state new-local-state]
-    (let [path (cursor-key this)]
-      (if (empty? path)
-        new-local-state
-        (assoc-in state (cursor-key this) new-local-state))))
-
-  (get-state [this state]
-    (get-in state (cursor-key this))))
+      (Cursor. items))))

 (defn make-cursor []
   (Cursor. []))
+
+(defn update-state [this state new-local-state]
+  (let [path (cursor-key this)]
+    (if (empty? path)
+      new-local-state
+      (assoc-in state (cursor-key this) new-local-state))))
+
+(defn get-state [this state]
+  (get-in state (cursor-key this)))


Use first argument as configuration file fallback

This preserves backward compatibility but using -c or --config should be
the prefered way for specifying the configuration file.

--- src/statuses/server.clj
+++ src/statuses/server.clj
@@ -23,16 +23,15 @@

 (def cli-options
   [["-p" "--port PORT" "Port number" :parse-fn #(Integer/parseInt %)]
-  ["-h" "--host HOST" "Hostname"]
-  ["-c" "--conf ConfigurationFile" "The Location of the Configuration File"]])
+   ["-h" "--host HOST" "Hostname"]
+   ["-c" "--conf ConfigurationFile" "The Location of the Configuration File"]])

 (defn -main [& args]
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
-    (cfg/init! (or (:conf options) "config.clj"))
+    (println "CLI Options: " (str options))
+    (cfg/init! (or (:conf options) (first arguments) "config.clj"))
     (println "Configuration: " (config))
-    (println "CLI Options: " (str options))
     (persistence/init! (config :database-path) (config :save-interval))
-
     (println "Starting server on host" (or (:host options) (config :host))
              "port" (or (:port options) (config :http-port))
              "in mode" (config :run-mode))
@@ -42,7 +41,6 @@
         app)
       {:host (or (:host options) (config :host))
        :port (or (:port options) (config :http-port))
-       :join? false}))
-  )
+       :join? false})))


Adding pricing to osx ga migration notice.

--- src-cljs/frontend/components/org_settings.cljs
+++ src-cljs/frontend/components/org_settings.cljs
@@ -449,7 +449,7 @@
             (if-let [new-plan (get plan-migrations current-plan-name)]
               [:div.your-plan
                [:span "You are currently on '"]
-               [:span.plan-name "Limited Release " current-plan-name]
+               [:span.plan-name "Limited Release " current-plan-name  " ($" (pm/osx-cost plan) "/mo)" ]
                [:span "' and will be moved to '"]
                [:span.plan-name "General Release " (get plan-migrations current-plan-name)]
                [:span "' on March 31st."]]


Add tests for fields with spaces

Add tests for fields with spaces


Improves readability of saved? with destructuring

--- src/wordsmith/core.cljs
+++ src/wordsmith/core.cljs
@@ -87,10 +87,10 @@
 (defn button-click [app]
   (put! (:channel @app) [:save nil]))

-(defn saved? [app]
+(defn saved? [{:keys [input last-input title last-title]}]
   (and
-    (= (:input app) (:last-input app))
-    (= (:title app) (:last-title app))))
+    (= input last-input)
+    (= title last-title)))

 (defn save-button [app owner]
   (reify


Fill gaps in data. This didn't however change output data.

--- src/clj_simple_chart/ncs/production_monthly_field.clj
+++ src/clj_simple_chart/ncs/production_monthly_field.clj
@@ -1,10 +1,28 @@
 (ns clj-simple-chart.ncs.production-monthly-field
   (:require [clojure.test :as test]
             [clj-http.client :as client]
+            [clojure.string :as string]
             [clj-simple-chart.csv.csvmap :as csv]
             [clj-simple-chart.ncs.reserve :as reserve]
             [clj-simple-chart.csv.csvmap :as csvmap])
   (:import (java.time YearMonth)))
+
+(defn year-month [s]
+  {:pre [(string? s)]}
+  (let [parts (string/split s #"-0?")
+        year (read-string (first parts))
+        month (read-string (last parts))]
+    (YearMonth/of year month)))
+
+(defn date-range
+  ([start stop] (date-range [] start stop))
+  ([sofar start stop]
+   (cond
+     (string? start) (recur sofar (year-month start) stop)
+     (string? stop) (recur sofar start (year-month stop))
+     (.equals start stop)
+     (mapv #(format "%04d-%02d" (.getYear %) (.getMonthValue %)) (conj sofar stop))
+     :else (date-range (conj sofar start) (.plusMonths start 1) stop))))

 (def field-monthly-production-url "http://factpages.npd.no/ReportServer?/FactPages/TableView/field_production_monthly&rs:Command=Render&rc:Toolbar=false&rc:Parameters=f&rs:Format=CSV&Top100=false&IpAddress=80.213.237.130&CultureCode=en")
 (defonce raw-data (-> field-monthly-production-url
@@ -26,25 +44,44 @@
                (csv/read-string-columns numeric-columns)
                (csv/number-or-nil-columns numeric-columns)
                ; bootstrap cumulative values
-               (map #(assoc % :oil-cumulative (:prfPrdOilNetMillSm3 %)))
                (map #(assoc % :gas-cumulative (:prfPrdGasNetBillSm3 %)))
-               (map #(assoc % :oe-cumulative (:prfPrdOeNetMillSm3 %)))
                (map #(assoc % :date (str (format "%04d-%02d" (:prfYear %) (:prfMonth %)))))
                (map #(assoc % :days-in-month (. (YearMonth/of (:prfYear %) (:prfMonth %)) lengthOfMonth)))
-               (map #(assoc % :fldRecoverableOil (reserve/get-reserve (:prfInformationCarrier %) :fldRecoverableOil)))
                (map #(assoc % :fldRecoverableGas (reserve/get-reserve (:prfInformationCarrier %) :fldRecoverableGas)))
-               (map #(assoc % :fldRecoverableOE (reserve/get-reserve (:prfInformationCarrier %) :fldRecoverableOE)))
                (filter #(pos? (:fldRecoverableGas %)))
                ; remove unused values
-               (map #(dissoc % :prfPrdNGLNetMillSm3))
-               (map #(dissoc % :prfPrdCondensateNetMillSm3))
-               (map #(dissoc % :prfPrdProducedWaterInFieldMillSm3))
-               (map #(dissoc % :prfNpdidInformationCarrier))
+               (map #(dissoc % :prfPrdNGLNetMillSm3
+                             :prfPrdCondensateNetMillSm3
+                             :prfPrdProducedWaterInFieldMillSm3
+                             :prfNpdidInformationCarrier
+                             :prfPrdOeNetMillSm3
+                             :prfPrdOilNetMillSm3
+                             :prfMonth
+                             :prfYear))
                (sort-by :date)
                (vec)))

 (defn add-prev-rows-last-n [n rows]
   (map-indexed (fn [idx x] (assoc x :prev-rows (take-last n (take (inc idx) rows)))) rows))
+
+(defn fill-gaps [production]
+  {:pre [(coll? production)]}
+  (let [field-name (:prfInformationCarrier (first production))
+        dates (sort (mapv :date production))
+        date-range (date-range (first dates) (last dates))
+        missing-months (->> date-range
+                            (remove #(some #{%} dates))
+                            (vec))
+        filled-gaps (mapv (fn [date]
+                            {:gas-cumulative        0.0
+                             :date                  date
+                             :days-in-month         (.lengthOfMonth (year-month date))
+                             :prfInformationCarrier field-name
+                             :prfPrdGasNetBillSm3   0.0
+                             :fldRecoverableGas     (:fldRecoverableGas (first production))}) missing-months)]
+    (->> (concat production filled-gaps)
+         (sort-by :date)
+         (vec))))

 (def bucket-fn
   #(cond
@@ -58,10 +95,8 @@
   [production]
   {:pre [(coll? production)]}
   (->> (sort-by :date production)
-       ;(reductions (fn [old n] (assoc n :start-production (:start-production old))))
-       (reductions (fn [old n] (update n :oil-cumulative (fn [v] (+ v (:oil-cumulative old))))))
+       (fill-gaps)
        (reductions (fn [old n] (update n :gas-cumulative (fn [v] (+ v (:gas-cumulative old))))))
-       (reductions (fn [old n] (update n :oe-cumulative (fn [v] (+ v (:oe-cumulative old))))))
        (add-prev-rows-last-n 12)
        (mapv #(assoc % :gas-production-12-months-est (* (apply + (mapv :prfPrdGasNetBillSm3 (:prev-rows %)))
                                                         (/ 12 (count (:prev-rows %))))))


Fixed small possible bug.

Fixed small possible bug.

--- src/clojush/pushgp/selection/fitness_proportionate.clj
+++ src/clojush/pushgp/selection/fitness_proportionate.clj
@@ -33,7 +33,8 @@
     (loop [pop pop
            random-prob (* max-prob (lrand))]
       (let [current-prob (:fitness-proportionate-selection-probability (first pop))]
-        (if (< random-prob current-prob)
+        (if (or (< random-prob current-prob)
+                (empty? (rest pop)))
           (first pop)
           (recur (rest pop)
                  (- random-prob current-prob)))))))


minor refactor

minor refactor

--- src/midje/parsing/1_to_explicit_form/prerequisites.clj
+++ src/midje/parsing/1_to_explicit_form/prerequisites.clj
@@ -15,10 +15,10 @@

 (defn prerequisite-to-fake [fake-body]
   (let [^Integer line-number (-> fake-body
-                                 (zip/seq-zip)
-                                 (zip/down )
-                                 (zip/right)
-                                 (pointer/line-number-for))
+                                 zip/seq-zip
+                                 zip/down
+                                 zip/right
+                                 pointer/line-number-for)
         fake-tag (if (recognize/metaconstant-prerequisite? fake-body)
                    `data-fake
                    `fake)]


model stock price

model stock price

--- stock-ticker-demo/src/stock_ticker_demo/price_feed.clj
+++ stock-ticker-demo/src/stock_ticker_demo/price_feed.clj
@@ -12,3 +12,28 @@
                 "AMZN" {:max-price 274.1 :min-price 42.7
                         :wavelength 45 :starting-point 0.25
                         :eps 1.15}})
+
+(def stock-codes (keys stock-map))
+
+(defn time-model
+  "Model the price of a stock on sine wave"
+  [time-secs stock-map]
+  (let [max-price (:max-price stock-map)
+        min-price (:min-price stock-map)
+        wavelength (:wavelength stock-map)
+        med-price (+ (/ (- max-price min-price) 2) min-price)
+        amplitude (- max-price med-price)
+        starting-point (:starting-point stock-map)]
+    (+ (* (Math/sin (- (/ (* Math/PI time-secs) wavelength)
+                       (* Math/PI starting-point wavelength)))
+          amplitude)
+       med-price)))
+
+(defn curr-price
+  "Given a stock price - get a price for the current point in time"
+  [stock-code]
+  (format "%.2f"
+          (time-model
+           (/ (java.lang.System/currentTimeMillis) 60)
+           (stock-map stock-code))))
+


Add dispatching support for exp type

Add dispatching support for exp type

--- services/get-comparison-files.clj
+++ services/get-comparison-files.clj
@@ -3,17 +3,20 @@
  :path ""
  :repeat true
  :generator true
- :func (let [bam-ot-pairs (volatile! :nyi)]
-         (fn[eid comp-filename rep?]
-           (when (= @bam-ot-pairs :nyi)
-             (vswap! bam-ot-pairs
-                     (fn[_] (htrs/get-comparison-files eid comp-filename rep?))))
-           (let [pairs @bam-ot-pairs]
-             (if (seq pairs)
-               (let [p (first pairs)]
-                 (vswap! bam-ot-pairs (fn[_] (rest pairs)))
+ :func (let [cmpgrps (volatile! :nyi)]
+         (fn[eid comp-filename opt?]
+           (when (= @cmpgrps :nyi)
+             (vswap! cmpgrps
+                     (fn[_]
+                       (cmn/get-comparison-files
+                        (cmn/get-exp-info eid :exp)
+                        eid comp-filename opt?))))
+           (let [grp @cmpgrps]
+             (if (seq grp)
+               (let [p (first grp)]
+                 (vswap! cmpgrps (fn[_] (rest grp)))
                  p)
                (pg/done)))))

- :description "Streaming comparison input data pairs. Each element is a vector [bams csv] where bams are the input bams to count and csv is the output file for the count matrix."
+ :description "Streaming comparison input data grp. For RNA-Seq, each element is a vector [bams csv] where bams are the input bams to count and csv is the output file for the count matrix. For Tn-Seq, each element is a quad [t1 t2 csv ef], where t1 and t2 are the condition map files, csv the out matrix file, and ef the expansion factor."
  }


use babel.directory to get model rather than creating with (medium)

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -3,7 +3,7 @@
   (:require
    [babel.directory :refer [models]]
    [babel.generate :as generate]
-   [babel.italiano :as italiano :refer [analyze fo-ps generate medium morph
+   [babel.italiano :as italiano :refer [analyze fo-ps generate morph
                                         np-grammar parse preprocess]]
    [babel.italiano.grammar :as grammar]
    [babel.italiano.morphology :as morph :refer [analyze-regular]]
@@ -51,7 +51,7 @@
                                          :subj {:pred :I}
                                          :aspect :simple
                                          :tense :present}}}
-                         :model (medium)
+                         :model model
                          :do-enrich false)]
     (is (= "io sono" (morph result)))))

@@ -114,7 +114,7 @@
                              :subj {:pred :I}
                              :tense :present
                              :aspect :perfect}}}]
-    (is (not (nil? (generate/generate spec (medium)))))))
+    (is (not (nil? (generate/generate spec model))))))

 (deftest passato-prossimo-reflexive
   (let [result (generate {:comp {:synsem {:agr {:gender :fem}}}
@@ -124,7 +124,7 @@
                                          :subj {:pred :I}
                                          :tense :present
                                          :aspect :perfect}}}
-                         :model (medium))]
+                         :model model)]
     (is (not (nil? result)))
     (is (= "io mi sono alzata" (morph result)))))

@@ -136,7 +136,7 @@
                                          :aspect :simple
                                          :subj {:pred :I}
                                          :iobj {:pred :luisa}}}}
-                         :model (medium))]
+                         :model model)]
     (is (not (nil? result)))
     (is (= "io mi chiamo Luisa" (morph result)))))

@@ -212,7 +212,7 @@
                                                 :sem {:tense :present
                                                       :aspect :simple}
                                                 :subcat []}}
-                                      :model (medium))))]
+                                      :model model)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
@@ -232,7 +232,7 @@
                                                 :sem {:tense :past
                                                       :aspect :progressive}
                                                 :subcat []}}
-                                      :model (medium))))]
+                                      :model model)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
@@ -255,7 +255,7 @@
                                                             :aspect :perfect
                                                             :obj :unspec}
                                                       :subcat []}}
-                                            :model (medium))]
+                                            :model model)]
                               result)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
@@ -275,7 +275,7 @@
                                                 :sem {:tense :present
                                                       :aspect :simple}
                                                 :subcat []}}
-                                      :model (medium))))]
+                                      :model model)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                             (let [surface (morph expr)
@@ -296,7 +296,7 @@
                            #(generate {:synsem {:cat :verb
                                                 :sem {:tense :future}
                                                 :subcat []}}
-                                      :model (medium))))]
+                                      :model model)))]
     (is (= do-this-many
            (count (map-fn (fn [expr]
                           (let [surface (morph expr)
@@ -317,7 +317,7 @@
                            #(generate {:synsem {:cat :verb
                                                 :sem {:tense :conditional}
                                                 :subcat []}}
-                                      :model (medium))))]
+                                      :model model)))]
     (log/debug (str "expressions: " (string/join "," (map morph expressions))))
     (is (= do-this-many
            (count (map (fn [expr]
@@ -350,7 +350,7 @@
           (let [semantics (strip-refs
                            (get-in
                             (first
-                             (reduce concat (map :parses (parse surface (medium)))))
+                             (reduce concat (map :parses (parse surface model))))
                             [:synsem :sem]))]
             (is (map? semantics))))
         ["la sua ragazza"
@@ -370,7 +370,7 @@
         (repeatedly #(let [generated
                            (morph (generate {:synsem {:cat :verb
                                                       :subcat []}}))
-                           parsed (reduce concat (map :parses (parse generated (medium))))]
+                           parsed (reduce concat (map :parses (parse generated model)))]
                        (log/info (str "generated: " generated))
                        (log/info (str "semantics: "
                                       (or
@@ -613,7 +613,7 @@
                                           :tense :present
                                           :subj {:gender :fem
                                                  :pred :loro}}}}
-                          :model (medium)))
+                          :model model))
          "loro sono andate")))

 (deftest exists1
@@ -626,7 +626,7 @@
                                           :tense :conditional}}
                            :root {:italiano {:italiano "essere"}}
                            :comp {:synsem {:agr {:number :sing}}}}
-                          :model (medium)))
+                          :model model))
          "ci sarebbe")))

 (deftest exists2
@@ -640,7 +640,7 @@
                                           :tense :past}}
                            :root {:italiano {:italiano "essere"}}
                            :comp {:synsem {:agr {:number :sing}}}}
-                          :model (medium)))
+                          :model model))
          "c'era")))

 (deftest exists3
@@ -654,7 +654,7 @@
                                           :tense :present}}
                            :root {:italiano {:italiano "essere"}}
                            :comp {:synsem {:agr {:number :sing}}}}
-                          :model (medium)))
+                          :model model))
          "c'è")))

 (deftest bisogno


(defn analyze) returns a (possibly-empty) list

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -14,14 +14,17 @@
 (deftest analyze-1
   (let [singular (analyze "compito" (:lookup medium))
         plural  (analyze "compiti" (:lookup medium))]
-    (is (not (nil? singular)))
-    (is (not (nil? plural)))))
+    (is (not (empty? singular)))
+    (is (not (empty? plural)))))

 (deftest analyze-2
   (let [singular (analyze "difficile" (:lookup medium))
         plural  (analyze "difficili" (:lookup medium))]
-    (is (not (nil? singular)))
-    (is (not (nil? plural)))))
+    (is (not (empty? singular)))
+    (is (not (empty? plural)))))
+
+(deftest analyze-3
+  (is (not (empty? (analyze "svegliata")))))

 (deftest present-irregular
   (let [result (first (take 1 (generate {:synsem {:subcat '()


Added max-distance test

Added max-distance test

--- test/trumpet_server/domain/trumpeter_trumpet_test.clj
+++ test/trumpet_server/domain/trumpeter_trumpet_test.clj
@@ -16,7 +16,7 @@
       ; When
       (trumpet trumpeter1 {:targets     [trumpeter1 trumpeter2 trumpeter3 trumpeter4 trumpeter5 trumpeter6]
                            :broadcaster (fn [id message] (swap! messages-sent assoc id message))
-                           :trumpet "Hello World!"})
+                           :trumpet     "Hello World!"})

       ; Then
       (keys (deref messages-sent)) => (just (list 2 3 4) :in-any-order))
@@ -35,9 +35,28 @@
       ; When
       (trumpet trumpeter1 {:targets     [trumpeter1 trumpeter2 trumpeter3 trumpeter4 trumpeter5 trumpeter6]
                            :broadcaster (fn [id message] (swap! messages-sent assoc id message))
-                           :trumpet "Hello World!"})
+                           :trumpet     "Hello World!"})

       ; Then
       (def messages (vals (deref messages-sent)))
       (map #(:message %) messages) => (has every? #(= % "Hello World!"))
-      (map #(:distanceFromSource %) messages) => (has every? #(> % 0)))+      (map #(:distanceFromSource %) messages) => (has every? #(> % 0)))
+
+(fact "Send trumpet to all trumpeters execept self and those that are out-of-range when explicity specifying max distance"
+      ; Given
+      (def trumpeter1 (->Trumpeter 1, 55.583985, 12.957578)) ; self
+      (def trumpeter2 (->Trumpeter 2, 55.584126, 12.957406))
+      (def trumpeter3 (->Trumpeter 3, 55.58453, 12.957406))
+      (def trumpeter4 (->Trumpeter 4, 55.58533, 12.95864))
+      (def trumpeter5 (->Trumpeter 5, 55.59772, 12.97519))  ; out of range
+      (def trumpeter6 (->Trumpeter 6, 55.60519, 13.00334))  ; out of range
+
+      (def messages-sent (atom {}))
+
+      ; When
+      (trumpet trumpeter1 {:targets     [trumpeter1 trumpeter2 trumpeter3 trumpeter4 trumpeter5 trumpeter6]
+                           :broadcaster (fn [id message] (swap! messages-sent assoc id message))
+                           :trumpet     "Hello World!"
+                           :max-distance-meters 150})
+      ; Then
+      (keys (deref messages-sent)) => (just (list 2 3) :in-any-order))


remove password

remove password

--- test/cljam/t_common.clj
+++ test/cljam/t_common.clj
@@ -10,8 +10,7 @@
   {:resources [{:id "large.bam"
                 :url "ftp://ftp.broadinstitute.org/old/NA12878.BI.illumina.dup.sort.bam"
                 :sha1 "523780c7f39dfe97939124e92c8d34d0759c841f"
-                :auth {:user "gsapubftp-anonymous", :password "cljam-test"}
-                }
+                :auth {:user "gsapubftp-anonymous"}}
                ]})

 (defn prepare-cavy! [] (cavy/without-print (cavy/get!)) (cavy/verify))


Use the correct port for run-dmc [IMMUTANT-519]

--- web/src/immutant/web/internal/wunderboss.clj
+++ web/src/immutant/web/internal/wunderboss.clj
@@ -80,7 +80,7 @@
         options (u/kwargs-or-map->map options)
         url (format "http://%s:%s%s%s"
               (:host options (:host create-defaults))
-              (http-port options)
+              (http-port result)
               (context-path)
               (:path options (:path register-defaults)))]
     (try


decompile debug info to verify

decompile debug info to verify

--- test/insn/core_test.clj
+++ test/insn/core_test.clj
@@ -2,7 +2,8 @@
   (:require [insn.core :as core]
             [insn.op :as op]
             [clojure.test :refer :all])
-  (:import [java.lang.annotation Retention RetentionPolicy Target ElementType]
+  (:import [clojure.asm ClassReader ClassVisitor MethodVisitor Opcodes]
+           [java.lang.annotation Retention RetentionPolicy Target ElementType]
            [java.lang.invoke CallSite ConstantCallSite MethodHandle MethodHandles MethodHandles$Lookup MethodType]
            [javax.annotation.processing SupportedOptions]
            [javax.xml.ws WebServiceRef WebServiceRefs]
@@ -267,20 +268,33 @@
     (is (= 43 (.go obj 42)))))

 (deftest test-debug-info
-  (let [obj (-> {:methods [{:name "inc", :desc [:int :int]
-                            :emit [[:mark :BEGIN]
-                                   [:line-number 1 :BEGIN]
-                                   [:iload 1]
-                                   [:ldc 1]
-                                   [:iadd]
-                                   [:ireturn]
-                                   [:mark :END]
-                                   [:local-variable "this" :this :BEGIN :END 0]
-                                   [:local-variable "i" :int :BEGIN :END 1]]}]}
-                core/visit
-                #_(core/write (System/getProperty "java.io.tmpdir"))
-                core/new-instance)]
-    (is (= 43 (.inc obj 42)))))
+  (let [t (core/visit
+           {:methods [{:name "inc", :desc [:int :int]
+                       :emit [[:mark :BEGIN]
+                              [:line-number 1 :BEGIN]
+                              [:iload 1]
+                              [:ldc 1]
+                              [:iadd]
+                              [:ireturn]
+                              [:mark :END]
+                              [:local-variable "this" :this :BEGIN :END 0]
+                              [:local-variable "i" :int :BEGIN :END 1]]}]})
+        obj (core/new-instance t)
+
+        debug (volatile! {})
+        cv (proxy [ClassVisitor] [Opcodes/ASM4]
+             (visitMethod [api mname & args]
+               (when (= mname "inc")
+                 (proxy [MethodVisitor] [Opcodes/ASM4]
+                   (visitLineNumber [line & args]
+                     (vswap! debug update :lines (fnil conj []) line))
+                   (visitLocalVariable [vname & args]
+                     (vswap! debug update :vars (fnil conj []) vname))))))
+        _ (.accept (ClassReader. (:bytes t)) cv 0)]
+
+    (is (= 43 (.inc obj 42)))
+    (is (= [1] (:lines @debug)))
+    (is (= ["this" "i"] (:vars @debug)))))

 (deftest test-new-instance
   (let [put (fn [s]


Show 'Loading...' on uploads page'

Show 'Loading...' on uploads page'

--- src/braid/uploads_page/views/uploads_page.cljs
+++ src/braid/uploads_page/views/uploads_page.cljs
@@ -77,6 +77,9 @@
         error
         [:div.error error]

+        (nil? uploads)
+        [:p "Loading..."]
+
         (empty? uploads)
         [:p "No uploads in this group yet"]


Fix Disqus mangling

Fix Disqus mangling

--- src/cljs/daveconservatoire/site/ui/disqus.cljs
+++ src/cljs/daveconservatoire/site/ui/disqus.cljs
@@ -36,7 +36,7 @@

 (defn current-url [] js/window.location.href)

-(defn Disqus [] js/window.DISQUS)
+(defn Disqus [] (gobj/get js/window "DISQUS"))

 (defn start-thread [this]
   (go
@@ -52,7 +52,7 @@
                                  (str "#!newthread"))]
                      (gobj/extend (gobj/get t "page") props)
                      (gobj/set (gobj/get t "page") "url" url)))]
-      (js/window.DISQUS.reset (js-obj "reload" true "config" config)))))
+      (.reset (Disqus) (js-obj "reload" true "config" config)))))

 (om/defui ^:once DisqusThread
   Object


add headers to orthologue results download

--- src/cljs/gointermod/orthologresults/views.cljs
+++ src/cljs/gointermod/orthologresults/views.cljs
@@ -48,7 +48,9 @@
 (defn csv-body
   "returns results of the graph in csv string format for download"
   []
-  (let [results (re-frame/subscribe [:aggregate-results])]
+  (let [results (re-frame/subscribe [:aggregate-results])
+        headers (str "Organism,Original Gene,Ortholog,Biological process, Molecular function,Cellular component, Datasources\n")]
+    (str headers
     (reduce (fn [outer-str [organism organism-details] organisms]
       (str outer-str
         (reduce (fn [inner-str [ortholog ortholog-details] organism-details]
@@ -64,7 +66,7 @@
                "\"" "\n")
         ) "" organism-details))
     ) "" @results)
-))
+)))

 (defn orthologs []
@@ -76,7 +78,7 @@
         [:div
           [:header
             [:h2 "Orthologous Genes"]
-            ;[exportcsv/download-button (csv-body)]
+            [exportcsv/download-button (csv-body)]
            ]
           [:table.aggregate
             [aggregate-headers]


PCbO should now work correctly

PCbO should now work correctly

some tests are missing though.

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

--- src/conexp/contrib/algorithms/parallel_cbo.clj
+++ src/conexp/contrib/algorithms/parallel_cbo.clj
@@ -8,8 +8,10 @@

 (ns conexp.contrib.algorithms.parallel-cbo
   (:use conexp.main
-        conexp.contrib.exec)
-  (:use [clojure.string :only (split-lines)]))
+        conexp.contrib.exec
+        [conexp.io.util :only (tmpfile)])
+  (:use [clojure.string :only (split-lines split)]
+        [clojure.java.io :only (reader)]))

 (ns-doc "Defines an external binding to the program «pcbo» by Petr
 Krajca, Jan Outrata, and Vilem Vychodil, which can compute context
@@ -17,22 +19,47 @@

 ;;;

-(define-external-program pcbo
-  pcbo :threads :depth :min-support :input-file :fcalgs)
+(define-external-program pcbo-external
+  pcbo :threads :depth :min-support :input-file :fcalgs :output-file)
 (alter-meta! (var pcbo) assoc :private true)
+
+(defn- pcbo
+  "Runs pcbo."
+  [threads depth min-support context]
+  (let [output-file (.getAbsolutePath ^java.io.File (tmpfile))]
+    (pcbo-external (str "-P" threads) (str "-L" depth) (str "-S" (float (* min-support 100)))
+                   context output-file)
+    output-file))

 (defn- to-fcalgs-context
   "Transforms ctx to a context suitable for the :fcalgs context
   format, returns a vector [context object-vector attribute-vector]."
   [ctx]
-  [ctx [] []])
+  (let [object-vector    (vec (objects ctx)),
+        attribute-vector (vec (attributes ctx)),
+
+        new-objects      (range (count object-vector)),
+        new-attributes   (range (count attribute-vector)),
+        new-incidence    (set-of [g m] [g new-objects,
+                                        m new-attributes,
+                                        :when (contains? (incidence ctx)
+                                                         [(nth object-vector g)
+                                                          (nth attribute-vector m)])])]
+    [(make-context new-objects new-attributes new-incidence)
+     object-vector
+     attribute-vector]))

 (defn concept-intents-by-parallel-cbo
   "Computes the intents of context using parallel close-by-one (CbO)."
   [threads depth min-support context]
-  (let [[ctx obj-vec att-vec] (to-fcalgs-context context)]
-    (map #(read-string (str "#{" % "}"))
-         (split-lines (pcbo (str "-P" threads) (str "-L" depth) (str "-S" min-support) ctx)))))
+  (let [[ctx _ att-vec] (to-fcalgs-context context),
+        output-file     (pcbo threads depth min-support ctx),
+        intents         (line-seq (reader output-file)),
+        transform-back  #(set-of (nth att-vec (Integer/parseInt ^String x))
+                                 [x (split % #"\s+")])]
+    (if (= "" (first intents))
+      (cons #{} (map transform-back (rest intents)))
+      (map transform-back intents))))

 ;;;


Add test for non-string variables

Add test for non-string variables

--- test/uruk/core_test.clj
+++ test/uruk/core_test.clj
@@ -74,5 +74,14 @@
           (= opts
              (describe-content-creation-options (content-creation-options opts)))))))

+;;;;

-
+(deftest non-string-variables
+  (testing "Non-string variables passed to request object are not converted to strings"
+    (is (instance? com.marklogic.xcc.types.impl.DocumentImpl
+                   (-> (with-open [session (create-session db)]
+                         (.getVariables (#'uruk.core/request-obj (.newAdhocQuery session "hello world")
+                                                                 nil {:derp {:value "<foo/>"
+                                                                             :type :document}})))
+                       first
+                       .getValue)))))


adds enterprise conditionals

adds enterprise conditionals

--- frontend/components/shared.cljs
+++ frontend/components/shared.cljs
@@ -53,32 +53,45 @@
             enterprise? (:enterprise? opts)]
         (html
          [:form.contact-us
-          [:label {:for "name"} "Full name"]
           [:input {:value name
+                   :required true
                    :class (when loading? "disabled")
                    :type "text",
-                   :placeholder "Your Name",
                    :name "name"
                    :on-change #(do (clear-notice!) (om/set-state! owner [:name] (.. % -target -value)))}]
-          [:label {:for "email"} "Email address"]
+          [:label {:for "name" :alt "Enter name" :placeholder "Name"}]
+
           [:input {:value email,
                    :class (when loading? "disabled")
                    :type "email",
-                   :placeholder "Your email address",
                    :name "email"
+                   :required true
                    :on-change #(do (clear-notice!) (om/set-state! owner [:email] (.. % -target -value)))}]
-          [:label {:for "message"} "Message"]
-          [:textarea {:value message,
-                      :class (when loading? "disabled")
-                      :placeholder "Tell us what you're thinking"
-                      :on-change #(do (clear-notice!) (om/set-state! owner [:message] (.. % -target -value)))}]
+          [:label {:for "email" :alt "Enter email" :placeholder "Email"}]
+
+          (if enterprise?
+            (list
+             [:input {:required true
+                      :value message
+                      :on-change #(do (clear-notice!) (om/set-state! owner [:message] (.. % -target -value)))
+                      :type "text"}]
+             [:label {:alt "Enter phone (optional)", :placeholder "Phone"}])
+
+            (list
+             [:textarea {:value message,
+                         :class (when loading? "disabled")
+                         :required true
+                         :name "message"
+                         :on-change #(do (clear-notice!) (om/set-state! owner [:message] (.. % -target -value)))}]
+             [:label {:for "message" :placeholder "Tell us what you're thinking"}]))
+
           [:div.notice (when notice
                          [:div {:class (:type notice)}
                           (:message notice)])]
           [:button.btn-primary {:class (when loading? "disabled")
                                 :on-click #(do (if-not (and (seq name) (seq email))
                                                  (om/set-state! owner [:notice] {:type "error"
-                                                                                :message "Name, email, and message are all required."})
+                                                                                :message "Name and email are required."})
                                                  (do
                                                    (om/set-state! owner [:loading?] true)
                                                    (go (let [resp (<! (ajax/managed-form-post
@@ -87,7 +100,6 @@
                                                                                :email email
                                                                                :message message
                                                                                :enterprise enterprise?}))]
-                                                         (utils/inspect resp)
                                                          (if (= (:status resp) :success)
                                                            (om/update-state! owner (fn [s]
                                                                                {:name ""


for easier reloading

for easier reloading

--- frontend/src/leftover/core.cljs
+++ frontend/src/leftover/core.cljs
@@ -34,8 +34,12 @@
         (swap! app-state assoc :data cleaned)))
     (recur)))

-(om/root
-  ui/main-view
-  app-state
-  {:target (. js/document (getElementById "app"))
-   :shared {:actions actions}})
+(defn main
+  []
+  (om/root
+    ui/main-view
+    app-state
+    {:target (. js/document (getElementById "app"))
+     :shared {:actions actions}}))
+
+(main)


clear up logging in service resolvers

clear up logging in service resolvers


Added new test into test_core

Added new test into test_core

--- test/clouseau/test_core.clj
+++ test/clouseau/test_core.clj
@@ -68,6 +68,11 @@
     (testing "if the clouseau.core/get-port definition exists."
         (is (callable? 'clouseau.core/get-port))))

+(deftest test-get-and-check-port-existence
+    "Check that the clouseau.core/get-and-check-port definition exists."
+    (testing "if the clouseau.core/get-and-check-port definition exists."
+        (is (callable? 'clouseau.core/get-and-check-port))))
+
 (deftest test-cli-options-def-existence
     "Check that the clouseau.core/cli-options definition exists."
     (testing "if the hostname def exists"
@@ -94,7 +99,8 @@
     "Check the function clouseau.core/get-port."
     (testing "the function clouseau.core/get-port."
         (is (= (get-port nil)    "3000"))
-        (is (= (get-port "")    "3000"))
+        (is (= (get-port "")     "3000"))
         (is (= (get-port "1")    "1"))
+        (is (= (get-port 1)      "3000"))
         (is (= (get-port "3000") "3000"))))


Add a note to the preexisting gradient checker

--- cortex/src/cortex/util.cljc
+++ cortex/src/cortex/util.cljc
@@ -629,6 +629,8 @@
 ;; analytic gradient computed by the network and the numerical gradient, but it
 ;; would be nice if it just said, yes!  Need to figure out how close they should
 ;; be.  Maybe just check that each difference is < 0.01 ???
+;;
+;; You may want to check cortex.optimise.functions/check-gradient. -- Radon 07/16
 (defn gradient-check
   "Use a finite difference approximation of the derivative to verify
   that backpropagation and the derivatives of layers and activation functions are correct.


CMR-7456 Fixes virtual granule to source granule ur translatio for AST_L1T.031 (#1275)

--- virtual-product-app/src/cmr/virtual_product/data/source_to_virtual_mapping.clj
+++ virtual-product-app/src/cmr/virtual_product/data/source_to_virtual_mapping.clj
@@ -274,11 +274,16 @@
   "Compute source granule ur from the virtual granule ur. This function should be the inverse
   of generate-granule-ur."
   (fn [provider-id source-short-name virtual-short-name virtual-granule-ur]
-    [provider-id source-short-name]))
+    [(provider-alias->provider-id provider-id) source-short-name]))

 (defmethod compute-source-granule-ur :default
   [provider-id source-short-name virtual-short-name virtual-granule-ur]
   (str/replace-first virtual-granule-ur virtual-short-name source-short-name))
+
+(defmethod compute-source-granule-ur ["LPDAAC_ECS" "AST_L1A"]
+  [provider-id source-short-name virtual-short-name virtual-granule-ur]
+  (as-> (str/replace-first virtual-granule-ur virtual-short-name source-short-name) virtual-granule-ur
+        (str/replace-first virtual-granule-ur #"\.\d\d\d:" ".003:")))

 (defn- update-core-fields
   "Update the core set of fields in the source granule umm to create the virtual granule umm. These


Make the def label stand out by putting it on it's own line

--- test/govuk/blinken_test.clj
+++ test/govuk/blinken_test.clj
@@ -4,9 +4,11 @@
             [govuk.blinken :as blinken]))

-(def type-to-worker-fn {"icinga" (fn [url options] {:type "icinga"
-                                                   :url url
-                                                   :options options})})
+(def type-to-worker-fn
+  {"icinga" (fn [url options]
+              {:type "icinga"
+               :url url
+               :options options})})

 (deftest test-load-config
   (testing "with spec config"


Rename ns

Rename ns

--- test/icecap/schema_test.clj
+++ test/icecap/schema_test.clj
@@ -2,7 +2,7 @@
   (:require [icecap.schema :as is]
             [icecap.test-data :refer :all]
             [clojure.test :refer :all]
-            [schema.core :as s]
+            [schema.core :as sc]
             [icecap.handlers.core :refer [get-schema]]))

 (deftest plan-tests


Story ID: untangled-7 removed some duplication

--- src/untangled/client/impl/application.cljs
+++ src/untangled/client/impl/application.cljs
@@ -23,6 +23,11 @@
 ;; this is here so we can do testing (can mock core async stuff out of the way)
 (defn- enqueue [q v] (go (async/>! q v)))

+(defn real-send
+  "Do a properly-plumbed network send that strips ui attributes from the tx"
+  [net tx on-load on-error]
+  (net/send net (plumbing/strip-ui tx) on-load on-error))
+
 (defn enqueue-mutations [{:keys [queue] :as app} remote-tx-map cb]
   (let [full-remote-transaction (:remote remote-tx-map)
         fallback (fallback-handler app full-remote-transaction)
@@ -34,13 +39,11 @@
     (when has-mutations?
       (enqueue queue payload))))

-(defn raw-send []
-  )
 (defn enqueue-reads [{:keys [queue reconciler networking]}]
   (let [parallel-payload (f/mark-parallel-loading reconciler)
         fetch-payload (f/mark-loading reconciler)]
     (doseq [{:keys [query on-load on-error]} parallel-payload]
-      (net/send networking (plumbing/strip-ui query) on-load on-error))
+      (real-send networking query on-load on-error))
     (when fetch-payload
       (enqueue queue (assoc fetch-payload :networking networking)))))

@@ -62,7 +65,7 @@
         (let [{:keys [query on-load on-error]} payload
               on-load (make-process-response on-load)
               on-error (make-process-response on-error)]
-          (net/send networking (plumbing/strip-ui query) on-load on-error))
+          (real-send networking query on-load on-error))
         (async/<! response-channel)                         ; expect to block
         (recur (async/<! queue))))))


enable print to console in core

enable print to console in core

--- Clojure-Websockets/MainApp/src/cljs/birdwatch/core.cljs
+++ Clojure-Websockets/MainApp/src/cljs/birdwatch/core.cljs
@@ -10,6 +10,8 @@
             [birdwatch.stats.timeseries :as ts]
             [birdwatch.stats.wordcount :as wc]
             [cljs.core.async :as async :refer [chan pub]]))
+
+(enable-console-print!)

 ;;;; Main file of the BirdWatch client-side application.


Flush outbox on autojoin.

Flush outbox on autojoin.

--- src/onyx/log/commands/prepare_join_cluster.clj
+++ src/onyx/log/commands/prepare_join_cluster.clj
@@ -36,15 +36,17 @@

 (defmethod extensions/fire-side-effects! :prepare-join-cluster
   [{:keys [args]} old new diff state]
-  (when (= (:id state) (:observer diff))
-    (let [ch (chan 1)]
-      (extensions/on-delete (:log state) (:subject diff) ch)
-      (go (when (<! ch)
-            (extensions/write-log-entry
-             (:log state)
-             {:fn :leave-cluster :args {:id (:subject diff)}}))
-          (close! ch))
-      (assoc state :watch-ch ch))))
+  (cond (= (:id state) (:observer diff))
+        (let [ch (chan 1)]
+          (extensions/on-delete (:log state) (:subject diff) ch)
+          (go (when (<! ch)
+                (extensions/write-log-entry
+                 (:log state)
+                 {:fn :leave-cluster :args {:id (:subject diff)}}))
+              (close! ch))
+          (assoc state :watch-ch ch))
+        (= (:id state) (:instant-join diff))
+        (extensions/flush-outbox (:outbox state))))

 (defmethod extensions/reactions :prepare-join-cluster
   [entry old new diff peer-args]


Fix message delivery status alignment on desktop

--- src/status_im/chat/styles/message/message.cljs
+++ src/status_im/chat/styles/message/message.cljs
@@ -3,6 +3,7 @@
   (:require [status-im.ui.components.styles :as styles]
             [status-im.chat.styles.photos :as photos]
             [status-im.ui.components.colors :as colors]
+            [status-im.utils.platform :as platform]
             [status-im.constants :as constants]))

 (defstyle style-message-text
@@ -95,9 +96,9 @@
 (defn delivery-status [outgoing]
   (if outgoing
     {:align-self    :flex-end
-     :padding-right 8}
+     :padding-right (if platform/desktop? 24 8)}
     {:align-self    :flex-start
-     :padding-left  8}))
+     :padding-left  (if platform/desktop? 24 8)}))

 (def message-author
   {:width      photos/default-size