Formattimng change

Formattimng change

Added proper indentation to server side fns

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -30,12 +30,7 @@
                :user *database-user*
                :password *database-password*
                :naming {:keys string/upper-case
-                        :fields string/upper-case}})
-    )
-
-
-
-
+                        :fields string/upper-case}}))

   (catch Exception e
@@ -47,8 +42,18 @@

+
+
+
+
+
 (defn !say-hello [params]
     {:text (str "System Hello " (:name params))})
+
+
+
+
+

@@ -70,6 +75,11 @@

+
+
+
+
+
 (defn !get-record-pointer-locally []
   {:value *record-pointer-locally*})

@@ -77,12 +87,19 @@

+
+
+
+
 (defn !get-record-ui []
   {:value *record-ui*})

+
+
+
 (defn !get-environment []
   {:value *environment*})

@@ -90,8 +107,19 @@

+
+
+
+
 (defn !get-show-debug []
   {:value *show-code*})
+
+
+
+
+
+
+

@@ -108,8 +136,13 @@
     {
      :value session-id
      :data-session-id    data-session-id
-    }
-    ))
+    }))
+
+
+
+
+
+

@@ -138,9 +171,6 @@
       (= *database-type* "oracle" )
         (if where (str "where " where " "))
     )
-    ;questions_answered_count is not null
-    ;order by
-    ;questions_answered_count desc"
       (cond
         (= *database-type* "postgres" )
         "limit 100"
@@ -156,8 +186,19 @@

+
+
+
+
+
+
+
+
 (defn fields-to-str [fields]
   (apply str (interpose "," (map (-> name ) fields) )))
+
+
+

@@ -195,6 +236,11 @@

+
+
+
+
+
 (defn get-count [db-table  where   params]
                                                (:cnt (sql-1 (str
                                                   "select count (id) as CNT from "
@@ -213,29 +259,28 @@

+
+
+
 (defn get-results [& {:keys [db-table where order start end params]}]
-(sql
-    (str
-        "select id from "
-        db-table " "
-        (if (-> where count pos?) (str "where " where " "))
-        (if (-> order count pos?) (str "order by " order " "))
-        (cond
-            (= *database-type* "postgres" )
-            (str
-                (if start (str " offset " (- start 1) " "))
-                (if end (str " limit " (+ 1 (- end start)) " ") "limit 2")
-                )
-
-            (= *database-type* "oracle" )
-            ""
-            )
-
-        ;questions_answered_count is not null
-        ;order by
-        ;questions_answered_count desc"
-        ) params)
-        )
+  (sql
+   (str
+    "select id from "
+    db-table " "
+    (if (-> where count pos?) (str "where " where " "))
+    (if (-> order count pos?) (str "order by " order " "))
+    (cond
+     (= *database-type* "postgres" )
+     (str
+      (if start (str " offset " (- start 1) " "))
+      (if end (str " limit " (+ 1 (- end start)) " ") "limit 2")
+      )
+
+     (= *database-type* "oracle" )
+     ""
+     )
+    ) params))
+

@@ -261,42 +306,37 @@

 (defn create-realtime-trigger [& {:keys [:table-name]}]
-(let [coils-trigger      (korma.core/exec-raw
-                                   [" select * from coils_triggers where table_name = ?" [table-name]]
-                                   :results)
+  (let [coils-trigger      (korma.core/exec-raw
+                            [" select * from coils_triggers where table_name = ?" [table-name]]
+                            :results)

         coils-trigger-exists   (pos? (count coils-trigger))

         sql-to-drop-trigger    (str "DROP TRIGGER IF EXISTS trigger_afterinsert ON " table-name ";")
-      sql-to-insert-trigger-row "
-INSERT INTO coils_triggers
-(
-  table_name,version
-) values (?,?);
-"
+        sql-to-insert-trigger-row "
+        INSERT INTO coils_triggers
+        (
+        table_name,version
+        ) values (?,?);
+        "

         sql-to-create-insert-trigger (str "CREATE TRIGGER trigger_afterInsert AFTER INSERT ON " table-name " FOR EACH ROW EXECUTE PROCEDURE trigger_function_afterInsert();")
         sql-to-create-update-trigger (str "CREATE TRIGGER trigger_afterUpdate AFTER UPDATE ON " table-name " FOR EACH ROW EXECUTE PROCEDURE trigger_function_afterUpdate();")
         sql-to-create-delete-trigger (str "CREATE TRIGGER trigger_afterDelete AFTER DELETE ON " table-name " FOR EACH ROW EXECUTE PROCEDURE trigger_function_afterDelete();")
         ]
-        ;(println "Coils trigger table exists: " coils-trigger-exists)
-
-
-        (if (not coils-trigger-exists )
-        (do
-            (korma.core/exec-raw   [sql-to-insert-trigger-row [table-name  coils-tables-trigger-version]]   [])
-            (korma.core/exec-raw   [sql-to-drop-trigger []]   [])
-            (korma.core/exec-raw   [sql-to-create-insert-trigger []]   [])
-            (korma.core/exec-raw   [sql-to-create-update-trigger []]   [])
-            (korma.core/exec-raw   [sql-to-create-delete-trigger []]   [])
-
-                      )
-                      nil
+    ;(println "Coils trigger table exists: " coils-trigger-exists)
+
+
+    (if (not coils-trigger-exists )
+      (do
+        (korma.core/exec-raw   [sql-to-insert-trigger-row [table-name  coils-tables-trigger-version]]   [])
+        (korma.core/exec-raw   [sql-to-drop-trigger []]   [])
+        (korma.core/exec-raw   [sql-to-create-insert-trigger []]   [])
+        (korma.core/exec-raw   [sql-to-create-update-trigger []]   [])
+        (korma.core/exec-raw   [sql-to-create-delete-trigger []]   [])

         )
-
-          )
-)
+      nil)))

@@ -344,6 +384,10 @@

+
+
+
+
 (defn make-todo-table []
   (let [coils-admin-tables      (korma.core/exec-raw
                                  [" select * from pg_tables where schemaname='public' and tablename='coils_todo_items'" []]
@@ -376,6 +420,11 @@

+
+
+
+
+
 (defn make-users-table []
   (let [coils-admin-tables      (korma.core/exec-raw
                                  [" select * from pg_tables where schemaname='public' and tablename='coils_users'" []]
@@ -409,39 +458,39 @@

+
+
+
+
 (defn make-log-table []
   (let [coils-admin-tables      (korma.core/exec-raw
-                                   [" select * from pg_tables where schemaname='public' and tablename='coils_realtime_log'" []]
-                                   :results)
+                                 [" select * from pg_tables where schemaname='public' and tablename='coils_realtime_log'" []]
+                                 :results)

         coils-admin-table-exists   (pos? (count coils-admin-tables))

         sql-to-create-admin-table "
-CREATE TABLE coils_realtime_log
-(
-  id                  serial NOT NULL,
-  realtime_jvm_id     integer,
-  record_timestamp    timestamp without time zone,
-  record_table_name   character varying,
-  record_id           character varying,
-  record_operation    character varying,
-  record_status       character varying
-);
-"
-  ]
-
-      (println "Coils admin table exists: " coils-admin-table-exists)
-      (if (not coils-admin-table-exists )
-                      (korma.core/exec-raw   [sql-to-create-admin-table []]   [])
-                      nil
-        )
-
-
-
-
-
-  )
-  )
+        CREATE TABLE coils_realtime_log
+        (
+        id                  serial NOT NULL,
+        realtime_jvm_id     integer,
+        record_timestamp    timestamp without time zone,
+        record_table_name   character varying,
+        record_id           character varying,
+        record_operation    character varying,
+        record_status       character varying
+        );
+        "
+        ]
+
+    (println "Coils admin table exists: " coils-admin-table-exists)
+    (if (not coils-admin-table-exists )
+      (korma.core/exec-raw   [sql-to-create-admin-table []]   [])
+      nil
+      )))
+
+
+

@@ -458,35 +507,36 @@

 (defn make-log-table-insert-trigger-function []
-    (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
-                                                  ["select exists(select * from pg_proc where proname = 'trigger_function_afterinsert');" []]
-                                                  :results)
-
-          coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
-
-          sql-to-create-trigger-fn "
-CREATE OR REPLACE FUNCTION trigger_function_afterInsert()
-      RETURNS trigger AS
-$BODY$
-      BEGIN
-           INSERT INTO coils_realtime_log
-                 (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
-           VALUES
-                 ( now(),   TG_TABLE_NAME ,  NEW.id,  'INSERT',  'WAITING');
-           RETURN NULL;
-      END;
-$BODY$
-LANGUAGE plpgsql;
-"
-          ]
-
-        ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
-        (if (not coils-trigger-fn-exists )
-            (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
-            nil
-            )
-        )
-    )
+  (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
+                                             ["select exists(select * from pg_proc where proname = 'trigger_function_afterinsert');" []]
+                                             :results)
+
+        coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
+
+        sql-to-create-trigger-fn "
+        CREATE OR REPLACE FUNCTION trigger_function_afterInsert()
+        RETURNS trigger AS
+        $BODY$
+        BEGIN
+        INSERT INTO coils_realtime_log
+        (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
+        VALUES
+        ( now(),   TG_TABLE_NAME ,  NEW.id,  'INSERT',  'WAITING');
+        RETURN NULL;
+        END;
+        $BODY$
+        LANGUAGE plpgsql;
+        "
+        ]
+
+    ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
+    (if (not coils-trigger-fn-exists )
+      (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
+      nil)))
+
+
+
+

@@ -503,35 +553,32 @@

 (defn make-log-table-update-trigger-function []
-    (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
-                                                  ["select exists(select * from pg_proc where proname = 'trigger_function_afterUpdate');" []]
-                                                  :results)
-
-          coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
-
-          sql-to-create-trigger-fn "
-CREATE OR REPLACE FUNCTION trigger_function_afterUpdate()
-      RETURNS trigger AS
-$BODY$
-      BEGIN
-           INSERT INTO coils_realtime_log
-                 (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
-           VALUES
-                 ( now(),   TG_TABLE_NAME ,  NEW.id,  'UPDATE',  'WAITING');
-           RETURN NULL;
-      END;
-$BODY$
-LANGUAGE plpgsql;
-"
-          ]
-
-        ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
-        (if (not coils-trigger-fn-exists )
-            (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
-            nil
-            )
-        )
-    )
+  (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
+                                             ["select exists(select * from pg_proc where proname = 'trigger_function_afterUpdate');" []]
+                                             :results)
+
+        coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
+
+        sql-to-create-trigger-fn "
+        CREATE OR REPLACE FUNCTION trigger_function_afterUpdate()
+        RETURNS trigger AS
+        $BODY$
+        BEGIN
+        INSERT INTO coils_realtime_log
+        (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
+        VALUES
+        ( now(),   TG_TABLE_NAME ,  NEW.id,  'UPDATE',  'WAITING');
+        RETURN NULL;
+        END;
+        $BODY$
+        LANGUAGE plpgsql;
+        "
+        ]
+
+    ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
+    (if (not coils-trigger-fn-exists )
+      (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
+      nil)))

@@ -548,47 +595,52 @@

 (defn make-log-table-delete-trigger-function []
-    (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
-                                                  ["select exists(select * from pg_proc where proname = 'trigger_function_afterDelete');" []]
-                                                  :results)
-
-          coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
-
-          sql-to-create-trigger-fn "
-CREATE OR REPLACE FUNCTION trigger_function_afterDelete()
-      RETURNS trigger AS
-$BODY$
-      BEGIN
-           INSERT INTO coils_realtime_log
-                 (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
-           VALUES
-                 ( now(),   TG_TABLE_NAME ,  OLD.id,  'DELETE',  'WAITING');
-           RETURN NULL;
-      END;
-$BODY$
-LANGUAGE plpgsql;
-"
-          ]
-
-        ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
-        (if (not coils-trigger-fn-exists )
-            (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
-            nil
-            )
-        )
-    )
-
-
-
-
-
-
-
-
-  (make-todo-table)
-  (make-users-table)
-  (make-admin-table )
-  (make-log-table   )
+  (let [coils-trigger-fn-exists-result      (korma.core/exec-raw
+                                             ["select exists(select * from pg_proc where proname = 'trigger_function_afterDelete');" []]
+                                             :results)
+
+        coils-trigger-fn-exists   (= "t"  coils-trigger-fn-exists-result)
+
+        sql-to-create-trigger-fn "
+        CREATE OR REPLACE FUNCTION trigger_function_afterDelete()
+        RETURNS trigger AS
+        $BODY$
+        BEGIN
+        INSERT INTO coils_realtime_log
+        (record_timestamp,  record_table_name,  record_id,  record_operation,  record_status)
+        VALUES
+        ( now(),   TG_TABLE_NAME ,  OLD.id,  'DELETE',  'WAITING');
+        RETURN NULL;
+        END;
+        $BODY$
+        LANGUAGE plpgsql;
+        "
+        ]
+
+    ;(println "Coils trigger function exists: " coils-trigger-fn-exists)
+    (if (not coils-trigger-fn-exists )
+      (korma.core/exec-raw   [sql-to-create-trigger-fn []]   [])
+      nil)))
+
+
+
+
+
+
+
+
+
+
+
+
+(make-todo-table)
+(make-users-table)
+(make-admin-table )
+(make-log-table   )
+
+
+
+

@@ -597,13 +649,11 @@

 (defn do-real [& {:keys [:table-name]}]
   ;(println "table name: " table-name)
-

   ( make-log-table-insert-trigger-function)
   ( make-log-table-update-trigger-function)
   ( make-log-table-delete-trigger-function)
-  (create-realtime-trigger  :table-name  table-name)
-)
+  (create-realtime-trigger  :table-name  table-name))

@@ -724,10 +774,7 @@
                      ;(println (str "    responses: " (if response-atom @response-atom)))

                      ;                   (swap! (:update-request @the-query) assoc  1 2)
-                     ))))
-
-
-        ))))
+                     ))))))))

@@ -769,6 +816,12 @@
       ;(println "")

       )))
+
+
+
+
+
+


Add missing 'added' metadata to ring.util.response

--- ring-core/src/ring/util/response.clj
+++ ring-core/src/ring/util/response.clj
@@ -8,7 +8,7 @@
            [java.util Date]
            [java.net URL URLDecoder URLEncoder]))

-(def redirect-status-codes
+(def ^{:added "1.4"} redirect-status-codes
   "Map a keyword to a redirect status code."
   {:moved-permanently 301
    :found 302
@@ -224,7 +224,7 @@
   protocol.

   This function is used internally by url-response."
-  {:arglists '([url])}
+  {:arglists '([url]), :added "1.4"}
   (fn [^java.net.URL url]
     (keyword (.getProtocol url))))


Improving documentation.

Improving documentation.

--- src/afterglow/effects/fun.clj
+++ src/afterglow/effects/fun.clj
@@ -19,25 +19,31 @@
            (afterglow.rhythm Metronome)
            (javax.vecmath Point3d)))

-(def default-down-beat-color
-  "The default color to flash on the down beats."
+(def ^{:doc/format :markdown} default-down-beat-color
+  "The default color for [[metronome-effect]] to flash on the down
+  beats."
   (colors/lighten (colors/create-color :red) 20))

-(def default-other-beat-color
-  "The default color to flash on beats that are not down beats."
+(def ^{:doc/format :markdown} default-other-beat-color
+  "The default color for [[metronome-effect]] to flash on beats that
+  are not down beats."
   (colors/darken (colors/create-color :yellow) 30))

 (defn metronome-effect
   "Returns an effect which flashes the supplied fixtures to the beats
   of the show metronome, emphasizing the down beat, which is a great
   way to test and understand metronome synchronization. The color of
-  the flashes can be controlled by the :down-beat-color
-  and :other-beat-color arguments (defaulting to red with lightness
-  70, and yellow with lightness 20, respectively).
+  the flashes can be controlled by the `:down-beat-color` and
+  `:other-beat-color` optional keyword arguments (defaulting to red
+  with lightness 70, and yellow with lightness 20, respectively).

   This is no longer as useful as it used to be before there were
   metronome adjustment interfaces in the Ableton Push and then web
-  interfaces."
+  interfaces, but is still an example of how to write a metronome
+  driven effect, and can be synchronized to metronomes other than the
+  default show metronome by passing them in with optional keyword
+  argument `:metronome`."
+  {:doc/format :markdown}
   [fixtures & {:keys [down-beat-color other-beat-color metronome]
                :or {down-beat-color default-down-beat-color
                     other-beat-color default-other-beat-color
@@ -80,8 +86,8 @@
                (fn [snow snapshot]  ;; Arrange to shut down at the end of a measure
                  (reset! running false))))))

-(def default-sparkle-color
-  "The default color for the sparkle effect."
+(def ^{:doc/format :markdown} default-sparkle-color
+  "The default color for the [[sparkle]] effect."
   (colors/create-color "white"))

 (defn- remove-finished-sparkles
@@ -104,7 +110,17 @@
 ;; so they can be scaled in time too. Eventually allow randomization of fade time and perhaps
 ;; hue and peak brightness, with control over how much they vary?
 (defn sparkle
-  "A random sparkling effect like a particle generator over the supplied fixture heads."
+  "A random sparkling effect like a particle generator over the
+  supplied fixture heads.
+
+  As each frame of DMX values generated, each participating fixture
+  head has a chance of being assigned a sparkle (this chance is
+  controlled by the optional keyword parameter `:chance`). Once a
+  sparkle has been created, it will fade out over the number of
+  milliseconds specified by the optional keyword parameter
+  `:fade-time`. The initial color of each sparkle can be changed with
+  the optional keyword parameter `:color`."
+  {:doc/format :markdown}
   [fixtures & {:keys [color chance fade-time] :or {color default-sparkle-color chance 0.001 fade-time 500}}]
   {:pre [(some? *show*)]}
   (let [color (params/bind-keyword-param color :com.evocomputing.colors/color default-sparkle-color)
@@ -227,13 +243,13 @@
   "A transition phase function which causes the color cycle transition
   to occur during the down beat of each bar. See [[color-cycle-chase]]
   for how this is used."
+  {:doc/format :markdown}
   [snapshot]
   (if (rhythm/snapshot-down-beat? snapshot)
     (rhythm/snapshot-beat-phase snapshot)  ; Transition is occuring
     1.0))  ; Transition is complete

-;; TODO: Working on:
-;;       Create no-assigner effects which set color lists and
+;; TODO: Create no-assigner effects which set color lists and
 ;;       transition functions in show variables; the latter
 ;;       should also have a variable to set the number of beats
 ;;       over which the transition takes place. This will allow
@@ -253,7 +269,7 @@
   value of 0 will change as soon as transition has started, and the
   fixture(s) that return the largest value will change when the
   transition ends. A value halfway between zero and the largest value
-  would mean the color of that fiture or head would change exactly at
+  would mean the color of that fixture or head would change exactly at
   the midpoint of the transition. Many interesting looking
   transtitions can be created using distance measures constructed by
   calling [[afterglow.transform/build-distance-measure]], as is done
@@ -283,25 +299,25 @@
   The function supplied with `:transition-phase-function` determines
   precisely when the transition takes place and how quickly it occurs.
   It is also called with the show metronome snapshot, and if the value
-  it returns is zero or less, the transition is considered not to have
-  started yet, and no fixtures will be assigned the current color.
-  Values between zero and one mean the transition is in progress, and
-  lights whose distance measure divided by the largest distance
-  measure is less than or equal to the current phase will change
-  color. Once the transition phase reaches one (or greater), the
-  transition is complete, and all lights will be assigned the color
-  associated with the current cycle index. The default transition
-  phase function causes the transition to be spread over the down beat
-  of each bar. Passing [[rhythm/snapshot-bar-phase]] instead would
-  spread the transition over the entire bar, so that transitions would
-  be feeding right into each other. Other possibilities are limited
-  only by your imagination, although for the transition mechanics to
-  work correctly with respect to assigning old and new color values,
-  it should always start at (or below) zero and progress to one (or
-  beyond). It can pause and reverse directions while in between those
-  extremes, but if you want to reverse the direction of the full
-  transition, do it by reversing the distance measure, not the phase
-  function.
+  it returns is less than zero, the transition is considered not to
+  have started yet, and no fixtures will be assigned the current
+  color. Values between zero and one mean the transition is in
+  progress, and lights whose distance measure divided by the largest
+  distance measure is less than or equal to the current phase will
+  change color. Once the transition phase reaches one (or greater),
+  the transition is complete, and all lights will be assigned the
+  color associated with the current cycle index. The default
+  transition phase function, [[transition-during-down-beat]], causes
+  the transition to be spread over the down beat of each bar.
+  Passing [[rhythm/snapshot-bar-phase]] instead would spread the
+  transition over the entire bar, so that transitions would be feeding
+  right into each other. Other possibilities are limited only by your
+  imagination, although for the transition mechanics to work correctly
+  with respect to assigning old and new color values, it should always
+  start at (or below) zero and progress to one (or beyond). It can
+  pause and reverse directions while in between those extremes, but if
+  you want to reverse the direction of the full transition, do it by
+  reversing the distance measure, not the phase function.

   To give your running effect a meaningful name within user
   interfaces, pass a short and descriptive value with `:effect-name`."
@@ -402,14 +418,3 @@
                                                   :ignore-y true :ignore-z true)]
     (color-cycle-chase fixtures measure :color-cycle color-cycle :color-index-function color-index-function
                        :transition-phase-function transition-phase-function :effect-name effect-name)))
-
-
-(defn blast
-  "An effect which creates a sphere of light which expands from a
-  point, then hollows out as it continues to grow and fade."
-  [fixtures & {:keys [color x y grow-time max-solid-diameter]
-               :or {color default-sparkle-color x (:center-x @(:dimensions *show*))
-                    y (:center-y @(:dimensions *show*)) grow-time 1000
-                    max-solid-diameter 0.2}}]
-  ;; Some kind of gradient slope for edges too?
-  )


Make pinstripe run left-to-right.

Make pinstripe run left-to-right.

--- src/afterglow/effects/fun.clj
+++ src/afterglow/effects/fun.clj
@@ -995,7 +995,7 @@
                         (let [effects (map (fn [color]
                                              (color-fx/color-effect "pin color" color stripe-heads))
                                            colors)
-                              pin-step (params/build-param-formula Number #(+ % i) step)]
+                              pin-step (params/build-param-formula Number #(- % i) step)]
                           (fx/chase "Pinstripe" effects pin-step :beyond (if bounce? :bounce :loop))))
                       (range) stripes)]
       (apply fx/scene "Pinstripes" chases))))


don't pass component state to results-view build

--- src-cljs/core.cljs
+++ src-cljs/core.cljs
@@ -235,14 +235,13 @@
     om/IInitState
     (init-state [_]
       {:search-term ""
-       :new-results (chan)
        })
     om/IRenderState
     (render-state [this state]
       (dom/div nil
                (om/build filters-view app {:init-state state})
                (dom/h2 nil "results")
-               (om/build results-view (:results app) {:init-state state})
+               (om/build results-view (:results app))
                (dom/h2 nil "queue")
                (om/build queue-view app)
                (om/build player-view app)


- remove extra ‘learn’

- remove extra ‘learn’

--- src/babel/english/lexicon.clj
+++ src/babel/english/lexicon.clj
@@ -966,12 +966,6 @@
               :present {:3sing "throws out"}
               :participle "throwing out"}}

-
-   "transfer" {:english {:past "transferred"
-                         :participle "transferring"}
-               :synsem {:cat :verb
-                        :sem {:pred :transfer}}}
-
    "transfer" {:english {:past "transferred"
                          :participle "transferring"}
                :synsem {:cat :verb


change Early Premiere advancement to :placed true

--- src/clj/game/cards-assets.clj
+++ src/clj/game/cards-assets.clj
@@ -149,7 +149,7 @@
                  :choices {:req #(or (= (:advanceable %) "always")
                                      (and (= (:advanceable %) "while-rezzed") (:rezzed %))
                                      (= (:type %) "Agenda"))}
-                 :effect (effect (add-prop target :advance-counter 1)) :once :per-turn
+                 :effect (effect (add-prop target :advance-counter 1 {:placed true})) :once :per-turn
                  :msg (msg "place 1 advancement token on " (if (:rezzed target) (:title target) "a card"))}]}

    "Edge of World"


fix Test Run to return hosted programs to the top of the Stack

--- src/clj/game/cards-events.clj
+++ src/clj/game/cards-events.clj
@@ -664,7 +664,7 @@
     :effect (req (add-prop state :runner target :counter 2))}

    "Test Run"
-   {:prompt "Install a program from Stack or Heap?"
+   {:prompt "Install a program from your Stack or Heap?"
     :choices (cancellable ["Stack" "Heap"])
     :msg (msg "install a program from " target)
     :effect (effect (resolve-ability
@@ -674,12 +674,9 @@
                                              ((if (= target "Heap") :discard :deck) runner))))
                       :effect (effect (runner-install (assoc-in target [:special :test-run] true) {:no-cost true}))
                       :end-turn
-                      {:req (req (some #(when (and (= (:cid target) (:cid %))
-                                                   (get-in % [:special :test-run])) %)
-                                       (get-in runner [:rig :program])))
-                       :msg (msg "move " (:title target) " on top of their Stack")
-                       :effect (req (move state side (some #(when (= (:cid target) (:cid %)) %)
-                                                           (get-in runner [:rig :program]))
+                      {:req (req (find-cid (:cid target) (all-installed state :runner)))
+                       :msg (msg "move " (:title target) " to the top of their Stack")
+                       :effect (req (move state side (find-cid (:cid target) (all-installed state :runner))
                                           :deck {:front true}))}}
                      card targets))}


Fix world generation, delete stale save files when generation goes wrong

--- src/cljc/robinson/update.cljc
+++ src/cljc/robinson/update.cljc
@@ -54,6 +54,12 @@
   [state & more]
   state)

+(defn delete-save-game []
+  ;; delete the save game on player death
+  (doseq [file (filter (fn [file] (re-matches #".*edn" (.getName file))) (file-seq (io/file "save")))]
+    (log/info "Deleting" file)
+    (.delete file)))
+
 (defn translate-directions
   [keyin]
   (case keyin
@@ -177,7 +183,10 @@
                     (rworldgen/load-unload-places))]
         (if (contains? #{:tree :palm-tree :fruit-tree :bamboo :mountain}
                        (get-in (rw/player-cellxy state) [0 :type]))
-          (recur)
+          (do
+            ;; remove generated placed
+            (delete-save-game)
+            (recur))
           (->  state
             (add-starting-inventory selected-hotkeys)
             (update-visibility)
@@ -1568,60 +1577,64 @@
       (rc/append-log state "Pick a valid recipe." :white))))

-(defn scroll-log
-  [state]
-  (let [t (get-in state [:world :time])]
-    (log/info "scroll-log t" t)
-    (log/info "scroll-log logs-viewed" (get-in state [:world :logs-viewed]))
+(defn scroll-log-up
+  [state]
+  (let [t        (rw/get-time state)
+        log-idx  (get-in state [:world :log-idx])
+        num-logs (count (filter #(= t (get % :time)) (get-in state [:world :log])))]
+    (update-in state [:world :log-idx] (fn [idx] (min (dec num-logs) (inc log-idx))))))
+
+(defn scroll-log-down
+  [state]
+  (let [t        (rw/get-time state)
+        log-idx  (get-in state [:world :log-idx])]
+    (update-in state [:world :log-idx] (fn [idx] (max 0 (dec log-idx))))))
+
+(defn reducing-join
+  "If coll is empty, it is returned.
+   If coll has one element it is returned.
+   If coll has two elements, the collection [(f (first coll) (second coll))]
+   is returned."
+  [f coll]
+  (if (> (count coll) 1)
+    (reduce (fn [acc v]
+              (concat (butlast acc) (f (last acc) v)))
+            [(first coll)]
+            (rest coll))
+    coll))
+
+(defn coalesce-log-group
+  [logs]
+  (reducing-join (fn [loga logb]
+                   (if (< (+ (-> loga :text count)
+                             (-> logb :text count))
+                          70)
+                     ;; join short lines
+                     [{:time (get loga :time)
+                       :text (clojure.string/join " " [(get loga :text)
+                                                       (get logb :text)])
+                       :color (get loga :color)}]
+                     ;; pass long lines through
+                     [loga logb]))
+                  logs))
+
+
+;; Logs is a vector with elements of {:text :color :time}
+(defn coalesce-logs
+  [state]
+  (let [now (rw/get-time state)]
     (-> state
-      (update-in [:world :logs-viewed] inc)
-      (as-> state
-        (let [c (count (filter #(= t (get % :time)) (get-in state [:world :log])))
-              logs-viewed (get-in state [:world :logs-viewed])]
-          (if (>= logs-viewed c)
-            (rw/assoc-current-state state :normal)
-            state))))))
-
-(defn init-log-scrolling
-  [state]
-  (-> state
-    (update-in [:world :log]
-      (fn [logs]
-        (log/info "updating :world :log. logs" logs)
-        (mapcat
-          (fn [logs-with-same-time]
-            (vec
-              (reduce (fn [logs-with-same-time log]
-                        (log/debug "updating logs-with-same-time" logs-with-same-time)
-                        (log/debug "log" log)
-                        (let [last-log (last logs-with-same-time)]
-                          (if (and (< (+ (count (get last-log :text))
-                                      (count (get log :text)))
-                                    70)
-                                (= (get last-log :color)
-                                   (get log :color)))
-                            ;; conj short lines
-                            (vec (conj (vec (butlast logs-with-same-time))
-                                        {:time (get log :time)
-                                         :text (clojure.string/join " " [(get last-log :text)
-                                                                         (get log :text)])
-                                         :color (get log :color)}))
-                            ;; pass long lines through
-                            (vec (conj logs-with-same-time log)))))
-                      []
-                      logs-with-same-time)))
-          (vals (group-by :time logs)))))
-    (as-> state
-      (let [t    (get-in state [:world :time])
-            logs (filter #(= t (get % :time)) (get-in state [:world :log]))
-            logs-viewed (get-in state [:world :logs-viewed] 1)]
-        (log/info "logs" logs)
-        (as-> state state
-          (assoc-in state [:world :logs-viewed] 1)
-          (if (and (> (count logs) 1)
-                   (= logs-viewed 1))
-            (rw/assoc-current-state state :more-log)
-            state))))))
+      (assoc-in [:world :log-idx] 0)
+      (update-in [:world :log]
+        (fn [logs]
+          (log/info "updating :world :log. logs" logs)
+          (vec
+            (mapcat
+              (fn [logs-with-same-time]
+                (if (= (-> logs-with-same-time first :time) now)
+                  (coalesce-log-group logs-with-same-time)
+                   logs-with-same-time))
+              (partition-by (juxt :time :color) logs))))))))

 (defn get-hungrier-and-thirstier
   "Increase player's hunger."
@@ -2568,6 +2581,8 @@
                            \T          [identity               :talk            true]
                            \m          [identity               :log             false]
                            \?          [identity               :help-controls   false]
+                           \/          [scroll-log-up          :normal          false]
+                           \*          [scroll-log-down        :normal          false]
                            \r          [repeat-commands        identity         false]
                            \0          [(fn [state]
                                           (-> state
@@ -2753,9 +2768,6 @@
                            :down       [close-down             :normal          true]
                            :up         [close-up               :normal          true]
                            :right      [close-right            :normal          true]}
-               :more-log  {:enter      [scroll-log             identity         false]
-                           :escape     [scroll-log             identity         false]
-                           :space      [scroll-log             identity         false]}
                :log       {:else       [pass-state             :normal          false]}
                :rescued   {\y          [identity               :start-inventory false]
                            \n          [(constantly nil)       :normal          false]}
@@ -2832,8 +2844,6 @@
                           (cond
                             (= current-state :normal)
                               (assoc-in state [:world  :command-seq] [keyin])
-                            (contains? (hash-set current-state new-state) :more-log)
-                              state
                             :else
                               (rc/conj-in state [:world :command-seq] keyin))
                           (assoc-in state [:world :command-seq] command-seq))
@@ -2874,7 +2884,8 @@
                   ;; update visibility
                   (update-visibility)
                   ;; add will-to-live flavor message
-                  (log-will-to-live-flavor wtl))
+                  (log-will-to-live-flavor wtl)
+                  (coalesce-logs))
                 state))
             (update-quests)
             (as-> state
@@ -2913,21 +2924,13 @@
                              (log/info "Done uploading save file")
                              (catch Exception e
                                (log/error "Caught exception while uploading save" e))))))
-                     (doseq [file (filter (fn [file] (re-matches #".*edn" (.getName file))) (file-seq (io/file "save")))]
-                       (log/info "Deleting" file)
-                       (.delete file)))
+                     ;; delete the save game on player death
+                     (delete-save-game))
                   (-> state
                     (update-in [:world :player :status]
                      (fn [status]
                        (disj status :dead)))
                     (rw/assoc-current-state :dead)))
-                state))
-                  ;; delete the save game on player death
-            ;; only try to start log scrolling if the state we were just in was not more-log
-            (as-> state
-              (if (and current-state
-                       (not (contains? #{:dead :more-log} current-state)))
-                (init-log-scrolling state)
                 state))))
       state)))


Do hash integrity checks on fetched values.

--- src/cljx/geschichte/sync.cljx
+++ src/cljx/geschichte/sync.cljx
@@ -4,6 +4,7 @@
               [konserve.protocols :refer [IAsyncKeyValueStore -assoc-in -get-in -update-in]]
               [geschichte.debug-channels :as debug]
               [clojure.set :as set]
+              [hasch.core :refer [uuid uuid?]]
               [geschichte.platform-data :refer [diff]]
               [geschichte.platform :refer [client-connect!]]
               #+clj [clojure.core.async :as async
@@ -183,8 +184,14 @@
                  (>! out {:topic :fetch
                           :ids nc
                           :peer pn})
-                 ;; TODO check hash
-                 (doseq [[trans-id val] (:values (<! fetched-ch))] ;; TODO timeout
+
+                 (doseq [[trans-id val] (:values (<! fetched-ch))]
+                   (when (and (uuid? trans-id) (not= trans-id (uuid val)))
+                     (let [msg (str "CRITICAL: Fetched ID:" trans-id
+                                    "does not match HASH" (uuid val)
+                                    "for value" val)]
+                       #+clj (throw (IllegalStateException. msg))
+                       #+cljs (throw msg)))
                    (<! (-assoc-in store [trans-id] val))))

                (>! out {:topic :meta-pubed


Make 'Add New Project' link more prominent pending dashboard redesign

--- src/clojars/web/dashboard.clj
+++ src/clojars/web/dashboard.clj
@@ -40,8 +40,8 @@
   (html-doc account "Dashboard"
     [:div.light-article.col-md-6
      [:h1 (str "Dashboard (" account ")")]
+     [:h3 (link-to "http://wiki.github.com/ato/clojars-web/pushing" "Add New Project")]
      [:h2 "Your projects"]
      (unordered-list (map jar-link (jars-by-username account)))
-     (link-to "http://wiki.github.com/ato/clojars-web/pushing" "add new project")
      [:h2 "Your groups"]
      (unordered-list (map group-link (find-groupnames account)))]))


Make predicates public, rename within-with-activity? to has-*activity*?

--- src/clojure/neko/activity.clj
+++ src/clojure/neko/activity.clj
@@ -30,13 +30,13 @@
                *activity* activity#]
        ~@body)))

-(defn- activity?
+(defn activity?
   "Determines whether the argument is an instance of Activity."
   [x]
   (instance? Activity x))

-(defn- within-with-activity?
-  "Ensures that the function is within a valid with-activity form."
+(defn has-*activity*?
+  "Ensures that the calling context has a valid *activity* var."
   []
   (and (bound? #'*activity*)
        (activity? *activity*)))
@@ -55,7 +55,7 @@
   omitted."
   ([id-or-name]
    {:pre  [(resolvable? id-or-name)
-           (within-with-activity?)]
+           (has-*activity*?)]
     :post [(or (nil? %)
                (instance? View %))]}
    (-find-view *activity* id-or-name))
@@ -104,7 +104,7 @@
   [activity & features]
   {:pre  [(or (activity? activity)
               (and (keyword? activity)
-                   (within-with-activity?)))
+                   (has-*activity*?)))
           (every? keyword? features)]
    :post [%
           (every? (fn [x] (instance? Boolean x)) %)]}


Add function to create fragments

Add function to create fragments

--- src/clojure/neko/activity.clj
+++ src/clojure/neko/activity.clj
@@ -13,8 +13,10 @@
   "Utilities to aid in working with an activity."
   {:author "Daniel Solano Gómez"}
   (:import android.app.Activity
-           android.view.View)
-  (:use neko.-utils))
+           android.view.View
+           android.app.Fragment)
+  (:use [neko.ui :only [make-ui]]
+        neko.-utils))

 (def
   ^{:doc "The current activity to operate on."
@@ -183,3 +185,15 @@
                       (~func ~'this))))
               [:on-start :on-restart :on-resume
                :on-pause :on-stop :on-destroy]))))
+
+(defn simple-fragment
+  "Creates a fragment which contains the specified view. If a UI tree
+  was provided, it is inflated and then set as fragment's view."
+  ([context tree]
+     (simple-fragment (make-ui context tree)))
+  ([view-or-tree]
+     (proxy [Fragment] []
+       (onCreateView [inflater container bundle]
+         (if (instance? View view-or-tree)
+           view-or-tree
+           (make-ui view-or-tree))))))


remove debug print stmts

remove debug print stmts

--- pigpen-cascading/src/main/clojure/pigpen/cascading/runtime.clj
+++ pigpen-cascading/src/main/clojure/pigpen/cascading/runtime.clj
@@ -41,23 +41,19 @@
 (defmethod pigpen.runtime/pre-process [:cascading :frozen-with-nils]
            [_ _]
   (fn [args]
-    (println "preprocess frozen-with-nils" args)
     (mapv #(thaw (.getBytes %)) args)))

 (defmethod pigpen.runtime/pre-process [:cascading :frozen]
            [_ _]
   (fn [args]
-    (println "preprocess frozen" args)
     (mapv hybrid->clojure args)))

 (defmethod pigpen.runtime/post-process [:cascading :frozen-with-nils]
            [_ _]
   (fn [args]
-    (println "postprocess frozen-with-nils" args)
     (mapv cs-freeze args)))

 (defmethod pigpen.runtime/post-process [:cascading :native-key-frozen-val]
            [_ _]
   (fn [[key value]]
-    (println "postprocess native-key-frozen-val" [key value])
     [key (cs-freeze value)]))


Add new test cases for build-from-url.

Add new test cases for build-from-url.

--- test/circle/backend/build/test_config.clj
+++ test/circle/backend/build/test_config.clj
@@ -39,21 +39,61 @@
 (fact "template/find works with strings"
   (circle.backend.build.template/find "build") => truthy)

-(fact "build-from-url works for inferred"
-  (let [project test/test-project
+(fact "build-from-url works"
+  (let [project (test/test-project)
         vcs_revision "78f58846a049bb6772dcb298163b52c4657c7d45"
         b (build-from-url (-> project :vcs_url)
                              :vcs-revision vcs_revision
                              :job-name :build)]
-    (ref? b) => true
-    (-> @b) => (contains {:vcs_url string?
-                          :vcs_revision "78f58846a049bb6772dcb298163b52c4657c7d45"
-                          :node anything
-                          :parents seq?
-                          :build_num number?
+    b => ref?
+    @b => (contains {:vcs_url string?
+                     :vcs_revision "78f58846a049bb6772dcb298163b52c4657c7d45"
+                     :node anything
+                     :parents (contains string?)
+                     :subject string?
+                     :committer_date #"\d+"
+                     :build_num pos?
+                     :vcs-private-key string?})

-                          })
+    (-> @b :actions) => () ; no steps inferred
+
     (validate @b) => nil))
+
+(fact "build-from-url :job-name :deploy works"
+  (let [project (test/circle-project)
+        b (build-from-url (-> project :vcs_url)
+                         :job-name :deploy)]
+    @b => (contains {:vcs_url "https://github.com/arohner/CircleCI"
+                     :job-name :deploy})
+    (-> @b :actions) => (contains [(contains {:name "start nodes"
+                                              :type :infrastructure
+                                              :source :template})
+                                   (contains {:name #"nginx"
+                                              :source :spec})]
+                                  :gaps-ok)))
+
+(fact "build-from-url :infer flag works"
+  (let [project (test/circle-project)
+
+        b (build-from-url (-> project :vcs_url)
+                          :infer true)]
+    (-> @b :actions) =not=> (contains {:name #"nginx"})
+    (-> @b :actions) =not=> (contains {:source :spec})
+
+    (-> @b :actions) =contains=> {:name #"bundle install"
+                                  :source :inferred}))
+
+
+
+
+
+(fact "build-from-url builds from database"
+  (let [project (test/partially-inferred-project)
+        b (build-from-url (-> project :vcs_url))]
+    (-> @b :actions) =contains=> {:name "echo a" :type :test :source :spec}
+    (-> @b :actions) =not=> (contains {:type :setup :source :inferred})))
+
+

 (fact "build-from-json works"
   (let [build (build-from-json test/circle-dummy-project-json)]
@@ -61,7 +101,7 @@
     (-> @build :vcs_revision) => "78f58846a049bb6772dcb298163b52c4657c7d45"))

 (fact "build-from-url works for yaml configs"
-  (build-from-url "https://github.com/arohner/CircleCI") => map?)
+  (build-from-url "https://github.com/arohner/CircleCI") => ref?)

 (fact "parse-spec-actions support different kinds of newline"
   (-> :setup ((parse-spec-actions {:setup "1\n2"}))) => (maps-containing {:name "1"} {:name "2"})
@@ -83,19 +123,4 @@
     (-> @build :node :username) => "ubuntu"
     (-> @build :node :public-key) => #"^ssh-rsa"
     (-> @build :node :private-key) => #"BEGIN RSA PRIVATE KEY"
-    (validate @build) => nil))
-
-(tabular
- (fact "build-from-url works"
-   (do
-     (test/ensure-project {:vcs_url ?url})
-     (infer-build-from-url ?url)) => ref?)
- ?url
- "https://github.com/arohner/CircleCI"
- "https://github.com/arohner/circle-dummy-project")
-
-(tabular
- (fact "infer project name works"
-   (infer-project-name ?url) => ?expected)
- ?url ?expected
- "https://github.com/rails/rails.git" "rails")
+    (validate @build) => nil))


Added test for apply-betas, per #233

Added test for apply-betas, per #233

--- test/clj/forma/hadoop/jobs/forma_test.clj
+++ test/clj/forma/hadoop/jobs/forma_test.clj
@@ -16,7 +16,8 @@
         [midje sweet cascalog]
         [clojure.string :only (join)]
         [forma.hadoop.pail :only (to-pail split-chunk-tap)]
-        [forma.hadoop.predicate :as p])
+        [forma.hadoop.predicate :as p]
+        [forma.ops.classify :only (beta-dict)])
   (:require [forma.testing :as t]
             [forma.thrift :as thrift]
             [forma.utils :as u]))
@@ -341,3 +342,19 @@
                           0.3516091392518591 0.07849384810832613
                           0.3908570303909329 0.11774050517175123
                           0.43010312243974663 0.15698786428781983]]]))
+
+(fact
+  "Test `apply-betas`"
+  (let [forma-val (thrift/FormaValue* (thrift/FireValue* 0 0 0 0) 1. 2. 3. 4.)
+        neighbor-val (thrift/NeighborValue* (thrift/FireValue* 1 0 0 1) 1 1. 2. 3. 4. 5. 6. 7. 8.)
+        src [[1 0 forma-val neighbor-val]
+             [2 1 forma-val neighbor-val]]
+        betas (beta-dict [["500" 0 (vec (repeat 21 0.5))]
+                          ["500" 1 (vec (repeat 21 0.75))]])]
+    (<- [?id ?prob]
+        (src ?id ?eco ?forma-val ?neighbor-val)
+        (apply-betas [betas] ?eco ?forma-val ?neighbor-val :> ?prob)))
+  => (produces [[1 0.9999999999771026]
+                [2 1.0]]))
+
+


More elegant optional injections in profiles.clj

Resolves #62.

--- profiles.clj
+++ profiles.clj
@@ -83,44 +83,35 @@
                                          {:url "https://clojars.org/repo/"}]]
                                        args)))))

-                        ;; For some reason, Leiningen tries to resolve every unquoted
-                        ;; symbol in the :injections code, even the ones that wouldn't
-                        ;; be resolved normally (e.g. the vinyasa.inject/in symbol
-                        ;; inside the when form). So to prevent it from choking on the
-                        ;; potentially nonexistent symbol inside the when block we have
-                        ;; to use this hilariously ridiculous eval hack.
-                        (when (resolve 'vinyasa.inject/in)
-                          (eval
-                            `(~(symbol "vinyasa.inject/in")
-                              ~'[alembic.still distill lein load-project])))]}
+                        (when-let [inject (resolve 'vinyasa.inject/inject)]
+                          ;; We have to use extra brackets because of a bug
+                          ;; in vinyasa. See https://github.com/zcaudate/vinyasa/pull/31
+                          (inject '[[alembic.still distill lein load-project]]))]}

  :pull {:dependencies [;; Pull dependencies from Clojars in the REPL
                        [im.chit/vinyasa.maven "0.4.7"]]

-        :injections [;; See :alembic profile for an explanation of this hack.
-                     (when (resolve 'vinyasa.inject/in)
-                       (eval
-                         `(~(symbol "vinyasa.inject/in")
-                           ~'[vinyasa.maven pull])))]}
+        :injections [(when-let [inject (resolve 'vinyasa.inject/inject)]
+                       ;; We have to use extra brackets because of a bug
+                       ;; in vinyasa. See https://github.com/zcaudate/vinyasa/pull/31
+                       (inject '[[vinyasa.maven pull]]))]}

  :reflection {:dependencies [;; Convenient reflection functions
                              [im.chit/vinyasa.reflection "0.4.7"]]

-              :injections [;; See :alembic profile for an explanation of this hack.
-                           (when (resolve 'vinyasa.inject/in)
-                             (eval
-                               `(~(symbol "vinyasa.inject/in")
-                                 ~'clojure.core
-                                 ~'[vinyasa.reflection .& .> .? .* .% .%>])))]}
+              :injections [(when-let [inject (resolve 'vinyasa.inject/inject)]
+                             ;; We have to use extra brackets because of a bug
+                             ;; in vinyasa. See https://github.com/zcaudate/vinyasa/pull/31
+                             (inject '[clojure.core
+                                       [vinyasa.reflection .& .> .? .* .% .%>]]))]}

  :refresh {:dependencies [;; Properly refresh a dirty namespace
                           [org.clojure/tools.namespace "0.2.11"]]

-           :injections [;; See :alembic profile for an explanation of this hack.
-                        (when (resolve 'vinyasa.inject/in)
-                          (eval
-                            `(~(symbol "vinyasa.inject/in")
-                              ~'[clojure.tools.namespace.repl refresh refresh-all])))]}
+           :injections [(when-let [inject (resolve 'vinyasa.inject/inject)]
+                          ;; We have to use extra brackets because of a bug
+                          ;; in vinyasa. See https://github.com/zcaudate/vinyasa/pull/31
+                          (inject '[[clojure.tools.namespace.repl refresh refresh-all]]))]}

  ;; END profiles with optional injections


Updated repl util to support new shutdown handling

--- test/puppetlabs/master/testutils/repl.clj
+++ test/puppetlabs/master/testutils/repl.clj
@@ -30,10 +30,14 @@
                          :webserver {:client-auth "want"
                                      :ssl-host    "localhost"
                                      :ssl-port    8140}})]
-              (tka/init app)))))
+              (tka/init app))))
+  (alter-var-root #'system tka/init)
+  (tka/check-for-errors! system))

 (defn start []
-  (alter-var-root #'system tka/start))
+  (alter-var-root #'system
+                  (fn [s] (if s (tka/start s))))
+  (tka/check-for-errors! system))

 (defn stop []
   (alter-var-root #'system


Update imports in repl user ns.

Update imports in repl user ns.

--- dev/user.clj
+++ dev/user.clj
@@ -4,8 +4,7 @@
     [byte-streams :as bytes :refer [bytes=]]
     (blocks
       [core :as block]
-      [data :as data]
-      [util :as util])
+      [data :as data])
     (blocks.store
       [memory :refer [memory-store]]
       [file :refer [file-store]]
@@ -13,6 +12,9 @@
     [clojure.java.io :as io]
     [clojure.repl :refer :all]
     [clojure.string :as str]
+    [clojure.test.check :as check]
+    [clojure.test.check.generators :as gen]
+    [clojure.test.check.properties :as prop]
     [multihash.core :as multihash])
   (:import
     blocks.data.Block
@@ -24,6 +26,10 @@
 (try (require '[clojure.tools.namespace.repl :refer [refresh]]) (catch Exception e nil))

+(def test-blocks
+  (tests/generate-blocks! 10 1024))
+
+
 (def tbs
   "Temporary block store in target."
   (file-store "target/blocks"))


(maint) update postgres error message on concurrent fact update

After the last rollup from stable we ended up with an incorrect rollback error
message on postgres. The new error still indicates a rollback.

--- test/puppetlabs/puppetdb/command_test.clj
+++ test/puppetlabs/puppetdb/command_test.clj
@@ -718,11 +718,8 @@

           (test-msg-handler new-facts-cmd publish discard-dir
             (reset! second-message? true)
-            (is (re-matches
-                  (if (sutils/postgres?)
-                    #"(?sm).*ERROR: could not serialize access due to concurrent update.*"
-                    #".*BatchUpdateException.*(rollback|abort).*")
-                  (extract-error-message publish))))
+            (is (re-matches #".*BatchUpdateException.*(rollback|abort).*"
+                            (extract-error-message publish))))
           @fut
           (is (true? @first-message?))
           (is (true? @second-message?)))))))


Add a `testing`

Add a `testing`

--- test/refactor_nrepl/integration_tests.clj
+++ test/refactor_nrepl/integration_tests.clj
@@ -1,5 +1,5 @@
 (ns refactor-nrepl.integration-tests
-  (:require [clojure.test :refer [deftest is use-fixtures]]
+  (:require [clojure.test :refer [deftest is use-fixtures testing]]
             [nrepl.server :as nrepl]
             [refactor-nrepl middleware
              [analyzer :as analyzer]
@@ -36,15 +36,15 @@
                               :line 6 :column 19
                               :name "foo" :dir test-project-dir)
         result (remove keyword? response)]
-
-    (is (= 3 (count result)) (format "expected 3 results but got %d" (count result)))
-    (is (every? (partial re-matches #"(?s).*(one|two)\.clj.*") result) "one.clj or two.clj not found in result")
-
-    (is (some (partial re-matches #"(?s).*one.clj \[2\].*") result) "call of foo not found in ns com.example.one")
-
-    (is (some (partial re-matches #"(?s).*one.clj \[6\].*") result) "call of foo not found in ns com.example.one")
-
-    (is (some (partial re-matches #"(?s).*two.clj \[3\].*") result) "def of foo not found in ns com.example.two")))
+    (testing (pr-str result)
+      (is (= 3 (count result)) (format "expected 3 results but got %d" (count result)))
+      (is (every? (partial re-matches #"(?s).*(one|two)\.clj.*") result) "one.clj or two.clj not found in result")
+
+      (is (some (partial re-matches #"(?s).*one.clj \[2\].*") result) "call of foo not found in ns com.example.one")
+
+      (is (some (partial re-matches #"(?s).*one.clj \[6\].*") result) "call of foo not found in ns com.example.one")
+
+      (is (some (partial re-matches #"(?s).*two.clj \[3\].*") result) "def of foo not found in ns com.example.two"))))

 (defn ns-ast-throw-error-for-five [^String content]
   (if (.contains content "com.example.five")
@@ -60,14 +60,16 @@
                                 :name "foo" :dir test-project-dir)
           result (remove keyword? response)]

-      (is (= 3 (count result)) (format "expected 3 results but got %d" (count result)))
-      (is (every? (partial re-matches #"(?s).*(one|two)\.clj.*") result) "one.clj or two.clj not found in result")
-
-      (is (some (partial re-matches #"(?s).*one.clj \[2\].*") result) "call of foo not found in ns com.example.one")
-
-      (is (some (partial re-matches #"(?s).*one.clj \[6\].*") result) "call of foo not found in ns com.example.one")
-
-      (is (some (partial re-matches #"(?s).*two.clj \[3\].*") result) "def of foo not found in ns com.example.two"))))
+      (testing (pr-str result)
+
+        (is (= 3 (count result)) (format "expected 3 results but got %d" (count result)))
+        (is (every? (partial re-matches #"(?s).*(one|two)\.clj.*") result) "one.clj or two.clj not found in result")
+
+        (is (some (partial re-matches #"(?s).*one.clj \[2\].*") result) "call of foo not found in ns com.example.one")
+
+        (is (some (partial re-matches #"(?s).*one.clj \[6\].*") result) "call of foo not found in ns com.example.one")
+
+        (is (some (partial re-matches #"(?s).*two.clj \[3\].*") result) "def of foo not found in ns com.example.two")))))

 (deftest test-shouldnt-find-str-in-assert
   (let [transport (connect :port 7777)


postings list stored as vector instead of string

--- src/help_me_im_dumb/index.clj
+++ src/help_me_im_dumb/index.clj
@@ -21,7 +21,7 @@
 (defn docid->url
   [docid]
   (-> (some
-       #(when (.startsWith % docid) %)
+       #(when (.startsWith % (str docid)) %)
        (line-seq (io/reader URL-MAPPING-FILENAME)))
       (s/split #"\t")
       second))
@@ -32,8 +32,7 @@
                 (let [postings-map (spicerack/open-hashmap db POSTINGS-LIST-DB)]
                   (get postings-map term)))]
     (if (some? plist)
-      (-> plist
-          (s/split #";"))
+      plist
       '())))

 (defn create-indicies
@@ -123,7 +122,7 @@
                 (str term "\t" (count (distinct postings)) "\n"))
         (spicerack/put!
          postings-list-map
-         term (clojure.string/join ";" postings))))))
+         term postings)))))

 (defn write-url-mapping-to-file
   [url-seq]


force inputs of type 'password' to be class :pass

--- src/hypertext_ray/finders.clj
+++ src/hypertext_ray/finders.clj
@@ -100,10 +100,10 @@

 (defn classify-inputs [form & flags]
   (for [input (find-elements-under form {:tag :input})]
-    {:class (apply classify-element input input-re-map flags)
-     :text (text input)
-     :value (value input)
-     :xpath (xpath input) }))
+    (if #(= "password" (attribute input :type))
+     {:class :pass :text (text input) :value (value input) :xpath (xpath input) }
+     {:class (apply classify-element input input-re-map flags)
+      :text (text input) :value (value input) :xpath (xpath input)})))

 (defn classify-form-inputs [form]
   (for [input (find-elements-under form {:tag :input})]


CMR-1321: Address review comments.

CMR-1321: Address review comments.

--- common-lib/src/cmr/common/jobs.clj
+++ common-lib/src/cmr/common/jobs.clj
@@ -148,7 +148,7 @@
       (qs/delete-job scheduler (qj/key job-key)))
     (qs/schedule scheduler quartz-job trigger)
     true
-    (catch Throwable e
+    (catch Exception e
       (warn e)
       false)))

@@ -167,7 +167,12 @@
     (loop [max-tries 3]
       (when-not (try-to-schedule-job scheduler job-key quartz-job trigger)
         (if (pos? max-tries)
-          (recur (dec max-tries))
+          (do
+            (warn (format "Failed to schedule job [%s]. Retrying." job-key))
+            ;; Random sleep time to make it less likely that two nodes try to recreate the job
+            ;; at the same time. Sleeps between 0.5 seconds and 3 seconds.
+            (Thread/sleep (+ 500 (rand-int 2500)))
+            (recur (dec max-tries)))
           (warn (format "All retries to schedule job [%s] failed." job-key)))))))

 (defprotocol JobRunner


Fix wrong reference to EventType.

Fix wrong reference to EventType.

--- src/bide/core.cljs
+++ src/bide/core.cljs
@@ -27,7 +27,8 @@
   (:require [bide.impl.router :as rtr]
             [clojure.string :as str]
             [goog.events :as e])
-  (:import goog.history.Html5History))
+  (:import goog.history.Html5History
+           goog.history.EventType))

 ;; --- Protocols

@@ -151,7 +152,7 @@
                         (.setEnabled true)))
             initial-token (-initial-token history)
             initial-loc (-match initial-token)]
-        (e/listen history History.EventType.NAVIGATE -on-navigate)
+        (e/listen history EventType.NAVIGATE -on-navigate)
         (.replaceToken history initial-token)
         (apply on-navigate initial-loc)
         (specify! router


Create debuggable mixin

Create debuggable mixin

--- src/bolt/core.cljs
+++ src/bolt/core.cljs
@@ -68,6 +68,26 @@
     :ui.search      (handle-search-result app event-data)
     (.log js/console "No event found for" event event-data)))

+;; UI debugging
+(def dom->component (atom {}))
+
+;; Mixin to debug state for component by selector
+;; Just drop it on any defc e.g. < debuggable
+(def debuggable
+  {:did-mount (fn [state]
+                ;; Save component since another mixin may change state later
+                (when-let [dom (.getDOMNode (:rum/react-component state))]
+                  (swap! dom->component assoc dom (:rum/react-component state)))
+                state)})
+
+(defn selector->state [selector]
+  (if-let [component (cljs.core/get @dom->component (js/document.querySelector selector))]
+    @(aget (.-props component) ":rum/state")
+    (cljs.core/println "No component found")))
+
+#_(selector->state "#app div")
+#_(selector->state "input")
+
 ;; UI

 (defn submit-search [e ch]


Create out-ch in outer goroutine.

Create out-ch in outer goroutine.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -3,7 +3,7 @@

 (ns cbfg.core
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]
-                   [cbfg.ago :refer [ago ago-loop achan-buf aput atake]])
+                   [cbfg.ago :refer [ago ago-loop achan-buf aclose aput atake]])
   (:require [clojure.string :as string]
             [cljs.core.async :refer [<! >! put! chan timeout merge]]
             [goog.dom :as gdom]
@@ -64,28 +64,32 @@

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

-(defn example-add [actx x y delay]
+(defn example-add [actx out-ch x y delay]
   (ago example-add actx
        (<! (timeout delay))
-       (+ x y)))
+       (aput example-add out-ch (+ x y))
+       (aclose example-add out-ch))
+  out-ch)

-(defn example-sub [actx x y delay]
+(defn example-sub [actx out-ch x y delay]
   (ago example-sub actx
        (<! (timeout delay))
-       (- x y)))
+       (aput example-sub out-ch (- x y))
+       (aclose example-sub out-ch))
+  out-ch)

-(def cmd-handlers {"add" (fn []
+(def cmd-handlers {"add" (fn [out-ch]
                            (let [x (js/parseInt (get-el-value "x"))
                                  y (js/parseInt (get-el-value "y"))
                                  fence (get-el-value "fence")
                                  delay (js/parseInt (get-el-value "delay"))]
-                             {:rq #(example-add % x y delay) :fence (= fence "1")})),
-                   "sub" (fn []
+                             {:rq #(example-add % out-ch x y delay) :fence (= fence "1")})),
+                   "sub" (fn [out-ch]
                            (let [x (js/parseInt (get-el-value "x"))
                                  y (js/parseInt (get-el-value "y"))
                                  fence (get-el-value "fence")
                                  delay (js/parseInt (get-el-value "delay"))]
-                             {:rq #(example-sub % x y delay) :fence (= fence "1")}))})
+                             {:rq #(example-sub % out-ch x y delay) :fence (= fence "1")}))})

 (defn vis-init []
   (let [cmds (merge [(listen (gdom/getElement "add") "click")
@@ -117,8 +121,8 @@
                                (recur (conj acc result))))]
            (ago-loop main-in w-actx []
                      (let [cmd (.-id (.-target (<! cmds)))
-                           cmd-handler ((get cmd-handlers cmd))]
-                       (aput main-in in cmd-handler)
+                           cmd-doer ((get cmd-handlers cmd) (achan-buf main-in 1))]
+                       (aput main-in in cmd-doer)
                        (recur)))))))

 (vis-init)


Whitespace.

Whitespace.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -40,11 +40,9 @@

 (defn vis-add-ch [vis ch first-taker-actx]
   (-> vis
-      (update-in [:chs ch] #(if (nil? %)
-                              {:id ((:gen-id vis))
-                               :msgs {}
-                               :first-taker-actx first-taker-actx}
-                              %))
+      (update-in [:chs ch] #(if % % {:id ((:gen-id vis))
+                                     :msgs {}
+                                     :first-taker-actx first-taker-actx}))
       (update-in [:chs ch :first-taker-actx] #(if % % first-taker-actx))))

 (def vis-event-handlers


Hide when assigned position is same as parent.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -240,18 +240,18 @@
                      cy (ch-y (:ch delta))]
                  (when (not= ay cy)
                    [(case (:delta delta)
-                      :put (when (get chs (:ch delta))
+                      :put (when (and (get chs (:ch delta)) (not= ay cy))
                              ["<g transform='translate(500," ay ")'>"
                               (vis-svg-line "arrow delta" 0 0 100 (- cy ay)) "</g>"])
-                      :take (when (get chs (:ch delta))
+                      :take (when (and (get chs (:ch delta)) (not= ay cy))
                               ["<g transform='translate(600," cy ")'>"
                                (vis-svg-line (str "arrow delta"
                                                   (when (not (:msg delta)) " close"))
                                              0 0 -100 (- ay cy)) "</g>"])
-                      :actx-start (when (> childy line-height)
+                      :actx-start (when (and (> childy line-height) (not= childy ay))
                                     ["<g transform='translate(30," ay ")'>"
                                      (vis-svg-line "arrow delta" 0 0 30 (- childy ay)) "</g>"])
-                      :actx-end (when (> childy line-height)
+                      :actx-end (when (and (> childy line-height) (not= childy ay))
                                   ["<g transform='translate(60," childy ")'>"
                                    (vis-svg-line "arrow delta close" 0 0 -40 0) "</g>"])
                       nil)


Always emit event html for better usability.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -310,6 +310,7 @@
               vis-last-html nil
               vis-last-svg nil]
       (let [[vis-next deltas after event-str] (<! render-ch)]
+        (set-el-innerHTML (str el-prefix "-event") event-str)
         (if after
           (let [vis-next-positions (atom {})
                 actx-ch-ch-infos (group-by #(:first-taker-actx (second %)) (:chs vis-next))]
@@ -319,8 +320,7 @@
                   vis-next-svg (apply str (flatten (vis-svg-actxs vis-next @vis-next-positions
                                                                   deltas true)))]
               (when (not= vis-next-html vis-last-html)
-                (set-el-innerHTML (str el-prefix "-html") vis-next-html)
-                (set-el-innerHTML (str el-prefix "-event") event-str))
+                (set-el-innerHTML (str el-prefix "-html") vis-next-html))
               (when (not= vis-next-svg vis-last-svg)
                 (set-el-innerHTML (str el-prefix "-svg") vis-next-svg))
               (recur vis-next @vis-next-positions vis-next-html vis-next-svg)))


Use mapv because map is lazy.

Use mapv because map is lazy.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -106,17 +106,17 @@
                     ; The ch-actions will be [[ch :take] [ch :put] ...].
                     ch-actions (map #(if (seq? %) [(first %) :put] [% :take])
                                     ch-bindings)]
-                (apply concat ; NOTE: mapcat doesn't seem to work.
-                       (map (fn [ch-action]
-                              (let [[ch action] ch-action]
-                                (swap! vis #(-> %
-                                                (vis-add-ch ch
-                                                            (when (= action :take) actx))
-                                                (assoc-in [:actxs actx :wait-chs ch]
-                                                          action)))
-                                (when (= action :put)
-                                  [[:msg-move msg :actx actx :ch ch]])))
-                            ch-actions))))
+                (apply concat
+                       (mapv (fn [ch-action]
+                               (let [[ch action] ch-action]
+                                 (swap! vis #(-> %
+                                                 (vis-add-ch ch
+                                                             (when (= action :take) actx))
+                                                 (assoc-in [:actxs actx :wait-chs ch]
+                                                           action)))
+                                 (when (= action :put)
+                                   [[:msg-move msg :actx actx :ch ch]])))
+                             ch-actions))))
     :after (fn [vis actx args]
              (let [[ch-bindings result] args
                    chs (map #(if (seq? %) (first %) %) ch-bindings)


Removed :gen-class form from utils, :gen-class should only be in the file containing the main function

--- src/cine/utils.clj
+++ src/cine/utils.clj
@@ -1,6 +1,5 @@
 (ns cine.utils
-  (:require [clojure.string :as str])
-  (:gen-class))
+  (:require [clojure.string :as str]))

 (defn month-to-num [^String month]
   (let [month-db {:january 1


Add main module functionality

Add main module functionality

--- src/clojure_pf.clj
+++ src/clojure_pf.clj
@@ -1 +1,41 @@
-(ns clojure-pf)
+(ns clojure-pf
+  "Packet socket/device context functions."
+  (:require [clojure-pf.data-link-type :as dlt]
+            [clojure-pf.native :as native]))
+
+(def ^:private ^:const default-options
+  "Default packet context options."
+  {:buffer-length   65536
+   :data-link-type  :null
+   :header-complete false
+   :immediate       false})
+
+(defn create-context
+  "Creates a packet socket/device context with the given interface
+  and option map."
+  ([interface]
+   (create-context interface {}))
+  ([interface options]
+   (let [options          (merge default-options options)
+         buffer-length    (:buffer-length options)
+         data-link-type   (or (dlt/to-code (:data-link-type options)) 0)
+         header-complete  (:header-complete options)
+         immediate        (:immediate options)
+         fd               (native/open interface
+                                       buffer-length
+                                       data-link-type
+                                       header-complete
+                                       immediate)]
+     (if fd
+       {:handle         fd
+        :buffer-length  buffer-length}))))
+
+(defn receive
+  "Receives possibly many destructured packets in a sequence."
+  [context]
+  (native/read (:handle context) (:buffer-length context)))
+
+(defn destroy-context
+  "Destroys a packet socket/device context."
+  [context]
+  (native/close (:handle context)))


fix cljs_eval mishandling reader errors

fix cljs_eval mishandling reader errors

--- src/main/shadow/cljs/repl.clj
+++ src/main/shadow/cljs/repl.clj
@@ -666,13 +666,19 @@

      (loop [state state]

-       (let [{:keys [eof?] :as read-result}
+       (let [{:keys [eof? error?] :as read-result}
              (read-one state reader opts)]

-         (if eof?
+         (cond
+           eof?
            state
-           (recur (process-read-result state read-result))))
-       ))))
+
+           error?
+           (throw (:ex read-result))
+
+           :else
+           (recur (process-read-result state read-result))
+           ))))))

 (defn process-input-stream
   "reads one form of the input stream and calls process-form"


removed all unused ab tests and added a multi variant ab test for a sanity check

--- src-cljs/frontend/state.cljs
+++ src-cljs/frontend/state.cljs
@@ -7,13 +7,12 @@
    ;; 2. If you change a test's options, you must also change the test's name
    ;; 3. Record your tests here: https://docs.google.com/a/circleci.com/spreadsheet/ccc?key=0AiVfWAkOq5p2dE1MNEU3Vkw0Rk9RQkJNVXIzWTAzUHc&usp=sharing
    :ab-test-definitions {:a_is_a [true false]
-                         :split_form [true false]
+                         :multi_test_equal_variants ["a" "b" "c" "d"]
+                         :updated-auth-page [true false]
                          :parallelism_button_design [true false]
-                         :pricing_button_green [true false]
                          :pay_now_button [true false]
                          :follow_notice [true false]
-                         :new_usage_queued_upsell [true false]
-                         :mention-github-permissions [true false]}
+                         :new_usage_queued_upsell [true false]}
    :changelog nil
    :environment "development"
    :settings {:projects {}            ; hash of project-id to settings


feat: lein: cider 0.11.0 version bump

feat: lein: cider 0.11.0 version bump

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -1,3 +1,3 @@
-{:user {:plugins [[cider/cider-nrepl "0.10.2"]]}
+{:user {:plugins [[cider/cider-nrepl "0.11.0"]]}
  :repl {:dependencies [[org.clojure/tools.nrepl "0.2.12"]]} ;emacs cider want specific repl <https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md#replacing-default-repl-dependencies>
  }


[lein] bump ultra

[lein] bump ultra

--- .lein/profiles.clj
+++ .lein/profiles.clj
@@ -17,8 +17,7 @@
                   [com.jakemccrary/lein-test-refresh "0.23.0"]

                   [lein-figwheel                     "0.5.18"]
-                  #_ ; breaks the repl
-                  [venantius/ultra                   "0.5.2"]]
+                  [venantius/ultra                   "0.6.0"]]

         :middleware [cider-nrepl.plugin/middleware
                      refactor-nrepl.plugin/middleware]


Refactor main: extract functionality to distinct functions.

--- src/dsbdp/main.clj
+++ src/dsbdp/main.clj
@@ -106,6 +106,71 @@
     "pcap-csv" (create-proc-fn sample-pcap-processing-definition-csv)
     nil))

+(defn prepare-in-data
+  [options]
+  (let [scenario (:scenario options)
+        in-data-arg (:in-data-arg options)
+        in-data (if (not (nil? in-data-arg))
+                  in-data-arg
+                  (condp (fn [^String v ^String s] (.startsWith s v)) scenario
+                    "no-op" 1
+                    "busy-sleep" [100000 100000 100000 100000]
+                    "factorial" 300N
+                    "opennlp-single" "This is a simple sentence."
+                    "opennlp-multi" (str
+                                      "This is a simple sentence. "
+                                      "The first example sentence is followed by another example sentence. "
+                                      "The second sentence is followed by another example sentence.")
+                    "pcap" pcap-byte-array-test-data
+                    "self-adaptive" 1
+                    "nil" nil))]
+    (println "in-data:" in-data)
+    in-data))
+
+(defn prepare-proc-fns
+  [scenario pipeline-length fn-mapping in-data]
+  (let [proc-fns (atom
+                   (condp = scenario
+                     "no-op" (create-no-op-proc-fns pipeline-length)
+                     "busy-sleep" (create-busy-sleep-proc-fns (count in-data))
+                     "factorial" [(fn [i _] (factorial i))]
+                     "factorial-inc" (create-factorial-proc-fns pipeline-length)
+                     "opennlp-single-inc" (utils/combine-proc-fns-vec
+                                            @fn-mapping
+                                            opennlp-single-sentence-inc-test-fns)
+                     "pcap-clj-map" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-clj-map)]
+                                      [(fn [i _] (pcap-fn i))])
+                     "pcap-clj-map-inc" (combine-proc-fns-vec
+                                          @fn-mapping
+                                          sample-pcap-processing-definition-clj-map)
+                     "pcap-java-map" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-java-map)]
+                                       [(fn [i _] (pcap-fn i))])
+                     "pcap-java-map-inc" (combine-proc-fns-vec
+                                           @fn-mapping
+                                           sample-pcap-processing-definition-java-map)
+                     "pcap-json" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-json)]
+                                   [(fn [i _] (pcap-fn i))])
+                     "pcap-json-inc" (combine-proc-fns-vec
+                                       @fn-mapping
+                                       sample-pcap-processing-definition-json)
+                     "pcap-csv" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-csv)]
+                                  [(fn [i _] (pcap-fn i))])
+                     "pcap-csv-inc" (combine-proc-fns-vec
+                                      @fn-mapping
+                                      sample-pcap-processing-definition-csv)
+                     "self-adaptive-low-throughput" (utils/combine-proc-fns-vec
+                                                      @fn-mapping
+                                                      synthetic-low-throughput-self-adaptivity-processing-fns)
+                     "self-adaptive-average-throughput" (utils/combine-proc-fns-vec
+                                                          @fn-mapping
+                                                          synthetic-average-throughput-self-adaptivity-processing-fns)
+                     "self-adaptive-high-throughput" (utils/combine-proc-fns-vec
+                                                       @fn-mapping
+                                                       synthetic-high-throughput-self-adaptivity-processing-fns)
+                     nil))]
+    (println "proc-fns:" proc-fns)
+    proc-fns))
+
 (defn -main [& args]
   (println "Starting dsbdp main...")
   (let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
@@ -118,65 +183,11 @@
           out-cntr (Counter.)
           delta-cntr (delta-counter)
           ^String scenario (:scenario options)
-          in-data-arg (:in-data options)
-          in-data (if (not (nil? in-data-arg))
-                    in-data-arg
-                    (condp (fn [^String v ^String s] (.startsWith s v)) scenario
-                      "no-op" 1
-                      "busy-sleep" [100000 100000 100000 100000]
-                      "factorial" 300N
-                      "opennlp-single" "This is a simple sentence."
-                      "opennlp-multi" (str
-                                        "This is a simple sentence. "
-                                        "The first example sentence is followed by another example sentence. "
-                                        "The second sentence is followed by another example sentence.")
-                      "pcap" pcap-byte-array-test-data
-                      "self-adaptive" 1
-                      "nil" nil))
-          _ (println "in-data:" in-data)
+          in-data (prepare-in-data options)
           fn-mapping (atom (:fn-mapping options))
           _ (println "fn-mapping:" @fn-mapping)
           pipeline-length (:pipeline-length options)
-          proc-fns (atom
-                     (condp = scenario
-                       "no-op" (create-no-op-proc-fns pipeline-length)
-                       "busy-sleep" (create-busy-sleep-proc-fns (count in-data))
-                       "factorial" [(fn [i _] (factorial i))]
-                       "factorial-inc" (create-factorial-proc-fns pipeline-length)
-                       "opennlp-single-inc" (utils/combine-proc-fns-vec
-                                              @fn-mapping
-                                              opennlp-single-sentence-inc-test-fns)
-                       "pcap-clj-map" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-clj-map)]
-                                        [(fn [i _] (pcap-fn i))])
-                       "pcap-clj-map-inc" (combine-proc-fns-vec
-                                            @fn-mapping
-                                            sample-pcap-processing-definition-clj-map)
-                       "pcap-java-map" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-java-map)]
-                                         [(fn [i _] (pcap-fn i))])
-                       "pcap-java-map-inc" (combine-proc-fns-vec
-                                             @fn-mapping
-                                             sample-pcap-processing-definition-java-map)
-                       "pcap-json" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-json)]
-                                     [(fn [i _] (pcap-fn i))])
-                       "pcap-json-inc" (combine-proc-fns-vec
-                                         @fn-mapping
-                                         sample-pcap-processing-definition-json)
-                       "pcap-csv" (let [pcap-fn (create-proc-fn sample-pcap-processing-definition-csv)]
-                                    [(fn [i _] (pcap-fn i))])
-                       "pcap-csv-inc" (combine-proc-fns-vec
-                                        @fn-mapping
-                                        sample-pcap-processing-definition-csv)
-                       "self-adaptive-low-throughput" (utils/combine-proc-fns-vec
-                                                        @fn-mapping
-                                                        synthetic-low-throughput-self-adaptivity-processing-fns)
-                       "self-adaptive-average-throughput" (utils/combine-proc-fns-vec
-                                                            @fn-mapping
-                                                            synthetic-average-throughput-self-adaptivity-processing-fns)
-                       "self-adaptive-high-throughput" (utils/combine-proc-fns-vec
-                                                         @fn-mapping
-                                                         synthetic-high-throughput-self-adaptivity-processing-fns)
-                       nil))
-          _ (println "Proc-fns:" @proc-fns)
+          proc-fns (prepare-proc-fns scenario pipeline-length fn-mapping in-data)
           pipeline (if
                      (and
                        (not (nil? in-data))


change order of handle and outline

change order of handle and outline

--- src-cljs/frontend/components/canvas.cljs
+++ src-cljs/frontend/components/canvas.cljs
@@ -77,10 +77,49 @@
 (defn layer-group [layer {:keys [tool selected-eids selected-eid cast! db live?]}]
   (dom/g #js {:className (str "layer " (when (= :select tool) "selectable-group "))
               :key (str (:db/id layer) live?)}
-         ;; The order of selectable-layer and non-selectable-layer is important!
-         ;; If the non-selectable-layer comes last in the DOM it render above the selectable-layer,
-         ;; and it steal the pointer-events. I.e., you click right in the center of the stroke and nothing happens.
-         ;; But not for long, we're fixing this with pointer-events!
+         (svg-element selected-eids
+                      (assoc layer
+                        :onMouseDown
+                        #(do
+                           (.stopPropagation %)
+                           (let [group? (and (< 1 (count selected-eids))
+                                             (contains? selected-eids (:db/id layer)))]
+
+                             (cond
+                              (not= :select tool) nil
+
+                              (or (= (.-button %) 2)
+                                  (and (= (.-button %) 0) (.-ctrlKey %)))
+                              (cast! :layer-properties-opened {:layer layer
+                                                               :x (first (cameras/screen-event-coords %))
+                                                               :y (second (cameras/screen-event-coords %))})
+
+
+                              (and (.-altKey %) group?)
+                              (cast! :group-duplicated
+                                     {:group-eid selected-eid
+                                      :layer-eids (disj selected-eids selected-eid)
+                                      :x (first (cameras/screen-event-coords %))
+                                      :y (second (cameras/screen-event-coords %))})
+
+                              (and (.-altKey %) (not group?))
+                              (cast! :layer-duplicated
+                                     {:layer layer
+                                      :x (first (cameras/screen-event-coords %))
+                                      :y (second (cameras/screen-event-coords %))})
+
+                              group?
+                              (cast! :group-selected {:x (first (cameras/screen-event-coords %))
+                                                      :y (second (cameras/screen-event-coords %))
+                                                      :group-eid selected-eid
+                                                      :layer-eids (disj selected-eids selected-eid)})
+
+                              :else
+                              (cast! :layer-selected {:layer layer
+                                                      :x (first (cameras/screen-event-coords %))
+                                                      :y (second (cameras/screen-event-coords %))}))))
+                        :className "selectable-layer layer-handle"
+                        :key (str "selectable-" (:db/id layer))))
          (svg-element selected-eids (assoc layer
                                       :onMouseDown (cond
                                                     (and (= :text tool)
@@ -96,49 +135,6 @@
                                       :className (str "layer-outline "
                                                       (when (= :text tool) "editable"))
                                       :key (:db/id layer)))
-         (svg-element selected-eids
-                      (assoc layer
-                        :onMouseDown
-                        #(do
-                           (.stopPropagation %)
-                           (let [group? (and (< 1 (count selected-eids))
-                                             (contains? selected-eids (:db/id layer)))]
-
-                             (cond
-                              (not= :select tool) nil
-
-                              (or (= (.-button %) 2)
-                                  (and (= (.-button %) 0) (.-ctrlKey %)))
-                              (cast! :layer-properties-opened {:layer layer
-                                                               :x (first (cameras/screen-event-coords %))
-                                                               :y (second (cameras/screen-event-coords %))})
-
-
-                              (and (.-altKey %) group?)
-                              (cast! :group-duplicated
-                                     {:group-eid selected-eid
-                                      :layer-eids (disj selected-eids selected-eid)
-                                      :x (first (cameras/screen-event-coords %))
-                                      :y (second (cameras/screen-event-coords %))})
-
-                              (and (.-altKey %) (not group?))
-                              (cast! :layer-duplicated
-                                     {:layer layer
-                                      :x (first (cameras/screen-event-coords %))
-                                      :y (second (cameras/screen-event-coords %))})
-
-                              group?
-                              (cast! :group-selected {:x (first (cameras/screen-event-coords %))
-                                                      :y (second (cameras/screen-event-coords %))
-                                                      :group-eid selected-eid
-                                                      :layer-eids (disj selected-eids selected-eid)})
-
-                              :else
-                              (cast! :layer-selected {:layer layer
-                                                      :x (first (cameras/screen-event-coords %))
-                                                      :y (second (cameras/screen-event-coords %))}))))
-                        :className "selectable-layer layer-handle"
-                        :key (str "selectable-" (:db/id layer))))
          (when (:layer/ui-target layer)
            (let [invalid? (not (pos? (layer-model/count-by-ui-id @db (:layer/ui-target layer))))]
              ;; TODO: figure out what to do with this title


add back the mic-off icon

add back the mic-off icon

--- src-cljs/frontend/components/common.cljs
+++ src-cljs/frontend/components/common.cljs
@@ -129,6 +129,8 @@
    :pencil      {:paths [:stroke-pencil]}
    :ellipse     {:paths [:stroke-ellipse]}
    :mic         {:paths [:stroke-mic]}
+   :mic-off     {:paths [:stroke-mic
+                         :stroke-slash-backward]}
    :user        {:paths [:stroke-user]}
    :users       {:paths [:stroke-users]}
    :bullet      {:paths [:stroke-dot]}


fix phone link (relative url)

fix phone link (relative url)

--- src-cljs/frontend/components/common.cljs
+++ src-cljs/frontend/components/common.cljs
@@ -214,5 +214,5 @@
           [:a {:href "https://twitter.com/circleci"} "Twitter"]
           [:a {:href "mailto:sayhi@circleci.com"} "Email"]
           [:a {:href "https://www.hipchat.com/gjwkHcrD5"} "Support Chat"]
-          [:a {:href "https://circleci.com/about#contact"} "Phone"]
+          [:a {:href "/about#contact"} "Phone"]
           [:a {:href "https://goo.gl/maps/uhkLn"} "San Francisco, CA"]]]))


Final version with Storm 0.7.0

Final version with Storm 0.7.0

--- deploy/project.clj
+++ deploy/project.clj
@@ -12,5 +12,6 @@

   :dev-dependencies [
 		     [org.clojure/clojure "1.2.0"]
+		     [org.clojure/clojure-contrib "1.2.0"]
 		     [storm "0.7.0"]
                     ])


add bang! to #'mk-tmp-dir

add bang! to #'mk-tmp-dir

--- src/overtone/helpers/file.clj
+++ src/overtone/helpers/file.clj
@@ -195,7 +195,7 @@
         f (File. path)]
     (.exists f)))

-(defn mk-tmp-dir
+(defn mk-tmp-dir!
   "Creates a unique temporary directory on the filesystem. Typically in /tmp on
   *NIX systems. Returns a File object pointing to the new directory. Raises an
   exception if the directory couldn't be created after 10000 tries."


Une version refactorée du puzzle "Horse Racing Duals" de CodinGame en Clojure.

--- clojure/codingame/practice/easy/horse-racing-duals/src/horse_racing_duals/core.clj
+++ clojure/codingame/practice/easy/horse-racing-duals/src/horse_racing_duals/core.clj
@@ -2,30 +2,9 @@
   (:gen-class))

 (defn -main [& args]
-      (let [N (read) powers (atom (list))]
-           (loop [i N]
-                 (when (> i 0)
-                       (let [Pi (read)]
-                            (reset! powers (cons Pi @powers))
-                            (recur (dec i)))))
-
-           ; (binding [*out* *err*]
-           ;   (println "Debug messages..."))
-           (binding [*out* *err*]
-                    (println (str "powers : " @powers)))
-           ; Write answer to stdout
-           (let [sorted-powers (sort @powers)
-                 reverse-sorted-powers (reverse sorted-powers)
-                 shorten-sorted-powers (rest sorted-powers)
-                 shorten-reverse-sorted-powers (rest reverse-sorted-powers)]
-                (binding [*out* *err*]
-                         (println (str "sorted powers : " sorted-powers)))
-                (binding [*out* *err*]
-                         (println (str "reverse sorted powers : " reverse-sorted-powers)))
-                (binding [*out* *err*]
-                         (println (str "shorten sorted powers : " shorten-sorted-powers)))
-                (binding [*out* *err*]
-                         (println (str "shorten reverse sorted powers : " shorten-reverse-sorted-powers)))
-                (println (str (first (sort (map - shorten-sorted-powers (reverse shorten-reverse-sorted-powers)))))))))
-
-
+  (let [N (read)
+        powers (repeatedly N read)
+        sorted-powers (sort powers)
+        sorted-powers-by-pairs (partition 2 1 sorted-powers)
+        result (str (apply min (map #(- (second %) (first %)) sorted-powers-by-pairs)))]
+    (println result)))


make okta home configuratble

make okta home configuratble

--- src/clj/conference_rating/server.clj
+++ src/clj/conference_rating/server.clj
@@ -15,8 +15,8 @@
 (def cli-options
   ;; An option with a required argument
   [["-o" "--okta-active"]
-   ["-e" "--environment ENV" "Environment name, e.g. ci"
-    :default "local"]
+   ["-e" "--environment ENV" "Environment name, e.g. ci" :default "local"]
+   ["-oh" "--okta-home OKTA_HOME" "URL of Okta" :default "https://dev-133267-admin.oktapreview.com/"]
    ["-h" "--help"]])

 (defn error-msg [errors]
@@ -28,16 +28,16 @@
   (System/exit status))

-(defn do-wrap-okta [handler okta-active env]
+(defn do-wrap-okta [handler okta-active env okta-home]
   (let [config-res (io/resource (str "okta-" env "-config.xml"))]
     (println "initialize okta?" okta-active " config location: " config-res)
     (if okta-active
-      (wrap-okta handler {:okta-home "https://dev-133267-admin.oktapreview.com/" :okta-config config-res})
+      (wrap-okta handler {:okta-home okta-home :okta-config config-res})
       handler)))

-(defn start-server [port okta-active env]
+(defn start-server [port okta-active env okta-home]
   (let [app (-> (app (db-handler/connect))
-                (do-wrap-okta okta-active env)
+                (do-wrap-okta okta-active env okta-home)
                 (ring-logger/wrap-with-logger)
                 (session/wrap-session))]
     (run-jetty app {:port port :join? false})))
@@ -51,4 +51,4 @@
      (cond
        (:help options) (exit 0 (usage summary))
        errors (exit 1 (error-msg errors)))
-     (start-server port (:okta-active options) (:environment options))))
+     (start-server port (:okta-active options) (:environment options) (:okta-home options))))


Fixed vector nesting issue

Fixed vector nesting issue

--- src/clj/forma/postprocess/output.clj
+++ src/clj/forma/postprocess/output.clj
@@ -43,8 +43,8 @@
 Ex. (backward-looking-mavg 3 [1 2 3 4]) expands to [nil nil 1 2 3 4]. Nils are filtered out, so the output is effectively [(average [1]) (average [1 2]) (average [1 2 3]) (average 2 3 4)]"
   [window series]
   (let [expanded-ts (concat (repeat (dec window) nil) (flatten series))]
-    (vec-ify (map (comp float average (partial filter not-nil?))
-                  (partition window 1 expanded-ts)))))
+    (map (comp float average (partial filter not-nil?))
+                  (partition window 1 expanded-ts))))

 (defn mono-inc
   "Make a series of numbers monotonically increasing. Useful for retaining the maximum probability for a pixel over time.
@@ -52,7 +52,7 @@
 (mono-inc [3 4 34 34 23 1 34 13 35 35 ])
 ==> (3 4 34 34 34 34 34 34 35 35)"
   [series]
-  (vec-ify (cons (first series) (rest (reductions max series)))))
+  (cons (first series) (rest (reductions max series))))

 (defn dec->int100
   [coll]


Removed the root redirect

Removed the root redirect

--- src/clj/picflow_slideshow/server.clj
+++ src/clj/picflow_slideshow/server.clj
@@ -23,14 +23,11 @@
         "</html>")})

 (defn handler [request]
-  (if (= "/" (:uri request))
-      (response/redirect "/help.html")
-      (render-app)))
+      (render-app))

-(def app
+(def app
   (-> handler
     (resources/wrap-resource "public")))

 (defn -main [& args]
   (jetty/run-jetty app {:port 3001}))
-


Remove superfluous or in get-component-state

--- src/cljs/chocolatier/engine/ces.cljs
+++ src/cljs/chocolatier/engine/ces.cljs
@@ -90,7 +90,7 @@
    entity. NOTE: As a convenience, if state is not found it returns an empty
    hashmap."
   [state component-id entity-id]
-  (or (get-in state [:state component-id entity-id]) {}))
+  (get-in state [:state component-id entity-id] {}))

 (defn get-all-component-state
   [state component-id]


fix styling of phones list in step-6

fix styling of phones list in step-6

--- src/cljs/phonecat_re_frame/core.cljs
+++ src/cljs/phonecat_re_frame/core.cljs
@@ -89,8 +89,9 @@

 (defn phone-component
   [phone]
-  [:li {:class "thumbnail"}
-   [:a {:href (str "#/phones/" (:id phone))}
+  [:li {:class "thumbnail phone-listing"}
+   [:a {:href (str "#/phones/" (:id phone))
+        :class "thumb"}
     [:img {:src (:imageUrl phone)}]]
    [:a {:href (str "#/phones/" (:id phone))} (:name phone)]
    [:p (:snippet phone)]])
@@ -109,7 +110,7 @@
         search-input (re-frame/subscribe [:search-input])
         order-prop (re-frame/subscribe [:order-prop])]
     (fn []
-      [:ul {:class= "phones"}
+      [:ul {:class "phones"}
        (for [phone (->> @phones
                         (filter (partial matches-query? @search-input))
                         (sort-by (keyword @order-prop)))]


Log errors when invoking a subcommand

Log errors when invoking a subcommand

The main dispatcher scans available namespaces and dispatches to the
specified "-main" function. For example, running the "services"
subcommand would trigger loading of the "-main" function in the
"com.puppetlabs.puppetdb.cli.services" namespace.

However, if there was an error during the attempt to "require" that
namespace, it wouldn't be logged properly. This commit adds the
"require" step to the existing try/catch block.

--- src/com/puppetlabs/puppetdb/core.clj
+++ src/com/puppetlabs/puppetdb/core.clj
@@ -74,8 +74,8 @@

     (let [module (str ns-prefix subcommand)
           args   (rest args)]
-      (require (symbol module))
       (try
+        (require (symbol module))
         (apply (resolve (symbol module "-main")) args)
         (System/exit 0)
         (catch Throwable e