Update words.clj

Update words.clj

--- src/iyye/subcon/knowledge/words.clj
+++ src/iyye/subcon/knowledge/words.clj
@@ -18,39 +18,43 @@
   (:require
     [clojure.tools.logging :as log]
     [iyye.bios.ioframes :as ioframes]
-    [iyye.bios.persistence :as persistence]
+    [iyye.bios.persistence :as persistence]))
     ;[iyye.subcon.knowledge.relation :as relation]
-    ))

 (def dbg-IO (ref nil))

-(def action-words (ref {}))
-(def noun-words (ref {}))
-;(def types-words (ref []))
-;(def relations-words (ref []))
-;(def instances-words (ref []))
-;(def adjective-words (ref []))
-
-(defrecord Iyye_ModalPredicate [AccordingTo When Time Prob])
-(defrecord Iyye_Atom [Name Uname Builtin])
-(defrecord Iyye_Relation [atom Predicate Types Function PredicateFunction Data])
-(defrecord Iyye_Type [atom Relations])
-(defrecord Iyye_Instance [atom type])
-
-(def atoms-number (ref 0))
-(defn inc-atoms! []
-  (dosync (ref-set atoms-number (inc @atoms-number)))
-  @atoms-number)
-
-(defn create-iyye-atom [name & builtin]
-  (let [uname (str name (inc-atoms!))
+(def builtin-words (ref {}))
+
+(defrecord Iyye_ModalPredicate [AccordingTo When Time Prob ])
+(defrecord Iyye_Name [Name Uname Type Word2vec Tags])
+(defrecord Iyye_Type [name Relations toString])
+(defrecord Iyye_Verb [name Types Result Function Complexity])
+;(defrecord Iyye_Query [verb PredicateFunction])
+(defrecord Iyye_Relation [name Types Predicate Function PredicateFunction Data])
+(defrecord Iyye_Instance [name type])
+(defrecord Iyye_Error [bug toString])
+
+(defn pred-toString [pred] (pr-str ))
+
+(def names-number (ref 0))
+(defn inc-names! []
+  (dosync (ref-set names-number (inc @names-number)))
+  @names-number)
+
+(defn get-types [verb] (if (:Types verb)
+                         (:Types verb)
+                         (if (:verb verb)
+                           ())))
+
+(defn create-iyye-name [name type & builtin]
+  (let [uname (str name (inc-names!))
         b (if (nil? builtin) false (first builtin))
-        atom (->Iyye_Atom name uname b)]
+        atom (->Iyye_Name name uname type nil {})]
     atom))

 (defn create-iyye-type [Name & builtin]
-  (let [type-atom (create-iyye-atom Name builtin)
-        type (->Iyye_Type type-atom [])]
+  (let [type-atom (create-iyye-name Name "type" builtin)
+        type (->Iyye_Type type-atom (list) pr-str)]
     type))

 (defn create-iyye-type-from-db [t]
@@ -58,7 +62,7 @@
   (let [mykey #(keyword (str %1 %2))
         create-types #(clojure.string/split (t (mykey "Relation-Types-List" %1)) #"_")
         create-data #(hash-map (keyword (t (mykey "Relation-Data-List1" %1))) ; Only 2 now
-                       (t (mykey "Relation-Data-List2" %1)))
+                               (t (mykey "Relation-Data-List2" %1)))
         relations-list
         (loop [rel-vec []
                num 0]
@@ -66,36 +70,47 @@
             rel-vec
             (let [rel-uname (t (mykey "Relation-uname" num))]
               (recur (conj rel-vec
-                         (->Iyye_Relation
-                           (->Iyye_Atom (t (mykey "Relation-name" num))
-                                        rel-uname
-                                        false)
-                           (->Iyye_ModalPredicate
-                             (t (mykey "Relation-AccordingTo" num))
-                             (t (mykey "Relation-When" num))
-                             (t (mykey "Relation-Time" num))
-                             (t (mykey "Relation-Prob" num)))
-                           (create-types num)
-                           (:Function (@action-words (t (mykey "Relation-uname" num))))
-                           (:PredicateFunction (@action-words (t (mykey "Relation-uname" num))))
-                           (create-data num)))
-                   (inc num)))))]
-    (->Iyye_Type (->Iyye_Atom (:Name t) (:Uname t) false) relations-list)))
+                           (->Iyye_Relation
+                             (->Iyye_Name (t (mykey "Relation-name" num))
+                                          rel-uname
+                                          "relation"
+                                          nil {})
+                             []
+                             (->Iyye_ModalPredicate
+                               (t (mykey "Relation-AccordingTo" num))
+                               (t (mykey "Relation-When" num))
+                               (t (mykey "Relation-Time" num))
+                               (t (mykey "Relation-Prob" num)))
+                             nil
+                             ;  (create-types num)
+                             ; (:Function (@verb-words (t (mykey "Relation-uname" num))))
+                             (:PredicateFunction (@builtin-words (t (mykey "Relation-uname" num))))
+                             (create-data num)))
+                     (inc num)))))]
+    (->Iyye_Type (->Iyye_Name (:Name t) (:Uname t) "type" nil {}) relations-list str)))
+
+(defn create-iyye-verb [Name Types Result Function & builtin]
+  (let [action-atom (create-iyye-type Name "verb" builtin)
+        relation (->Iyye_Verb action-atom Types Result Function [])]
+    relation))

 (defn create-iyye-relation [Name Predicate Types Function PredicateFunction & builtin]
-  (let [action-atom (create-iyye-atom Name builtin)
-        relation (->Iyye_Relation action-atom Predicate Types Function PredicateFunction [])]
+  (let [action-atom (create-iyye-name Name "relation" builtin)
+        relation (->Iyye_Relation action-atom Types Predicate Function PredicateFunction [])]
     relation))

 (def time-start (persistence/local-time-to-string))
+
 (defn get-supertypes [atype]
-  "gets types: self, type, immidiate parents"               ; FIXME Yumzia:0 get all parents
+  "gets types: self, type, immediate parents"               ; FIXME Yumzia:0 get all parents
   (if-not (:UNKNOWN atype)
-    (let [rels (:Relations atype)]
-      (conj (for [supertype rels :when (:super (:Data supertype))]
-              {:Name (:super (:Data supertype)) :Predicate (:Predicate supertype)})
-              {:Name "type" :Predicate (->Iyye_ModalPredicate :IYE :AXIOM time-start :ALWAYS)}
-              {:Name (:Name (:atom atype)) :Predicate (->Iyye_ModalPredicate :IYE :AXIOM time-start :ALWAYS)}))
+    (if-not (and (= "type" (:Name (:name atype))) (not= "relation" (:Type (:name atype))))
+      (let [rels (:Relations atype)]
+       (conj (for [supertype rels :when (:super (:Data supertype))]
+                {:Name (:super (:Data supertype)) :Predicate (:Predicate supertype)})
+             {:Name (:Type (:name atype)) :Predicate (->Iyye_ModalPredicate :IYE :AXIOM time-start :ALWAYS)}
+             {:Name (:Name (:name atype)) :Predicate (->Iyye_ModalPredicate :IYE :AXIOM time-start :ALWAYS)}))
+      (list {:Name "type" :Predicate (->Iyye_ModalPredicate :IYE :AXIOM time-start :ALWAYS)}))
     {:UNKNOWN (:UNKNOWN atype)}))

 (defn create-iyye-instance [values])
@@ -118,23 +133,23 @@

 (defn save-iyye-type-to-db [type]
   (let [types-list-str (fn [types]
-          (reduce #(str %1 "_" %2) types))
+                         (reduce #(str %1 "_" %2) types))
         rel-key (fn [name ind]
-          (keyword (str name ind)))
+                  (keyword (str name ind)))
         get-rel
         (fn [ind rel]
-          {(rel-key "Relation-name" ind) (:Name (:atom rel))
-             (rel-key "Relation-uname" ind) (:Uname (:atom rel))
-            (rel-key "Relation-AccordingTo" ind) (:AccordingTo (:Predicate rel))
-            (rel-key "Relation-When" ind) (:When (:Predicate rel))
-            (rel-key "Relation-Time" ind) (:Time (:Predicate rel))
-             (rel-key "Relation-Prob" ind) (:Prob (:Predicate rel))
-             (rel-key "Relation-Types-List" ind) (types-list-str (:Types rel))
-           (rel-key "Relation-Data-List1" ind) (types-list-str (map name (keys (:Data rel))))
-               (rel-key "Relation-Data-List2" ind) (types-list-str (vals (:Data rel)))
+          {(rel-key "Relation-name" ind)        (:Name (:name rel))
+           (rel-key "Relation-uname" ind)       (:Uname (:name rel))
+           (rel-key "Relation-AccordingTo" ind) (:AccordingTo (:Predicate rel))
+           (rel-key "Relation-When" ind)        (:When (:Predicate rel))
+           (rel-key "Relation-Time" ind)        (:Time (:Predicate rel))
+           (rel-key "Relation-Prob" ind)        (:Prob (:Predicate rel))
+           (rel-key "Relation-Types-List" ind)  (types-list-str (:Types rel))
+           (rel-key "Relation-Data-List1" ind)  (types-list-str (map name (keys (:Data rel))))
+           (rel-key "Relation-Data-List2" ind)  (types-list-str (vals (:Data rel)))
            })]
-    (let [write-type (reduce conj {:Uname (:Uname (:atom type))
-                                   :Name  (:Name (:atom type))}
+    (let [write-type (reduce conj {:Uname (:Uname (:name type))
+                                   :Name  (:Name (:name type))}
                              (map-indexed get-rel (:Relations type)))
           ]
       ; (when @dbg-IO (print-io-str @dbg-IO (pr-str "add list: " type ":::"
@@ -146,70 +161,82 @@
   )
 ;(persistence/write-noun-to-db (into {} type))

-
-(defn get-iyye-atoms [name builtins]
+(defn get-iyye-atoms [name mypred]
   "returns a list of found atoms with supplied name"
   (let [builtin-types
-        (for [word (vals @builtins) :when (= (:Name (:atom word)) name)] word)]
+        (for [word (vals @builtin-words) :when (= (mypred word) name)] word)]
     (if (empty? builtin-types) (list {:UNKNOWN name}) builtin-types)))

 (defn get-iyye-types [name]
-  (get-iyye-atoms name noun-words))
-
-(defn get-iyye-relations [name]
-  (get-iyye-atoms name action-words))
+  (get-iyye-atoms name #(:Name (:name %))))
+
+(defn get-iyye-verbs [name]
+  (get-iyye-atoms name #(:Name (:name (:name %)))))
+
+(defn get-iyye-words [name]
+  (let [types (get-iyye-types name)
+        verbs (get-iyye-verbs name)]
+    (if (:UNKNOWN (first types))
+      (if (:UNKNOWN (first verbs))
+        types
+        verbs)
+      (if (:UNKNOWN (first verbs))
+        types
+        (apply conj verbs types)))))

 (defn set-iyye-type! [type]
-  (let [uname (:Uname (:atom type))
-        builtin (:Builtin (:atom type))]
-      (do
-        (dosync (alter noun-words #(assoc % uname type)))
-        (if-not builtin
-          (save-iyye-type-to-db type)
-          (save-iyye-builtin-type-to-db type)))))
+  (let [uname (:Uname (:name type))
+        builtin (:Builtin (:name type))]
+    (do
+      (dosync (alter builtin-words #(assoc % uname type)))
+      (if-not builtin
+        (save-iyye-type-to-db type)
+        (save-iyye-builtin-type-to-db type)))))

 (defn check-params [action params]
-  (let [act-params (:Types action)]
-    (when (= (count params) (count act-params))
-      (let [params-types (map #(get-supertypes %) params)
-        ;   vec-params (vec (map #(:Name (:atom %)) params))
-            pairs (map vector act-params params-types)
-            ok (every? true? (for [cur pairs]
-                               (if (= :UNKNOWN (first cur))
-                                 (if (:UNKNOWN (second cur)) true false)
-                                 (some true?
-                                       (map #(= (first cur) %) (map :Name (second cur)))))))]
-    ok))))  ; FIXME Yumzya context aware compare
-
-(defn apply-relation [relation params]
-  (when (check-params relation params)
-    ((:Function relation) params)))
-
-(defn apply-query [relation params]
-  (when (check-params relation params)
-    ((:PredicateFunction relation) params)))
-
-(defn- run-action [cmd params IO func]
-  (let [actions-list (get-iyye-relations cmd)
-        params-list (apply concat (map get-iyye-types params))]
+  "true if params matches action, false other ways"
+  (let [act-params (:Types action)
+        check-params-count
+        (fn [p1 p2]
+          (if (= "*" (last p2))
+            (>= (count p1) (count p2))
+            (= (count p1) (count p2))))]
+    (when (check-params-count params act-params)
+      (let [params-types (map #(get-supertypes %) (flatten params))
+            act-params2 (take (count params-types) act-params)
+            ;   vec-params (vec (map #(:Name (:name %)) params))
+            pairs (map vector act-params2 params-types)
+            check-pair (fn [t check]
+                         (case t
+                             :UNKNOWN (= :UNKNOWN check)
+                             "*" true
+                             (some true?
+                                   (map #(= t %) (map :Name check)))))]
+        (every? true? (for [cur pairs] (check-pair (first cur) (flatten (second cur)))))))))    ; FIXME Yumzya context aware compare/tags
+
+; (defn apply-relation [relation params]
+; (when (check-params relation params)
+;  ((:Function relation) params)) )
+
+(defn run-action [cmd params IO]
+  (let [actions-list (get-iyye-verbs cmd)
+        params-list (if (map? (first params))               ; map? is a check for non-string but resolved type
+                      params (map get-iyye-words params))]
     (case (count actions-list)
-      0 (print-io-str IO (str "failed to parse: no matching action to " cmd))
-      1 (let [action (first actions-list)
-              result (func action params-list)]
-          (if result
-            (print-io-str IO result)))
+      0 (->Iyye_Error (str "failed to parse: no matching action to " cmd) pr-str)
+      1 (let [action (first actions-list)]
+          (if (check-params action params-list)
+            ((:Function action) params-list)
+            (->Iyye_Error (pr-str "Params invalid for " cmd " : " params) pr-str)))
       (let [matching-actions
             (for [action actions-list :when (check-params action params-list)] action)]
-        (if (empty? matching-actions)
-          (print-io-str IO (pr-str "Cant find " cmd " " params))
-          (let [result (func (first matching-actions) params-list)]
-            (if result
-              (print-io-str IO result)
-              (print-io-str IO "False"))))))))
-
+        (case (count matching-actions)
+          0 (->Iyye_Error (pr-str "Cant find " cmd " " params) pr-str)
+          1 ((:Function (first matching-actions)) params-list)
+          (->Iyye_Error (pr-str "Too many actions " cmd " " params) pr-str))))))

 (defn action [cmd params IO]
-  (when (not @dbg-IO) (dosync (ref-set dbg-IO IO)))
-  (if (= \? (last cmd))
-    (run-action (subs cmd 0 (dec (count cmd))) params IO apply-query)
-    (run-action cmd params IO apply-relation)))
+  "Params are either text or objects from previous evaluations"
+  (when (not @dbg-IO) (dosync (ref-set dbg-IO IO)))         ; set debug
+  ; (print-io-str @dbg-IO (str "cmd: " cmd "::" (pr-str params)) )
+  (run-action cmd params IO))


Fix typo in comment in user.clj

Fix typo in comment in user.clj

--- src/leiningen/new/figwheel/user.clj
+++ src/leiningen/new/figwheel/user.clj
@@ -22,7 +22,7 @@
 (defn fig-start
   "This starts the figwheel server and watch based auto-compiler."
   []
-  ;; this call will only work are long as your :cljsbuild and
+  ;; this call will only work as long as your :cljsbuild and
   ;; :figwheel configurations are at the top level of your project.clj
   ;; and are not spread across different lein profiles


for ALL on maps, interpret transformed key value pair of < size 2 as removal

--- src/clj/com/rpl/specter/navs.cljc
+++ src/clj/com/rpl/specter/navs.cljc
@@ -39,11 +39,14 @@
 (defprotocol AllTransformProtocol
   (all-transform [structure next-fn]))

+(defn void-transformed-kv-pair? [newkv]
+  (or (identical? newkv i/NONE) (< (count newkv) 2)))
+
 (defn- non-transient-map-all-transform [structure next-fn empty-map]
   (reduce-kv
     (fn [m k v]
       (let [newkv (next-fn [k v])]
-        (if (identical? newkv i/NONE)
+        (if (void-transformed-kv-pair? newkv)
           m
           (assoc m (nth newkv 0) (nth newkv 1)))))

@@ -100,7 +103,7 @@
              (let [k (.next k-it)
                    v (.next v-it)
                    newkv (next-fn [k v])]
-               (if (identical? newkv i/NONE)
+               (if (void-transformed-kv-pair? newkv)
                 (do
                   (i/update-cell! none-cell inc)
                   (recur (+ i 2) j))
@@ -133,7 +136,7 @@
       (reduce-kv
         (fn [m k v]
           (let [newkv (next-fn [k v])]
-            (if (identical? newkv i/NONE)
+            (if (void-transformed-kv-pair? newkv)
               m
               (assoc! m (nth newkv 0) (nth newkv 1)))))

@@ -156,7 +159,7 @@
                (reduce-kv
                  (fn [m k v]
                    (let [newkv (next-fn [k v])]
-                     (if (identical? newkv i/NONE)
+                     (if (void-transformed-kv-pair? newkv)
                       m
                       (assoc m (nth newkv 0) (nth newkv 1)))))

@@ -175,8 +178,21 @@
   #?(:cljs
      (all-transform [structure next-fn]
        (let [empty-structure (empty structure)]
-         (if (and (list? empty-structure) (not (queue? empty-structure)))
+         (cond
+           (and (list? empty-structure) (not (queue? empty-structure)))
            (all-transform-list structure next-fn)
+
+           (map? structure)
+           (reduce-kv
+             (fn [m k v]
+               (let [newkv (next-fn [k v])]
+                 (if (void-transformed-kv-pair? newkv)
+                  m
+                  (assoc m (nth newkv 0) (nth newkv 1)))))
+                  empty-structure
+                  structure)
+
+           :else
            (into empty-structure
                  (comp (map next-fn) (filter not-NONE?))
                  structure))))))


adding the ability to select multiple months for the trends analysis.

--- src/clj/forma/trends/analysis.clj
+++ src/clj/forma/trends/analysis.clj
@@ -82,7 +82,7 @@
   [v]
   (range 1 (inc (count v))))

-(defn whizbang-general
+(defn long-trend-general
   "A general version of the original whizbang function, which extracted the time
   trend and the t-statistic on the time trend from a given time-series.  The more
   general function allows for more attributes to be extracted (e.g., total model
@@ -108,4 +108,15 @@
       (catch IllegalArgumentException e
         (repeat (count attributes) 0)))))

-(def whizbang (partial whizbang-general [:coefs :t-tests]))
+(def long-trend (partial long-trend-general [:coefs :t-tests]))
+
+(defn lengthening-ts
+  [base-ts start-index end-index]
+  (reverse
+   (into ()
+         (for [x (range start-index end-index)]
+           (take x base-ts)))))
+
+(defn whizbang
+  [t-series start-period end-period & cofactors]
+  (apply long-trend (lengthening-ts start-period end-period)))


started bfast analysis

started bfast analysis


continued to try to figure out how to recursively collect the max value of a sequence

--- src/clj/forma/trends/analysis.clj
+++ src/clj/forma/trends/analysis.clj
@@ -24,7 +24,8 @@
                         (range 1 (inc num-months)))))

 (defn singular?
-  "Check to see if the supplied matrix `X` is singular."
+  "Check to see if the supplied matrix `X` is singular. note that `X` has to
+  be square, n x n, where n > 1."
   [X]
   (<= (i/det X) 0))

@@ -60,6 +61,8 @@
        (windowed-apply ols-coefficient long-block)
        (windowed-apply average window)
        (reduce min)))
+
+

 ;; WHIZBANG

@@ -116,12 +119,25 @@
     (subvec base-vec 0 x)))

 (defn whizbang
-  [t-series start-period end-period & cofactors]
-  (map (partial lengthening-ts start-period end-period) (apply vector t-series cofactors))
-  #_(map long-trend
-       (map (partial lengthening-ts start-period end-period)
-            (apply vector t-series cofactors))))
+  [t-series start-pd end-pd & cofactors]
+  {:pre [(vector? t-series)]}
+  (let [all-ts (apply vector t-series cofactors)]
+    (->> all-ts
+         (map (partial lengthening-ts start-pd end-pd))
+         (apply map long-trend))))
+
+(defn test-vec
+  [ts & cof]
+  (apply vector ts cof))
+
+(defn test-count
+  [v1 v2] (+ (count v1)
+             (count v2)))
+
+(let [coll (test-vec ndvi rain)]
+  (->> coll
+       (map (partial split-at 10))
+       (apply map test-count)))

-


benchmarks

benchmarks

--- src/cljs/triboard/logic/move.cljs
+++ src/cljs/triboard/logic/move.cljs
@@ -32,7 +32,7 @@
   (or (nil? cell) (= cell :empty) (= cell :wall)))

 (defn- walk-dir
-  [[dx dy] [x y]]
+  [[x y] [dx dy]]
   [(+ x dx) (+ y dy)])

 (defn- available-cells-by-dir
@@ -105,3 +105,14 @@
 (defn apply-transition
   [board transition]
   (reduce apply-conversion board transition))
+
+#_(defn benchmarks
+  []
+  (let [b (board/new-board)]
+    (time (dotimes [i 10]
+            (all-transitions b)
+            ))
+    (time (dotimes [i 10]
+            (doall (map #(apply-transition b %) (all-transitions b)))
+            ))
+    ))


Changed :ident property of services to :name

That is a real world for one, is more intelligible, and just so happens
to be compatible with the search tool.

--- src/clojure/staircase/handler.clj
+++ src/clojure/staircase/handler.clj
@@ -237,7 +237,7 @@
             (GET "/" []
                  (locking services ;; Not very happy about this - is there some better way to avoid this bottle-neck?
                   (let [user-services (get-all services)
-                        configured-services (->> config :services (map (fn [[k v]] {:root v :ident k})))]
+                        configured-services (->> config :services (map (fn [[k v]] {:root v :name k})))]
                     (info "USER SERVICES" (count user-services) "CONF SERVICES" (count configured-services))
                     (response (vec (map ensure-token (left-outer-join configured-services user-services :root :root)))))))
             (context "/:ident" [ident]
@@ -246,7 +246,7 @@
                             (let [ident (real-id ident)
                                   uri (get-in config [:services ident])
                                   user-services (get-where services [:= :root uri])
-                                  service (-> (left-outer-join [{:root uri :ident ident}]
+                                  service (-> (left-outer-join [{:root uri :name ident}]
                                                               user-services
                                                               :root
                                                               :root)


tuning some of the model values

tuning some of the model values

--- src/main/clj/emotions_demo/core.clj
+++ src/main/clj/emotions_demo/core.clj
@@ -46,7 +46,7 @@
     :learning-window 30000}
    {:id :saf-bored :name "bored" :layer :safety
     :valence -0.1 :arousal -0.4
-    :desire 0.0 :decay-rate 0.02 :max-delta 0.3
+    :desire 0.0 :decay-rate 0.01 :max-delta 0.3
     :learning-window (* 5 60 1000)}
    {:id :saf-delight :name "delight" :layer :safety
     :valence 0.7 :arousal 0.7
@@ -54,11 +54,11 @@
     :learning-window 60000}
    {:id :saf-playful :name "playful" :layer :safety
     :valence 0.6 :arousal 0.9
-    :desire 0.0 :decay-rate 0.01 :max-delta 0.3
+    :desire 0.0 :decay-rate 0.005 :max-delta 0.3
     :learning-window (* 30 60 1000)}
    {:id :soc-lonely :name "lonely" :layer :social
     :valence -0.6 :arousal -0.6
-    :desire 0.0 :decay-rate 0.01 :max-delta 0.3
+    :desire 0.0 :decay-rate 0.005 :max-delta 0.3
     :learning-window (* 60 60 1000)}
    ])

@@ -99,7 +99,7 @@
     :satisfaction-vector {:phys-anger 0.0
                           :phys-hunger 0.0
                           :phys-fear 0.1
-                          :saf-bored -0.25
+                          :saf-bored -0.5
                           :saf-delight -0.4
                           :saf-playful -0.1
                           :soc-lonely -0.2}}
@@ -108,8 +108,8 @@
     :other-agents #{:steve_ballmer}
     :satisfaction-vector {:phys-anger 0.1
                           :phys-hunger 0.0
-                          :phys-fear 0.4
-                          :saf-bored -0.1
+                          :phys-fear 0.8
+                          :saf-bored -0.5
                           :saf-delight 0.0
                           :saf-playful -0.1
                           :soc-lonely -0.1}}
@@ -119,8 +119,8 @@
     :satisfaction-vector {:phys-anger 0.0
                           :phys-hunger 0.0
                           :phys-fear -0.2
-                          :saf-bored -0.25
-                          :saf-delight -0.5
+                          :saf-bored -0.5
+                          :saf-delight -0.6
                           :saf-playful -0.2
                           :soc-lonely -0.3}}
    })
@@ -274,9 +274,12 @@

 (defn anger-reaction-percept
   [done-signal]
-  {:name "Got angry" :satisfaction-vector
-   {:phys-anger -0.5
-    :saf-bored -0.3}})
+  {:name "Got angry"
+   :satisfaction-vector {:phys-anger -0.5
+                         :saf-bored -0.3}
+   :timestamp (t/now)
+   :locations @location
+   :other-agents #{}})

 (defn anger-management
   [robot percept-chan]
@@ -296,9 +299,12 @@

 (defn lonely-reaction-percept
   [done-signal]
-  {:name "Very lonely" :satisfaction-vector
-   {:soc-lonely -0.4
-    :saf-bored 0.1}})
+  {:name "Very lonely"
+   :satisfaction-vector {:soc-lonely -0.4
+                         :saf-bored 0.1}
+   :timestamp (t/now)
+   :locations @location
+   :other-agents #{}})

 (defn loneliness-management
   [robot percept-chan]
@@ -320,9 +326,12 @@

 (defn bored-reaction-percept
   [done-signal]
-  {:name "Bored" :satisfaction-vector
-   {:soc-lonely 0.05
-    :saf-bored -0.1}})
+  {:name "Bored"
+   :satisfaction-vector {:soc-lonely 0.05
+                         :saf-bored -0.1}
+   :timestamp (t/now)
+   :locations @location
+   :other-agents #{}})

 (defn react-scared?
   [state]
@@ -334,9 +343,12 @@

 (defn fear-reaction-percept
   [done-signal]
-  {:name "Got scared" :satisfaction-vector
-   {:phys-fear -0.2
-    :saf-bored -0.5}})
+  {:name "Got scared"
+   :satisfaction-vector {:phys-fear -0.2
+                         :saf-bored -0.5}
+   :timestamp (t/now)
+   :locations @location
+   :other-agents #{}})

 (defn fear-management
   [robot percept-chan]
@@ -355,9 +367,12 @@

 (defn delight-reaction-percept
   [done-signal]
-  {:name "Happy & Playful" :satisfaction-vector
-   {:saf-delight -0.4
-    :saf-playful -0.4}})
+  {:name "Happy & Playful"
+   :satisfaction-vector {:saf-delight -0.4
+                         :saf-playful -0.4}
+   :timestamp (t/now)
+   :locations @location
+   :other-agents #{}})

 (defn delight-management
   [robot percept-chan]
@@ -375,9 +390,12 @@
            (do
              (if (float= 1.0 value)
                (>! percept-chan
-                   {:name "Head touched" :satisfaction-vector
-                    {:phys-anger 0.2
-                     :saf-bored -0.3}}))
+                   {:name "Head touched"
+                    :satisfaction-vector {:phys-anger 0.2
+                                          :saf-bored -0.3}
+                    :timestamp (t/now)
+                    :locations @location
+                    :other-agents #{:unknown}}))
              (recur (<! event-chan)))))

 (defn back-head-touch-process
@@ -386,9 +404,12 @@
            (do
              (if (float= 1.0 value)
                (>! percept-chan
-                   {:name "Back Head touched" :satisfaction-vector
-                    {:phys-fear 1.0
-                     :saf-bored -0.3}}))
+                   {:name "Back Head touched"
+                    :satisfaction-vector {:phys-fear 1.0
+                                          :saf-bored -0.3}
+                    :timestamp (t/now)
+                    :locations @location
+                    :other-agents #{:unknown}}))
              (recur (<! event-chan)))))

 (defn hand-touch-process
@@ -397,10 +418,13 @@
            (do
              (if (float= 1.0 value)
                (>! percept-chan
-                   {:name "Hand touched" :satisfaction-vector
-                    {:phys-anger -0.2
-                     :saf-bored -0.2
-                     :soc-lonely -0.3}}))
+                   {:name "Hand touched"
+                    :satisfaction-vector {:phys-anger -0.2
+                                          :saf-bored -0.2
+                                          :soc-lonely -0.3}
+                    :timestamp (t/now)
+                    :locations @location
+                    :other-agents #{:unknown}}))
              (recur (<! event-chan)))))

 (defn foot-touch-process
@@ -409,10 +433,13 @@
            (do
              (if (float= 1.0 value)
                (>! percept-chan
-                   {:name "Foot touched" :satisfaction-vector
-                    {:phys-anger -0.1
-                     :saf-bored -0.2
-                     :saf-playful 0.2}}))
+                   {:name "Foot touched"
+                    :satisfaction-vector {:phys-anger -0.1
+                                          :saf-bored -0.2
+                                          :saf-playful 0.2}
+                    :timestamp (t/now)
+                    :locations @location
+                    :other-agents #{:unknown}}))
              (recur (<! event-chan)))))

 (defn face-detected-process


improve check-use-macros checking

improve check-use-macros checking

--- src/main/clojure/cljs/analyzer.cljc
+++ src/main/clojure/cljs/analyzer.cljc
@@ -1638,15 +1638,14 @@
           (error env
             (error-message :undeclared-ns-form {:type "var" :lib lib :sym sym})))))))

-;; TODO: better error handling here, we should be first checking if the ns
-;; was found
 (defn check-use-macros [use-macros env]
   (doseq [[sym lib] use-macros]
-    (when (nil? #?(:clj  (.findInternedVar ^clojure.lang.Namespace (find-ns lib) sym)
-                   :cljs (.findInternedVar (find-macros-ns lib) sym)))
-      (throw
-        (error env
-          (error-message :undeclared-ns-form {:type "macro" :lib lib :sym sym}))))))
+    (let [the-ns #?(:clj  (find-ns lib)
+                    :cljs (find-macros-ns lib))]
+      (when (or (nil? the-ns) (nil? (.findInternedVar ^clojure.lang.Namespace the-ns sym)))
+        (throw
+          (error env
+            (error-message :undeclared-ns-form {:type "macro" :lib lib :sym sym})))))))

 (defn parse-ns-error-msg [spec msg]
   (str msg "; offending spec: " (pr-str spec)))


Add global codeblock function for convenience

--- src/main/resources/sandbox-init.clj
+++ src/main/resources/sandbox-init.clj
@@ -1,12 +1,10 @@
 (do
+  ;; Imports and aliases
   (clojure.core/use '[clojure.core])
   (require '[clojure.string :as str])
   (require '[clojure.pprint :as pp])
   (require '[clojure.math.numeric-tower :as math])
-)
-
-(let [ res (->> "%s"
-                str/split-lines
-                (map (fn [x] (str "  \"" (str/replace x "=" "\": \"") \")))
-                (str/join ",\n")) ]
-  (str "{\n" res "\n}"))+
+  ;; Convenience functions
+  (defn codeblock [s & { type :type }] (str "```" type "\n" s "\n```"))
+)


Move the project-followed and unfollowed events into a hanlder

--- src-cljs/frontend/controllers/controls.cljs
+++ src-cljs/frontend/controllers/controls.cljs
@@ -73,16 +73,18 @@
 (defn button-ajax
   "An ajax/ajax wrapper that releases the current managed-button after the API
   request.  Exists to faciliate migration away from stateful-button."
-  [method url message channel & opts]
+  [method url message channel & {:keys [context params events] :as opts}]
   (let [uuid frontend.async/*uuid*
         c (chan)]
     (apply ajax/ajax method url message c opts)
     (go-loop []
-      (when-let [[_ status _ :as event] (<! c)]
-        (when (#{:success :failed} status)
-          (release-button! uuid status))
-        (>! channel event)
-        (recur)))))
+             (when-let [[_ status _ :as event] (<! c)]
+               (when-let [track-event (-> opts :events status)]
+                 (track-event))
+               (when (#{:success :failed} status)
+                 (release-button! uuid status))
+               (>! channel event)
+               (recur)))))

 ;; --- Navigation Multimethod Declarations ---

@@ -459,11 +461,11 @@
                  :follow-repo
                  api-ch
                  :params {:vcs-type (:vcs_type repo)}
-                 :context repo)
-    (analytics/track {:event-type :project-followed
-                      :current-state current-state
-                      :properties {:org org-name
-                                   :repo repo-name}})))
+                 :context repo
+                 :events {:success #(analytics/track {:event-type :project-followed
+                                                      :current-state current-state
+                                                      :properties {:org org-name
+                                                                   :repo repo-name}})})))

 (defmethod control-event :inaccessible-org-toggled
@@ -482,11 +484,11 @@
                  (gstring/format "/api/v1/project/%s/follow" project)
                  :follow-project
                  api-ch
-                 :context {:project-id project-id})
-    (analytics/track {:event-type :project-followed
-                      :current-state current-state
-                      :properties {:org org-name
-                                   :repo repo-name}})))
+                 :context {:project-id project-id}
+                 :events {:success #(analytics/track {:event-type :project-followed
+                                                     :current-state current-state
+                                                     :properties {:org org-name
+                                                                  :repo repo-name}})})))

 (defmethod post-control-event! :unfollowed-repo
@@ -502,11 +504,11 @@
                  :unfollow-repo
                  api-ch
                  :params {:vcs-type (:vcs_type repo)}
-                 :context repo)
-    (analytics/track {:event-type :project-unfollowed
-                      :current-state current-state
-                      :properties {:org org-name
-                                   :repo repo-name}})))
+                 :context repo
+                 :events {:success #(analytics/track {:event-type :project-unfollowed
+                                                      :current-state current-state
+                                                      :properties {:org org-name
+                                                                   :repo repo-name}})})))

 (defmethod post-control-event! :unfollowed-project
@@ -521,11 +523,11 @@
                  :unfollow-project
                  api-ch
                  :params {:vcs-type (:vcs_type repo)}
-                 :context {:project-id project-id})
-    (analytics/track {:event-type :project-unfollowed
-                      :current-state current-state
-                      :properties {:org org-name
-                                   :repo repo-name}})))
+                 :context {:project-id project-id}
+                 :events {:success #(analytics/track {:event-type :project-unfollowed
+                                                      :current-state current-state
+                                                      :properties {:org org-name
+                                                                   :repo repo-name}})})))

 (defmethod post-control-event! :stopped-building-project
   [target message {:keys [vcs-url project-id]} previous-state current-state]
@@ -538,11 +540,11 @@
                  (gstring/format "/api/v1/project/%s/enable" project)
                  :stop-building-project
                  api-ch
-                 :context {:project-id project-id})
-    (analytics/track {:event-type :project-builds-stopped
-                      :current-state current-state
-                      :properties {:org org-name
-                                   :repo repo-name}})))
+                 :context {:project-id project-id}
+                 :events {:success #(analytics/track {:event-type :project-builds-stopped
+                                                      :current-state current-state
+                                                      :properties {:org org-name
+                                                                   :repo repo-name}})})))

 ;; XXX: clean this up
 (defmethod post-control-event! :container-parent-scroll
@@ -732,10 +734,9 @@
 (defmethod post-control-event! :saved-ssh-key
   [target message {:keys [project-id ssh-key]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (button-ajax :post
-                 (api-path/project-ssh-key vcs-type project-name)
+                 (gstring/format "/api/v1/project/%s/ssh-key" project-name)
                  :save-ssh-key
                  api-ch
                  :params ssh-key
@@ -745,10 +746,9 @@
 (defmethod post-control-event! :deleted-ssh-key
   [target message {:keys [project-id hostname fingerprint]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (ajax/ajax :delete
-               (api-path/project-ssh-key vcs-type project-name)
+               (gstring/format "/api/v1/project/%s/ssh-key" project-name)
                :delete-ssh-key
                api-ch
                :params {:fingerprint fingerprint
@@ -778,10 +778,9 @@
 (defmethod post-control-event! :saved-project-api-token
   [target message {:keys [project-id api-token]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (button-ajax :post
-                 (api-path/project-tokens vcs-type project-name)
+                 (gstring/format "/api/v1/project/%s/token" project-name)
                  :save-project-api-token
                  api-ch
                  :params api-token
@@ -791,10 +790,9 @@
 (defmethod post-control-event! :deleted-project-api-token
   [target message {:keys [project-id token]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (ajax/ajax :delete
-               (api-path/project-token vcs-type project-name token)
+               (gstring/format "/api/v1/project/%s/token/%s" project-name token)
                :delete-project-api-token
                api-ch
                :context {:project-id project-id
@@ -804,10 +802,9 @@
 (defmethod post-control-event! :set-heroku-deploy-user
   [target message {:keys [project-id login]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (button-ajax :post
-                 (api-path/heroku-deploy-user vcs-type project-name)
+                 (gstring/format "/api/v1/project/%s/heroku-deploy-user" project-name)
                  :set-heroku-deploy-user
                  api-ch
                  :context {:project-id project-id
@@ -817,10 +814,9 @@
 (defmethod post-control-event! :removed-heroku-deploy-user
   [target message {:keys [project-id]} previous-state current-state]
   (let [project-name (vcs-url/project-name project-id)
-        vcs-type (vcs-url/vcs-type project-id)
         api-ch (get-in current-state [:comms :api])]
     (button-ajax :delete
-                 (api-path/heroku-deploy-user vcs-type project-name)
+                 (gstring/format "/api/v1/project/%s/heroku-deploy-user" project-name)
                  :remove-heroku-deploy-user
                  api-ch
                  :context {:project-id project-id})))
@@ -939,14 +935,13 @@
   [target message {:keys [project-id project-name key-type]} previous-state current-state]
   (let [uuid frontend.async/*uuid*
         api-ch (get-in current-state [:comms :api])
-        err-ch (get-in current-state [:comms :errors])
-        vcs-type (vcs-url/vcs-type project-id)]
+        err-ch (get-in current-state [:comms :errors])]
     (go (let [api-resp (<! (ajax/managed-ajax
                              :post
-                             (api-path/project-checkout-keys vcs-type project-name)
+                             (gstring/format "/api/v1/project/%s/checkout-key" project-name)
                              :params {:type key-type}))]
           (if (= :success (:status api-resp))
-            (let [api-resp (<! (ajax/managed-ajax :get (api-path/project-checkout-keys vcs-type project-name)))]
+            (let [api-resp (<! (ajax/managed-ajax :get (gstring/format "/api/v1/project/%s/checkout-key" project-name)))]
               (put! api-ch [:project-checkout-key (:status api-resp) (assoc api-resp :context {:project-name project-name})]))
             (put! err-ch [:api-error api-resp]))
           (release-button! uuid (:status api-resp))))))
@@ -955,13 +950,12 @@
   [target message {:keys [project-id project-name fingerprint]} previous-state current-state]
   (let [uuid frontend.async/*uuid*
         api-ch (get-in current-state [:comms :api])
-        err-ch (get-in current-state [:comms :errors])
-        vcs-type (vcs-url/vcs-type project-id)]
+        err-ch (get-in current-state [:comms :errors])]
     (go (let [api-resp (<! (ajax/managed-ajax
                              :delete
-                             (api-path/project-checkout-key vcs-type project-name fingerprint)))]
+                             (gstring/format "/api/v1/project/%s/checkout-key/%s" project-name fingerprint)))]
           (if (= :success (:status api-resp))
-            (let [api-resp (<! (ajax/managed-ajax :get (api-path/project-checkout-keys vcs-type project-name)))]
+            (let [api-resp (<! (ajax/managed-ajax :get (gstring/format "/api/v1/project/%s/checkout-key" project-name)))]
               (put! api-ch [:project-checkout-key (:status api-resp) (assoc api-resp :context {:project-name project-name})]))
             (put! err-ch [:api-error api-resp]))
           (release-button! uuid (:status api-resp))))))
@@ -1218,7 +1212,9 @@
            (put! api-ch [:org-plan (:status plan-api-result) (assoc plan-api-result :context {:org-name org-name})])
            (put! nav-ch [:navigate! {:path (routes/v1-org-settings {:org org-name
                                                                     :vcs_type vcs_type})
-                                     :replace-token? true}])))
+                                     :replace-token? true}])
+           (analytics/track {:event-type :plan-cancelled
+                             :current-state current-state})))
        (release-button! uuid (:status api-result))))))

 (defn track-and-redirect [event properties owner path]
@@ -1392,19 +1388,6 @@
   [_ _ {:keys [login scope]} _ {{api-ch :api} :comms}]
   (api/set-user-admin-scope login scope api-ch))

-(defmethod control-event :system-setting-changed
-  [_ _ {:keys [name]} state]
-  (update-in state state/system-settings-path
-             (fn [settings]
-               (mapv #(if (= name (:name %))
-                        (assoc % :updating true)
-                        %)
-                     settings))))
-
-(defmethod post-control-event! :system-setting-changed
-  [_ _ {:keys [name value]} _ {{api-ch :api} :comms}]
-  (api/set-system-setting name value api-ch))
-
 (defmethod control-event :insights-sorting-changed
   [_ _ {:keys [new-sorting]} state]
   (assoc-in state state/insights-sorting-path new-sorting))


email report modes are supposed to be 1=active, 2=disabled.

--- src/metabase/models/emailreport.clj
+++ src/metabase/models/emailreport.clj
@@ -13,9 +13,9 @@
 ;; ## Static Definitions

 (def modes
-  {:active   {:id 0
+  {:active   {:id 1
               :name "Active"}
-   :disabled {:id 1
+   :disabled {:id 2
               :name "Disabled"}})

 (def mode-kws


add support for previous >git diff src/kafka_clj/client.clj bad versions returning always nil

--- kafka-clj/src/kafka_clj/client.clj
+++ kafka-clj/src/kafka_clj/client.clj
@@ -62,7 +62,10 @@
   (if (and (-> state :conf :batch-fail-message-over-limit) (>= (count bts) ^long (-> state :conf :batch-byte-limit)))
     (throw (RuntimeException. (str "The message size [ " (count bts)  " ] is larger than the configured batch-byte-limit [ " (get-in state [:conf :batch-byte-limit]) "]")))
     (if (first (filter (partial healthy-partition-rc? state) (get @(:brokers-metadata-ref state) topic)))
-      (if-not (async/>!! (:msg-ch connector) (produce/message topic -1 bts)) (throw (RuntimeException. "The client has been shutdown")))
+      ;;checkin for boolean false here, aparently some code generated by clojure async in some versions and situations
+      ;;always return nil so it is not matter if its closed or not nil is returned, later versions return TRUE
+      (if (= (async/>!! (:msg-ch connector) (produce/message topic -1 bts)) Boolean/FALSE)
+        (throw (RuntimeException. "The client has been shutdown")))
       (throw (RuntimeException. (str "No healthy brokers available for topic " topic " " connector))))))

 (defn close [{{:keys [^AtomicLong activity-counter metadata-producers-ref producers-cache-ref scheduled-service retry-cache]} :state


Try to increate number of tests for filter-children.

--- evermind.core/test/evermind/domain/core_test.clj
+++ evermind.core/test/evermind/domain/core_test.clj
@@ -28,7 +28,7 @@

 (deftest test-filter-children
-         (is (tu/check 'evermind.domain.core/filter-children {::clojure.spec.test.check/opts {:num-tests 10}})))
+         (is (tu/check 'evermind.domain.core/filter-children {::clojure.spec.test.check/opts {:num-tests 20}})))

 (deftest test-create-mindmap


Add player from overtone.examples.getting-started.basic

--- src/overtone_workspace/grunbles.clj
+++ src/overtone_workspace/grunbles.clj
@@ -11,12 +11,31 @@
     (pan2 snd (sin-osc:kr 1))))

-(grumble :freq-mul 0.5)
-(grumble :freq-mul 0.75)
-(grumble :freq-mul 1)
-(grumble :freq-mul 1.5)
-(grumble :freq-mul 2)
-
-(ctl grumble :speed 3000)
+;; (grumble :freq-mul 0.5)
+;; (grumble :freq-mul 0.75)
+;; (grumble :freq-mul 1)
+;; (grumble :freq-mul 1.5)
+;; (grumble :freq-mul 2)
+;; (ctl grumble :speed 3000)

 (volume (/  32  127))
+
+(def metro (metronome 10))
+
+(defn player [beat notes]
+  (let [notes (if (empty? notes)
+                [4 8 2 1.5]
+                notes)]
+    (at (metro beat)
+        (grumble :freq-mul 0.25))
+    (at (metro beat)
+        (if (zero? (mod beat 5))
+          (grumble :freq-mul 1)))
+    (at (metro (+ 0.5 beat))
+        (if (zero? (mod beat 6))
+          (grumble :freq-mul (choose notes))))
+    (apply-by (metro (inc beat)) #'player (inc beat) (next notes) [])
+    ))
+
+;;(player (metro) [])
+;;(stop)


submit their name if they tab out, cancel if they Escape

--- src-cljs/frontend/components/aside.cljs
+++ src-cljs/frontend/components/aside.cljs
@@ -128,6 +128,13 @@
               (if editing-name?
                 [:form {:on-submit #(do (cast! :self-updated {:name new-name})
                                         (om/set-state! owner :editing-name? false)
+                                        false)
+                        :on-blur #(do (cast! :self-updated {:name new-name})
+                                      (om/set-state! owner :editing-name? false)
+                                      false)
+                        :on-key-down #(when (= "Escape" (utils/inspect (.-key %)))
+                                        (om/set-state! owner :editing-name? false)
+                                        (om/set-state! owner :new-name "")
                                         false)}
                  [:input {:type "text"
                           :ref "name-edit"


Don't do redundant work

Don't do redundant work

--- src-cljs/frontend/components/build.cljs
+++ src-cljs/frontend/components/build.cljs
@@ -274,7 +274,7 @@
             style {:position "fixed"}
             div (html
                  [:div.container-list-v2
-                  (if (-> state :container-index (> 0))
+                  (if (> previous-container-count 0)
                     [:a.container-selector-v2.page-container-pills
                      {:on-click #(om/set-state! owner :container-index (- container-index paging-width))}
                      [:div.nav-caret


Add implementation for create-partial-proc-fn with start-idx=0.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -127,6 +127,21 @@
                              (eval `(fn [~input-sym] ~fn-body)))]
     data-processing-fn))

+(defn create-partial-proc-fn
+  [dsl-expression start-idx end-idx]
+  (if (= 0 start-idx)
+    (create-proc-fn
+      {:output-type (:output-type dsl-expression)
+       :rules (subvec (:rules dsl-expression) start-idx end-idx)})))
+
 (defn create-proc-fns-vec
   [fn-mapping dsl-expression]
+;  (loop [v [(fn [in _] ((create-partial-proc-fn dsl-expression 0 (first fn-mapping))))]
+;         current-idx (first fn-mapping)
+;         remaining-mapping (rest fn-mapping)]
+;    (if (empty? remaining-mapping)
+;      (conj v )
+;      (recur
+;        (conj v )
+;        )))
   )


Improve docstring.

Improve docstring.

--- src/fhofherr/clj_db_util/core.clj
+++ src/fhofherr/clj_db_util/core.clj
@@ -86,7 +86,15 @@
                                 :to-db-name       identity})

 (defn connect-to-db
-  "Create a connection pool for the database identified by `url`, `user`, and `password`."
+  "Create a connection pool for the database identified by `url`, `user`, and `password`.
+  `db-opts` may contain one of the following keys to configure the database:
+
+  * `:db-resource-path`: path to the database resources on the classpath
+  * `:schema`: name of the schema managed by this database
+  * `:from-db-name`: function that converts column and table names from their db
+    internal representation to a presentation used by the program
+  * `:to-db-name`: function that converts column and table names from their representation
+    in the program to a db internal representation"
   {:added "0.2.0"}
   ([^String url ^String user ^String password]
     (connect-to-db url user password {}))


Clean up

Clean up

Including a common move function, useed by the specific move functions for ship, shot, asteroid, etc.

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -38,7 +38,7 @@
               (int \D) {:rotation turn-speed}
               (int \W) {:acceleration 1}
               (int \K) {:shoot true}
-              (int \R) {:reset true}
+              (int \R) {:repair true}
               (int \1) {:set-level 1}
               (int \2) {:set-level 2}
               (int \3) {:set-level 3}
@@ -132,6 +132,7 @@
     (map f pol))
   )

+(declare fill-polygon draw-polygon)

 (defn create-ship []
   {:type                   :ship
@@ -140,6 +141,7 @@
    :shape                  [[-0.143 1.0] [0.143 1.0] [0.429 0.429] [1.0 0.143] [1.0 -1.0] [0.429 -0.714]
                             [0.143 -1.0] [-0.143 -1.0] [-0.429 -0.714] [-1.0 -1.0] [-1.0 0.143] [-0.429 0.429]]
    :color                  (Color. 160 160 150)
+   :paint-method fill-polygon

    :cockpit-shape          [[-0.143 0.714] [0.143 0.714] [0.286 -0.143] [-0.286 -0.143]]
    :cockpit-color          (Color. 0 0 80)
@@ -167,6 +169,7 @@
     :size           shot-size
     :shape          [[-1.0 -5.0] [1.0 -5.0] [0.0 1.0]]
     :color          (Color. 250 50 10)
+    :paint-method fill-polygon

     :position       pos
     :speed          speed
@@ -203,6 +206,7 @@
       :size           (vary asteroid-size-variance size)
       :shape          shape
       :color          (Color. 250 240 (if debris? 150 20))
+      :paint-method draw-polygon

       :position       position
       :speed          speed
@@ -225,7 +229,7 @@
 (defn create-asteroids
   ([num size] (map create-asteroid (repeat num size)))
   ([num size pos speed] (map create-asteroid (repeat num size) (repeat num pos) (repeat num speed)))
-  #_(repeat num (create-asteroid size)))
+  #_(repeat num (create-asteroid size pos speed)))

 (defn out-of-bounds? [{[x y] :position size :size}]
   (or
@@ -236,14 +240,12 @@
     ))

 (defn collide? [{size1 :size [x1 y1] :position} {size2 :size [x2 y2] :position}]
-  (let [distance (fn [a b max]
-                   (let [d (Math/abs (- a b))]
-                     (if (< d (/ max 2)) d (- max d))))
-        x (distance x1 x2 width)
-        y (distance y1 y2 height)
+  (let [distance (fn [a b max] (let [d (Math/abs (- a b))] (if (< d (/ max 2)) d (- max d))))
+        delta-x (- x1 x2)
+        delta-y (- y1 y2)
         size (+ size1 size2)
         square #(* % %)]
-    (<= (+ (square x) (square y)) (square size))))
+    (<= (+ (square delta-x) (square delta-y)) (square size))))

 (defmulti check-collision
           (fn [obj1 obj2]
@@ -264,16 +266,14 @@
     (if (empty? coll)
       [obj1 coll-result]
       (let [[obj1 obj2] (check-collision obj1 (first coll))]
-        (recur obj1 (rest coll) (conj coll-result obj2)))
-      )))
+        (recur obj1 (rest coll) (conj coll-result obj2))))))

 (defmethod check-collision :seq-seq [coll1 coll2]
   (loop [coll1 coll1, coll2 coll2, coll1-result []]
     (if (empty? coll1)
       [coll1-result coll2]
       (let [[obj1 coll2] (check-collision (first coll1) coll2)]
-        (recur (rest coll1) coll2 (conj coll1-result obj1)))
-      )))
+        (recur (rest coll1) coll2 (conj coll1-result obj1))))))

 (defmulti handle-collision (fn [{type :type}]
                              (if (#{:ship :shot :asteroid} type)
@@ -297,8 +297,10 @@
       (create-asteroids 3 fragment-size position speed)
       asteroid)))

-(defmethod handle-collision :other [object]
-  object)
+(defmethod handle-collision :other [{hit? :hit? :as object}]
+  (if hit?
+    nil
+    object))

 (defn resolve-all-collision [{shots :shots :as ship} asteroids]
   (let [[ship asteroids] (check-collision ship asteroids)
@@ -314,9 +316,6 @@
                        (filter (comp not nil?)))]
     [(assoc ship :shots shots) asteroids]))

-(def win? (constantly false))
-(def lose? (constantly false))
-
 (defn win? [asteroids]
   (empty? asteroids))

@@ -327,14 +326,13 @@
 ; Actions
 ; ----------------------------------------------------------------------

-(defn reset-ship [ship]
+(defn repair-ship [ship]
   "Repair method while input keys f*** up at start-up"
   (assoc ship :rotation-speed 0
               :acceleration 0
               :shooting? false))

 (defn shoot [{:keys [shooting? shots millis-since-last-shot] :as ship}]
-  #_(prn "shoot" position size direction speed)
   (let [millis-since-last-shot (+ turn-millis millis-since-last-shot)
         shoots? (and shooting? (>= millis-since-last-shot shot-millis))
         shots (if shoots? (conj shots (create-shot ship)) shots)]
@@ -342,56 +340,44 @@
                 :shots shots))
   )

+(defn basic-move
+  ([{:keys [direction rotation-speed speed acceleration position] :as object} wrap?]
+   (let [direction (+ direction (* rotation-speed turn-millis 0.001))
+         speed (vec+vec speed (rotate-vec direction [0 (* acceleration turn-millis 0.001)]))
+         [x y] (vec+vec speed position)]
+     (assoc object :direction direction
+                   :speed speed
+                   :position (if wrap? [(mod x width) (mod y height)] [x y]))))
+  ([object] (basic-move object true)))
+
 (defmulti move (fn [object] (:type object)))

-(defmethod move :ship [{:keys [direction rotation-speed position speed acceleration shots] :as ship}]
-  (let [direction (+ direction (* rotation-speed turn-millis 0.001))
-        speed (vec+vec speed (rotate-vec direction [0 (* acceleration turn-millis 0.001)]))
-        [x y] (vec+vec speed position)
-        position [(mod x width) (mod y height)]
+(defmethod move :ship [{shots :shots :as ship}]
+  (let [ship (basic-move ship)
         shots (->> shots
                    (filter #(not (out-of-bounds? %)))
                    (map move))]
-    (assoc ship :direction direction
-                :speed speed
-                :position position
-                :shots shots)))
-
-(defmethod move :shot [{:keys [position speed] :as shot}]
-  (let [position (vec+vec speed position)]
-    (assoc shot :position position)))
-
-(defmethod move :asteroid [{:keys [direction rotation-speed position speed] :as asteroid}]
-  (let [direction (+ direction (* rotation-speed turn-millis 0.001))
-        [x y] (vec+vec speed position)
-        position [(mod x width) (mod y height)]]
-    (assoc asteroid :direction direction
-                    :position position)))
-
-(defmethod move :debris [{:keys [life-time direction rotation-speed position speed size] :as debris}]
+    (assoc ship :shots shots)))
+
+(defmethod move :shot [shot]
+  (basic-move shot false))
+
+(defmethod move :asteroid [asteroid]
+  (basic-move asteroid))
+
+(defmethod move :debris [{:keys [life-time size] :as debris}]
   (if (<= life-time 0)
     nil
-    (let [direction (+ direction (* rotation-speed turn-millis 0.001))
-          [x y] (vec+vec speed position)
-          position [(mod x width) (mod y height)]
+    (let [debris (basic-move debris)
           size (* size (- 1 (/ turn-millis life-time)))
           life-time (- life-time turn-millis)]
-      (assoc debris :direction direction
-                      :position position
-                      :size size
-                      :life-time life-time))))
+      (assoc debris :size size
+                    :life-time life-time))))

 (defn move-many [coll]
   (->> coll
        (map move)
        (filter (comp not nil?))))
-
-; Accelerating shots - not used right now
-#_(defmethod move :shot [{:keys [position speed direction acceleration] :as shot}]
-    (let [speed (vec+vec speed (rotate-vec direction [0 (* acceleration turn-millis 0.001)]))
-          position (vec+vec speed position)]
-      (assoc shot :speed speed
-                  :position position)))

 (defn turn [{:keys [rotation-speed] :as ship} rot]
   (assoc ship :rotation-speed (+ rotation-speed rot)))
@@ -421,12 +407,11 @@
       (ref-set asteroids asteroids*))))

 (defn do-action!
-  ([ship {:keys [rotation acceleration shoot reset] :as action} modifier]
+  ([ship {:keys [rotation acceleration shoot repair] :as action} modifier]
    (when rotation (dosync (alter ship turn (* modifier rotation))))
    (when acceleration (dosync (alter ship accelerate (* modifier acceleration))))
    (when shoot (dosync (alter ship toggle-shooting (> modifier 0))))
-   (when reset (dosync (alter ship reset-ship)))
-    #_(prn "update" dir modifier "speed:" (:rotation-speed @ship) "acceleration:" (:acceleration @ship)))
+   (when repair (dosync (alter ship repair-ship))))
   ([ship action]
    (do-action! ship action 1))
   )
@@ -460,30 +445,22 @@
   nil)

 (defmulti paint (fn [_ {type :type}]
-                  (cond
-                    (= type :ship) :ship
-                    (#{:shot} type) :fill
-                    (#{:asteroid :debris} type) :draw)))
-
-(defmethod paint :ship [g {:keys [shape life-colors life cockpit-shape cockpit-color shots] :as ship}]
+                  (if (= type :ship) :ship :other)))
+
+(defmethod paint :ship [g {:keys [shape life-colors life cockpit-shape cockpit-color shots paint-method] :as ship}]
   (doseq [shot shots]
     (paint g shot))
   (let [transformation (get-transformation-matrix ship point-size)
         polygon (polygon-to-screen shape transformation)
         color (get life-colors life)
         cockpit-polygon (polygon-to-screen cockpit-shape transformation)]
-    (fill-polygon g polygon color)
-    (fill-polygon g cockpit-polygon cockpit-color)))
-
-(defmethod paint :fill [g {:keys [shape color] :as object}]
+    (paint-method g polygon color)
+    (paint-method g cockpit-polygon cockpit-color)))
+
+(defmethod paint :other [g {:keys [shape color paint-method] :as object}]
   (let [transformation (get-transformation-matrix object point-size)
         polygon (polygon-to-screen shape transformation)]
-    (fill-polygon g polygon color)))
-
-(defmethod paint :draw [g {:keys [shape color] :as object}]
-  (let [transformation (get-transformation-matrix object point-size)
-        polygon (polygon-to-screen shape transformation)]
-    (draw-polygon g polygon color)))
+    (paint-method g polygon color)))

 ; ----------------------------------------------------------
 ; game


Added debris when asteroids are destroyed.

--- src/asteroids/core.clj
+++ src/asteroids/core.clj
@@ -16,13 +16,13 @@

 (def width 120)
 (def height 100)
-(def point-size 8)
+(def point-size 8.5)
 (def ship-size 1.5)
 (def ship-life 3)
 (def turn-speed 4)
 (def shot-size (/ ship-size 10))
-(def shot-speed 1.5)
-(def shot-millis 200)
+(def shot-speed 2.5)
+(def shot-millis 400)
 (def asteroids-start-number 1)
 (def asteroid-start-size 5)
 (def asteroid-min-size 1.2)
@@ -30,6 +30,7 @@
 (def asteroid-jaggedness 0.6)
 (def asteroid-max-speed 0.6)
 (def asteroid-max-rotation-speed 4)
+(def debris-life-millis 3000)
 (def turn-millis 40)

 (def actions {
@@ -38,6 +39,12 @@
               (int \W) {:acceleration 1}
               (int \K) {:shoot true}
               (int \R) {:reset true}
+              (int \1) {:set-level 1}
+              (int \2) {:set-level 2}
+              (int \3) {:set-level 3}
+              (int \4) {:set-level 4}
+              (int \5) {:set-level 5}
+              (int \6) {:set-level 6}
               })

 ; END: constants
@@ -178,7 +185,8 @@

 (defn create-asteroid
   ([size pos speed]
-   (let [direction (rand (* 2 (Math/PI)))
+   (let [size (vary asteroid-size-variance size)
+         direction (rand (* 2 (Math/PI)))
          dir-vec (rotate-vec direction [0 1])
          speed (vec+vec speed (num*vec (rand asteroid-max-speed) dir-vec))
          position (vec+vec pos (num*vec size dir-vec))
@@ -188,12 +196,13 @@
                       (let [angle (* 2 (Math/PI) (/ n num-points))
                             length (random (- 1 asteroid-jaggedness) (+ 1 (/ asteroid-jaggedness 2)))]
                         (rotate-vec angle [0 length])))
-         shape (map make-point (range num-points))]
-     {:type           :asteroid
+         shape (map make-point (range num-points))
+         debris? (< size asteroid-min-size)]
+     {:type           (if debris? :debris :asteroid)

       :size           (vary asteroid-size-variance size)
       :shape          shape
-      :color          (Color. 250 240 20)
+      :color          (Color. 250 240 (if debris? 150 20))

       :position       position
       :speed          speed
@@ -202,7 +211,9 @@
       :direction      direction
       :rotation-speed rotation-speed

-      :collidable?    true
+      :collidable?    (not debris?)
+
+      :life-time      (if debris? debris-life-millis nil)
       }))
   ([size pos]
    (create-asteroid size pos [0 0]))
@@ -264,7 +275,10 @@
         (recur (rest coll1) coll2 (conj coll1-result obj1)))
       )))

-(defmulti handle-collision (fn [object] (:type object)))
+(defmulti handle-collision (fn [{type :type}]
+                             (if (some #{:ship :shot :asteroid} type)
+                               type
+                               :other)))

 (defmethod handle-collision :ship [{:keys [hit? life] :as ship}]
   (if hit?
@@ -280,10 +294,11 @@
 (defmethod handle-collision :asteroid [{:keys [hit? size position speed] :as asteroid}]
   (let [fragment-size (/ size sqrt3)]
     (if hit?
-      (if (< fragment-size asteroid-min-size)
-        nil
-        (create-asteroids 3 fragment-size position speed))
+      (create-asteroids 3 fragment-size position speed)
       asteroid)))
+
+(defmethod handle-collision :other [object]
+  object)

 (defn resolve-all-collision [{shots :shots :as ship} asteroids]
   (let [[ship asteroids] (check-collision ship asteroids)
@@ -340,8 +355,7 @@
     (assoc ship :direction direction
                 :speed speed
                 :position position
-                :shots shots
-                )))
+                :shots shots)))

 (defmethod move :shot [{:keys [position speed] :as shot}]
   (let [position (vec+vec speed position)]
@@ -352,8 +366,25 @@
         [x y] (vec+vec speed position)
         position [(mod x width) (mod y height)]]
     (assoc asteroid :direction direction
-                    :position position
-                    )))
+                    :position position)))
+
+(defmethod move :debris [{:keys [life-time direction rotation-speed position speed size] :as debris}]
+  (if (<= life-time 0)
+    nil
+    (let [direction (+ direction (* rotation-speed turn-millis 0.001))
+          [x y] (vec+vec speed position)
+          position [(mod x width) (mod y height)]
+          size (* size (- 1 (/ turn-millis life-time)))
+          life-time (- life-time turn-millis)]
+      (assoc debris :direction direction
+                      :position position
+                      :size size
+                      :life-time life-time))))
+
+(defn move-many [coll]
+  (->> coll
+       (map move)
+       (filter (comp not nil?))))

 ; Accelerating shots - not used right now
 #_(defmethod move :shot [{:keys [position speed direction acceleration] :as shot}]
@@ -380,7 +411,7 @@
   (dosync
     (alter ship shoot)
     (alter ship move)
-    (alter asteroids (partial map move))
+    (alter asteroids move-many)
     nil))

 (defn resolve-collision! [ship asteroids]
@@ -428,7 +459,11 @@
       (.fillPolygon jpolygon)))
   nil)

-(defmulti paint (fn [_ object] (:type object)))
+(defmulti paint (fn [_ {type :type}]
+                  (cond
+                    (= type :ship) :ship
+                    (some #{:shot} type) :fill
+                    (some #{:asteroid :debris} type) :draw)))

 (defmethod paint :ship [g {:keys [shape life-colors life cockpit-shape cockpit-color shots] :as ship}]
   (doseq [shot shots]
@@ -440,12 +475,12 @@
     (fill-polygon g polygon color)
     (fill-polygon g cockpit-polygon cockpit-color)))

-(defmethod paint :shot [g {:keys [shape color] :as object}]
+(defmethod paint :fill [g {:keys [shape color] :as object}]
   (let [transformation (get-transformation-matrix object point-size)
         polygon (polygon-to-screen shape transformation)]
     (fill-polygon g polygon color)))

-(defmethod paint :asteroid [g {:keys [shape color] :as object}]
+(defmethod paint :draw [g {:keys [shape color] :as object}]
   (let [transformation (get-transformation-matrix object point-size)
         polygon (polygon-to-screen shape transformation)]
     (draw-polygon g polygon color)))


Add missing entry to css-dirs of figwheel config.

--- scripts/figwheel.clj
+++ scripts/figwheel.clj
@@ -2,7 +2,8 @@
          '[figwheel-sidecar.repl-api :as ra])

 (ra/start-figwheel!
-  {:figwheel-options {:css-dirs ["resources/public/css"]
+  {:figwheel-options {:css-dirs ["resources/public/css"
+                                 "resources/public/view/css"]
                       :server-port 3449
                       :server-ip   "0.0.0.0"}
    :build-ids ["main", "view"]


Parallel loading of datasets is now the default

--- src/cfpb/qu/loader.clj
+++ src/cfpb/qu/loader.clj
@@ -135,30 +135,6 @@
         (let [tabledef (table tables)
               indexes (get-indexes slices table)
               sources (:sources tabledef)
-              columns (:columns tabledef)]
-          (set-indexes table indexes)
-          (doseq [file sources]
-            (load-csv-file table (str dir "/" file) columns)))))))
-
-(defn pload-dataset
-  "Given the name of a dataset, load that dataset from disk into the
-database. The dataset must be under the datasets/ directory as a
-directory containing a definition.json and a set of CSV files."
-  [name]
-  (let [dir (str "datasets/" name)
-        definition (-> (str dir "/definition.json")
-                       io/resource
-                       slurp
-                       (json/parse-string true))
-        tables (:tables definition)
-        slices (:slices definition)]
-    (save-dataset-definition name definition)
-    (with-db (get-db name)
-      (doseq [table (keys tables)]
-        (coll/remove table)
-        (let [tabledef (table tables)
-              indexes (get-indexes slices table)
-              sources (:sources tabledef)
               columns (:columns tabledef)
               agents (map agent sources)]
           (set-indexes table indexes)


adding todo comments

adding todo comments

--- src/chat/server/db.clj
+++ src/chat/server/db.clj
@@ -643,6 +643,8 @@
 (defn search-threads-as
   [user-id text]
   ; TODO: add pagination
+  ; TODO: ability to search by tag?
+  ; TODO: consistent order for results
   (->> (d/q '[:find [?t-id ...]
               :in $ ?txt
               :where


Added templating dependency.

Added templating dependency.

--- search-app/project.clj
+++ search-app/project.clj
@@ -21,6 +21,7 @@
                  [org.clojure/tools.nrepl "0.2.12"]
                  [net.sf.saxon/Saxon-HE "9.7.0-7"]
                  [com.github.fge/json-schema-validator "2.2.6"]
+                 [selmer "1.10.7"]

                  ;; Temporary inclusion of libraries needed for swagger UI until the dev portal is
                  ;; done.


Add shorthand for alembic.still/load-project

--- roles/clojure/files/profiles.clj
+++ roles/clojure/files/profiles.clj
@@ -26,6 +26,7 @@
         :injections [(require 'spyscope.core)]

         :shorthand {. [^:lazy alembic.still/distill
+                       ^:lazy alembic.still/load-project
                        ^:lazy ^:macro alembic.still/lein
                        ^:lazy clojure.java.shell/sh
                        ^:lazy clojure.pprint/pprint


Remove unnecessary search page styles

Remove unnecessary search page styles

--- src/braid/search/ui/search_page_styles.cljs
+++ src/braid/search/ui/search_page_styles.cljs
@@ -1,56 +1,4 @@
-(ns braid.search.ui.search-page-styles
-  (:require
-    [garden.units :refer [rem em px]]
-    [braid.core.client.ui.styles.mixins :as mixins]
-    [braid.core.client.ui.styles.vars :as vars]))
-
-(def avatar-size (rem 4))
-
-(def card-style
-  [:>.card
-   {:margin-bottom "50%"
-    :max-width (rem 25)}
-
-   [:>.header
-    {:overflow "auto"}
-
-    [:>.pill.off
-     :>.pill.on
-     {:color [["white" "!important"]]}]
-
-    [:>.status
-     {:display "inline-block"
-      :margin-left (em 0.5)}
-     (mixins/mini-text)]
-
-    [:>.badges
-     {:display "inline-block"
-      :margin [[0 (em 0.5)]]}
-
-     [:>.admin::before
-      {:display "inline-block"
-       :-webkit-font-smoothing "antialiased"}
-      (mixins/fontawesome \uf0e3)]]
-
-    [:>img.avatar
-     {:margin-top (px 2)
-      :border-radius (px 3)
-      :width avatar-size
-      :height avatar-size
-      :background "white"
-      :float "left"}]]
-
-   [:>.local-time
-
-    [:&::after
-     (mixins/fontawesome \uf017)
-     {:margin-left (em 0.25)}]]])
+(ns braid.search.ui.search-page-styles)

 (def >search-page
-  [:>.page.search
-
-   [:>.threads
-    card-style]
-
-   [:>.content
-    card-style]])
+  [:>.page.search])


Add transition when playing countess

Add transition when playing countess

--- src/cljs/love_letter_cljs/handlers.cljs
+++ src/cljs/love_letter_cljs/handlers.cljs
@@ -60,6 +60,7 @@
      (condp = face
        :princess (set-phase d :resolution)
        :handmaid (set-phase d :resolution)
+       :countess (set-phase d :resolution)
        (set-phase d :target)))))

 (register-handler


Improve ident-value generator

Improve ident-value generator

--- src/com/wsscode/pathom/specs/query.cljc
+++ src/com/wsscode/pathom/specs/query.cljc
@@ -8,7 +8,10 @@

 (s/def ::property (s/with-gen keyword? #(s/gen #{:user/id :user/name :product/title :name :other})))
 (s/def ::special-property #{'*})
-(s/def ::ident-value (s/with-gen any? #(s/gen #{123 "123" [:a "b"]})))
+(s/def ::ident-value (s/with-gen any? #(gen/frequency [[10 (gen/return 123)]
+                                                       [10 (gen/return "123")]
+                                                       [2 (gen/return [:a "b"])]
+                                                       [1 (gen/return '_)]])))
 (s/def ::ident (s/with-gen
                  (s/and vector? (s/cat :ident ::property :value ::ident-value))
                  #(gen/let [s (s/gen (s/cat :ident ::property :value ::ident-value))]
@@ -101,8 +104,3 @@
     (s/or :query ::query
           :mutation ::mutation-tx)
     #(gen/frequency [[5 (s/gen ::query)] [1 (s/gen ::mutation-tx)]])))
-
-(comment
-  (gen/sample (s/gen ::join-key) 30)
-  (s/conform ::transaction [:a {'(:b {:foo "bar"}) [:c]}])
-  (s/conform ::transaction [:a '(:b {:foo "bar"})]))


Correct mismatch for Snøhvit

Correct mismatch for Snøhvit

--- src/clj_simple_chart/ncs/discovery_year.clj
+++ src/clj_simple_chart/ncs/discovery_year.clj
@@ -53,6 +53,7 @@
 (def data-parsed (->> data
                       (csvmap/read-string-columns numeric-columns)
                       (csvmap/number-or-throw-columns numeric-columns)
+                      (remove #(= "Included in other discovery" (:dscCurrentActivityStatus %)))
                       (group-by :fldName)
                       (vals)
                       (mapv de-duplicate)
@@ -65,6 +66,7 @@
        (first)
        (:dscDiscoveryYear)))

+; TODO: Consider adding more tests.
 (test/is (= 1969 (discovery-year "EKOFISK")))
 (test/is (= 1978 (discovery-year "GULLFAKS")))
 (test/is (= 1979 (discovery-year "TROLL")))


Remove not used imports from bcrypt hasher namespace.

--- src/clojure/buddy/crypto/hashers/bcrypt.clj
+++ src/clojure/buddy/crypto/hashers/bcrypt.clj
@@ -3,9 +3,7 @@
             [buddy.crypto.hashers.sha256 :refer [make-sha256]]
             [buddy.crypto.core :refer :all]
             [clojure.string :refer [split]])
-  (:import (buddy.impl BCrypt)
-           (javax.crypto.spec PBEKeySpec)
-           (javax.crypto SecretKeyFactory)))
+  (:import (buddy.impl BCrypt)))

 (defn make-bcrypt
   [password log-rouds]


* 4clojure: introduced a new version of func for identifying clojure data-structures * 4clojure: finished impl for power-sets function(using binary mapping approach)

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -2455,13 +2455,165 @@
              [x-set]
              (map (fn [bit-pair]
                     (apply hash-map (interleave (seq x-set) bit-pair)))
-                  (gen-bit-combinations (count x-set))))]
-    (map-to-vals x-set)
-    ))
-
+                  (gen-bit-combinations (count x-set))))
+          (filter-maps-by-val
+             [m-val m]
+              (map
+                 (fn [each-map]
+                   (reduce
+                      (fn [m entry]
+                        (if (zero? (val entry)) m
+                          (conj m entry)))
+                      {} each-map))
+                 m))]
+
+    ((comp (partial filter-maps-by-val 0)
+            map-to-vals) x-set)))
+
+;; demo:
 (assoc-entries #{:a :b :c})
+;; ({:c 1} {:b 1} {:b 1, :c 1} {:a 1} {:a 1, :c 1} {:a 1, :b 1} {:a 1, :b 1, :c 1} {})
+
+;; before applying the filter-maps-by-val func, we had this result:
 ;; {:c 1, :b 0, :a 0}
 ;; {:c 0, :b 1, :a 0}
 ;; {:c 1, :b 1, :a 0}
 ;; {:c 0, :b 0, :a 1} .....
-;; next step: filter 0-keys
+;; next step: filter 0-keys + map the keys into sets and we're done :)
+
+(defn filter-maps-by-val
+  [m-val m]
+  (map
+     (fn [each-map]
+       (reduce
+          (fn [m entry] (if (zero? (val entry)) m (conj m entry))) {} each-map)) m))
+
+;; demo:
+(filter-maps-by-val 0 [{:foo 0 :bar 1 :zip 0}])  ;; ({:bar 1}) --> cool :)
+(doc val) ;; -> returns the value in the map-entry
+
+;; next step: extract all the keys of each map into sets
+(defn keys-to-sets [maps]
+  (map (comp set keys) maps))
+
+;; demo:
+(keys-to-sets '({:c 1} {:b 1} {:b 1, :c 1} {:a 1} {:a 1, :c 1} {:a 1, :b 1} {:a 1, :b 1, :c 1} {}))
+;; (#{:c} #{:b} #{:c :b} #{:a} #{:c :a} #{:b :a} #{:c :b :a} #{})
+
+
+;; Note: (comp set keys) partial application can be translated into: (comp (partial apply hash-set) keys)
+;; but because [set] function transforms the given structure into a set is more less-to-write + readable
+(keys {:c 1 :a 1}) ;; (:c :a)
+
+;; final function which yields power-sets algorithm:
+(defn power-sets
+  [x-set]
+  (letfn [(left-padding-seq
+            [how-many padded]
+             (take how-many (lazy-cat (reverse (seq padded)) (repeat how-many 0))))
+          (to-binary
+             [x]
+             (map #(Integer/valueOf (str %)) (seq (Integer/toBinaryString x))))
+          (gen-bit-combinations
+             [x]
+             (let [bin-val (Math/pow 2 (count x-set))]
+                (map
+                   (fn [x] (->> x
+                               to-binary
+                               (left-padding-seq (count x-set))))
+                   (range 1 (inc bin-val)))))
+          (map-to-vals
+             [x-set]
+             (map (fn [bit-pair]
+                    (apply hash-map (interleave (seq x-set) bit-pair)))
+                  (gen-bit-combinations (count x-set))))
+          (filter-maps-by-val
+             [m-val m]
+              (map
+                 (fn [each-map]
+                   (reduce
+                      (fn [m entry]
+                        (if (zero? (val entry)) m
+                          (conj m entry)))
+                      {} each-map))
+                 m))
+          (keys-to-sets [maps]
+            (map (comp set keys) maps))]
+    ((comp
+         set
+         keys-to-sets
+        (partial filter-maps-by-val 0)
+         map-to-vals)
+       x-set)))
+
+;; demo....niceeeeeeeee:
+(power-sets #{:a :b :c})
+;; #{#{:c} #{:b} #{:c :b} #{:a} #{:c :a} #{:b :a} #{:c :b :a} #{}}
+
+;; Study function:
+(fn power-set [xs]
+	(letfn [(gen-next [xs acc]
+				(if (contains? acc xs)
+					(conj acc #{})
+					(recur xs (set (for [x xs ys acc] (conj ys x))))))]
+	(gen-next xs #{#{}})))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Black Box Testing
+;; Difficulty:	Medium
+;; Topics:	seqs testing
+;; Special Restrictions: class, instance?, type, vector?, sequential?, list?, seq?, map?, set?, getClass
+;; Clojure has many sequence types, which act in subtly different ways. The core functions
+;; typically convert them into a uniform "sequence" type and work with them that way,
+;; but it can be important to understand the behavioral and performance differences so that
+;; you know which kind is appropriate for your application.
+
+;; Write a function which takes a collection and returns one of :map, :set, :list, or :vector
+;; - describing the type of collection it was given.
+;; You won't be allowed to inspect their class or use the built-in predicates like list?
+;; - the point is to poke at them and understand their behavior.
+;; (= :map (__ {:a 1, :b 2}))
+;; (= :vector (__ [1 2 3 4 5 6]))
+(defn type-of
+  [some-struct]
+  (let [foo [:some :foo]
+        bar [:some :bar]
+        is-vector? #(and (identical? (last (conj % foo bar)) bar)   ;; lifo behavior from last
+                         (identical? (last (butlast (conj % foo bar))) foo)
+                         (nil? (get (conj % foo) :some)))           ;; associative by index
+        is-list? #(and (identical? (first (conj % foo bar foo)) foo)
+                       (identical? (second (conj % foo bar foo)) bar) ;; lifo behavior from first
+                       (nil? (get (conj % foo) :some)))
+        is-set? #(and (= 2 (count (conj (empty %) foo bar foo))))   ;; uniques
+        is-map? #(and (= :bar ((conj % foo bar) :some))             ;; override map-entry
+                      (= 1 (count (conj (empty %) foo bar))))]      ;; only one-map-entry added
+    (cond (is-set? some-struct) :set
+      	  (is-vector? some-struct) :vector
+          (is-list? some-struct) :list
+          (is-map? some-struct) :map)))
+
+;; refactored function to take in control the properties associated to each ds: associative? + reversible?
+(defn type-of [ds]
+  (if (associative? ds)
+    (if (reversible? ds) :vector :map)
+    (if (= 1 (count (conj (empty ds) :foo :foo))) :set :list)))
+
+(associative? '(1 2))  ;; false
+(associative? #{1 2})  ;; false
+(associative? [1 2])   ;; true
+(associative? {1 2})   ;; true
+
+(reversible? '(1 2))   ;; false
+(reversible? [1 2])    ;; true
+(reversible? {1 2})    ;; false
+(reversible? #{1 2})   ;; false
+
+;; demo:
+(map type-of [{} #{} [] ()])  ;; (:map :set :vector :list)
+(= [:map :set :vector :list] (map type-of [{} #{} [] ()])) ;; true
+(= :set (type-of #{10 (rand-int 5)})) ;; true
+
+;; Note: TWO sets are NOT identical, even if they have all the items the same, and use the same "given" order
+(identical? #{1 2 3} #{1 3 2}) ;; false
+(identical? #{1 2 3} #{1 2 3}) ;; false


Don't require param names

Don't require param names

--- src/tick/core.clj
+++ src/tick/core.clj
@@ -520,8 +520,8 @@
   (end [_] nil))

 (defprotocol ITimeAt
-  (on [_ date] "Set time be ON a date")
-  (at [_ date] "Set date to be AT a time")  )
+  (on [_ _] "Set time be ON a date")
+  (at [_ _] "Set date to be AT a time")  )

 (extend-protocol ITimeAt
   LocalTime


fix cache invalidation for convert-goog sources

didn't invalidate properly when :output-feature-set changed

--- src/main/shadow/build/closure.clj
+++ src/main/shadow/build/closure.clj
@@ -2056,6 +2056,15 @@
                  :live-js-deps live-js-deps))
       )))

+(defn goog-compiler-options [state]
+  (merge
+    {:pretty-print true
+     :pseudo-names false
+     :language-in :ecmascript-next
+     :output-feature-set :es5
+     :source-map true}
+    (get-output-options state)))
+
 (defn convert-goog*
   "convert Closure Library code since it may contain a random mix of ClosureJS and Closure Modules"
   [{:keys [js-options mode] :as state} sources]
@@ -2082,13 +2091,7 @@
         (data/make-closure-compiler)

         co-opts
-        (merge
-          {:pretty-print true
-           :pseudo-names false
-           :language-in :ecmascript-next
-           :output-feature-set :es5
-           :source-map true}
-          (get-output-options state))
+        (goog-compiler-options state)

         generate-source-map?
         (not (false? (:source-map js-options)))
@@ -2181,9 +2184,9 @@
             (do (io/make-parents cache-index-file)
                 {}))

-        ;; FIXME: currently this doesn't accept any outside compiler options
+        ;; must invalidate cache if :output-feature-set changes
         cache-options
-        []
+        (goog-compiler-options state)

         cache-files
         (if (or (not= SHADOW-CACHE-KEY (:SHADOW-CACHE-KEY cache-index))


Support hour, minute and second coercions on LocalDateTime

--- src/tick/core.clj
+++ src/tick/core.clj
@@ -232,6 +232,9 @@
   LocalDateTime
   (date [dt] (.toLocalDate dt))
   (time [dt] (.toLocalTime dt))
+  (second [t] (.getSecond t))
+  (minute [t] (.getMinute t))
+  (hour [t] (.getHour t))
   (day [dt] (day (date dt)))
   (day-of-month [dt] (day-of-month (date dt)))
   (year-month [dt] (year-month (date dt)))


Changed foreign part to pull `::pc/index-io` and `::pc/index-attributes`

--- src/com/wsscode/pathom/connect/foreign.cljc
+++ src/com/wsscode/pathom/connect/foreign.cljc
@@ -12,12 +12,14 @@
             [edn-query-language.core :as eql]))

 (def index-query
-  [{:com.wsscode.pathom.connect/indexes
-    [:com.wsscode.pathom.connect/index-oir
-     :com.wsscode.pathom.connect/idents
-     :com.wsscode.pathom.connect/autocomplete-ignore
-     :com.wsscode.pathom.connect/index-resolvers
-     :com.wsscode.pathom.connect/index-mutations]}])
+  [{::pc/indexes
+    [::pc/index-attributes
+     ::pc/index-oir
+     ::pc/index-io
+     ::pc/idents
+     ::pc/autocomplete-ignore
+     ::pc/index-resolvers
+     ::pc/index-mutations]}])

 (defn remove-internal-keys [m]
   (into {} (remove (fn [[k _]] (str/starts-with? (or (namespace k) "") "com.wsscode.pathom"))) m))
@@ -28,6 +30,7 @@
       (::pc/indexes <>)
       (p/elide-items p/special-outputs <>)
       (update <> ::pc/index-oir remove-internal-keys)
+      #_(update <> ::pc/index-io remove-internal-keys)
       (update <> ::pc/index-resolvers remove-internal-keys)
       (update <> ::pc/index-mutations remove-internal-keys)
       (update <> ::pc/index-resolvers #(p.misc/map-vals (fn [x] (assoc x ::pc/resolve (fn [_ _]))) %))


Try to get more informative info out of compile-stefon-with-sourcemaps

--- src/frontend/stefon_with_sourcemaps.clj
+++ src/frontend/stefon_with_sourcemaps.clj
@@ -35,9 +35,14 @@
               (let [compiled-source-map (second (asset/compile
                                                   (fs/join root (fs/dirname sf))
                                                   source-map))]
-                (swap! current-sourcemap-sections conj {:offset {:line @current-offset-row
-                                                                 :column 0}
-                                                        :map (json/read-str compiled-source-map)})))
+                (try
+                  (swap! current-sourcemap-sections conj {:offset {:line @current-offset-row
+                                                                   :column 0}
+                                                          :map (json/read-str compiled-source-map)})
+                  (catch java.lang.ClassCastException e
+                    (infof "(asset/compile %s source-map) gives compiled-source-map of type %s"
+                           (fs/join root (fs/dirname sf)) (type compiled-source-map))
+                    (throw e)))))
             (do
               ;; if the last line isn't a sourcemapping, append it
               (.append compiled-stefon (last compiled-content-lines))


Removes extra BK parameter from signature.

--- src/onyx/state/log/bookkeeper.clj
+++ src/onyx/state/log/bookkeeper.clj
@@ -42,7 +42,7 @@
                (zk/ledgers-path (:onyx/id opts))
                (arg-or-default :onyx.bookkeeper/client-timeout opts)
                (arg-or-default :onyx.bookkeeper/client-throttle opts)))
-  ([zk-addr zk-root-path timeout disk-usage throttle]
+  ([zk-addr zk-root-path timeout throttle]
    (let [conf (doto (ClientConfiguration.)
                 (.setZkServers zk-addr)
                 (.setZkTimeout timeout)


clean up extemp piano example

clean up extemp piano example

--- examples/extemp_piano.clj
+++ examples/extemp_piano.clj
@@ -30,26 +30,25 @@
 (def beat-offsets [0 0.1 0.2 1/3  0.7 0.9])

 (def metro (metronome 20))
-;;(metro :bpm 30)

 (def root 40)
 (def max-range 35)
 (def range-variation 10)
 (def range-period 8)

-;;this assumes you have the mda-piano or the piano samples available. Feel free
-;;to eplace piano with a different synth which accepts a MIDI note as its first
-;;arg such as tb303.
-;; (def instrument tb303)
-
 (defn beat-loop
   [metro beat chord-idx]
   (let [[tonic chord-name] (choose (seq (nth chord-prog chord-idx)))
-        nxt-chord-idx      (mod (inc chord-idx) (count chord-prog))]
+        nxt-chord-idx      (mod (inc chord-idx) (count chord-prog))
+        note-range         (cosr beat range-variation  max-range range-period)
+        notes-to-play      (rand-chord (+ root tonic)
+                                       chord-name
+                                       (count beat-offsets)
+                                       note-range)]
     (dorun
      (map (fn [note offset]
             (at (metro (+ beat offset)) (sampled-piano note 0.3)))
-          (rand-chord (+ root tonic) chord-name (count beat-offsets) (cosr beat range-variation  max-range range-period))
+          notes-to-play
           beat-offsets))
     (apply-at (metro (inc beat)) #'beat-loop [metro (inc beat) nxt-chord-idx])))


lookup index in the right place

lookup index in the right place

--- src/org/spootnik/cyanite/http.clj
+++ src/org/spootnik/cyanite/http.clj
@@ -72,7 +72,7 @@
   (path/prefixes index "" (str query "*")))

 (defmethod process :metrics
-  [{{:keys [index from to path agg]} :params :keys [store rollups]}]
+  [{{:keys [from to path agg]} :params :keys [index store rollups]}]
   (debug "fetching paths: " path)
   (if-let [{:keys [rollup period]} (find-best-rollup from rollups)]
     (let [to    (if to (Long/parseLong to) (now))


Indentation

Indentation

--- src/oxcart/passes/lambda_lift.clj
+++ src/oxcart/passes/lambda_lift.clj
@@ -65,8 +65,8 @@
               sym          (pattern/fn->name ast)
               def-form     `(def ~(symbol sym)
                               ~(-> (emit-form ast)
-                                 fn*->cannonical-fn*
-                                 (rewrite-fn* used-locals)))
+                                   fn*->cannonical-fn*
+                                   (rewrite-fn* used-locals)))
               partial-form `(partial ~(symbol sym) ~@used-locals)
               def-ast      (util/ast def-form     (:env ast))
               partial-ast  (util/ast partial-form (:env ast))]


make helpers/prefix work on clj symbols

make helpers/prefix work on clj symbols

--- src/refactor_nrepl/ns/helpers.clj
+++ src/refactor_nrepl/ns/helpers.clj
@@ -29,11 +29,15 @@
   (some->> (index-of-component ns type) (nth ns)))

 (defn prefix
-  "java.util.Date -> java.util"
+  "java.util.Date -> java.util
+
+  clojure.walk/walk -> clojure.walk"
   [fully-qualified-name]
-  (let [parts (-> fully-qualified-name str (.split "\\.") butlast)]
-    (when (seq parts)
-      (str/join "." parts))))
+  (if(re-find #"/" (str fully-qualified-name))
+    (-> fully-qualified-name str (.split "/") first)
+    (let [parts (-> fully-qualified-name str (.split "\\.") butlast)]
+      (when (seq parts)
+        (str/join "." parts)))))

 (defn suffix
   "java.util.Date -> Date


more cleanup, a few small optimizations

more cleanup, a few small optimizations

--- src/viz/core.cljs
+++ src/viz/core.cljs
@@ -27,47 +27,39 @@

 (def window-half-size (apply vector (map #(float (/ %1 2)) window-size)))

-(def frame-rate 15)
-
-(defn- mk-ghost [state ghost-def]
+(defn- set-grid-size [state]
+  (let [h (int (* (window-size 1)
+                  (float (/ (:grid-width state) (window-size 0)))))]
+    (assoc state :grid-size [(:grid-width state) h])))
+
+(defn- add-ghost [state ghost-def]
   (let [[forest id] (forest/add-node (:forest state) (:start-pos ghost-def))
-        ghost       (ghost/add-active-node (ghost/new-ghost) id)
+        ghost       (-> (ghost/new-ghost)
+                        (ghost/add-active-node id)
+                        (assoc :ghost-def ghost-def))
         ]
-    [(assoc state :forest forest) (assoc ghost :ghost-def ghost-def)]))
-
-(defn- mk-ghosts [state]
-  (let [[state ghosts] (reduce (fn [[state ghosts] ghost-def]
-                                    (let [[state ghost] (mk-ghost state ghost-def)]
-                                      [state (cons ghost ghosts)]))
-                               [state '()]
-                               (:ghost-defs state))]
-        (assoc state :ghosts ghosts)))
+    (assoc state
+           :forest forest
+           :ghosts (cons ghost (:ghosts state)))))

 (defn- new-state []
-  (-> {:frame-rate frame-rate
+  (-> {:frame-rate 15
        :color-cycle-period 8
-       :exit-wait-frames 40
        :tail-length 7
        :frame 0
        :grid-width 45 ; from the center
        :forest (forest/new-forest grid/isometric)
-       :ghost-defs [;{:start-pos [2 2]
-                    ; :color-fn (fn [state] (q/color 0 1 1))
-                    ; ;:color-fn (fn [state]
-                    ; ;            (q/color (mod (:frame state) (frames-per-color-cycle state)) 1 1))
-                    ; }
-                    {:start-pos [-2 -2]
-                     :color-fn (fn [state]
-                                 (let [frames-per-color-cycle
-                                       (* (:color-cycle-period state) (:frame-rate state))]
-                                   (q/color
-                                     (/ (mod (:frame state) frames-per-color-cycle)
-                                        frames-per-color-cycle)
-                                     1 1)))
-                     }
-                    ]
        }
-      (mk-ghosts)
+      (set-grid-size)
+      (add-ghost {:start-pos [-2 -2]
+                  :color-fn (fn [state]
+                              (let [frames-per-color-cycle
+                                    (* (:color-cycle-period state) (:frame-rate state))]
+                                (q/color
+                                  (/ (mod (:frame state) frames-per-color-cycle)
+                                     frames-per-color-cycle)
+                                  1 1)))
+                  })
       ))

 (defn setup []
@@ -80,14 +72,9 @@
 (defn- curr-second [state]
   (float (/ (:frame state) (:frame-rate state))))

-(defn- grid-size [state]
-  (let [h (int (* (window-size 1)
-                  (float (/ (:grid-width state) (window-size 0)))))]
-             [(:grid-width state) h]))
-
-(defn- scale [state xy]
+(defn- scale [grid-size xy]
   (map-indexed #(* %2 (float (/ (window-half-size %1)
-                                ((grid-size state) %1)))) xy))
+                                (grid-size %1)))) xy))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; poss-fn
@@ -95,14 +82,10 @@
 (def bounds-buffer 1)

 (defn- in-bounds? [grid-size pos]
-  (let [[w h] (apply vector (map #(- % bounds-buffer) grid-size))
-        min-bound [(- w) (- h)]
-        max-bound [w h]
-        pos-k (keep-indexed #(let [mini (min-bound %1)
-                                   maxi (max-bound %1)]
-                               (when (and (>= %2 mini) (<= %2 maxi)) %2)) pos)]
-    (= (count pos) (count pos-k))))
-
+  (let [[w h] (apply vector (map #(- % bounds-buffer) grid-size))]
+    (every?
+      #(and (>= (% 1) (- (% 0))) (<= (% 1) (% 0)))
+      (map vector [w h] pos))))

 (defn- dist-from-sqr [pos1 pos2]
   (reduce + (map #(* % %) (map - pos1 pos2))))
@@ -119,7 +102,7 @@
       adj-poss)))

 (defn- mk-poss-fn [state]
-  (let [grid-size (grid-size state)]
+  (let [grid-size (:grid-size state)]
     (fn [pos adj-poss]
       (->> adj-poss
            (filter #(in-bounds? grid-size %))
@@ -229,10 +212,10 @@
 (defn draw-state [state]
   ; Clear the sketch by filling it with light-grey color.
   (q/background 0xFFFFFFFF)
-  (q/with-translation [(/ (window-size 0) 2)
-                       (/ (window-size 1) 2)]
-
-    (let [scale-fn #(scale state %)
+  (q/with-translation window-half-size
+
+    (let [grid-size (:grid-size state)
+          scale-fn #(scale grid-size %)
           ghost (:ghost state)
           forest (:forest state)
           roots (forest/roots forest)


Fix issue with num-bins on aerospike histogram.

--- src/forecast/parse.clj
+++ src/forecast/parse.clj
@@ -68,8 +68,7 @@
      #(do
         (Thread/sleep 1000)
         (process-new-locations)
-        ))))
-  )
+        )))))

 (defn get-histogram
   [num-bins]
@@ -112,7 +111,9 @@
 (defn parse-args
   [params]
   (metrics/reset-metrics)
-  (let [args (set params)]
+  (let [args (set params)
+        process? (contains? args "--process")
+        num-bins-location (if process? second first)]
     ;; setup
     (when (contains? args "--aero")
       (println "using aerospike")
@@ -121,13 +122,13 @@
       (println "using live services")
       (use-live))

-    ;; process file
-    (when-not (and (first params) (= \- (-> params first first)))
+    ;; load logfile
+    (when-not (and process? (first params) (= \- (-> params first first)))
       (println "load file")
       (parse-logfile (first params) log-parser))

     ;; post processing
-    (when (contains? args "--process")
+    (when process?
       (println "processing ...")
       (process-new-ips)
       (process-new-locations)
@@ -136,7 +137,7 @@
       (println "setting up a daemon")
       (daemon))
     (when (contains? args "--hist")
-      (let [num-bins (if (= \- (-> params second first))
+      (let [num-bins (if (= \- (-> params num-bins-location first))
                        5
                        (read-string (second params)))]
         (print-histogram num-bins)))


working http-collector tests

working http-collector tests

--- http-collector/test/http_collector/core_test.clj
+++ http-collector/test/http_collector/core_test.clj
@@ -1,5 +1,7 @@
 (ns http-collector.core-test
   (:require [midje.sweet :refer :all]
+            [clj-http.client :as http]
+            [cheshire.core :refer :all]
             [http-collector.core :refer :all]))

 (facts "Content filtering"
@@ -15,10 +17,14 @@
              (collect-endpoint "http://localhost:12000") => {:error "Connection Refused",
                                                              :status "DOWN",
                                                              :type "error",
-                                                             :url "http://localhost:12000"})
+                                                             :url "http://localhost:12000"}
+             (provided (http/get anything) =throws=> (java.net.ConnectException.)))
+
        (fact "Service running and healthy"
              (collect-endpoint "http://kuona.io:9002/status") => {:status "UP",
-                                                                  :url "http://kuona.io:9002/status"}))
+                                                                  :url "http://kuona.io:9002/status"}
+             (provided (http/get anything) => {:headers {:Content-Type "json"}
+                                               :body (generate-string {:status "UP"})})))

 (facts "Content testing"
        (fact "test run against content"


Set proper :language-in on build.clj script.

--- scripts/build.clj
+++ scripts/build.clj
@@ -6,6 +6,7 @@
    :output-dir "out/tests"
    :target :nodejs
    :optimizations :advanced
+   :language-in :es5
    :pretty-print true
    :verbose true})


Compute `+n-orbitals-extra-at-energy-level-diffs+`

--- test/com/nomistech/clojure_the_language/c_900_appy_stuff/s_100_science/ss_atomic_orbitals.clj
+++ test/com/nomistech/clojure_the_language/c_900_appy_stuff/s_100_science/ss_atomic_orbitals.clj
@@ -1,8 +1,22 @@
 (ns com.nomistech.clojure-the-language.c-900-appy-stuff.s-100-science.ss-atomic-orbitals
   (:require [midje.sweet :refer :all]))

+(def +orbitals-extra-at-energy-level+
+  [{:s 1}
+   {:p 3}
+   {}
+   {:d 5}
+   {}
+   {:f 7}
+   {}])
+
 (def +n-orbitals-extra-at-energy-level-diffs+
-  [0 1 3 0 5 0 7 0])
+  (cons 0
+        (for [m +orbitals-extra-at-energy-level+]
+          (if (empty? m)
+            0
+            (apply + (for [[k v] m]
+                       v))))))

 (def +n-electrons-extra-at-energy-level-diffs+
   (map (partial * 2)


fixed test that could never fail because of incorret parens

--- redis-utils-lib/test/cmr/redis_utils/test/test_redis_cache.clj
+++ redis-utils-lib/test/cmr/redis_utils/test/test_redis_cache.clj
@@ -17,7 +17,7 @@
       (cache/set-value rcache "test" "expire")
       (is (= "expire"
              (cache/get-value rcache "test")))
-      (is (> (wcar* (carmine/ttl (redis-cache/serialize "test")) 0))))))
+      (is (> (wcar* (carmine/ttl (redis-cache/serialize "test"))) 0)))))

 (deftest test-redis-cache-with-persistance
   (testing "Redis cache with default timeout..."