SUBMIT TO FIREBASE

SUBMIT TO FIREBASE

--- src/cljs/bmihw/submit.cljs
+++ src/cljs/bmihw/submit.cljs
@@ -1,17 +1,26 @@
 (ns bmihw.submit
-  (:require [bmihw.common :refer [fb]]))
+  (:require [bmihw.common :refer [auth fb]]
+            [reagent-forms.core :refer [bind-fields]]))

-(defn submit-to-fb []
-  (.log js/console fb))
+(defn submit-to-fb [state]
+  (.push fb
+    (clj->js state)
+    (fn [error]
+      (when error
+        (js/alert (str "An error occurred: " error))))))

 (defn submit-page []
-  [:div [:h2 "Submit your insult."]
-   [:div [:div
-          [:input {:type :text :name :username :placeholder "Username"}]
-          [:br]
-          [:input {:type :text :name :keyword :placeholder "Keyword"}]
-          [:br]
-          [:input {:type :text :name :content :placeholder "Content"}]
-          [:br]
-          [:input {:type :submit :value "Submit"
-                   :on-click submit-to-fb}]]]])+  (let [state (atom {})]
+    [:div [:h2 "Submit your insult."]
+     [:div [:div
+            [:input {:type :text :name :username :placeholder "Username"
+                     :on-change #(swap! state assoc :username (-> % .-target .-value))}]
+            [:br]
+            [:input {:type :text :name :keyword :placeholder "Keyword"
+                     :on-change #(swap! state assoc :keyword (-> % .-target .-value))}]
+            [:br]
+            [:input {:type :text :name :content :placeholder "Content"
+                     :on-change #(swap! state assoc :content (-> % .-target .-value))}]
+            [:br]
+            [:input {:type :submit :value "Submit"
+                     :on-click #(submit-to-fb @state)}]]]]))


shift it around

shift it around

--- src/cljs/cezanne/core.cljs
+++ src/cljs/cezanne/core.cljs
@@ -14,26 +14,18 @@
                     0.1
                     1000)
         renderer (js/THREE.WebGLRenderer.)
-        geometry-0 (js/THREE.CubeGeometry. 1.7 1.7 1.7)
-        geometry-1 (js/THREE.SphereGeometry. 1.5 8 8)
-        geometry-2 (js/THREE.RingGeometry. 1.2 1.5 64)
-        geometry-3 (js/THREE.SphereGeometry. 1 4 4)
-        material-0 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true
-                                                         :color 0xa00e39
-                                                          :wireframeLinewidth 8}))
-        material-1 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true
-                                                         :color 0x066a9d
-                                                         :wireframeLinewidth 3}))
-        material-2 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true
-                                                         :color 0x0ea039
-                                                         :wireframeLinewidth 3}))
-        material-3 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true
-                                                         :color 0xf99a25
-                                                         :wireframeLinewidth 3}))
-        cube-0 (js/THREE.Mesh. geometry-0 material-0)
-        sphere-0 (js/THREE.Mesh. geometry-1 material-1)
-        sphere-1 (js/THREE.Mesh. geometry-3 material-2)
-        ring-0 (js/THREE.Mesh. geometry-2 material-3)
+        cube-geo-0 (js/THREE.CubeGeometry. 1.7 1.7 1.7)
+        sphere-geo-0 (js/THREE.SphereGeometry. 1.3 16 16)
+        sphere-geo-1 (js/THREE.SphereGeometry. 0.8 16 16)
+        ring-geo-0 (js/THREE.RingGeometry. 1.2 1.5 64)
+        material-0 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true :color 0xa00e39 :wireframeLinewidth 8}))
+        material-1 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true :color 0x0ea039 :wireframeLinewidth 3}))
+        material-2 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true :color 0x066a9d :wireframeLinewidth 3}))
+        material-3 (js/THREE.MeshBasicMaterial. (clj->js {:wireframe true :color 0xf99a25 :wireframeLinewidth 3}))
+        cube-0 (js/THREE.Mesh. cube-geo-0 material-0)
+        sphere-0 (js/THREE.Mesh. sphere-geo-0 material-1)
+        sphere-1 (js/THREE.Mesh. sphere-geo-1 material-2)
+        ring-0 (js/THREE.Mesh. ring-geo-0 material-3)
         ]
     (.setSize renderer (.-innerWidth js/window) (.-innerHeight js/window))
     (.. js/document -body (appendChild (.-domElement renderer)))
@@ -43,8 +35,7 @@
     (.add scene ring-0)
     (set! (.. camera -position -z) 5)
     (set! (.. cube-0 -position -x) 4)
-    (set! (.. ring-0 -position -x) -4)
-    (set! (.. sphere-1 -position -x) -4)
+    (set! (.. sphere-0 -position -x) -4)
     (reset! state
           {:scene scene
            :camera camera
@@ -63,8 +54,8 @@
   (set! (.. (:cube-0 @state) -rotation -y) (+ (.. (:cube-0 @state) -rotation -y) 4e-2))
   (set! (.. (:sphere-0 @state) -rotation -x) (+ (.. (:sphere-0 @state) -rotation -x) 2e-2))
   (set! (.. (:sphere-0 @state) -rotation -y) (+ (.. (:sphere-0 @state) -rotation -y) 1e-2))
-  (set! (.. (:ring-0 @state) -rotation -x) (+ (.. (:ring-0 @state) -rotation -x) 4e-2))
-  (set! (.. (:ring-0 @state) -rotation -y) (+ (.. (:ring-0 @state) -rotation -y) 8e-2))
+  (set! (.. (:ring-0 @state) -rotation -x) (+ (.. (:ring-0 @state) -rotation -x) 2.1e-2))
+  (set! (.. (:ring-0 @state) -rotation -y) (+ (.. (:ring-0 @state) -rotation -y) 7.3e-2))
   (set! (.. (:sphere-1 @state) -rotation -x) (+ (.. (:sphere-1 @state) -rotation -x) -4e-2))
   (set! (.. (:sphere-1 @state) -rotation -y) (+ (.. (:sphere-1 @state) -rotation -y) -4e-3))
   )


simplify diagnostic-delta

simplify diagnostic-delta

--- src/cljx/commos/delta.cljx
+++ src/cljx/commos/delta.cljx
@@ -10,9 +10,11 @@
 (defn summable-delta
   "Make a diagnostic applicable for add again."
   [[op korks new-val :as delta]]
-  (if (seq korks)
-    delta
-    [op new-val]))
+  (let [new-val (cond-> new-val
+                  (= :is op) peek)]
+    (if (seq korks)
+      (assoc delta 2 new-val)
+      [op new-val])))

 ;; Creating deltas
 (defn negative-diagnostic-deltas
@@ -49,26 +51,32 @@
                        [[:in full-ks v]]

                        :else
-                       [[:is full-ks v]])))]
+                       [[:is full-ks [v]]])))]
     (mapcat (partial step []) (flatten-keys m))))

-(def ^{:arglists '([m])} positive-deltas
+(defn positive-deltas
   "Convert a map to positive summable deltas."
-  positive-diagnostic-deltas)
+  [m]
+  (->> m
+       positive-diagnostic-deltas
+       (map summable-delta)))

 ;; Helpers on deltas
 (defn diagnostic-delta
-  "Bring delta into diagnostic form [op ks (v | [v+])].  v is a
-  collection for :in and :ex ops.  This form is not applicable for add
-  as ks can be [], which is invalid.  See summable-delta.
+  "Bring delta into diagnostic form [op ks vs].  For convenience, vs
+  is a collection for any op.
+
+  This form is not applicable for add.  See summable-delta.

   Not suitable for :batch - use unpack."
   [[op korks-or-new-val new-val :as delta]]
-  (cond-> (if (= 3 (count delta))
-            [op (collect korks-or-new-val) new-val]
-            [op [] korks-or-new-val])
-    (not (#+clj identical? #+cljs keyword-identical? op :is))
-    (update-in [2] collect)))
+  (-> (if (= 3 (count delta))
+        [op (collect korks-or-new-val) new-val]
+        [op [] korks-or-new-val])
+      (update-in [2]
+                 (if (#+clj identical? #+cljs keyword-identical? op :is)
+                   vector
+                   collect))))

 (defn- prepend-ks*
   [ks [op korks-or-new-val new-val :as delta]]


Fix a bug in JavaSchemaRDD

Fix a bug in JavaSchemaRDD

--- src/clojure/flambo/sql.clj
+++ src/clojure/flambo/sql.clj
@@ -64,7 +64,7 @@
 (extend-type SQLContext
   PHasSQLContext
   (^JavaSQLContext get-java-sql-context [this]
-    (JavaSQLContext. (.sqlContext this))))
+    (JavaSQLContext. this)))

 (extend-type SchemaRDD
   PHasSQLContext


Import the JavaCC MPA-Parser (not tested!)

--- src/mpa/cst/parser/parser.clj
+++ src/mpa/cst/parser/parser.clj
@@ -8,7 +8,26 @@

 (defn- cst2list
   [cst]
-  (.jjtGetChild cst 0))
+  (case (.jjtGetNumChildren cst)
+    0 (case (.getLexeme cst) ; Boolean | Atom
+        "TRUE" 'true
+        "FALSE" 'false
+        (symbol (.getLexeme cst)))
+    1 (if (= (class cst) mpa.cst.parser.MpaNotExpr) ; NOT | hierarchic descent
+        (list 'not (cst2list (.jjtGetChild cst 0)))
+        (cst2list (.jjtGetChild cst 0)))
+    2 (let [op (case (.getOp cst)
+                 14 'and
+                 15 'nand
+                 16 'or
+                 17 'nor
+                 18 'cimpl
+                 19 'ncimpl
+                 20 'impl
+                 21 'nimpl
+                 22 'equiv
+                 23 'xor)]
+        (list op (cst2list (.jjtGetChild cst 0)) (cst2list (.jjtGetChild cst 1))))))

 (defn parse
   [formula]


Add default buttons

Add default buttons

--- src/discuss/utils/bootstrap.cljs
+++ src/discuss/utils/bootstrap.cljs
@@ -3,10 +3,22 @@
   (:require [om.dom :as dom]
             [discuss.utils.common :as lib]))

+(defn button
+  "Create dom element of a bootstrap button."
+  [fn class & strs]
+  (dom/button #js {:className (str "btn " class)
+                   :onClick   fn
+                   :key       (lib/get-unique-key)}
+              strs))
+
 (defn button-primary
   "Create dom element of a bootstrap primary button."
-  [fn & strs]
-  (dom/button #js {:className "btn btn-primary"
-                   :onClick   fn
-                   :key       (lib/get-unique-key)}
-              strs))+  [fn & strs] (button fn "btn-primary" strs))
+
+(defn button-default
+  "Create dom element of a bootstrap default button."
+  [fn & strs] (button fn "btn-default" strs))
+
+(defn button-default-sm
+  "Create dom element of a bootstrap default small button."
+  [fn & strs] (button fn "btn-default btn-sm" strs))


start of external kernel

start of external kernel

--- src/latte/core.clj
+++ src/latte/core.clj
@@ -6,13 +6,11 @@
   mostly depend on this namespace."

   (:require [clojure.pprint :as pp]
-            [latte.kernel.utils :as u]
-            [latte.kernel.presyntax :as stx]
-            [latte.kernel.typing :as ty]
-            [latte.kernel.norm :as n]
-            [latte.kernel.defenv :as defenv]
-            [latte.kernel.defs :as d]
-            [latte.kernel.proof :as p]))
+            [latte-kernel.presyntax :as stx]
+            [latte-kernel.typing :as ty]
+            [latte-kernel.norm :as n]
+            [latte-kernel.defenv :as defenv]
+            [latte-kernel.proof :as p]))

 ;;{
 ;; ## Definitions (defined terms)


Update to ClojureScript 1.7.145

Update to ClojureScript 1.7.145

--- ClojureScript/replete/project.clj
+++ ClojureScript/replete/project.clj
@@ -1,6 +1,6 @@
 (defproject replete "0.1.0"
   :dependencies [[org.clojure/clojure "1.7.0"]
-                 [org.clojure/clojurescript "1.7.122"]
+                 [org.clojure/clojurescript "1.7.145"]
                  [tailrecursion/cljson "1.0.7"]]
   :clean-targets ["out" "target"]
   :plugins [[lein-cljsbuild "1.0.6"]]


removed page_utils dead dependency

removed page_utils dead dependency

--- src/crawler/core.clj
+++ src/crawler/core.clj
@@ -5,7 +5,6 @@
   (:require [clojure.tools.cli :as cli]
             [clj-http.client :as client]
             [org.bovinegenius [exploding-fish :as uri]]
-            [crawler.page-utils :as page-utils]
             [crawler.utils :as utils])
   (:use [clojure.pprint]))


Fix create new board with entries notification trigger since it was still using the old form without the personal note.

--- src/oc/storage/api/boards.clj
+++ src/oc/storage/api/boards.clj
@@ -194,7 +194,7 @@
               (when (= :add entry-action)
                 (entries-api/auto-share-on-publish conn (assoc ctx :existing-board board-result) entry-result))
               (change/send-trigger! (change/->trigger entry-action entry-result))
-              (notification/send-trigger! (notification/->trigger entry-action org board-result {:new entry-result} (:user ctx)))))))
+              (notification/send-trigger! (notification/->trigger entry-action org board-result {:new entry-result} (:user ctx) nil))))))
       (let [created-board (if (and (empty? authors) (empty? viewers))
                             ;; no additional members added, so using the create response is good
                             board-result


fix test: "be called" should be present

fix test: "be called" should be present

--- test/babel/test/en.cljc
+++ test/babel/test/en.cljc
@@ -154,7 +154,8 @@
                                  :sem {:mod '()
                                        :iobj {:pred :luisa}
                                        :pred :be-called
-                                       :subj {:pred :lei}}}}
+                                       :subj {:pred :lei}
+                                       :tense :present}}}
                        :model medium)))))

 (deftest jean-s


remove misleading comment

remove misleading comment

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -86,7 +86,7 @@
                  :sem (get-in (first (parse (fo expr) np-grammar))
                               [:synsem :sem])})))))
 (deftest roundtrip-all
-  (let [do-this-many 100] ;; doing them all takes minutes rather than seconds.
+  (let [do-this-many 100]
     (is (empty?
          (filter #(not (nil? %))
                  (let [expressions


tense should be :present, not :past for passato prossimo

--- test/babel/test/it.cljc
+++ test/babel/test/it.cljc
@@ -111,11 +111,10 @@

 (deftest fix-regression
   (let [spec {:synsem {:cat :verb
-                       :infl :present
                        :subcat '()
                        :sem {:pred :get-up
                              :subj {:pred :I}
-                             :tense :past
+                             :tense :present
                              :aspect :perfect}}}]
     (is (not (nil? (generate/generate spec small))))))


re-implement #'metronome using defrecord and protocols. Added Metronome class and IMetronome protocol.

--- src/overtone/music/rhythm.clj
+++ src/overtone/music/rhythm.clj
@@ -22,9 +22,45 @@
 ;  ([] (bar 1))
 ;  ([b] (* (bar 1) (first @*signature) b)))

-; A metronome is a linear function that given a beat count returns the time in milliseconds.
-;
-; tpb = ticks-per-beat
+(defprotocol IMetronome
+  (start [this] [this b]
+    "Start or restart the metronome at beat number 'b' or 0 if none is given. Returns the next beat number")
+  (tick [this]
+    "Returns the duration of each 'tick' in milleseconds.")
+  (beat [this] [this b]
+    "Returns the number of the next beat or the timestamp (in milliseconds) of the
+     given beat number 'b'.")
+  (bpm [this] [this new-bpm]
+    "Get the current bpm or change the bpm to 'new-bpm'."))
+
+(defrecord Metronome [start cur-bpm tick-ms]
+  IMetronome
+  (start [this] (do (reset! start (now))
+                    (beat this)))
+  (start [this b] (let [new-start (- (now) (* b @tick-ms))]
+                        (reset! start new-start)
+                        (beat this)))
+  (tick  [this] (beat-ms 1 @cur-bpm))
+  (beat  [this] (inc (long (/ (- (now) @start) @tick-ms))))
+  (beat  [this b] (+ (* b @tick-ms) @start))
+  (bpm   [this] @cur-bpm)
+  (bpm   [this new-bpm]
+    (let [cur-beat (beat this)
+          new-tick (beat-ms 1 new-bpm)
+          new-start (- (now) (* new-tick cur-beat))]
+      (reset! start new-start)
+      (reset! tick-ms new-tick)
+      (reset! cur-bpm new-bpm))
+    [:bpm new-bpm])
+  clojure.lang.IFn
+  (invoke [this] (beat this))
+  (invoke [this arg]
+    (cond
+     (number? arg) (beat this arg)
+     (= :bpm arg) (.bpm this) ;; (bpm this) fails.
+     :else (throw (Exception. (str "Unsupported metronome arg: " arg)))))
+  (invoke [this _ new-bpm] (.bpm this new-bpm)))
+
 (defn metronome
   "A metronome is a beat management function.  Tell it what BPM you want,
   and it will output beat timestamps accordingly.  Call the returned function
@@ -32,7 +68,7 @@
   to get the timestamp to play a note at that beat.

   (def m (metronome 128))
-  (m)          ; => <current beat number>
+  (m)          ; => <next beat number>
   (m 200)      ; => <timestamp of beat 200>
   (m :bpm)     ; => return the current bpm val
   (m :bpm 140) ; => set bpm to 140"
@@ -40,27 +76,7 @@
   (let [start   (atom (now))
         tick-ms (atom (beat-ms 1 bpm))
         cur-bpm (atom bpm)]
-    (fn
-      ([] (inc (long (/ (- (now) @start) @tick-ms))))
-      ([arg] (cond
-              (number? arg) (+ (* arg @tick-ms) @start)
-              (= :bpm arg) @cur-bpm
-              :else (throw (Exception. (str "Unsupported metronome arg: " arg)))))
-      ([_ bpm]
-       (let [tms (beat-ms 1 bpm)
-             cur-beat (long (/ (- (now) @start) @tick-ms))
-             new-start (- (now) (* tms cur-beat))]
-         (reset! tick-ms tms)
-         (reset! start new-start)
-         (reset! cur-bpm bpm))
-       [:bpm bpm]))))
-
-(comment defprotocol IMetronome
-  (start [this])
-  (stop  [this])
-  (beat  [this])
-  (tick  [this])
-  (bpm   [this] [this bpm]))
+    (Metronome. start cur-bpm tick-ms)))

 ;== Grooves
 ;


Refactor code

Refactor code

--- src/pinpointer/formatter.cljc
+++ src/pinpointer/formatter.cljc
@@ -15,6 +15,9 @@
                  " must have its own method implementation of " `render)]
     (throw (ex-info msg {:spec spec}))))

+(defn call-with-base-printer [f printer x]
+  (f (:base-printer printer) x))
+
 (defn- highlight [x]
   [:span [:escaped *highlighting-mark*] x [:escaped *highlighting-mark*]])

@@ -22,9 +25,9 @@
   (let [frame (first trace)]
     (if (= x (:val frame))
       (if (and (= (count trace) 1) (not (:reason frame)))
-        (highlight (f (:base-printer printer) x))
+        (highlight (call-with-base-printer f printer x))
         (render frame printer x))
-      (f (:base-printer printer) x))))
+      (call-with-base-printer f printer x))))

 (defn pop-trace [printer]
   (update printer :trace rest))
@@ -166,20 +169,18 @@

 (defn- render-regex [{:keys [reason steps] :as frame} printer x]
   (cond (= reason "Extra input")
-        (let [printer (:base-printer printer)]
-          (render-coll frame printer x
-            (fn [i v]
-              (cond-> (visit/visit printer v)
-                (>= i (first steps)) highlight))))
+        (render-coll frame (:base-printer printer) x
+          (fn [i v]
+            (cond-> (call-with-base-printer visit/visit printer v)
+              (>= i (first steps)) highlight)))

         (or (= reason "Insufficient input") ;; special case for s/alt
             (when-let [next-frame (second (:trace printer))]
               (= (:reason next-frame) "Insufficient input")))
-        (let [printer (:base-printer printer)
-              x (if (seq? x) (concat x ['...]) (conj x '...))]
+        (let [x (if (seq? x) (concat x ['...]) (conj x '...))]
           (render-coll frame printer x
             (fn [i v]
-              (cond-> (visit/visit printer v)
+              (cond-> (call-with-base-printer visit/visit printer v)
                 (= i (dec (count x))) highlight))))

         (empty? steps)
@@ -216,7 +217,7 @@

 (defmethod render `s/multi-spec [frame printer x]
   (if (= (:reason frame) "no method")
-    (highlight (visit/visit (:base-printer printer) x))
+    (highlight (call-with-base-printer visit/visit printer x))
     (render-next printer x)))

 (defmethod render `s/nonconforming [frame printer x]


Adds `type` to projects and tasks

Adds `type` to projects and tasks

--- src/great_things_done/state.cljs
+++ src/great_things_done/state.cljs
@@ -2,9 +2,14 @@
   (:require [cljs-uuid-utils.core :as uuid]
             [great-things-done.db :as db]))

+(def ^:private task-types ["Task" "SubTask"])
+
+;; Caches
 (def ^:private meta-projects      (atom []))
+(def ^:private projects           (atom {}))
 (def ^:private active-projects    (atom {}))
 (def ^:private completed-projects (atom {}))
+(def ^:private tasks              (atom {}))
 (def ^:private active-tasks       (atom {}))
 (def ^:private repeating-tasks    (atom {}))
 (def ^:private completed-tasks    (atom {}))
@@ -18,7 +23,8 @@
                                          :creation-date nil
                                          :due-date      nil
                                          :active        nil
-                                         :done          false}))
+                                         :done          false
+                                         :type          "Project"}))

 (defn- generate-uuid
   []
@@ -44,6 +50,14 @@
   "Return the current time as a string"
   []
   (str (.now js/Date)))
+
+(defn- is-project
+  [entity]
+  (= (:type entity) "Project"))
+
+(defn- is-task
+  [entity]
+  (filter #{(:type entity)} task-types))

 (defn- register-tags!
   [entry entry-type]
@@ -99,9 +113,20 @@

 (defn- new-task
   [task-name project tags sub-tasks description remind-date due-date show-before repeating done]
+  [task-name parent task-type tags sub-tasks description remind-date due-date show-before repeating done]
+  (when-not (is-task {:type task-type})
+    (throw (js/Error. (str "Task type must belong to ["
+                           (clojure.string/join ", "
+                                                task-types)
+                           "]. Provided type was `"
+                           task-type
+                           "`"))))
   {:name        task-name
    :id          (build-id task-name)
    :project     (select-keys project [:name :id])
+   :type        (if (= (:type parent) "Project")
+                  "Task"
+                  "SubTask")
    :tags        tags
    :sub-tasks   sub-tasks
    :description description
@@ -115,6 +140,7 @@
   [project-name tags tasks description due-date active done]
   {:name          project-name
    :id            (build-id project-name)
+   :type          "Project"
    :tags          tags
    :tasks         tasks
    :description   description
@@ -135,8 +161,8 @@
     (inbox)))

 (defn register-task
-  [task-name {:keys [project tags sub-tasks description remind-date due-date show-before repeating]
-              :or   {project     (inbox)
+  [task-name {:keys [parent tags sub-tasks description remind-date due-date show-before repeating]
+              :or   {parent      (inbox)
                      tags        []
                      sub-tasks   []
                      description ""
@@ -145,7 +171,7 @@
                      show-before 0
                      repeating   false}}]
   (let [task (new-task task-name
-                       project
+                       parent
                        tags
                        sub-tasks
                        description


start quartz scheduler in handler init

start quartz scheduler in handler init

--- src/chat/server/handler.clj
+++ src/chat/server/handler.clj
@@ -230,6 +230,5 @@
     (chat.server.sync/start-router!)
     (nrepl/start-server :port repl-port)
     (println "starting on port " port)
-    (let [sch (qs/initialize)]
-      (println "starting quartz scheduler")
-      (qs/start sch))))
+    (println "starting quartz scheduler")
+    (start-scheduler!)))


interpolate first then calculate z coordinate

--- src/clj/calc_angle/core.clj
+++ src/clj/calc_angle/core.clj
@@ -20,12 +20,12 @@
 ;;
 (def min-y 18)
 (def xfield-size 24)
-(def yfield-size 12)
+(def yfield-size 8)

 (def base-high 25.4)
 (def first-arm 20.9)
 (def second-arm 24.0)
-(def offset-last 5.2)
+(def offset-last 5.5)

 (defn to-int [val]
   (int (+ 0.5 val)))
@@ -96,11 +96,26 @@
 ;          (* ratio1 (second pt1))
 ;          (* ratio2 (second pt2)))))

-(def intra-max-dist 15)
+(def intra-max-dist 4)

 (defn fill-intra-stroke-gap [stroke]
   (defn append-point [stroke-arr new-tail]
     (let [dist (point-dist (last stroke-arr) new-tail)]
+      (if (> dist intra-max-dist)
+        (let [iter-pts (rest (concat (range 0 1 (/ intra-max-dist dist)) '(1)))
+              last-pt  (last stroke-arr)]
+          (reduce (fn [arr ptv] (conj arr (mix-pts last-pt (- 1 ptv) new-tail ptv))) stroke-arr iter-pts))
+        (conj stroke-arr new-tail))))
+  (loop [left-stroke (rest stroke)
+         last-point  (first stroke)
+         reslt-stroke [last-point]]
+    (if (zero? (count left-stroke))
+      reslt-stroke
+      (recur (rest left-stroke) (first left-stroke) (append-point reslt-stroke (first left-stroke))))))
+
+(defn fill-intra-index-stroke-gap [stroke]
+  (defn append-point [stroke-arr new-tail]
+    (let [dist (point-dist (rest (last stroke-arr)) (rest new-tail))]
       (if (> dist intra-max-dist)
         (let [iter-pts (rest (concat (range 0 1 (/ intra-max-dist dist)) '(1)))
               last-pt  (last stroke-arr)]
@@ -144,8 +159,8 @@
         y (+ (* (Math/sin beta-rad) first-arm) (* (Math/sin (- alpha-rad)) second-arm))]
     (list (* r (Math/cos theta-rad)) y (* r (Math/sin (- theta-rad))))))

-(def ^:dynamic *serial-conn* nil)
-(def dump-degrees false)
+(def ^:dynamic *serial-conn*)
+(def dump-degrees true)

 (defn set-count [cnt]
   (let [count-str (format "s=%d," cnt)]
@@ -195,7 +210,7 @@
         dense-strokes (map fill-intra-stroke-gap strokes)
         ;; gaps has one element than dense-strokes
         strokes-plus-gaps (concat (interleave (map (fn [x] (process-stroke x xscale yscale 6.0)) gaps)
-                                              (map (fn [x] (process-stroke x xscale yscale 3.9)) dense-strokes))
+                                              (map (fn [x] (process-stroke x xscale yscale 3.7)) dense-strokes))
                                   (list (process-stroke (last gaps) xscale yscale 6.0)))
         strokes-z (reduce concat strokes-plus-gaps)]
     (xyz2angles-list strokes-z)))
@@ -206,7 +221,8 @@
   (with-open [fout (io/writer "dump_degrees.h" :append true)]
     (.write fout (str (count angles-seq) "., "))
     (doseq [[a b c d] angles-seq]
-      (.write fout (format "%f, %f, %f, %f, " a b c d)))))
+      (.write fout (format "%f, %f, %f, %f, " a b c d)))
+    (.write fout "\n")))

 (defn augmented-strokes-to-angles [filename]
   (defn calc-z [point left right]
@@ -235,14 +251,14 @@
             xscale (:xscale stroke-data)
             yscale (:yscale stroke-data)
             joints (:joints stroke-data)
-            stroke-z (calc-stroke-z stroke joints)
+            dense-stroke (fill-intra-index-stroke-gap stroke)
+            stroke-z (calc-stroke-z dense-stroke joints)
             gaps (fill-inter-stroke-gap (list stroke-z))
-            dense-strokes (map fill-intra-stroke-gap (list stroke-z))
             strokes-plus-gaps (list
                                 (process-stroke (first gaps) xscale yscale 6.0)
-                                (process-stroke (first dense-strokes) xscale yscale nil)
+                                (process-stroke stroke-z xscale yscale nil)
                                 (process-stroke (second gaps) xscale yscale 6.0))]
-        (println (map cons (iterate inc 0) (second strokes-plus-gaps)))
+        (println dense-stroke)
         (dump-angles (xyz2angles-list (reduce concat strokes-plus-gaps)))))))

 (defn write-strokes [angles-seq]


fix write-text-file without file-format (#65)

--- src/clj/datasplash/core.clj
+++ src/clj/datasplash/core.clj
@@ -1113,15 +1113,18 @@
 (def text-writer-schema
   {:file-format {:docstr "Choose file format."
                  :action
-                 (fn [transform file-format] (.via transform
-                                              (Contextful/fn
-                                                (sfn
-                                                 (fn [x]
-                                                   (case file-format
-                                                     :json (json/encode x {})
-                                                     :edn (pr-str x)
-                                                     (file-format x)))))
-                                              (TextIO/sink)))}
+                 (fn [transform file-format]
+                   (if (= :default file-format)
+                     (.via transform (TextIO/sink))
+                     (.via transform
+                           (Contextful/fn
+                             (sfn
+                              (fn [x]
+                                (case file-format
+                                  :json (json/encode x {})
+                                  :edn (pr-str x)
+                                  (file-format x)))))
+                           (TextIO/sink))))}
    :compression-type {:docstr "Choose compression type."
                       :enum compression-type-enum
                       :action (select-enum-option-fn
@@ -1158,13 +1161,14 @@
 ```"
           base-schema text-writer-schema)
    :added "0.6.2"}
-  [to {:keys [dynamic? dynamic-fn] :as options} ^PCollection pcoll]
-  (let [[base-path filename ] (split-path to)
+  [to {:keys [dynamic? dynamic-fn file-format] :as options} ^PCollection pcoll]
+  (let [[base-path filename] (split-path to)
         opts (-> options
-                  (assoc :label (str "write-text-file-to-"
-                                     (clean-filename to))
-                         :coder nil)
-                  (cond-> filename (assoc :prefix filename)))]
+                 (assoc :label (str "write-text-file-to-"
+                                    (clean-filename to))
+                        :coder nil
+                        :file-format (or file-format :default))
+                 (cond-> filename (assoc :prefix filename)))]
     (apply-transform pcoll
                      (-> (if dynamic?
                            (-> (FileIO/writeDynamic)


dump threads automatically

dump threads automatically

--- src/clueweb_disqus/core.clj
+++ src/clueweb_disqus/core.clj
@@ -147,10 +147,14 @@
   [start-epoch body]
   (let [content-to-write (get body "response")
         filename-to-write (str disqus-jobs-dir start-epoch "-" writer-file-name)
-        stats-f-to-write (str disqus-jobs-dir start-epoch "-" stats-file-name)]
-    (do (with-open [wrtr (io/writer filename-to-write :append true)]
-          (doall (doseq [c content-to-write]
-                   (pprint c wrtr))))
+        stats-f-to-write (str disqus-jobs-dir start-epoch "-" stats-file-name)
+        threads-file (clojure.string/replace filename-to-write #".clj$" ".threads")]
+    (do (with-open [wrtr (io/writer filename-to-write :append true)
+                    threads-wrtr (io/writer threads-file :append true)]
+          (doall
+           (doseq [c content-to-write]
+             (pprint c wrtr)
+             (println (get c "id") threads-wrtr))))
         (if (.exists (java.io.File. stats-f-to-write))
           (let [cnt
                 (+ (read-string (slurp stats-f-to-write))


CMR-3223: Addressing code review comments

--- search-app/src/cmr/search/data/metadata_retrieval/metadata_transformer.clj
+++ search-app/src/cmr/search/data/metadata_retrieval/metadata_transformer.clj
@@ -139,20 +139,18 @@

 (defn transform-to-multiple-formats
   "Transforms the concept into multiple different formats. Returns a map of target format to metadata."
-  ([context concept target-formats]
-   (transform-to-multiple-formats context concept target-formats false))
-  ([context concept target-formats ignore-exceptions?]
-   (->> target-formats
-        (group-by #(transform-strategy concept %))
-        (keep (fn [[k v]]
-                (if ignore-exceptions?
-                  (try
-                    (transform-with-strategy context concept k v)
-                    (catch Exception e
-                      ;; Namespace used to reference error here to allow redefing in tests
-                      (log/error e "Ignoring exception while trying to transform metadata:" (.getMessage e))))
-                  (transform-with-strategy context concept k v))))
-        (reduce into {}))))
+  [context concept target-formats ignore-exceptions?]
+  (->> target-formats
+       (group-by #(transform-strategy concept %))
+       (keep (fn [[k v]]
+               (if ignore-exceptions?
+                 (try
+                   (transform-with-strategy context concept k v)
+                   (catch Exception e
+                     ;; Namespace used to reference error here to allow redefing in tests
+                     (log/error e "Ignoring exception while trying to transform metadata:" (.getMessage e))))
+                 (transform-with-strategy context concept k v))))
+       (reduce into {})))

 (defn transform
   "Transforms a concept to the target format given returning metadata."


CMR-3223: Adding logging of the concept id so we can track down the problematic collection.

--- search-app/src/cmr/search/data/metadata_retrieval/metadata_transformer.clj
+++ search-app/src/cmr/search/data/metadata_retrieval/metadata_transformer.clj
@@ -148,7 +148,9 @@
                    (transform-with-strategy context concept k v)
                    (catch Throwable e
                      ;; Namespace used to reference error here to allow redefing in tests
-                     (log/error e "Ignoring exception while trying to transform metadata:" (.getMessage e))))
+                     (log/error e "Ignoring exception while trying to transform metadata for concept"
+                                (:concept-id concept) "with revision" (:revision-id concept) "error:"
+                                (.getMessage e))))
                  (transform-with-strategy context concept k v))))
        (reduce into {})))


PLD: pass cursor through and use cond-> to avoid extra nils

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -29,11 +29,12 @@
 (defn get-extra-fields
   "Extra fields that will be displayed on the table."
   [is-filtered-dataview?]
-  (let [extra-field  [{:full-name _id :label "ID" :name _id :type
-                       "integer"}]]
-    (if is-filtered-dataview?
-      extra-field
-      (conj extra-field forms/submission-time-field))))
+  (let [id-field  [{:full-name _id
+                    :label "ID"
+                    :name _id
+                    :type "integer"}]]
+    (cond-> id-field
+      (not is-filtered-dataview?) (conj forms/submission-time-field))))

 (defn all-fields
   "Given a (flat-)form, returns fields for table display.
@@ -137,7 +138,8 @@
                   owner]
            :or {get-label? true}}]
   (let [has-hxl? (any? false? (map #(nil? (-> % :instance :hxl)) form))
-        columns (for [field (all-fields form :is-filtered-dataview?
+        columns (for [field (all-fields form
+                                        :is-filtered-dataview?
                                         is-filtered-dataview?)]
                   (let [{:keys [name type full-name]
                          {:keys [hxl]} :instance} field
@@ -154,9 +156,9 @@
                      :cssClass column-class
                      :minWidth 50
                      :hxl hxl}))]
-    (clj->js (conj columns
-                   (when-not hide-actions-column?
-                     (actions-column owner has-hxl?))))))
+    (clj->js (cond-> columns
+               (not hide-actions-column?)
+               (conj (actions-column owner has-hxl?))))))

 (defn init-sg-pager [grid dataview]
   (let [Pager (.. js/Slick -Controls -Pager)]
@@ -174,26 +176,6 @@
        :enableTextSelectionOnCells true
        :rowHeight 40
        :syncColumnCellResize false})
-
-(defn freeze-action-column!
-  "Fixes the first column on slick table on horizontal scroll"
-  []
-  (let [actions (.getElementsByClassName js/document "record-actions")
-        sg-viewport (first (.getElementsByClassName js/document
-                                                    "slick-viewport"))]
-    (doseq [action actions]
-      (let [leftOffset (js/parseInt (.-offsetLeft action))]
-        (.addEventListener sg-viewport "scroll"
-                           (fn []
-                             (let [sl (.-scrollLeft  sg-viewport)
-                                   set-border! #(set!
-                                                 (.-borderRight
-                                                  (.-style action)) %)]
-                               (if (zero? sl)
-                                 (set-border! "1px dotted #ededed")
-                                 (set-border! "1px solid silver"))
-                               (set! (.-left (.-style action))
-                                     (str (+ sl leftOffset) "px")))))))))

 (defn bind-external-sg-grid-event-handlers
   [grid event-handlers]
@@ -260,7 +242,6 @@
                     (when (= id data-id)
                       (put! shared/event-chan
                             {:submission-to-rank rank})))))
-
     ;; page, filter, and data set-up on the dataview
     (init-sg-pager grid dataview)
     (.setPagingOptions dataview
@@ -280,9 +261,12 @@
   (let [event-chan (shared/event-tap)]
     (go
       (while true
-        (let [e (<! event-chan)
-              {:keys [submission-to-rank submission-clicked submission-unclicked
-                      filter-by new-columns re-render]} e
+        (let [{:keys [submission-to-rank
+                      submission-clicked
+                      submission-unclicked
+                      filter-by
+                      new-columns
+                      re-render]} (<! event-chan)
               update-data! (partial om/update! app-state
                                     [:table-page :submission-clicked :data])
               get-submission-data (fn [field value]
@@ -323,7 +307,7 @@

 ;; OM COMPONENTS
 (defmethod label-changer :default
-  [_ owner]
+  [{{:keys [hide-actions-column?]} :table-page :as cursor} owner]
   (reify
     om/IInitState
     (init-state [_] {:name-or-label :label})
@@ -338,9 +322,7 @@
                             (flat-form->sg-columns
                              flat-form
                              :get-label? (= :label %)
-                             :hide-actions-column? (-> @shared/app-state
-                                                       :table-page
-                                                       :hide-actions-column?)
+                             :hide-actions-column? hide-actions-column?
                              :language new-language)})]
         (when (not= new-language language)
           (om/set-state! owner :language new-language)
@@ -376,18 +358,18 @@
               :on-change #(delayed-search (.-target %) :filter-by)}]])))

 (defmethod table-header :default
-  [app-state owner]
+  [cursor owner]
   (om/component
    (html
     [:div.topbar
      [:div {:id pager-id}]
-     (om/build label-changer nil)
-     (om/build table-search app-state)
+     (om/build label-changer cursor)
+     (om/build table-search cursor)
      [:div {:style {:clear "both"}}]])))

 (defn- init-grid!
+  "Initializes grid + dataview, and stores them in owner's state."
   [data owner slick-grid-event-handlers]
-  "Initializes grid + dataview, and stores them in owner's state."
   (when (seq data)
     (let [{:keys [flat-form is-filtered-dataview?]} (om/get-shared owner)
           current-language (:current
@@ -424,7 +406,7 @@
     (om/set-state! owner :resize-handler resize-handler)))

 (defmethod table-page :default
-  [{{:keys [active]} :views :as app-state}
+  [{{:keys [active]} :views :as cursor}
    owner
    {:keys [slick-grid-event-handlers] :as opts}]
   "Om component for the table grid.
@@ -459,10 +441,10 @@
         (let [{:keys [data dataset-info]
                {:keys [prevent-scrolling-in-table-view? submission-clicked]}
                :table-page}
-              app-state
+              cursor
               {:keys [num_of_submissions]} dataset-info
               no-data? (empty? data)
-              with-info #(merge % {:dataset-info dataset-info})]
+              with-info #(merge cursor %)]
           (when active?
             (html
              [:div.table-view
@@ -476,7 +458,7 @@
                           {:opts (merge
                                   (select-keys opts #{:delete-record! :role})
                                   {:view :table})}))
-              (om/build table-header app-state)
+              (om/build table-header cursor)
               [:div.slickgrid {:id table-id}
                (if (and no-data? (zero? num_of_submissions))
                  [:p.alert.alert-warning "No data"]
@@ -486,10 +468,10 @@
       (did-mount [_]
         (when active?
           (set-window-resize-handler owner)
-          (let [data (get-in app-state [:data])]
+          (let [data (get-in cursor [:data])]
             (when-let [[grid dataview]
                        (init-grid! data owner slick-grid-event-handlers)]
-              (handle-table-events app-state grid dataview)))))
+              (handle-table-events cursor grid dataview)))))
       om/IWillUnmount
       (will-unmount [_]
         (.removeEventListener js/window
@@ -508,7 +490,7 @@
                            (init-grid! new-data
                                        owner
                                        slick-grid-event-handlers)]
-                  (handle-table-events app-state grid dataview))
+                  (handle-table-events cursor grid dataview))
                 (do ; data has changed
                   (.invalidateAllRows grid)
                   (.setItems dataview (clj->js new-data) _id)


Added helper a couple of functions

Added helper a couple of functions

- add-element: adds an element to a vector
- remove-element: removes an element from a vector
- update-data-to-be-deleted-vector: updates a vector whose name is data-to-be-deleted by either adding or removing and element
- get-elements-count-by-selector: gets a dom element based on a selector
- check-select-unselect-all-records-element?: checks if select-unselect-all-records element should be checked
- get-checkbox-selector: get selector based of data attribute and an id
- get-delete-checkbox-by-data-id: get checkbox based on an id
- select-rows-marked-to-be-deleted: select checkboxes marked to be deleted
- higlight-rows-marked-to-be-deleted: highlight rows marked to be deleted

--- src/hatti/views/table.cljs
+++ src/hatti/views/table.cljs
@@ -197,6 +197,72 @@
          :let [handler-name (hyphen->camel-case (name handler-key))
                event (aget dataview handler-name)]]
      (.subscribe event handler-function))))
+
+(defn add-element
+  [vector value]
+  (-> vector
+      (conj (int value))
+      set
+      vec))
+
+(defn remove-element
+  [vector value]
+  (vec (remove (fn [id] (= id value))
+               vector)))
+
+(defn update-data-to-be-deleted-vector
+  [checked? data-id]
+  (let [{:keys [data-to-be-deleted]} @shared/app-state
+        fn (if checked? add-element remove-element)]
+    (transact! shared/app-state
+               [:data-to-be-deleted]
+               #(fn data-to-be-deleted data-id))))
+
+(defn get-elements-count-by-selector
+  [selector]
+  (.. js/document (querySelectorAll selector) -length))
+
+(defn check-select-unselect-all-records-element?
+  []
+  (let [delete-record-class-selector (str "." delete-record-class)
+        total-rows-count (get-elements-count-by-selector
+                          delete-record-class-selector)
+        ; TODO: test using (:data-to-be-deleted @shared/app-state)
+        selected-rows-count (get-elements-count-by-selector
+                             (str delete-record-class-selector ":checked"))]
+    (if (= selected-rows-count total-rows-count) true false)))
+
+(defn get-checkbox-selector
+  [data-id]
+  (str "." delete-record-class "[data-id=\"" data-id "\"]"))
+
+(defn get-delete-checkbox-by-data-id
+  [data-id]
+  (let [selector (get-checkbox-selector data-id)]
+    (.querySelector js/document selector)))
+
+(defn select-rows-marked-to-be-deleted
+  []
+  (doseq [data-id (:data-to-be-deleted @shared/app-state)]
+    (let
+     [element (get-delete-checkbox-by-data-id data-id)]
+      (set! (.-checked element) true))))
+
+(defn higlight-rows-marked-to-be-deleted
+  [grid]
+  (let [checkboxes (.getElementsByClassName js/document delete-record-class)
+        indexes (range (.-length checkboxes))
+        indexes-of-selected-checkboxes (->> (map-indexed
+                                             (fn [index checkbox]
+                                               (when (.-checked checkbox)
+                                                 index))
+                                             checkboxes)
+                                            (remove nil?)
+                                            vec)]
+    (transact! shared/app-state
+               [:selected-table-rows]
+               #(identity indexes-of-selected-checkboxes))
+    (.setSelectedRows grid (clj->js indexes-of-selected-checkboxes))))

 (defn sg-init
   "Creates a Slick.Grid backed by Slick.Data.DataView from data and fields.


Fix arity of interop call

Fix arity of interop call

--- src/main/resources/archetype-resources/src/main/clojure/interop/Sample.clj
+++ src/main/resources/archetype-resources/src/main/clojure/interop/Sample.clj
@@ -1,5 +1,5 @@
 (ns interop.Sample
   (:gen-class))

-(defn -main []
+(defn -main [& _]
   (throw (UnsupportedOperationException. "Not yet implemented")))


add todo.

add todo.

--- src/pepa/model.clj
+++ src/pepa/model.clj
@@ -452,6 +452,7 @@
                                   WHERE dt.state_seq > ?" seq-num])
                    (mapv :id))
    ;; Special case: Also send down used tags
+   ;; TODO: We return a wrong count of tags here.
    :tags (->> (db/query db ["SELECT t.name, COUNT(dt.document)
                              FROM tags AS t
                              JOIN document_tags AS dt ON t.id = dt.tag


Added with-rest-key, renamed with-master

--- src/pundit/api.clj
+++ src/pundit/api.clj
@@ -13,8 +13,12 @@
 (defmacro with-auth [auth & body]
   `(binding [*auth* ~auth] ~@body))

-(defmacro with-master [& body]
+(defmacro with-master-key [& body]
   `(binding [*auth* (assoc *auth* :use-master true)]
+     ~@body))
+
+(defmacro with-rest-key [& body]
+  `(binding [*auth* (assoc *auth* :use-master false)]
      ~@body))

 (defmacro with-token [token & body]


Remove shutdown-agents - no need for it anymore

--- src/reply/core.clj
+++ src/reply/core.clj
@@ -52,8 +52,5 @@
   (repl :read jline-read
         :prompt (constantly ""))

-  (.flush (.getHistory jline-reader))
+  (.flush (.getHistory jline-reader)))

-  (shutdown-agents))
-
-


cleanup, comments

cleanup, comments

--- src/cljs/core.cljs
+++ src/cljs/core.cljs
@@ -8,10 +8,13 @@

 ;;;; Main file of the inspect tool written in ClojureScript

-(defn by-id [id] (.getElementById js/document id))
+(defn by-id
+  "helper function for selecting DOM elements"
+  [id]
+  (.getElementById js/document id))

 (defn get-next-items
-  ""
+  "send command to server to subscribe to the next events"
   []
   (let [next-items (into {} (map (fn [i] [i (:next-n @appstate/app)]) @appstate/selected-event-types))]
     (print next-items)
@@ -29,18 +32,30 @@
     (swap! selected disj t)
     (swap! selected conj t)))

-(defn select-btn [t selected]
-  (let [active (if (active? selected t) "btn-primary btn-sm" "")]
-    [:button.btn {:class active :on-click #(toggle-selected selected t)} (str t)]))
+(defn select-btn
+  "creates toggle button in group for selecting shown event types"
+  [t selected]
+  (let [active (if (active? selected t) "btn-primary" "")]
+    [:button.btn.btn-sm {:class active :on-click #(toggle-selected selected t)} (str t)]))

-(defn known-types [types selected]
+(defn known-types
+  "creates button group for all known event types"
+  [types selected]
   [:div.btn-group
-   (for [t types]
-     [select-btn t selected])
+   (for [t types] [select-btn t selected])
    [:br]])

+(defn subscribed-selected
+  "creates table with the current subscriptions"
+  [client-map]
+  [:div
+   [:table (for [[origin n] @client-map]
+             [:tr
+              [:td (str origin)]
+              [:td n]])]])
+
 (defn event-div
-  ""
+  "creates div with the event (header, timestamp, pre code) when type currently selected"
   [item selected]
   (let [origin (:origin item)]
     (when (active? selected origin)
@@ -50,19 +65,16 @@
        [:pre [:code (:payload item)]]
        [:br]])))

-(defn subscribed-selected [client-map]
-  [:div
-   [:table (for [[origin n] @client-map]
-             [:tr
-              [:td (str origin)]
-              [:td n]])]])
-
-(defn lister [items selected]
+(defn lister
+  "list view for events"
+  [items selected]
   [:div
    (for [item items]
      [event-div item selected])])

-(defn inspect-view []
+(defn inspect-view
+  "creates main view of the application"
+  []
   [:div
    [known-types @appstate/known-event-types appstate/selected-event-types]
    [:br]


Increased max number needed to treat from 1000 to 2000.

Starting to tinker with the layouts to bring them more into line with IOS
design guidelines. (Old state of affairs was closer to Android Material Design style).

This is ito avoid app store rejections due to UI.

--- src/unspun/db.cljs
+++ src/unspun/db.cljs
@@ -11,7 +11,7 @@

 (def flash-error-time 5000)                                 ; duration (ms) of flash error messages

-(def max-nn 1000)                                           ; maximum number needed to treat
+(def max-nn 2000)                                           ; maximum number needed to treat

 (def max-id-length 100)                                     ; maximum length of a csv column id


WitRD now correctly addresses the Corporation. The :player :corp key was in the wrong position.

--- src/clj/game/cards-resources.clj
+++ src/clj/game/cards-resources.clj
@@ -618,9 +618,10 @@
    "Woman in the Red Dress"
    {:events {:runner-turn-begins
              {:msg (msg "reveal " (:title (first (:deck corp))) " on the top of R&D")
-              :optional {:prompt (msg "Draw " (:title (first (:deck corp))) "?")
+              :optional {:player :corp
+                         :prompt (msg "Draw " (:title (first (:deck corp))) "?")
                          :msg (msg "draw " (:title (first (:deck corp))))
-                         :yes-ability {:effect :player :corp (effect (draw))}
+                         :yes-ability {:effect (effect (draw))}
                          :no-ability {:effect (effect (system-msg "doesn't draw with Woman in the Red Dress"))}}}}}

    "Wyldside"


add ddos test

add ddos test

--- src/clj/test/cards-resources.clj
+++ src/clj/test/cards-resources.clj
@@ -214,3 +214,30 @@
       (is (= 2 (get (refresh hive) :counter 0)) "Hivemind gained 1 counter")
       (is (= 0 (get (refresh vbg) :counter 0)) "Virus Breeding Ground lost 1 counter"))))

+(deftest ddos
+  "Prevent rezzing of outermost ice for the rest of the turn"
+  (do-game
+    (new-game (default-corp [(qty "Ice Wall" 3)]) (default-runner [(qty "DDoS" 1)]))
+    (play-from-hand state :corp "Ice Wall" "HQ")
+    (play-from-hand state :corp "Ice Wall" "HQ")
+    (take-credits state :corp)
+    (play-from-hand state :runner "DDoS")
+    (let [ddos (get-in @state [:runner :rig :resource 0])
+          iwall (get-in @state [:corp :servers :hq :ices 0])]
+      (card-ability state :runner ddos 0)
+      (is (= (:title ddos) (get-in @state [:runner :discard 0 :title]) ))
+      (core/click-run state :runner {:server "HQ"})
+      (core/rez state :corp iwall)
+      (is (not (get-in (refresh iwall) [:rezzed])))
+      (core/end-run state :runner)
+      (core/click-run state :runner {:server "HQ"})
+      (core/rez state :corp iwall)
+      (is (not (get-in (refresh iwall) [:rezzed])))
+      (core/end-run state :runner)
+      (take-credits state :runner)
+      (take-credits state :corp)
+      (core/click-run state :runner {:server "HQ"})
+      (core/rez state :corp iwall)
+      (is (get-in (refresh iwall) [:rezzed]))
+      )))
+


Use a list of uis to draw the game

Use a list of uis to draw the game

--- src/cljs/caves_of_cljs/core.cljs
+++ src/cljs/caves_of_cljs/core.cljs
@@ -30,15 +30,33 @@
       (swap! app-state dissoc :game)
       (recur))))

-(defn draw-ui [display]
-  (.drawText display 0 0 "Welcome to the Caves of Clojure!")
-  (.drawText display 0 1 "Press any key to exit..."))
+(defmulti draw-ui
+  (fn [ui game screen]
+    (:kind ui)))
+
+(defmethod draw-ui :start [ui game screen]
+  (.drawText screen 0 0 "Welcome to the Caves of Clojure!")
+  (.drawText screen 0 1 "Press enter to win, anything else to lose."))
+
+(defmethod draw-ui :win [ui game screen]
+  (.drawText screen 0 0 "Congratulations, you win!")
+  (.drawText screen 0 1 "Press escape to exit, anything else to restart."))
+
+(defmethod draw-ui :lose [ui game screen]
+  (.drawText screen 0 0 "Sorry, better luck next time.")
+  (.drawText screen 0 1 "Press escape to exit, anything else to go."))
+
+(defn draw-game [game screen]
+  (.clear screen)
+  (doseq [ui (:uis game)]
+    (draw-ui ui game screen)))
+

 (defn game-loop []
-  (when-let [display (:screen @app-state)]
-    (let [game (:game @app-state)]
-      (.clear display)
-      (draw-ui display)))
+  (when-let [screen (:screen @app-state)]
+    (let [input (:input @app-state)
+          game (:game @app-state)]
+      (draw-game game screen)))
   (.requestAnimationFrame js/window #(game-loop)))

 (defn init-game! []
@@ -65,7 +83,7 @@
 (defn home-page [state]
   [:div [:h2 "Caves of Clojurescript"]
    [:div [:a {:href "#/about"} "go to the about page"]]
-   (when (:game @state)
+   (when-not (empty? (:uis (:game @state)))
      [canvas state])])

 (defn about-page []
@@ -93,7 +111,7 @@
 (secretary/defroute "/" []
   (swap! app-state assoc
          :current-page :home
-         :game {}))
+         :game {:uis [{:kind :start}]}))

 (secretary/defroute "/about" []
   (swap! app-state assoc :current-page :about))


refactoring

refactoring

--- src/cljs/salava/badge/ui/my.cljs
+++ src/cljs/salava/badge/ui/my.cljs
@@ -10,7 +10,6 @@
     [salava.core.ui.notactivated :refer [not-activated-banner]]
     [salava.core.ui.layout :as layout]
     [salava.core.ui.grid :as g]
-    [salava.badge.ui.settings :as s]
     [salava.badge.ui.helper :as bh]
     [salava.core.helper :refer [dump]]
     ;[salava.extra.application.ui.helper :refer [application-plugin?]]


Fix bug

Fix bug

--- src/clojournal/routes/author.clj
+++ src/clojournal/routes/author.clj
@@ -17,7 +17,7 @@

 (defn post-article [author-id title content tags]
   (let [tags' (clojure.string/split tags #"\s*,\s*")]
-    (assert (some empty? tags'))
+    (assert (not-any? empty? tags'))
     (article/add-article! :title title :content content :author author-id :tags tags')
     (response/redirect "/author")))


trying to work out what is going on

trying to work out what is going on

--- src/clojure/staircase/assets.clj
+++ src/clojure/staircase/assets.clj
@@ -1,5 +1,6 @@
 (ns staircase.assets
   (:import org.lesscss.LessCompiler
+           org.mozilla.classfile.ClassFileWriter
            [java.util Date])
   (:require [dieter.settings :as settings]
             [ring.util.time  :as ring-time]
@@ -12,7 +13,11 @@

 (def less-c (LessCompiler. ["--relative-urls"]))

-(defn less [f] (.compile less-c f))
+(defn less [f]
+  (let [pdm (.getProtectionDomain ClassFileWriter)
+        src (.getCodeSource pdm)]
+    (info "Rhino is loaded from" src))
+  (.compile less-c f))

 (defn ext
   [f]


Add insert-all for inserting seqs of facts.

--- src/main/clojure/clara/rules.clj
+++ src/main/clojure/clara/rules.clj
@@ -13,6 +13,12 @@
    session, but returns a new session with the facts added."
   [session & facts]
   (eng/insert session facts))
+
+(defn insert-all
+  "Inserts a sequence of facts into a working session. It does not modify the given
+   session, but returns a new session with the facts added."
+  [session fact-seq]
+  (eng/insert session fact-seq))

 (defn retract
   "Retracts a fact from a working session. It does not modify the given session,


actually invalidate macros properly

actually invalidate macros properly

dependency discovery was performed too early so it only worked
if the macro had already been loaded by other means.

fixes #495

--- src/main/shadow/build/macros.clj
+++ src/main/shadow/build/macros.clj
@@ -93,11 +93,6 @@
             ;; reloading is handled somewhere else
             (when-not (contains? @active-macros-ref macro-ns)

-              ;; activate even if the require fails
-              ;; so they are reloaded on change
-              (let [clj-deps (find-all-clj-references macro-ns)]
-                (swap! active-macros-ref assoc macro-ns clj-deps))
-
               (try
                 (require macro-ns)
                 (catch Exception e
@@ -106,7 +101,12 @@
                            {:tag ::macro-load
                             :macro-ns macro-ns
                             :ns-info ns-info}
-                           e))))))))
+                           e))))
+
+              ;; need to do this after the actual require since otherwise no deps can be discovered
+              (let [clj-deps (find-all-clj-references macro-ns)]
+                (swap! active-macros-ref assoc macro-ns clj-deps))
+              ))))

       (if (contains? macro-namespaces name)
         (let [macros (find-macros-in-ns name)]


Make schemas public on images service.

Make schemas public on images service.

--- src/uxbox/services/images.clj
+++ src/uxbox/services/images.clj
@@ -9,11 +9,14 @@
   (:require [suricatta.core :as sc]
             [clj-uuid :as uuid]
             [buddy.core.codecs :as codecs]
+            [storages.core :as st]
             [uxbox.config :as ucfg]
             [uxbox.schema :as us]
+            [uxbox.media :as md]
             [uxbox.sql :as sql]
             [uxbox.util.transit :as t]
-            [uxbox.services.core :as usc])
+            [uxbox.services.core :as usc]
+            [uxbox.util.data :as data])
   (:import ratpack.form.UploadedFile
            org.apache.commons.io.FilenameUtils))

@@ -28,9 +31,9 @@
                                            :user user
                                            :name name})]
     (-> (sc/fetch-one conn sqlv)
-        (usc/normalize-attrs))))
+        (data/normalize-attrs))))

-(def ^:private create-collection-scheme
+(def create-collection-scheme
   {:id [us/uuid]
    :user [us/required us/uuid]
    :name [us/required us/string]})
@@ -49,10 +52,9 @@
                                            :name name
                                            :version version})]
     (some-> (sc/fetch-one conn sqlv)
-            (usc/normalize-attrs)
-            (decode-data))))
+            (data/normalize-attrs))))

-(def ^:private update-collection-scheme
+(def update-collection-scheme
   (assoc create-collection-scheme
          :version [us/required us/integer]))

@@ -67,7 +69,7 @@
   [conn user]
   (let [sqlv (sql/get-image-collections {:user user})]
     (->> (sc/fetch conn sqlv)
-         (map usc/normalize-attrs))))
+         (map data/normalize-attrs))))

 (defmethod usc/-query :list/image-collections
   [conn {:keys [user] :as params}]
@@ -75,7 +77,7 @@

 ;; --- Delete Collection

-(def ^:private delete-collection-schema
+(def  delete-collection-schema
   {:id [us/required us/uuid]
    :user [us/required us/uuid]})

@@ -95,16 +97,16 @@
   [conn {:keys [id user file collection]}]
   (let [id (or id (uuid/v4))
         filename (.getFileName ^UploadedFile file)
-        ext (FilenameUtils/getExtension oname)
-        path @(st/save (str id "." ext) file)
+        ext (FilenameUtils/getExtension filename)
+        path @(st/save md/storage (str id "." ext) file)
         sqlv (sql/create-image {:id id
                                 :path path
                                 :collection collection
                                 :user user})]
     (some-> (sc/fetch-one conn sqlv)
-            (usc/normalize-attrs))))
+            (data/normalize-attrs))))

-(def ^:private create-image-schema
+(def create-image-schema
   {:id [us/uuid]
    :user [us/required us/uuid]
    :file [us/required us/uploaded-file]})
@@ -120,9 +122,9 @@
   [conn {:keys [id name version]}]
   (let [sqlv (sql/update-image {:id id :name name :version version})]
     (some-> (sc/fetch-one conn sqlv)
-            (usc/normalize-attrs))))
+            (data/normalize-attrs))))

-(def ^:private update-image-schema
+(def update-image-schema
   {:id [us/uuid]
    :user [us/required us/uuid]
    :file [us/required us/uploaded-file]})
@@ -139,7 +141,7 @@
   (let [sqlv (sql/delete-image {:id id :user user})]
     (pos? (sc/execute conn sqlv))))

-(def ^:private delete-image-schema
+(def delete-image-schema
   {:id [us/uuid]
    :user [us/required us/uuid]})


Make type-of-completion work with unbound Vars

--- src/de/kotka/vimclojure/util.clj
+++ src/de/kotka/vimclojure/util.clj
@@ -232,11 +232,14 @@
     (instance? clojure.lang.Namespace thing) "n"
     (class? thing)        "c"
     (:macro (meta thing)) "m"
-    :else                 (let [value (var-get thing)]
-                            (cond
-                              (instance? clojure.lang.MultiFn value) "f"
-                              (fn? value) "f"
-                              :else       "v"))))
+    :else                 (try
+                            (let [value (var-get thing)]
+                              (cond
+                                (instance? clojure.lang.MultiFn value) "f"
+                                (fn? value) "f"
+                                :else       "v"))
+                            (catch IllegalStateException _
+                              "v"))))

 (defn make-completion-item
   "Create a completion item for Vim's popup-menu."


cassandra: fix - only update value if it exists in the record

--- src/er_cassandra/model/types.clj
+++ src/er_cassandra/model/types.clj
@@ -471,4 +471,6 @@
   "a callback which updates a column with a function"
   [col f]
   (fn [r]
-    (update r col f)))
+    (if (contains? r col)
+      (update r col f)
+      r)))


First transformation working

First transformation working

- injecting a <base> element as the first element under <head> to ensure
  relative links use wikipedia resources (mainly CSS)

--- src/mickopedia/mickify.clj
+++ src/mickopedia/mickify.clj
@@ -10,6 +10,7 @@
   transformations and return a reconstituted html page."
   [nodes]
   (-> nodes
+      (html/transform [:head] (html/prepend (html/html [:base {:href "http://en.wikipedia.org"}])))
       html/emit*
       (->> (apply str))))

@@ -23,8 +24,9 @@
                 {"User-Agent"
                  "Mickifier/0.2 mickopedia.org mickopedia@gmail.com"}})
    :body
-   html/html-snippet
-   transform))
+   html/html-snippet))

 (defn mickify [in]
-  (parse-wikipedia-page (str *wikipedia-search-url* in)))
+  (-> (str *wikipedia-search-url* in)
+      parse-wikipedia-page
+      transform))


RealBlockVector now implements Monoid protocol.

--- src/clojure/uncomplicate/neanderthal/impl/buffer_block.clj
+++ src/clojure/uncomplicate/neanderthal/impl/buffer_block.clj
@@ -5,7 +5,7 @@
              [bytes :refer [direct-buffer byte-seq slice-buffer]]
              [structs :refer [float64 float32 wrap-byte-seq]]]
             [uncomplicate.fluokitten.protocols
-             :refer [PseudoFunctor Foldable Magma fmap!]]
+             :refer [PseudoFunctor Foldable Magma Monoid]]
             [uncomplicate.neanderthal
              [protocols :refer :all]
              [core :refer [transfer! copy! dim mrows ncols create-raw]]]
@@ -689,6 +689,9 @@
     (create-vector fact n (.createDataSource accessor n) nil))
   (zero [this]
     (raw this))
+  Monoid
+  (id [x]
+    (create-vector fact 0 (.createDataSource accessor 0) nil))
   EngineProvider
   (engine [_]
     eng)


Switched ld, sd, and fd order in RealGeneralmatrix constructor.

--- src/clojure/uncomplicate/neanderthal/impl/buffer_block.clj
+++ src/clojure/uncomplicate/neanderthal/impl/buffer_block.clj
@@ -270,7 +270,7 @@
                             ^RealBufferAccessor accessor ^BLAS eng
                             ^Class entry-type ^Boolean master
                             ^ByteBuffer buf ^long m ^long n
-                            ^long fd ^long sd ^long ld ^long ord ^long tra]
+                            ^long ld ^long sd ^long fd ^long ord ^long tra]
   Object
   (hashCode [this]
     (matrix-fold this hash* (-> (hash :RealGeneralMatrix) (hash-combine m) (hash-combine n)
@@ -427,8 +427,8 @@
     ([fact master buf m n ld ord tra]
      (let [columnar (columnar? ord tra)
            sd (long (if columnar m n))
+           ld (max sd (long ld))
            fd (long (if columnar n m))
-           ld (max sd (long ld))
            accessor (data-accessor fact)]
        (RealGeneralMatrix. (if columnar column-index row-index)
                            (if (= ld sd) init-all init-slice)
@@ -436,7 +436,7 @@
                            (if columnar cross-cut straight-cut)
                            fact accessor (matrix-engine fact)
                            (.entryType accessor) master
-                           buf m n fd sd ld ord tra)))
+                           buf m n ld sd fd ord tra)))
     ([fact m n ord tra]
      (let-release [buf (.createDataSource (data-accessor fact) (* (long m) (long n)))]
        (real-ge-matrix fact true buf m n 0 ord tra)))


util/s3.clj: added put/get for strings/streams

--- src/org/altlaw/util/s3.clj
+++ src/org/altlaw/util/s3.clj
@@ -1,7 +1,11 @@
 (ns org.altlaw.util.s3
+  (:require [org.altlaw.util.zip :as zip])
   (:import (org.jets3t.service.impl.rest.httpclient RestS3Service)
            (org.jets3t.service.model S3Bucket S3Object)
-           (org.jets3t.service.security AWSCredentials)))
+           (org.jets3t.service.security AWSCredentials)
+           (org.apache.commons.io IOUtils)
+           (java.io ByteArrayInputStream)
+           (java.util.zip GZIPInputStream)))

 (def #^{:private true} get-s3
      (memoize (fn [] (RestS3Service.
@@ -25,7 +29,7 @@
   "Returns a list of symbols.  Each symbol has a name matching a
   bucket name, and metadata matching that bucket's S3 metadata."
   []
-  (map make-object-symbol
+  (map make-bucket-symbol
        (.listAllBuckets (get-s3))))

 (defn list-objects
@@ -33,6 +37,9 @@
      (.listObjects (get-s3) (get-bucket bucket-name)))
   ([bucket-name prefix]
      (.listObjects (get-s3) (get-bucket bucket-name) nil)))
+
+(defn delete-object [bucket-name object-key]
+  (.deleteObject (get-s3) bucket-name object-key))

 (defn get-object [bucket-name object-key]
   (.getObject (get-s3) (get-bucket bucket-name) object-key))
@@ -43,4 +50,36 @@
                                object-key))))

 (defn get-object-stream [bucket-name object-key]
-  (.getDataInputStream (get-object bucket-name object-key)))
+  (let [object (get-object bucket-name object-key)
+        input (.getDataInputStream object)]
+    (if (= (.getContentEncoding object) "gzip")
+      (GZIPInputStream. input)
+      input)))
+
+(defn get-object-string [bucket-name object-key]
+  (IOUtils/toString (get-object-stream bucket-name object-key)
+                    "UTF-8"))
+
+(defn put-object-stream [bucket-name object-key stream metadata]
+  (let [bucket (get-bucket bucket-name)
+        object (S3Object. bucket object-key)]
+    (.addAllMetadata object metadata)
+    (.setDataInputStream object stream)
+    (.putObject (get-s3) bucket object)))
+
+(defn put-object-string [bucket-name object-key data-string metadata]
+  (let [bucket (get-bucket bucket-name)
+        object (S3Object. bucket object-key data-string)]
+    (.addAllMetadata object metadata)
+    (.putObject (get-s3) bucket object)))
+
+(defn put-object-gzip-string
+  [bucket-name object-key data-string metadata]
+  (let [bucket (get-bucket bucket-name)
+        object (S3Object. bucket object-key)
+        bytes (zip/gzip-utf8-string data-string)]
+    (.addAllMetadata object metadata)
+    (.setContentEncoding object "gzip")
+    (.setContentLength object (count bytes))
+    (.setDataInputStream object (ByteArrayInputStream. bytes))
+    (.putObject (get-s3) bucket object)))


cleanup

cleanup

--- src/overtone/core/ugen.clj
+++ src/overtone/core/ugen.clj
@@ -1,5 +1,5 @@
 (ns
-  #^{:doc "UGens, or Unit Generators, are the functions that act as DSP nodes in the synthesizer definitions used by SuperCollider.  We generate most of the UGen functions for clojure based on metadata about each ugen, and eventually we hope to get this information dynamically from the server itself."
+  #^{:doc "UGens, or Unit Generators, are the functions that act as DSP nodes in the synthesizer definitions used by SuperCollider.  We generate the UGen functions based on hand written metadata about each ugen (ugen directory). (Eventually we hope to get this information dynamically from the server.)"
      :author "Jeff Rose & Christophe McKeon"}
   overtone.core.ugen
   (:refer-clojure :exclude (deftype))


Add view showing all usage; add separate usage-view; private fn

--- src/discuss/references.cljs
+++ src/discuss/references.cljs
@@ -8,17 +8,23 @@
             [discuss.sidebar :as sidebar]
             [discuss.utils.common :as lib]))

+(defn- get-reference-usages-from-app-state
+  "Return list of reference usages, which were previously stored in the app-state.
+   TODO: optimize"
+  []
+  (get-in @lib/app-state [:common :reference-usages]))
+
 (defn reference-usage-handler
-  "Handler to process information about the reference."
+  "Handler to process information about the reference. Store results and change view."
   [response]
   (let [res (com/success-handler response)]
-    (println res)))
+    (lib/update-state-item! :common :reference-usages (fn [_] res))
+    (lib/change-view! :reference-usages)))

 (defn query-reference-details
   "Show usages of the provided reference."
   [reference-id]
   (let [url (str (:base config/api) (get-in config/api [:get :reference-usages]) "/" reference-id)]
-    (println "OMG I am here!")
     (com/ajax-get url {} reference-usage-handler)))

@@ -27,7 +33,6 @@
   "When clicking on a reference directly in the text, interact with the user to give her the choice of what
    her next steps might be."
   [reference]
-  #_(com/ajax-get (:url reference))
   (lib/change-view! :reference-dialog)
   (lib/save-selected-reference! reference)
   (sidebar/show)
@@ -49,9 +54,29 @@
                (dom/button #js {:className "btn btn-primary"}
                            "Create new Statement with this reference")))))

+(defn usage-view
+  "List single usages of reference."
+  [data _owner]
+  (reify om/IRender
+    (render [_]
+      (let [reference (:reference data)
+            issue (:issue data)
+            statement (:statement data)
+            author (:author data)]
+        (dom/div #js {:className "bs-callout bs-callout-info"}
+                 (dom/a #js {:href    "javascript:void(0)"
+                             :onClick #(com/ajax-get (:url statement))}
+                        (dom/strong nil (:text statement)))
+                 (dom/div nil "Issue: " (:title issue))
+                 (dom/div nil "Author: " (:nickname author)))))))
+
 (defn usages-view
   "List with details showing the usages of the given reference."
   []
   (reify om/IRender
     (render [_]
-      (dom/h4 nil "foo"))))+      (let [usages (get-reference-usages-from-app-state)]
+        (dom/div nil
+                 (dom/h6 nil (str "Received " (count usages) " usage(s)."))
+                 (apply dom/div nil
+                        (map #(om/build usage-view (lib/merge-react-key %)) usages)))))))


Use bootstraped fns

Use bootstraped fns

--- src/discuss/references.cljs
+++ src/discuss/references.cljs
@@ -6,6 +6,7 @@
             [discuss.communication :as com]
             [discuss.config :as config]
             [discuss.sidebar :as sidebar]
+            [discuss.utils.bootstrap :as bs]
             [discuss.utils.common :as lib]
             [discuss.utils.views :as vlib]))

@@ -48,12 +49,11 @@
   (reify om/IRender
     (render [_]
       (dom/div #js {:className "text-center"}
-               (dom/button #js {:className "btn btn-primary"
-                                :onClick   #(query-reference-details (:id (lib/selected-reference)))}
-                           "Find usages of this reference")
+               (bs/button-primary #(query-reference-details (:id (lib/selected-reference)))
+                                  "Find usages of this reference")
                " "
-               (dom/button #js {:className "btn btn-primary"}
-                           "Create new Statement with this reference")))))
+               (bs/button-primary nil
+                                  "Create new Statement with this reference")))))

 (defn usage-view
   "List single usages of reference."
@@ -66,7 +66,7 @@
             author (:author data)]
         (dom/div #js {:className "bs-callout bs-callout-info"}
                  (dom/a #js {:href    "javascript:void(0)"
-                             :onClick #(com/ajax-get-and-change-view (:url statement) :default)}
+                             :onClick #(lib/change-view! :reference-agree-disagree)}
                         (dom/strong nil (:text statement)))
                  (dom/div nil "Issue: " (:title issue))
                  (dom/div nil "Author: " (:nickname author)))))))
@@ -96,10 +96,10 @@
                         "Do you agree or disagree with this statement?")
                (om/build usage-view {})
                (dom/div #js {:className "text-center"}
-                        (dom/button #js {:className "btn btn-primary"}
-                                    (vlib/fa-icon "fa-thumbs-up")
-                                    " Agree")
+                        (bs/button-primary #(println "foo")
+                                           (vlib/fa-icon "fa-thumbs-up")
+                                           " Agree")
                         " "
-                        (dom/button #js {:className "btn btn-primary"}
-                                    (vlib/fa-icon "fa-thumbs-down")
-                                    " Disagree"))))))
+                        (bs/button-primary nil
+                                           (vlib/fa-icon "fa-thumbs-down")
+                                           " Disagree"))))))


port binding now working

port binding now working

--- src/dokkaa_builder/apps.clj
+++ src/dokkaa_builder/apps.clj
@@ -13,10 +13,10 @@
   (docker/make-client "127.0.0.1:4243"))

 (defn generate-host-port [host]
-  (+ 10000 (rand 1000)))
+  (+ 10000 (rand-int 1000)))

 (defn port-binding [host-port container-port]
-  (str host-port ":" container-port))
+  {(str container-port "/tcp") [{"HostPort" (str host-port)}]})

 (defn app->id [app-name user]
   (get-in @apps [(keyword app-name) :instances 0 :id]))
@@ -24,8 +24,8 @@
 (defn create [app-name user image & {:keys [tag command port]}]
   (let [app-name (keyword app-name)
         cli (choose-client)
-        port-bindings [(port-binding (generate-host-port (.host cli))
-                                     port)]]
+        host-port (generate-host-port (.host cli))
+        port-bindings (port-binding host-port port)]
     (if (nil? (app-name @apps))
       (let [id (docker/run cli image :tag tag
                                      :cmd command
@@ -33,7 +33,7 @@
             host (urly/url-like (str "http://" (.host cli)))
             domain (str (name app-name) "." (config/domain-name))]
         (router/add-domain domain)
-        (router/add-upstream domain (str "http://" (urly/host-of host) ":" port))
+        (router/add-upstream domain (str "http://" (urly/host-of host) ":" host-port))
         (swap! apps assoc app-name {:image image
                                     :tag tag
                                     :user-id (:id user)


[CI] Typo

[CI] Typo

--- src/layzee/adapters/settings.clj
+++ src/layzee/adapters/settings.clj
@@ -27,5 +27,5 @@
 (def amazon-credential
      (or
       (from-disk ".amazon")
-      { :access-key-id (env "AMAZON_ACCESS_KEY_ID")  :secret-acces-key (env "AMAZON_SECRET_ACCESS_KEY") }
+      { :access-key-id (env "AMAZON_ACCESS_KEY_ID")  :secret-access-key (env "AMAZON_SECRET_ACCESS_KEY") }
       (fail "You need to either supply the <AMAZON_ACCESS_KEY_ID,AMAZON_SECRET_ACCESS_KEY> environment variables or the <%s> file. Find them at <https://console.aws.amazon.com/iam/home?region=us-west-2#security_credential>" ".amazon")))


Fix list of known commands in help message

--- src/leiningen/pallet_release.clj
+++ src/leiningen/pallet_release.clj
@@ -17,4 +17,4 @@
     "finish" (release/finish project args)
     "push" (travis/push project args)
     "publish" (release/publish project args)
-    (fail "Known cmds are init, start, finish, and push")))
+    (fail "Known cmds are init, start, finish, and publish.")))


Inserting instead of upserting for profile data

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -131,6 +131,15 @@
     {:upsert true}))

+(defn mongo-insert-results
+  "Perform insert to mongo collection"
+  [collection-name object]
+  (mc/update
+    (db/mongo-db (env/env :mongolab-uri))
+    collection-name
+    object))
+
+
 (defn handle-profile-data
   "For now, just log profile data. Eventually want to send to influxDB and graphite."
   [conv & {:keys [recompute n-votes] :as extra-data}]
@@ -143,7 +152,7 @@
             (assoc :n-ptps (:n conv))
             (merge (hash-map-subset conv #{:n-cmts :zid})
                    extra-data)
-            ((partial mongo-upsert-results (db/mongo-collection-name "profile"))))
+            ((partial mongo-insert-results (db/mongo-collection-name "profile"))))
         (catch Exception e
           (log/error "Unable to submit profile data for zid:" (:zid conv))
           (.printStackTrace e)))


Fixed issues with small actor msgbox by maxing out buffer, and cleaned a couple actor things up

--- src/polismath/conv_man.clj
+++ src/polismath/conv_man.clj
@@ -249,11 +249,12 @@

 (defn new-conv-actor [init-fn & opts]
-  (let [msgbox (chan 1024)
-        conv (atom (init-fn))
-        status (atom :parked)
+  (let [msgbox (chan Long/MAX_VALUE) ; we want this to be as big as possible, since backpressure doesn't really work
+        conv (atom (init-fn)) ; keep track of conv state in atom so it can be dereffed
         ca (ConvActor. msgbox conv)
         err-handler (build-update-error-handler msgbox ca)]
+    ; Initialize the go loop which watches the mailbox, and runs updates all all pending messages when they
+    ; arrive
     (go (loop []
           (try
             (let [first-msg (<! msgbox) ; do this so we park efficiently


Adding docstrings and making PollManager idempotent.

--- src/ranked_choice/poll.clj
+++ src/ranked_choice/poll.clj
@@ -10,6 +10,12 @@
                  latest-results])

 (defn new-poll
+  "Creates a new poll using the provided VotingSystem
+  vsys and set of candidates. After creation voters
+  can cast votes by putting them on the :votes-ch
+  of the poll. Callers interested in the results of
+  the poll should use pipe-results to have the results
+  added to their channel. Returns the new poll."
   [vsys candidates]
   (let [latest-results (atom [])
         results-xf (comp (xf/reductions conj)
@@ -20,26 +26,40 @@
     (->Poll candidates votes-ch results-mult latest-results)))

 (defn pipe-results
+  "Pipes the results of the given poll onto the
+  channel ch. The latest results are always provided
+  first. Subsequent results will be provided as additional
+  votes are cast. Returns the provided channel."
   [poll ch]
   (async/put! ch @(:latest-results poll))
   (async/tap (:results-mult poll) ch)
   ch)

+(def ^:private close-all!
+  (comp (map :votes-ch)
+        (filter identity)
+        (map async/close!)))
+
 (defrecord PollManager [polls]
   component/Lifecycle
   (start [component]
-    (assoc component :polls (atom [])))
+    (if (:polls component)
+      component
+      (assoc component :polls (atom []))))
   (stop [component]
-    (swap! (:polls component)
-           (fn [polls]
-             (doseq [poll (keep identity polls)]
-               (async/close! (:votes-ch poll)))))
-    (dissoc component :polls)))
+    (if (:polls component)
+      (do
+        (swap! (:polls component)
+               #(into [] close-all! %))
+        (dissoc component :polls))
+      component)))

 (defn get-poll
+  "Gets a poll from the provided manager by id."
   [poll-mgr poll-id]
   (-> poll-mgr :polls deref (nth poll-id nil)))

 (defn conj-poll
+  "Conj's a poll onto the manager and returns its id."
   [poll-mgr poll]
   (-> poll-mgr :polls (swap! conj poll) count dec))


Move :on-click handler to th instead of icon

--- src/re_com/datepicker.cljs
+++ src/re_com/datepicker.cljs
@@ -95,16 +95,16 @@
     [:thead
      (conj template-row
            [:th {:class (str "prev " (if prev-enabled? "available selectable" "disabled"))
-                 :style {:padding "0px"}}
+                 :style {:padding "0px"}
+                 :on-click (handler-fn (when prev-enabled? (reset! current prev-date)))}
             [:i.zmdi.zmdi-chevron-left
-             {:style    {:font-size "24px"}
-              :on-click (handler-fn (when prev-enabled? (reset! current prev-date)))}]]
+             {:style    {:font-size "24px"}}]]
            [:th {:class "month" :col-span "5"} (month-label @current)]
            [:th {:class (str "next " (if next-enabled? "available selectable" "disabled"))
-                 :style {:padding "0px"}}
+                 :style {:padding "0px"}
+                 :on-click (handler-fn (when next-enabled? (reset! current next-date)))}
             [:i.zmdi.zmdi-chevron-right
-             {:style    {:font-size "24px"}
-              :on-click (handler-fn (when next-enabled? (reset! current next-date)))}]])
+             {:style    {:font-size "24px"}}]])
      (conj template-row
            [:th {:class "day-enabled"} "SUN"]
            [:th {:class "day-enabled"} "MON"]


Updated files

Updated files

--- src/intro/core.clj
+++ src/intro/core.clj
@@ -162,7 +162,8 @@
 ;The first param is the result of the previous application of the function while the second value is the next value from the list.
 (reduce #(+ %1 %2) '(1 2 3 4 5))

-;It doesnt always aggregate things it can be used to select a single value from the list. Although it should only be used in cases where it does not want to exit once it finds a valid value.
+;It doesnt always aggregate things it can be used to select a single value from the list.
+;Although it should only be used in cases where it does not want to exit once it finds a valid value.
 ;The following returns the larget value from the list.
 (reduce #(if
            (< %1 %2)
@@ -193,20 +194,36 @@
 (max '(1 2 3 4));(1 2 3 4)
 (apply max '(1 2 3 4)); 4

-
-
-(fn [board]
-  (let [x-win? (fn [s b]
-                 (some #(every? #{s} %) b))
-        transpose (fn [b] (apply mapv vector b))
-        tBoard (transpose board)
-        diagBoard [[((board 0) 0) ((board 1) 1) ((board 2) 2)] [((board 0) 2) ((board 1) 1) ((board 2) 0)]]
-       ]
-  (cond
-   (x-win? :x board) :x
-   (x-win? :o board) :o
-   (x-win? :x tBoard) :x
-   (x-win? :o tBoard) :o
-   (x-win? :x diagBoard) :x
-   (x-win? :o diagBoard) :o)))
-
+;Laziness!!
+
+;Sequences!!!
+
+;Useful links
+
+;THE build/project/Clojure installation tool. Very impress. Much power.
+;http://leiningen.org/
+
+;Wiki style documentation on all core functions. Primary documentation source outside actual source.
+;http://clojuredocs.org/
+
+;Editors - Currently the best editors with support for clojure are Emacs/Vim.
+;Vim plugins
+;https://github.com/guns/vim-clojure-static
+;https://github.com/tpope/vim-fireplace
+
+;Emacs
+;Learn vim here. Technically emacs has the best support, but then you are not using vim.
+
+;Windows friendly gui editor. Quite powerful and under active development. For most usages this is more than enough.
+;http://www.lighttable.com/
+
+
+;The actual website! Not super useful.
+;http://clojure.org/
+
+;Lots of very intresting videos on Clojure and related topics.
+;https://www.youtube.com/user/ClojureTV
+
+;For further intrest highly recommend the following books.
+;Programming Clojure
+;The Joy of Clojure


More on atoms.

More on atoms.

--- test/com/nomistech/clojure_the_language/intro_to_state.clj
+++ test/com/nomistech/clojure_the_language/intro_to_state.clj
@@ -103,26 +103,27 @@
 ;;;;
 ;;;; - An agent (another kind or reference) is used to keep track of how
 ;;;;   many times the swap function is called.
+;;;;   - This is just incidental -- I'm not trying to explain agents here.

-(def atom-to-demo-competing-updates (atom 0))
+(def competing-updates-atom (atom 0))

 (def n-competitors 100)

 (defn demo-competition-to-modify-atom []
   (let [n-attempts-agent (agent 0)
         futures          (for [i (range n-competitors)]
-                           (future (swap! atom-to-demo-competing-updates
+                           (future (swap! competing-updates-atom
                                           (fn [n]
                                             (send n-attempts-agent inc)
                                             (Thread/sleep (rand-int 100))
                                             (inc n)))))]
     (loop []
-      (println @atom-to-demo-competing-updates)
+      (println @competing-updates-atom)
       (when (not-every? realized? futures)
         (Thread/sleep 1000)
         (recur)))
     (println "Finished -- n-attempts =" @n-attempts-agent)
-    [@atom-to-demo-competing-updates
+    [@competing-updates-atom
      @n-attempts-agent]))

 (fact "About concurrency and atoms"


Re-add Java interop tests for byte array conversions.

--- test/dsbdp/test/data_processing_dsl_java_interop_tests.clj
+++ test/dsbdp/test/data_processing_dsl_java_interop_tests.clj
@@ -71,44 +71,44 @@
 ;;;
 ;;; Tests for byte array input and various output types.
 ;;;
-;(deftest byte-array-to-java-map-test
-;  (let [expected {"udpSrc" 2048, "udpDst" 4096}
-;        dsl-expression {:output-type :java-map
-;                        :rules [['udpSrc '(int16 50)]
-;                                ['udpDst '(int16 52)]]}
-;        data-processing-fn (create-proc-fn dsl-expression)
-;        result (data-processing-fn pcap-byte-array-test-data)]
-;    (is (instance? Map result))
-;    (is (= expected result))))
-;
-;(deftest byte-array-to-clj-map-test
-;  (let [expected {"udpSrc" 2048, "udpDst" 4096}
-;        dsl-expression {:output-type :clj-map
-;                        :rules [['udpSrc '(int16 50)]
-;                                ['udpDst '(int16 52)]]}
-;        data-processing-fn (create-proc-fn dsl-expression)
-;        result (data-processing-fn pcap-byte-array-test-data)]
-;    (is (map? result))
-;    (is (= expected result))))
-;
-;(deftest byte-array-to-csv-str-test
-;  (let [expected "2048,4096"
-;        dsl-expression {:output-type :csv-str
-;                        :rules [['udpSrc '(int16 50)]
-;                                ['udpDst '(int16 52)]]}
-;        data-processing-fn (create-proc-fn dsl-expression)
-;        result (data-processing-fn pcap-byte-array-test-data)]
-;    (is (= expected (str result)))))
-;
-;(deftest byte-array-to-json-str-test
-;  (let [expected "{\"udpSrc\":2048,\"udpDst\":4096}"
-;        dsl-expression {:output-type :json-str
-;                        :rules [['udpSrc '(int16 50)]
-;                                ['udpDst '(int16 52)]]}
-;        data-processing-fn (create-proc-fn dsl-expression)
-;        result (data-processing-fn pcap-byte-array-test-data)]
-;    (is (= expected (str result)))))
-;
+(deftest byte-array-to-java-map-test
+  (let [expected {"udpSrc" 2048, "udpDst" 4096}
+        dsl-expression-str (str "{:output-type :java-map "
+                                " :rules [[udpSrc (int16 50)] "
+                                "         [udpDst (int16 52)]]}")
+        data-processing-fn (DslHelper/generateProcessingFn dsl-expression-str)
+        result (.invoke data-processing-fn pcap-byte-array-test-data)]
+    (is (instance? Map result))
+    (is (= expected result))))
+
+(deftest byte-array-to-clj-map-test
+  (let [expected {"udpSrc" 2048, "udpDst" 4096}
+        dsl-expression-str (str "{:output-type :clj-map "
+                                " :rules [[udpSrc (int16 50)] "
+                                "         [udpDst (int16 52)]]}")
+        data-processing-fn (DslHelper/generateProcessingFn dsl-expression-str)
+        result (.invoke data-processing-fn pcap-byte-array-test-data)]
+    (is (map? result))
+    (is (= expected result))))
+
+(deftest byte-array-to-csv-str-test
+  (let [expected "2048,4096"
+        dsl-expression-str (str "{:output-type :csv-str "
+                                " :rules [[udpSrc (int16 50)] "
+                                "         [udpDst (int16 52)]]}")
+        data-processing-fn (DslHelper/generateProcessingFn dsl-expression-str)
+        result (.invoke data-processing-fn pcap-byte-array-test-data)]
+    (is (= expected (str result)))))
+
+(deftest byte-array-to-json-str-test
+  (let [expected "{\"udpSrc\":2048,\"udpDst\":4096}"
+        dsl-expression-str (str "{:output-type :json-str "
+                                " :rules [[udpSrc (int16 50)] "
+                                "         [udpDst (int16 52)]]}")
+        data-processing-fn (DslHelper/generateProcessingFn dsl-expression-str)
+        result (.invoke data-processing-fn pcap-byte-array-test-data)]
+    (is (= expected (str result)))))
+
 ;(deftest byte-array-to-csv-str-qm-test
 ;  (let [expected "\"2048\",4096"
 ;        dsl-expression {:output-type :csv-str


fix bigquery :features so that we don't get nils

--- src/metabase/driver/bigquery.clj
+++ src/metabase/driver/bigquery.clj
@@ -473,9 +473,8 @@
           ;; people can manually specifiy "foreign key" relationships in admin and everything should work correctly.
           ;; Since we can't infer any "FK" relationships during sync our normal FK tests are not appropriate for BigQuery, so they're disabled for the time being.
           ;; TODO - either write BigQuery-speciifc tests for FK functionality or add additional code to manually set up these FK relationships for FK tables
-          :features              (constantly (merge #{:native-parameters}
-                                                    (when-not config/is-test?
-                                                      :foreign-keys)))
+          :features              (constantly (cond-> #{:native-parameters}
+                                                     (not config/is-test?) :foreign-keys))
           :field-values-lazy-seq (u/drop-first-arg field-values-lazy-seq)
           :mbql->native          (u/drop-first-arg mbql->native)}))


Fix wrong variable name.

Fix wrong variable name.

--- test/cljam/test_common.clj
+++ test/cljam/test_common.clj
@@ -235,7 +235,7 @@
 (def test-bcf-various-bins-file "test-resources/bcf/various-bins.bcf")
 (def test-bcf-various-bins-csi-file "test-resources/bcf/various-bins.bcf.csi")
 (def test-large-bcf-file (cavia/resource mycavia "large.bcf"))
-(def test-large-vcf-csi-file (cavia/resource mycavia "large.bcf.csi"))
+(def test-large-bcf-csi-file (cavia/resource mycavia "large.bcf.csi"))

 ;; ### GFF3 files


Remove printlns.

Remove printlns.

--- src/onyx/peer/task_lifecycle.clj
+++ src/onyx/peer/task_lifecycle.clj
@@ -208,8 +208,8 @@
     (.set ^AtomicLong (:checkpoint-size monitoring) (alength checkpoint-bytes))
     (checkpoint/write-checkpoint storage tenancy-id job-id (t/replica-version state)
                                  (t/epoch state) task-id slot-id :input checkpoint-bytes)
-    (println "Checkpointed input" job-id (t/replica-version state)
-             (t/epoch state) task-id slot-id :input)
+    (info "Checkpointed input" job-id (t/replica-version state)
+          (t/epoch state) task-id slot-id :input)
     (advance state)))

 (defn checkpoint-state [state]
@@ -219,12 +219,11 @@
                             (map (juxt ws/window-id ws/export-state))
                             (into {}))
         checkpoint-bytes (checkpoint-compress exported-state)]
-    (println "n-bytes checkpointing:" (count checkpoint-bytes))
     (.set ^AtomicLong (:checkpoint-size monitoring) (alength checkpoint-bytes))
     (checkpoint/write-checkpoint storage tenancy-id job-id (t/replica-version state)
                                  (t/epoch state) task-id slot-id :windows checkpoint-bytes)
-    (println "Checkpointed state" job-id (t/replica-version state)
-             (t/epoch state) task-id slot-id :windows)
+    (info "Checkpointed state" job-id (t/replica-version state)
+          (t/epoch state) task-id slot-id :windows)
     (advance state)))

 (defn checkpoint-output [state]
@@ -236,8 +235,8 @@
     (.set ^AtomicLong (:checkpoint-size monitoring) (alength checkpoint-bytes))
     (checkpoint/write-checkpoint storage tenancy-id job-id (t/replica-version state)
                                    (t/epoch state) task-id slot-id :input checkpoint-bytes)
-    (println "Checkpointed output" job-id (t/replica-version state)
-             (t/epoch state) task-id slot-id :input)
+    (info "Checkpointed output" job-id (t/replica-version state)
+          (t/epoch state) task-id slot-id :input)
     (advance state)))

 (defn completed? [state]


Use defonce to keep session store between file reloads

--- src/territory_bro/middleware.clj
+++ src/territory_bro/middleware.clj
@@ -49,8 +49,7 @@
         (response/content-type resp "text/plain")))))

 ;; Avoid forgetting sessions every time the code is reloaded in development mode
-;; TODO: use mount
-(def session-store (memory-session/memory-store))
+(defonce session-store (memory-session/memory-store))

 (defn wrap-base [handler]
   (-> handler


fix #61, re-add fix into new source file

--- src/thi/ng/geom/tetrahedron.cljc
+++ src/thi/ng/geom/tetrahedron.cljc
@@ -76,8 +76,9 @@

   g/IFaceAccess
   (faces
-    [{[a b c d] :points}]
-    [[a b c] [a d b] [b d c] [c d a]])
+    ([t _] (g/faces t))
+    ([{[a b c d] :points}]
+     [[[a b c]] [[a d b]] [[b d c]] [[c d a]]]))

   g/IGraph
   (vertex-neighbors
@@ -165,7 +166,7 @@
     [_ m] (thi.ng.geom.types.Tetrahedron. (mapv #(g/transform-vector m %) (get _ :points))))

   ;; http://mathcentral.uregina.ca/QQ/database/QQ.09.03/peter2.html
-
+
   g/IVolume
   (volume
     [{[a b c d] :points}]