use normalized gammas for dirichlet instead of normalized uniform-continuouss

--- examples/src/worksheets/pdfa.clj
+++ examples/src/worksheets/pdfa.clj
@@ -23,7 +23,7 @@
 (anglican.infcomp.core/reset-infcomp-addressing-scheme!)
 ;; @@
 ;; =>
-;;; {"type":"html","content":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--26348$fn--26349]","value":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--26348$fn--26349]"}
+;;; {"type":"html","content":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--28032$fn--28033]","value":"#function[anglican.infcomp.core/reset-infcomp-addressing-scheme!$fn--28032$fn--28033]"}
 ;; <=

 ;; **
@@ -31,24 +31,6 @@
 ;; **

 ;; @@
-(defm new-pdfa [alphabet K transition emissiondist]
-  (let [alphabet (map str (seq alphabet))
-
-        states (range K)
-
-        edges (into {} (map (fn [state]
-                              [state (into {} (map #(vector % (transition state %))
-                                                   alphabet))])
-                            states))
-
-        probs (into {} (map (fn [state]
-                              [state (into {} (map (fn [[symbol prob]]
-                                                     [(str symbol) prob])
-                                                   (:categories (emissiondist state))))])
-                            states))]
-    {:edges edges
-     :probs probs}))
-
 (defn pdfa-states [pdfa]
   (keys (:edges pdfa)))

@@ -104,11 +86,29 @@
 ;; **

 ;; @@
+(defm new-pdfa [alphabet K transition emissiondist]
+  (let [alphabet (map str (seq alphabet))
+
+        states (range K)
+
+        edges (into {} (map (fn [state]
+                              [state (into {} (map #(vector % (transition state %))
+                                                   alphabet))])
+                            states))
+
+        probs (into {} (map (fn [state]
+                              [state (into {} (map (fn [[symbol prob]]
+                                                     [(str symbol) prob])
+                                                   (:categories (emissiondist state))))])
+                            states))]
+    {:edges edges
+     :probs probs}))
+
 (with-primitive-procedures [normalize]
   (defquery pdfa [observedsequence alphabet]
     (let [num-states (sample (categorical [[2 10] [3 6] [4 3] [5 1]]))

-          emissionprior (fn [] (normalize (repeatedly (count alphabet) (fn [] (sample (uniform-continuous 0 1))))))
+          emissionprior (fn [] (normalize (repeatedly (count alphabet) (fn [] (sample (gamma 1 1))))))
           emissiondist (mem (fn [state] (categorical (zipmap alphabet (emissionprior))))) ; \pi

           transitiondist (uniform-discrete 0 num-states)
@@ -163,14 +163,14 @@
 (sample-observes-from-prior pdfa [(repeat 10 nil) alphabet])
 ;; @@
 ;; =>
-;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"0","value":"0"}],"value":"[:time-index 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"0","value":"0"}],"value":"[:observe-instance 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 0, :observe-address O44, :observe-instance 0, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"1","value":"1"}],"value":"[:time-index 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"1","value":"1"}],"value":"[:observe-instance 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 1, :observe-address O44, :observe-instance 1, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"2","value":"2"}],"value":"[:time-index 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"2","value":"2"}],"value":"[:observe-instance 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 2, :observe-address O44, :observe-instance 2, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"3","value":"3"}],"value":"[:time-index 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"3","value":"3"}],"value":"[:observe-instance 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 3, :observe-address O44, :observe-instance 3, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"4","value":"4"}],"value":"[:time-index 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"4","value":"4"}],"value":"[:observe-instance 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 4, :observe-address O44, :observe-instance 4, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"5","value":"5"}],"value":"[:time-index 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"5","value":"5"}],"value":"[:observe-instance 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 5, :observe-address O44, :observe-instance 5, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"6","value":"6"}],"value":"[:time-index 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"6","value":"6"}],"value":"[:observe-instance 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 6, :observe-address O44, :observe-instance 6, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"7","value":"7"}],"value":"[:time-index 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"7","value":"7"}],"value":"[:observe-instance 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 7, :observe-address O44, :observe-instance 7, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"8","value":"8"}],"value":"[:time-index 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"8","value":"8"}],"value":"[:observe-instance 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 8, :observe-address O44, :observe-instance 8, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"9","value":"9"}],"value":"[:time-index 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"9","value":"9"}],"value":"[:observe-instance 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 9, :observe-address O44, :observe-instance 9, :value 0}"}],"value":"[{:time-index 0, :observe-address O44, :observe-instance 0, :value 0} {:time-index 1, :observe-address O44, :observe-instance 1, :value 0} {:time-index 2, :observe-address O44, :observe-instance 2, :value 1} {:time-index 3, :observe-address O44, :observe-instance 3, :value 1} {:time-index 4, :observe-address O44, :observe-instance 4, :value 1} {:time-index 5, :observe-address O44, :observe-instance 5, :value 1} {:time-index 6, :observe-address O44, :observe-instance 6, :value 0} {:time-index 7, :observe-address O44, :observe-instance 7, :value 0} {:time-index 8, :observe-address O44, :observe-instance 8, :value 0} {:time-index 9, :observe-address O44, :observe-instance 9, :value 0}]"}
+;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"0","value":"0"}],"value":"[:time-index 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"0","value":"0"}],"value":"[:observe-instance 0]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 0, :observe-address O44, :observe-instance 0, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"1","value":"1"}],"value":"[:time-index 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"1","value":"1"}],"value":"[:observe-instance 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 1, :observe-address O44, :observe-instance 1, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"2","value":"2"}],"value":"[:time-index 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"2","value":"2"}],"value":"[:observe-instance 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 2, :observe-address O44, :observe-instance 2, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"3","value":"3"}],"value":"[:time-index 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"3","value":"3"}],"value":"[:observe-instance 3]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 3, :observe-address O44, :observe-instance 3, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"4","value":"4"}],"value":"[:time-index 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"4","value":"4"}],"value":"[:observe-instance 4]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 4, :observe-address O44, :observe-instance 4, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"5","value":"5"}],"value":"[:time-index 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"5","value":"5"}],"value":"[:observe-instance 5]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"0","value":"0"}],"value":"[:value 0]"}],"value":"{:time-index 5, :observe-address O44, :observe-instance 5, :value 0}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"6","value":"6"}],"value":"[:time-index 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"6","value":"6"}],"value":"[:observe-instance 6]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 6, :observe-address O44, :observe-instance 6, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"7","value":"7"}],"value":"[:time-index 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"7","value":"7"}],"value":"[:observe-instance 7]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 7, :observe-address O44, :observe-instance 7, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"8","value":"8"}],"value":"[:time-index 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"8","value":"8"}],"value":"[:observe-instance 8]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 8, :observe-address O44, :observe-instance 8, :value 1}"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":time-index","value":":time-index"},{"type":"html","content":"9","value":"9"}],"value":"[:time-index 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-address","value":":observe-address"},{"type":"html","content":"O44","value":"O44"}],"value":"[:observe-address O44]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":observe-instance","value":":observe-instance"},{"type":"html","content":"9","value":"9"}],"value":"[:observe-instance 9]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":value","value":":value"},{"type":"html","content":"1","value":"1"}],"value":"[:value 1]"}],"value":"{:time-index 9, :observe-address O44, :observe-instance 9, :value 1}"}],"value":"[{:time-index 0, :observe-address O44, :observe-instance 0, :value 1} {:time-index 1, :observe-address O44, :observe-instance 1, :value 1} {:time-index 2, :observe-address O44, :observe-instance 2, :value 1} {:time-index 3, :observe-address O44, :observe-instance 3, :value 1} {:time-index 4, :observe-address O44, :observe-instance 4, :value 1} {:time-index 5, :observe-address O44, :observe-instance 5, :value 0} {:time-index 6, :observe-address O44, :observe-instance 6, :value 1} {:time-index 7, :observe-address O44, :observe-instance 7, :value 1} {:time-index 8, :observe-address O44, :observe-instance 8, :value 1} {:time-index 9, :observe-address O44, :observe-instance 9, :value 1}]"}
 ;; <=

 ;; @@
 (combine-observes-fn (sample-observes-from-prior pdfa [(repeat 10 nil) alphabet]))
 ;; @@
 ;; =>
-;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"1","value":"1"},{"type":"html","content":"0","value":"0"}],"value":"[1 0]"}],"value":"[[0 1] [1 0] [1 0] [1 0] [1 0] [1 0] [1 0] [1 0] [1 0] [1 0]]"}
+;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"},{"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":"0","value":"0"},{"type":"html","content":"1","value":"1"}],"value":"[0 1]"}],"value":"[[0 1] [0 1] [0 1] [0 1] [0 1] [0 1] [0 1] [0 1] [0 1] [0 1]]"}
 ;; <=

 ;; **
@@ -178,7 +178,7 @@
 ;; **

 ;; @@
-(def torch-connection (start-torch-connection pdfa [(repeat 10 nil) alphabet] combine-observes-fn :tcp-endpoint "tcp://*:5555"))
+(def torch-connection (start-torch-connection pdfa [(repeat 100 nil) alphabet] combine-observes-fn :tcp-endpoint "tcp://*:5555"))
 ;; @@
 ;; =>
 ;;; {"type":"html","content":"#'pdfa/torch-connection","value":"#'pdfa/torch-connection"}


Minor refactoring

Minor refactoring

--- src/time_tracker/auth/core.clj
+++ src/time_tracker/auth/core.clj
@@ -5,7 +5,7 @@

             [time-tracker.config :as config]))

-(defn- munge-keyword
+(defn- snake-case->hyphenated-kw
   "In: \"key_string\"
   Out: :key-string"
   [key-string]
@@ -16,7 +16,7 @@
   (let [{body :body :as response} @(http/get config/google-tokeninfo-url
                                              {:as :text
                                               :query-params {"id_token" token}})]
-    (assoc response :body (json/parse-string body munge-keyword))))
+    (assoc response :body (json/parse-string body snake-case->hyphenated-kw))))

 (defn token->credentials
   "Validates a JWT by calling Google's API and by checking the client ID."
@@ -28,7 +28,7 @@

 (defn token-from-headers
   "Extracts the token from a Ring header map, if present.
-  See: https://tools.ietf.org/html/rfc6750#section-2.1"
+  See: https://jwt.io/introduction/"
   [ring-headers]
   (if-let [header-value (get ring-headers "authorization")]
     (let [[scheme token] (clojure.string/split header-value #" ")]


minor cleanup

minor cleanup

--- src/httpkit/core.clj
+++ src/httpkit/core.clj
@@ -25,10 +25,9 @@
 (declare gen-handler)

 (defn system []
-  (let [user-storage (db/MySQLUserStorage.)]
-    {:foe-config {:user-storage user-storage
-                  :modules [:user :remember-me]}
-     :server {:port 8080}}))
+  {:foe-config {:user-storage (db/MySQLUserStorage.)
+                :modules [:user :remember-me]}
+   :server {:port 8080}})

 (defn start [system]
   (foe/start! (:foe-config system))


Removed the save button

Removed the save button

--- src/wishlistd/views/common.clj
+++ src/wishlistd/views/common.clj
@@ -42,8 +42,7 @@
                 [:div.content
                  [:div.page-header
                   [:h1 "Wishlistd"]
-                  [:p {:style "margin-left:550px;margin-right:-100px"}
-                   [:input {:id "save-wishlist" :class "btn primary" :type "submit" :value "Save wishlist"}]
+                  [:p {:style "margin-left:700px;margin-right:-100px"}
                    [:input {:id "create-wishlist" :class "btn primary" :type "submit" :value "New wishlist"}]]]
                 [:div.row
                  [:div.span10


release bigquery 0.2.5.2

release bigquery 0.2.5.2

--- bigquery/project.clj
+++ bigquery/project.clj
@@ -1,4 +1,4 @@
-(defproject gclouj/bigquery "0.2.5.1"
+(defproject gclouj/bigquery "0.2.5.2"
   :description "Google Cloud BigQuery"
   :url "https://github.com/pingles/gclouj"
   :license {:name "Eclipse Public License"


Fixing test failure in issue #328

Fixing test failure in issue #328

--- test/ctia/http/generative/specs.clj
+++ test/ctia/http/generative/specs.clj
@@ -1,6 +1,7 @@
 (ns ctia.http.generative.specs
   (:refer-clojure :exclude [get])
-  (:require [clojure.string :as str]
+  (:require [clojure.set :as set]
+            [clojure.string :as str]
             [clojure.test.check.properties :refer [for-all]]
             [clojure.test.check.generators :as tcg]
             [ctia.test-helpers.core
@@ -75,8 +76,12 @@
       (assert-successful search-result-status)

       (and
-       (= stored-sighting-ids
-          search-result-ids)
+       ;; Sometimes the indicator ID is reused multiple times during a
+       ;; test run (with no store cleanup in between).  Use subset? to
+       ;; make sure that extra results don't fail the test.  (See
+       ;; issue #328).
+       (set/subset? stored-sighting-ids
+                    search-result-ids)
        (common= new-indicator
                 (normalize post-indicator)
                 (normalize get-indicator))))))


run through the rockets and render them on the page

--- src-cljs/hello.cljs
+++ src-cljs/hello.cljs
@@ -39,8 +39,12 @@
         width (aget canvas "width")]
     (.clearRect graphics-context 0 0 width height)))

-(defn render [graphics-context]
-  (.fillRect graphics-context 10 20 200 100))
+(defn render [graphics-context game-world]
+  (doseq [rocket (aget game-world :rockets)]
+    (.fillRect graphics-context
+      (get rocket :pos-x)
+      (get rocket :pos-y)
+      5 5)))

 (defn ^:export main []
   (let [canvas-element (create-canvas)


Update dependencies

Update dependencies

--- mtg-pairings-server/project.clj
+++ mtg-pairings-server/project.clj
@@ -2,6 +2,8 @@
   :license {:name "MIT License"
             :url  "http://www.opensource.org/licenses/mit-license.php"}
   :dependencies [[org.clojure/clojure "1.10.0"]
+                 [org.clojure/clojurescript "1.10.516" :exclusions [com.google.errorprone/error_prone_annotations
+                                                                    com.google.code.findbugs/jsr305]]
                  [org.clojure/core.async "0.4.490"]
                  [org.clojure/tools.logging "0.4.1"]
                  [ring/ring-core "1.7.1"]
@@ -13,9 +15,9 @@
                  [org.clojure/tools.reader "1.3.2"]
                  [clj-time "0.15.1"]
                  [korma "0.4.3"]
-                 [mount "0.1.15"]
+                 [mount "0.1.16"]
                  [org.postgresql/postgresql "42.2.5"]
-                 [metosin/compojure-api "1.1.12"]
+                 [metosin/compojure-api "1.1.12" :exclusions [com.google.code.findbugs/jsr305]]
                  [cheshire "5.8.1"]
                  [ring.middleware.jsonp "0.1.6"]
                  [com.taoensso/sente "1.13.1" :exclusions [com.taoensso/encore]]
@@ -23,7 +25,7 @@
                  [com.cognitect/transit-clj "0.8.313" :exclusions [commons-codec]]
                  [com.fzakaria/slf4j-timbre "0.3.12"]]
   :plugins [[lein-asset-minifier "0.4.5"]
-            [lein-cljfmt "0.6.3"]
+            [lein-cljfmt "0.6.4"]
             [lein-ancient "0.6.15"]
             [lein-garden "0.3.0" :exclusions [org.apache.commons/commons-compress]]]

@@ -76,16 +78,15 @@
                         :resource-paths ["target"]
                         :dependencies   [[org.clojure/tools.namespace "0.2.11"]
                                          [binaryage/devtools "0.9.10"]
-                                         [com.bhauman/rebel-readline-cljs "0.1.4" :exclusions [org.clojure/clojurescript]]
+                                         [com.bhauman/rebel-readline-cljs "0.1.4" :exclusions [args4j]]
                                          [ring/ring-mock "0.3.2" :exclusions [cheshire ring/ring-codec]]
                                          [ring/ring-devel "1.7.1"]
                                          [prone "1.6.1"]
                                          [hawk "0.2.11"]
                                          [cider/piggieback "0.3.10" :exclusions [org.clojure/clojurescript]]
-                                         [re-frisk "0.5.4" :exclusions [args4j]]]}
+                                         [re-frisk "0.5.4" :exclusions [org.clojure/clojurescript]]]}
              :prod     {:source-paths ["env/prod/cljs"]}
              :provided {:dependencies [[reagent "0.8.1" :exclusions [cljsjs/react]]
-                                       [org.clojure/clojurescript "1.10.439"]
                                        [com.google.errorprone/error_prone_annotations "2.3.2"]
                                        [com.google.code.findbugs/jsr305 "3.0.2"]
                                        [com.bhauman/figwheel-main "0.2.0" :exclusions [org.clojure/clojurescript]]
@@ -95,8 +96,8 @@
                                        [com.andrewmcveigh/cljs-time "0.5.2"]
                                        [re-frame "0.10.6" :exclusions [cljsjs/react args4j]]
                                        [binaryage/oops "0.6.4"]
-                                       [cljsjs/react "16.6.0-0"]
-                                       [cljsjs/react-dom "16.6.0-0"]
+                                       [cljsjs/react "16.8.1-0"]
+                                       [cljsjs/react-dom "16.8.1-0"]
                                        [cljs-react-material-ui "0.2.50" :exclusions [args4j]]
                                        [cljsjs/prop-types "15.6.2-0"]
                                        [cljsjs/rc-slider "8.6.1-0"]


kill dummy test

kill dummy test

--- test/block_chain/core_test.clj
+++ test/block_chain/core_test.clj
@@ -1,7 +1,3 @@
 (ns block-chain.core-test
   (:require [clojure.test :refer :all]
             [block-chain.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


Actual storage tests

Actual storage tests

--- test/doctopus/storage_test.clj
+++ test/doctopus/storage_test.clj
@@ -1,3 +1,14 @@
 (ns doctopus.storage-test
   (:require [doctopus.storage :refer :all]
             [clojure.test :refer :all]))
+
+
+(deftest storage
+  (testing "Can we swap backends?"
+    (is (= default-backend (get-key-from-backend backend :name))
+        "Are we using the default backend?")
+    (is (set-backend! backend :temp-fs)
+        "Can we set the backend to a differen't implementation?")
+    (is (set-backend! backend default-backend)
+        "And can we set it back to the default"))
+  )


go ahead and parse the returned POST xml if we can

--- src/myshelf/core.clj
+++ src/myshelf/core.clj
@@ -63,10 +63,12 @@
                                        oauth_token_secret
                                        :POST
                                        url
-                                       params)]
-      (http/post url
-                 {:query-params (merge credentials
-                                       params)})))
+                                       params)
+          resp (http/post url
+                          {:query-params (merge credentials
+                                                params)})]
+      (when (= 201 (:status resp))
+        (xml/parse-str (:body resp)))))

 (defn make-auth-request-PUT
   [consumer access-token url params]


Really ugly template thing, also formatting

--- src/pronouns/web.clj
+++ src/pronouns/web.clj
@@ -13,6 +13,15 @@

 (def config {:default-server-port 5000})

+(defn render-examples-page
+  [subject object possessive-determiner possessive-pronoun reflexive]
+  (s/join "\n"
+          [(str subject " went to the park")
+           (str "I went with " object)
+           (str subject " brought " possessive-determiner " frisbee")
+           (str "at least I think it was " possessive-pronoun)
+           (str subject " threw it to " reflexive)]))
+
 (defroutes app-routes
   (GET "/" []
        {:status 200
@@ -21,7 +30,15 @@
   (GET "/:subject/:object/:possessive-determiner/:possessive-pronoun/:reflexive" {params :params}
        {:status 200
         :headers {"Content-Type" "text/plain"}
-        :body (str (:subject params) " goes to the park")})
+        ;; ew this is super gross there's certainly a better way
+        :body (let [{:keys
+                     [subject object possessive-determiner possessive-pronoun reflexive]}
+                    params]
+                (render-examples-page subject
+                                      object
+                                      possessive-determiner
+                                      possessive-pronoun
+                                      reflexive))})
   (ANY "*" []
        (route/not-found (slurp (io/resource "404.html")))))

@@ -40,8 +57,8 @@
       trace/wrap-stacktrace))

 (defn -main []
-  (let [port (Integer. (env :port (:default-server-port config)))
-                 ]
+  (let [port (Integer. (:port env
+                              (:default-server-port config)))]
     (jetty/run-jetty app {:port port})))

 ;; For interactive development:


+comment about CREATE SEQUENCE IF NOT EXISTS

--- src/babel/korma.clj
+++ src/babel/korma.clj
@@ -134,6 +134,8 @@
             :password password
             :host host
             :port (or port "5432")}))))
+    ;; older postgres versions (pre-9.6(?)) do not support CREATE SEQUENCE IF NOT EXISTS,
+    ;; so that will fail here: catch the exception and continue.
     (try (exec-raw [(str "CREATE SEQUENCE IF NOT EXISTS lexeme_id_seq")])
          (catch Exception e
            (log/warn (str "ignoring error from database server: " e))))


Delete .#basics.clj

Delete .#basics.clj


Move portal to :provided section

Move portal to :provided section

--- clojure/profiles.clj
+++ clojure/profiles.clj
@@ -1,7 +1,8 @@
 ;; https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
 {:provided
  {:dependencies
-  [[djblue/portal "0.21.2"]]}
+  [[djblue/portal "0.21.2"]
+   [fipp "0.6.24"]]}
  :user
  {:plugins
   [[cider/cider-nrepl "0.27.4"]


up version

up version

--- kafka-clj/project.clj
+++ kafka-clj/project.clj
@@ -1,4 +1,4 @@
-(defproject kafka-clj "2.3.7-SNAPSHOT"
+(defproject kafka-clj "2.3.8-SNAPSHOT"
   :description "fast kafka library implemented in clojure"
   :url "https://github.com/gerritjvv/kafka-fast"
   :license {:name "Eclipse Public License"


Use re-com throbber instead of material design spinner

--- src/re_com/misc.cljs
+++ src/re_com/misc.cljs
@@ -7,6 +7,36 @@
                                      string-or-hiccup? css-style? html-attr? number-or-string?
                                      string-or-atom? throbber-size? throbber-sizes-list] :refer-macros [validate-args-macro]]
             [reagent.core    :as    reagent]))
+
+;; ------------------------------------------------------------------------------------
+;;  Component: throbber
+;; ------------------------------------------------------------------------------------
+
+(def throbber-args-desc
+  [{:name :size :required false :type "keyword" :default :regular :validate-fn throbber-size? :description [:span "one of " throbber-sizes-list]}
+   {:name :color :required false :type "string" :default "#999" :validate-fn string? :description "CSS color"}
+   {:name :class :required false :type "string" :validate-fn string? :description "CSS class names, space separated"}
+   {:name :style :required false :type "CSS style map" :validate-fn css-style? :description "CSS styles to add or override"}
+   {:name :attr :required false :type "HTML attr map" :validate-fn html-attr? :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])
+
+(defn throbber
+  "Render an animated throbber using CSS"
+  [& {:keys [size color class style attr] :as args}]
+  {:pre [(validate-args-macro throbber-args-desc args "throbber")]}
+  (let [seg (fn [] [:li (when color {:style {:background-color color}})])]
+    [box
+     :align :start
+     :child [:ul
+             (merge {:class (str "rc-throbber loader "
+                                 (case size :regular ""
+                                            :small "small "
+                                            :large "large "
+                                            "")
+                                 class)
+                     :style style}
+                    attr)
+             [seg] [seg] [seg] [seg]
+             [seg] [seg] [seg] [seg]]])) ;; Each :li element in [seg] represents one of the eight circles in the throbber

 ;; ------------------------------------------------------------------------------------
@@ -116,27 +146,31 @@
                           :status status
                           ;:width    "200px"
                           :showing? showing?
-                          :anchor [:i {:class         (str "zmdi " icon-class " form-control-feedback")
-                                       :style         {:position "static"
-                                                       :width    "auto"
-                                                       :height   "auto"
-                                                       :opacity  (if (and status-icon? status) "1" "0")}
-                                       :on-mouse-over (handler-fn (when (and status-icon? status) (reset! showing? true)))
-                                       :on-mouse-out  (handler-fn (reset! showing? false))}]
+                          :anchor (if (= :validating status)
+                                    [throbber :size :small]
+                                    [:i {:class         (str "zmdi " icon-class " form-control-feedback")
+                                         :style         {:position "static"
+                                                         :width    "auto"
+                                                         :height   "auto"
+                                                         :opacity  (if (and status-icon? status) "1" "0")}
+                                         :on-mouse-over (handler-fn (when (and status-icon? status) (reset! showing? true)))
+                                         :on-mouse-out  (handler-fn (reset! showing? false))}])
                           :style (merge (flex-child-style "none")
                                         (align-style :align-self :center)
                                         {:font-size   "130%"
                                          :margin-left "4px"})]
-                         [:i {:class (str "zmdi " icon-class " form-control-feedback")
-                              :style (merge (flex-child-style "none")
-                                            (align-style :align-self :center)
-                                            {:position    "static"
-                                             :font-size   "130%"
-                                             :margin-left "4px"
-                                             :opacity     (if (and status-icon? status) "1" "0")
-                                             :width       "auto"
-                                             :height      "auto"})
-                              :title status-tooltip}])))]]))))
+                         (if (= :validating status)
+                           [throbber :size :small]
+                           [:i {:class (str "zmdi " icon-class " form-control-feedback")
+                                :style (merge (flex-child-style "none")
+                                              (align-style :align-self :center)
+                                              {:position    "static"
+                                               :font-size   "130%"
+                                               :margin-left "4px"
+                                               :opacity     (if (and status-icon? status) "1" "0")
+                                               :width       "auto"
+                                               :height      "auto"})
+                                :title status-tooltip}]))))]]))))

 (defn input-text
@@ -330,34 +364,3 @@
                :style {:width      (str model "%")
                        :transition "none"}}                 ;; Default BS transitions cause the progress bar to lag behind
               (str model "%")]]]))
-
-
-;; ------------------------------------------------------------------------------------
-;;  Component: throbber
-;; ------------------------------------------------------------------------------------
-
-(def throbber-args-desc
-  [{:name :size     :required false :type "keyword"       :default :regular :validate-fn throbber-size? :description [:span "one of " throbber-sizes-list]}
-   {:name :color    :required false :type "string"        :default "#999"   :validate-fn string?        :description "CSS color"}
-   {:name :class    :required false :type "string"                          :validate-fn string?        :description "CSS class names, space separated"}
-   {:name :style    :required false :type "CSS style map"                   :validate-fn css-style?     :description "CSS styles to add or override"}
-   {:name :attr     :required false :type "HTML attr map"                   :validate-fn html-attr?     :description [:span "HTML attributes, like " [:code ":on-mouse-move"] [:br] "No " [:code ":class"] " or " [:code ":style"] "allowed"]}])
-
-(defn throbber
-  "Render an animated throbber using CSS"
-  [& {:keys [size color class style attr] :as args}]
-  {:pre [(validate-args-macro throbber-args-desc args "throbber")]}
-  (let [seg (fn [] [:li (when color {:style {:background-color color}})])]
-    [box
-     :align :start
-     :child [:ul
-             (merge {:class (str "rc-throbber loader "
-                                 (case size :regular ""
-                                            :small "small "
-                                            :large "large "
-                                            "")
-                                 class)
-                     :style style}
-                    attr)
-             [seg] [seg] [seg] [seg]
-             [seg] [seg] [seg] [seg]]])) ;; Each :li element in [seg] represents one of the eight circles in the throbber


Single pass router creation

Single pass router creation

--- src/reitit/core.cljc
+++ src/reitit/core.cljc
@@ -97,16 +97,15 @@
    (linear-router routes {}))
   ([routes opts]
    (let [{:keys [compile]} (meta-merge default-router-options opts)
-         compiled (map (partial compile-route compile) routes)]
-     (->LinearRouter
-       routes
-       (mapv (partial impl/create) compiled)
-       (->> (for [[p {:keys [name] :as meta} handler] compiled
-                  :when name
-                  :let [route (impl/create [p meta handler])]]
-              [name (fn [params]
-                      (->Match p meta (impl/path-for route params) handler params))])
-            (into {}))))))
+         compiled (map (partial compile-route compile) routes)
+         [data lookup] (reduce
+                         (fn [[data lookup] [p {:keys [name] :as meta} handler]]
+                           (let [route (impl/create [p meta handler])]
+                             [(conj data route)
+                              (if name
+                                (assoc lookup name #(->Match p meta (impl/path-for route %) handler %))
+                                lookup)])) [[] {}] compiled)]
+     (->LinearRouter routes data lookup))))

 (defrecord LookupRouter [routes data lookup]
   Routing
@@ -125,24 +124,21 @@
   ([routes]
    (lookup-router routes {}))
   ([routes opts]
+   (when-let [route (some impl/contains-wilds? (map first routes))]
+     (throw
+       (ex-info
+         (str "can't create LookupRouter with wildcard routes: " route)
+         {:route route
+          :routes routes})))
    (let [{:keys [compile]} (meta-merge default-router-options opts)
-         compiled (map (partial compile-route compile) routes)]
-     (when-let [route (some impl/contains-wilds? (map first routes))]
-       (throw
-         (ex-info
-           (str "can't create LookupRouter with wildcard routes: " route)
-           {:route route
-            :routes routes})))
-     (->LookupRouter
-       routes
-       (->> (for [[p meta handler] compiled]
-              [p (->Match p meta p handler {})])
-            (into {}))
-       (->> (for [[p {:keys [name] :as meta} handler] compiled
-                  :when name]
-              [name (fn [params]
-                      (->Match p meta p handler params))])
-            (into {}))))))
+         compiled (map (partial compile-route compile) routes)
+         [data lookup] (reduce
+                         (fn [[data lookup] [p {:keys [name] :as meta} handler]]
+                           [(assoc data p (->Match p meta p handler {}))
+                            (if name
+                              (assoc lookup name #(->Match p meta p handler %))
+                              lookup)]) [{} {}] compiled)]
+     (->LookupRouter routes data lookup))))

 (defn router
   "Create a [[Router]] from raw route data and optionally an options map.


Fix output flushing before exit

Fix output flushing before exit

--- src/bltool/core.clj
+++ src/bltool/core.clj
@@ -110,5 +110,4 @@
         (catch Object _
           (println (:message &throw-context))
           (dorun (map println (:stack-trace &throw-context)))))
-      (if-not (= *out* (:output *opts*)) (.close (:output *opts*)))
-      (if-not (= *in* (:input *opts*)) (.close (:input *opts*))))))
+      (.flush (:output *opts*)))))


warn on reflection project option is superceded by check task

--- src/cake/server.clj
+++ src/cake/server.clj
@@ -56,7 +56,6 @@
           (let [form (read), vars (read)]
             (clojure.main/with-bindings
               (reload)
-              (set! *warn-on-reflection* (:warn-on-reflection *project*))
               (binding [*vars*    vars
                         *pwd*     (:pwd vars)
                         *env*     (:env vars)


Solvability

Solvability

--- src/cellf/core.cljs
+++ src/cellf/core.cljs
@@ -42,12 +42,30 @@
         (put! pc img-el))))
     {:cells cells :image img-data}))

+(defn order [grid]
+  (map first (sort-by second grid)))
+
+(defn inversions [grid size]
+  (let [cells (order grid)]
+    (reduce +
+      (map count
+        (map (fn [n] (filter #(< % (nth cells n)) (drop n cells)))
+             (range (count grid)))))))
+
+(defn blank-at-row [grid size]
+  (Math.floor (/ (get grid :empty) size)))
+
+(defn solvable? [grid size]
+  (or
+    (and (odd? size) (even? (inversions grid size)))
+    (and (even? size) (= (even? (inversions grid size)) (odd? (blank-at-row grid size))))))
+
 (defn make-cell-list [size]
   (conj (vec (range (dec (sq size)))) :empty))

 (defn make-cells [size win-state]
   (let [shuffled (zipmap (make-cell-list size) (shuffle (range (sq size))))]
-    (if (= shuffled win-state) (recur size win-state) shuffled)))
+    (if (or (= shuffled win-state) (not (solvable? shuffled size))) (recur size win-state) shuffled)))

 (defn make-win-state [size]
   (zipmap (make-cell-list size) (range (sq size))))


Update based on kibit recommendation

Update based on kibit recommendation

--- src/rule110/core.clj
+++ src/rule110/core.clj
@@ -103,7 +103,7 @@
     (doseq [ [rule-num rule-map] rules]
       (prn "rule -num " rule-num " map " rule-map)
       (run-rule rule-num rule-map grid))
-    (when (not (= :all (keyword action)))
+    (when-not (= :all (keyword action))
       (println "New rule:")
       (let [naction (read-line)]
         (println "Got it ")


core: dotimes

core: dotimes

--- data/core.clj
+++ data/core.clj
@@ -1318,3 +1318,20 @@
          :arglists '([pred coll])
          :added "1.0"}
   not-any? (comp not some))
+
+;will be redefed later with arg checks
+(defmacro dotimes
+  "bindings => name n
+
+  Repeatedly executes body (presumably for side-effects) with name
+  bound to integers from 0 through n-1."
+  {:added "1.0"}
+  [bindings & body]
+  (let [i (first bindings)
+        n (second bindings)]
+    `(let [n# (int* ~n)]
+       (loop [~i 0]
+         (when (< ~i n#)
+           ~@body
+           (recur (inc ~i)))))))
+


Fix Clojure 1.2 issue.  (char -1) use to return (char 65535), now throws error.

--- src/clojars/scp.clj
+++ src/clojars/scp.clj
@@ -152,16 +152,18 @@
          (when okay
            (send-okay ctx))

-         (let [cmd (char (.read in))]
-           (condp = cmd
-             (char 0)      (do (recur files false))
-             \C            (recur (conj files (scp-copy ctx)) true)
-             \D            (do (safe-read-line in) (recur files true))
-             \T            (do (safe-read-line in) (recur files true))
-             \E            (do (safe-read-line in) (recur files true))
-             (char 65535)  (finish-deploy ctx files)
-             (throw (IOException. (str "Unknown scp command: '"
-                                       (int cmd) "'")))))))
+         (let [cmd (.read in)]
+           (if (= -1 cmd)
+             (finish-deploy ctx files)
+             (let [cmd (char cmd)]
+               (condp = cmd
+                   (char 0)      (do (recur files false))
+                   \C            (recur (conj files (scp-copy ctx)) true)
+                   \D            (do (safe-read-line in) (recur files true))
+                   \T            (do (safe-read-line in) (recur files true))
+                   \E            (do (safe-read-line in) (recur files true))
+                   (throw (IOException. (str "Unknown scp command: '"
+                                             (int cmd) "'")))))))))

      (catch Throwable t
                                         ;(.printStackTrace t *err*)


Function to generate time signatures

Function to generate time signatures

--- src/tenor/predef.clj
+++ src/tenor/predef.clj
@@ -3,7 +3,7 @@
 (defprotocol NoteEntities
   (note-value [s] "1, 2, 4, 8, 16")
   (pitch-letter [s] "A, B, C, D, E, F, G")
-  (octave [s] "1, 2, 3, 4, 5, 6 etc.)"))
+  (octave [s] "1, 2, 3, 4, 5, 6 etc."))

 (defrecord Note [notation]
   NoteEntities
@@ -11,5 +11,13 @@
   (pitch-letter [this] (str (get notation 1)))
   (octave [this] (- (int (get notation 2)) (int \0))))

-(defn time-signature [beats note-value]
-  ())
+(defn time-signature [beat-count & [sig]]
+  (cond
+    (> beat-count 3)
+    (let [beats (rand-nth [2 3 4])
+          sig (concat (or sig '()) (range 1 (inc beats)))]
+      (time-signature (- beat-count beats) sig))
+    (and (<= beat-count 3) (> beat-count 0))
+    (let [sig (concat (or sig '()) (range 1 (inc beat-count)))]
+      (time-signature 0 sig))
+    :else sig))


fix project clj

fix project clj

--- server/project.clj
+++ server/project.clj
@@ -25,19 +25,17 @@

   :plugins [[lein-environ "0.4.0"]]

-  :profiles {:user
-             {:env {:datomic {:config "resources/datomic-transactor.properties"
+  :profiles {:dev
+             {:dependencies [[midje "1.5.0"]]
+              :env {:html-paths ["../html-app/app"
+                                 "../html-app/.tmp"]
+                    :datomic {:config "resources/datomic-transactor.properties"
                               :db-uri "datomic:free://localhost:4334/gp2"
                               :test-uri "datomic:mem://gp2"}
                     :moderator-names ["flyingmachine"]}}
-
-             :dev
-             {:dependencies [[midje "1.5.0"]]
-              :env {:html-paths ["../html-app/app"
-                                 "../html-app/.tmp"]}}

              ;;
              :production
-             {:env {:html-paths ["resources/html-app"]}}}
+             {:env {:html-paths ["public"]}}}

   :main gratefulplace.server)


Improve definition error messages

Improve definition error messages

--- test/comic_reader/sites/test_util.clj
+++ test/comic_reader/sites/test_util.clj
@@ -113,7 +113,8 @@
   `(are-with-msg [selector#]
                  (is (not= (selector#)
                            nil)
-                     (str "Data function " 'selector#
+                     (str "Site config "
+                          "`" 'selector# "'"
                           " cannot be undefined"))
                  ~@(->> (keyword fn-name)
                         (alg/topsort dependecy-dag)


master is now 1.7.0-master-SNAPSHOT

master is now 1.7.0-master-SNAPSHOT

--- metrics-clojure-core/project.clj
+++ metrics-clojure-core/project.clj
@@ -12,6 +12,6 @@
                                        :releases {:checksum :fail :update :always}}}
     :profiles {:1.4    {:dependencies [[org.clojure/clojure "1.4.0"]]}
                :1.5    {:dependencies [[org.clojure/clojure "1.5.1"]]}
-               :master {:dependencies [[org.clojure/clojure "1.6.0-master-SNAPSHOT"]]}}
+               :master {:dependencies [[org.clojure/clojure "1.7.0-master-SNAPSHOT"]]}}
   :aliases  {"all" ["with-profile" "+dev:+1.4:+1.5:+master"]}
   :global-vars {*warn-on-reflection* true})


Added-back a hello world from om.

Added-back a hello world from om.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -57,3 +57,19 @@

 (defn change-event-delay [d]
   (reset! event-delay d))
+
+;; ------------------------------------------------
+
+(def app-state
+  (atom {:text "Hello world!"}))
+
+(defn app-ui [app-state owner]
+  (reify
+    om/IRender
+    (render [_]
+      (dom/div nil
+               (dom/h1 nil (:text app-state))))))
+
+(om/root app-state
+         app-ui
+         (. js/document (getElementById "app")))


Fix reducer scenario.

Fix reducer scenario.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -210,10 +210,10 @@
                             (doseq [_ (pmap direct-proc-fn d)]
                               (.inc out-cntr))))
                       (.endsWith scenario "-reducers-map")
-                        (let [d (repeat (* 512 4) in-data)]
-                          (doall d)
+                        (let [in-vec (vec (repeat (* 512 pipeline-length) in-data))]
+                          (doall in-vec)
                           (fn []
-                            (doseq [_ (reducers/foldcat (reducers/map direct-proc-fn d))]
+                            (doseq [_ (reducers/foldcat (reducers/map direct-proc-fn in-vec))]
                               (.inc out-cntr))))
                       (.endsWith scenario "-async-pipeline")
                         (if


Update command line args.

Update command line args.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -53,10 +53,14 @@

 (def cli-options
   [["-h" "--help"]
-   ["-l" "--pipeline-length"
+   ["-l" "--pipeline-length PIPELINE-LENGTH"
     :default 2
     :parse-fn #(Integer/parseInt %)]
-   ["-S" "--scenario SCENARIO"
+   ["-m" "--fn-mapping FN-MAPPING"
+    "The mapping of dsl-expressions to processing functions."
+    :default [5 5 4 3]
+    :parse-fn #(binding [*read-eval* false] (read-string %))]
+   ["-s" "--scenario SCENARIO"
     "The scenario that is to be used."
     :default "no-op"]])

@@ -83,13 +87,14 @@
           out-fn (fn [_ _]
                    (.inc out-cntr))
           scenario (:scenario options)
-          in-data (condp = scenario
+          in-data (condp (fn [v s] (.startsWith s v)) scenario
                     "no-op" 1
                     "factorial" 24N
-                    "pcap-json" pcap-byte-array-test-data
+                    "pcap" pcap-byte-array-test-data
                     "nil" nil
                     )
           proc-fn (create-proc-fn sample-pcap-processing-definition-json)
+          fn-mapping (:fn-mapping options)
           pipeline-length (:pipeline-length options)
           pipeline (if (not (nil? in-data))
                      (create-local-processing-pipeline
@@ -97,6 +102,9 @@
                          "no-op" (create-no-op-proc-fns pipeline-length)
                          "factorial" (create-factorial-proc-fns pipeline-length)
                          "pcap-json" [(fn [i _] (proc-fn i))]
+                         "pcap-json#inc" (create-proc-fns-vec
+                                           fn-mapping
+                                           sample-pcap-processing-definition-json)
                          )
                        out-fn))
           in-fn (if (not (nil? in-data))


134 FF code added

134 FF code added

--- src/etaoin/api.clj
+++ src/etaoin/api.clj
@@ -2342,7 +2342,7 @@

   - `file`: either a path to a file or a native `java.io.File` instance.
 "
-  {:arglists '([driver filename])}
+  {:arglists '([driver file])}
   dispatch-driver)

 (defmethod screenshot :default
@@ -2353,11 +2353,33 @@
     resp
     (if-let [b64str (-> resp :value not-empty)]
       (b64-to-file b64str file)
-      (throw+ {:type :etaoin/screenshot
-               :message "Empty screenshot"
-               :driver @driver}))))
-
+      (util/error "Empty screenshot"))))
+
+(defmulti screenshot-element
+
+  {:arglists '([driver q file])}
+  dispatch-driver)
+
+(defmethod screenshot-element
+  :default
+  [driver q file]
+  (util/error "This driver doesn't support screening elements."))
+
+(defmethod screenshot-element
+  :firefox
+  [driver q file]
+  (let [el (query driver q)]
+    (with-resp driver :get
+      [:session (:session @driver) :element el :screenshot]
+      nil
+      resp
+      (if-let [b64str (-> resp :value not-empty)]
+        (b64-to-file b64str file)
+        (util/error "Empty screenshot, query: %s" q)))))
+
+;;
 ;; postmortem
+;;

 (defn get-pwd []
   (System/getProperty "user.dir"))


Adding fog, net-ssh-multi, and highline

Adding fog, net-ssh-multi, and highline

--- src/fatty/core.clj
+++ src/fatty/core.clj
@@ -52,7 +52,9 @@
                             ["sudo" "make" "install"]]))

 (def chef (software :source "chef"
-            :steps [["sudo" "/opt/opscode/embedded/bin/gem" "install" "chef" "-n" "/opt/opscode/bin"]]))
+            :steps [["sudo" "/opt/opscode/embedded/bin/gem" "install" "chef" "fog" "highline" "net-ssh-multi" "-n" "/opt/opscode/bin"]]))
+
+

 (defn- log-sh-result
   [status true-log false-log]


Drop get-spec.

Drop get-spec.

--- src/onyx/spec.cljc
+++ src/onyx/spec.cljc
@@ -137,22 +137,26 @@

 (s/def :flow/from
   (s/or :task-name keyword?
-        :special-task (s/get-spec :flow/special-tasks)))
+        :special-task :flow/special-tasks))

 (s/def :flow/to
   (s/or :task-name keyword?
         :task-names (s/coll-of keyword? :kind vector?)
-        :special-task (s/get-spec :flow/special-tasks)))
+        :special-task :flow/special-tasks))

 (s/def :flow/predicate
-  (s/or :keyword keyword?
-        :coll (s/coll-of any? :kind vector?)))
+  (s/or :and (s/cat :op #{:and} :exprs (s/+ :flow/predicate))
+        :or (s/cat :op #{:or} :exprs (s/+ :flow/predicate))
+        :not (s/cat :op #{:not} :exprs (s/cat :pred :flow/predicate))
+        :fn keyword?
+        :fn-and-args (s/cat :fn (fn [x]
+                                  (and (keyword? x)
+                                       (not (some #{x} #{:and :or :not}))))
+                            :args (s/* keyword?))))

 (s/def :flow/post-transform namespaced-keyword?)

 (s/def :flow/thrown-exception? boolean?)
-
-(s/def :flow/action (s/get-spec :flow/action))

 (s/def :flow/short-circuit? boolean?)

@@ -171,7 +175,7 @@
                 :flow/short-circuit]))

 (s/def :job/flow-conditions
-  (s/coll-of (s/get-spec :flow/condition)
+  (s/coll-of :flow/condition
              :kind vector?))

 (s/def :job.lifecycles/lifecycle
@@ -314,7 +318,7 @@
 (s/def :job/trigger (s/multi-spec trigger-on :trigger/on))

 (s/def :job/triggers
-  (s/coll-of (s/get-spec :job/trigger) :kind vector?))
+  (s/coll-of :job/trigger :kind vector?))

 (s/def :jvm/function
   (s/or :fn fn? :var var?))
@@ -391,24 +395,21 @@

 (s/def :onyx.core/serialized-task any?)

-(s/def :onyx.core/workflow (s/get-spec :job/workflow))
-
-(s/def :onyx.core/task-map
-  (s/multi-spec onyx-type :onyx/type))
+(s/def :onyx.core/workflow :job/workflow)
+
+(s/def :onyx.core/task-map (s/multi-spec onyx-type :onyx/type))

 (s/def :onyx.core/catalog
-  (s/coll-of (s/multi-spec onyx-type :onyx/type)
-             :kind vector?))
-
-(s/def :onyx.core/flow-conditions
-  (s/get-spec :job/flow-conditions))
-
-(s/def :onyx.core/windows (s/get-spec :job/windows))
-
-(s/def :onyx.core/triggers (s/get-spec :job/triggers))
+  (s/coll-of (s/multi-spec onyx-type :onyx/type) :kind vector?))
+
+(s/def :onyx.core/flow-conditions :job/flow-conditions)
+
+(s/def :onyx.core/windows :job/windows)
+
+(s/def :onyx.core/triggers :job/triggers)

 (s/def :onyx.core/lifecycles
-  (s/coll-of (s/get-spec :job.lifecycles/lifecycle) :kind vector?))
+  (s/coll-of :job.lifecycles/lifecycle :kind vector?))

 (s/def :onyx.messaging/peer-port integer?)

@@ -450,11 +451,9 @@
 (s/def :aeron/idle-strategy
   #{:busy-spin :low-restart-latency :high-restart-latency})

-(s/def :onyx.messaging.aeron/poll-idle-strategy
-  (s/get-spec :aeron/idle-strategy))
-
-(s/def :onyx.messaging.aeron/offer-idle-strategy
-  (s/get-spec :aeron/idle-strategy))
+(s/def :onyx.messaging.aeron/poll-idle-strategy :aeron/idle-strategy)
+
+(s/def :onyx.messaging.aeron/offer-idle-strategy :aeron/idle-strategy)

 (s/def :onyx.bookkeeper/client-timeout pos-int?)

@@ -556,7 +555,7 @@

 (s/def :onyx/messaging #{:aeron :dummy-messenger})

-(s/def :onyx.messaging/impl (s/get-spec :onyx/messaging))
+(s/def :onyx.messaging/impl :onyx/messaging)

 (s/def :onyx/peer-config
   (s/keys :req [:onyx/tenancy-id
@@ -629,8 +628,7 @@
                 :onyx.zookeeper/backoff-max-retries
                 :onyx.zookeeper/prepare-failure-detection-interval]))

-(s/def :onyx.core/peer-opts
-  (s/get-spec :onyx/peer-config))
+(s/def :onyx.core/peer-opts :onyx/peer-config)

 (s/def :onyx.core/event-map
   (s/keys :req [:onyx.core/id
@@ -679,8 +677,7 @@

 (s/def :onyx.state-event/event-type keyword?)

-(s/def :onyx.state-event/task-event
-  (s/get-spec :onyx.core/event-map))
+(s/def :onyx.state-event/task-event :onyx.core/event-map)

 (s/def :onyx.state-event/segment any?)


diagnostics and exceptions for strange outside-of-synsem :subcat value in vp-32

--- src/babel/forest.clj
+++ src/babel/forest.clj
@@ -80,18 +80,50 @@
                           (generate-all (rest spec) grammar lexicon index morph))
                 true
                 (do
-                  (log/trace (str "generate-all with semantics: " (show-spec (remove-false (get-in spec [:synsem :sem])))))
-                  (log/trace (str "generate-all with spec: " (strip-refs spec)))
-                  (log/trace (str "generate-all with pred: " (show-spec (remove-false (get-in spec [:synsem :sem :pred])))))
-                  (log/trace (str "generate-all(details): " (show-spec spec)))
-                  (-> (lightning-bolt grammar
+                  (log/debug (str "generate-all with semantics: " (show-spec (remove-false (get-in spec [:synsem :sem])))))
+                  (log/debug (str "generate-all with spec: " (strip-refs spec)))
+                  (log/debug (str "generate-all with pred: " (show-spec (remove-false (get-in spec [:synsem :sem :pred])))))
+                  (log/debug (str "generate-all(details): " (show-spec spec)))
+                  (let [lb (lightning-bolt grammar
                                       lexicon
                                       spec 0 index nil morph)
-                      ;; TODO: allow more than a fixed maximum depth of generation (here, 4 levels from top of tree).
-                      (add-complements-to-bolts [:head :head :head :comp] :top grammar lexicon index morph)
-                      (add-complements-to-bolts [:head :head :comp]       :top grammar lexicon index morph)
-                      (add-complements-to-bolts [:head :comp]             :top grammar lexicon index morph)
-                      (add-complements-to-bolts [:comp]                   :top grammar lexicon index morph))))))
+                        check1 (remove #(= % nil)
+                                       (concat
+
+                                        (map #(get-in % [:head :head :subcat]) lb)
+                                        (map #(get-in % [:head :subcat]) lb)
+                                        (map #(get-in % [:subcat]) lb)
+
+                                        ))]
+                    (if (not (empty? check1))
+                      (let [message (str "BAD BOLT RESULT: (foo):"
+                                         (string/join ","
+                                                      (map #(get-in % [:synsem :foo])
+                                                           lb))
+                                         " >>> "
+                                         (string/join ","
+                                                      (map #(get-in % [:head :head :subcat] :none)
+                                                           lb))
+                                         " >>> "
+                                         (string/join ","
+                                                      (map #(get-in % [:head :subcat] :none)
+                                                           lb))
+                                         " >>> "
+                                         (string/join ","
+                                                      (map #(get-in % [:subcat] :none)
+                                                           lb))
+                                         " >>> "
+                                         (string/join "," (map #(get-in % [:rule])
+                                                               lb)))]
+                        (log/error message)
+                        (throw (Exception. message))))
+
+                    (-> lb
+                        ;; TODO: allow more than a fixed maximum depth of generation (here, 4 levels from top of tree).
+                        (add-complements-to-bolts [:head :head :head :comp] :top grammar lexicon index morph)
+                        (add-complements-to-bolts [:head :head :comp]       :top grammar lexicon index morph)
+                        (add-complements-to-bolts [:head :comp]             :top grammar lexicon index morph)
+                        (add-complements-to-bolts [:comp]                   :top grammar lexicon index morph)))))))

 ;; TODO: add usage of rule-to-lexicon cache (rather than using lexicon directly)
 (defn lightning-bolt [grammar lexicon spec & [ depth index parent morph]]
@@ -124,7 +156,7 @@
       (let [lexical ;; 1. generate list of all phrases where the head child of each parent is a lexeme.
             (mapcat (fn [parent]
                       (let [candidate-lexemes (get-lex parent :head index spec)]
-                        (log/trace
+                        (log/debug
                          (str "candidate head lexeme for parent: "
                               (get-in parent [:rule]) ": "
                               (string/join ","
@@ -132,13 +164,13 @@
                                                   (wrapped-morph morph lexeme))
                                                 candidate-lexemes))))
                         (let [result (over/overh parent (lazy-shuffle (get-lex parent :head index spec)) morph)]
-                          (log/trace
-                           (str "parent: " (get-in parent [:rule]) " with lexemes: "
+                          (log/debug
+                           (str "parent: " (get-in parent [:rule]) " with head lexemes: "
                                 (string/join ","
                                              (map #(wrapped-morph morph %1)
                                                   result))))
                           (if (empty? result)
-                            (log/warn (str "failed to attach any lexemes to: " (get-in parent [:rule])))
+                            (log/warn (str "failed to attach any head lexemes to: " (get-in parent [:rule])))

                             (log/debug (str "successful results of attaching head lexemes to: " (get-in parent [:rule]) ":"
                                             (string/join ","
@@ -189,6 +221,12 @@
         bolt-spec (get-in bolt path :no-path)
         spec (unifyc spec bolt-spec)
         lexicon (if (future? lexicon) @lexicon lexicon)]
+
+    (if (not (= :none (get-in bolt [:head :head :subcat] :none)))
+      (let [message (str "BAD BOLT RESULT: " (get-in bolt [:head :head :subcat] :none))]
+        (log/error message)
+        (throw (Exception. message))))
+
     (log/debug (str "add-complement to bolt with bolt:["
                     (if (map? bolt) (get-in bolt [:rule]))
                     " '" (wrapped-morph morph bolt) "'"
@@ -230,9 +268,9 @@
                                    is-fail? (fail? result)]
                                (if is-fail?
                                  (do
-                                   (log/debug (str "fail-path-between:" (fail-path-between (strip-refs (get-in bolt path))
+                                   (log/trace (str "fail-path-between:" (fail-path-between (strip-refs (get-in bolt path))
                                                                                (strip-refs complement)))))
-                                 (log/debug (str "Success: returning: " (wrapped-morph morph complement))))
+                                 (log/trace (str "Success: returning: " (wrapped-morph morph complement))))

                                (if is-fail? :fail result)))

@@ -248,8 +286,6 @@
               (do
                 (log/warn (str " add-complement took " run-time " msec, but found no lexical complements for "
                                (wrapped-morph morph from-bolt)
-;                               "(rule: " (get-in from-bolt [:rule]) ")"
-;                               "; head rule:" (get-in from-bolt [:head :rule])
                                ". Complements tried were: " (morph complement-candidate-lexemes)))

                 ;; TODO: show warn about not finding any phrasal complements, as well as not finding any lexical complements.
@@ -265,6 +301,10 @@
                                              (map (fn [each]
                                                     (wrapped-morph morph each))
                                                   return-val))))
+                (log/debug (str "BAD RESULT: " (string/join ","
+                                                            (map #(get-in % [:head :head :subcat] :none)
+                                                                 return-val))))
+
                 return-val))))

       ;; path doesn't exist in bolt: simply return the bolt unmodified.


fix namespace

fix namespace

--- src/babel/repair.clj
+++ src/babel/repair.clj
@@ -1,4 +1,4 @@
-(ns italianverbs.repair)
+(ns babel.repair)

 (require '[babel.writer :refer [fill-by-spec fill-verb]])
 (require '[babel.english :refer :all])


simplify INSERT queries: use json/write-str and '::jsonb' with sql params.

--- src/babel/writer.clj
+++ src/babel/writer.clj
@@ -163,21 +163,28 @@
   (log/debug (str "inserting expression: spec=" spec))
   (try
     (exec-raw [(let [insert
-                     (str "INSERT INTO " table " (surface, structure, spec, serialized, language, model) VALUES (?,"
-                          "$$" (json/write-str (strip-refs expression)) "$$,"
-                          "$$" (json/write-str (strip-refs spec)) "$$,"
-                          "$$[" (string/join "" (serialize expression)) "]$$," ;; TODO: check for presence of "$$" within (serialize expression).
-                          "?,?)")]
+                     (str "INSERT INTO " table
+                          "(surface, structure, spec, "
+                          " serialized, language, model)"
+                          " VALUES (?,?::jsonb,?::jsonb,?,?,?)")]
                  (log/trace (str "INSERT IS : " insert))
                  insert)
                [surface
-                language
-                model-name]])
+                (-> expression
+                    (dissoc :dag_unify.core/serialized)
+                    strip-refs
+                    json/write-str)
+                (-> spec
+                    (dissoc :dag_unify.core/serialized)
+                    strip-refs
+                    json/write-str)
+                (-> expression serialize vec str)
+                language model-name]])
     (catch Exception e
       (log/error (str "SQL error: " (.printStackTrace (.getNextException(.getSQLException e))))))))

 (defn insert-lexeme [canonical lexeme language]
-  (log/trace (str "insert-lexeme: canonical=" canonical ",lexeme=" (strip-refs lexeme) ",language=" language))
+  (log/info (str "insert-lexeme: canonical=" canonical ",lexeme=" (strip-refs lexeme) ",language=" language))
   (if (fail? lexeme)
     (let [message (str "Refusing to enter a :fail for canonical form: " canonical)]
       (log/error message)
@@ -185,11 +192,10 @@
     ;; else, lexeme is valid for insertion
     (exec-raw [(str "INSERT INTO lexeme
                                  (canonical, structure, serialized, language)
-                          VALUES (?,"
-                    "$$" (json/write-str (strip-refs lexeme)) "$$"
-                    ",?,?)")
-               [canonical (str "[" (string/join " " (serialize lexeme)) ;; TODO: remove unneeded whitespace: string/join "" should work fine.
-                               "]")
+                          VALUES (?,?::jsonb,?,?)")
+               [canonical
+                (json/write-str (strip-refs lexeme))
+                (-> lexeme serialize vec str)
                 language]])))

 ;; TODO: change all calls to populate-with-language to set source-language if needed


Add the arity/1 for flat-map that defaults identity as map function.

--- src/beicon/core.cljs
+++ src/beicon/core.cljs
@@ -294,9 +294,11 @@
   an observable sequence and merges the resulting
   observable sequences or Promises or array/iterable
   into one observable sequence."
-  [f ob]
-  {:pre [(observable? ob)]}
-  (.flatMap ob #(f %)))
+  ([ob]
+   (flat-map identity ob))
+  ([f ob]
+   {:pre [(observable? ob)]}
+   (.flatMap ob #(f %))))

 (defn skip
   "Bypasses a specified number of elements in an


Improved source code style.

Improved source code style.

--- src/bencode/main.clj
+++ src/bencode/main.clj
@@ -6,61 +6,51 @@
            [java.util Date]
            [java.text SimpleDateFormat]))

-(defn format-date
-  [timestamp]
+(defn format-date [timestamp]
   (let [f (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSSZ")]
     (.format f (Date. (* timestamp 1000)))))

-(defn torrent-piece-length
-  [torrent]
+(defn torrent-piece-length [torrent]
   (get-in torrent ["info" "piece length"]))

-(defn torrent-pieces
-  [torrent]
+(defn torrent-pieces [torrent]
   (get-in torrent ["info" "pieces"]))

-(defn count-torrent-pieces
-  [torrent]
+(defn count-torrent-pieces [torrent]
   (/ (count (torrent-pieces torrent)) 20))

-(defn torrent-size
-  [torrent]
+(defn torrent-size [torrent]
   (* (torrent-piece-length torrent)
      (count-torrent-pieces torrent)))

-(defn hex-from-bytes
-  [byte-arr]
+(defn hex-from-bytes [byte-arr]
   (let [sb (StringBuffer.)]
     (doseq [b byte-arr]
       (.append sb (.substring (Integer/toString (+ (bit-and b 0xff) 0x100) 16) 1)))
     (.toString sb)))

-(defn torrent-info-hash
-  [torrent]
+(defn torrent-info-hash [torrent]
   (let [enc (bencode (get torrent "info") {:raw-str? true})
         dig (MessageDigest/getInstance "SHA1")
         res (.digest dig enc)]
     (hex-from-bytes res)))

-(defn print-announce-group
-  [idx group]
+(defn print-announce-group [idx group]
   (print (str (inc idx) ". "))
   (apply print (interpose ", " group))
   (println ""))

-(defn print-file
-  [idx file]
+(defn print-file [idx file]
   (print (str (inc idx) ". "))
   (print (apply str (interpose "/" (get file "path")))
          (str "[" (get file "length") " bytes]"))
   (println ""))

-(defn -main
-  [& args]
+(defn -main [& args]
   (let [f (io/file (nth args 0))]
     (with-open [stream (io/input-stream f)]
-      (let [torrent(bdecode stream {:str-keys? true
-                                    :raw-keys ["pieces"]})]
+      (let [torrent (bdecode stream {:str-keys? true
+                                     :raw-keys ["pieces"]})]
           (println "Torrent Name..: " (get-in torrent ["info" "name"]))
           (println "Creation Date.: " (format-date (get torrent "creation date")))
           (println "Created By....: " (get torrent "created by"))


Invoke dtbook properly

Invoke dtbook properly

--- src/catalog/core.clj
+++ src/catalog/core.clj
@@ -38,10 +38,10 @@
    (layout.fop/generate-pdf! out)))

 (defn neu-in-braille [in out editorial recommendations]
-  (->> in
+  (-> in
    vubis/read-file
    vubis/order-and-group
    :braille
-   layout.dtbook/dtbook (slurp editorial) (slurp recommendations)
-   (spit (io/file out))))
+   (layout.dtbook/dtbook (slurp editorial) (slurp recommendations))
+   (->> (spit (io/file out)))))


[Add] fun reftype?

[Add] fun reftype?

--- src/clj_elm/util.clj
+++ src/clj_elm/util.clj
@@ -3,3 +3,7 @@
 (defn printfl [obj]
   {:post [(coll? %) (nil? (first %))]}
   [(print obj) (flush)])
+
+(defn reftype? [obj]
+  (or (instance? clojure.lang.Ref obj)
+      (instance? clojure.lang.Atom obj)))


Fixed test fail (missing declare). Added note.

--- src/clj_git/core.clj
+++ src/clj_git/core.clj
@@ -8,6 +8,7 @@
   (:gen-class))

 (declare is-file-modified)
+(declare is-file-staged)

 (defn -main [& args]
   (let [modified (->>  (read-index)
@@ -44,6 +45,7 @@
     )))

 ; TODO: This is slow! (checking if any files are staged takes a long time..)
+;         the tree-to-files function takes 1 second!
 (defn is-file-staged [filename]
   (let [head-tree (tree-to-files (:tree (commit (head))))
         tree-entry      (->> head-tree (filter #(= (:name %) filename)) (first))


add timing to queries

add timing to queries

--- src/clj_pg/honey.clj
+++ src/clj_pg/honey.clj
@@ -49,14 +49,21 @@
         (vector? hsql) (if (keyword? (first hsql)) (sql/format (apply sql/build hsql)) hsql)
         (string? hsql) [hsql]))

+(. java.lang.System nanoTime)
+
+(defmacro from-start [start]
+  `(Math/floor (/ (double (- (. java.lang.System nanoTime) ~start)) 1000000.0)))
+
 (defn query
   "query honey SQL"
   ([db hsql]
    (pr-error
-    (let [sql (honetize hsql)]
+    (let [sql (honetize hsql)
+          start (. java.lang.System nanoTime)
+          res (jdbc/query db sql)]
       (log/debug hsql)
-      (log/info sql)
-      (jdbc/query db sql))))
+      (log/info (str "[" (from-start start) "ms]") sql)
+      res)))
   ([db h & more]
    (query db (into [h] more))))

@@ -71,10 +78,12 @@
 (defn execute
   "execute honey SQL"
   [db hsql]
-  (let [sql (honetize hsql)]
+  (let [sql (honetize hsql)
+        start (. java.lang.System nanoTime)
+        res (pr-error (jdbc/execute! db sql))]
     (log/debug hsql)
-    (log/info sql)
-    (pr-error (jdbc/execute! db sql))))
+    (log/info (str "[" (from-start start) "ms]") sql)
+    res))

 (defn- coerce-entry [conn spec ent]
   (reduce (fn [acc [k v]]


Consistency, we don't want to use the js layer when avoidable

--- src/cljs/go/core.clj
+++ src/cljs/go/core.clj
@@ -316,7 +316,7 @@
   (bool-expr (core/list 'js* "~{} == false" x)))

 (defmacro array? [x]
-  (bool-expr `(.isArray js/Array ~x)))
+  (bool-expr (core/list 'js* "reflect.TypeOf(~{}).Kind() == reflect.Slice" x)))

 (defmacro string? [x]
   (bool-expr (core/list 'js* "reflect.TypeOf(~{}).Kind() == reflect.String" x)))


Note that we might need to pull this stuff over as well

--- src/cljs/go/core.clj
+++ src/cljs/go/core.clj
@@ -8,6 +8,8 @@

 ;; Go emitter. Forked from 5ca535759f8e2490b42dfa25df0458a6c3376d8c
 ;; This file only overlays cljs.core macros that use js*
+;; Functions which use the internal representation of IFn, related to get-apply-to and protocols probabaly also needs to be here.
+;; Some of this leaks out into cljs/core.cljs

 (require 'cljs.core)


SVG#axis should use unify instead of map for better in-browser performance.

--- src/cljx/c2/svg.cljx
+++ src/cljx/c2/svg.cljx
@@ -2,13 +2,15 @@
 ;;
 ;;Coordinates to any fn can be 2-vector `[x y]` or map `{:x x :y y}`.
 ^:clj (ns c2.svg
-        (:use [c2.maths :only [Pi Tau radians-per-degree
+        (:use [c2.core :only [unify]]
+              [c2.maths :only [Pi Tau radians-per-degree
                                sin cos mean]]
               [clojure.core.match :only [match]]))

 ^:cljs (ns c2.svg
          (:use-macros [clojure.core.match.js :only [match]])
-         (:use [c2.maths :only [Pi Tau radians-per-degree
+         (:use [c2.core :only [unify]]
+               [c2.maths :only [Pi Tau radians-per-degree
                                 sin cos mean]])
          (:require [c2.dom :as dom]))

@@ -112,11 +114,11 @@
     [:g {:class (str "axis " (name orientation))}
      [:line.rule (apply hash-map (interleave [y1 y2] (:range scale)))]
      [:g.ticks
-      (map (fn [d]
-             [:g.tick.major-tick {:transform (translate {x 0 y (scale d)})}
-              [:text {x (* parity text-margin)} (formatter d)]
-              [:line {x1 0 x2 (* parity major-tick-width)}]])
-           ticks)]
+      (unify ticks
+             (fn [d]
+               [:g.tick.major-tick {:transform (translate {x 0 y (scale d)})}
+                [:text {x (* parity text-margin)} (formatter d)]
+                [:line {x1 0 x2 (* parity major-tick-width)}]]))]

      (when label
        [:text.label {:transform (str (translate {x (* parity label-margin)


use smarter regexes -> order-of-magnitude-plus improvemnt

--- src/blx/sortable/core.clj
+++ src/blx/sortable/core.clj
@@ -1,11 +1,9 @@
 (ns blx.sortable.core
   (:require [clojure.java.io :as io]
             [clojure.string :as str]
-            [clojure.core.reducers :as r]
             [iota]
             [tesser.core :as t]
             [cheshire.core :as json]
-;            [clj-fuzzy.metrics :refer [levenshtein]]
             [taoensso.timbre :as timbre]
             [taoensso.timbre.profiling :as p]
             [blx.sortable.util :refer [first-word levenshtein map-vals]])
@@ -52,29 +50,57 @@
          ; close the stream before the seq is realized.
          (mapv parse-json))))

+(defn family-regex
+  [family]
+  (re-pattern
+    (str #"^(?:[\w()]*\s*){0,3}"
+         (when family
+           (str "(?:" (str/lower-case family) ")?"
+                #"\s*\w*\s*")))))
+
+(defn model-regex
+  [model]
+  (-> (or model "")
+      ; [_ -] chars are equivalent and optional
+      (str/replace #"[\s_-]+" "[\\\\s_-]*")
+      ; common model prefixes are optional
+      str/lower-case
+      (str/replace #"(dsc|dslr|dmc|pen|slt|is)" "(?:$1)?")))
+
 (p/defnp product-regex
   "Generates a case-insensitive regex pattern that represents the product."
   [product]
-  (let [fmt-model (fn [s]
-                    (-> (or s "")
-                        ; [_ -] chars are equivalent and optional
-                        (str/replace #"[\s_-]+" "[\\\\s_-]*")
-                        ; common model prefixes are optional
-                        (str/replace #"(?i)(DSC|DSLR|DMC|PEN|SLT|IS)" "(?:$1)?")
-                        str/lower-case))]
-    ; Roughly: word{0,3} family? word? model
-    (re-pattern
-      (str #"^(?:[\w()]*\s*){0,3}"
-           (when-let [family (:family product)]
-             (str "(?:" (str/lower-case family) ")?"
-                  #"\s*\w*\s*"))
-           (fmt-model (:model product))
-           ; Don't match if model is directly followed by a number,
-           ; eg. don't accept "EOS 100" for "EOS 10".
-           #"(?:[^\d]+|$)"))))
+  ; Roughly: word{0,3} family? word? model
+  (re-pattern
+    (str (family-regex (:family product))
+         (model-regex (:model product))
+         ; Don't match if model is directly followed by a number,
+         ; eg. don't accept "EOS 100" for "EOS 10".
+         #"(?:[^\d]+|$)")))
+
+(comment
+(defn make-product-matchers
+  [products]
+  (let [prefix-pattern
+        (fn [family]
+          (re-pattern
+            (str #"^(?:[\w()]*\s*){0,3}"
+                 (when family)
+                   (str "(?:" (str/lower-case family) ")?"
+                        #"\s*\w*\s*"))))]
+    (->> (map :family product)
+         (map (fn [family]
+                (let [fam-pat (prefix-pattern family)]
+                  (fn [query]
+                    (and (re-find fam-pat query)
+                         1)
+
+         (apply some-fn)))))))))

 (defn prepare-product [product]
-  (assoc product :regex (product-regex product)))
+  (assoc product
+         :regex (product-regex product)
+         :model-regex (re-pattern (model-regex (:model product)))))

 (p/defnp group-products
   "Returns a map of (lowercase first word of manufacturer) to products."
@@ -105,7 +131,8 @@
     (fn [title]
       (p/p :title-matcher
            (first
-             (filter #(re-find (:regex %) title)
+             (filter #(and (re-find (:model-regex %) title)
+                           (re-find (:regex %) title))
                      products))))))

 (defn make-manufacturer-matcher


Remove special case for router handler adapter.

--- src/catacumba/ratpack.clj
+++ src/catacumba/ratpack.clj
@@ -38,13 +38,6 @@
 ;; Routing
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

-(defn- chain-handler
-  [handler]
-  (impl/ratpack-adapter
-   (fn [^Context context]
-     (let [params (into {} (.getPathTokens context))]
-       (handler context params)))))
-
 (defmulti attach-route
   (fn [chain [method & _]] method))

@@ -60,7 +53,7 @@

 (defmethod attach-route :default
   [^Chain chain [method ^String path & handlers]]
-  (let [^java.util.List handlers (mapv chain-handler handlers)]
+  (let [^java.util.List handlers (mapv impl/ratpack-adapter handlers)]
     (condp = method
       :get (.get chain path (Handlers/chain handlers))
       :post (.post chain path (Handlers/chain handlers))


display error when websocket disconnects

--- src/chat/client/sync.cljs
+++ src/chat/client/sync.cljs
@@ -4,6 +4,7 @@
   (:require [cljs.core.async :as async :refer [<! >! put! chan alts!]]
             [taoensso.sente  :as sente :refer [cb-success?]]
             [goog.string :as gstring]
+            [chat.client.store :as store]
             [goog.string.format]))

 (defn debugf [s & args]
@@ -32,7 +33,11 @@
   [{:as ev-msg :keys [?data]}]
   (if (?data :first-open?)
     (debugf "Channel socket successfully established!")
-    (debugf "Channel socket state change: %s" ?data))
+    (do
+      (debugf "Channel socket state change: %s" ?data)
+      (if (not (:open? ?data))
+        (store/display-error! "Disconnected")
+        (store/clear-error!))))
   (event-handler [:socket/connected ?data]))

 (defmethod event-msg-handler :chsk/recv


More dev cleanup

More dev cleanup

--- src/clj/gtfve/handler.clj
+++ src/clj/gtfve/handler.clj
@@ -56,11 +56,9 @@
                           "application/json"]
   :allowed-methods [:get]
   :last-modified (fn [_] (begin-of-last-minute))
-  :handle-ok (fn [_] (do
-                       (println [query pull])
-                       (if pull
-                         (q/stops-search query pull)
-                         (q/stops-search query)))))
+  :handle-ok (fn [_] (if pull
+                       (q/stops-search query pull)
+                       (q/stops-search query))))

 (defroutes routes
   (GET "/" [] (render-file "templates/index.html" {:dev (env :dev?)}))


Fix command GUI for depreciation rate.

Fix command GUI for depreciation rate.

--- src/cljs/beatha/core.cljs
+++ src/cljs/beatha/core.cljs
@@ -628,10 +628,13 @@
     (automaton-command-view [_] market-command-view)
     (automaton-command-initial-state [_]
       (let [params a/market-model-default-params]
-        (merge (select-keys params [:fixed-tax :depreciation :taxation-type])
+        (merge (select-keys params [:fixed-tax :taxation-type])
                (:utility-params params)
                {:tax-rate
-                (apply str (butlast (num->percent (:tax-rate params))))})))
+                (apply str (butlast (num->percent (:tax-rate params))))
+                :depreciation
+                (apply str
+                       (butlast (num->percent (:depreciation params))))})))
     (automaton-command-reset [_ command-channel]
       (put! command-channel a/market-model-default-state))
     (automaton-output-handler [_ data owner msg]


adding more input fields

adding more input fields

--- src/cljs/hit_wl/core.cljs
+++ src/cljs/hit_wl/core.cljs
@@ -66,6 +66,8 @@
    [:div.page-header [:h1 "Reagent Sandbox"]]
    [text-input :first-name "First name"]
    [text-input :sur-name "Surname"]
+   [text-input :date "Date"]
+   [text-input :comments "Comments"]
    [selection-list :excercise-type "Select type of Excercise"
     [:leg-press "Leg Press"]
     [:chest-press "Chest Press"]


add order-by functionality

add order-by functionality

--- src/cljs/phonecat_re_frame/core.cljs
+++ src/cljs/phonecat_re_frame/core.cljs
@@ -23,13 +23,13 @@
    (reaction (:phones @db))))  ;; pulls out :phones

 (re-frame/register-handler
- :initialise-db             ;; usage: (dispatch [:initialise-db])
- (fn
-   [_ _]                   ;; Ignore both params (db and v).
-   {:phones [{:name "Nexus S" :snippet "Fast just got faster with Nexus S."}
-             {:name "Motorola XOOM™ with Wi-Fi" :snippet "The Next, Next Generation tablet."}
-             {:name "Motoral Xoom" :snippet "The Next, Next Generation tablet."}]
-    :search-input ""}))
+   :initialise-db             ;; usage: (dispatch [:initialise-db])
+   (fn
+     [_ _]                   ;; Ignore both params (db and v).
+     {:phones [{:name "Nexus S" :snippet "Fast just got faster with Nexus S."}
+               {:name "Motorola XOOM™ with Wi-Fi" :snippet "The Next, Next Generation tablet."}
+               {:name "Motoral Xoom" :snippet "The Next, Next Generation tablet."}]
+      :search-input ""}))

 (defn handle-search-input-entered
   [app-state [_ search-input]]
@@ -51,16 +51,15 @@
   [search-input phone]
   (if (= "" search-input)
     true
-    (boolean (or
-              (re-find (re-pattern search-input) (:name phone))
-              (re-find (re-pattern search-input) (:snippet phone))))))
+    (= (:name phone) search-input)))

 (defn phones-component
   []
   (let [phones (re-frame/subscribe [:phones])
         search-input (re-frame/subscribe [:search-input])]
     (fn []
-      [:ul {:class "phones"}
+
+      [:ul {:class= "phones"}
        (for [phone (filter (partial matches-query? @search-input) @phones)]
          ^{:key (:name phone)} [phone-component phone])])))