Use :multiaccount instead of :multiaccounts/multiaccounts when looking
through candidate public keys

Signed-off-by: Vitaliy Vlasov <e49d0217baed7632d034fb41cd352d74cf7c0ec8@gmail.com>

--- src/status_im/notifications/core.cljs
+++ src/status_im/notifications/core.cljs
@@ -91,12 +91,13 @@
   (defn lookup-contact-pubkey-from-hash
     [{:keys [db] :as cofx} contact-pubkey-or-hash]
     "Tries to deanonymize a given contact pubkey hash by looking up the
-    full pubkey (if db is unlocked) in :contacts/contacts.
+    full pubkey (if db is unlocked) in :multiaccount and, if not found,
+    in :contacts/contacts.
     Returns original value if not a hash (e.g. already a public key)."
     (if (and contact-pubkey-or-hash
              (= (count contact-pubkey-or-hash) pn-pubkey-hash-length))
       (if-let [multiaccount-pubkey (hash->pubkey contact-pubkey-or-hash
-                                                 (-> db :multiaccounts/multiaccounts vals))]
+                                                 [(:multiaccount db)])]
         multiaccount-pubkey
         (if (multiaccounts.model/logged-in? cofx)
           ;; TODO: for simplicity we're doing a linear lookup of the contacts,


Group helper fns.

Group helper fns.

--- src/isla/parser.clj
+++ src/isla/parser.clj
@@ -3,33 +3,12 @@
   (:use [isla.lexer])
   (:require [clojure.string :as str]))

-(defn nnode [tag data]
-  {:tag tag :content data})
-
-(declare parse alternatives is-type pattern-sequence
+(declare parse alternatives is-type pattern-sequence pattern
          -root -block -expression -assignment -invocation
          -nl -integer -is -string -assignee -value -identifier)

 (defn parse [code]
   (-root (lex code)))
-
-(defn alternatives [input types] ;; bit round the houses
-  (vec (map (fn [t] (t input)) ;; get nodes for each matching type
-            (filter (fn [t] (not= nil (t input))) ;; get matching types
-                    types))))
-
-(defmulti is-type (fn [matcher token] (class matcher)))
-
-(defmethod is-type clojure.lang.Keyword [symbol token]
-  (= symbol token))
-
-(defmethod is-type java.util.regex.Pattern [re token]
-  (if (keyword? token)
-    false
-    (if (not= nil (re-matches re token))
-      true
-      false)))
-

 (defn -root [tokens]
   (nnode :root [(-block tokens [])]))
@@ -61,6 +40,50 @@
       {:expr (nnode :invocation (take 2 nodes)) :left-tokens (nthrest tokens 3)}
       nil)))

+;; atoms
+
+(defn -nl [token] (pattern token :nl :nl))
+
+(defn -is [token]
+  (pattern token #"is" :is (fn [x] [:is])))
+
+;; values
+
+(defn -value [token]
+  (def nodes (alternatives token [-string -integer -identifier]))
+  (if (> (count nodes) 0)
+    (nnode :value [(first nodes)])
+    nil))
+
+(defn -assignee [token] (pattern token #"[A-Za-z]+" :assignee))
+
+(defn -identifier [token] (pattern token #"(?!^is$)[A-Za-z]+" :identifier))
+
+(defn -integer [token]
+  (pattern token #"[0-9]+" :integer (fn [x] [(Integer/parseInt token)])))
+
+(defn -string [token]
+  (pattern token #"'[A-Za-z0-9 ]+'" :string (fn [x] [(str/replace token "'" "")])))
+
+;; helpers
+
+(defmulti is-type (fn [matcher token] (class matcher)))
+
+(defmethod is-type clojure.lang.Keyword [symbol token]
+  (= symbol token))
+
+(defmethod is-type java.util.regex.Pattern [re token]
+  (if (keyword? token)
+    false
+    (if (not= nil (re-matches re token))
+      true
+      false)))
+
+(defn alternatives [input types] ;; bit round the houses
+  (vec (map (fn [t] (t input)) ;; get nodes for each matching type
+            (filter (fn [t] (not= nil (t input))) ;; get matching types
+                    types))))
+
 (defn pattern-sequence [tokens patterns collected]
   (if (and (> (count patterns) 0) ;; still patterns to test
            (>= (count tokens) (count patterns))) ;; enough tokens to satisfy pattern
@@ -78,25 +101,5 @@
       (nnode tag output))
     nil))

-;; atoms
-
-(defn -nl [token] (pattern token :nl :nl))
-(defn -is [token]
-  (pattern token #"is" :is (fn [x] [:is])))
-
-;; values
-
-(defn -value [token]
-  (def nodes (alternatives token [-string -integer -identifier]))
-  (if (> (count nodes) 0)
-    (nnode :value [(first nodes)])
-    nil))
-
-(defn -assignee [token] (pattern token #"[A-Za-z]+" :assignee))
-(defn -identifier [token] (pattern token #"(?!^is$)[A-Za-z]+" :identifier))
-(defn -integer [token]
-  (pattern token #"[0-9]+" :integer (fn [x] [(Integer/parseInt token)])))
-
-(defn -string [token]
-  (pattern token #"'[A-Za-z0-9 ]+'" :string (fn [x] [(str/replace token "'" "")])))
-
+(defn nnode [tag data]
+  {:tag tag :content data})


More idiomatic expression.

More idiomatic expression.

--- src/isla/parser.clj
+++ src/isla/parser.clj
@@ -15,7 +15,7 @@

 (defn -block [tokens collected]
   (let [{expr :expr left-tokens :left-tokens} (-expression tokens [])]
-    (if (= expr nil)
+    (if (nil? expr)
       (nnode :block collected) ;; no more exprs, return block
       (-block left-tokens (conj collected expr))))) ;; add expr, continue collecting more


Refactors rember to use equal?

Refactors rember to use equal?

--- src/the_little_clojurian/chapter5.clj
+++ src/the_little_clojurian/chapter5.clj
@@ -4,6 +4,8 @@
             [the-little-clojurian.chapter2 :refer :all]
             [the-little-clojurian.chapter3 :refer :all]
             [the-little-clojurian.chapter4 :refer :all]))
+
+(declare equal?)

 (with-test
   (def rember*
@@ -118,11 +120,7 @@
     (fn [l1 l2]
       (cond (and (null? l1) (null? l2)) true
             (or (null? l1) (null? l2)) false
-            (and (atom? (car l1)) (atom? (car l2))) (and (equan? (car l1) (car l2))
-                                                         (eqlist? (cdr l1) (cdr l2)))
-            (or (atom? (car l1))
-                (atom? (car l2))) false
-            :else (and (eqlist? (car l1) (car l2))
+            :else (and (equal? (car l1) (car l2))
                        (eqlist? (cdr l1) (cdr l2))))))

   (is (= (eqlist? '() '()) true))
@@ -148,6 +146,27 @@
   (is (= (equal? '(a) '(a)) true))
   (is (= (equal? '(a) '(b)) false)))

+;; The Sixth Commandment
+;;
+;; SIMPLIFY ONLY AFTER THE FUNCTION IS CORRECT
+;;
+;; (Refactor only when all tests are passing)
+
+;; Example refactor of rember from chapter 3 (Renamed to keep the old one intact)
+(with-test
+  (def rember2
+    (fn [s l]
+      (cond (null? l) '()
+            (equal? (car l) s) (cdr l)
+            :else (rember2 s (cdr l)))))
+
+  (is (= (rember 'and '()) '()))
+  (is (= (rember 'and '(and)) '()))
+  (is (= (rember 'and '(bacon lettuce and tomato)) '(bacon lettuce tomato)))
+  (is (= (rember 'mint '(lamb chops and mint jelly)) '(lamb chops and jelly)))
+  (is (= (rember 'mint '(lamb chops and mint flavored mint jelly)) '(lamb chops and flavored mint jelly))))
+
+
 ;; exercises
 (with-test
   (def replace*


Refactors member*

Refactors member*

--- src/the_little_clojurian/chapter5.clj
+++ src/the_little_clojurian/chapter5.clj
@@ -91,8 +91,8 @@
   (def member*
     (fn [a l]
       (cond (null? l) false
-            (atom? (car l)) (cond (eq? (car l) a) true
-                                  :else (member* a (cdr l)))
+            (atom? (car l)) (or (eq? (car l) a)
+                                (member* a (cdr l)))
             :else (or (member* a (car l))
                       (member* a (cdr l))))))


support optional show-notes and from-language

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -23,8 +23,10 @@
 (def grammar (:grammar-map (medium)))

 ;; can't decide between 'morph' or 'fo' or something other better name.
-(defn morph [expr]
-  (fo expr))
+(defn morph [expr & {:keys [from-language show-notes]
+                     :or {from-language nil
+                          show-notes true}}]
+  (fo expr :from-language from-language :show-notes show-notes))

 (defn fo-ps [expr]
   (parse/fo-ps expr fo))


in (defn generate), model should be optional

--- src/babel/english.cljc
+++ src/babel/english.cljc
@@ -43,10 +43,10 @@
   ((:lookup medium) lexeme))

 (defn generate
-  [spec model
-   & {:keys [max-total-depth model truncate-children]
-      :or {max-total-depth generate/max-total-depth
-           truncate-children true}}]
+  [spec & [model
+           {:keys [max-total-depth model truncate-children]
+            :or {max-total-depth generate/max-total-depth
+                 truncate-children true}}]]
   (let [model (if model model medium)]
     (let [result (engine/generate spec model
                                   :max-total-depth max-total-depth


Show diff between files.

Show diff between files.

--- test/clj/testing/pamela/plan_schema.clj
+++ test/clj/testing/pamela/plan_schema.clj
@@ -11,7 +11,8 @@
             [plan-schema.core :as psc]
             [clojure.java.io :as io]
             [clojure.string :as str]
-            [clojure.pprint :refer :all])
+            [clojure.pprint :refer :all]
+            [clojure.java.shell :as sh])
   (:import [java.io.File]))

 ;; NOTE ["test/pamela/cannon.pamela" "(game.main)"]
@@ -93,31 +94,31 @@
   (read-string (slurp filename)))

 #_(defn json->edn
-  "Perform basic HTN/TPN data conversion"
-  {:added "0.6.0"}
-  ([m]
-   (cond
-     (map? m) (reduce-kv json->edn {} m)
-     :else m))
-  ([m k v]
-   (assoc m k
-     (let [v2
-           (cond ;; type coercion of v based on k
-             (map? v) (reduce-kv json->edn {} v)
-             ;; k that wants v to be a keyword
-             (#{:type :tpn-type :network :network-id :uid :htn-node :end-node} k)
-             (keyword v)
-             ;; k that wants v to be a set of keywords
-             (#{:incidence-set :rootnodes :constraints :activities} k)
-             (set (map keyword v))
-             ;; k that wants v to be a vector of keywords
-             (#{:edges} k)
-             (mapv keyword v)
-             :else v)]
-       ;; DEBUGGING
-       ;; (if (not= v2 v)
-       ;;   (println "k:" k "v:" v " -> " v2))
-       v2))))
+    "Perform basic HTN/TPN data conversion"
+    {:added "0.6.0"}
+    ([m]
+     (cond
+       (map? m) (reduce-kv json->edn {} m)
+       :else m))
+    ([m k v]
+     (assoc m k
+              (let [v2
+                    (cond                                   ;; type coercion of v based on k
+                      (map? v) (reduce-kv json->edn {} v)
+                      ;; k that wants v to be a keyword
+                      (#{:type :tpn-type :network :network-id :uid :htn-node :end-node} k)
+                      (keyword v)
+                      ;; k that wants v to be a set of keywords
+                      (#{:incidence-set :rootnodes :constraints :activities} k)
+                      (set (map keyword v))
+                      ;; k that wants v to be a vector of keywords
+                      (#{:edges} k)
+                      (mapv keyword v)
+                      :else v)]
+                ;; DEBUGGING
+                ;; (if (not= v2 v)
+                ;;   (println "k:" k "v:" v " -> " v2))
+                v2))))

 ; The output produced by plan-schema (edn and json) is being compared to find coercion issues.
 ; Note: plan-schema reads edn and json (produced by pamela) and spits out the version of the same after coercion.
@@ -136,13 +137,13 @@
   (= (read-clj edn) (read-clj json))
   ; This is a bad test because it is actually performing the same coercion that plan-schema should be doing.
   #_(let [edn-sorted (into (sorted-map) (keywordize (read-clj edn)))
-        json-sorted (into (sorted-map) (json->edn (read-clj json)))
-        equal? (= edn-sorted json-sorted)]
-    ;; DEBUGGING
-    ;; (when-not equal?
-    ;;   (spit (str edn ".sorted.edn") (with-out-str (pprint edn-sorted)))
-    ;;   (spit (str json ".sorted.edn") (with-out-str (pprint json-sorted))))
-    equal?))
+          json-sorted (into (sorted-map) (json->edn (read-clj json)))
+          equal? (= edn-sorted json-sorted)]
+      ;; DEBUGGING
+      ;; (when-not equal?
+      ;;   (spit (str edn ".sorted.edn") (with-out-str (pprint edn-sorted)))
+      ;;   (spit (str json ".sorted.edn") (with-out-str (pprint json-sorted))))
+      equal?))

 (deftest testing-check-coercion
   (testing "HTN and TPN Json coercion"
@@ -152,9 +153,14 @@

         (when-not (compare-files htn-edn-clj htn-json-clj)
           ;; fake comparison to trigger unit test error
-          (is (= htn-edn-clj htn-json-clj) (prn-str "files differ" htn-edn-clj htn-json-clj " Do diff for details")))
+          (is (= htn-edn-clj htn-json-clj) (prn-str "files differ" htn-edn-clj htn-json-clj " See diff for details"))
+          (println (:out (sh/sh "diff" "-u" htn-edn-clj htn-json-clj))))

         (when-not (compare-files tpn-edn-clj tpn-json-clj)
-          (is (= tpn-edn-clj tpn-json-clj) (prn-str "files differ" tpn-edn-clj tpn-json-clj " Do diff for details")))
+          (is (= tpn-edn-clj tpn-json-clj) (prn-str "files differ" tpn-edn-clj tpn-json-clj " See diff for details"))
+          (println (:out (sh/sh "diff" "-u" tpn-edn-clj tpn-json-clj))))

         ))))
+
+(defn check-shell []
+  (sh/sh "ls"))


Comment flaky gen test

Comment flaky gen test

--- test/com/wsscode/pathom/system_test.clj
+++ test/com/wsscode/pathom/system_test.clj
@@ -134,6 +134,7 @@
            (<!! (async-parser (assoc env ::p/reader [p/map-reader pc/all-async-readers]
                                          ::pc/resolver-dispatch pct/async-resolve-fn) query)))))))

+#_
 (test/defspec connect-read {:max-size 10 :num-tests 100} (connect-read-props pct/parser-env))

 (comment


Failing test for listing images as json

Failing test for listing images as json

--- test/silly_image_store/handler_test.clj
+++ test/silly_image_store/handler_test.clj
@@ -17,6 +17,10 @@
         (is (= (:status response) 404))
         (is (= (:body response) "No image 'not-such-image.png' found")))))

+  (testing "list images as json"
+    (let [response (app (mock/request :get "/images"))]
+      (is (= (:status response) 200))))
+
   (testing "generic not-found route"
     (let [response (app (mock/request :get "/invalid"))]
       (is (= (:status response) 404)))))


topology message timeout used as default wait time now

--- src/clj/backtype/storm/ui/core.clj
+++ src/clj/backtype/storm/ui/core.clj
@@ -426,7 +426,7 @@
           window-hint (window-hint window)
           summ (.getTopologyInfo ^Nimbus$Client nimbus id)
           topology (.getTopology ^Nimbus$Client nimbus id)
-          topology-conf (.getTopologyConf ^Nimbus$Client nimbus id)
+          topology-conf (from-json (.getTopologyConf ^Nimbus$Client nimbus id))
           spout-summs (filter (partial spout-summary? topology) (.get_executors summ))
           bolt-summs (filter (partial bolt-summary? topology) (.get_executors summ))
           spout-comp-summs (group-by-comp spout-summs)
@@ -434,6 +434,7 @@
           bolt-comp-summs (filter-key (mk-include-sys-fn include-sys?) bolt-comp-summs)
           name (.get_name summ)
           status (.get_status summ)
+          msg-timeout (topology-conf TOPOLOGY-MESSAGE-TIMEOUT-SECS)
           ]
       (concat
        [[:h2 "Topology summary"]]
@@ -442,8 +443,8 @@
        [[:p {:class "js-only"} (concat
          [(topology-action-button id name "Activate" "activate" false 0 (= "INACTIVE" status))]
          [(topology-action-button id name "Deactivate" "deactivate" false 0 (= "ACTIVE" status))]
-         [(topology-action-button id name "Rebalance" "rebalance" true 30 (not= "KILLED" status))]
-         [(topology-action-button id name "Kill" "kill" true 30 (not= "KILLED" status))]
+         [(topology-action-button id name "Rebalance" "rebalance" true msg-timeout (not= "KILLED" status))]
+         [(topology-action-button id name "Kill" "kill" true msg-timeout (not= "KILLED" status))]
        )]]
        [[:h2 "Topology stats"]]
        (topology-stats-table id window (total-aggregate-stats spout-summs bolt-summs include-sys?))
@@ -452,7 +453,7 @@
        [[:h2 "Bolts (" window-hint ")"]]
        (bolt-comp-table id bolt-comp-summs (.get_errors summ) window include-sys?)
        [[:h2 "Topology Configuration"]]
-       (configuration-table (from-json topology-conf))
+       (configuration-table topology-conf)
        ))))

 (defn component-task-summs [^TopologyInfo summ topology id]


Propagate server-went-away exceptions

Propagate server-went-away exceptions

--- src/clj/reply/eval_modes/nrepl.clj
+++ src/clj/reply/eval_modes/nrepl.clj
@@ -27,6 +27,7 @@
     (nrepl.server/stop-server @nrepl-server))
   (when (isa? (class @current-connection) java.io.Closeable)
     (.close ^java.io.Closeable @current-connection))
+  (signals/set-signal-handler! "INT" (constantly nil))
   (reset! current-command-id nil)
   (reset! current-session nil)
   (reset! current-connection nil)
@@ -44,10 +45,10 @@

 (def response-queues (atom {}))

-(defn notify-all-queues-of-error []
+(defn notify-all-queues-of-error [e]
   (doseq [session-key (keys @response-queues)]
     (.offer ^LinkedBlockingQueue (@response-queues session-key)
-            {:status "error" :global true})))
+            {:status ["error"] :global true :error e})))

 (defn session-responses [session]
   (lazy-seq
@@ -61,10 +62,11 @@
   (let [relevant-message (or (= command-id (:id message)) (:global message))
         error (some #{"error" "eval-error"} (:status message))
         done (some #{"done" "interrupted"} (:status message))]
-
     (when error
       (when-let [caught (:caught options)]
-        (execute-with-client client options (str "(" (pr-str caught) ")"))))
+        (execute-with-client client options (str "(" (pr-str caught) ")")))
+      (when (:global message)
+        (throw (:error message))))

     (and relevant-message (or error done))))

@@ -186,7 +188,7 @@
             (flush))
           :success
           (catch Throwable t
-            (notify-all-queues-of-error)
+            (notify-all-queues-of-error t)
             (when (System/getenv "DEBUG") (clojure.repl/pst t))
             :failure))]
     (when (= :success continue)


Finish renaming the :value option to :print-value

--- src/clj/reply/eval_modes/nrepl.clj
+++ src/clj/reply/eval_modes/nrepl.clj
@@ -168,7 +168,7 @@
   (let [results (atom "nil")]
     (execute-with-client
       client
-      {:value (partial reset! results)
+      {:print-value (partial reset! results)
        :session session}
       (binding [*print-length* nil
                 *print-level* nil]


more cleanup

more cleanup

--- src/cljs/apollo/client/player.cljs
+++ src/cljs/apollo/client/player.cljs
@@ -10,8 +10,7 @@
             [apollo.client.views.nav :as nav]
             [apollo.client.state :as state]
             [cljs.core.async :refer [<! put! chan pub]]
-            [sablono.core :as html :refer-macros [html]]
-            ))
+            [sablono.core :as html :refer-macros [html]]))

 (defn ctrl-audio-node [action]
   (let [seek-offset 5]
@@ -49,48 +48,48 @@
                                   (last (take (inc offset) track-src))
                                   (first track-src))]

-                (set-track current-track (or offset 0) owner)
-                (om/set-state! owner :current-src track-src)
-                (om/transact! (state/ref-player) (fn [p]
-                                                   (assoc p
-                                                          :current-playlist track-src
-                                                          :current-offset (or offset 0)))))
-              (recur)))
-        (go (loop []
-              (let [ctrl (<! channels/player-ctrl)
-                    current-offset (or (om/get-state owner :current-offset) 0)
-                    previous-offset (dec current-offset)
-                    next-offset (inc current-offset)
-                    track-src (om/get-state owner :current-src)
-                    next-track (last (take (inc next-offset) track-src))
-                    previous-track (last (take (inc previous-offset) track-src))
-                    current-track (last (take (inc current-offset) track-src))]
-                (om/set-state! owner :ctrl ctrl)
-                (cond
-                  (and (= ctrl :next) (> next-offset (dec (count track-src))))
-                  (ctrl-audio-node :stop)
-                  (and (= ctrl :next) (not (nil? next-track)))
-                  (set-track next-track next-offset owner)
-                  (and (= ctrl :previous) (not (nil? previous-track)))
-                  (set-track previous-track previous-offset owner)
-                  :else (do (ctrl-audio-node ctrl)
-                            (when (= ctrl :stop)
-                              (put! channels/now-playing {"track" {}}))
-                            (when (= ctrl :play)
-                              (put! channels/now-playing current-track)))))
-              (recur)))
-        (go (loop []
-              (<! channels/stream-position)
-              (let [c (.-currentTime audio-node)
-                    e (.-duration audio-node)]
-                (if (= 0 c)
-                  (do
-                    (om/set-state! owner :current-position 0)
-                    (om/set-state! owner :end-position 0))
-                  (do
-                    (om/set-state! owner :current-position c)
-                    (om/set-state! owner :end-position e))))
-              (recur))))
+              (set-track current-track (or offset 0) owner)
+              (om/set-state! owner :current-src track-src)
+              (om/transact! (state/ref-player) (fn [p]
+                                                 (assoc p
+                                                        :current-playlist track-src
+                                                        :current-offset (or offset 0)))))
+            (recur)))
+      (go (loop []
+            (let [ctrl (<! channels/player-ctrl)
+                  current-offset (or (om/get-state owner :current-offset) 0)
+                  previous-offset (dec current-offset)
+                  next-offset (inc current-offset)
+                  track-src (om/get-state owner :current-src)
+                  next-track (last (take (inc next-offset) track-src))
+                  previous-track (last (take (inc previous-offset) track-src))
+                  current-track (last (take (inc current-offset) track-src))]
+              (om/set-state! owner :ctrl ctrl)
+              (cond
+                (and (= ctrl :next) (> next-offset (dec (count track-src))))
+                (ctrl-audio-node :stop)
+                (and (= ctrl :next) (not (nil? next-track)))
+                (set-track next-track next-offset owner)
+                (and (= ctrl :previous) (not (nil? previous-track)))
+                (set-track previous-track previous-offset owner)
+                :else (do (ctrl-audio-node ctrl)
+                          (when (= ctrl :stop)
+                            (put! channels/now-playing {"track" {}}))
+                          (when (= ctrl :play)
+                            (put! channels/now-playing current-track)))))
+            (recur)))
+      (go (loop []
+            (<! channels/stream-position)
+            (let [c (.-currentTime audio-node)
+                  e (.-duration audio-node)]
+              (if (= 0 c)
+                (do
+                  (om/set-state! owner :current-position 0)
+                  (om/set-state! owner :end-position 0))
+                (do
+                  (om/set-state! owner :current-position c)
+                  (om/set-state! owner :end-position e))))
+            (recur))))
     om/IRender
     (render [this]
       (let [ctrl-current (om/get-state owner :ctrl)
@@ -112,8 +111,7 @@
                 [:li {:on-click (fn [e] (put! channels/player-ctrl :next))}
                  [:i.fa.fa-step-forward]]
                 [:li [:i.fa.fa-repeat]]
-                [:li [:i.fa.fa-random]]
-                ]])))))
+                [:li [:i.fa.fa-random]]]])))))

 (defn view-now-playing [data owner]
   (reify
@@ -135,20 +133,14 @@
                 [:div.now-playing
                  [:a {:href album-nav}
                   [:img {:src album-image}]]
-                 [:span track-heading]
-               ]))))))
+                 [:span track-heading]]))))))

 (defn view-playlists [data owner]
   (reify
-    om/IInitState
-    (init-state [this]
-      {:playlist []
-       :current "this is a test"})
     om/IRender
     (render [this]
       (let [current (:current-playlist (om/observe owner (state/ref-player)))
-            current-offset (:current-offset (om/observe owner (state/ref-player)))
-            t (om/get-state owner :current)]
+            current-offset (:current-offset (om/observe owner (state/ref-player)))]
         (html [:div
                [:i.fa.fa-plus]
                [:ul.playlist


Add get-token and protect both token manipulators

--- src/cljs/comic_reader/history.cljs
+++ src/cljs/comic_reader/history.cljs
@@ -21,5 +21,10 @@
       (doto hist
         (.setEnabled true)))))

+(defn get-token []
+  (when-let [h @goog-history]
+    (.getToken h)))
+
 (defn set-token [token]
-  (.setToken @goog-history (str token)))
+  (when-let [h @goog-history]
+    (.setToken h (str token))))


Fix build pane refreshing bug

Fix build pane refreshing bug

--- src/clojure/nightcode/builders.clj
+++ src/clojure/nightcode/builders.clj
@@ -135,18 +135,18 @@
                 (lein/test-project! process (ui/get-io! console) path))
         clean! (fn [_]
                  (lein/clean-project! process (ui/get-io! console) path))
-        check-versions!
-        (fn [_]
-          (lein/check-versions-in-project! process (ui/get-io! console) path))
+        check-versions! (fn [_]
+                          (lein/check-versions-in-project!
+                            process (ui/get-io! console) path))
         stop! (fn [_]
                 (lein/stop-process! process))
-        auto-build!
-        (fn [_]
-          (ui/config! build-group :#auto-button
-                      :selected? (nil? @auto-process))
-          (if (nil? @auto-process)
-            (lein/cljsbuild-project! auto-process (ui/get-io! console) path)
-            (lein/stop-process! auto-process)))
+        auto-build! (fn [_]
+                      (ui/config! build-group :#auto-button
+                                  :selected? (nil? @auto-process))
+                      (if (nil? @auto-process)
+                        (lein/cljsbuild-project!
+                          auto-process (ui/get-io! console) path)
+                        (lein/stop-process! auto-process)))
         ; create the buttons with their actions attached
         btn-group (ui/wrap-panel
                     :items [(ui/button :id :run-button
@@ -197,8 +197,11 @@
     (add-watch process
                :refresh-builder
                (fn [_ _ _ new-state]
-                 (when (nil? new-state) (reset! last-reload nil))
-                 (show-builder! path)))
+                 (when (nil? new-state)
+                   (reset! last-reload nil))
+                 (-> (ui/get-selected-path)
+                     ui/get-project-path
+                     show-builder!)))
     ; add the buttons to the main panel and create shortcuts
     (doto build-group
       (s/config! :north btn-group)


Simplified cmd-handler.

Simplified cmd-handler.

--- src/cbfg/world/t2.cljs
+++ src/cbfg/world/t2.cljs
@@ -9,14 +9,10 @@
 (def req-handlers
   {"add" cbfg.world.base/example-add
    "sub" cbfg.world.base/example-add
-   "count" cbfg.world.base/example-add
+   "count" cbfg.world.base/example-count
    "close-lane" cbfg.world.base/close-lane})

-(defn req-handler [actx c]
-  (let [rh (get req-handlers (:op c))]
-    (rh actx c)))
-
-(defn cmd-handler [c] (assoc c :rq #(req-handler % c)))
+(defn cmd-handler [c] (assoc c :rq #((get req-handlers (:op c)) % c)))

 (defn make-t2-cmd-handlers []
   (into {} (map (fn [k] [k cmd-handler]) (keys req-handlers))))


raw envs

raw envs

--- src/ci3/agent/core.clj
+++ src/ci3/agent/core.clj
@@ -187,11 +187,12 @@

 (defn run [& [arg]]
   (u/*apply
-   [::e/raw-env
+   [::e/env
     ::get-build
     ::get-repository
     ::checkout-project
     ::get-build-config
+    ::e/raw-env
     ::run-build
     ::catch-errors {::u/intercept :all}]
    arg))


make backup optional

make backup optional

--- src/clj/ceres/core.clj
+++ src/clj/ceres/core.clj
@@ -148,7 +148,8 @@
     (run-server (site #'all-routes) {:port (:port @server-state) :join? false}))
   (let [{:keys [follow track handler credentials]} (:app @server-state)]
     (start-filter-stream follow track handler credentials))
-  (start-executor (:backup-folder @server-state))
+  (when (:backup? @server-state)
+    (start-executor (:backup-folder @server-state)))
   )

@@ -170,4 +171,7 @@

   (stop-server)

+  @server-state
+
+
   )


Added TODO note for generalizing function.

--- src/cmr/ous/common.clj
+++ src/cmr/ous/common.clj
@@ -185,6 +185,9 @@
           (apply errors/collect urls))
         (map #(str % "." (:format params) query-string) urls)))))

+;; XXX This function is nearly identical to one of the same name in
+;;     cmr.sizing.core -- we should put this somewhere both can use,
+;;     after generalizing to take a func and the func's args ...
 (defn process-results
   ([results start errs]
    (process-results results start errs {:warnings nil}))
@@ -204,7 +207,7 @@
          (do
            (log/debug "Generated URLs:" (vec urls-or-errs))
            (results/create urls-or-errs :elapsed (util/timed start)
-                                         :warnings warns)))))))
+                                        :warnings warns)))))))

 (defn apply-bounding-conditions
   "This function is where variable queries to the CMR are made. There are


Name default ClojureScript resolver

Name default ClojureScript resolver

--- src/aero/core.cljc
+++ src/aero/core.cljc
@@ -148,15 +148,17 @@
                        include)]
        (if (string? include)
          (relative-resolver source include)
-         include))))
+         include)))
+   :cljs
+   (defn adaptive-resolver [source include]
+     (if (path/isAbsolute include)
+       include
+       (path/join source ".." include))))
+

 (def default-opts
   {:profile :default
-   :resolver #?(:clj adaptive-resolver
-                :cljs (fn [source include]
-                        (if (path/isAbsolute include)
-                          include
-                          (path/join source ".." include))))})
+   :resolver adaptive-resolver})

 ;; The rationale for deferreds is to realise some values after the
 ;; config has been read. This allows certain expensive operations to


core: test

core: test

--- core/data/core.clj
+++ core/data/core.clj
@@ -2522,6 +2522,16 @@
      `(when-not ~x
         (throw (ex-info (str "Assert failed: " ~message "\n" '~x)))))))

+(defn test
+  "test [v] finds fn at key :test in var metadata and calls it,
+  presuming failure will throw exception"
+  {:added "1.0"}
+  [v]
+  (let [f (:test (meta v))]
+    (if f
+      (do (f) :ok)
+      :no-test)))
+
 (defmacro defn-
   "same as defn, yielding non-public def"
   {:added "1.0"}


Specify event type

Specify event type

--- ajax-core-async/src/cljs/ajax_core_async/core.cljs
+++ ajax-core-async/src/cljs/ajax_core_async/core.cljs
@@ -1,6 +1,7 @@
 (ns ajax-core-async.core
   (:require-macros [cljs.core.async.macros :refer [go]])
   (:require [goog.events :as events]
+            [goog.events.EventType :as EventType]
             [goog.dom :as dom]
             [cljs.core.async :refer [<! put! chan]])
   (:import goog.History
@@ -54,7 +55,7 @@
 (defn main []
   (set-html! (dom/getElement "app") home-html)

-  (let [clicks (listen (dom/getElement "searchbutton") (.-CLICK events/EventType))]
+  (let [clicks (listen (dom/getElement "searchbutton") EventType/CLICK)]
     (handle-search-button-click clicks)))


Hack to add more experiment options.

Hack to add more experiment options.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -87,7 +87,9 @@
           proc-fn (create-proc-fn sample-pcap-processing-definition-json)
           fn-mapping (:fn-mapping options)
           pipeline-length (:pipeline-length options)
-          pipeline (if (not (nil? in-data))
+          pipeline (if (and
+                         (not (nil? in-data))
+                         (not= scenario "pcap-direct"))
                      (create-local-processing-pipeline
                        (condp = scenario
                          "no-op" (create-no-op-proc-fns pipeline-length)
@@ -98,14 +100,18 @@
                                            sample-pcap-processing-definition-json)
                          )
                        out-fn))
-          in-fn (if (not (nil? in-data))
-                  (get-in-fn pipeline))
+          in-fn (cond
+                  (nil? in-data) (fn [] (.inc in-cntr))
+                  (= scenario "pcap-direct") (fn []
+                                               (proc-fn in-data)
+                                               (.inc in-cntr))
+                  :default (get-in-fn pipeline))
           in-loop (ProcessingLoop.
                     "InLoop"
                     (if (not (nil? in-data))
                       (fn []
                         (doseq [i (repeat 1000 0)]
-                          (in-fn in-data)
+                          (in-fn)
                           (.inc in-cntr))
                         (sleep 1))
                       (fn []
@@ -113,15 +119,15 @@
           thread-info-fn (create-thread-info-fn)
           stats-fn (fn []
                      (let [in (double (/ (.value in-cntr) 1000.0))
-                           out (double (/ (.value out-cntr) 1000.0))
-                           pe-counts (get-counts pipeline)]
+                           out (double (/ (.value out-cntr) 1000.0))]
                        (println
                          "time-delta:" (delta-cntr :time (System/currentTimeMillis)) "ms;"
                          "in:" in "k;"
                          "out:" out "k;"
                          "in-delta:" (delta-cntr :in in) "k/s;"
                          "out-delta:" (delta-cntr :out out) "k/s;")
-                       (println pe-counts)))]
+                       (if (not (nil? pipeline))
+                         (println (get-counts pipeline)))))]
       (println "Starting experiment...")
       (.setName (Thread/currentThread) "Main")
       (.start in-loop)


Fix parser helper spec.

Fix parser helper spec.

--- spec/incise/parsers/helpers_spec.clj
+++ spec/incise/parsers/helpers_spec.clj
@@ -9,20 +9,20 @@
   (it "handles empty dates well"
     (should= "" (date-str->path "")))
   (it "basically works"
-    (should= "/2013/8/12" (date-str->path "2013-08-12"))))
+    (should= "2013/8/12/" (date-str->path "2013-08-12"))))

 (describe "Parse->path"
   (it "works with dated parses"
-    (should= "/2013/8/12/something-about-binding-pry/index.html"
+    (should= "2013/8/12/something-about-binding-pry/index.html"
              (Parse->path (map->Parse {:title "Something about binding.pry"
                                        :date "2013-8-12"
                                        :extension "/index.html"}))))
   (it "works with undated parses"
-    (should= "/run-a-muck/index.html"
+    (should= "run-a-muck/index.html"
              (Parse->path (map->Parse {:title "Run a Muck"
                                        :date ""
                                        :extension "/index.html"})))
-    (should= "/nilnilnil/index.html"
+    (should= "nilnilnil/index.html"
              (Parse->path (map->Parse {:title "NilNilNil"
                                        :date nil
                                        :extension "/index.html"})))))


Example of combining sequential swap!s

Example of combining sequential swap!s

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -51,13 +51,15 @@
   {"ago"
    {:beg (fn [vis actx args]
            (let [[child-actx] args]
-             (swap! vis #(assoc-in % [:actxs child-actx]
-                                   {:children {} :wait-chs {}}))
-             (swap! vis #(assoc-in % [:actxs actx :children child-actx] true))))
+             (swap! vis #(-> %
+                             (assoc-in [:actxs child-actx]
+                                       {:children {} :wait-chs {}})
+                             (assoc-in [:actxs actx :children child-actx] true)))))
     :end (fn [vis actx args]
            (let [[child-actx result] args]
-             (swap! vis #(dissoc-in % [:actxs child-actx]))
-             (swap! vis #(dissoc-in % [:actxs actx :children child-actx]))))}
+             (swap! vis #(-> %
+                             (dissoc-in [:actxs child-actx])
+                             (dissoc-in [:actxs actx :children child-actx])))))}
    "aclose"
    {:beg (fn [vis actx args]
            (let [[ch] args] 1))


Whitespace.

Whitespace.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -162,8 +162,6 @@
                                           "]"]
              :default [name " " (if val val "nil")]))))

-;; ------------------------------------------------
-
 (defn vis-html-actx [vis actx positions actx-ch-ch-infos]
   (let [actx-id (last actx)
         actx-info (get-in vis [:actxs actx])
@@ -185,6 +183,8 @@
                    (sort #(compare (last %1) (last %2)) (keys children)))
       "
"]
      "
"]))
+
+;; ------------------------------------------------

 (defn vis-svg-actxs [vis positions deltas phase]
   (let [stroke-width 1
@@ -266,8 +266,7 @@
         step-ch (chan)
         last-id (atom 0)
         gen-id #(swap! last-id inc)
-        w [{:gen-id gen-id
-            :event-ch event-ch}]
+        w [{:gen-id gen-id :event-ch event-ch}]
         root-actx (atom nil)
         vis (atom {:actxs {} ; {actx -> {:children {child-actx -> true},
                              ;           :wait-chs {ch -> [:take|:put optional-ch-name])},


use broker meta to get new brokers

use broker meta to get new brokers

--- kafka-clj/src/kafka_clj/client.clj
+++ kafka-clj/src/kafka_clj/client.clj
@@ -333,15 +333,20 @@
                                                  m))))

         ;from the producers-ref if any new brokers add them to the metadata-producers-ref
+        ;this will only include
         update-metadata-producers (fn []
                                     (let [producers (-> producer-ref deref vals flatten distinct)
                                           metadata-producer-map (reduce (fn [m {:keys [host port]}] (assoc m {:host host :port port} producer)) {} @metadata-producers-ref)

-                                          new-meta-producers (reduce (fn [m {:keys [host port]}]
-                                                                       (if-not (get metadata-producer-map {:host host :port port})
-                                                                         (assoc m {:host host :port port} (metadata-request-producer host port conf))
-                                                                         m)) {} (map deref producers))]
-                                      (dosync (alter metadata-producers-ref (fn [coll] (apply conj coll (vals new-meta-producers)))))))
+                                          new-meta-producers (reduce
+                                                               (fn [m {:keys [host port]}]
+                                                                 (if-not (get metadata-producer-map {:host host :port port})
+                                                                   (assoc m {:host host :port port} (metadata-request-producer host port conf))
+                                                                   m))
+                                                                     {}
+                                                                     (-> brokers-metadata deref vals flatten))]
+                                      (dosync (alter metadata-producers-ref (fn [coll]
+                                                                              (apply conj coll (vals new-meta-producers)))))))

         ;try each metadata-producer-ref entry in search of metadata
         ;update the producers (ref) with the new metadata found


Start making more notes about what in this NS is useful and what might need removing/refactoring. Add a function that returns the file listing we need for the postgres backend.

--- src/doctopus/files.clj
+++ src/doctopus/files.clj
@@ -13,13 +13,13 @@

 (defn filter-files
-  "Vector Triple of (path, directories, files), and function that filters relevant doc-types"
+  "Vector Triple of (path, directories, files), and function that filters
+  relevant doc-types"
   [path-listing doc-type-fn]
   (into [] (for [[path directory files] path-listing
                  :let [found-files (filter doc-type-fn files)]
                  :when (not-empty found-files)]
              [path found-files])))
-

 (declare truncate-str)
 (defn assemble-file-filter-results
@@ -29,7 +29,7 @@
              (for [matched-file matched-files]
                (fs/file path matched-file)))))

-
+;; Yes yes yes. Super good.
 (defn truncate-str
   "Given a fully qualified root directory, correctly return the path, relative
   to a given root. I.E: given /foo/bar/baz and root baz, return /;
@@ -43,20 +43,23 @@
       "/"
       (last (clojure.string/split fq-path-string splitting-regex)))))

+;; Cannot remember why we did this.
 (defn set-ext
   "For a given file with extension foo.bar, set extension to .html"
   [strang]
   (clojure.string/replace strang #"\.(\w+)$" ".html"))

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

+;; Almost certainly deprecated
 (defn htmlify
   "Ingests a path. Turns the contents in to html, truncates the path, returns
   the pair."
@@ -66,6 +69,7 @@
         htmlified-path (set-ext truncated-path)]
     [html htmlified-path]))

+;; Probably also deprecated? Or, part of the md parser?
 (defn write-doc
   "This is prooooooobably not how we wanna do this f'reals?"
   [[html rel-path] target-dir]
@@ -75,8 +79,9 @@
     (spit output-file html)))

-;; This cool dood needs to be changed to use the new storage
-;; backend... eventually. Or it needs to be removed? Unclear.
+;; This cool dood needs to be changed to use the new storage backend...
+;; eventually. Or it needs to be removed? Unclear. Maybe useful for the markdown
+;; parser too.
 (defn read-and-write-dir
   "Searches a source dir for all files that match a given predicate.

@@ -91,11 +96,22 @@
       (write-doc html-relpath-pair target-dir)
       )))

+;; Hrmmmmmmm. Could be useful for our markdown parser?
 (defn read-html
   "Reads a directory structure looking for html; returns the result as a vector
   of relative path-html"
   [src-dir]
   (let [docs (walk-docs-dir src-dir html?)]
     (into [] (for [doc docs
-           :let [[html rel-path] (htmlify doc src-dir identity)]] ;; Is this a hack? WHY YES IT IS.
+                   :let [[html rel-path] (htmlify doc src-dir identity)]] ;; Is this a hack? WHY YES IT IS.
                [rel-path html]))))
+
+
+(defn list-files-with-relative-paths
+  "Given a directory, list the contents as pairs of:
+  [path-relative-to-root file-handle]"
+  [root]
+  (let [all-files (walk-docs-dir root)]
+    (for [found-file all-files
+          :let [rel-path (truncate-str found-file root)]]
+      [rel-path found-file])))


Add skip option to example dev

Add skip option to example dev

for testing

--- example/build.boot
+++ example/build.boot
@@ -8,9 +8,10 @@
   '[afrey.boot-asset-fingerprint :refer [asset-fingerprint]]
   '[tailrecursion.boot-jetty :as jetty])

-(deftask dev []
+(deftask dev
+  [s skip bool]
   (comp
     (watch)
-    (asset-fingerprint :extensions [".css" ".html"])
+    (asset-fingerprint :extensions [".css" ".html"] :skip skip)
     (jetty/serve :port 5000)
     (target)))


要把这个授权策略 AliyunSTSAssumeRoleAccess 给到授权的那个用户。

--- src/aliyun_oss_clj/core.clj
+++ src/aliyun_oss_clj/core.clj
@@ -1,19 +1,41 @@
 (ns aliyun-oss-clj.core
   (:import
-   [java.io
-    BufferedReader
-    ByteArrayInputStream
-    File
-    InputStream
-    InputStreamReader]
-   [java.util.List]
-   [java.net.URLClassLoader]
-   [com.aliyun.oss
-    ClientException
-    OSSClient
-    OSSException]
-   [com.aliyun.oss.model
-    BucketInfo
-    OSSObject
-    OSSObjectSummary
-    ObjectListing]))
+   [com.aliyuncs DefaultAcsClient]
+   [com.aliyuncs.exceptions.ClientException]
+   [com.aliyuncs.http MethodType ProtocolType]
+   [com.aliyuncs.profile DefaultProfile IClientProfile]
+   [com.aliyuncs.sts.model.v20150401 AssumeRoleRequest AssumeRoleResponse]))
+
+(def config
+  (:aliyun-oss-ram-config
+   (read-string (slurp "config/config.clj"))))
+
+(def REGION_CN_HANGZHOU (:region config))
+(def STS_API_VERSION "2015-04-01")
+(def accessKeyId (:accessKeyId config))
+(def accessKeySecret (:accessKeySecret config))
+(def roleArn (:rolearn config))
+(def roleSessionName (:roleSessionName config))
+(def protocolType ProtocolType/HTTPS)
+(def policy (:policy config))
+
+;;(assumeRole accessKeyId accessKeySecret roleArn roleSessionName policy protocolType)
+;;=> #object[com.aliyuncs.sts.model.v20150401.AssumeRoleResponse 0x51902f96 "com.aliyuncs.sts.model.v20150401.AssumeRoleResponse@51902f96"]
+(defn assumeRole
+  [^String accessKeyId ^String accessKeySecret
+   ^String roleArn ^String roleSessionName ^String policy
+   ^ProtocolType protocolType]
+  (let [profile (DefaultProfile/getProfile REGION_CN_HANGZHOU accessKeyId accessKeySecret)
+        client (DefaultAcsClient. profile)
+        request (AssumeRoleRequest.)
+        _ (.setVersion request STS_API_VERSION)
+        _ (.setMethod request MethodType/POST)
+        _ (.setProtocol request protocolType)
+        _ (.setRoleArn request roleArn)
+        _ (.setRoleSessionName request roleSessionName)
+        _ (.setPolicy request policy)]
+    (.getAcsResponse client request)
+    )
+  )
+
+


Setting freactive-state on root nodes so that they can be unmounted properly. WIP on more generic as-velem to support scoped plugins.

--- src/freactive/dom.cljs
+++ src/freactive/dom.cljs
@@ -246,6 +246,7 @@
     :default (.toString value)))

 (defn- set-attr! [element attr-name attr-value]
+  ;; (println "setting attr" element attr-name attr-value)
   (if attr-value
     (.setAttribute element attr-name (normalize-attr-value attr-value))
     (.removeAttribute element attr-name)))
@@ -287,7 +288,9 @@
   ((EventBinding. node (name event-name) nil) handler))

 (defn- do-bind-attr [setter val]
-  (r/bind-attr* val setter queue-animation))
+  (let [binding
+        (r/bind-attr* val setter queue-animation)]
+    binding))

 (defn- bind-style! [node style-kw style-val]
   (let [style-name (name style-kw)]
@@ -324,7 +327,9 @@

 ;; attributes to set directly
 (doseq [a #js ["id" "value"]]
-  (aset attr-setters a (fn [e v] (aset e a v))))
+  (aset attr-setters a
+        (fn [e v]
+          (aset e a v))))

 (defn- get-attr-setter [element attr-name]
   (if-let [setter (aget attr-setters attr-name)]
@@ -334,7 +339,6 @@

 (defn- get-ns-attr-setter [element attr-ns attr-name]
   (fn [attr-value]
-      ;(println "setting attr" element attr-name attr-value)
       (if attr-value
         (.setAttributeNS element attr-ns attr-name
           (normalize-attr-value attr-value))
@@ -551,6 +555,58 @@

 (declare dom-element)

+(defn- as-velem* [{:keys [node-ns-lookup attr-ns-lookup]}]
+  (fn [elem-spec]
+    (cond
+      (string? elem-spec)
+      (DOMTextNode. elem-spec nil nil)
+
+      (dom-node? elem-spec)
+      (if-let [state (get-element-state elem-spec)]
+        state
+        (UnmanagedDOMNode. elem-spec nil nil))
+
+      (sequential? elem-spec)
+      (let [head (first elem-spec)]
+        (cond
+          (keyword? head)
+          (let [tag-ns (namespace head)
+                tag-name (name head)
+                tail (rest elem-spec)]
+            (if tag-ns
+              (if-let [tag-handler (aget node-ns-lookup tag-ns)]
+                (cond
+                  (string? tag-handler)
+                  (dom-element tag-handler tag-name tail)
+
+                  (ifn? tag-handler)
+                  (as-velem (tag-handler tag-name tail))
+
+                  :default
+                  (.warn js/console "Invalid ns node handler" tag-handler))
+                (.warn js/console "Undefined ns node prefix" tag-ns))
+              (dom-element nil tag-name tail)))
+
+          (and (ifn? head) (not (sequential? head)))
+          (as-velem (r/rx* (fn [] (apply head (rest elem-spec)))))
+
+          :default
+          (as-velem (r/seq-projection elem-spec))))
+
+      (satisfies? IDeref elem-spec)
+      (ui/reactive-element elem-spec as-velem queue-animation)
+
+      (satisfies? ui/IVirtualElement elem-spec)
+      elem-spec
+
+      (satisfies? r/IProjection elem-spec)
+      (ui/reactive-element-sequence elem-spec as-velem queue-animation)
+
+      (satisfies? r/IAsVirtualElement elem-spec)
+      (as-velem (r/-as-velem elem-spec as-velem))
+
+      :default (as-velem (-get-dom-image elem-spec)))))
+
 (defn- as-velem [elem-spec]
   (cond
     (string? elem-spec)
@@ -696,6 +752,7 @@
                      root-node
                      nil
                      (bind-attrs! root-node {}))]
+          (set! (.-freactive-state root-node) vroot)
           (configure-root! vroot vdom))))
     root-node))


sequential downloads

sequential downloads

--- src/frontend/core.cljs
+++ src/frontend/core.cljs
@@ -16,7 +16,8 @@
                           :current-track-id nil
                           :current-sound nil
                           :ball-being-dragged? false
-                          :play-next-upload? false}))
+                          :play-next-upload? false
+                          :num-of-queued-download-requests 0}))

 (enable-console-print!)

@@ -140,12 +141,27 @@
       (do
         (.emit socket "file-download-request" (.-id music-info))
         (swap! app-state assoc :current-track-id (.-id music-info))
-        (swap! app-state assoc :play-next-upload? false)))))
+        (swap! app-state assoc :play-next-upload? false))
+      (do
+        (swap! app-state assoc :num-of-queued-download-requests
+          (+ 1 (:num-of-queued-download-requests @app-state)))
+        (if-not (:is-file-downloading? @app-state)
+          (let [next-track-num (+ 1 (.-tracknum (nth (filter #(= (.-id %1)
+                                                                 (:current-track-id @app-state))
+                                                      (:music-info @app-state)) 0)))]
+            (if (< next-track-num (count (:music-info @app-state)))
+              (.emit socket "file-download-request" (.-id (nth (:music-info @app-state)
+                                                               next-track-num))))))))))

 (.on (new js/ss socket) "file-download"
   (fn [stream track-id file-size]
     (println "Download starting!")
+
     (swap! app-state assoc :is-file-downloading? true)
+    (if (> (:num-of-queued-download-requests @app-state) 0)
+      (swap! app-state assoc :num-of-queued-download-requests
+        (- 1 (:num-of-queued-download-requests @app-state))))
+
     (.on stream "data"
       (fn [data-chunk]
         (let [size (+ (.-length data-chunk) (:data-downloaded @app-state))]
@@ -162,7 +178,7 @@
     (.on stream "end"
       (fn []
         (println "Download complete!")
-        (swap! app-state assoc :is-file-downloading? true)
+        (swap! app-state assoc :is-file-downloading? false)
         (swap! app-state assoc :download-progress nil)
         (swap! app-state assoc :data-downloaded 0)


Minor cosmetic improvements.

Minor cosmetic improvements.

--- src/futura/promise.clj
+++ src/futura/promise.clj
@@ -155,7 +155,6 @@

 (alter-meta! #'->Promise assoc :private true)

-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Public Api
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -166,12 +165,11 @@
 (defmulti ^:no-doc promise* class)

 (defmethod promise* clojure.lang.IFn
-  [func]
+  [factory]
   (let [futura (CompletableFuture.)
-        promise (Promise. futura)
-        callback #(deliver promise %)]
+        promise (Promise. futura)]
     (try
-      (func callback)
+      (factory #(deliver promise %))
       (catch Throwable e
         (.completeExceptionally futura e)))
     promise))
@@ -215,7 +213,7 @@

   - throwable
   - plain value
-  - function / callable
+  - factory function

   In case of the initial value is instance of `Throwable`, rejected
   promise will be retrned. In case of a plain value (not throwable),
@@ -223,16 +221,15 @@
   or any callable is provided, that function will be executed with
   one argument as callback for mark the promise resolved or rejected.

-      (promise (fn [complete]
+      (promise (fn [deliver]
                  (future
                    (Thread/sleep 200)
-                   (complete 1))))
+                   (deliver 1))))

   The body of that function can be asynchronous and the promise can
   be freely resolved in other thread."
   ([] (promise* nil))
   ([v] (promise* v)))
-

 (defn promise?
   "Returns true if `p` is a promise


Edited the ontology id denotes concept gen rule

Add description to rule, changed variable name to be more explicit, and
exclude root concepts from being acted on by the rule.

--- kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_ice/step_b/ontology_id_denotes_concept_gen.clj
+++ kabob-build/src/main/resources/edu/ucdenver/ccp/kabob/build/rules/bio_to_ice/step_b/ontology_id_denotes_concept_gen.clj
@@ -3,14 +3,18 @@
 ;; ------------------------------------------------------------------------
 ;; create id denotes concept triple for every ontology concept
 `{:name "ontology-id-denotes-concept-gen"
-  :head ((?/id obo/IAO_0000219 ?/sc) ; denotes
+  :description "This rule generates an ontology concept identifier for every non-root ontology concept."
+  :head ((?/id obo/IAO_0000219 ?/ontology_concept) ; denotes
          (?/id rdf/type ccp/IAO_EXT_0000088)) ; ontology concept identifier
+  :reify ([?/id {:ln (:localname ?/ontology_concept)
+                 :ns "ccp" :prefix "" :suffix ""}])
   :sparql-string "prefix ccp: <http://ccp.ucdenver.edu/obo/ext/>
                   prefix obo: <http://purl.obolibrary.org/obo/>
-                  select ?sc {
-                  ?root_id rdf:type ccp:IAO_EXT_0000190 .
-                  ?root_id obo:IAO_0000219 ?root_class .
-                  ?sc rdfs:subClassOf* ?root_class .
+                  select ?ontology_concept {
+                  ?root_id rdf:type ccp:IAO_EXT_0000190 . # ccp:ontology root concept identifier
+                  ?root_id obo:IAO_0000219 ?root_class . # obo:denotes
+                  ?ontology_concept rdfs:subClassOf* ?root_class .
+                  minus {?ontology_concept owl:deprecated true} .
+                  minus {?ontology_concept rdf:type ccp:IAO_EXT_0000190} # ccp:ontology root concept identifier
                   }"
-  :reify ([?/id {:ln (:localname ?/sc)
-                 :ns "ccp" :prefix "" :suffix ""}])}+  }


Adjust radius function to be "dual" of location

The radius of a node should be inversely proportional to the "density"
of space around the node. For example, if one node is in an area of the
screen such that a pixel represents twice as much length, then the node
should have half the radius.

To enable this, the radius function should be equal to the derivative of
the space function at each point. We choose a function that approximates
this derivative.


Remove assers on route building process.

--- src/bide/core.cljs
+++ src/bide/core.cljs
@@ -92,10 +92,9 @@
   [routes]
   {:pre [(vector? routes)]}
   (reduce (fn [router [path name]]
-            (assert (string? path) "path should be string")
-            (assert (keyword? name) "name should be keyword")
             (rtr/insert router path name))
-          (rtr/empty) routes))
+          (rtr/empty)
+          routes))

 (defn- adapt-params
   [params]


Rename program to id->node. Add interactive step.

--- src/aurora/interpreter.cljs
+++ src/aurora/interpreter.cljs
@@ -9,7 +9,7 @@

 (defrecord Cursor [path value])

-(defn run-pipe [program node inputs output stack]
+(defn run-pipe [id->node node inputs output stack]
   (let [vars #js {}
         calls #js []
         frame #js {:id (:id node) :vars vars :calls calls}]
@@ -19,85 +19,85 @@
       (aset vars id value))
     (doseq [{:keys [id inputs node]} (:nodes node)]
       (assert (not= :pipe (:type node)) "No inline pipes")
-      (aset vars id (run-node program node (map #(aget vars %) inputs) output calls))) ; note calls, not stack
+      (aset vars id (run-node id->node node (map #(aget vars %) inputs) output calls))) ; note calls, not stack
     (let [result (aget vars (-> node :nodes last :id))]
       (aset frame "result" result) ; return
       result)))

-(defn run-node [program node inputs output stack]
+(defn run-node [id->node node inputs output stack]
   (case (:type node)
-    :return (run-return program node inputs output stack)
-    :data (run-data program node inputs output stack)
-    :ref (run-ref program node inputs output stack)
-    :match (run-match program node inputs output stack)
-    :replace (run-replace program node inputs output stack)
-    :output (run-output program node inputs output stack)))
-
-(defn run-return [program node inputs output stack]
+    :return (run-return id->node node inputs output stack)
+    :data (run-data id->node node inputs output stack)
+    :ref (run-ref id->node node inputs output stack)
+    :match (run-match id->node node inputs output stack)
+    :replace (run-replace id->node node inputs output stack)
+    :output (run-output id->node node inputs output stack)))
+
+(defn run-return [id->node node inputs output stack]
   (assert (= 1 (count inputs)))
   (first inputs))

-(defn run-data [program node inputs output stack]
+(defn run-data [id->node node inputs output stack]
   (assert (empty? inputs))
-  (Cursor. [] (run-data* program node inputs output stack)))
-
-(defn run-data* [program node inputs output stack]
+  (Cursor. [] (run-data* id->node node inputs output stack)))
+
+(defn run-data* [id->node node inputs output stack]
   (case (:kind node)
     :value (:value node)
     :vector (into []
                   (for [value (:value node)]
-                    (run-data* program value inputs output stack)))
+                    (run-data* id->node value inputs output stack)))
     :map (into {}
                (for [[key value] (:value node)]
-                 [(run-data* program key inputs output stack) (run-data* program value inputs output stack)]))))
-
-(defn run-ref [program node inputs output stack]
+                 [(run-data* id->node key inputs output stack) (run-data* id->node value inputs output stack)]))))
+
+(defn run-ref [id->node node inputs output stack]
   (case (:kind node)
     :cljs (Cursor. [] (apply (:fn node) (map :value inputs)))
-    :pipe (run-pipe program (get program (:id node)) inputs output stack)))
+    :pipe (run-pipe id->node (get id->node (:id node)) inputs output stack)))

 (defrecord MatchFailure [])

 (defn check [bool]
   (when-not bool (throw (MatchFailure.))))

-(defn run-match [program node inputs output stack]
+(defn run-match [id->node node inputs output stack]
   (assert (= 1 (count inputs)))
   (let [input (first inputs)]
     (loop [branches (:branches node)]
       (if-let [[{:keys [pattern inputs node]} & branches] (seq branches)]
         (try
           (let [vars #js {}]
-            (run-match-pattern program pattern (:path input) (:value input) output stack vars)
-            (run-node program node (map #(aget vars %) inputs) output stack))
+            (run-match-pattern id->node pattern (:path input) (:value input) output stack vars)
+            (run-node id->node node (map #(aget vars %) inputs) output stack))
           (catch MatchFailure _
             (recur branches)))
         (throw (MatchFailure.))))))

-(defn run-match-pattern [program pattern input-path input-value output stack vars]
+(defn run-match-pattern [id->node pattern input-path input-value output stack vars]
   (condp = (:type pattern)
     :match/any nil
     :match/bind (do (aset vars (:var pattern) (Cursor. input-path input-value))
-                  (run-match-pattern program (:pattern pattern) input-path input-value output stack vars))
+                  (run-match-pattern id->node (:pattern pattern) input-path input-value output stack vars))
     :data (case (:kind pattern)
             :value (check (= input-value (:value pattern)))
             :vector (let [value (:value pattern)]
                       (check (vector? input-value))
                       (check (= (count input-value) (count value)))
                       (dotimes [i (count value)]
-                        (run-match-pattern program (nth value i) (conj input-path i) (nth input-value i) output stack vars)))
+                        (run-match-pattern id->node (nth value i) (conj input-path i) (nth input-value i) output stack vars)))
             :map (let [value (:value pattern)]
                    (check (map? input-value))
                    (doseq [key-pattern (keys value)]
                      (let [key (:value key-pattern)]
                        (check (contains? input-value key))
-                       (run-match-pattern program (get value key-pattern) (conj input-path key) (get input-value key) output stack vars)))))
-    (check (:value (run-node program pattern [(Cursor. input-path input-value)] output stack)))))
-
-(defn run-replace [program node inputs output stack]
+                       (run-match-pattern id->node (get value key-pattern) (conj input-path key) (get input-value key) output stack vars)))))
+    (check (:value (run-node id->node pattern [(Cursor. input-path input-value)] output stack)))))
+
+(defn run-replace [id->node node inputs output stack]
   (swap! output assoc-in (:path (first inputs)) (:value (second inputs))))

-(defn run-output [program node inputs output stack]
+(defn run-output [id->node node inputs output stack]
   (swap! output update-in (:path node) cons (:value (first inputs))))

 (assoc-in {} [] :foo)
@@ -196,13 +196,21 @@
           "c+1" ["c" "one"] (cljs-ref +)
           "nil" ["c" "c+1"] replace)})

-(defn run-example [example input]
+(defn run-example [example this-state]
   (let [stack #js []
-        program (into {} (for [pipe example] [(:id pipe) pipe]))
-        output (atom input)]
+        id->node (into {} (for [pipe example] [(:id pipe) pipe]))
+        next-state (atom state)
+        result (run-pipe id->node (get id->node "root") [(Cursor. [] this-state)] next-state stack)]
     (try
-      [(run-pipe program (get program "root") [(Cursor. [] input)] output stack) @output (aget stack 0)]
-      (catch :default e [e @output (aget stack 0)]))))
+      [result @next-state (aget stack 0)]
+      (catch :default exception
+        [exception @next-state (aget stack 0)]))))
+
+(defn step-example [example watchers input]
+  (let [[_ output _] (run-example example input)]
+    (doseq [watcher watchers]
+      (watcher (:output output)))
+    (dissoc output :output)))

 (run-example example-b {"a" 1 "b" 2})
 (run-example example-b {"a" 1 "c" 2})
@@ -216,6 +224,10 @@
 (run-example example-c 10)

 (run-example example-d {"counter" 0})
+
+(step-example example-d [] {"counter" 0})
+
+(take 10 (iterate #(step-example example-d [] %) {"counter" 0}))

 (defn print-stack
   ([frame]


Prevent error when there are no more inactive quests

--- src/braid/client/quests/helpers.cljs
+++ src/braid/client/quests/helpers.cljs
@@ -17,11 +17,12 @@
   (assoc-in state [:quests quest-id :state] :skipped))

 (defn activate-next-quest [state]
-  (let [quest-id-to-activate (->> state
-                                  :quests
-                                  vals
-                                  (filter (fn [quest]
-                                            (= (quest :state) :inactive)))
-                                  first
-                                  :id)]
-    (assoc-in state [:quests quest-id-to-activate :state] :active)))
+  (let [quest-to-activate (->> state
+                               :quests
+                               vals
+                               (filter (fn [quest]
+                                         (= (quest :state) :inactive)))
+                               first)]
+    (if quest-to-activate
+      (assoc-in state [:quests (quest-to-activate :id) :state] :active)
+      state)))


remember original-input for logging

remember original-input for logging

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -4,8 +4,9 @@
   (:refer-clojure)
   (:require
    [babel.exception :refer [exception]]
+   #?(:cljs [babel.logjs :as log])
    #?(:clj [clojure.tools.logging :as log])
-   #?(:cljs [babel.logjs :as log])))
+   [dag_unify.core :refer [strip-refs]]))

 (def encyc
   {
@@ -32,220 +33,223 @@

 (defn null-sem-impl [input]
   "null sem-impl: simply return input."
+  (log/trace (str "null-sem-impl:" (strip-refs input)))
   input)

-(defn sem-impl [input]
+(defn sem-impl [input & [original-input]]
   "expand input feature structures with semantic (really cultural) implicatures, e.g., if human, then not buyable or edible"
-  (cond
-   (= input :top) input
-   true
-   (let [activity (if (= (get-in input '(:activity))
+  (let [original-input (if original-input original-input
+                           (do
+                             (log/debug (str "original call of sem-impl: (" (get-in input [:pred]) ")" (strip-refs input)))
+                             input))]
+    (cond
+      (= input :top) input
+      true
+      (let [activity (if (= (get-in input '(:activity))
+                            true)
+                       {:animate false
+                        :artifact false
+                        :consumable false
+                        :part-of-human-body false})
+            animate (if (= (get-in input '(:animate))
+                           true)
+                      {:activity false
+                       :artifact false
+                       :mass false
+                       :furniture false
+                       :physical-object true
+                       :part-of-human-body false
+                       :drinkable false
+                       :speakable false
+                       :place false}{})
+            artifact (if (= (get-in input '(:artifact))
+                            true)
+                       {:animate false
+                        :activity false
+                        :physical-object true}{})
+
+            buyable (if (= (get-in input '(:buyable))
+                           true)
+                      {:human false
+                       :part-of-human-body false})
+
+            city (if (= (get-in input '(:city))
+                        true)
+                   {:place true
+                    :human false
+                    :animate false
+                    :legible false})
+
+            clothing (if (= (get-in input '(:clothing))
+                            true)
+                       {:animate false
+                        :place false
+                        :physical-object true}{})
+
+            consumable (if (= (get-in input '(:consumable)) true)
+                         {:activity false
+                          :buyable true
+                          :furniture false
+                          :legible false
+                          :pet false
+                          :physical-object true
+                          :speakable false})
+
+            consumable-false (if (= (get-in input '(:consumable)) false)
+                               {:drinkable false
+                                :edible false} {})
+
+            drinkable
+            ;; drinkables are always mass nouns.
+            (if (= (get-in input '(:drinkable)) true)
+              {:mass true})
+
+            drinkable-xor-edible-1
+            ;; things are either drinkable or edible, but not both (except for weird foods
+            ;; like pudding or soup). (part 1: edible)
+            (if (and (= (get-in input '(:edible)) true)
+                     (= (get-in input '(:drinkable) :notfound) :notfound))
+              {:drinkable false}{})
+
+            drinkable-xor-edible-2
+            ;; things are either drinkable or edible, but not both (except for weird foods
+            ;; like pudding or soup). (part 2: drinkable)
+            (if (and (= (get-in input '(:drinkable)) true)
+                     (= (get-in input '(:edible) :notfound) :notfound))
+              {:edible false})
+
+            ;; qualities of foods and drinks.
+            edible (if (or (= (get-in input '(:edible)) true)
+                           (= (get-in input '(:drinkable)) true))
+                     {:consumable true
+                      :human false
+                      :pet false
+                      :place false
+                      :speakable false
+                      :legible false
+                      :furniture false
+                      :part-of-human-body false}{})
+
+            furniture (if (= (get-in input '(:furniture))
+                             true)
+                        {:artifact true
+                         :animate false
+                         :buyable true
+                         :drinkable false
+                         :legible false
+                         :edible false
+                         :place false
+                         :speakable false})
+
+            human (if (= (get-in input '(:human))
                          true)
-                    {:animate false
-                     :artifact false
-                     :consumable false
-                     :part-of-human-body false})
-         animate (if (= (get-in input '(:animate))
+                    {:activity false
+                     :buyable false
+                     :physical-object true
+                     :edible false
+                     :animate true
+                     :part-of-human-body false
+                     :drinkable false
+                     :speakable false
+                     :city false
+                     :place false})
+            inanimate (if (= (get-in input '(:animate))
+                             false)
+                        {:human false})
+
+            ;; legible(x) => artifact(x),drinkable(x,false),edible(x,false),human(x,false)
+            legible
+            (if (= (get-in input '(:legible)) true)
+              {:artifact true
+               :drinkable false
+               :human false
+               :furniture false
+               :part-of-human-body false
+               :edible false})
+
+            material-false
+            (if (= (get-in input '(:material)) :false)
+              {:edible false
+               :animate false
+               :drinkable false
+               :buyable false ; money can't buy me love..
+               :visible false})
+
+            non-places (if (or
+                            (= (get-in input '(:legible)) true)
+                            (= (get-in input '(:part-of-human-body)) true)
+                            (= (get-in input '(:pred)) :fiore)
+                            (= (get-in input '(:pred)) :scala))
+                         {:place false})
+
+            ;; artifact(x,false) => legible(x,false)
+            not-legible-if-not-artifact
+            (if (= (get-in input '(:artifact)) false)
+              {:legible false})
+
+            part-of-human-body
+            (if (= (get-in input '(:part-of-human-body)) true)
+              {:speakable false
+               :buyable false
+               :animate false
+               :edible false
+               :drinkable false
+               :legible false
+               :artifact false})
+
+            ;; we don't eat pets (unless things get so desperate that they aren't pets anymore)
+            pets (if (= (get-in input '(:pet))
+                        true)
+                   {:edible false
+                    :buyable true
+                    :physical-object true
+                    })
+
+            place (if (= (get-in input '(:place))
+                         true)
+                    {:activity false
+                     :animate false
+                     :speakable false
+                     :physical-object true
+                     :drinkable false
+                     :edible false
+                     :legible false}{})
+
+            place-false (if (= (get-in input '(:place))
+                               false)
+                          {:city false})
+
+            time (if (= (get-in input [:time])
                         true)
                    {:activity false
-                    :artifact false
-                    :mass false
-                    :furniture false
+                    :animate false
+                    :city false
+                    :speakable false
                     :physical-object true
-                    :part-of-human-body false
                     :drinkable false
-                    :speakable false
-                    :place false}{})
-         artifact (if (= (get-in input '(:artifact))
-                         true)
-                    {:animate false
-                     :activity false
-                     :physical-object true}{})
-
-         buyable (if (= (get-in input '(:buyable))
-                        true)
-                   {:human false
-                    :part-of-human-body false})
-
-         city (if (= (get-in input '(:city))
-                     true)
-                {:place true
-                 :human false
-                 :animate false
-                 :legible false})
-
-         clothing (if (= (get-in input '(:clothing))
-                         true)
-                    {:animate false
-                     :place false
-                     :physical-object true}{})
-
-
-         consumable (if (= (get-in input '(:consumable)) true)
-                      {:activity false
-                       :buyable true
-                       :furniture false
-                       :legible false
-                       :pet false
-                       :physical-object true
-                       :speakable false})
-
-         consumable-false (if (= (get-in input '(:consumable)) false)
-                            {:drinkable false
-                             :edible false} {})
-
-         drinkable
-         ;; drinkables are always mass nouns.
-         (if (= (get-in input '(:drinkable)) true)
-           {:mass true})
-
-         drinkable-xor-edible-1
-         ;; things are either drinkable or edible, but not both (except for weird foods
-         ;; like pudding or soup). (part 1: edible)
-         (if (and (= (get-in input '(:edible)) true)
-                  (= (get-in input '(:drinkable) :notfound) :notfound))
-           {:drinkable false}{})
-
-         drinkable-xor-edible-2
-         ;; things are either drinkable or edible, but not both (except for weird foods
-         ;; like pudding or soup). (part 2: drinkable)
-         (if (and (= (get-in input '(:drinkable)) true)
-                  (= (get-in input '(:edible) :notfound) :notfound))
-           {:edible false})
-
-         ;; qualities of foods and drinks.
-         edible (if (or (= (get-in input '(:edible)) true)
-                        (= (get-in input '(:drinkable)) true))
-                  {:consumable true
-                   :human false
-                   :pet false
-                   :place false
-                   :speakable false
-                   :legible false
-                   :furniture false
-                   :part-of-human-body false}{})
-
-         furniture (if (= (get-in input '(:furniture))
-                          true)
-                     {:artifact true
-                      :animate false
-                      :buyable true
-                      :drinkable false
-                      :legible false
-                      :edible false
-                      :place false
-                      :speakable false})
-
-         human (if (= (get-in input '(:human))
-                      true)
-                 {:activity false
-                  :buyable false
-                  :physical-object true
-                  :edible false
-                  :animate true
-                  :part-of-human-body false
-                  :drinkable false
-                  :speakable false
-                  :city false
-                  :place false})
-         inanimate (if (= (get-in input '(:animate))
-                           false)
-                     {:human false})
-
-         ;; legible(x) => artifact(x),drinkable(x,false),edible(x,false),human(x,false)
-         legible
-         (if (= (get-in input '(:legible)) true)
-           {:artifact true
-            :drinkable false
-            :human false
-            :furniture false
-            :part-of-human-body false
-            :edible false})
-
-         material-false
-         (if (= (get-in input '(:material)) :false)
-           {:edible false
-            :animate false
-            :drinkable false
-            :buyable false ; money can't buy me love..
-            :visible false})
-
-         non-places (if (or
-                         (= (get-in input '(:legible)) true)
-                         (= (get-in input '(:part-of-human-body)) true)
-                         (= (get-in input '(:pred)) :fiore)
-                         (= (get-in input '(:pred)) :scala))
-                   {:place false})
-
-         ;; artifact(x,false) => legible(x,false)
-         not-legible-if-not-artifact
-         (if (= (get-in input '(:artifact)) false)
-           {:legible false})
-
-         part-of-human-body
-         (if (= (get-in input '(:part-of-human-body)) true)
-           {:speakable false
-            :buyable false
-            :animate false
-            :edible false
-            :drinkable false
-            :legible false
-            :artifact false})
-
-         ;; we don't eat pets (unless things get so desperate that they aren't pets anymore)
-         pets (if (= (get-in input '(:pet))
-                     true)
-                {:edible false
-                 :buyable true
-                 :physical-object true
-                 })
-
-         place (if (= (get-in input '(:place))
-                      true)
-                 {:activity false
-                  :animate false
-                  :speakable false
-                  :physical-object true
-                  :drinkable false
-                  :edible false
-                  :legible false}{})
-
-         place-false (if (= (get-in input '(:place))
-                            false)
-                       {:city false})
-
-         time (if (= (get-in input [:time])
-                      true)
-                 {:activity false
-                  :animate false
-                  :city false
-                  :speakable false
-                  :physical-object true
-                  :drinkable false
-                  :edible false
-                  :legible false
-                  :place false})
-
-         ]
-     (let [merged
-           (cond (= input :fail) :fail
-
-                 (seq? input)
-                 (log/error (exception (str "input was unexpectedly a sequence: " input)))
-;                 (first (remove #(= {} %)
-;                                (remove #(nil? %) input)))
-
-                 true
-                 (merge input animate artifact buyable city clothing consumable consumable-false drinkable
-                        drinkable-xor-edible-1 drinkable-xor-edible-2
-                        edible furniture human inanimate
-                        legible material-false non-places
-                        not-legible-if-not-artifact part-of-human-body pets place
-                        place-false time
-                        ))]
-       (log/trace (str "sem-impl so far: " merged))
-       (if (not (= merged input)) ;; TODO: make this check more efficient: count how many rules were hit
-         ;; rather than equality-check to see if merged has changed.
-         (sem-impl merged) ;; we've added some new information: more implications possible from that.
-         merged))))) ;; no more implications: return
-
+                    :edible false
+                    :legible false
+                    :place false})
+            ]
+        (let [merged
+              (cond (= input :fail) :fail
+
+                    true
+                    (merge input animate artifact buyable city clothing consumable consumable-false drinkable
+                           drinkable-xor-edible-1 drinkable-xor-edible-2
+                           edible furniture human inanimate
+                           legible material-false non-places
+                           not-legible-if-not-artifact part-of-human-body pets place
+                           place-false time
+                           ))]
+          (log/trace (str "sem-impl so far: " merged))
+          (if (not (= merged input)) ;; TODO: make this check more efficient: count how many rules were hit
+            ;; rather than equality-check to see if merged has changed.
+            (sem-impl merged original-input) ;; we've added some new information: more implications possible from that.
+
+            ;; else, no more implications: done.
+            (do
+              (log/debug (str "sem-impl:" (strip-refs original-input) " -> " (strip-refs merged)))
+              merged)))))))
+
+


semantics of {:pred :student}

semantics of {:pred :student}

--- src/babel/encyclopedia.cljc
+++ src/babel/encyclopedia.cljc
@@ -125,7 +125,7 @@
                       :speakable false
                       :spec {:of {:animate true}}}
    ;; some places could place additional
-   ;; restrictions on owners (e.g. {:human true}).
+   ;; restrictions on owners (e.g. {:of {:human true}}).

    ;; <preds>
    {:pred :bag}      {:artifact true
@@ -161,6 +161,7 @@

    {:pred :name}     {:physical-object false
                       :event false}
+   {:pred :student}  {:human true}

    ;; </preds>


first draft

first draft

calling it foldseq since it only works on sequences for now


Remove monad transformers stuff from `cats.core` ns.

--- src/cats/core.cljc
+++ src/cats/core.cljc
@@ -215,12 +215,6 @@
    (when (not b) mv))
   ([ctx b mv]
    (when ctx (not b) mv)))
-
-(defn lift
-  "Lift a value from the inner monad of a monad transformer
-  into a value of the monad transformer."
-  ([mv] (p/-lift ctx/*context* mv))
-  ([m mv] (p/-lift m mv)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Monadic Let Macro


selection movement after node deletion should be structural

--- cljs/src/main/plastic/cogs/editor/ops/editing.cljs
+++ cljs/src/main/plastic/cogs/editor/ops/editing.cljs
@@ -9,7 +9,7 @@
             [rewrite-clj.zip :as zip]))

 (defn select-next-candidate-for-case-of-selected-node-removal [editor]
-  (selection/apply-move-selection editor :spatial-left :spatial-right :structural-up))
+  (selection/apply-move-selection editor :structural-left :structural-right :structural-up))

 (defn get-selected-node-id [editor]
   (first (editor/get-selection editor)))


minor refactoring

minor refactoring

--- src/org/domaindrivenarchitecture/pallet/crate/user/ssh_key.clj
+++ src/org/domaindrivenarchitecture/pallet/crate/user/ssh_key.clj
@@ -26,7 +26,7 @@
 (defn new-ssh-key
   "Constructor for ssh key"
   ([type public-key comment]
-    (SshKey. type public-key comment nil))
+    (new-ssh-key type public-key comment nil))
   ([type public-key comment private-key]
     (SshKey. type public-key comment private-key)))


Delete Enter handler.

Delete Enter handler.

--- src/cljs/hatnik/web/client/form.cljs
+++ src/cljs/hatnik/web/client/form.cljs
@@ -26,9 +26,3 @@
                (.modal ($ :#iModalProject) "hide")
                (.modal ($ :#iModalProjectMenu) "hide"))))

-;; Submit new email action by Enter pressing
-(.keydown ($ :#iModal)
-          (fn [e]
-            (when (= 13 (.-keyCode e))
-              (action/send-new-email-action (:current-project (deref state/app-state))))))
-


beta-delta normalization fixed

beta-delta normalization fixed

--- src/latte/norm.clj
+++ src/latte/norm.clj
@@ -208,16 +208,27 @@
 ;; ## Normalization (up-to beta/delta)
 ;;}

+(defn beta-normalize [t]
+  (let [[t' red?] (beta-step t)]
+    (if red?
+      (recur t')
+      t')))
+
+(defn beta-delta-normalize [def-env t]
+  (let [[t' red?] (beta-step t)]
+    (if red?
+      (recur def-env t')
+      (let [[t'' red?] (delta-step def-env t)]
+        (if red?
+          (recur def-env t'')
+          t'')))))
+
 (defn normalize
-  ([t] (normalize {} t))
+  ([t] (beta-normalize t))
   ([def-env t]
-   (let [[t' red?] (beta-step t)]
-     (if red?
-       (recur def-env t')
-       (let [[t'' red?] (delta-step def-env t)]
-         (if red?
-           (recur def-env t'')
-           t''))))))
+   (if (empty? def-env)
+     (beta-normalize t)
+     (beta-delta-normalize def-env t))))

 (example
  (normalize '(lambda [y [(lambda [x :kind] x) :type]] [(lambda [x :type] x) y]))
@@ -233,5 +244,8 @@
  (beta-eq? '(lambda [z :type] z)
            '(lambda [y [(lambda [x :kind] x) :type]] [(lambda [x :type] x) y])) => true)

-
-
+(defn delta-beta-eq? [def-env t1 t2]
+  (let [t1' (normalize def-env t1)
+        t2' (normalize def-env t2)]
+    (stx/alpha-eq? t1' t2')))
+


Story ID: RPC-206 generated locales namespace should also defonce an instance of goog.module.ModuleManager

--- src/leiningen/i18n.clj
+++ src/leiningen/i18n.clj
@@ -118,6 +118,7 @@
                                 (list :import 'goog.module.ModuleManager)) :stream nil)
         output-dir (:output-dir (:compiler (get-cljsbuild (get-in project [:cljsbuild :builds]))))
         abs-module-path (str/join (interleave (repeat "/") (drop 2 (str/split output-dir #"/"))))
+        manager-def (list 'defonce 'manager (list 'module-manager/getInstance))
         modules-map (reduce #(assoc %1 %2 (str abs-module-path "/" %2 ".js")) {} locales)
         modules-def (pp/write (list 'defonce 'modules (symbol (str "#js")) modules-map) :stream nil)
         mod-info-map (reduce #(assoc %1 %2 []) {} locales)
@@ -139,7 +140,7 @@
                                                (list 'js/console.log (list 'str "LOADED ALTERNATE LOCALE: " 'l))
                                                (list 'reset! 'i18n/*current-locale* 'l)
                                                (list (list 'op (symbol "#(assoc % :application/locale l)")))))))]
-    (str/join "\n\n" [ns-decl modules-def mod-info-def loader-def set-locale-def])))
+    (str/join "\n\n" [ns-decl manager-def modules-def mod-info-def loader-def set-locale-def])))

 (defn deploy-translations
   "This subtask converts translated .po files into locale-specific .cljs files for runtime string translation."


removed unused resources of videojs

removed unused resources of videojs

--- src/distillery/view/dependencies.clj
+++ src/distillery/view/dependencies.clj
@@ -1,40 +1,32 @@
-(ns distillery.view.dependencies
-  (:import [java.io InputStream])
-  (:import [java.nio.file Path Files CopyOption StandardCopyOption])
-  (:require [clojure.java.io :as io])
-  (:require [mastersign.files :refer :all]))
-
-(def static-resources
-  ["reset.css"
-   "base.css"
-   "layout.css"
-   "distillery.css"
-   "jquery.js"
-   "distillery.js"
-;   "video.js"
-;   "video-js.min.css"
-;   "video-js.png"
-;   "video-js.swf"
-;   "vjs.eot"
-;   "vjs.woff"
-;   "vjs.ttf"
-;   "vjs.svg"
-   ])
-
-(defn- copy-stream-to-file
-  [^InputStream s ^Path p]
-  (Files/copy s p (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING])))
-
-(defn- save-dependency
-  "Saves a static resource dependency relative to the given HTML file path."
-  [^String target-dir ^String rn]
-  (let [src-s (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) rn)
-        trg (get-path target-dir rn)]
-    (copy-stream-to-file src-s trg)
-    (.close src-s)))
-
-(defn save-dependencies
-  "Saves all static resource dependencies relative to the given HTML file path."
-  [^String target-dir]
-  (doseq [rn static-resources]
-    (save-dependency target-dir rn)))
+(ns distillery.view.dependencies
+  (:import [java.io InputStream])
+  (:import [java.nio.file Path Files CopyOption StandardCopyOption])
+  (:require [clojure.java.io :as io])
+  (:require [mastersign.files :refer :all]))
+
+(def static-resources
+  ["reset.css"
+   "base.css"
+   "layout.css"
+   "distillery.css"
+   "jquery.js"
+   "distillery.js"
+   ])
+
+(defn- copy-stream-to-file
+  [^InputStream s ^Path p]
+  (Files/copy s p (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING])))
+
+(defn- save-dependency
+  "Saves a static resource dependency relative to the given HTML file path."
+  [^String target-dir ^String rn]
+  (let [src-s (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) rn)
+        trg (get-path target-dir rn)]
+    (copy-stream-to-file src-s trg)
+    (.close src-s)))
+
+(defn save-dependencies
+  "Saves all static resource dependencies relative to the given HTML file path."
+  [^String target-dir]
+  (doseq [rn static-resources]
+    (save-dependency target-dir rn)))


Refactor. Removed file-vec and changed it to be a file-map which makes a lot more sense. Replace (into {} (map....)) with reduce-kv.

--- src/swiss/core.clj
+++ src/swiss/core.clj
@@ -1,18 +1,25 @@
 (ns swiss.core
   (:require [clojure.java.shell :refer [sh]]
             [clojure.string :refer [join]]
-            [digest :refer [md5]]
-            [clojure.java.io :refer [as-file]]
-            [me.raynes.fs :refer [glob]])
+            [digest :refer [md5]])
   (:import [com.yahoo.platform.yui.compressor CssCompressor JavaScriptCompressor]
            [java.nio.file FileSystems]
            [java.io File InputStreamReader StringReader StringWriter]))

+(defn get-filename
+  [file-map]
+  (-> file-map keys first))
+
+(defn get-contents
+  [file-map]
+  (-> file-map vals first))
+
 (defn- compress-javascript*
   "Calls the YUI compressor and returns the compressed js as a string.

-  Input is a vector with the filename as the first value and file's contents as the second value."
-  [input &
+  file-map is a map with a key of the filename and
+  value being the file's contents."
+  [file-map &
    [{:keys
      [disable-optimizations?
       preserve-semi?
@@ -29,7 +36,7 @@
       charset "utf-8"}}
     :as options]]
   (let [compressor (JavaScriptCompressor.
-                    (StringReader. (last input))
+                    (StringReader. (get-contents file-map))
                     nil)
         writer (StringWriter.)]
     (.compress
@@ -40,13 +47,14 @@
      verbose?
      preserve-semi?
      disable-optimizations?)
-    {(first input) (.toString (.getBuffer writer))}))
+    {(get-filename file-map) (.toString (.getBuffer writer))}))

 (defn- compress-stylesheet*
   "Calls the YUI compressor and returns the compressed css as a string.

-  Input is a vector with the filename as the first value and file's contents as the second value."
-  [input &
+  file-map is a map with a key of the filename and
+  value being the file's contents."
+  [file-map &
    [{:keys
      [line-break
       charset]
@@ -54,19 +62,19 @@
      {line-break -1
       charset "utf-8"}}
     :as options]]
-  (let [compressor (CssCompressor. (StringReader. (last input)))
+  (let [compressor (CssCompressor. (StringReader. (get-contents file-map)))
         writer (StringWriter.)]
     (.compress
      compressor
      writer
      line-break)
-    {(first input) (.toString (.getBuffer writer))}))
+    {(get-filename file-map) (.toString (.getBuffer writer))}))

 (defn- get-previous-output
   "Returns the return value of the previous function via the
-  swiss-map."
-  [swiss-map]
-  ((:prev-fn swiss-map) swiss-map))
+  context."
+  [context]
+  ((:prev-fn context) context))

 (defn- current-working-directory
   "Returns the directory the project is located in."
@@ -91,72 +99,80 @@
   "Takes a vector of files as strings to be read in and returned as
   map of the file-name to its content.

-  Optionally give it a swiss-map and it'll replae the :src value with
+  Optionally give it a context and it'll replace the :src value with
   the new ones."
   ([files]
    (src {} files))
-  ([swiss-map files]
-   (merge swiss-map
+  ([context files]
+   (merge context
           {:src (into {} (map read-file files))
            :prev-fn :src})))

 (defn compress-javascript
-  "Takes a swiss-map and optionally yui compressor options as a map
+  "Takes a context and optionally yui compressor options as a map
   and returns a map of the file-name to its compressed content."
-  ([swiss-map]
-   (compress-javascript swiss-map nil))
-  ([swiss-map yui-options]
-   (merge swiss-map
-          {:compress-javascript (into {} (map #(compress-javascript* % yui-options)
-                                              (get-previous-output swiss-map)))
+  ([context]
+   (compress-javascript context nil))
+  ([context yui-options]
+   (merge context
+          {:compress-javascript (reduce-kv
+                                 (fn [m k v]
+                                   (merge m (compress-javascript* {k v} yui-options)))
+                                 {}
+                                 (get-previous-output context))
            :prev-fn :compress-javascript})))

 (defn compress-stylesheet
-  "Takes a swiss-map and optionally yui compressor options as a map
+  "Takes a context and optionally yui compressor options as a map
   and returns a map of the file-name to its compressed content."
-  ([swiss-map]
-   (compress-stylesheet swiss-map nil))
-  ([swiss-map yui-options]
-   (merge swiss-map
-          {:compress-javascript (into {} (map #(compress-stylesheet* % yui-options)
-                                              (get-previous-output swiss-map)))
-           :prev-fn :compress-javascript})))
+  ([context]
+   (compress-stylesheet context nil))
+  ([context yui-options]
+   (merge context
+          {:compress-stylesheet (reduce-kv
+                                 (fn [m k v]
+                                   (merge m (compress-stylesheet* {k v} yui-options)))
+                                 {}
+                                 (get-previous-output context))
+           :prev-fn :compress-stylesheet})))

 (defn concat
   "Concatenates the values of the file-map of the previous output and
   returns a map with the concatenated file-name as a key to the new
   concanted content as a value."
-  [swiss-map file-name]
-  (merge swiss-map
+  [context file-name]
+  (merge context
          {:concat {file-name
-                   (apply str (vals (get-previous-output swiss-map)))}
+                   (apply str (vals (get-previous-output context)))}
           :prev-fn :concat}))

 (defn- output-to-file*
-  "Takes in a file vector, which is a vector with the first value
-  being the filename and second value being the file's contents."
-  [file-path file-vec]
-  (let [filename (first file-vec)
-        contents (last file-vec)]
+  "Takes in a file map, which is a map with a key of the filename and
+  value being the file's contents."
+  [file-path file-map]
+  (let [filename (get-filename file-map)
+        contents (get-contents file-map)]
     (spit (str file-path "/" filename) contents)
     {filename contents}))

 (defn output-to-file
-  "Takes a swiss-map with a file-map as its previous output, which is
+  "Takes a context with a file-map as its previous output, which is
   a map of keys consisting of a file's name as a string to its content
   as a value. Spits it out to the file-path."
-  [swiss-map file-path]
-  (merge swiss-map
-         {:output-to-file (into {} (map #(output-to-file* file-path %)
-                                        (get-previous-output swiss-map)))
+  [context file-path]
+  (merge context
+         {:output-to-file (reduce-kv
+                           (fn [m k v]
+                             (merge m (output-to-file* file-path {k v})))
+                           {}
+                           (get-previous-output context))
           :prev-fn :output-to-file}))

 (defn rename
   "Renames a file. If there are multiple files, it renames the first
   one and returns it as a file-map."
-  [swiss-map new-file-name]
-  (merge swiss-map
+  [context new-file-name]
+  (merge context
          {:rename
-          {new-file-name (first (vals (get-previous-output swiss-map)))}
+          {new-file-name (get-contents (get-previous-output context))}
           :prev-fn :rename}))
-


add function for finding a specific :cid

--- src/clj/game/core-cards.clj
+++ src/clj/game/core-cards.clj
@@ -26,6 +26,11 @@
                   (into (get-in @state [:corp :scored]) (get-in @state [:runner :scored]))
                   (get-in @state (cons (to-keyword side) zones))))))
       card)))
+
+(defn find-cid
+  "Return a card with specific :cid from given sequence"
+  [cid from]
+  (some #(when (= (:cid %) cid) %) from))

 ; Functions for updating cards
 (defn update!


microservices with interval

microservices with interval

--- src/clj/neb/trunk_store.clj
+++ src/clj/neb/trunk_store.clj
@@ -39,26 +39,24 @@
 (defn defrag-store-trunks []
   (locking defrag-service
     (doseq [trunk (.getTrunks trunks)]
-      (defrag/scan-trunk-and-defragment trunk)))
-  (Thread/sleep 1))
+      (defrag/scan-trunk-and-defragment trunk))))

 (defn backup-trunks []
   (doseq [trunk (.getTrunks trunks)]
     (try
       (sync-trunk trunk)
       (catch Exception ex
-        (clojure.stacktrace/print-cause-trace ex))))
-  (Thread/sleep 1000))
+        (clojure.stacktrace/print-cause-trace ex)))))

 (defn start-defrag []
   (defrag/collecting-frags)
-  (reset! defrag-service (ms/start-service defrag-store-trunks)))
+  (reset! defrag-service (ms/start-service defrag-store-trunks 10)))

 (defn stop-defrag []
   (ms/stop-service @defrag-service))

 (defn start-backup []
-  (reset! backup-service (ms/start-service backup-trunks)))
+  (reset! backup-service (ms/start-service backup-trunks 1000)))

 (defn stop-backup []
   (ms/stop-service @backup-service))