Some more tweaks

Some more tweaks

--- src/overtone_workspace/beats.clj
+++ src/overtone_workspace/beats.clj
@@ -219,40 +219,55 @@
   (swap! *fn-beats assoc ambi-rand [1 _ 1 _ 1 _ 1 _ 1 _ 1 _ 1 _ 1 _])
   (swap! *fn-beats assoc ambi-rand [[1 _ _ [1 1]] [(vec (repeat 8 1)) _ _ 1] [_ _ 1 _] [(vec (repeat 8 1)) _ _ [1 1 1]]])
   (swap! *fn-beats assoc ambi-rand (vec (repeat 16 1)))
-  (swap! *fn-beats assoc rand-laser (vec (repeat 16 1)))
+  (swap! *fn-beats assoc rand-laser (vec (repeat 64 1)))
   (swap! *fn-beats assoc rand-laser [_])
-  (swap! *fn-beats assoc rand-latchbell (vec (repeat 8 1)))
-  (swap! *fn-beats assoc rand-latchbell (vec (repeat 16 1)))
+  (swap! *fn-beats assoc rand-latchbell (vec (repeat 32 1)))
   (swap! *fn-beats assoc rand-latchbell [_])

+  (reset! *fn-beats fn-beats)
   (let
-    [fnrep 64]
-    (swap! *fn-beats assoc ambi-rand (vec (repeat fnrep 1)))
+      [fnrep 1]
+    (swap! *fn-beats assoc rand-laser (vec (repeat (/ fnrep 1) 1)))
+    (swap! *fn-beats assoc rand-latchbell (vec (repeat (/ fnrep 1) 1)))
+    (swap! *fn-beats assoc ambi-rand (vec (repeat (/ fnrep 1) 1)))
     (swap! *fn-beats assoc prob-kick (vec (repeat fnrep 0.6)))
     (swap! *fn-beats assoc prob-sd (vec (repeat fnrep 0.6)))
     (swap! *fn-beats assoc prob-hat (vec (repeat fnrep 0.4)))
     (swap! *fn-beats assoc prob-openhh (vec (repeat fnrep 0.4))))
   (do
+    ;;(swap! *fn-beats assoc rand-latchbell [_])
+    ;;(swap! *fn-beats assoc rand-laser [_])
     (swap! *fn-beats assoc ambi-rand (vec (repeat 16 1)))
+    ;;(swap! *fn-beats assoc ambi-rand (vec (repeat 1 _)))
     (swap! *fn-beats assoc prob-kick (take 32 (cycle [10 0 2 0 6 0 2 0 3 0 6 0 1.1 0 2 4])))
     (swap! *fn-beats assoc prob-sd (take 32 (cycle [0 0 1.1 0 1.1 0 6 0 6 0 1.1 0 1.1 0 6 0])))
     (swap! *fn-beats assoc prob-hat (take 32 (cycle [10 2 8 2 1 2])))
     (swap! *fn-beats assoc prob-openhh (take 32 (cycle [0 0 0 0 5 0 0 0 0 0 0 0 0 0 5 0]))))
+  (reset! *fn-beats fn-beats)
   (do
+    ;;(swap! *fn-beats assoc rand-latchbell [_])
+    ;;(swap! *fn-beats assoc rand-laser [_])
     (swap! *fn-beats assoc ambi-rand (vec (repeat 16 1)))
     (swap! *fn-beats assoc prob-openhh [7])
     (swap! *fn-beats assoc prob-kick [9])
     (swap! *fn-beats assoc prob-hat (take 16 (cycle [10 2 8 2 1 2])))
-    (swap! *fn-beats assoc prob-sd [[[0] [10 _ _ [8]] ] [0 10]]))
-
-  (volume 0.6)
+    (swap! *fn-beats assoc prob-sd [[[0] [10 _ _ [8]] ] [0 10]])
+    ;;(volume 0)
+    ;;(fadein-master 0.6)
+    )
+
+  ;;(volume 0.6)
+  (volume 0)
   (fadein-master 0.6)
   (volume)
   (fadeout-master 0.6)
   (stop)

-  (do
-    (swap! *fn-beats assoc ambi-rand (vec (repeat 32 1)))
+  (let
+    [fnrep 64]
+    (swap! *fn-beats assoc rand-latchbell (vec (repeat (/ fnrep 1) 1)))
+    (swap! *fn-beats assoc rand-laser (vec (repeat (/ fnrep 2) 1)))
+    (swap! *fn-beats assoc ambi-rand (vec (repeat (/ fnrep 1) 1)))
     (swap! *fn-beats assoc prob-kick [_])
     (swap! *fn-beats assoc prob-sd [_])
     (swap! *fn-beats assoc prob-hat [_])


clojure etl - make data types for tests consistent with the README

--- assignments/clojure/etl/etl_test.clj
+++ assignments/clojure/etl/etl_test.clj
@@ -3,16 +3,16 @@

 (deftest transform-one-value
-  (is (= {"world" "hello"}
-         (etl/transform {"hello" ["WORLD"]}))))
+  (is (= {"world" 1}
+         (etl/transform {1 ["WORLD"]}))))

 (deftest transform-more-values
-  (is (= {"world" "hello" "gschoolers" "hello"}
-         (etl/transform {"hello" ["WORLD" "GSCHOOLERS"]}))))
+  (is (= {"world" 1 "gschoolers" 1}
+         (etl/transform {1 ["WORLD" "GSCHOOLERS"]}))))

 (deftest more-keys
-  (is (= {"apple" "a" "artichoke" "a" "boat" "b" "ballerina" "b"}
-         (etl/transform {"a" ["APPLE" "ARTICHOKE"] "b" ["BOAT" "BALLERINA"] }))))
+  (is (= {"apple" 1 "artichoke" 1 "boat" 2 "ballerina" 2}
+         (etl/transform {1 ["APPLE" "ARTICHOKE"] 2 ["BOAT" "BALLERINA"] }))))

 (deftest full-dataset
   (is (= { "a"  1 "b"  3 "c" 3 "d" 2 "e" 1


Call System/exit instead of shutdown-agents, as the latter does not appear to work.

--- src/vacation2/main.clj
+++ src/vacation2/main.clj
@@ -209,12 +209,12 @@
             (map #(spawn worker-behavior % data options) (range n-workers))
           done-promises
             (repeatedly n-reservations promise)]
-      (log-data data)
+      #_(log-data data)
       (doseq [[worker reservation done?]
                 (zip (cycle worker-actors) reservations done-promises)]
         (send worker reservation done?))
       (doseq [done? done-promises]
         (deref done?))
-      (log-data data)))
-  (Thread/sleep 1000) ; XXX This is needed as log actor might not have finished yet
-  (shutdown-agents))
+      #_(log-data data)))
+  (log "done")
+  (System/exit 0))


Added sat-solve-dimacs and worked on sat-solve

* sat-solve-dimacs return a vector of numbers
* sat-solve returns a vector of literals

--- src/logic/sat-solve.clj
+++ src/logic/sat-solve.clj
@@ -32,9 +32,9 @@
   (let [res-str (sat4j-solve dimacs-map)]
     (if (nil? res-str)
               [0]
-              (cons 1 (vec (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" "))))))))
+              (vec (cons 1 (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" "))))))))

-(defn sat-sovle
+(defn sat-solve
   "Returns one result as vector with litereals.
    The first number is 0 or 1:
    0: the formula is unsatisfiable
@@ -43,5 +43,7 @@
   (let [res-str (sat4j-solve dimacs-map)]
     (if (nil? res-str)
               [0]
-              (let [numvec  (vec (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" "))))]
-
+              (vec (cons 1 (let [numvec  (vec (filter #(not= 0 %) (map #(Integer. %) (clojure.string/split res-str #" "))))
+                                 substitutions (apply hash-map (flatten (map (fn [[k v]] [k v (Integer. (str "-" k)) (symbol (str "not(" v ")"))]) (:subs dimacs-test))))]
+                             (println substitutions)
+                             (replace substitutions numvec)))))))


Removes unused function

Removes unused function

--- src/lt/plugins/css.cljs
+++ src/lt/plugins/css.cljs
@@ -15,13 +15,6 @@
    (if (= (first s1) (first s2))
      (get-prefix (rest s1) (rest s2) (str memo (first s1)))
      memo)))
-
-;; Not currently used.
-(defn ensure-end-sep [s]
-  "If s is a directory, ensure it ends in a path separator."
-  (if (or (= (last s) files/separator) (not (files/dir? s)))
-    s
-    (str s files/separator)))

 ; @NOTE: Are the names source and dest backwards here?
 (defn diff-paths [source dest]


update vector construction benchmarks to include `vec`

--- benchmark/cljs/benchmark_runner.cljs
+++ benchmark/cljs/benchmark_runner.cljs
@@ -60,8 +60,9 @@

 (println ";;; vector ops")
 (simple-benchmark [] [] 1000000)
-(simple-benchmark [] [1 2 3] 1000000)
-(simple-benchmark [] (vector 1) 1000000)
+(simple-benchmark [[a b c] (take 3 (repeatedly #(rand-int 10)))] (-count [a b c]) 1000000)
+(simple-benchmark [[a b c] (take 3 (repeatedly #(rand-int 10)))] (-count (vec #js [a b c])) 1000000)
+(simple-benchmark [[a b c] (take 3 (repeatedly #(rand-int 10)))] (-count (vector a b c)) 1000000)
 (simple-benchmark [coll [1 2 3]] (transient coll) 100000)
 (simple-benchmark [coll [1 2 3]] (nth coll 0) 1000000)
 (simple-benchmark [coll [1 2 3]] (-nth coll 0) 1000000)


flipped y-axis of polar point for typical screen coordinate systems

--- src/mastersign/geom.clj
+++ src/mastersign/geom.clj
@@ -12,7 +12,7 @@

 (defn polar-point
   [r a]
-  (point (* r (Math/cos a)) (* r (Math/sin a))))
+  (point (* r (Math/cos a)) (- (* r (Math/sin a)))))

 (defn rectangle
   ([] (rectangle 0 0 0 0))


azulenoids.clj: used more idiomatic Clojure

--- clojure/org/gavrog/clojure/azulenoids.clj
+++ clojure/org/gavrog/clojure/azulenoids.clj
@@ -2,16 +2,15 @@
   (:import (org.gavrog.jane.numbers Whole)
            (org.gavrog.joss.dsyms.basic DSymbol DynamicDSymbol)
            (org.gavrog.joss.dsyms.generators CombineTiles DefineBranching2d))
-  (:require clojure.set)
+  (:use [clojure.set :only [map-invert]])
   (:gen-class))

 (defn iterate-cycle [coll x]
   (reductions #(%2 %1) x (cycle coll)))

 (defn unique [coll key-fun]
-  (letfn [(step [acc x]
-                (let [[seen _] acc
-                      key (key-fun x)]
+  (letfn [(step [[seen _] x]
+                (let [key (key-fun x)]
                   (if (seen key)
                     [seen false]
                     [(conj seen key) x])))]
@@ -57,14 +56,12 @@
               (take 16 template-boundary)))))

 (defn on-template [ds oct2tmp]
-  (let [tmp2oct (clojure.set/map-invert oct2tmp)
+  (let [tmp2oct (map-invert oct2tmp)
         tmp (DynamicDSymbol. template)]
-    (doseq [D (keys tmp2oct)]
-      (if (not (.definesOp tmp 2 D))
-        (.redefineOp tmp 2 D (oct2tmp (.op ds 2 (tmp2oct D))))))
-    (doseq [D (keys tmp2oct)]
-      (if (not (.definesV tmp 1 2 D))
-        (.redefineV tmp 1 2 D (.v ds 1 2 (tmp2oct D)))))
+    (doseq [D (keys tmp2oct) :when (not (.definesOp tmp 2 D))]
+      (.redefineOp tmp 2 D (oct2tmp (.op ds 2 (tmp2oct D)))))
+    (doseq [D (keys tmp2oct) :when (not (.definesV tmp 1 2 D))]
+      (.redefineV tmp 1 2 D (.v ds 1 2 (tmp2oct D))))
     tmp))

 (def octa-sets (filter #(-> %1 max-curvature .isNegative not)


Clean unncessary type tag

Clean unncessary type tag

--- examples/material-ui/src/example/core.cljs
+++ examples/material-ui/src/example/core.cljs
@@ -114,7 +114,7 @@
       :placeholder "Placeholder"
       :helper-text "Helper text"
       :class (.-textField classes)
-      :on-change (fn [^js/DomEvent e]
+      :on-change (fn [e]
                    (reset! text-state (event-value e)))
       :multiline true
       ;; TODO: Autosize textarea is broken.


Add `active.clojure.record-test` to `record-spec-test`.

--- test/active/clojure/record_spec_test.cljc
+++ test/active/clojure/record_spec_test.cljc
@@ -50,10 +50,98 @@
     (let [kv (make-kv "foo" :bar)]
       (t/is (= "foo" (kv-k kv)))
       (t/is (= :bar (kv-v kv)))))
-  (t/testing "after instrumentation, this throws an error"
-    (stest/instrument)
-    (try (make-kv "foo" :bar)
-         (catch Exception e
-           (t/is (= "Call to #'active.clojure.record-spec-test/make-kv did not conform to spec:
+  #?(:clj
+     (t/testing "after instrumentation, this throws an error"
+       (stest/instrument)
+       (try (make-kv "foo" :bar)
+            (catch Exception e
+              (t/is (= "Call to #'active.clojure.record-spec-test/make-kv did not conform to spec:
 In: [0] val: \"foo\" fails spec: :active.clojure.record-spec-test/k at: [:args :k] predicate: int?\n"
-                  (.getMessage e)))))))
+                       (.getMessage e))))))))
+
+
+;; taken from record-test
+
+(define-record-type Pare
+  (kons a b)
+  pare?
+  [a kar
+   b kdr])
+
+(defrecord FakePare [a b])
+
+(t/deftest simple
+  (let [r (kons 1 2)]
+    (t/is (pare? r))
+    (t/is (= 1 (kar r)))
+    (t/is (= 2 (kdr r)))))
+
+#?(:clj
+   (t/deftest unique
+     (t/is (thrown? Throwable
+                    (kar (FakePare. 1 2))))))
+
+(define-record-type Pu
+  (make-pu c a)
+  pu?
+  [a pua
+   b pub
+   c puc])
+
+(t/deftest constructor
+  (let [p (make-pu 1 2)]
+    (t/is (pu? p))
+    (t/is (not (pare? p)))
+    (t/is (= 2 (pua p)))
+    (t/is (= 1 (puc p)))
+    (t/is (nil? (pub p)))))
+
+;; Records with lenses
+
+(defn law-1-holds [l data v]
+  ;; you get back what you put in
+  (t/is (= v
+         (lens/yank (lens/shove data l v) l))))
+
+(defn law-2-holds [l data]
+  ;; putting back what you got doesn't change anything
+  (t/is (= data
+         (lens/shove data l (lens/yank data l)))))
+
+(defn law-3-holds [l data v1 v2]
+  ;; second set wins, or setting once is the same as setting twice
+  (t/is (= (lens/shove data l v1)
+         (lens/shove (lens/shove data l v2) l v1))))
+
+(defn lens-laws-hold [l data v1 v2]
+  (and (law-1-holds l data v1)
+       (law-2-holds l data)
+       (law-3-holds l data v1 v2)))
+
+(define-record-type ^{:doc "Lens example"} LensPare
+  (lens-kons a b)
+  lens-pare?
+  [(^{:doc "a field"} a lens-kar lens-kar-lens)
+   (^{:doc "b field"} b lens-kdr lens-kdr-lens)])
+
+(t/deftest pare-lens
+  (lens-laws-hold lens-kar-lens (lens-kons 1 2) 23 42)
+  (lens-laws-hold lens-kdr-lens (lens-kons 1 2) 23 42)
+  (t/is (= (lens-kons "a" 42)
+         (lens/shove (lens-kons 23 42) lens-kar-lens "a")))
+  (t/is (= (lens-kons 23 "b")
+         (lens/shove (lens-kons 23 42) lens-kdr-lens "b"))))
+
+(define-record-type Quadruple
+  (quadruple a b c d)
+  quadruple?
+  [(a quadruple-one quadruple-one-lens)
+   b quadruple-two
+   (c quadruple-three quadruple-three-lens)
+   d quadruple-four])
+
+(t/deftest quadruple-lens
+  (lens-laws-hold quadruple-one-lens (quadruple 'a 'b 'c 'd) 12 78)
+  (lens-laws-hold quadruple-three-lens (quadruple 'a 'b 'c 'd) 12 78)
+  (t/is (= (quadruple 4 8 15 16)
+         (lens/shove (quadruple 108 8 15 16) quadruple-one-lens 4))))


Two tests for function update-jenkins-url

--- test/clj_jenkins_api/jenkins_api_test.clj
+++ test/clj_jenkins_api/jenkins_api_test.clj
@@ -257,3 +257,30 @@
         (is (thrown? NullPointerException (job-name->url ""  nil)))
         (is (thrown? NullPointerException (job-name->url nil nil)))))

+(deftest test-update-jenkins-url-1
+    "Check the clj-jenkins-api.jenkins-api/update-jenkins-url"
+    (testing "the clj-jenkins-api.jenkins-api/update-jenkins-url"
+        (are [x y] (= x y)
+            ""                        (update-jenkins-url "" nil)
+            "http://example.com/job"  (update-jenkins-url "http://example.com/job" nil)
+            "https://example.com/job" (update-jenkins-url "https://example.com/job" nil)
+            "other://example.com/job" (update-jenkins-url "other://example.com/job" nil)
+            ""                        (update-jenkins-url "" "")
+            "http://example.com/job"  (update-jenkins-url "http://example.com/job" "")
+            "https://example.com/job" (update-jenkins-url "https://example.com/job" "")
+            "other://example.com/job" (update-jenkins-url "other://example.com/job" "")
+            ""                        (update-jenkins-url "" {})
+            "http://example.com/job"  (update-jenkins-url "http://example.com/job" {})
+            "https://example.com/job" (update-jenkins-url "https://example.com/job" {})
+            "other://example.com/job" (update-jenkins-url "other://example.com/job" {}))))
+
+(deftest test-update-jenkins-url-2
+    "Check the clj-jenkins-api.jenkins-api/update-jenkins-url"
+    (testing "the clj-jenkins-api.jenkins-api/update-jenkins-url"
+        (are [x y] (= x y)
+            ""                                      (update-jenkins-url "" "name:password")
+            "http://name:password@example.com/job"  (update-jenkins-url "http://example.com/job" "name:password")
+            "https://name:password@example.com/job" (update-jenkins-url "https://example.com/job" "name:password")
+            "other://example.com/job"               (update-jenkins-url "other://example.com/job" "name:password"))))
+
+


debugger: Sweep -> Vacuum, Sweep All -> Clear

--- examples/_common/middleware/devtools.cljs
+++ examples/_common/middleware/devtools.cljs
@@ -151,11 +151,11 @@
                ::on-toggle-persist
                (dispatch-action ::toggle-persist)

-               ::on-sweep
-               (dispatch-action ::sweep)
-
-               ::on-sweep-all
-               (dispatch-action ::sweep-all)
+               ::on-vacuum
+               (dispatch-action ::vacuum)
+
+               ::on-clear
+               (dispatch-action ::clear)

                ::on-reset
                (do
@@ -222,12 +222,12 @@
            ::toggle-persist
            (update-in model [::debugger :persist?] not)

-           ::sweep
+           ::vacuum
            (as-> model m
                  (update-in m [::debugger :action-events] #(filter :enabled? %))
                  (update-in m [::debugger :signal-events] #(remove (partial -orphaned-signal? m) %)))

-           ::sweep-all
+           ::clear
            (-> model
                (assoc-in [::debugger :signal-events] nil)
                (assoc-in [::debugger :action-events] nil))
@@ -249,7 +249,7 @@
                                                                                (dissoc m ::debugger))])
                    (update-in m [::debugger :next-action-id] inc))

-             ; looks like originating signal could be already sweeped -> create "unknown signal" to record this action
+             ; looks like originating signal could be already cleared -> create "unknown signal" to record this action
              (reconcile model a)))))

 ;;;;;;;;;;;;;;;;;;;;;;;; View model
@@ -304,8 +304,8 @@
                                   :checked   persist?
                                   :on-change #(dispatch ::on-toggle-persist)}]
    [:label {:for "persist-toggle"} "Persist"]
-   [-menu-button "Sweep" #(dispatch ::on-sweep) "Removes disabled actions and \"orphaned\" signals from history"]
-   [-menu-button "Sweep All" #(dispatch ::on-sweep-all) "Clears debugger history without affecting app model"]
+   [-menu-button "Vacuum" #(dispatch ::on-vacuum) "Removes disabled actions and signals with no actions from history"]
+   [-menu-button "Clear" #(dispatch ::on-clear) "Clears debugger history"]
    [-menu-button "Reset" #(dispatch ::on-reset) "Removes all actions and signals resetting the model to initial state"]
    [-menu-button "Hide" #(dispatch ::on-toggle-visibility) (str "Hides debugger view (" toggle-visibility-shortcut ")")]
    [-menu-button "Save" #(dispatch ::on-save) "Saves current debugger session into file"]


Apparently resolve doesn't work in the same namespace as the file

--- src/hphelper/shared/sql.clj
+++ src/hphelper/shared/sql.clj
@@ -20,7 +20,7 @@
 (defn init-named-items
   "Checks if namedItems is initialised. If not, initialise it"
   []
-  (if (not (resolve 'namedItems))
+  (if (not (ns-resolve 'hphelper.shared.sql 'namedItems))
     (def namedItems
       "A map atom with references as keys and named items as values"
       (atom {}))))


Fix amplitude session id cookie always setting to null (#1669)

--- src-cljs/frontend/analytics/amplitude.cljs
+++ src-cljs/frontend/analytics/amplitude.cljs
@@ -1,11 +1,11 @@
 (ns frontend.analytics.amplitude
-  (:require [goog.net.cookies :as cookies])
-  (:require-macros [frontend.utils :refer [swallow-errors]]))
+  (:require [goog.net.cookies :as cookies]
+            [frontend.utils :as utils :include-macros]))

 (def session-cookie-name "amplitude-session-id")

 (defn session-id []
-  (swallow-errors
+  (utils/swallow-errors
     (js/amplitude.getSessionId)))

 (defn set-session-id-cookie!


Fix docstring

Fix docstring

--- src/io/aviso/rook/async.clj
+++ src/io/aviso/rook/async.clj
@@ -163,7 +163,7 @@
   (-> request ::rook/injections kw))

 (defn wrap-restful-format
-  "Asychronous version of `ring.middleware.format/wrap-restful-format`; this implementation uses
+  "Asychronous version of `ring.middleware.format/wrap-restful-format`; this implementation
   will work properly inside an asynchronous pipeline."
   ([handler]
    (wrap-restful-format handler [:json-kw :edn]))


statistics page made pretier

statistics page made pretier

--- src/notehub/handler.clj
+++ src/notehub/handler.clj
@@ -122,13 +122,16 @@
          (return-content-type "text/plain; charset=utf-8" md-text)))

   (GET "/:year/:month/:day/:title/stats" [year month day title]
-       (when-let [stats (:statistics (api/get-note {:noteID (api/build-key year month day title)}))]
-         (layout (get-message :statistics)
-                 [:table#stats.helvetica.central-element
-                  (map
-                   #(when (% stats)
-                      [:tr [:td (str (get-message %) ":")] [:td (% stats)]])
-                   [:published :edited :publisher :views])])))
+       (when-let [resp (api/get-note {:noteID (api/build-key year month day title)})]
+         (let [stats (:statistics resp)
+               statistics (get-message :statistics)]
+           (layout statistics
+                   [:h2.central-element statistics ": " (api/derive-title (:note resp))]
+                   [:table#stats.helvetica.central-element
+                    (map
+                     #(when (% stats)
+                        [:tr [:td (str (get-message %) ":")] [:td (% stats)]])
+                     [:published :edited :publisher :views])]))))

   (GET "/:year/:month/:day/:title/edit" [year month day title]
        (let [noteID (api/build-key year month day title)]


comment

comment

--- cljs/sledge/core.cljs
+++ cljs/sledge/core.cljs
@@ -221,7 +221,7 @@
     om/IDidMount
     (did-mount [_]
       (let [el (om/get-node owner)]
-        ;; add capturing handler (last arg "true")
+        ;; this is a capturing handler (last arg "true")
         ;; cos audio events don't bubble
         (.addEventListener el "ended"
                            #(om/update! state [:ended] true)


CMR-1247: Make queue publication timeout a configuration parameter

--- ingest-app/src/cmr/ingest/data/indexer.clj
+++ ingest-app/src/cmr/ingest/data/indexer.clj
@@ -3,7 +3,7 @@
   (:require [clj-http.client :as client]
             [cheshire.core :as json]
             [cmr.ingest.config :as config]
-            [cmr.common.config :as cfg]
+            [cmr.common.config :as cfg :refer [defconfig]]
             [cmr.common.log :as log :refer (debug info warn error)]
             [cmr.common.services.errors :as errors]
             [cmr.common.services.health-helper :as hh]
@@ -37,10 +37,10 @@
                 delete-url status response)))
     response))

-(def ^:const publish-timeout-ms
+(defconfig publish-queue-timeout-ms
   "Number of milliseconds to wait for a publish request to be confirmed before considering the
   request timed out."
-  60000)
+  {:default 60000 :type Long})

 (defn- put-message-on-queue
   "Put an index operation on the message queue. Throws a service unavailable error if the message
@@ -53,7 +53,7 @@
   period has expired. By retrying, routine maintenance such as restarting the RabbitMQ server
   will not result in any ingest errors returned to the provider."
   ([context msg]
-   (put-message-on-queue context msg publish-timeout-ms))
+   (put-message-on-queue context msg (publish-queue-timeout-ms)))
   ([context msg timeout-ms]
    (let [queue-broker (get-in context [:system :queue-broker])
          queue-name (config/index-queue-name)
@@ -65,7 +65,7 @@
                                                    timeout-ms)]
                                     (when-not response
                                       (if (< (- (System/currentTimeMillis) start-time) timeout-ms)
-                                        (warn "Retrying publishing message: " msg)
+                                        (warn "Attempt to queue message failed. Retrying: " msg)
                                         (errors/throw-service-error
                                           :service-unavailable
                                           (str "All retries exhausted to queue message: " msg))))


fix kafkafast for redis auth

fix kafkafast for redis auth

--- kafka-clj/src/kafka_clj/kafkafast_main.clj
+++ kafka-clj/src/kafka_clj/kafkafast_main.clj
@@ -4,9 +4,9 @@
   (:gen-class))

-(defn read-redis-queue [[host from limit & _]]
+(defn read-redis-queue [[host from limit & {:strs [password] :or {password nil}}]]

-  (let [redis-conn (redis-core/create {:host host})
+  (let [redis-conn (redis-core/create {:host host :password password})
         data (redis-core/wcar redis-conn (redis-api/-lrange redis-conn "etl-kafka-work-queue" from limit))]

     (doseq [item data]


Specify the class of the primitive array

--- src/radicalzephyr/boot_junit.clj
+++ src/radicalzephyr/boot_junit.clj
@@ -11,7 +11,8 @@
   [p packages PACKAGE #{sym} "The set of Java packages to run tests in."]
   (with-pre-wrap fileset
     (let [result (JUnitCore/runClasses
-                  (into-array [#_ (magic goes here to find all test classes)]))]
+                  (into-array Class
+                              [#_ (magic goes here to find all test classes)]))]
       (when (> (.getFailureCount result) 0)
         (throw (ex-info "There were some test failures."
                         (destructure-results result)))))


shapes: use param destructuring instead of let statements in gen-shape multi method impls

--- src/overtime/shapes.clj
+++ src/overtime/shapes.clj
@@ -5,72 +5,62 @@
 (defonce ^:private half-pi (* 0.5 Math/PI))

-(defmulti gen-shape (fn [stage _pos] (nth stage 4)))
+(defmulti gen-shape (fn [[_beg-level _end-level _start-time _end-time shape-id _curvature] _pos] shape-id))

 (defmethod gen-shape (ot/ENV-SHAPES :step)
-  [stage _pos]
-  (let [[_y1 y2] stage]
-    y2))
+  [[_beg-level end-level] _pos]
+  end-level)

 (defmethod gen-shape (ot/ENV-SHAPES :hold)
-  [stage pos]
-  (let [[y1 y2] stage]
-    (if (< pos 1) y1 y2)))
+  [[beg-level end-level] pos]
+  (if (< pos 1) beg-level end-level))

 (defmethod gen-shape (ot/ENV-SHAPES :linear)
-  [stage pos]
-  (let [[y1 y2] stage]
-    (+ y1
-       (* pos (- y2 y1)))))
+  [[beg-level end-level] pos]
+  (+ beg-level (* pos (- end-level beg-level))))

 (defmethod gen-shape (ot/ENV-SHAPES :exp)
-  [stage pos]
-  (let [[y1 y2] stage
-        limit (max 0.0001 y1)]
-    (* limit (Math/pow (/ y2 limit) pos))))
+  [[beg-level end-level] pos]
+  (let [limit (max 0.0001 beg-level)]
+    (* limit (Math/pow (/ end-level limit) pos))))

 (defmethod gen-shape (ot/ENV-SHAPES :sine)
-  [stage pos]
-  (let [[y1 y2] stage]
-    (+ y1
-       (* (- y2 y1)
-          (+ (* -1 (Math/cos (* Math/PI pos)) 0.5) 0.5)))))
+  [[beg-level end-level] pos]
+  (+ beg-level
+     (* (- end-level beg-level)
+        (+ (* -1 (Math/cos (* Math/PI pos)) 0.5) 0.5))))

 (defmethod gen-shape (ot/ENV-SHAPES :welch)
-  [stage pos]
-  (let [[y1 y2] stage]
-    ; From SC src: lang/LangPrimSource/PyrArrayPrimitives.cpp, see case shape_Welch
-    (if (< y1 y2)
-      (+ y1 (* (- y2 y1) (Math/sin (* half-pi pos))))
-      (- y2 (* (- y2 y1) (Math/sin (- half-pi (* half-pi pos))))))))
+  [[beg-level end-level] pos]
+  ; From SC src: lang/LangPrimSource/PyrArrayPrimitives.cpp, see case shape_Welch
+  (if (< beg-level end-level)
+    (+ beg-level (* (- end-level beg-level) (Math/sin (* half-pi pos))))
+    (- end-level (* (- end-level beg-level) (Math/sin (- half-pi (* half-pi pos)))))))

 ; FIXME Overtone code does not use a keyword for curve but instead uses 5
 (defmethod gen-shape 5
-  [stage pos]
-  (let [[y1 y2 _ _ _ curvature] stage]
-    (if (< (Math/abs curvature) 0.0001)
-      (+ (* pos (- y2 y1))
-         y1)
-      (let [denominator (- 1.0 (Math/exp curvature))
-            numerator (- 1.0 (Math/exp (* pos curvature)))]
-        (+ y1
-           (* (- y2 y1) (/ numerator denominator)))))))
+  [[beg-level end-level _ _ _ curvature] pos]
+  (if (< (Math/abs curvature) 0.0001)
+    (+ (* pos (- end-level beg-level))
+       beg-level)
+    (let [denominator (- 1.0 (Math/exp curvature))
+          numerator (- 1.0 (Math/exp (* pos curvature)))]
+      (+ beg-level
+         (* (- end-level beg-level) (/ numerator denominator))))))

 (defmethod gen-shape (ot/ENV-SHAPES :squared)
-  [stage pos]
-  (let [[y1 y2] stage
-        y1-s (Math/sqrt y1)
-        y2-s (Math/sqrt y2)
-        yp (+ y1-s (* pos (- y2-s y1-s)))]
-    (* yp yp)))
+  [[beg-level end-level] pos]
+  (let [beg-level-sroot (Math/sqrt beg-level)
+        end-level-sroot (Math/sqrt end-level)
+        val (+ beg-level-sroot (* pos (- end-level-sroot beg-level-sroot)))]
+    (* val val)))

 (defmethod gen-shape (ot/ENV-SHAPES :cubed)
-  [stage pos]
-  (let [[y1 y2] stage]
-    (let [y1-c (Math/pow y1 0.3333333)
-          y2-c (Math/pow y2 0.3333333)
-          yp (+ y1-c (* pos (- y2-c y1-c)))]
-      (* yp yp yp))))
+  [[beg-level end-level] pos]
+  (let [beg-level-cubed (Math/pow beg-level 0.3333333)
+        end-level-cubed (Math/pow end-level 0.3333333)
+        val (+ beg-level-cubed (* pos (- end-level-cubed beg-level-cubed)))]
+    (* val val val)))


Sanitize photo url

Sanitize photo url

--- frontend/src/faceboard/helpers/person.cljs
+++ frontend/src/faceboard/helpers/person.cljs
@@ -33,7 +33,7 @@
     (sanitize (get-in person [:bio :nickname]))))

 (defn photo-url [person]
-  (or (get-in person [:bio :photo :url] nil) "/images/unknown.jpg"))
+  (or (sanitize (get-in person [:bio :photo :url] nil)) "/images/unknown.jpg"))

 (defn photo-has-frame? [person]
   (not (get-in person [:bio :photo :no-frame])))


mess around

mess around

--- src/lolteambuilder/core.clj
+++ src/lolteambuilder/core.clj
@@ -130,7 +130,6 @@
     (insert-matches
       (filter seq
         (for [{id :matchId} (take 50 (:matches history))]
-          (Thread/sleep 1000)
           (try
             (match region id)
             (catch clojure.lang.ExceptionInfo e


Clean up

Clean up

--- src/angelic/search/implicit/dash_astar.clj
+++ src/angelic/search/implicit/dash_astar.clj
@@ -43,6 +43,7 @@
 ;;    I.e., live decrease -50 to -49, now blocked sibling becomes best; above is -50 TDB;
 ;; TODO: smarter summary updates (i.e., pass child)
 ;; TODO: smarter choose-leaf?
+;; TODO: conspiracy number, weighted, etc.

 ;;;;; SP caching
 ;; TODO: tail (i.e., pair) caching? -- Only help for >2 len refs...
@@ -106,19 +107,14 @@
 (def *decreases* (ArrayList.))
 (def *subsumes* (ArrayList.))

+(defn schedule-increase! [sp] (.add ^ArrayList *increases* sp))
 (defn schedule-decrease! [sp] (.add ^ArrayList *decreases* sp))
-(defn schedule-increase! [sp] (.add ^ArrayList *increases* sp))
 (defn schedule-subsumption! [ts subsumed-ts] (.add ^ArrayList *subsumes* [ts subsumed-ts]))

-
-
-(defn do-changes! [^ArrayList a f]
-  (doseq [sp a] (f sp))
-  (.clear a))
+(defn do-changes! [^ArrayList a f] (doseq [sp a] (f sp)) (.clear a))

 (declare evaluate!)

-;; Note: doing pairs right away doesn't help.
 (defn evaluate-and-update! [s]
   (evaluate! s)
   (do-changes! *increases* summaries/summary-increased!) ;; Must go first for correctness.
@@ -174,29 +170,16 @@

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Generic Trait  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-;(def *out-count* (atom 1))
-
 ;; Canonical SPs are Atomic and Pair; wrappers use TS of inner SP.
 (defn canonicalize [sp] (ts-sp (sp-ts sp)))
 (defn canonical? [sp] (identical? sp (ts-sp (sp-ts sp))))
-
-(defn notify-output-set! [w s] #_ (println "NO" s w) (w))
-(defn notify-child! [w s c] #_ (println "NC" s c w) (swap! *out-count* inc) (w c))
-
-
-;; Note subsumption following is a bit tricky, since we want access to all children
-;; (including unpublished ones).
-;; TODO: remove all-children if it doesn't help?
-;; What we need is a 3-way dependence:
-;; Child, sub child, sub link.?
-

 (traits/deftrait simple-subproblem
   [nm inp-set wrapped-ts eval!-fn ri-fn]
   [                 ts-atom          (atom wrapped-ts)
    ^PubSubHub       output-ps        (make-pubsubhub)
    ^PubSubHub       child-ps         (make-pubsubhub)
-   ^PubSubHub       all-child-ps     (make-pubsubhub)
+   ^PubSubHub       all-child-ps     (make-pubsubhub) ;; For sub-following -- remove if no help.
    ^IdentityHashMap subsuming-sp-set (IdentityHashMap.)]
   [summaries/simple-cached-node]
   Subproblem
@@ -428,9 +411,7 @@

 (defn atomic-name-fs [n] (assert (= :Atomic (first n))) (second n))
 (defn log-input [fs inp-set] (if *state-abstraction* (fs/get-logger fs inp-set) inp-set))
-
 (defn get-input-key [fs inp-set] (if *state-abstraction* (fs/extract-context fs inp-set) inp-set))
-(defn get-cache-key [atomic-n inp-set] [atomic-n (get-input-key (atomic-name-fs atomic-n) inp-set)])

 ;; Input-key caching not necessary, but speeds things up a lot on, e.g., d-m.
 (defn- make-output-collecting-subproblem [fs inp-key inner-sp]
@@ -536,10 +517,6 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn- get-root-summarizer [inp-set fs] (sp-ts (make-atomic-subproblem fs inp-set )))
-
-(def *lazy-cache* false)
-(def *no-subsumption* false)
-(def *assume-consistency* false) ;; Don't propagate lazy increases.

 ;; TODO: sa options...
 (defn implicit-dash-a*


cams comments 2

cams comments 2

--- src/metabase/util/stats.clj
+++ src/metabase/util/stats.clj
@@ -5,6 +5,7 @@
             (metabase [config :as config]
                       [db :as db])
             (metabase.models [field :as field]
+                             [humanization :as humanization]
                              [table :as table]
                              [setting :as setting])
             [metabase.public-settings :as settings]
@@ -12,7 +13,7 @@

 (def ^:private ^:const ^String metabase-usage-url "https://kqatai1z3c.execute-api.us-east-1.amazonaws.com/prod/ServerStatsCollector")

-(def ^:private ^Integer anonymous-id
+(def ^:private ^:const ^Integer anonymous-id
   "Generate an anonymous id. Don't worry too much about hash collisions or localhost cases, etc.
    The goal is to be able to get a rough sense for how many different hosts are throwing a specific error/event."
   (hash (str (java.net.InetAddress/getLocalHost))))
@@ -28,11 +29,11 @@
 (defn- bin-micro-number
   "Return really small bin number. Assumes positive inputs"
   [x]
-  (cond
-    (= 0 x) "0"
-    (= 1 x) "1"
-    (= 2 x) "2"
-    (> x 2) "3+"))
+  (case x
+    0 "0"
+    1 "1"
+    2 "2"
+    "3+"))

 (defn- bin-small-number
@@ -123,7 +124,7 @@
    :check_for_updates     (setting/get :check-for-updates)
    :site_name             (not= settings/site-name "Metabase")
    :report_timezone       (setting/get :report-timezone)
-   :friendly_names        (metabase.models.humanization/enable-advanced-humanization)
+   :friendly_names        (humanization/enable-advanced-humanization)
    :email_configured      ((resolve 'metabase.email/email-configured?))
    :slack_configured      ((resolve 'metabase.integrations.slack/slack-configured?))
    :sso_configured        (boolean (resolve 'metabase.api.session/google-auth-client-id))


add pixels fn for obtaining pixel array and further docstrings.

--- src/processing/core.clj
+++ src/processing/core.clj
@@ -1071,14 +1071,38 @@
      (.frameRate *applet* (float new-rate))))

 (defn frustum
-  [l r b t near far]
-  (.frustum *applet* (float l) (float r) (float b) (float t)
+  "Sets a perspective matrix defined through the parameters. Works
+  like glFrustum, except it wipes out the current perspective matrix
+  rather than muliplying itself with it."
+  [left right bottom top near far]
+  (.frustum *applet* (float left) (float right) (float bottom) (float top)
             (float near) (float far)))

 (defn get-pixel
+  "Reads the color of any pixel or grabs a section of an image. If no
+  parameters are specified, the entire image is returned. Get the
+  value of one pixel by specifying an x,y coordinate. Get a section of
+  the display window by specifying an additional width and height
+  parameter. If the pixel requested is outside of the image window,
+  black is returned. The numbers returned are scaled according to the
+  current color ranges, but only RGB values are returned by this
+  function. For example, even though you may have drawn a shape with
+  colorMode(HSB), the numbers returned will be in RGB.
+
+  Getting the color of a single pixel with (get x y) is easy, but not
+  as fast as grabbing the data directly using the pixels fn."
   ([] (.get *applet*))
   ([x y] (.get *applet* (int x) (int y)))
   ([x y w h] (.get *applet* (int x) (int y) (int w) (int h))))
+
+(defn pixels
+  "Array containing the values for all the pixels in the display
+  window. This array is therefore the size of the display window. If
+  this array is modified, the update-pixels fn must be called to update
+  the changes. Calls load-pixels before obtaining the pixel array."
+  []
+  (load-pixels)
+  (. *applet* :pixels))

 (defn green
   "Extracts the green value from a color, scaled to match current
@@ -1255,7 +1279,21 @@
   []
   (. *applet* :keyCode))

-(defn lights [] (.lights *applet*))
+(defn lights
+  "Sets the default ambient light, directional light, falloff, and
+  specular values. The defaults are:
+
+  (ambient-light 128 128 128)
+  (directional-light 128 128 128 0 0 -1)
+  (light-falloff 1 0 0)
+  (light-specular 0 0 0).
+
+  Lights need to be included in the draw to remain persistent in a
+  looping program. Placing them in the setup of a looping program
+  will cause them to only have an effect the first time through the
+  loop."
+  []
+  (.lights *applet*))

 (defn light-specular
   [x y z]
@@ -1304,7 +1342,19 @@

 (defn load-matrix [] (.loadMatrix *applet*))

-(defn load-pixels [] (.loadPixels *applet*))
+(defn load-pixels
+  "Loads the pixel data for the display window into the pixels[]
+  array. This function must always be called before reading from or
+  writing to pixels.
+
+  Certain renderers may or may not seem to require load-pixels or
+  update-pixels. However, the rule is that any time you want to
+  manipulate the pixels array, you must first call load-pixels, and
+  after changes have been made, call updatePixels. Even if the
+  renderer may not seem to use this function in the current Processing
+  release, this will always be subject to change."
+  []
+  (.loadPixels  *applet*))

 (defn load-shape
   "Load a geometry from a file as a PShape."


[experimental] add TTL to statuses collection

--- server/src/clinicico/server/store.clj
+++ server/src/clinicico/server/store.clj
@@ -25,8 +25,15 @@
    :db (str (:mongo-db config))
    :collection "statuses"})

+
+(defn- megabytes
+  [^long n]
+  (* n 1024 1024))
+
 (connect! mongo-options)
 (set-db! (get-db (mongo-options :db)))
+(collection/create (mongo-options :collection) {:capped true :size (-> 16 megabytes)})
+(collection/ensure-index (mongo-options :collection) {:modified 1} {:expireAfterSeconds 120})

 (defn retrieve
   [id]


change clojure verstion to pass tests

change clojure verstion to pass tests

--- datomic-dsl/project.clj
+++ datomic-dsl/project.clj
@@ -1,6 +1,6 @@
 (defproject datomic-dsl "0.1.0-SNAPSHOT"
-  :dependencies [[org.clojure/clojure "1.8.0"]
-                 [com.datomic/datomic-free "0.9.5350" :exclusions [joda-time]]]
+  :dependencies [[org.clojure/clojure "1.6.0"]
+                 [com.datomic/datomic-free "0.9.5130" :exclusions [joda-time]]]
   :main ^:skip-aot datomic-dsl.core
   :target-path "target/%s"
   :profiles {:uberjar {:aot :all}})


namespace is a confusing parameter name in clojure

--- src/prometheus/core.clj
+++ src/prometheus/core.clj
@@ -7,20 +7,20 @@
     (io.prometheus.client.utility.hotspot Hotspot)
     (java.io StringWriter ByteArrayOutputStream ByteArrayInputStream)))

-(def request-counter (atom nil))
-(def request-summary (atom nil))
+(def ^:private request-counter (atom nil))
+(def ^:private request-summary (atom nil))

-(defn- make-request-counter [namespace]
+(defn- make-request-counter [app-name]
   (-> (Counter/newBuilder)
-      (.namespace namespace)
+      (.namespace app-name)
       (.name "http_requests_total")
       (.labelNames (into-array String ["method" "status" "path"]))
       (.documentation "A counter of the total number of HTTP requests processed.")
       (.build)))

-(defn- make-request-summary [namespace]
+(defn- make-request-summary [app-name]
   (-> (Summary/newBuilder)
-      (.namespace namespace)
+      (.namespace app-name)
       (.name "http_request_durations_milliseconds")
       (.labelNames (into-array String ["method" "status" "path"]))
       (.documentation "A histogram of the response latency for HTTP requests (in milliseconds).")
@@ -84,8 +84,8 @@
   "Compojure handler to expose prometheus metrics in either protocol buffer binary or json format depending on the http request accept header"
   (if (accepts-proto-response request) (metrics-proto) (metrics-json)))

-(defn init! [namespace]
+(defn init! [app-name]
   (Prometheus/defaultInitialize)
   (Prometheus/defaultAddPreexpositionHook (Hotspot.))
-  (reset! request-counter (make-request-counter namespace))
-  (reset! request-summary (make-request-summary namespace)))
+  (reset! request-counter (make-request-counter app-name))
+  (reset! request-summary (make-request-summary app-name)))


only redraw if state changes

only redraw if state changes

--- src/solar_system_of_js/draw.cljs
+++ src/solar_system_of_js/draw.cljs
@@ -482,37 +482,41 @@
     (stroke!))
   (restore!))

+(def prev-state nil)
+
 (defn draw!
   "Draw the current state of the application."
   []
-  (save!)
-  (fill-style! "#222")
-  (fill-rect! 0 0 width height)
-  (set-cam! (:cam @state))
-
-  (draw-title! (:title @state))
-  (draw-js-core! (:js-core @state))
-  (draw-es-captions! (:es-captions @state))
-  (draw-highlight-layer! (:highlight-layer @state))
-
-  (draw-transpiler! (:transpiler @state))
-  (draw-linter! (:linter @state))
-  (draw-modulesys! (:modulesys @state))
-
-  (draw-static! (:static @state))
-
-  (draw-radar! (:radar @state))
-
-  (draw-js-face! (:js-face @state))
-
-  (draw-coffeescript! (:coffeescript @state))
-  (draw-dart! (:dart @state))
-  (draw-clojurescript! (:clojurescript @state))
-
-  (draw-other-langs! @state)
-
-  (restore!)
-  (draw-progress!)
+  (when (not= prev-state @state)
+    (set! prev-state @state)
+    (save!)
+    (fill-style! "#222")
+    (fill-rect! 0 0 width height)
+    (set-cam! (:cam @state))
+
+    (draw-title! (:title @state))
+    (draw-js-core! (:js-core @state))
+    (draw-es-captions! (:es-captions @state))
+    (draw-highlight-layer! (:highlight-layer @state))
+
+    (draw-transpiler! (:transpiler @state))
+    (draw-linter! (:linter @state))
+    (draw-modulesys! (:modulesys @state))
+
+    (draw-static! (:static @state))
+
+    (draw-radar! (:radar @state))
+
+    (draw-js-face! (:js-face @state))
+
+    (draw-coffeescript! (:coffeescript @state))
+    (draw-dart! (:dart @state))
+    (draw-clojurescript! (:clojurescript @state))
+
+    (draw-other-langs! @state)
+
+    (restore!)
+    (draw-progress!))

   ;; self-schedule the next frame to draw
   (.requestAnimationFrame js/window draw!))


CMR-4367: Fixed tests.

CMR-4367: Fixed tests.

--- ingest-app/src/cmr/ingest/config.clj
+++ ingest-app/src/cmr/ingest/config.clj
@@ -30,11 +30,14 @@
    This environment variable needs to be manually set when newer UMM version becomes official"
   {:default "1.0"})

-(def ingest-accept-umm-version
-  "Defines the latest umm version accepted by ingest - it's the latest official version."
-  {:collection (collection-umm-version)
-   :variable (variable-umm-version)
-   :service (service-umm-version)})
+(defn ingest-accept-umm-version
+  "Returns the latest umm version accepted by ingest for the given concept-type."
+  [concept-type]
+  (get
+   {:collection (collection-umm-version)
+    :variable (variable-umm-version)
+    :service (service-umm-version)}
+   concept-type))

 (defconfig ingest-username
   "Ingest database username"


now gather all the right files and order them for reload

--- sidecar/src/figwheel_sidecar/core.clj
+++ sidecar/src/figwheel_sidecar/core.clj
@@ -1,6 +1,9 @@
 (ns figwheel-sidecar.core
   (:require
    [cljs.compiler]
+   [cljs.analyzer :as ana]
+   [cljs.env]
+   [cljs.analyzer.api :as ana-api]
    [compojure.route :as route]
    [compojure.core :refer [routes GET]]
    [ring.util.response :refer [resource-response]]
@@ -9,6 +12,7 @@
    [watchtower.core :as wt :refer [watcher compile-watcher watcher* ignore-dotfiles file-filter extensions]]
    [clojure.core.async :refer [go-loop <!! <! chan put! sliding-buffer timeout]]
    [clojure.string :as string]
+   [clojure.set :refer [difference union]]
    [clojure.edn :as edn]
    [clojure.java.io :refer [as-file] :as io]
    [digest]
@@ -204,6 +208,16 @@
             (swap! file-md5-atom assoc filepath check-sum)
             changed?))))))

+(defn target-file-changed? [{:keys [file-md5-atom] :as st} ns-sym]
+  (let [file (cbapi/cljs-target-file-from-ns (:output-dir st) ns-sym)
+        filepath (str file)]
+    (when (.exists file)
+      (let [check-sum (digest/md5 file)
+            changed? (not= (get @file-md5-atom filepath)
+                           check-sum)]
+        (swap! file-md5-atom assoc filepath check-sum)
+        changed?))))
+
 (defn dependency-files [{:keys [output-to output-dir]}]
    [output-to (str output-dir "/goog/deps.js") (str output-dir "/cljs_deps.js")])

@@ -220,14 +234,69 @@
         :eval-body (slurp %)})
    (dependency-files st)))

+(def ^:dynamic *transitive-dep-cache* false)
+(declare transitive-dependents)
+
+;; mutual recursion
+(defn transitive-dependents* [n]
+  (let [deps (ana/ns-dependents n)]
+    (if (empty? deps)
+      #{}
+      (set (concat deps (mapcat transitive-dependents deps))))))
+
+(defn transitive-dependents [nm]
+  (let [cached (get-in @*transitive-dep-cache* (name nm))]
+    (if (not (nil? cached))
+      cached
+      (let [res (transitive-dependents* nm)]
+        (swap! *transitive-dep-cache* assoc (name nm) res)
+        res))))
+
+(defn topo-compare [nm nm2]
+  (cond
+    (= nm nm2) 0
+    (get (transitive-dependents nm) nm2) -1
+    :else 1))
+
+(defn mark-changed-ns [state ns-syms]
+  (mapv (fn [nm]
+          (vary-meta nm assoc :file-changed-on-disk
+                     (if (target-file-changed? state nm) true false)))
+        ns-syms))
+
+(defn topo-sort [ns-syms]
+  (vec (sort topo-compare ns-syms)))
+
+(defn find-figwheel-always []
+  (set (filter (fn [n] (-> n meta :figwheel-always)) (ana-api/all-ns))))
+
+(defn expand-to-all-ns [state changed-ns-syms']
+  (if (nil? cljs.env/*compiler*) ;; bail if no comp env
+    changed-ns-syms'
+    (let [changed-ns-syms       (set changed-ns-syms')
+          dependants            (set (mapcat
+                                      transitive-dependents
+                                      changed-ns-syms))
+          additional-dependents (difference dependants changed-ns-syms)
+          additional-dependents (mark-changed-ns state additional-dependents)
+          all-ns                (union changed-ns-syms additional-dependents)
+          all-names             (set (map name all-ns))
+          additional-always     (set (filter #(not (all-names (name %)))
+                                             (find-figwheel-always)))
+        all-ns'               (union all-ns additional-always)]
+      (topo-sort all-ns'))))
+
+(defn dependents-info [n]
+  (vec (ana/ns-dependents n)))
+
 (defn make-sendable-file
   "Formats a namespace into a map that is ready to be sent to the client."
   [st nm]
   (let [n (-> nm name underscore)]
-    { :file (str (cbapi/cljs-target-file-from-ns (:output-dir st) nm))
+    { :file (str (cbapi/cljs-target-file-from-ns "" nm))
       :namespace (cljs.compiler/munge n)
       :type :namespace
-      :meta-data (meta nm) }))
+      :meta-data (meta nm)}))

 ;; I would love to just check the compiled javascript files to see if
 ;; they changed and then just send them to the browser. There is a
@@ -247,9 +316,10 @@

 (defn notify-cljs-ns-changes [state ns-syms]
   (->> ns-syms
-       (map (partial make-sendable-file state))
-       (concat (get-dependency-files state))
-       (send-changed-files state)))
+    (expand-to-all-ns state)
+    (map (partial make-sendable-file state))
+    (concat (get-dependency-files state))
+    (send-changed-files state)))

 ;; this functionality should be moved to autobuilder or a new ns
 ;; this ns should just be for notifications?
@@ -266,10 +336,11 @@
   ;; this is the new way where if additional changes are needed they
   ;; are made explicitely
   ([state old-mtimes new-mtimes additional-ns]
+   (binding [*transitive-dep-cache* (atom {})]
      (notify-cljs-ns-changes state
-      (set (concat additional-ns
-              (keep get-ns-from-source-file-path
-                    (:cljs (get-changed-source-file-paths old-mtimes new-mtimes))))))))
+       (set (concat additional-ns
+                    (keep get-ns-from-source-file-path
+                          (:cljs (get-changed-source-file-paths old-mtimes new-mtimes)))))))))

 ;; css changes
 ;; this can be moved out of here I think


Bump thread pool size

Bump thread pool size

--- src/onyx_benchmark/peer.clj
+++ src/onyx_benchmark/peer.clj
@@ -72,6 +72,7 @@
                      :onyx.peer/join-failure-back-off 500
                      :onyx.peer/job-scheduler :onyx.job-scheduler/greedy
                      :onyx.peer/inbox-capacity 1000
+                     :onyx.messaging.netty/thread-pool-sizes 4
                      :onyx.messaging/impl :netty
                      :onyx.log/config logging-config}
         n-peers-parsed (Integer/parseInt n-peers)


Use some destructuring in defs-from-option-groups, though it's still awful messy.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -51,18 +51,18 @@
     (sql/do-prepared
       (format "delete from %s where %s" (table-name model-name) (to-conditions attributes)) [])))

-(defn- defs-from-option-groups [model-name options]
+(defn- defs-from-option-groups [model-name option-groups]
   (reduce
-    (fn [forms option-group]
-      (let [option-ns (symbol (str "clj-record." (name (first option-group))))]
+    (fn [forms [option-group-name & options]]
+      (let [option-ns (symbol (str "clj-record." (name option-group-name)))]
         (reduce
-          (fn [forms option-form]
-            (let [defs (apply (ns-resolve option-ns (first option-form)) model-name (rest option-form))]
+          (fn [forms [option-fn & option-args]]
+            (let [defs (apply (ns-resolve option-ns option-fn) model-name option-args)]
               (if defs (conj forms defs) forms)))
           forms
-          (rest option-group))))
+          options)))
     []
-    options))
+    option-groups))

 (def all-models-metadata (ref {}))


Reformatting.

Reformatting.

--- clj_record/core.clj
+++ clj_record/core.clj
@@ -119,23 +119,23 @@
   [& option-groups]
   (let [model-name (last (str-utils/re-split #"\." (name (ns-name *ns*))))
         optional-defs (defs-from-option-groups model-name option-groups)]
-      `(do
-        (init-model-metadata ~model-name)
-        (defn ~'model-metadata [& args#]
-          (apply model-metadata-for ~model-name args#))
-        (defn ~'table-name [] (table-name ~model-name))
-        (defn ~'get-record [id#]
-          (get-record ~model-name id#))
-        (defn ~'find-records [attributes#]
-          (find-records ~model-name attributes#))
-        (defn ~'create [attributes#]
-          (create ~model-name attributes#))
-        (defn ~'insert [attributes#]
-          (insert ~model-name attributes#))
-        (defn ~'update [attributes#]
-          (update ~model-name attributes#))
-        (defn ~'destroy-record [record#]
-          (destroy-record ~model-name record#))
-        (defn ~'validate [record#]
-          (clj-record.validation/validate ~model-name record#))
-        ~@optional-defs)))
+    `(do
+      (init-model-metadata ~model-name)
+      (defn ~'model-metadata [& args#]
+        (apply model-metadata-for ~model-name args#))
+      (defn ~'table-name [] (table-name ~model-name))
+      (defn ~'get-record [id#]
+        (get-record ~model-name id#))
+      (defn ~'find-records [attributes#]
+        (find-records ~model-name attributes#))
+      (defn ~'create [attributes#]
+        (create ~model-name attributes#))
+      (defn ~'insert [attributes#]
+        (insert ~model-name attributes#))
+      (defn ~'update [attributes#]
+        (update ~model-name attributes#))
+      (defn ~'destroy-record [record#]
+        (destroy-record ~model-name record#))
+      (defn ~'validate [record#]
+        (clj-record.validation/validate ~model-name record#))
+      ~@optional-defs)))


interim checkin. starting to work on emit

--- src/rapscallion/xml.clj
+++ src/rapscallion/xml.clj
@@ -17,7 +17,8 @@
   (tag [this] "Return the tag of the element")
   (attrs [this] "Return a map of the attributes of the element")
   (content [this] "Return a sequence of children of the element")
-  (uri [this] "Return the namespace URI of the element"))
+  (uri [this] "Return the namespace URI of the element")
+  (prefix [this] "Returns the prefix that should be used when emitting the element"))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -514,12 +515,19 @@
       xml-escape
       (.replaceAll "'"  "'")))

+(defn emit-attr [k v ^Writer out]
+  (.write out " ")
+  (if (keyword? k)))

 (defn emit-element [^Element e ^Writer out]
-  (let [{:keys [tag attrs content]} e]
+  (let [tag (tag e)
+        attrs (attrs e)
+        content (content e)
+        prefix (prefix e)
+        tagname (str prefix (if prefix \:) (name tag))]
     (doto out
       (.write "<")
-      (.write (name tag)))
+      (.write tagname))
     (doseq [[k v] attrs]
       (if-not (nil? v)
         (doto out
@@ -536,7 +544,7 @@
           (emit-xml child out))
         (doto out
           (.write "</")
-          (.write (name tag))
+          (.write tagname)
           (.write ">"))))))

 (defn emit-comment [^Comment c ^Writer out]


Remove unused file

Remove unused file

I have a very nice alias in my .zshrc, `ga`, which does git add --all.
I'm using it too much.

--- src/refactor_nrepl/test.clj
+++ src/refactor_nrepl/test.clj
@@ -1,6 +0,0 @@
-(ns refactor-nrepl.test
-  (:require
-   [clojure.string]))
-
-(defn tt [foo bar baz]
-  (println foo bar baz))


Well, I apparently CAN set the id in bulk upload item headers.

--- src/riemann/elastic.clj
+++ src/riemann/elastic.clj
@@ -120,12 +120,19 @@
         (doseq [index (keys esets)]
           (let [raw (get esets index)
                 bulk-create-items
-                (interleave (repeat {:create {:_type doc-type}})
+                (interleave (map #(if-let [id (get % "_id")]
+                                    {:create {:_type doc-type :_id id}}
+                                    {:create {:_type doc-type}}
+                                    )
+                                 raw)
                             raw)]
             (when (seq bulk-create-items)
-              (let [res (eb/bulk-with-index index bulk-create-items)]
-                (info "elasticized" (count (:items res)) "items to index " index "in " (:took res) "ms")
-                res))))))))
+              (try
+                (let [res (eb/bulk-with-index index bulk-create-items)]
+                  (info "elasticized" (count (:items res)) "items to index " index "in " (:took res) "ms")
+                  (info "Results: " res))
+                (catch Exception e
+                  (error "Unable to bulk index:" e))))))))))

 (defn ^{:private true} resource-as-json [resource-name]
   (json/parse-string (slurp (io/resource resource-name))))


Add received OSC messages to dubug output

--- src/overtone/sc/machinery/server/comms.clj
+++ src/overtone/sc/machinery/server/comms.clj
@@ -4,14 +4,17 @@
         [overtone.util.lib :only [uuid deref!]])
   (:require [overtone.util.log :as log]))

-(defonce osc-debug*     (atom false))
-(defonce server-osc-peer*        (ref nil))
+(defonce osc-debug*       (atom false))
+(defonce server-osc-peer* (ref nil))

 ;; The base handler for receiving osc messages just forwards the message on
 ;; as an event using the osc path as the event key.
 (on-sync-event :osc-msg-received
                (fn [{{path :path args :args} :msg}]
+                 (when @osc-debug*
+                   (println "Receiving: " path args)
+                   (log/debug (str "Receiving: " path args)))
                  (event path :path path :args args))
                ::osc-receiver)

@@ -40,8 +43,8 @@
   [path & args]
   (let [args (massage-numerical-args args)]
     (when @osc-debug*
-      (println "Sending: " path [args])
-      (log/debug (str "Sending: " path [args])))
+      (println "Sending: " path args)
+      (log/debug (str "Sending: " path args)))
     (apply validated-snd @server-osc-peer* path args)))

 (defn on-server-sync


Got rid of the anonymous function in run.

--- src/overtunes/songs/canone_alla_quarta.clj
+++ src/overtunes/songs/canone_alla_quarta.clj
@@ -55,13 +55,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (defn run [[from to & tos]]
-  (let [up-or-down (fn [start end]
-          (if (<= start end)
-            (range start end)
-            (reverse (range (inc end) (inc start)))))]
-    (if to
-      (concat (up-or-down from to) (run (cons to tos)))
-      [from])))
+    (if-not to
+      [from]
+      (concat
+        (if (<= from to)
+          (range from to)
+          (reverse (range (inc to) (inc from))))
+        (run (cons to tos)))))

 ;(demo# (map g-major
 ;            (run [0 3 1 3 -1 0])


Removed debugging code in melody#

Removed debugging code in melody#

--- src/overtunes/songs/canone_alla_quarta.clj
+++ src/overtunes/songs/canone_alla_quarta.clj
@@ -69,8 +69,7 @@
 (defn melody# [melody]
   (let [notes (update-all melody [:pitch :time] natural-seq)
         play-at #(at %1 (piano# %2))]
-    (dorun (map play-at (:time notes) (:pitch notes)))
-  notes))
+    (dorun (map play-at (:time notes) (:pitch notes)))))

 (defn update [k f] #(update-in % [k] f))
 (def mirror (update :pitch #(connect - %)))


javaparser: using :cu with map

javaparser: using :cu with map

--- src/app/javaparser.clj
+++ src/app/javaparser.clj
@@ -263,7 +263,7 @@
   (filter not-nil? (parseDirByName dirname)))

 (defn cus [dirname]
-  (map (fn [cuTuple] (:cu cuTuple)) (cusTuples dirname)))
+  (map :cu (cusTuples dirname)))

 (defn getConstructors [cl]
   (filter (fn [m] (instance? ConstructorDeclaration m)) (.getMembers cl)))


Simplify build task

Simplify build task

--- build.boot
+++ build.boot
@@ -37,34 +37,33 @@

 (deftask build []
   (comp
-   (pom
-    :project 'deraen/less4clj)
-   (with-files (fn [x]
-                 (re-find #"less4clj" (:path x)))
-               (comp
-                (jar
-                 :file (format "less4clj-%s.jar" +version+))
-                (install)))
+   (with-files
+    (fn [x] (re-find #"less4clj" (:path x)))
+    (comp
+     (pom
+      :project 'deraen/less4clj)
+     (jar)
+     (install)))

-   (pom
-    :project 'deraen/boot-less
-    :description "Boot task to compile Less code to Css. Uses Less4j Java implementation of Less compiler."
-    :dependencies [])
-   (with-files (fn [x] (re-find #"boot[-_]less" (:path x)))
-               (comp
-                (jar
-                 :file (format "boot-less-%s.jar" +version+))
-                (install)))
+   (with-files
+    (fn [x] (re-find #"boot[-_]less" (:path x)))
+    (comp
+     (pom
+      :project 'deraen/boot-less
+      :description "Boot task to compile Less code to Css. Uses Less4j Java implementation of Less compiler."
+      :dependencies [])
+     (jar)
+     (install)))

-   (pom
-    :project 'deraen/lein-less4j
-    :description "Leinigen task for Less4j"
-    :dependencies [])
-   (with-files (fn [x] (re-find #"less4j" (:path x)))
-               (comp
-                (jar
-                 :file (format "lein-less4j-%s.jar" +version+))
-                (install)))))
+   (with-files
+    (fn [x] (re-find #"less4j" (:path x)))
+    (comp
+     (pom
+      :project 'deraen/lein-less4j
+      :description "Leinigen task for Less4j"
+      :dependencies [])
+     (jar)
+     (install)))))

 (deftask dev []
   (comp


Check dependency sizes, move cljs libs to test scope

--- build.boot
+++ build.boot
@@ -15,6 +15,7 @@
                   [org.clojure/tools.nrepl "0.2.12" :scope "test"]
                   [adzerk/boot-reload     "0.5.1" :scope "test"]
                   [metosin/boot-alt-test  "0.3.0"      :scope "test"]
+                  [metosin/boot-deps-size "0.1.0-SNAPSHOT" :scope "test"]
                   [deraen/boot-less       "0.6.2"      :scope "test"]
                   ;; For boot-less
                   [org.slf4j/slf4j-nop    "1.7.21"     :scope "test"]
@@ -26,13 +27,13 @@
                   [reloaded.repl "0.2.3"]
                   [com.stuartsierra/component "0.3.1"]
                   [metosin/ring-http-response "0.8.0"]
-                  [ring "1.5.0"]
+                  [ring/ring-core "1.5.1"]
                   [compojure "1.5.1"]
                   [hiccup "1.0.5"]

                   ; Frontend
-                  [reagent "0.6.1-SNAPSHOT"]
-                  [binaryage/devtools "0.8.2"]
+                  [reagent "0.6.1-SNAPSHOT" :scope "test"]
+                  [binaryage/devtools "0.8.2" :scope "test"]

                   ; LESS
                   [org.webjars/bootstrap "3.3.6"]
@@ -44,6 +45,7 @@
   '[adzerk.boot-cljs-repl :refer [cljs-repl start-repl repl-env]]
   '[adzerk.boot-reload    :refer [reload]]
   '[metosin.boot-alt-test  :refer [alt-test]]
+  '[metosin.boot-deps-size :refer [deps-size]]
   '[deraen.boot-less      :refer [less]]
   '[deraen.boot-sass      :refer [sass]]
   '[crisptrutski.boot-cljs-test :refer [test-cljs prep-cljs-tests run-cljs-tests]]


Add :scope test

Add :scope test

--- build.boot
+++ build.boot
@@ -2,7 +2,7 @@
   :dependencies '[[adzerk/boot-cljs "2.1.4" :scope "test"]
                   [javax.xml.bind/jaxb-api "2.3.0" :scope "test"]
                   [seancorfield/boot-tools-deps "0.1.4" :scope "test"]
-                  [orchestra "2017.11.12-1"]]
+                  [orchestra "2017.11.12-1" :scope "test"]]
   :repositories (conj (get-env :repositories)
                   ["clojars" {:url "https://clojars.org/repo/"
                               :username (System/getenv "CLOJARS_USER")


Move files after building cljs

Move files after building cljs

--- build.boot
+++ build.boot
@@ -15,7 +15,9 @@
                   [eval-soup "1.2.0" :exclusions [org.clojure/core.async]]
                   [org.eclipse.jgit/org.eclipse.jgit "4.6.0.201612231935-r"]])

-(require '[adzerk.boot-cljs :refer [cljs]])
+(require
+  '[adzerk.boot-cljs :refer [cljs]]
+  '[clojure.java.io :as io])

 (task-options!
   sift {:include #{#"\.jar$"}}
@@ -31,17 +33,21 @@
 (deftask run []
   (comp
     (aot)
-    (with-pre-wrap fileset
+    (with-pass-thru _
       (require
         '[clojure.spec.test :refer [instrument]]
         '[nightcode.core :refer [dev-main]])
       ((resolve 'instrument))
-      ((resolve 'dev-main))
-      fileset)))
+      ((resolve 'dev-main)))))

 (deftask build []
   (comp (aot) (pom) (uber) (jar) (sift) (target)))

 (deftask build-cljs []
-  (comp (cljs :optimizations :advanced) (target)))
+  (comp
+    (cljs :optimizations :advanced)
+    (target)
+    (with-pass-thru _
+      (.renameTo (io/file "target/public/paren-soup.js") (io/file "resources/public/paren-soup.js"))
+      (.renameTo (io/file "target/public/codemirror.js") (io/file "resources/public/codemirror.js")))))


Fix typo

Fix typo

--- build.boot
+++ build.boot
@@ -128,7 +128,7 @@
                                     :namespaces    '[mikron.runtime.core-tests
                                                      mikron.runtime.buffer-tests]
                                     :optimizations (or opt :none)
-                                    :cljs-otps     cljs-compiler-opts))))
+                                    :cljs-opts     cljs-compiler-opts))))

 (deftask test-browser
   "Runs the tests in a browser environment."
@@ -139,7 +139,7 @@
                                   :namespaces    '[mikron.runtime.core-tests
                                                    mikron.runtime.buffer-tests]
                                   :optimizations (or opt :none)
-                                  :cljs-otps     cljs-compiler-opts)))
+                                  :cljs-opts     cljs-compiler-opts)))

 (deftask test
   "Runs the specified tests."


replaced (keyword “/“) with :/ as it’s syntactically correcy


add bookmarks(Get) route

add bookmarks(Get) route

--- src/bookmarks/core.clj
+++ src/bookmarks/core.clj
@@ -1,6 +1,7 @@
 (ns bookmarks.core
   (:require
    [compojure.core :refer :all]
+   [bookmarks.db.core :as db]
    [compojure.route :as route]
    [ring.adapter.jetty :as jetty]
    [ring.middleware.json :as ring-json]
@@ -17,8 +18,10 @@
   (render (io/resource "index.html") req))

+
 (defroutes app-routes
   (GET "/" [] home)
+  (GET "/bookmarks" [] (rr/content-type (rr/response  (db/get-bookmarks)) "application/json; charset=utf-8"))
   (route/resources "/static")
   (route/not-found "
Page not found
"))


Reimplement in shorter way calculate/verify signature on jws.

--- src/buddy/sign/jws.clj
+++ src/buddy/sign/jws.clj
@@ -106,96 +106,24 @@
       (codecs/bytes->str)
       (json/parse-string true)))

-(defmulti calculate-signature :alg)
-(defmulti verify-signature :alg)
+(defn- calculate-signature
+  "Given the bunch of bytes, a private key and algorithm,
+  return a calculated signature as byte array."
+  [{:keys [key alg header claims]}]
+  (let [signer (get-in *signers-map* [alg :signer])
+        authdata (str/join "." [header claims])]
+    (-> (signer authdata key)
+        (codecs/bytes->safebase64))))

-(defmethod calculate-signature :hs256
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (hmac/hash key :sha256)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :hs512
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (hmac/hash key :sha512)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :rs256
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapkcs/sign key :sha256)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :rs512
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapkcs/sign key :sha512)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :ps256
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapss/sign key :sha256)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :ps512
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapss/sign key :sha512)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :es256
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (ecdsa/sign key :sha256)
-      (codecs/bytes->safebase64)))
-
-(defmethod calculate-signature :es512
-  [{:keys [key alg header claims]}]
-  (-> (str/join "." [header claims])
-      (ecdsa/sign key :sha512)
-      (codecs/bytes->safebase64)))
-
-(defmethod verify-signature :hs256
+(defn- verify-signature
+  "Given a bunch of bytes, a previously generated
+  signature, the private key and algorithm, return
+  signature matches or not."
+  ;; [^bytes input ^bytes signature ^bytes key ^Keyword alg]
   [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (hmac/verify signature key :sha256)))
-
-(defmethod verify-signature :hs512
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (hmac/verify signature key :sha512)))
-
-(defmethod verify-signature :rs256
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapkcs/verify signature key :sha256)))
-
-(defmethod verify-signature :rs512
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapkcs/verify signature key :sha512)))
-
-(defmethod verify-signature :ps256
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapss/verify signature key :sha256)))
-
-(defmethod verify-signature :ps512
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (rsapss/verify signature key :sha512)))
-
-(defmethod verify-signature :es256
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (ecdsa/verify signature key :sha256)))
-
-(defmethod verify-signature :es512
-  [{:keys [alg signature key header claims]}]
-  (-> (str/join "." [header claims])
-      (ecdsa/verify signature key :sha512)))
+  (let [verifier (get-in *signers-map* [alg :verifier])
+        authdata (str/join "." [header claims])]
+   (verifier authdata signature key)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Public Api


fix standalone executables to work on ubuntu and various other linuces

--- src/cake/tasks/jar.clj
+++ src/cake/tasks/jar.clj
@@ -101,7 +101,7 @@
       (when (newer? uberjar binfile)
         (log "Creating standalone executable:" (.getPath binfile))
         (with-open [bin (FileOutputStream. binfile)]
-          (.write bin (.getBytes "#!/usr/bin/env java -jar\n"))
+          (.write bin (.getBytes "#!/usr/bin/env sh\nexec java -jar $0 $@\n"))
           (copy uberjar bin))
         (ant Chmod {:file binfile :perm "+x"})))
     (println "Cannot create bin without :main namespace in project.clj")))


Put render-controls nearer top.

Put render-controls nearer top.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -64,6 +64,14 @@

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

+(defn render-controls[app owner]
+     (apply dom/ul nil
+            (map (fn [[k v]]
+                   (dom/li nil
+                           (dom/button #js {:onClick v}
+                                       k)))
+                 (:controls app))))
+
 (defn render-world [app owner]
   (apply dom/ul nil
          (map (fn [[k v]] (dom/li nil (str k ":" v))) app)))
@@ -100,19 +108,9 @@
            [nil []]
            (:events app)))))

-(defn render-controls[app owner]
-     (apply dom/ul nil
-            (map (fn [[k v]]
-                   (dom/li nil
-                           (dom/button #js {:onClick v}
-                                       k)))
-                 (:controls app))))
-
 (defn init-roots []
   (om/root render-controls run-controls
            {:target (. js/document (getElementById "controls"))})
-  (om/root render-events run-history
-           {:target (. js/document (getElementById "events"))})
   (om/root render-world run-world
            {:target (. js/document (getElementById "world"))})
   (om/root render-world run-world
@@ -120,7 +118,9 @@
   (om/root render-world run-world-hover
            {:target (. js/document (getElementById "world-hover"))})
   (om/root render-world run-world-hover
-           {:target (. js/document (getElementById "world-map-hover"))}))
+           {:target (. js/document (getElementById "world-map-hover"))})
+  (om/root render-events run-history
+           {:target (. js/document (getElementById "events"))}))

 (defn world-vis-init [el-prefix init-event-delay]
   (init-roots)


Split app-state into several atoms.

Split app-state into several atoms.

--- src/cbfg/world/t1.cljs
+++ src/cbfg/world/t1.cljs
@@ -6,49 +6,37 @@

 ;; How to assign locations to world entities before rendering?

-(def app-state
-  (atom
-   {:text "hello"
-    :controls ["play" "step" "pause"]
-    :speed 1.0
-    :snapshots {0 {}
-                10 {:a 1 :b 2 :c 3 :d 4}
-                20 {:a 11 :b 22 :c 33 :d 44}}
-    :events [[0 :snapshot]
-             [1 :event [:a 1]]
-             [2 :event [:b 2]]
-             [3 :event [:c 3]]
-             [4 :event [:d 4]]
-             [10 :snapshot]
-             [11 :event [:a 11]]
-             [12 :event [:b 22]]
-             [13 :event [:c 33]]
-             [14 :event [:d 44]]
-             [20 :snapshot]
-             [21 :event [:a 21]]
-             [22 :event [:b 22]]]
-    :world {:a 11 :b 22 :c 33}
-    :hover nil}))
+(def app-controls
+  (atom {:controls ["play" "step" "pause"]
+         :speed 1.0}))

 (def app-history
-  (atom []))
+  (atom {:snapshots {0 {}
+                     10 {:a 1 :b 2 :c 3 :d 4}
+                     20 {:a 11 :b 22 :c 33 :d 44}}
+         :events [[0 :snapshot]
+                  [1 :event [:a 1]]
+                  [2 :event [:b 2]]
+                  [3 :event [:c 3]]
+                  [4 :event [:d 4]]
+                  [10 :snapshot]
+                  [11 :event [:a 11]]
+                  [12 :event [:b 22]]
+                  [13 :event [:c 33]]
+                  [14 :event [:d 44]]
+                  [20 :snapshot]
+                  [21 :event [:a 21]]
+                  [22 :event [:b 22]]]}))

-(def app-future
-  (atom []))
+(def app-world
+  (atom {:a 11 :b 22 :c 33 :d 44}))

-(def transient-state
-  (atom nil))
-
-(def preview-state
-  (atom {:focus nil}))
-
-(def ghost-state
+(def app-world-ghost
   (atom nil))

 (defn render-world [app owner]
   (apply dom/ul nil
-         (map (fn [[k v]] (dom/li nil (str k ":" v)))
-              (:world app))))
+         (map (fn [[k v]] (dom/li nil (str k ":" v))) app)))

 (defn render-snapshot [app owner ss-ts]
   (apply dom/ul nil
@@ -60,13 +48,13 @@
 (defn event-blur [snapshot-ts event-ts]
   (println :event-blur snapshot-ts event-ts))

-(defn init-roots [app-state]
+(defn init-roots []
   (om/root
    (fn [app owner]
      (apply dom/ul nil
             (map (fn [x] (dom/li nil (dom/button nil x)))
                  (:controls app))))
-   app-state
+   app-controls
    {:target (. js/document (getElementById "controls"))})

   (om/root
@@ -91,13 +79,13 @@
                                  (str ts (pr-str args))))]))
               [nil []]
               (:events app)))))
-   app-state
+   app-history
    {:target (. js/document (getElementById "events"))})

-  (om/root render-world app-state
+  (om/root render-world app-world
            {:target (. js/document (getElementById "world"))})
-  (om/root render-world app-state
+  (om/root render-world app-world
            {:target (. js/document (getElementById "world-map"))}))

 (defn world-vis-init [el-prefix init-event-delay]
-  (init-roots app-state))
+  (init-roots))


adding clean fn

adding clean fn

--- src/celestial/jobs.clj
+++ src/celestial/jobs.clj
@@ -141,3 +141,8 @@
       (trace "shutting down" k w)
       (mq/stop w))))

+(defn clean-shutdown
+  "Clear jobs and shutdown workers"
+  []
+  (shutdown-workers)
+  (clear-all))


rename function

rename function

--- src/chat/server/db.clj
+++ src/chat/server/db.clj
@@ -286,7 +286,7 @@
        (d/db *conn*)
        user-id))

-(defn- get-users-subscribe-to-tag [tag-id]
+(defn- get-users-subscribed-to-tag [tag-id]
   (d/q '[:find [?user-id ...]
          :in $ ?tag-id
          :where
@@ -301,7 +301,7 @@
         (map (fn [user-id]
                [:db/add [:user/id user-id]
                 :user/subscribed-thread [:thread/id thread-id]])
-             (get-users-subscribe-to-tag tag-id))]
+             (get-users-subscribed-to-tag tag-id))]
     (d/transact *conn* (conj subscriber-transactions
                              [:db/add [:thread/id thread-id]
                               :thread/tag [:tag/id tag-id]]))))


wrapped counter query in a def.

wrapped counter query in a def.

--- src/clj/forma/core.clj
+++ src/clj/forma/core.clj
@@ -20,8 +20,8 @@
   [path]
   (w/hfs-tap (whole-file ["file"]) path))

+(def testquery
+  (?<- (stdout) [?count]
+     ((hfs-wholefile nasa-dir-path) ?file)
+     (c/count ?count)))

-
-(?<- (stdout) [?count]
-     ((hfs-wholefile nasa-dir-path) ?file)
-     (c/count ?count))


More convenient re-compile link on failure page

--- src/clj/inky/entry.clj
+++ src/clj/inky/entry.clj
@@ -307,7 +307,8 @@
                         (apply str)))))))

 (defn sketch-page [login gist-id {:keys [doc ns created url user source inky-version compile-res]}]
-  (let [sketch-url (str "/" login "/" gist-id "/sketch")
+  (let [main-url (str "/" login "/" gist-id)
+        sketch-url (str "/" login "/" gist-id "/sketch")
         gist-url (str "https://gist.github.com/" login "/" gist-id)
         user-url (str "https://github.com/" login)]
     ($layout
@@ -321,7 +322,7 @@
          (if-not (:success compile-res)
            [:section.compile-failed
             [:h2 "Ruh-Roh, compile failed:"]
-            [:p "Rerun compilation by setting query param " [:code "recompile=true"] " on this page."]
+            [:p [:a {:href (str main-url "?recompile=true")} "Click here"] " to recompile. You can also re-run compilation by setting query param " [:code "recompile=true"] " on this page."]
             [:pre
              "# Compilation result:\n\n"
              (util/pp-str compile-res)]]


Some more store tests.

Some more store tests.

--- src/cbfg/store-test.cljs
+++ src/cbfg/store-test.cljs
@@ -4,15 +4,23 @@
             [cbfg.store :as store]))

 (defn e [n result expect]
-  (println (swap! n inc) ":"
-           (if (= result expect) "pass" (str "FAIL:" result expect)))
+  (println (str (swap! n inc) ":")
+           (if (= result expect)
+             (str "pass: " (:key expect))
+             (str "FAIL:" result expect)))
   (= result expect))

 (defn test [actx opaque-id]
   (ago test actx
        (let [n (atom 0)
-             s (store/make-store)]
+             s (store/make-store test)]
          (if (and (e n (atake test (store/store-get test s 1 "does-not-exist"))
-                     {:status :not-found, :key "does-not-exist", :opaque 1}))
+                     {:status :not-found, :key "does-not-exist", :opaque 1})
+                  (e n (atake test (store/store-get test s 2 "does-not-exist2"))
+                     {:status :not-found, :key "does-not-exist2", :opaque 2})
+                  (e n (atake test (store/store-del test s 3 "does-not-exist" 0))
+                     {:status :not-found, :key "does-not-exist", :opaque 3})
+                  (e n (atake test (store/store-set test s 4 "does-not-exist" 0 "" :replace))
+                     {:status :not-found, :key "does-not-exist", :opaque 4}))
            "pass"
            (str "FAIL: on test #" @n)))))


Always create a new goog/deps.js file.

Always create a new goog/deps.js file.

--- src/clj/cljs/closure.clj
+++ src/clj/cljs/closure.clj
@@ -643,11 +643,11 @@
    The deps file for the current project will include third-party
    libraries."
   [opts & sources]
-  (let [disk-sources (map #(source-on-disk opts %) sources)
-        goog-deps-url (io/resource "goog/deps.js")]
-    (do (write-javascript opts {:url goog-deps-url
-                                :source (deps-file opts (filter #(= (:group %) :goog) disk-sources))})
-        (output-deps-file opts (remove #(= (:group %) :goog) disk-sources)))))
+  (let [disk-sources (map #(source-on-disk opts %) sources)]
+    (let [goog-deps (io/file (output-directory opts) "goog/deps.js")]
+      (do (mkdirs goog-deps)
+          (spit goog-deps (deps-file opts (filter #(= (:group %) :goog) disk-sources)))
+          (output-deps-file opts (remove #(= (:group %) :goog) disk-sources))))))

 (comment


add more to resp log

add more to resp log

--- src/clj/searchbot/es.clj
+++ src/clj/searchbot/es.clj
@@ -11,7 +11,21 @@

 (defn- pr-resp
   [resp]
-  (println "[resp]" (-> resp :aggregations keys first) "took" (:took resp) "ms"))
+  (let [took (:took resp)
+        top-agg-key (-> resp :aggregations keys first)
+        top-agg-buckets (-> resp :aggregations top-agg-key :buckets)
+        top-agg (->> top-agg-buckets (map (juxt :key :doc_count)) flatten)
+        hits (-> resp :hits :total)
+        shards ((juxt :total :successful :failed) (:_shards resp))]
+    (println "[now]" (java.util.Date.)
+             "[resp]" top-agg-key
+             "[took]" took "ms"
+             "[shards]" shards
+             "[hits]" hits
+             "[agg]" top-agg)
+;;     (println "[raw]" (keys resp))
+;;     (println "[raw]" (:_shards resp))
+    ))

 (defn es-search
   ([host idx query]


Change default entry point to a working example

--- src/cljs/gampg/core.cljs
+++ src/cljs/gampg/core.cljs
@@ -12,6 +12,8 @@
             [gampg.learn-gamma.lesson-11 :as lg11]
             [gampg.learn-gamma.lesson-12 :as lg12]
             [gampg.learn-gamma.lesson-13 :as lg13]
+            [gampg.learn-gamma.lesson-14 :as lg14]
+            [gampg.learn-gamma.lesson-15 :as lg15]
             ;;[gampg.learn-gamma.lesson-20 :as lg20]
             [gampg.learn-gamma.apartment :as lg-apartment]
             [gampg.learn-gamma.gltf :as lg-gltf]
@@ -24,13 +26,13 @@
 ;;
 ;; XXX: We're not properly reusing gl context's here, hurts fighweel's
 ;; reloadability
-(def title   lg-apartment/title)
-(def prog    lg-apartment/program-source)
-(def gl-main lg-apartment/main)
+;; (def title   lg-apartment/title)
+;; (def prog    lg-apartment/program-diffuse-per-fragment)
+;; (def gl-main lg-apartment/main)

-;; (def title   lg20/title)
-;; (def prog    lg20/program-sky-box)
-;; (def gl-main lg20/main)
+(def title   lg14/title)
+(def prog    lg14/program-specular)
+(def gl-main lg14/main)

 (defonce app-state (atom {:live {}}))

@@ -76,13 +78,12 @@
                                         (get-in prog [:fragment-shader :glsl])))))))
      app-state
      {:target (. js/document (getElementById "app"))})
-    (gl-main gl node)))
+    (gl-main node)))

 ;; Temporarily here for debugging

 (defn main []
-  (let [node (js/document.getElementById "glcanvas")
-        gl   (.getContext node "webgl")]
+  (let [node (js/document.getElementById "glcanvas")]
     (main*)))

 (aset js/window "reinstallApp"


Simplifying coercion logic

Simplifying coercion logic

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -157,24 +157,20 @@

 ;; this is vastly oversimplistic.
 (defn go-needs-coercion? [from to]
-  (not (or (set? from)
-           (and (= 'string from) (= 'array to)) ;; strings are indexable
-           ('#{clj-nil clj clj-or-nil} to)
-           (contains? (hash-set to 'clj-nil) from))))
+  (and (not (= (go-type to) "interface{}"))
+       (not= (go-type from) (go-type to))
+       ;; strings are indexable, but this is a dubious way to deal with it
+       (not (and (= 'string from) (= 'array to)))))

 (declare emit-str)

-(defn go-unbox-no-emit
-  ([from x] (go-unbox-no-emit from (go-type from) x))
-  ([from to x]
-     (when (go-needs-coercion? from (:tag x))
-       (str ".(" to ")"))))
-
-(defn go-unbox
-  ([from x] (go-unbox from (go-type from) x))
-  ([from to x]
-     (when x
-       (str (emit-str x) (go-unbox-no-emit from to x)))))
+(defn go-unbox-no-emit [to x]
+  (when (go-needs-coercion? (:tag x) to)
+    (str ".(" (go-type to) ")")))
+
+(defn go-unbox [to x]
+  (when x
+    (str (emit-str x) (go-unbox-no-emit to x))))

 (def go-native-decorator '{string js.JSString})
 (def go-native-property-decorator '{cljs$lang$maxFixedArity CljsLangFn_
@@ -799,8 +795,7 @@

       ;; this is somewhat optimistic, the analyzer tags the expression based on the body of the fn, not the actual return type.
       (when-not (or native? has-primitives?
-                    (= :statement (:context env))
-                    (= "interface{}" (-> expr :tag go-type)))
+                    (= :statement (:context env)))
         (emits (go-unbox-no-emit (:tag expr) nil))))))

 (defn normalize-goog-ctor [ctor]


Missing :else

Missing :else

--- src/cljs/go/compiler.clj
+++ src/cljs/go/compiler.clj
@@ -213,6 +213,7 @@
     (cond
       (truthy-constant? test) (emitln then)
       (falsey-constant? test) (emitln else)
+      :else
       (if (= :expr context)
         (emits "(func() { if " (when checked "Truth_") "(" test ") { return " then "} else { return " else "} )()")
         (do


Fix compiler warning

Fix compiler warning

--- src/cljx/revue/util.cljx
+++ src/cljx/revue/util.cljx
@@ -158,11 +158,11 @@
             #+clj (-> (java.io.StringReader. string)
                       clojure.lang.LineNumberingPushbackReader.)
             #+cljs (reader/push-back-reader string)]
-           (loop [form (reader/read stream false stream)
+           (loop [form (reader/read stream false stream false)
                   forms []]
              (if (identical? form stream)
                forms
-               (recur (reader/read stream false stream)
+               (recur (reader/read stream false stream false)
                       (conj forms form)))))
     (catch #+clj java.lang.Exception #+cljs js/Error e
            [::syntax-error])))


Refactor basic mouse streams and atoms on workspace/base.

--- src/uxbox/ui/workspace/base.cljs
+++ src/uxbox/ui/workspace/base.cljs
@@ -79,25 +79,32 @@

 (defonce mouse-b (rx/bus))
 (defonce mouse-s
-  (->> mouse-b
-       (rx/filter #(= (:id %) (:id @page-l)))
+  (rx/dedupe mouse-b))
+
+(defonce mouse-canvas-s
+  (->> mouse-s
        (rx/map :canvas-coords)
        (rx/share)))

-(defonce mouse-a
-  (rx/to-atom mouse-s))
+(defonce mouse-canvas-a
+  (rx/to-atom mouse-canvas-s))
+
+(defonce mouse-viewport-s
+  (->> mouse-s
+       (rx/map :viewport-coords)
+       (rx/share)))
+
+(defonce mouse-viewport-a
+  (rx/to-atom mouse-viewport-s))

 (defonce mouse-absolute-s
-  (->> mouse-b
-       (rx/filter #(= (:id %) (:id @page-l)))
+  (->> mouse-s
        (rx/map :window-coords)
        (rx/share)))

 (defonce mouse-ctrl-s
-  (->> mouse-b
-       (rx/filter #(= (:id %) (:id @page-l)))
+  (->> mouse-s
        (rx/map :ctrl)
-       (rx/dedupe)
        (rx/share)))

 (defn- coords-delta
@@ -105,18 +112,11 @@
   (gpt/subtract new old))

 (defonce mouse-delta-s
-  (->> mouse-s
+  (->> mouse-viewport-s
        (rx/sample 10)
        (rx/buffer 2 1)
        (rx/map coords-delta)
        (rx/share)))
-
-(defonce mouse-position
-  (->> mouse-s
-       (rx/sample 10)
-       (rx/to-atom)))
-
-(defonce bounding-rect (atom {}))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Constants


Add separate card for search-results

Add separate card for search-results

--- src/discuss/cards.cljs
+++ src/discuss/cards.cljs
@@ -3,7 +3,7 @@
             [sablono.core :as html :refer-macros [html]]
             [om.next :as om :refer-macros [defui]]
             [discuss.parser :as parser]
-            [discuss.components.search.statements :refer [SearchQuery]]
+            [discuss.components.search.statements :refer [SearchQuery Results]]
             [discuss.utils.common :as lib]
             [discuss.views :as views]))

@@ -20,10 +20,16 @@
   (om/reconciler {:state test-data
                   :parser (om/parser {:read parser/read :mutate parser/mutate})}))

-(defcard search-query-card-no-next
+(defcard search-query
   (dom-node
    (fn [_ node]
-     (om/add-root! devcard-reconciler SearchQuery node)))
+     (om/add-root! parser/reconciler SearchQuery node)))
+  {:inspect-data true})
+
+(defcard search-results
+  (dom-node
+   (fn [_ node]
+     (om/add-root! parser/reconciler Results node)))
   {:inspect-data true})


Now possible to add new wishlists to database

--- src/wishlistd/models/queries.clj
+++ src/wishlistd/models/queries.clj
@@ -24,4 +24,8 @@
   (sql/with-connection db
 	(sql/with-query-results results
       ["select * from wishlist where code=?" code]
-      (into [] results))))+      (into [] results))))
+
+(defn insert-row-wishlist [wishlist]
+  (sql/with-connection db
+	(sql/insert-records :wishlist wishlist)))


Forgot to remove outdated import

Forgot to remove outdated import

--- src/wishlistd/views/wishlist.clj
+++ src/wishlistd/views/wishlist.clj
@@ -1,6 +1,5 @@
 (ns wishlistd.views.wishlist
-  (:require [wishlistd.views.common :as common]
-            [wishlistd.models.sql :as model])
+  (:require x[wishlistd.models.sql :as model])
   (:use noir.fetch.remotes))

 (def layout (slurp "resources/public/index.html"))


saving state

saving state

--- src-cljs/cljsbuild_ui/pages/main.cljs
+++ src-cljs/cljsbuild_ui/pages/main.cljs
@@ -289,6 +289,31 @@
       ;; loop back
       (handle-compiler-output c prj-key current-bld-key))))

+(defn- get-active-bld-ids [prj]
+  (->> prj
+    :builds
+    (filter #(true? (:active? %)))
+    (map :id)))
+
+(defn- start-auto-compile! [prj-key active-bld-ids]
+  (exec/start-auto prj-key active-bld-ids)
+  ;; TODO: finish me
+  )
+
+(defn- start-compile-once! [prj-key active-bld-ids]
+  (exec/build-once prj-key active-bld-ids)
+  ;; TODO: finish me
+  )
+
+(defn- click-compile-btn [prj-key]
+  (let [prj (get-in @state [:projects prj-key])
+        active-bld-ids (get-active-bld-ids prj)]
+    ;; safeguard
+    (when-not (zero? (count active-bld-ids))
+      (if (:auto-compile? prj)
+        (start-auto-compile! prj-key active-bld-ids)
+        (start-compile-once! prj-key active-bld-ids)))))
+
 (defn- click-auto-btn [prj-key]
   (let [current-bld-key (atom nil)]
     (remove-compiled-info! prj-key)
@@ -502,9 +527,8 @@
     (map-indexed #(build-option %1 %2 prj-key) (:builds prj))])

 (sablono/defhtml idle-buttons [prj-key prj]
-  ;(start-auto-btn prj-key num-selected-builds)
-  ;(build-once-btn prj-key num-selected-builds)
   [:button.compile-btn-17a78
+    {:on-click #(click-compile-btn prj-key)}
     (if (:auto-compile? prj)
       "Auto Compile"
       "Compile Once")


move key-values out of :cljsbuild into the build parent

--- src-cljs/cljsbuild_ui/pages/main.cljs
+++ src-cljs/cljsbuild_ui/pages/main.cljs
@@ -30,12 +30,11 @@
           :warnings []

           ;; copied directly from project.clj
-          :cljsbuild {
-            :source-paths ["src/client"]
-            :compiler {
-              :output-to "public/js/client.js"
-              :output-dir "public/out"
-              :optimizations :whitespace }}}
+          :source-paths ["src/client"]
+          :compiler {
+            :output-to "public/js/client.js"
+            :output-dir "public/out"
+            :optimizations :whitespace }}

         { :id :client-adv
           :active? true
@@ -46,13 +45,12 @@
           :warnings []

           ;; copied directly from project.clj
-          :cljsbuild {
-            :source-paths ["src/client"]
-            :compiler {
-              :externs ["externs/jquery-1.9.js" "externs/socket.io.js"]
-              :output-to "public/js/client.min.js"
-              :optimizations :advanced
-              :pretty-print false }}}
+          :source-paths ["src/client"]
+          :compiler {
+            :externs ["externs/jquery-1.9.js" "externs/socket.io.js"]
+            :output-to "public/js/client.min.js"
+            :optimizations :advanced
+            :pretty-print false }}

         { :id :server
           :active? true
@@ -63,14 +61,13 @@
           :warnings []

           ;; copied directly from project.clj
-          :cljsbuild {
-            :source-paths ["src/server"]
-            :compiler {
-              :language-in :ecmascript5
-              :language-out :ecmascript5
-              :target :nodejs
-              :output-to "server.js"
-              :optimizations :simple }}}]}
+          :source-paths ["src/server"]
+          :compiler {
+            :language-in :ecmascript5
+            :language-out :ecmascript5
+            :target :nodejs
+            :output-to "server.js"
+            :optimizations :simple }}]}

     "/home/oakmac/project2/project.clj" {
       :auto-compile? false
@@ -88,11 +85,10 @@
             "Use of undeclared Var project2.core/bar at line 80 src-cljs/project2/core.cljs"
           ]

-          :cljsbuild {
-            :source-paths ["src-cljs"]
-            :compiler {
-              :optimizations :whitespace
-              :output-to "public/js/main.js"}}}
+          :source-paths ["src-cljs"]
+          :compiler {
+            :optimizations :whitespace
+            :output-to "public/js/main.js"}}

         { :id :main-min
           :active? true
@@ -101,13 +97,10 @@
           :state :done-with-error
           :warnings []

-          :cljsbuild {
-            :source-paths ["src-cljs"]
-            :compiler {
-              :optimizations :advanced
-              :output-to "public/js/main.min.js"}}}]}
-  }
-  }))
+          :source-paths ["src-cljs"]
+          :compiler {
+            :optimizations :advanced
+            :output-to "public/js/main.min.js"}}]}}})

 ;;------------------------------------------------------------------------------
 ;; Util
@@ -120,7 +113,7 @@
 ;; should probably refactor with a filter?
 (defn- output-to->bld-id [prj-key output-to]
   (let [blds (get-in @state [:projects prj-key :builds])
-        outputs (map #(-> % :cljsbuild :compiler :output-to) blds)
+        outputs (map #(-> % :compiler :output-to) blds)
         ids (map :id blds)
         m (zipmap outputs ids)]
     (get m output-to)))
@@ -518,11 +511,11 @@
     [:tbody
       [:tr {:class (build-row-class bld)}
         [:td.cell-9ad24 (-> bld :id name)]
-        [:td.cell-9ad24 (-> bld :cljsbuild :source-paths first)] ;; TODO: need to print the vector here
-        [:td.cell-9ad24 (-> bld :cljsbuild :compiler :output-to)]
+        [:td.cell-9ad24 (-> bld :source-paths first)] ;; TODO: need to print the vector here
+        [:td.cell-9ad24 (-> bld :compiler :output-to)]
         [:td.cell-9ad24 (state-cell bld)]
         [:td.cell-9ad24 (last-compile-cell bld)]
-        [:td.cell-9ad24 (-> bld :cljsbuild :compiler :optimizations name)]]
+        [:td.cell-9ad24 (-> bld :compiler :optimizations name)]]
       (when (:error bld)
         (error-row (:error bld)))
       (when (and (:warnings bld)


don't show tooltip for closing menu

don't show tooltip for closing menu

--- src-cljs/frontend/components/app.cljs
+++ src-cljs/frontend/components/app.cljs
@@ -114,7 +114,7 @@
          [:div.main-actions
           [:a.action-menu {:on-click #(cast! :aside-menu-toggled)
                            :class (when-not aside-opened? "closed")
-                           :data-right (if aside-opened? "Close Menu" "Open Menu")}
+                           :data-right (when-not aside-opened? "Open Menu")}
            (common/icon :menu)]
           (when (and (not aside-opened?) (pos? unread-chat-count))
             [:div.unseen-eids (str unread-chat-count)])


1_3_4

--- src/sicp_tasks_on_clojure/chapter1_3_4.clj
+++ src/sicp_tasks_on_clojure/chapter1_3_4.clj
@@ -38,4 +38,13 @@
 (defn sqrt [x]
   (fixed-point-of-transform (fn [y] (- (square y) x))
                             newton-transform
-                            1.0))+                            1.0))
+
+(defn cubic [a b c]
+  (fn [x] (+ (cube x)
+             (* a (square x))
+             (* b x)
+             c)))
+
+(defn find-zero [a b c]
+  (newton-method (cubic a b c) 1))


test(model.connection): should not make new conncetion violating schema

--- test/busa_server/model/connection_test.clj
+++ test/busa_server/model/connection_test.clj
@@ -29,6 +29,9 @@
          :to-place (:to-place connection)
          :from-place (:from-place connection)}))

+  (fact "should not make new connection violating schema"
+    (c/make-connection {:id "123qwe"}) => (throws Exception))
+
   (fact "should save new connection"
     (c/save [connection]) => (contains {:inserted 1}))

@@ -37,4 +40,5 @@

   (fact "should not save invalid connection with too long id"
     (c/save [connection-with-too-long-id]) => (throws Exception))
+
 )


try-catch

try-catch


probabilistic spying; println profiling for `admissibles`

I had suspected that the reason we saw such a big speedup from using the
Cartesian product of what I've been calling "spot-admissibles" (even
though Cartesian products can get very expensive very fast) is because
the prefix trees thin out quickly enough such that there are fewer
prefix-admissible strings than the six-or-whatever thousand English
words of a given length. The crudely-collected ("collected") data
available after this commit seems to bear this intuition out: while
solving a 5x5 grid, words-fitting-across is of course constant at 5883,
whereas string-admissible-down is usually much smaller (mean 1207,
median 4, standard deviation 16173, maximum 308000; this from data
gathered, cleaned, and summarized from the println output through an
absurd multi-step procedure involving copy-paste, Emacs, grep, and
Python 3.4's statistics module; you can ask why I didn't just do it
sanely in Clojure in the first place but I'm sorry).


fix test: don't enable anti-forgery in dev environment

--- src/clj/conference_rating/handler.clj
+++ src/clj/conference_rating/handler.clj
@@ -111,7 +111,8 @@
 (defn ring-settings [ssl-redirect-disabled]
   (-> secure-api-defaults
       (assoc-in [:security :ssl-redirect] (not ssl-redirect-disabled))
-      (assoc-in [:security :anti-forgery] true)
+      (assoc-in [:security :anti-forgery] (not (env :dev)))
+      (assoc-in [:security :frame-options] :deny)
       (assoc :proxy true)))

 (defn prevent-open-redirect-through-relay-state [handler]


replace wrap-on-close with more generic on-close-pipe

--- src/cljc/commos/delta/compscribe.cljc
+++ src/cljc/commos/delta/compscribe.cljc
@@ -281,18 +281,18 @@
       (meta)
       ::swapped-out))

-(defn- wrap-on-close
-  "Returns a channel that transports from source, but invokes on-close
-  when source has closed."
-  [source on-close]
-  (let [target (chan 1 (fn [rf]
-                         (completing rf
-                                     (fn [result]
-                                       (on-close)
-                                       (rf result)))))]
-
-    (pipe source target)
-    target))
+(defn- on-close-pipe
+  "Like pipe, but invokes on-close when source closes."
+  [source target on-close]
+  (let [watch-ch (chan 1 (fn [rf]
+                           (completing rf
+                                       (fn [result]
+                                         (on-close)
+                                         (rf result)))))]
+
+    (pipe source watch-ch)
+    (pipe watch-ch target)))
+

 (defn compscribe


Update index when components changes

Update index when components changes

--- src/warehouse/core.cljs
+++ src/warehouse/core.cljs
@@ -207,6 +207,12 @@
                         :name (:name component)
                         :tags (:tags component)})))

+(add-watch app-state nil (fn [k ns os]
+  (doseq [[k component] (:components @ns)]
+    (.update index (clj->js {:id (:id component)
+                          :name (:name component)
+                          :tags (:tags component)})))))
+
 (defn on-js-reload []
   ;; optionally touch your app-state to force rerendering depending on
   ;; your application


Enable path optimization

Enable path optimization

--- src/web/reconciler.cljs
+++ src/web/reconciler.cljs
@@ -35,6 +35,10 @@
   (let [st @state]
     {:value (db->tree-cached query (get st key) st)
      :remote (or force-remotes? (go-remote? st params))}))
+
+(defmethod read :node
+  [{:keys [query query-root state]} _ _]
+  {:value (om/db->tree query query-root @state)})

 (defmethod read :custard/ready?
   [{:keys [state]} key _]
@@ -80,6 +84,7 @@
 (def reconciler
   (om/reconciler {:parser parser
                   :state initial-state
+                  :pathopt true
                   :merge-tree merge-result-tree
                   :send remote/send-to-remote
                   :id-key :id}))


add id-sk-origin validation to workaround gangway assumptions

--- src/traveler/validation.clj
+++ src/traveler/validation.clj
@@ -3,6 +3,7 @@

 (def validations
   {:user {:id-sk                    s/Str
+          :id-sk-origin             s/Keyword
           :username                 s/Str
           :password                 s/Str
           :privilege                s/Str


Cosmetic changes on library ns.

Cosmetic changes on library ns.